Zsh Mailing List Archive
Messages sorted by:
Re: [patch] Avoid race in zf_mkdir
- X-seq: zsh-workers 47437
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: [patch] Avoid race in zf_mkdir
- Date: Fri, 9 Oct 2020 13:24:42 -0700
- Archived-at: <https://zsh.org/workers/47437>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/CAH%2Bw%3D7anY9r%2B-MYki4cycVuaP2%2Bd9L3W5u8k3sHyZx4R5kvafg%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-oi1-f175.google.com) smtp.remote-ip=126.96.36.199; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none
- 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; bh=IGT/h7ob03A1TtaObAsvHxdwJG5rf4W3YEZu9GCSjos=; b=cZd+A9/jV7dx8cxY7liSS1t6t1hm1kHJpjZA9Ck5TuTpM2QKmLCFIiWhOA0vL6tKDj pC3i1sEnwqlYqBQTe/YnGW3wpYqppUaFA8xiJ6+3zVZ6HU9aHKQvkaPKNCAxIlAfEeY7 4hrxUMb7eJXqs0PdtkSN1DDukpFWyIykefQ2dH/fuuuzxKu8qEmUokibXhi84/lz94F9 GBbR9S4omwlspiOc+gIToQafcdbYqt0mg5N6vglQuLANnUkR7In3vAU9tA47C+EDvktl J5Tn/dMCUfpCVWzcFGxnHi9ZIPKRBD2SS4UZOQV7eiTslA2u+QGJGauyY8Wl/HzmncjG gutg==
- In-reply-to: <20201009200737.GA78914@CptOrmolo.darkstar>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:firstname.lastname@example.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:email@example.com>
- List-post: <mailto:firstname.lastname@example.org>
- List-subscribe: <mailto:email@example.com?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:firstname.lastname@example.org?subject=unsubscribe%20zsh-workers>
- References: <20201009200737.GA78914@CptOrmolo.darkstar>
- Sender: zsh-workers-request@xxxxxxx
A user reported in #zsh they were seeing sporadic zf_mkdir errors when
concurrently creating the same directory. Move the stat ISDIR check to
after the mkdir call to avoid the race.
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'm not sure that's really desirable? Sometimes you might want to know that the directory was NOT created BY the current shell?
On the flip side in the original code we skip the mkdir entirely if the directory already exists, so perhaps this is close enough.
In neither variation are we checking that the existing directory actually has the requested mode.
Messages sorted by: