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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15212 invoked from network); 13 Jan 2021 22:28:20 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Jan 2021 22:28:20 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610576900; b=xBTv3Sa52CYIbEDjh+G/kmrOwIJDD6evUtd3ruHqcKR7hpBiH0M7YfaZesb8OCU0b5OZwjePBs bjxpfwwIChfSAMOhWchxwJlr1ouHoF877R1b9ptUEHKL6E5eA+1UTdf7qR9/vIsXIETLrMqyGm Zp0opqq3SRUcTHe1NM5dZcJruvwdyCFcYogqeYIadZ0kPuoQcsPXit7Yr8eR00cHJ/C5jraTzH Jh6t0k0tL9Y5EWVBMfu6egtvCpBLjgUiziGhxciRuByKNoPh10Y8xPg5E9PxylNluzXOhHnqo2 mHyUNgUDQ3FdACzv2dXJifW0vZDo633pZtqGy4RtxvuENw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f178.google.com) smtp.remote-ip=209.85.167.178; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1610576900; bh=C+x059B8ssYg0+p1RQsR9nRv6SrOAxbDB30ZsUnUwCI=; 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=E4c0sBqW5/1SwCUI2kIC8eRrxD0RDKa9hE3muzqKXou9SWb3q3pBiVjDoXam3v0cnBBDAqxo5g Gv3CHBo28keJosD9Y89XR3ZeYMHt6EhWnmKcVGlv/CgkA0kDwDKO+6dwt3FtiRNVGoZnL7BEUp esp7G1/DXWmbnVLgsrVb+Q/BH8MoOVWqwC0X43e0esG27zBlBkoXhtbO01PjabztnZ0x2L5ey8 QwCuGw8KQDwwvriktcbctp7GomFEcI1bxePwngETWE8Kwn1RW0yuJt2KAjg7ZhRMJkMWOqbPl6 JSMFnJqw0PvdqyQqCR/yxAq+WuYQ15s674zBQKG5/nhi+w==; 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=tgNZJE+pL1N4oKP1Im80IlFrxrYIjNmREf9eAbh8bLc=; b=tmfDPM0FZs5PkV5YOUA2IuDycs /k1hYIbcnHy7j3uG57ASgGoITarcjvdMXZVIkmMwzx0deEEAZ4o61rzruv2hSm+Q/GS0BaBgFJLv8 KHDbxUsArk/drGTZdE5+qS9fnJvyO26CCz+1zNdTlHLphHPEtJV1ZCl1QQhK8KXX+ovN1JFvpPspL YI+vdNwYrplwPhXS67RVz4fUS6n+6xXvscjkItZpOCdmYWgxczF0EhEKnIdlSDcIBOQRqpoTxrd9N 2aXHmrSww75+wUIIpEWPCEMTSS8WM3lKdCNpqLSwcOo9xPQTm6RG3RiYcr11tmzlproEFPI5rUHGk /nZXVnfw==; Received: from authenticated user by zero.zsh.org with local id 1kzocl-000KAj-SX; Wed, 13 Jan 2021 22:28:19 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f178.google.com) smtp.remote-ip=209.85.167.178; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f178.google.com ([209.85.167.178]:32853) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzocS-000K1X-7C; Wed, 13 Jan 2021 22:28:01 +0000 Received: by mail-oi1-f178.google.com with SMTP id d203so3906665oia.0 for ; Wed, 13 Jan 2021 14:28:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tgNZJE+pL1N4oKP1Im80IlFrxrYIjNmREf9eAbh8bLc=; b=0eR7+iiG1thdG8qi/2ou6Q+GkssPQfGcE4Jt1iroMd+8jsH74TPGzEwjNydul27xbd tGadtGgjFDXeRi746yYkAXiBH8qrosYvmwwGAw2/7Y386gh/a74Q+9r3N/dRSOEVO7BI FZt8MveviIxE76sXqIKxUBOhAgLsTKajAd5hhtH4p3p2plEYGNo3unh+0fE7BzMex9ak BLcL65ZO/kkMOVLdnoBhIMwXW2357WQygrYPIkX8/Il4ujt8KzcomBUIs1fl+2bkAMRT 0Lo5eDnYm2xziMVbt8rEt0kjIJvz3dqAYaZoM29p9U8alscedCe7l6MpRlCiOQgybeLY lzfQ== 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=tgNZJE+pL1N4oKP1Im80IlFrxrYIjNmREf9eAbh8bLc=; b=CLi+2Vn6s3gsH6j4WCB3lt3izpgJuJ7vEDx3cIX14+0hPRcfh4ExZd2JnBCzQlEexG 1zL+lUbU3EL6xASfM3wuvnnGCDBBya4rrsSaqrdgAsOChf5ToAx30qWBszZD5Vz5b9Dd E+RpKCL0hmkkXtuwneYvanacalyT6+QToDcfpOzIC60ozPnksxbl0CU/MTmeDzDH5pux 2wZjivrYOswNElIWRTtijLjLgzZuiLWYm6eVWVEe7DXvSqHPGQ9vbupoRYQE34ss1E/t tCs9WIRzYhy1RqNv1qCbxQIGvX9nkvM81h1tdU1wIayjoWMSqgp+711a/4Npi70Wn0/i AOeg== X-Gm-Message-State: AOAM530ywBvZR9cR1L+t2ZzbEbBHAMrnt5MnTaSbRwaSNX9ORppsBsyG Hs2ok1S9u2e72jVoVBDMkYpRmOQDG9RHCTqMISE8iA== X-Google-Smtp-Source: ABdhPJzkGkXXkxms6e5C/IULUoxBaI1kYAdtw3gK7RuIbXNgDQHjUTq0ddUtgjNVxapDe0Nl1JiqwMqPKCA0tpkU2Ik= X-Received: by 2002:aca:6089:: with SMTP id u131mr889958oib.84.1610576878826; Wed, 13 Jan 2021 14:27:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 13 Jan 2021 14:27:47 -0800 Message-ID: Subject: Re: [PATCH] Allow globbing with unreadable parent directories To: Devin Hussey Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 47823 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: On Tue, Jan 12, 2021 at 7:04 PM Devin Hussey wrote: > > POSIX specifies that when globbing, parent directories only have to be > searchable, not readable. > > + /* First check for search permission. */ > + if (access(fn, X_OK) != 0) > return; I don't think this is correct. Even if it is strictly correct per POSIX (which would seem strange to me), it should not be applied in zsh native mode (see my previous email about setopts). % mkdir /tmp/adirectory % touch /tmp/adirectory/somefile % chmod a-x /tmp/adirectory % echo /tmp/adirectory/* /tmp/adirectory/somefile % echo /tmp/adirectory/*(.) zsh: no match Lack of search permission only means that you can't tell what kind of file "somefile" is (you can't read its inode data, e.g., stat() it), not that you can't see the name itself. Compare "ls /tmp/adirectory" and "ls -l /tmp/adirectory" for a related example. > + /* Then, if we have read permission, try to open the directory. */ > + if (access(fn, R_OK) == 0) { > + int dirs = !!q->next; > + DIR *lock = opendir(fn); The access call here is redundant; opendir(fn) will fail if there is not read permission. Why do you believe the extra test is needed? I think the rest is just re-indentation. Did I miss an "else" clause for the R_OK ? Can you provide a specific test case that shows the difference in behavior with and without this patch? As far as I can tell, the patch would only cause globbing to fail in more cases, not succeed where it previously did not.