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 11065 invoked from network); 9 Oct 2020 20:36:20 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Oct 2020 20:36:20 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1602275780; b=MT19DgN7jSr7pGh3N856GX0M62vIzTybiTBZYB2fs8k+Nz2jQlGBSt0tQ6LOGDL6s9s62nnzuZ hY9U7e0sYyVs4h0wczunVd0k8enhKZmV1dG4qfH49OXUW1RF8j6moPtsDlDbPalXNaH5MQ1zlg EkBSAMAObQLGBZC+oLpwF/8th2hQLk+J0ZYMfuZCrN1t/9Goz7BZOZQUpGFAMdnhlQh+DULWw8 QkTR5hOt6X/oN077Znz/F5QnXO5JJlU7NTvTHL+t7wVMI4cG9LLZl2wB1ngGGfcZQ/QArfB5Al E72qifvy7vNRYc3FCL9uhQ1j6NaJafOKKcbgqnwDT/Eakw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f176.google.com) smtp.remote-ip=209.85.166.176; 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=1602275780; bh=mkIeCFCE0jPJPAn1N5baqI11yp+lNApxqaWevneP10I=; 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=Ezi31TeH7kEBW8mt8JKZExGlLyTGqUWoTAlS+5BnOK4ofdgWR7IBOpOFixhv3tonDEYM6sK3Wr gwHH/rdE4ymIqoSi++pr1rf9wW9LE9raKbfVaJ8A4hP0unoDHF7AQhsnR1NCMcnUpPqUT9LIPP VvFC6kxuBy1kB8YHLxNqdBxEiKocCtStTXo5mIsN7NDDcZGkMjiCNzEarhtw/D9XMpEFZJpWwD 0LelOG/nGhltFDjSJW3RLclnVWgUH/cFaIUVKnKW5YgILlMQvrutmaflTxtLjg5DuKeg0Vkd3d r992wOx0AL09bIqzdK+HodKuycpxAbL3iHctKhNiodb3Uw==; 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=mkIeCFCE0jPJPAn1N5baqI11yp+lNApxqaWevneP10I=; b=WFPYe6do+ppWJ6FHfpMGqbFLkX p+8jdtiQO8qCln/hiX5lBX721xE2uBnN1HrHXyIZlCV3rMmnFNePcKiWT/VerYqB/bpvGM98r6DKZ oYdTv6r6TO8hiiMzk49eoWOH7ygiX2mSOoFNRDf9E/6vXnNtoKtuBYBGFH/3aDYXEM56LbxiNex4M TJ0t4fPM5pPb3xWLULrUh7ohz/3J/eWv1rcTurYdSIUF8uLorjNwD6N1fRcDn5Rsme/ujnQLe346U 4TuKrxRvhBBxLyKwI2Dpy/0u2D68A4VOSOUoAEeoME/j1rFC+9xFUQyMq/hOzXBIk2xXS9AYuWH46 Z4OTj6fQ==; Received: from authenticated user by zero.zsh.org with local id 1kQz7j-000HzF-PN; Fri, 09 Oct 2020 20:36:19 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f176.google.com) smtp.remote-ip=209.85.166.176; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-il1-f176.google.com ([209.85.166.176]:40896) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kQz7P-000HpM-Gx; Fri, 09 Oct 2020 20:35:59 +0000 Received: by mail-il1-f176.google.com with SMTP id y16so6293363ila.7 for ; Fri, 09 Oct 2020 13:35:59 -0700 (PDT) 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== 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=mkIeCFCE0jPJPAn1N5baqI11yp+lNApxqaWevneP10I=; b=Iw2AMnzL/sCyT6Z6TnxuXS4i78XprQp3B1QuR81I/fu25oM7JjgXlwYfEHNp6Cry07 qeoDo59ruKLMKKi04luOY7Wf/7MMuwdedCq6ToLvziEV2uZaaHLfztzkqKCd0y9gJDEy e7OR395L3dSIm3cu+vbfGyMWve+0RWfOlAQS89ymkisgaOI6CG9M+vUJSGYTpadN5ke0 4ZUqg7pu9Fzvy0YoWI9elU0/V3yJOYA+JJZKq0wdsTx2mIi4+N0yzh9NkX2WEv1mANBl Q7ZbA8GTnKxnumw7O0biY832LY96PvnttKB9LLfLRpnx2UjCAuL5fTwQzaje3MO37Md3 r2AA== X-Gm-Message-State: AOAM530Tz0CwEsjYqjtGc8RMN6hfSVJ0qp0HoJtWuiuRNoQ1wMHQWWsF 8eWWGeYFTE7f8T7P3DX7jKdnUUgPINulfzLTQBqwzVY4 X-Google-Smtp-Source: ABdhPJyZA2B9M3tF0EeHXiUoZ+RbMyzDUkx097AcPfpQp7SYSX61fgSScksJRQ+G4n1EUkRmymEaCvz5t/zGDzFRVLQ= X-Received: by 2002:a92:41c4:: with SMTP id o187mr11516027ila.304.1602275758067; Fri, 09 Oct 2020 13:35:58 -0700 (PDT) MIME-Version: 1.0 References: <20201009200737.GA78914@CptOrmolo.darkstar> In-Reply-To: From: Roman Perepelitsa Date: Fri, 9 Oct 2020 22:35:46 +0200 Message-ID: Subject: Re: [patch] Avoid race in zf_mkdir To: Bart Schaefer Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" X-Seq: 47438 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 Fri, Oct 9, 2020 at 10:25 PM Bart Schaefer 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. Roman. P.S. 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.