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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4338 invoked from network); 12 Jan 2021 22:43:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Jan 2021 22:43:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610491402; b=I7YRDZbrZLGtImlHwHoJkd5V0yFyhOYlO14jMO49t5RWHsnVrdXxR3X0ZIDws5o6dAWbynb4W6 s5ncWP7UWi4CdK70/1Fv8/oZmvfUv6cRxqYg9G3E/UKoqY/nq+36HDCvxC/RlBxQnAQMW4PRNU e0rWhT2kJRdsaWMoNV/vLuBP5Bft89IyMc+lAg2I7JSe5pwoUHsqGC302xeSIqr7aWnTue4qvt us9/6Cejx2euSaxfOe+vcgD9iztUncFShV+O56MSI5quIMrMdiTGUXBxK5Nw29Ahny+yOE4rT+ nHnLMYuOmEW0CLCMNatA5Oz9dsUfrJMUPmE8zpGzXPNHKQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vs1-f50.google.com) smtp.remote-ip=209.85.217.50; 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=1610491402; bh=/fFRBNxotkN5r/mdNjaEnQz/MThs+AkX3Kr3TQ5qm2c=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=OBe9iVnC7Zy8Pg8hVjCAknqN+BMp1cMhNUEwtccNPE8h8f6hIeFBwE7h5AeuxzH1EfW1UQj3A8 j58CrqfFIE+xMRweK4PpgNdvgCFXrvNACgtXixCUoQnegybp80pGafIln8d0YCj9ecDKFCeQni aK2boXX340EYn1ohdQaiXt8Py4K96fdNilvqkk53LDcuQHCirVqOfAosBp/yYIuy+++JhoKhi/ bZzhRAQR2FQvA98xnzWYMoDjdMM/zwJ6zQA5Ao4P/5YoeF/do609jvvizhTkPFwUhJ47KX/G+i QmpYhMcMH0evbRYujjLG9veD4IYXpRmD91T+tkTm1xg9ag==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=FfVgwwC522TN4BpnyE+iEEbESTxrGWg2WsH4QuWE8Rs=; b=p8OtmrkZ4KX+bs8UlYPScDgOJK 4qIYUfdtDfzBouZALEdWJ5cfu0slKN1pQ/edX5cU2TOFZlI5rtyGIkTT7zbq4FbLr0XOA/Sl2GUgZ 9S/dr5cnIQwhnWzORnKNlnCN7Lz82az9/C78OJ9Gu8e4BaaODqo5BVctKG5b5ZTpQzohgbSZGYs9g sW6Y90t6Z35u4mveShrhprKrG7DkLuwMlMGS75LusiDpufAr2HSjXTK2YwLGDLoLgIdmDRXM3k+A2 DckriS55Tjavz7iTx6LtV2GP7vVEtq49sRj3FeGpicuqO1A31R93C9aAArwP6x92Ylr6+2wXYgfDI /5pdyJfg==; Received: from authenticated user by zero.zsh.org with local id 1kzSNh-000IH4-Dz; Tue, 12 Jan 2021 22:43:17 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vs1-f50.google.com) smtp.remote-ip=209.85.217.50; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vs1-f50.google.com ([209.85.217.50]:35264) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzSNO-000HvV-EM; Tue, 12 Jan 2021 22:42:59 +0000 Received: by mail-vs1-f50.google.com with SMTP id s2so88017vsk.2 for ; Tue, 12 Jan 2021 14:42:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=FfVgwwC522TN4BpnyE+iEEbESTxrGWg2WsH4QuWE8Rs=; b=THnY5caqv8EQZ4ObL6b+3XMjTt9Z/xsPOcM7CpwS5/8Ar4vbwDCHQEff+2K6m+Fbn7 SrqfLsaDhDyG9zWKuQnK4SiarxzNkNlHNqWPH9ZAl5CMM8PpLq8Xp6j+Bt4i9RGb6WFX gqJMVoVuCZFJISaD0/FCsgZTvG8Avy/Juf9UFkenTcFtIia8v0VcUVN0FNuXQGw2Mke1 m04bggKClKFBVWKiKj4q7riNtd3eS08AUInU1fl3xlzn2NiG/l1JPH8z8TlmCctVsjFC kyU9ThMBWLveeSuo5z60/P5W3UYb0LFrj/KieUPBpbas2qeg1YPXjCPjIl5GvgR3GeL9 bbfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=FfVgwwC522TN4BpnyE+iEEbESTxrGWg2WsH4QuWE8Rs=; b=F0fvhe8rGQPYYuZc/Nb6pe1vBuHCWU8heFmyNBrRlRQfj/2Q55FPmZVn0/NS96jJgc zDmLZojsmbEk+811XcKn4bmigWncTl2l2XqpZINE63po2uTDQr+rVVHzE46rg7ht9zsC GChw0R1PX3eq3ZAeCiFADEy3A0KaoGGbxte9pxXB9GfD+EkPUMpWDESVu4qYC4UcHrAO Z041CTZ0gc4da/TIZEIvd+bp53bUrNgwqq2iQ2kXraULV9hL0CR7XDLxMR4Pnz2xSJ0y R1b+37fPZ+X3iJSf7dpbO+JIlpJ16TEakrt+gjFRsGVeUyd/WdjpCeS46cBLaAFKgnvn DSwA== X-Gm-Message-State: AOAM532rQbV9G1HrSKoWb8PPlpN1oRN66kg6OHH158i3J2jCyO0ixwyM 74D0ltfjaP4/t+gtR2aIQJdjQnRNPPDD26tBQhMUbcCL X-Google-Smtp-Source: ABdhPJwFHv3JTokyPs3DgYOpYx5dqQKmi4qU6PYyJCenerkFlT/Dy9c9CifZgL0Z+qTO1Ee4cSR6Ft27zE0fjTDV4UI= X-Received: by 2002:a05:6102:93:: with SMTP id t19mr1749199vsp.57.1610491376807; Tue, 12 Jan 2021 14:42:56 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ab0:2306:0:0:0:0:0 with HTTP; Tue, 12 Jan 2021 14:42:56 -0800 (PST) From: Devin Hussey Date: Tue, 12 Jan 2021 17:42:56 -0500 Message-ID: Subject: [PATCH] Ignore EACCES when doing non-pure globbing To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 47813 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: Even if we can't access a parent folder, there is still a chance we can access a subdirectory. This is notoriously the case on Android, where apps can access their own subfolders in /data, but not /data itself. This was causing many issues with Termux, the terminal emulator which runs from /data on Android, as many scripts will try to glob relative to the home directory, and it would error when it tried to opendir() on /data. Over-recursion does not seem to be an issue, as EACCES seems to have lower priority than ENOENT or ENOTDIR, at least on Linux. See: - https://github.com/sorin-ionescu/prezto/issues/1560 - https://github.com/termux/termux-packages/issues/1894 Signed-off-by: Devin Hussey --- Src/glob.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Src/glob.c b/Src/glob.c index bee890caf..7b9414c6f 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -585,9 +585,11 @@ scanner(Complist q, int shortcircuit) char *subdirs = NULL; int subdirlen = 0; - if (lock == NULL) + /* Ignore EACCES. We may be in a jail like Android's /data where we can + * only access specific subfolders. */ + if (lock == NULL && errno != EACCES) return; - while ((fn = zreaddir(lock, 1)) && !errflag) { + while (lock != NULL && (fn = zreaddir(lock, 1)) && !errflag) { /* prefix and suffix are zle trickery */ if (!dirs && !colonmod && ((glob_pre && !strpfx(glob_pre, fn)) @@ -673,7 +675,8 @@ scanner(Complist q, int shortcircuit) } } } - closedir(lock); + if (lock != NULL) + closedir(lock); if (subdirs) { int oppos = pathpos; -- 2.30.0