Zsh Mailing List Archive
Messages sorted by:
Re: [patch] Avoid race in zf_mkdir
- X-seq: zsh-workers 47438
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: [patch] Avoid race in zf_mkdir
- Date: Fri, 9 Oct 2020 22:35:46 +0200
- Archived-at: <https://zsh.org/workers/47438>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/CAN%3D4vMoJrD%2Bg4Go37yT6gF-Lx61vHm45GvmG1Fx6-%2B3yyb1hAQ%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-il1-f176.google.com) smtp.remote-ip=126.96.36.199; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- 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=mkIeCFCE0jPJPAn1N5baqI11yp+lNApxqaWevneP10I=; b=vMOhve18EA4/ht1T6bjNF0LDD4q52Tfpzc5FpMr96jx34XNKn/WRKDG063/Hd80Xqq 1wMPX6CWnd8pXMtXILAgGkbRnD1aK0vRJOTMGIz+oClOcYQmNtGu9JX6SxWVuR6HEw5x WXfNMg1zqqNLOiZzYd7vilqUjB8klAcq9VzdJxZZRgOsfHoUp30v3toyb7Jzg6vaqCGd UeySszcq6NikQry2X2jSmITLcV3DLnbyOd1U8hfJtH/HHl3wjuWhyRzZ1VhS2mJr/FTe B1b6O2QjMawBmjYrtlTIRdCqG//HS0HuG6zt/CkTzRI+A5+f58Y8vDXTB5fxKUYcuiTH zuxw==
- In-reply-to: <CAH+w=7anY9r+-MYki4cycVuaP2+d9L3W5u8k3sHyZx4R5kvafg@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:email@example.com?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:firstname.lastname@example.org>
- List-post: <mailto:email@example.com>
- List-subscribe: <mailto:firstname.lastname@example.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:email@example.com?subject=unsubscribe%20zsh-workers>
- References: <20201009200737.GA78914@CptOrmolo.darkstar> <CAH+w=7anY9r+-MYki4cycVuaP2+d9L3W5u8k3sHyZx4R5kvafg@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Fri, Oct 9, 2020 at 10:25 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Er, sorry, this doesn't actually avoid the race, it just prevents the error message from being shown by whichever shell loses the race.
I think this is the expected behavior. It's prescribed by POSIX for mkdir.
> ISometimes you might want to know that the directory was NOT created BY the current shell?
In this case you would invoke zf_mkdir without -p.
> In neither variation are we checking that the existing directory actually has the requested mode.
POSIX says this is how it should be.
The patch is incorrect for a different reason. If `zf_mkdir -p foo` is
racing with another process that's doing `mkdir foo && rmdir foo`, the
zf_mkdir call must never fail but with this patch it can fail.
Messages sorted by: