From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4438 invoked from network); 13 Jan 2021 03:02:04 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Jan 2021 03:02:04 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610506924; b=dV1b5oCJrw4cKUKLKkQDei+7VArqlIgYnFu8qUu3mNrcoDBvWpK8JGveYvTFVI50MY7D/xzDgg PdWkLFoupacDLwbIQO4CztNs1Z0p/iy8qLc3B2ep877uHI/u/MPNAyT5SrTzXofoQD5xPBQVI7 uyU9PxIWSZb+VadXQs8QdWDuRXFBrowOCtqjipDn6TtwVSArCFTEkP0ABcfdshIkH6gQcMVbto 5OSfgfRwzPT5WddRW62poKJp1bLhcxl8yVUuu+id6bYId2Go6QdNoYMzIvDn+IXLmi02TIGWdC J9J8q+plYtrddL7V3N6sCEUWa9EpSOzMxOQo6Qb976Kg7Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f42.google.com) smtp.remote-ip=209.85.222.42; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1610506924; bh=wY6aPhQvE+5vHfHgh60AbDAEo/YoC3cotLSFrF7zECw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ZkjKZh5PkbX52fBYcPiZEQwmcWh8qvCmaqmofAUPmgxhimI/UBr3JHnMyv10WOp9WzFTQkj7WZ H9oTMPbrlJ0uYrJAWgJrCUpTdNfZl3Raak6UKaQm7aYA9rKuItepk5mNsfcjGn0cZ6vGli5Dl8 XbzgwbMfqQu1K8bL0yNPd+g30hi+fMCMVBl3ElSsB5EDhu4pY/Np2XdwvjLFKSyccZCdUsHwpf pc9kQeoo8LB7z4V7N3HxZpoRnSutowfHTGZf6KbBcW7D/Ju8YRytXmwEcm0uIc8snldVwiiUm2 3WY5fSwP+0OoRnSYyYn6mg3SK91H6+qAmsp0b/Zt50p7/Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Xx1A5LmN1DZp/Br2LSl/u6zVAGMaNEIuSqYUwjRitB8=; b=z1ypbCxGWJyUImqQOkvEV2dpxD sFddfOnTo/odWnxjMHQ/3KLWhRCfKOxEjztU89tuxgoAWlcMSKi9czOrvuvOb6hu+0PyEQRJObDDo WKEfACC+ULxDMv9QVoK3wbP/vCBy0baH5Rlx0+3O1QMcniQ+fRaN04R18bPKMHDNLvD6tHgZTqCJq EOBm0uomYtw3hN6Kzrfa4qmWLwH9rhFDBI5q8vN7tydtuH3CvrFFm68Ft3+DbJU2dV9NBOYtZLKIm DoyHNOS/LWl/aubJ1Juf7grYX1QT+zo+nBDQ3Ik+6n3xiW82otzo+HNFqxG7sN0fc2p/RV/tzsITE CZ4x3gPg==; Received: from authenticated user by zero.zsh.org with local id 1kzWQ6-000CFS-8U; Wed, 13 Jan 2021 03:02:02 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f42.google.com) smtp.remote-ip=209.85.222.42; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ua1-f42.google.com ([209.85.222.42]:34840) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzWPl-000C7M-Gq; Wed, 13 Jan 2021 03:01:42 +0000 Received: by mail-ua1-f42.google.com with SMTP id y21so249751uag.2 for ; Tue, 12 Jan 2021 19:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xx1A5LmN1DZp/Br2LSl/u6zVAGMaNEIuSqYUwjRitB8=; b=dycgQohyJwhbfxfvrr74LqyPaITdWpN1SjJyT79yb+FibLsYdGg8rswN2Y1ci6urvf 9iQG4qcff50knB5XSTQD/p6ruKlNQcJcUeVHRn+KRgUfKVstAQS3RhVIacNcY/vGDUoB Mf7fFX9vM/siTIHIggfCy7WOo/bn1ZioZ6AI5A6L47a4JbqvboxmF+oMJ6aG8wxusz+o OVs2Xf61VoAapRNIljqFxd1n+GFxhSehClo/WN8rqHhiX8GKPJYfl6pm0lhvLCWetYcU evnTWVebYQTzY3ZqsYIeFThBDoXkJ62zUQkIPPEOi/sqxmnFuy09N7y6VCDkeGiVMyEj x0qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xx1A5LmN1DZp/Br2LSl/u6zVAGMaNEIuSqYUwjRitB8=; b=WZzcOLazwPR4dYE9tloEErwB6yf71e1ElyeABdBTPoFMi3/rnkPWdJOL7poFdE5yGn llmw3h3+4CggY0fCDTt0kaKShRr1b131Om+RZVGn8zXdT1g5EuJeK+eFm4RASR0j5RPT +YXamXcDy0qTwehCt3lX6YlfQk/nsE8Hd0/dWaG5FsJ1fNwtUhRGZOVMpz7n5gW/oHoJ xJNCOc+1SP3mL2OsdJJkvDKBWhmN9ixSqeIqKg9lX+k8pQj9yGvVwxcUbJqFUgx5skGR SmWkZkp+WPX4yl2ZQixFONsGiYwD6gKtQEvRlgrFKBlGnLWOKkPaGq2MrSUszUxaoj3Y xIxA== X-Gm-Message-State: AOAM530w6b6Z1ynETJ1KUjupBkOzy/eGB/QtSjhRFRAhVNWFamOrg72I p9EDkPVr6/2JFXd6CPGb6ar52dvxLbqBLp5YLCE= X-Google-Smtp-Source: ABdhPJzf5yB6yKeB1n7DpMMdpjiUMxNzV1Nc8HlaSK0B2UwOVl+/kKH7ixdUq9wtGopTo9DRwItVBxUQfNujzNArk94= X-Received: by 2002:ab0:61c8:: with SMTP id m8mr141156uan.84.1610506900325; Tue, 12 Jan 2021 19:01:40 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Devin Hussey Date: Tue, 12 Jan 2021 22:01:30 -0500 Message-ID: Subject: Re: [PATCH] Ignore EACCES when doing non-pure globbing To: Mikael Magnusson Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000b3c76f05b8bf5bf8" X-Seq: 47821 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --000000000000b3c76f05b8bf5bf8 Content-Type: text/plain; charset="UTF-8" I am abandoning this hack in favor of the next patch. On Tue, Jan 12, 2021, 9:14 PM Devin Hussey wrote: > Actually replied to the mailing list this time... > > >Have you considered just not unsetting caseglob? > > Brilliant solution. > "Doctor, it hurts when I do this." > "Then don't do that." > > As for the compliant version, here is a much more "polite" version which > also avoids the awkward checks if lock != NULL (at the cost of reformatting > O.o). > > /* Check for search permissions. If we don't have them, get out. */ > if (access(fn, X_OK) != 0) { > return; > } > /* Check for read permissions. If we have them, try to open the directory. > */ > if (access(fn, R_OK) == 0) { > DIR *lock = diropen(fn); > if (lock == NULL) > return; > > while (...) { ... } > closedir(lock); > } > if (subdirs) { ... } > > > % chmod 111 .. > % echo $PWD/* > /tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c > % chmod 000 .. > % echo $PWD/* > zsh: no matches found: /tmp/inaccessible/a/* > > This matches the POSIX behavior of requiring parent directories to be > searchable, and is a little more respectful to filesystem permissions. > > On Tue, Jan 12, 2021, 8:58 PM Devin Hussey wrote: > >> >Have you considered just not unsetting caseglob? >> >> Brilliant solution. >> "Doctor, it hurts when I do this." >> "Then don't do that." >> >> As for the compliant version, here is a much more "polite" version. >> >> This matches the behavior of the POSIX globs: with a non searchable >> directory, it returns no match, but doesn't require read access for parent >> directories. >> >> DIR *lock = NULL; >> >> /* Check for search permissions. If we don't have them, get out. */ >> if (access(fn, X_OK) != 0) { >> return; >> } >> /* Check for read permissions. If we have them, try to open the >> directory. */ >> if (access(fn, R_OK) == 0) { >> lock = diropen(fn); >> /* Error */ >> if (lock == NULL) >> return; >> } >> while (lock != NULL &&... >> >> % chmod 111 .. >> % echo $PWD/* >> /tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c >> % chmod 000 .. >> % echo $PWD/* >> zsh: no matches found: /tmp/inaccessible/a/* >> > --000000000000b3c76f05b8bf5bf8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I am abandoning this hack in favor of the next patch.
On T= ue, Jan 12, 2021, 9:14 PM Devin Hussey <husseydevin@gmail.com> wrote:
Actual= ly replied to the mailing list this time...=C2=A0

>Have you co= nsidered just not unsetting caseglob?

Brilliant solution.
"Doctor, it h= urts when I do this."
"Then don't do t= hat."

As for th= e compliant version, here is a much more "polite" version which a= lso avoids the awkward checks if lock !=3D NULL (at the cost of reformattin= g O.o).

/* Check for sea= rch permissions. If we don't have them, get out. */
if (access(fn, X_OK) !=3D 0) {
=C2=A0 =C2=A0 ret= urn;
}
/* Check for read perm= issions. If we have them, try to open the directory. */
if (access(fn, R_OK) =3D=3D 0) {
=C2=A0 =C2=A0 D= IR *lock =3D diropen(fn);
=C2=A0 =C2=A0 if (lock =3D= =3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
<= div dir=3D"auto">
=C2=A0 =C2=A0 while (...) { ..= . }
=C2=A0 =C2=A0 closedir(lock);
}
if (subdirs) { ... }
<= br>

% chmod 111 ..
=
% echo $PWD/*
/tmp/inaccessible/a/= a /tmp/inaccessible/a/b /tmp/inaccessible/a/c
% chmod 000 ..
% echo $PWD/*
zsh: no = matches found: /tmp/inaccessi= ble/a/*

This matches the POSIX behavior of requiring parent direct= ories to be searchable, and is a little more respectful to filesystem permi= ssions.=C2=A0

On Tue, Jan 12, 2021, 8:58 PM Devin Hussey <husseydevin@gmail.c= om> wrote:
>Have you considered just not unsetting caseglob?

Brilliant solution.
"Doctor, it hurts when I do this."
"Then don't do that."
As for the compliant version, here is a much more= "polite" version.

This matches the behavior of the POSIX globs: with a non searchable di= rectory, it returns no match, but doesn't require read access for paren= t directories.

DIR *lock= =3D NULL;

/* Check for = search permissions. If we don't have them, get out. */
if (access(fn, X_OK) !=3D 0) {
=C2=A0 =C2=A0 = return;
}
/* Check for read p= ermissions. If we have them, try to open the directory. */
if (access(fn, R_OK) =3D=3D 0) {
=C2=A0 =C2= =A0 lock =3D diropen(fn);
=C2=A0 =C2=A0 /* Error */<= /div>
=C2=A0 =C2=A0 if (lock =3D=3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
}
while (lock !=3D NULL &&...
=
% chmod 111 ..
% echo $P= WD/*
/tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c
% chmod 000 ..
% echo $PWD/*
zsh: no matches found: /tmp<= span style=3D"font-family:sans-serif">/inaccessible/a/*
--000000000000b3c76f05b8bf5bf8--