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 30839 invoked from network); 13 Jan 2021 02:15:00 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Jan 2021 02:15:00 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610504100; b=TTAG/+IN9wapRuUqcvtC33BO47Od7XQ8/QmscdjD7pbJoBPJ4b/gL4+iic383pOsPcn9nCPGAz FuO49Yp0/hKBRqjoFCq9MC70Q8lTIrrq/pn6/nxXPKa/AjgGjUFL0vggJZBK4C1gtF9Vf5MF0J sX9ZJkMDuMe2l7BhBNS8dX2pNGqMoPj/ucQ31kw91vtfEh1veXl1+sVTOUCkB6BWIbtg8rZikK EFUtvxCN1Hycnin01k58F/yHVOddXKtnKUrixYMHPjKKnVhR6Q6TMcxKrPUnAmMUqV36BZkZRx OPwVSUdzjrpCs2ob5UCirugHAznjSATwdTc15PCrrgNtuQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f45.google.com) smtp.remote-ip=209.85.222.45; 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=1610504100; bh=W4RklKj0/67iAfwCCqucozF4YrUzAl4ymN8iNiVMgHE=; 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=T8Aoq2tGbSSUQt5n/gTCSDDa13CPUwrfNlpYOsF0/dNhiU5fLHQggBEoFGwGpzEM9hTgtHYf9v 2O8xNb33g/+yB8ktvS/P5prWAPNet44SWfoNAtAVLhsKumrja/csVj/+60tI/gbws1Uw2IwvwF eljIP9rWHnOZY5OqvRxWNRMprAttpgLC8cLik02x9ShNGQk5KIsPMXWFPf+ZqsX4+MJnTBse3T uhcD0zliyHVl5cxM6iXF6b2zl1/x1oy6JyFc/VuyrDaO3PMzHL0qVtnGj0tU4WPGu+qDObXUBs rwly3wnT/x7BAjHiSQZQqDNvmNnnIj3L82BRTlmQPQNS/A==; 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=OQEM/vbKWd6DJywcxUhbBfesuG2UTOXGB7uGiQa/Yq4=; b=NVENdIwsBDp3uJLAkBq8wZYklb 0EXJtmxFV5T7X7+c3V5cTxaQBPZgdckv7xucEzq8t47YoVN4y1rt0z9KrkyiuvKMySHWfKG8Qv22s 1BftqrtwfpC6sX3gPdJz58wQD5frgv85qD4FugbEqNcKjxmIJJGY5WRdNBYlIvXP0BQmUG0I31+g3 gP3qBDZ3Tr77qAEVW0h4RwLvrjpmquXm/mbt4be1uffKV3pRyC9iFZj3n+Dvmr2W/UjxQlm3GWCHP Pc098cqvMM/6kbJmXVNVD0P9RDhGP9HCeplxKZ87WUb8n2VzRfN813ZlCXWRf6iPb2PMyHnhxKFwC SmcDQvFQ==; Received: from authenticated user by zero.zsh.org with local id 1kzVgW-000AMC-16; Wed, 13 Jan 2021 02:14:56 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f45.google.com) smtp.remote-ip=209.85.222.45; 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-f45.google.com ([209.85.222.45]:45955) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzVgC-000AE2-UM; Wed, 13 Jan 2021 02:14:38 +0000 Received: by mail-ua1-f45.google.com with SMTP id f16so202089uav.12 for ; Tue, 12 Jan 2021 18:14:36 -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=OQEM/vbKWd6DJywcxUhbBfesuG2UTOXGB7uGiQa/Yq4=; b=oJxVxigOpHZojzh6gvJgk101RI3zIac/U+Lsi6ztsYfFAAfDCIlmOKNX8ygQS/9Kr3 Nb7B8rsBkdKCharneZzfXMeEsS7Sv4b+ngEkM+2RIAkYMcMPTPPyE/ktG43I6oxRTVzN J6TnM4LpMJI6M/WVZSgVir1stpGbkC5v4b/saDQJ4fd5IMmTk43usXQ8e0pZRv/P7rtZ YWnNsqMyZiUbTmhaaVdrv8+SVHiT7cI6PXtrDOtCs3b1RhXicw4bUVDgnIHx4/Nsat1L ag/QybMuzcIY3jENhP8DnfyQB1j4JWtmPJ6ckvbT2x44+EQ0tWADG/oV/yXrmGs4ixTh H2fg== 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=OQEM/vbKWd6DJywcxUhbBfesuG2UTOXGB7uGiQa/Yq4=; b=Sj4EKxMzJOMW+lNLBpsyYfBfP3tyeVvukBDCkIeHQhkKwzHACBLVh1e72HxLAIumMA otZ8n2hqq2tllUtcupa2BJ8huHXT+GZimXAI8+ExFv3EGuIgIWYwBwloAtv0KOK8eX9J QPYbRVXQCyHLpUMZiyx+kMU4YnAAf+okJiX0UMO0TCW6inqK96qMzrrhWAyauuFo8gDi DkirJoVI8z8u6BjglCC0WYHA5wtwopX3cFZe84nxPgmo6y51J5zLzQkBpzlTQSUGoVk+ JAgc27cvNjuLwxZMh/AdRc9QZ/8Vjl8IU+cmzH7vKtX4pzn4gfzUsQVX2Lnds7sgcJXY ExoA== X-Gm-Message-State: AOAM533j6fXJUZ5q7J+z1TGbduOeNzXUJ44G6P7PBjNtC/eGmpvL9f2A aubR7L461cKyOREQe2dpPRUYn37dmye0k0y1nc8= X-Google-Smtp-Source: ABdhPJwW73mZUO/GZmT5gJPzIsgb5HpQSkFdq+iY6EfLUOmImmdC0AbEcplD/It1Uhy3lLTwKPL6U0/5FYmZJUjLv8Y= X-Received: by 2002:ab0:61c8:: with SMTP id m8mr35489uan.84.1610504075207; Tue, 12 Jan 2021 18:14:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Devin Hussey Date: Tue, 12 Jan 2021 21:14:25 -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="0000000000004fe7c005b8beb3ca" X-Seq: 47820 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: --0000000000004fe7c005b8beb3ca Content-Type: text/plain; charset="UTF-8" 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/* > --0000000000004fe7c005b8beb3ca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Actually replied = to the mailing list this time...=C2=A0

>Have you considered j= ust not unsetting caseglob?

Brilliant solution.
"Doctor, it hurts when = I do this."
"Then don't do that."=

As for the complian= t version, here is a much more "polite" version which also avoids= the awkward checks if lock !=3D NULL (at the cost of reformatting O.o).

/* Check for search permis= sions. If we don't have them, get out. */
if (ac= cess(fn, X_OK) !=3D 0) {
=C2=A0 =C2=A0 return;
=
}
/* Check for read permissions. I= f we have them, try to open the directory. */
if (ac= cess(fn, R_OK) =3D=3D 0) {
=C2=A0 =C2=A0 DIR *lock = =3D diropen(fn);
=C2=A0 =C2=A0 if (lock =3D=3D NULL)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;

=C2=A0 =C2=A0 while (...) { ... }
=C2=A0 =C2=A0 closedir(lock);
}<= /div>
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 t= o be searchable, and is a little more respectful to filesystem permissions.= =C2=A0

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

Brilliant solution.
"Doctor, it hurt= s when I do this."
"Then don't do that= ."

As for the c= ompliant 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 does= n't require read access for parent directories.
=
DIR *lock =3D NULL;

=
/* Check for search permissions. If we don't ha= ve them, get out. */
if (access(fn, X_OK) !=3D 0) {<= /div>
=C2=A0 =C2=A0 return;
}
=
/* Check for read permissions. If we have them, try to op= en the directory. */
if (access(fn, R_OK) =3D=3D 0) = {
=C2=A0 =C2=A0 lock =3D diropen(fn);
=C2=A0 =C2=A0 /* Error */
=C2=A0 =C2=A0 if= (lock =3D=3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 retu= rn;
}
while (lock !=3D NULL &= amp;&...

% chmod 111= ..
% echo $PWD/*
/tmp/inacce= ssible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c
% chmod 000 ..
% echo = $PWD/*
zsh: no matches found: /tmp/= inaccessible/a/*
--0000000000004fe7c005b8beb3ca--