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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 900 invoked from network); 3 Nov 2023 04:29:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Nov 2023 04:29:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1698985766; b=DTls7OGLdj5vZI+nAj0HV4hY1NA9FrQeiPl3NCO3QO88WkT/844SkjWMurDnMP04xwaJOZpmLM 7ZyLQiUHCHj6Mu/+uCeZykkWp9xbeRym1Gxrjw2oEgGjzsP5GrqksvmI5T70w6QIjbJy/PKeBs QQQzNsjnlIVtjZkat+iMYan/qlsqW0nr+ujb2d52rfaL7ixvyBpnT2D20K3Kp7j8hADWZ/upHx vJdAlUiABwhunqZ9Yrchp7dsMP+RNfstjPThNoe5H/wNy74T0ae8Zo2tqo0+MtFyBILCRNJa2m G9y6LY95wXRyyllvR/wy/HnBok5dDehxUpM3AQosPp6idg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f45.google.com) smtp.remote-ip=209.85.208.45; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 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-20210803; t=1698985766; bh=J4g1bM150V/jNOMeQ0HoLHQTYw5ncyzBB1WQZm2ufXo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=RoKk8JFajPabzHaNBucyl7dT7HkpEA64gpcOkns184HkSoGbG4lJyVOmuRnHATxjbx8gkZLoNW /eF0GIBJ4vbmjrmziXclm/FvBgTky6IhibvMJN8wrbzQKsqkpGnIsJhW8ucRZH9OB5P9wnFarr AQWzwJ0XSqpNkAVYAvzAHNA4n18WMhONuRwvW8ZPWrDviXH1yZf9u4IoCOeMH0Qd70Fs69UIAN cIDf6izbjavd7FolufF8Nth8sVzEK9F5VAiF3jEdnrIgZ5ctXrqS1GzcQOnbyWquzvK5TXnBqf zP9UAz7iXT1c20eKIRNBSM2dyz2ePVoeoTgH/Unxm/JQsQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Dx5rGQR13nrgcF9nPvj2Rocios9i+rGWullAFnu2ovU=; b=W2rcAR89XgDtCQliEmxMWjOMMF Atnbtw1GMV/BLS6yrB9al5b3jE1su9uhU++mCofFcZjzI8h1AwKftEHFLJ0wx9tF92+RxtzA92JVa kZVF2PymsuXzijMYAsKf1eHLdSo41kpePfq5nCk4jq74PzPQwnUyQ72Sf6k9eJ+o5yxHE4/gC4Gq5 JiGlitgS9I/RmgROuqFThIpBs+6kUidkYDNn6dvnGJV28sAO9bAPcrwiQxRqANLr3fZpla0FPKUJZ CPcsAKfYLG32pJg0vDrYxTetQY0rMkHM7P4JrtI+uW2kf4mzIhUL5TtxJgSxYXjCb1yqmy9VA14Ym o+IXlk4w==; Received: by zero.zsh.org with local id 1qyloB-000NBT-9O; Fri, 03 Nov 2023 04:29:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f45.google.com) smtp.remote-ip=209.85.208.45; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f45.google.com ([209.85.208.45]:55794) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qylnb-000MtC-Rn; Fri, 03 Nov 2023 04:28:50 +0000 Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-53d8320f0easo2618301a12.3 for ; Thu, 02 Nov 2023 21:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1698985727; x=1699590527; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Dx5rGQR13nrgcF9nPvj2Rocios9i+rGWullAFnu2ovU=; b=ZUO9GRnKx2Z3rafvvuBNYpp7Y2+HqBZ9m04WUuKCPG57tCxrxKLKZZ6MWJh0f3Tzyw Oye16a8eufSfWnFVzWr9DDKq+jeV0OOokRKi1hfnuoMo0e/nDdh/dPdqkH+2jYi3J5QO 9xbLoP0JZP3hVsbDsNA+3Lrqgqo3Aotb+t6rFaRrvhmmnwduLYvoS38CWH9F4QHqpMF6 0SR6gWyhPjEG1VV501v4eeGbd8uLhOVQCWuUie+Pd4QAviokdyv4Wqvk0VFN1Y1PRnKG FGAHvV4GO4QxkKTF3vZV64KC2yhxZ3Lc3/YkuOBBTiIc+f+3qsxXGq4sIfNlGlUhD07I cNIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698985727; x=1699590527; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dx5rGQR13nrgcF9nPvj2Rocios9i+rGWullAFnu2ovU=; b=PxhzeMVkNf1isUKSy5CR7h6kksFhCEVFgH7R/rt0mMHw3C4ydX8CG3HSkGZ2gzlFmN 3BqBYrSfgtJP4Edvjnf/bmh1pw6cheZXitkUZ0TYwjBSn3RUdEeSUopbq7o8oKKXcvFU BfJKFwI95xhwy5iRNi58AyIU9P0V1KHQBKkIod7+RVEWrQtPlnwQXRnRF2HCa8/zKFoa zXOomMH1qSbBHIOM0EUOjq2WHM1DPSPMjckO7ogWTs80eoYIHo1crLmlijPxGaYTCbQ/ vakC5pmSMEAUoJXEb3g/6Y8jSdaBvTChi+F236faA3GKhd8GU5wO48bUseKg6+ftE5KA 6SwQ== X-Gm-Message-State: AOJu0YwTRCcscLYkVXbgSjoPyhcNWnyWV+9xQ5b3vRWCGUXwPfkDMoiW I0x5CcKf0p4iYGvKdLEDuQU/+oApYNI6HU9At5gxRi2+kMA5K+R5Ci8= X-Google-Smtp-Source: AGHT+IH3Wt0BPfThYTEhKM+zXWGfRrH+ya9Y9BIJED0vf8U/AyIetdyBI6FdIuGA+6fKQNu5QBz3watwFJiMEqvXDlQ= X-Received: by 2002:a17:907:7291:b0:9ae:7206:963c with SMTP id dt17-20020a170907729100b009ae7206963cmr6062940ejc.15.1698985727186; Thu, 02 Nov 2023 21:28:47 -0700 (PDT) MIME-Version: 1.0 References: <6f0cc0e8-665f-4c90-ba6e-6180ebcf9d60@laker.email> In-Reply-To: <6f0cc0e8-665f-4c90-ba6e-6180ebcf9d60@laker.email> From: Bart Schaefer Date: Thu, 2 Nov 2023 21:28:36 -0700 Message-ID: Subject: Re: [PATCH] Re: `pwd -P` with systemd-homed causes inconsistent cwd state To: Kyle Laker Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52270 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: On Wed, Nov 1, 2023 at 7:54=E2=80=AFPM Kyle Laker wrote: > > It seems like this does in fact fix the case where _both_ HAVE_GETCWD > and USE_GETCWD are false; however, in 5.9, even if HAVE_GETCWD is true, > USE_GETCWD is false (and this same setup can be induced on master where > the same behavior happens). In that case, the new error handling is > never hit because after zgetdir() now returns NULL, getcwd() is called > as a fallback (which sets ret so the subsequent logic to use pwd isnt > hit). The only possible case I can think of where we'd want to fall back on getcwd() after zgetdir() returns NULL, is here: 363 if (stat(".", &sbuf) < 0) { 364 return NULL; 365 } Somehow getcwd() might bypass whatever restriction caused this to fail? In all other cases we've chdir'd away from the current directory and can't get back. I'm tempted to say we should just delete that entire fallback, but then we never use getcwd() at all. Maybe we should be checking errno (for what?) as well as ret before falling back to getcwd()? Or maybe when USE_GETCWD, we should use it preferentially, and zgetdir() should be the fallback? Or maybe zgetdir() itself should USE_GETCWD there at line 364? The whole situation seems a bit strange. In utils.c:lchdir() we have calls to zgetdir() in both an #ifndef HAVE_FCHDIR and later an #ifdef HAVE_CHDIR branch.