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 11313 invoked from network); 14 Jan 2021 02:24:37 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Jan 2021 02:24:37 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610591077; b=qVeYPEsAP4Twec8+MBzFOrJ2uubHbxJYklqMsOwno94xNW7RuIn9FCFY6YV70uS5uiP4XwTEoQ U4wUsDvvue55TgOpSZH29K0+L7nlVyS/q4KlncCbMRtamEMXOU6wROGcgLE0lGwalwWZaDS8z5 vhJTfdE2h7CtxsXDcjik14Wb7tPO1QbJ6y25xpywPuSmBbfm+DXv9QoZw2Z0gClcL/U8Fmbghk baeShMvRzPpxWcs8mvVb2Adt3JSqpfdIP611wUede6J34Yv4DIinJ9XWTETTbtkZBE3nJoO1iD qfx1FXM54ulcrnz5JheJ1m5urKQcN6dUkLTtm8Mp4I9jjg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f43.google.com) smtp.remote-ip=209.85.222.43; 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=1610591077; bh=0wxT0G6evMXzH4R5cH7poqTJRMrykJLYsN9XAzE0Y18=; 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=YLQvdE+ujZ2zry386ZhDLZgLTKu3b6pGp3xXY1VqCBpoyMaUGdwcldCDpoa8epNpEc/GPDKG1b /p5qKKYZCVY9t9odfvSbpAtTgxeC3ZAOLM4KL+08t3K1I7ehbOBjvun/qZFWNNBGa+KELC5aH5 YRunY/TBvDOVfa72cOettPGbiktRg6VgSEcpY4QMYVMVRS2HKd4KtXfXQzLC8rQOpIEd2pUzf8 XnMU0sPi1qqvmGg3vt341NOfoGvL1bQ9F+luCmGXvLo2TclZ3D2TU6hfwCu3KSUb8Oc4ry07t2 FMRMdbTV5ntIGo2OqjAWxlBrKaBmQeU9BViAPQY4vjjPqA==; 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=8mJvGLK69oNP1nZNz+IYaiMNHLyoMW3Cn6PgC5mKCFo=; b=Y8A6+LrVJb6iz1yNmRpmpooLdw sek+szP4jIH2W4+lKtwq24N6OdHaNpY7ppeAtgDPW8lxrfM5n4lpR7oO8ZeSBGCNHhvWgwsmORipT 2oEDsZvYYhfVkQIJSgk6zTJEy/g5Hztp5yC/shh5B4t5JuUowVIPb1lI9AXN3C6ttAmA5kIFlxV2g w2xaPmjl2Wfmud1w9l5jZOAW9NIHvMGxzQc5CYSJzPYPp3KNjnqIBG6W9r9tSql7J/3jm151MPzDW FMaVnPTACIT2XM9wEMqoS9nUVQ/Pz1pWnUDdkKgW7fZ98+cVee3T1rKASu+TgYY+E8d61iruoTkvP zunnWhlQ==; Received: from authenticated user by zero.zsh.org with local id 1kzsJQ-0001o7-Pk; Thu, 14 Jan 2021 02:24:36 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f43.google.com) smtp.remote-ip=209.85.222.43; 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-f43.google.com ([209.85.222.43]:42108) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzsJB-0001eU-7A; Thu, 14 Jan 2021 02:24:22 +0000 Received: by mail-ua1-f43.google.com with SMTP id n18so1341632ual.9 for ; Wed, 13 Jan 2021 18:24:21 -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=8mJvGLK69oNP1nZNz+IYaiMNHLyoMW3Cn6PgC5mKCFo=; b=Mdh2p6EfuqVnNHC2W3puLRokMMsp8zCvIAsZe1ipAqnIJaIo+H9fQkoRPDWMPZZUX0 AQi9LiO85D4c5Hy4ZwfMl72gOa84m2p2spkRzbmxPNSnYqiQXDawuc2Z62k8eAqlDdIk bfKGPz2RIySwk7dj4FhGMrAGwuXmvM1oDXqHeyCqogMdizbHatjYZnV8sRBfqI2Ramb+ X7NncTU/z8uYZaVsyBUBy0nEiM8gINv5FC/2WhtlrgXxRfkhLCHkJZfn4HTsKqpw2lF5 EJx3jL1vgLxQvS7+sKZlfYUA4vLFGKd6J0W1Y/t1vknQDAGmXgoVf6apa+4yV3HkCnE0 HTDA== 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=8mJvGLK69oNP1nZNz+IYaiMNHLyoMW3Cn6PgC5mKCFo=; b=FYHU9+W5iSz84PccI5pYfC4b5dowiTM6fIAefqVqJ58muKwR8z7ZRccYN4wbewmxuI RROyZrnIz44FDyuzlzRdsZiROl7bnCvi9MQzVFoLSqBGDRInvmnVzzJ+bh64IPEPRLNX 3GArPVOo1EQmg4DTFuZsPgDcU0x1c7dtNqMd4SPki3/Db5H4mRr/xFsbQtx47htL+QxA I8dJrIOWqWy5L9Kzm/I0ljMEreO84xAjYV/vDgSq0mCughMAMI2OijZWoMNsgYRgl0yr d/5WwD9yRke2aygMfYDkfep1GsGzjo37YFi3Xk3opb3PqTPUXJld3/vR6f+m9VMFtiWX RQRw== X-Gm-Message-State: AOAM532ndC68jdTBt9RJXiNIsZoh3Tui95ZvR9iDaJRwkYdMTonZ1Bkx SeflQ7rctb0yGJj5X87hg12TUm7bTyxV+m6RboigjOw85hg= X-Google-Smtp-Source: ABdhPJzQ85N8l9Q8R8xVyG71fIhmaf6OoghM/EtORJhZjYoKnnJAFSrCZ8A7d76ch8K+t8VrgTY8tEp08cNSXE3WB/Q= X-Received: by 2002:a9f:2356:: with SMTP id 80mr4316025uae.92.1610591060391; Wed, 13 Jan 2021 18:24:20 -0800 (PST) MIME-Version: 1.0 References: <8563F702-5AC3-42C7-9FF9-B736A11B1A0D@larryv.me> In-Reply-To: From: Devin Hussey Date: Wed, 13 Jan 2021 21:24:11 -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="000000000000087bcc05b8d2f41a" X-Seq: 47827 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: --000000000000087bcc05b8d2f41a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Nevermind, I'm dumb on that last part, I forgot that the shell option syntax is backwards. On Wed, Jan 13, 2021, 9:22 PM Devin Hussey wrote: > > On Wed, Jan 13, 2021, 8:33 PM Lawrence Vel=C3=A1zquez wrot= e: > >> > 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 b= ug > 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 chan= ge. > --000000000000087bcc05b8d2f41a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Nevermind, I'm dumb on that last part, I forgot that = the shell option syntax is backwards.

<= div dir=3D"ltr" class=3D"gmail_attr">On Wed, Jan 13, 2021, 9:22 PM Devin Hu= ssey <husseydevin@gmail.com= > wrote:
=
On Wed= , Jan 13, 2021, 8:33 PM Lawrence Vel=C3=A1zquez <vq@larryv.me&g= t; wrote:
> On Jan 13, 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.
--000000000000087bcc05b8d2f41a--