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 11139 invoked from network); 14 Jan 2021 02:23:17 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Jan 2021 02:23:17 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610590997; b=fbCv6doJHPNBrmOq7AKEGbQZESj91nE5gEckQW+ohZDizksZeMtSFYk09rUGMQJwD02fIkWHgy OgYK8go3eaG6f/EU0h+1ohrEDNrqXFZBv3rCt2wYNdAQFQ4m5KXnZBKlQ3puYF5LkEZYHIVYox SEQBchzcNi23Wx3mkm+0xtkVjkJbabPYREZdZn4vKsZIiu8LfZBjeaI9sHH6DCkFamvfCdZ48W 46U55uzM6bfyrkislUCrzJtHXC4zcN9FYV4rXvOEv0X79kfJY6qgRv/iOVZif/KdkblM1DMwQ4 61atsYkPL89TkCMM58rprmhHMqFgq/d4YtdpekVrRQhjrQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f47.google.com) smtp.remote-ip=209.85.222.47; 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=1610590997; bh=wOk/95nk5tAXgLHKzaSn1EO4YUMUS/5ITOqa40xY4l0=; 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=mBYSGTpe9IPLybLbliPdS8K8TpAwPCUjj8bsXFxFLPPnBhHJCSQx260UqVIev0zRnX6xF+kvAs uGEcwMhrYkSwrh/KfSEeWtQHp0n8uwiXWfy3JxqDdd7m9mO+x+48jh2iav+9v5mXUGzR5h5XhX bKVXAbX+Suq6oYcNgmYkiRbELeB+5VkMDJakIpw5ByvgjVA+p7WOMOZi+LO8uPQ2sT3KBus+BU heKdlAf4hxa6T9dRHR8rzjiLayk8iTGegKAGnwnWq/ndmHIFHhi2cluCeaVxYFmRE2Fizmwesn Zx2OAKpvrEQCjNmtP/eVh/PGfBGuLi+KjPc06TVb7lksVg==; 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=p4TdI0SZQGRrYi41XAs9pZL4W0M0C6T5qVlrYD7CR/0=; b=IcyOk6lMqyLXemmpnN+ZI1v7iP aDFAZZSdRmhuXijV7QGBKGAaqg7u9vfpjwGDGCUYi+5P6TsUAiTAQISHWbBu/ui4UuG1N37eIW6oa lDsspgSfWcHQJUECVQdDKXYB43iPJvTrSqhYwHB9ZeJegJJpf99yk1v+2JPhigfDaDjShGPh+lJ+D ML8Dns9tlenWnGpK4YnOfFpLrmZimOxwiHf+PxqACKfgJvW4D3YrUM07Q9Zf7msM9/CoDKA0zbzfP C3hWUR7CAmx9XBktAVBRBUwcMTHG/SRpKwEW3++bJcPIimVFrt5sal9FdV69LhFKrMXTax/Py1Ze6 DlhoR2fQ==; Received: from authenticated user by zero.zsh.org with local id 1kzsI6-0001WU-2i; Thu, 14 Jan 2021 02:23:14 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f47.google.com) smtp.remote-ip=209.85.222.47; 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-f47.google.com ([209.85.222.47]:35978) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzsHq-0001Me-K4; Thu, 14 Jan 2021 02:22:59 +0000 Received: by mail-ua1-f47.google.com with SMTP id p2so1343435uac.3 for ; Wed, 13 Jan 2021 18:22:58 -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=p4TdI0SZQGRrYi41XAs9pZL4W0M0C6T5qVlrYD7CR/0=; b=d3PxyymzukeZDxXLh99UUu4u9zOXIvJppRlOCIxyfhGDw3p1+77MWVG7MlKWZXXJWc 8vaH5L7/SssNhlbu3QYTvovWWBZllKU8CXeXCK1wlYidoYcziBhIfTSSspRq2dIVpUuJ DlaYFr1m9Y053+8tXrqEmRPJaQE4/GzBW0ZgYWU0Qpby7sR9a4E0b26yB/W2UuBT62zb 7vOV7XGdzUwJFJl/TkgYPXsANzefz8gMWihYGyiqWaVZSXqXzhUXrfsDgNMXd50P3upR a1bQvef/QuybSGAQhXgyt2fO/Tkpb7GOywFg+nY5iV34Evhe5Q+K5qGIDcNYxTA599ka ZCcg== 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=p4TdI0SZQGRrYi41XAs9pZL4W0M0C6T5qVlrYD7CR/0=; b=DBhrZ9OH9qSzKuy2cz6eOy/S9PfVmbWG/8RhZOlp/Il/Exe0+4wDWdWJf7SSqjAtoe UZ3hpxpa0WtH0fjr+ZlJgviVJzrCE3ow21qv+3s0cI7IMoT9d1dksKShzyOCQGaMNbkk YblclozOIBYmVRuu9WCm8Tkont2HfzjJqYfXRG+z2wq7H+5opw/j1jzTZnImPkLaB071 YxZisenVvV3eVFHfQN9+d4AbVeJJPGyUpZ6WtofMOMoOGGFTSj544TpBijagKT07fSOF iRg1Np08Pmj5fWZSQkXsx2J1Y1H19/C5iN2PeiTb0l+B/tuFpof1MZTht0FZED2kca2H 9mEw== X-Gm-Message-State: AOAM532jgiz4qtNNoqToSPgco5aVuHW2ptTY7sU3O0jxKjQNt4Oocj47 IcRfIUr9UnFUswOJH6xdsa1CALDyPY1pQNG5c1M= X-Google-Smtp-Source: ABdhPJypZOqMo7cPr3kNbxVGLYR4BKilcTQBb78XQdmEP4S5QToLzNRYGTlU70uQ7+rkfewAK/vUnBN3Sz4baEbQyCc= X-Received: by 2002:ab0:6e8c:: with SMTP id b12mr4454932uav.36.1610590977228; Wed, 13 Jan 2021 18:22:57 -0800 (PST) MIME-Version: 1.0 References: <8563F702-5AC3-42C7-9FF9-B736A11B1A0D@larryv.me> In-Reply-To: <8563F702-5AC3-42C7-9FF9-B736A11B1A0D@larryv.me> From: Devin Hussey Date: Wed, 13 Jan 2021 21:22:47 -0500 Message-ID: Subject: Re: [PATCH] Allow globbing with unreadable parent directories To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: Bart Schaefer , zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="00000000000013864b05b8d2ef42" X-Seq: 47826 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: --00000000000013864b05b8d2ef42 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 13, 2021, 8:33 PM Lawrence Vel=C3=A1zquez wrote: > > On Jan 13, 2021, at 7:27 PM, Devin Hussey wrote= : > > > >> On Wed, Jan 13, 2021, 5:28 PM Bart Schaefer > wrote: > >> > >> As far as I can tell, the patch > >> would only cause globbing to fail in more cases, not succeed where it > >> previously did not. > > > > No, that is definitely not the case. > > But your patch *does* cause globbing to fail in cases for which it > currently doesn't. > > % mkdir -p notsearchable/{dir,DIR} > % touch notsearchable/{dir,DIR}/file > % chmod 600 notsearchable > % zsh -fc 'echo notsearchable/*' > notsearchable/DIR notsearchable/dir > % ./zsh-patched -fc 'echo notsearchable/*' > zsh:1: no matches found: notsearchable/* > Huh. Yeah, that is a bug. I don't yet understand enough of the logic. > opendir() would fail if either R_OK or X_OK was false, causing unreadable > folders to be a false negative. > > > > This is allowing certain combinations where opendir() would fail. > > If I'm understanding your intention correctly, you would like > "literal" segments (e.g., lacking special characters) of > case-insensitive glob patterns to match literally if the "parent" > lacks read permissions. This doesn't seem to work, though. Am I > missing something? > That is correct. To reiterate the problem: - Case-sensitive (and POSIX) globs seemingly only fail if the parent directory is unsearchable or if the target directory is unreadable, as it only opens the globbed directory. - The case-insensitive ("impure") glob will fail if ANY parent is unreadable or unsearchable. This is because unlike the normal glob, the impure glob will try to recursively opendir() from "/". - If I ignore EACCES entirely like in my first patch, case-insensitive globs would succeed if the parent is unsearchable, causing the opposite bug where case-sensitive globs fail. - The current patch does not handle the target directory being readable but not searchable. I admit that I know very little about the Zsh source tree, so I have tunnel vision when it comes to the program logic. It is likely I who is missing something obvious. The only reason that I found the cause of this bug was via strace. % mkdir -p notreadable/dir > % touch notreadable/dir/file > % chmod 300 notreadable > % zsh -f +o CASE_GLOB -c 'echo notreadable/dir/*' > zsh:1: no matches found: notreadable/dir/* > % ./zsh-patched -f +o CASE_GLOB -c 'echo notreadable/dir/*' > zsh:1: no matches found: notreadable/dir/* I didn't do anything that would directly affect CASE_GLOB, as CASE_GLOB uses the "pure" codepath. It is expected that the behavior would not change= . --00000000000013864b05b8d2ef42 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, Jan 13, 2021, 8:33 PM Lawrence Vel=C3=A1zquez <= vq@lar= ryv.me> wrote:
> On Jan 1= 3, 2021, at 7:27 PM, Devin Hussey <husseydevin@gmail.com> wrote:
>
>> On Wed, Jan 13, 2021, 5:28 PM Bart Schaefer <
= schaefer@brasslantern.com> wrote:
>>
>> As far as I can tell, the patch
>> would only cause globbing to fail in more cases, not succeed where= it
>> previously did not.
>
> No, that is definitely not the case.

But your patch *does* cause globbing to fail in cases for which it
currently doesn't.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 % mkdir -p notsearchable/{dir,DIR}
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % touch notsearchable/{dir,DIR}/file
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % chmod 600 notsearchable
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % zsh -fc 'echo notsearchable/*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 notsearchable/DIR notsearchable/dir
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % ./zsh-patched -fc 'echo notsearchable/*&#= 39;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 zsh:1: no matches found: notsearchable/*

Huh. Ye= ah, that is a bug.

I don= 't yet understand enough of the logic.


=
That is correct.

To reiterate the problem:

=C2=A0- Case-sensitive (and POSIX) globs seemingly only fail i= f the parent directory is unsearchable or if the target directory is unread= able, as it only opens the globbed directory.

=C2=A0- The case-insensitive ("impure") glo= b will fail if ANY parent is unreadable or unsearchable. This is because un= like the normal glob, the impure glob will try to recursively opendir() fro= m "/".

=C2=A0-= If I ignore EACCES entirely like in my first patch, case-insensitive globs= would succeed if the parent is unsearchable, causing the opposite bug wher= e case-sensitive globs fail.

=C2=A0- The current patch does not handle the target directory being r= eadable but not searchable.

I admit that I know very little about the Zsh source tree, so I have tu= nnel vision when it comes to the program logic. It is likely I who is missi= ng something obvious.=C2=A0

The only reason that I found the cause of this bug was via strace.

<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 % mkdir -p notreadable/dir
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % touch notreadable/dir/file
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % chmod 300 notreadable
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % zsh -f +o CASE_GLOB -c 'echo notreadable/= dir/*'=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 zsh:1: no matches found: notreadable/dir/*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 % ./zsh-patched -f +o CASE_GLOB -c 'echo no= treadable/dir/*'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 zsh:1: no matches found: notreadable/dir/*

I didn= 9;t do anything that would directly affect CASE_GLOB, as CASE_GLOB uses the= "pure" codepath. It is expected that the behavior would not chan= ge.
--00000000000013864b05b8d2ef42--