From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 03 10:02:06 2018 Received: (at submit) by debbugs.gnu.org; 3 Jan 2018 15:02:06 +0000 Received: from localhost ([127.0.0.1]:34488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWkYQ-0002h2-86 for submit@debbugs.gnu.org; Wed, 03 Jan 2018 10:02:06 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33233) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWkYN-0002cP-Hq for submit@debbugs.gnu.org; Wed, 03 Jan 2018 10:02:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWkYH-0002iS-JG for submit@debbugs.gnu.org; Wed, 03 Jan 2018 10:01:58 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53350) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWkYH-0002iK-Fr for submit@debbugs.gnu.org; Wed, 03 Jan 2018 10:01:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWkYG-0005H0-7X for bug-coreutils@gnu.org; Wed, 03 Jan 2018 10:01:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWkYA-0002ZL-Fa for bug-coreutils@gnu.org; Wed, 03 Jan 2018 10:01:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWkYA-0002YU-9g for bug-coreutils@gnu.org; Wed, 03 Jan 2018 10:01:50 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63EB0C059B6E for ; Wed, 3 Jan 2018 15:01:49 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF97562530; Wed, 3 Jan 2018 15:01:48 +0000 (UTC) From: Kamil Dudka To: bug-coreutils@gnu.org Subject: [PATCH] mv: document the missing atomicity of 'mv -n' Date: Wed, 3 Jan 2018 16:01:47 +0100 Message-Id: <20180103150147.16295-1-kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 03 Jan 2018 15:01:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) * src/mv.c (usage): Add note about the missing atomicity of 'mv -n'. * doc/coreutils.texi (mv invocation): Likewise. --- doc/coreutils.texi | 3 +++ src/mv.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 3fa083085..e7ca6a737 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -9660,6 +9660,9 @@ If the response is not affirmative, the file is skipped. Do not overwrite an existing file. @mvOptsIfn This option is mutually exclusive with @option{-b} or @option{--backup} option. +Note that the operation is not atomic. If @var{dest} appears after +@command{mv} has checked its non-existence, it can be overwritten despite +the @option{-n} option is used. @item -u @itemx --update diff --git a/src/mv.c b/src/mv.c index a8df730a7..a08e75649 100644 --- a/src/mv.c +++ b/src/mv.c @@ -306,6 +306,8 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\ -i, --interactive prompt before overwrite\n\ -n, --no-clobber do not overwrite an existing file\n\ If you specify more than one of -i, -f, -n, only the final one takes effect.\n\ +NOTE: The operation is not atomic. If DEST appears after mv has checked its\n\ +non-existence, it can be overwritten despite the -n option is used.\n\ "), stdout); fputs (_("\ --strip-trailing-slashes remove any trailing slashes from each SOURCE\n\ -- 2.13.6 From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 03 10:08:54 2018 Received: (at 29961) by debbugs.gnu.org; 3 Jan 2018 15:08:54 +0000 Received: from localhost ([127.0.0.1]:34498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWkf0-0002sT-BP for submit@debbugs.gnu.org; Wed, 03 Jan 2018 10:08:54 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:53546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWkey-0002sH-Dl for 29961@debbugs.gnu.org; Wed, 03 Jan 2018 10:08:52 -0500 Received: from localhost.localdomain (unknown [109.78.194.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id D69624B12; Wed, 3 Jan 2018 15:08:51 +0000 (GMT) Subject: Re: bug#29961: [PATCH] mv: document the missing atomicity of 'mv -n' To: Kamil Dudka , 29961@debbugs.gnu.org References: <20180103150147.16295-1-kdudka@redhat.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> Date: Wed, 3 Jan 2018 15:08:51 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20180103150147.16295-1-kdudka@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29961 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 03/01/18 15:01, Kamil Dudka wrote: > * src/mv.c (usage): Add note about the missing atomicity of 'mv -n'. > * doc/coreutils.texi (mv invocation): Likewise. > --- > doc/coreutils.texi | 3 +++ > src/mv.c | 2 ++ > 2 files changed, 5 insertions(+) > > diff --git a/doc/coreutils.texi b/doc/coreutils.texi > index 3fa083085..e7ca6a737 100644 > --- a/doc/coreutils.texi > +++ b/doc/coreutils.texi > @@ -9660,6 +9660,9 @@ If the response is not affirmative, the file is skipped. > Do not overwrite an existing file. > @mvOptsIfn > This option is mutually exclusive with @option{-b} or @option{--backup} option. > +Note that the operation is not atomic. If @var{dest} appears after > +@command{mv} has checked its non-existence, it can be overwritten despite > +the @option{-n} option is used. > > @item -u > @itemx --update > diff --git a/src/mv.c b/src/mv.c > index a8df730a7..a08e75649 100644 > --- a/src/mv.c > +++ b/src/mv.c > @@ -306,6 +306,8 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n\ > -i, --interactive prompt before overwrite\n\ > -n, --no-clobber do not overwrite an existing file\n\ > If you specify more than one of -i, -f, -n, only the final one takes effect.\n\ > +NOTE: The operation is not atomic. If DEST appears after mv has checked its\n\ > +non-existence, it can be overwritten despite the -n option is used.\n\ > "), stdout); > fputs (_("\ > --strip-trailing-slashes remove any trailing slashes from each SOURCE\n\ Eep, Seems like we should use RENAME_NOREPLACE in this case, rather than document the caveat? This is already used in shred. cheers, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 03 11:26:58 2018 Received: (at 29961) by debbugs.gnu.org; 3 Jan 2018 16:26:58 +0000 Received: from localhost ([127.0.0.1]:34534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWlsY-0004nX-IZ for submit@debbugs.gnu.org; Wed, 03 Jan 2018 11:26:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWlsW-0004nD-3G for 29961@debbugs.gnu.org; Wed, 03 Jan 2018 11:26:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F0B4C0B2A3D; Wed, 3 Jan 2018 16:26:50 +0000 (UTC) Received: from kdudka-nb.localnet (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D63866C43A; Wed, 3 Jan 2018 16:26:49 +0000 (UTC) From: Kamil Dudka To: =?ISO-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#29961: [PATCH] mv: document the missing atomicity of 'mv -n' Date: Wed, 03 Jan 2018 17:27:14 +0100 Message-ID: <126265219.ZQsyJp4JuT@kdudka-nb> In-Reply-To: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> References: <20180103150147.16295-1-kdudka@redhat.com> <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 03 Jan 2018 16:26:50 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, bug-coreutils@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On Wednesday, January 3, 2018 4:08:51 PM CET P=E1draig Brady wrote: > Eep, Seems like we should use RENAME_NOREPLACE in this case, > rather than document the caveat? Thanks for the suggestion! I will give it a try... Kamil > This is already used in shred. >=20 > cheers, > P=E1draig From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 03 13:24:23 2018 Received: (at 29961) by debbugs.gnu.org; 3 Jan 2018 18:24:24 +0000 Received: from localhost ([127.0.0.1]:34614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWniB-0007mI-PC for submit@debbugs.gnu.org; Wed, 03 Jan 2018 13:24:23 -0500 Received: from mail-qk0-f178.google.com ([209.85.220.178]:36207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eWniA-0007m6-IY for 29961@debbugs.gnu.org; Wed, 03 Jan 2018 13:24:22 -0500 Received: by mail-qk0-f178.google.com with SMTP id g123so2622321qka.3 for <29961@debbugs.gnu.org>; Wed, 03 Jan 2018 10:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=O5zzbqOM/+e2oFVLMZURzomKyKa0rKQiBbyTiPeYh7s=; b=nd3Nm2iZt66yvUBnQOvmiynN09VUV0yBHKL0YLFp/lzyeFZ+pyjTDsHhhPed0GQtkF fSkY75g7U2Wc8WrMcIXQ2e6Y1mj3199+EVzqdBotnZ3ZfJhR6pjaq09joNsXXEAKWVMO MMqB+TJV+0YBvvA+SyMGYiedhTicAvwuQKLvIWizM+2mbN+/DNt3aEKHYtOQ1WoVLP2z P87q0gNVc9U/zAAqJG1HlW2UfNLTtmfTr0nkGkUBknFDzka75GPJj1LUsPc+KpQYLXLX zxnmZG0r6qe3QnhkZUITylKozvEw3Lg0oC3VlKaAi2Q59MUuq5c5YKx/qI+oNgj//FRb U2eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=O5zzbqOM/+e2oFVLMZURzomKyKa0rKQiBbyTiPeYh7s=; b=BHMC535D8d/20/pTo9F0peQhrDGW9eGp3qnNGM+jpq1I7MO/MMXPNrbEKOHCpwnxTX DCP09Y/5tuHM0yYiyhnsYgS0HpduMqcKNvf3MRCnQFZHJzv41ZOGGcXXqfn9QmiHGHnR 98j1M3MRjQqRMzDa9TR0yFRKHyLBBVJYOq/zUR2erm8Zfg7JNmaoagFC8F0sEyhaQUQs 0wDUd6a+JMN3Qfg6NpAmtDGR0QdZRYUXAWnXOpi0pcxL+X9nX6rVoE01glK7QXhSerT2 9t5AY+Y6uaax4iCfUypuhof3p4olf/fOJh9Cg22ywl8yRQHoInIWvEfP1vzs0qSQdhSN htOA== X-Gm-Message-State: AKGB3mI+RkoCTUKu9/pmCNs7SxBQGiDCZa1un6DWqibng4VEbGDy19iN qdaVOnnoNwYbZ+6H2tO3rJXIISwc8KiSVg4kOdw= X-Google-Smtp-Source: ACJfBos93VqgODPeR55jFQRGOvFeNWv5/xYPxd1bAmqC3O1Gp6Ousw2YEJN07dOZZoyv2jBD2tS5T4y7qhA/uUBXYp0= X-Received: by 10.55.80.11 with SMTP id e11mr2849101qkb.75.1515003856924; Wed, 03 Jan 2018 10:24:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.55.164.10 with HTTP; Wed, 3 Jan 2018 10:23:56 -0800 (PST) In-Reply-To: <126265219.ZQsyJp4JuT@kdudka-nb> References: <20180103150147.16295-1-kdudka@redhat.com> <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <126265219.ZQsyJp4JuT@kdudka-nb> From: Jim Meyering Date: Wed, 3 Jan 2018 10:23:56 -0800 X-Google-Sender-Auth: K6KWCObvtLd7BPBNdVU1WBr7gbw Message-ID: Subject: Re: bug#29961: [PATCH] mv: document the missing atomicity of 'mv -n' To: Kamil Dudka Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, =?UTF-8?Q?P=C3=A1draig_Brady?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On Wed, Jan 3, 2018 at 8:27 AM, Kamil Dudka wrote: > On Wednesday, January 3, 2018 4:08:51 PM CET P=C3=A1draig Brady wrote: >> Eep, Seems like we should use RENAME_NOREPLACE in this case, >> rather than document the caveat? Good catch/fix. Thanks to both of you. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 04 04:00:18 2018 Received: (at 29961) by debbugs.gnu.org; 4 Jan 2018 09:00:19 +0000 Received: from localhost ([127.0.0.1]:35051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX1Nq-0006kQ-J1 for submit@debbugs.gnu.org; Thu, 04 Jan 2018 04:00:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX1No-0006k9-Jm for 29961@debbugs.gnu.org; Thu, 04 Jan 2018 04:00:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A70CA64130; Thu, 4 Jan 2018 09:00:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6480E608EE; Thu, 4 Jan 2018 09:00:06 +0000 (UTC) From: Kamil Dudka To: =?UTF-8?q?P=C3=A1draig=20Brady?= Subject: [PATCH] mv -n: do not overwrite the destination Date: Thu, 4 Jan 2018 10:00:03 +0100 Message-Id: <20180104090003.1117-1-kdudka@redhat.com> In-Reply-To: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 Jan 2018 09:00:10 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) ... if it is created by another process after mv has checked its non-existence. * src/copy.c (copy_internal): Use renameat2 (..., RENAME_NOREPLACE) if called by mv -n. If it fails with EEXIST in that case, pretend successful rename as if the existing destination file was detected by the preceding lstat call. * NEWS: Mention the fix. Fixes https://bugs.gnu.org/29961 --- NEWS | 3 +++ src/copy.c | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b89254f7e..e463ce6db 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ GNU coreutils NEWS -*- outline -*- df no longer hangs when given a fifo argument. [bug introduced in coreutils-7.3] + mv -n no longer overwrites the destination if it is created by another + process after mv has checked its non-existence. + ptx -S no longer infloops for a pattern which returns zero-length matches. [the bug dates back to the initial implementation] diff --git a/src/copy.c b/src/copy.c index 2a804945e..be4e357a8 100644 --- a/src/copy.c +++ b/src/copy.c @@ -53,6 +53,7 @@ #include "ignore-value.h" #include "ioblksize.h" #include "quote.h" +#include "renameat2.h" #include "root-uid.h" #include "same.h" #include "savedir.h" @@ -2319,7 +2320,12 @@ copy_internal (char const *src_name, char const *dst_name, if (x->move_mode) { - if (rename (src_name, dst_name) == 0) + int flags = 0; + if (x->interactive == I_ALWAYS_NO) + /* do not replace DST_NAME if it was created since our last check */ + flags = RENAME_NOREPLACE; + + if (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) == 0) { if (x->verbose) { @@ -2351,6 +2357,15 @@ copy_internal (char const *src_name, char const *dst_name, return true; } + if ((flags & RENAME_NOREPLACE) && (errno == EEXIST)) + { + /* Pretend the rename succeeded, so the caller (mv) + doesn't end up removing the source file. */ + if (rename_succeeded) + *rename_succeeded = true; + return true; + } + /* FIXME: someday, consider what to do when moving a directory into itself but when source and destination are on different devices. */ -- 2.13.6 From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 04 04:49:08 2018 Received: (at 29961) by debbugs.gnu.org; 4 Jan 2018 09:49:08 +0000 Received: from localhost ([127.0.0.1]:35068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX295-0007yQ-Jl for submit@debbugs.gnu.org; Thu, 04 Jan 2018 04:49:08 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX292-0007xu-Em for 29961@debbugs.gnu.org; Thu, 04 Jan 2018 04:49:05 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5AAA21615AC; Thu, 4 Jan 2018 01:48:58 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id TM_z24hdVG0z; Thu, 4 Jan 2018 01:48:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F28441615B2; Thu, 4 Jan 2018 01:48:56 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MHkiPUB5sv_1; Thu, 4 Jan 2018 01:48:56 -0800 (PST) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C7E3A1615AC; Thu, 4 Jan 2018 01:48:56 -0800 (PST) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Kamil Dudka , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <20180104090003.1117-1-kdudka@redhat.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Thu, 4 Jan 2018 01:48:56 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180104090003.1117-1-kdudka@redhat.com> Content-Type: multipart/mixed; boundary="------------3A34A6A00A58B759590FA4B6" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------3A34A6A00A58B759590FA4B6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Kamil Dudka wrote: > - if (rename (src_name, dst_name) =3D=3D 0) > + int flags =3D 0; > + if (x->interactive =3D=3D I_ALWAYS_NO) > + /* do not replace DST_NAME if it was created since our last ch= eck */ > + flags =3D RENAME_NOREPLACE; By then it's too late, as multiple decisions have been made on the basis = of=20 stat/lstat calls that are still subject to races. It's better to try the=20 renameat2 with RENAME_NOREPLACE first thing, and fall back on the existin= g code=20 only if renameat2 fails with errno !=3D EEXIST. Plus, there are some other problems when combining -u and -n. How about the attached patch instead? --------------3A34A6A00A58B759590FA4B6 Content-Type: text/x-patch; name="0001-mv-improve-n-atomicity.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-mv-improve-n-atomicity.patch" =46rom f80cb02081cdb1d5a31abac651c99bf0280fa6a6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 4 Jan 2018 01:46:01 -0800 Subject: [PATCH] mv: improve -n atomicity Problem reported by Kamil Dudka (Bug#29961). * NEWS: Mention these fixes. * doc/coreutils.texi (cp invocation, mv invocation): Mention that -n is silent, and that it overrides -u. * src/copy.c: Include renameat2.h. (copy_internal): If mv, try renameat2 first thing, with RENAME_NOREPLACE. If this works, skip most of the remaining code. Also, fail quickly if it fails with EEXIST, and we are using -n. * src/cp.c, src/mv.c (main): -n overrides -u. --- NEWS | 13 ++++++++ doc/coreutils.texi | 13 +++++--- src/copy.c | 87 ++++++++++++++++++++++++++++++++++++------------= ------ src/cp.c | 3 ++ src/mv.c | 3 ++ 5 files changed, 87 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index b89254f7e..b7ec20085 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,19 @@ GNU coreutils NEWS -*= - outline -*- =20 * Noteworthy changes in release ?.? (????-??-??) [?] =20 +** Bug fixes + + 'mv -n A B' no longer suffers from a race condition that can + overwrite a simultaneously-created B. This bug fix requires + platform support for the renameat2 or renameatx_np syscalls, found + in recent Linux and macOS kernels. + [bug introduced with coreutils-7.1] + + 'cp -n -u' and 'mv -n -u' now consistently ignore the -u option. + Previously, this option combination suffered from race conditions + that caused -u to sometimes override -n. + [bug introduced with coreutils-7.1] + =20 * Noteworthy changes in release 8.29 (2017-12-27) [stable] =20 diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 1c0e8a36c..6bb9f0906 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8569,7 +8569,8 @@ a regular file in the destination tree. @itemx --no-clobber @opindex -n @opindex --no-clobber -Do not overwrite an existing file. The @option{-n} option overrides a p= revious +Do not overwrite an existing file; silently do nothing instead. +This option overrides a previous @option{-i} option. This option is mutually exclusive with @option{-b} = or @option{--backup} option. =20 @@ -8809,8 +8810,10 @@ the comparison is to the source timestamp truncate= d to the resolutions of the destination file system and of the system calls used to update timestamps; this avoids duplicate work if several @samp{cp -pu} commands are executed with the same source and destination= =2E -If @option{--preserve=3Dlinks} is also specified (like with @samp{cp -au= } -for example), that will take precedence. Consequently, depending on the= +This option is ignored if the @option{-n} or @option{--no-clobber} +option is also specified. +Also, if @option{--preserve=3Dlinks} is also specified (like with @samp{= cp -au} +for example), that will take precedence; consequently, depending on the order that files are processed from the source, newer files in the desti= nation may be replaced, to mirror hard links in the source. =20 @@ -9657,7 +9660,7 @@ If the response is not affirmative, the file is ski= pped. @opindex -n @opindex --no-clobber @cindex prompts, omitting -Do not overwrite an existing file. +Do not overwrite an existing file; silently do nothing instead. @mvOptsIfn This option is mutually exclusive with @option{-b} or @option{--backup} = option. =20 @@ -9673,6 +9676,8 @@ source timestamp truncated to the resolutions of th= e destination file system and of the system calls used to update timestamps; this avoids duplicate work if several @samp{mv -u} commands are executed with the same source and destination. +This option is ignored if the @option{-n} or @option{--no-clobber} +option is also specified. =20 @item -v @itemx --verbose diff --git a/src/copy.c b/src/copy.c index 2a804945e..f63418bda 100644 --- a/src/copy.c +++ b/src/copy.c @@ -53,6 +53,7 @@ #include "ignore-value.h" #include "ioblksize.h" #include "quote.h" +#include "renameat2.h" #include "root-uid.h" #include "same.h" #include "savedir.h" @@ -1858,7 +1859,7 @@ copy_internal (char const *src_name, char const *ds= t_name, mode_t dst_mode_bits; mode_t omitted_permissions; bool restore_dst_mode =3D false; - char *earlier_file =3D NULL; + char *earlier_file; char *dst_backup =3D NULL; bool delayed_ok; bool copied_as_regular =3D false; @@ -1907,6 +1908,21 @@ copy_internal (char const *src_name, char const *d= st_name, =20 bool dereference =3D should_dereference (x, command_line_arg); =20 + int rename_errno =3D -1; + if (x->move_mode) + { + if (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name, RENAME_NORE= PLACE) + !=3D 0) + rename_errno =3D errno; + else + { + rename_errno =3D 0; + new_dst =3D true; + if (rename_succeeded) + *rename_succeeded =3D true; + } + } + if (!new_dst) { /* Regular files can be created by writing through symbolic @@ -1914,18 +1930,22 @@ copy_internal (char const *src_name, char const *= dst_name, destination when copying a regular file, and lstat otherwise. However, if we intend to unlink or remove the destination first, use lstat, since a copy won't actually be made to the - destination in that case. */ - bool use_stat =3D - ((S_ISREG (src_mode) - || (x->copy_as_regular - && ! (S_ISDIR (src_mode) || S_ISLNK (src_mode)))) - && ! (x->move_mode || x->symbolic_link || x->hard_link - || x->backup_type !=3D no_backups - || x->unlink_dest_before_opening)); - if ((use_stat - ? stat (dst_name, &dst_sb) - : lstat (dst_name, &dst_sb)) - !=3D 0) + destination in that case. Finally, if mv -n then set + USE_STAT to -1, i.e., do not use either stat or lstat. */ + int use_stat =3D + ((rename_errno =3D=3D EEXIST + && x->interactive =3D=3D I_ALWAYS_NO) + ? -1 + : ((S_ISREG (src_mode) + || (x->copy_as_regular + && ! (S_ISDIR (src_mode) || S_ISLNK (src_mode)))) + && ! (x->move_mode || x->symbolic_link || x->hard_link + || x->backup_type !=3D no_backups + || x->unlink_dest_before_opening))); + if (0 <=3D use_stat + && (fstatat (AT_FDCWD, dst_name, &dst_sb, + use_stat ? 0 : AT_SYMLINK_NOFOLLOW) + !=3D 0)) { if (errno !=3D ENOENT) { @@ -1938,17 +1958,23 @@ copy_internal (char const *src_name, char const *= dst_name, } } else - { /* Here, we know that dst_name exists, at least to the point - that it is stat'able or lstat'able. */ + { + /* The directory entry DST_NAME was found to exist. */ bool return_now; =20 - have_dst_lstat =3D !use_stat; - if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, - x, &return_now)) + if (use_stat < 0) + return_now =3D false; + else { - error (0, 0, _("%s and %s are the same file"), - quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); - return false; + have_dst_lstat =3D !use_stat; + if (x->interactive !=3D I_ALWAYS_NO + && ! same_file_ok (src_name, &src_sb, dst_name, &dst_s= b, + x, &return_now)) + { + error (0, 0, _("%s and %s are the same file"), + quoteaf_n (0, src_name), quoteaf_n (1, dst_name= )); + return false; + } } =20 if (!S_ISDIR (src_mode) && x->update) @@ -2233,7 +2259,9 @@ copy_internal (char const *src_name, char const *ds= t_name, Also, with --recursive, record dev/ino of each command-line directo= ry. We'll use that info to detect this problem: cp -R dir dir. */ =20 - if (x->recursive && S_ISDIR (src_mode)) + if (rename_errno =3D=3D 0) + earlier_file =3D NULL; + else if (x->recursive && S_ISDIR (src_mode)) { if (command_line_arg) earlier_file =3D remember_copied (dst_name, src_sb.st_ino, src_s= b.st_dev); @@ -2319,7 +2347,10 @@ copy_internal (char const *src_name, char const *d= st_name, =20 if (x->move_mode) { - if (rename (src_name, dst_name) =3D=3D 0) + if (rename_errno =3D=3D EEXIST) + rename_errno =3D rename (src_name, dst_name) =3D=3D 0 ? 0 : errn= o; + + if (rename_errno =3D=3D 0) { if (x->verbose) { @@ -2356,7 +2387,7 @@ copy_internal (char const *src_name, char const *ds= t_name, =20 /* This happens when attempting to rename a directory to a subdirectory of itself. */ - if (errno =3D=3D EINVAL) + if (rename_errno =3D=3D EINVAL) { /* FIXME: this is a little fragile in that it relies on rename= (2) failing with a specific errno value. Expect problems on @@ -2391,7 +2422,7 @@ copy_internal (char const *src_name, char const *ds= t_name, where you'd replace '18' with the integer in parentheses that was output from the perl one-liner above. If necessary, of course, change '/tmp' to some other directory.= */ - if (errno !=3D EXDEV) + if (rename_errno !=3D EXDEV) { /* There are many ways this can happen due to a race condition= =2E When something happens between the initial XSTAT and the @@ -2403,7 +2434,7 @@ copy_internal (char const *src_name, char const *ds= t_name, If the permissions on the directory containing the source o= r destination file are made too restrictive, the rename will fail. Etc. */ - error (0, errno, + error (0, rename_errno, _("cannot move %s to %s"), quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); forget_created (src_sb.st_ino, src_sb.st_dev); @@ -2417,9 +2448,9 @@ copy_internal (char const *src_name, char const *ds= t_name, and operate on dst_name here as a tighter constraint and also b= ecause src_mode is readily available here. */ if ((S_ISDIR (src_mode) ? rmdir (dst_name) : unlink (dst_name)) !=3D= 0 - && errno !=3D ENOENT) + && rename_errno !=3D ENOENT) { - error (0, errno, + error (0, rename_errno, _("inter-device move failed: %s to %s; unable to remove tar= get"), quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); forget_created (src_sb.st_ino, src_sb.st_dev); diff --git a/src/cp.c b/src/cp.c index 1b5bf7285..d81d41859 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1145,6 +1145,9 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } =20 + if (x.interactive =3D=3D I_ALWAYS_NO) + x.update =3D false; + if (make_backups && x.interactive =3D=3D I_ALWAYS_NO) { error (0, 0, diff --git a/src/mv.c b/src/mv.c index a8df730a7..818ca59b6 100644 --- a/src/mv.c +++ b/src/mv.c @@ -459,6 +459,9 @@ main (int argc, char **argv) quoteaf (file[n_files - 1])); } =20 + if (x.interactive =3D=3D I_ALWAYS_NO) + x.update =3D false; + if (make_backups && x.interactive =3D=3D I_ALWAYS_NO) { error (0, 0, --=20 2.14.3 --------------3A34A6A00A58B759590FA4B6-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 04 06:01:16 2018 Received: (at 29961) by debbugs.gnu.org; 4 Jan 2018 11:01:16 +0000 Received: from localhost ([127.0.0.1]:35085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX3Gs-0001T9-UT for submit@debbugs.gnu.org; Thu, 04 Jan 2018 06:01:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eX3Go-0001Ss-2D for 29961@debbugs.gnu.org; Thu, 04 Jan 2018 06:01:10 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBB958B103; Thu, 4 Jan 2018 11:01:03 +0000 (UTC) Received: from kdudka-nb.localnet (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 801775DA2A; Thu, 4 Jan 2018 11:01:03 +0000 (UTC) From: Kamil Dudka To: Paul Eggert Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination Date: Thu, 04 Jan 2018 12:01:28 +0100 Message-ID: <24444770.oSBMtbdO5L@kdudka-nb> In-Reply-To: References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <20180104090003.1117-1-kdudka@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 04 Jan 2018 11:01:03 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, =?ISO-8859-1?Q?P=E1draig?= Brady X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On Thursday, January 4, 2018 10:48:56 AM CET Paul Eggert wrote: > Kamil Dudka wrote: > > - if (rename (src_name, dst_name) == 0) > > + int flags = 0; > > + if (x->interactive == I_ALWAYS_NO) > > + /* do not replace DST_NAME if it was created since our last check > > */ + flags = RENAME_NOREPLACE; > > By then it's too late, as multiple decisions have been made on the basis of > stat/lstat calls that are still subject to races. Do you mean in the case of mv -n? Which decisions exactly? > It's better to try the > renameat2 with RENAME_NOREPLACE first thing, and fall back on the existing > code only if renameat2 fails with errno != EEXIST. > > Plus, there are some other problems when combining -u and -n. Sounds like a corner case. Please consider writing a separate patch for that. > How about the attached patch instead? I had difficulties trying to evaluate the patch. It does not compile with gcc-7.2.1: src/copy.c: In function 'copy_internal': src/copy.c:2340:17: error: 'earlier_file' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (! create_hard_link (earlier_file, dst_name, true, x->verbose, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dereference)) ~~~~~~~~~~~~ src/copy.c:2050:14: error: 'return_now' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (return_now) ^ So I added initializers to those two variables but then I saw multiple test-cases failing because of the patch: FAIL: tests/mv/hard-link-1 FAIL: tests/mv/mv-special-1 FAIL: tests/mv/part-fail FAIL: tests/mv/part-hardlink FAIL: tests/mv/part-rename FAIL: tests/mv/part-symlink Kamil From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 04 20:01:04 2018 Received: (at 29961) by debbugs.gnu.org; 5 Jan 2018 01:01:04 +0000 Received: from localhost ([127.0.0.1]:36157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXGNb-0001jU-Dv for submit@debbugs.gnu.org; Thu, 04 Jan 2018 20:01:03 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:52182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXGNZ-0001it-89 for 29961@debbugs.gnu.org; Thu, 04 Jan 2018 20:01:02 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C5BB0161455; Thu, 4 Jan 2018 17:00:54 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Aj_afhBadlvK; Thu, 4 Jan 2018 17:00:53 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3A3A416147C; Thu, 4 Jan 2018 17:00:53 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lA7_IQx2MAFk; Thu, 4 Jan 2018 17:00:53 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 11660160076; Thu, 4 Jan 2018 17:00:53 -0800 (PST) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Kamil Dudka References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <20180104090003.1117-1-kdudka@redhat.com> <24444770.oSBMtbdO5L@kdudka-nb> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Thu, 4 Jan 2018 17:00:52 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <24444770.oSBMtbdO5L@kdudka-nb> Content-Type: multipart/mixed; boundary="------------D95BB020AEFCC049E15539F7" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, =?UTF-8?Q?P=c3=a1draig_Brady?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------D95BB020AEFCC049E15539F7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 01/04/2018 03:01 AM, Kamil Dudka wrote: > On Thursday, January 4, 2018 10:48:56 AM CET Paul Eggert wrote: >> Kamil Dudka wrote: >>> - if (rename (src_name, dst_name) =3D=3D 0) >>> + int flags =3D 0; >>> + if (x->interactive =3D=3D I_ALWAYS_NO) >>> + /* do not replace DST_NAME if it was created since our last = check >>> */ + flags =3D RENAME_NOREPLACE; >> By then it's too late, as multiple decisions have been made on the bas= is of >> stat/lstat calls that are still subject to races. > Do you mean in the case of mv -n? Which decisions exactly? Mostly mv -n, but I suspect problems also for mv without -n.=C2=A0 It's a= ll=20 the decisions that depend on the result of lstat of dst_name, before=20 abandon_move decides whether to skip the rename. With the patch you=20 proposed, mv -n could call lstat and get a failure (with errno =3D=3D=20 ENOENT), then (after another process creates the file) call renameat2=20 with RENAME_NOREPLACE and after this fails (with errno =3D=3D EEXIST) rep= ort=20 an error. mv -n should silently succeed in that case. > Sounds like a corner case. Please consider writing a separate patch=20 > for that. OK, that's pretty straightforward so I installed it. Please see the=20 first attached patch. > I had difficulties trying to evaluate the patch. It does not compile That's what I get for sending an untested patch. Sorry. I fixed the bugs=20 you mentioned and tested the result. Please see the second attached=20 patch, which I have not installed. There is an interesting behavior change with this second patch.=20 Currently, 'mv -n a a' fails with a diagnostic "mv: 'a' and 'a' are the=20 same file". With the patch, 'mv -n a a' silently succeeds. The coreutils=20 documentation allows both behaviors. I doubt whether anyone cares, and=20 doing it the new way avoids some syscalls so I left it that way. --------------D95BB020AEFCC049E15539F7 Content-Type: text/x-patch; name="0001-mv-n-overrides-u.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-mv-n-overrides-u.patch" >From 7e244891b0c41bbf9f5b5917d1a71c183a8367ac Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 4 Jan 2018 13:57:40 -0800 Subject: [PATCH 1/2] mv: -n overrides -u * NEWS: Mention these fixes. * doc/coreutils.texi (cp invocation, mv invocation): Mention that -n is silent, and that it overrides -u. * src/cp.c, src/mv.c (main): -n overrides -u. --- NEWS | 7 +++++++ doc/coreutils.texi | 13 +++++++++---- src/cp.c | 3 +++ src/mv.c | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index b89254f7e..4712f5a46 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,13 @@ GNU coreutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + 'cp -n -u' and 'mv -n -u' now consistently ignore the -u option. + Previously, this option combination suffered from race conditions + that caused -u to sometimes override -n. + [bug introduced with coreutils-7.1] + * Noteworthy changes in release 8.29 (2017-12-27) [stable] diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 1c0e8a36c..6bb9f0906 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8569,7 +8569,8 @@ a regular file in the destination tree. @itemx --no-clobber @opindex -n @opindex --no-clobber -Do not overwrite an existing file. The @option{-n} option overrides a previous +Do not overwrite an existing file; silently do nothing instead. +This option overrides a previous @option{-i} option. This option is mutually exclusive with @option{-b} or @option{--backup} option. @@ -8809,8 +8810,10 @@ the comparison is to the source timestamp truncated to the resolutions of the destination file system and of the system calls used to update timestamps; this avoids duplicate work if several @samp{cp -pu} commands are executed with the same source and destination. -If @option{--preserve=links} is also specified (like with @samp{cp -au} -for example), that will take precedence. Consequently, depending on the +This option is ignored if the @option{-n} or @option{--no-clobber} +option is also specified. +Also, if @option{--preserve=links} is also specified (like with @samp{cp -au} +for example), that will take precedence; consequently, depending on the order that files are processed from the source, newer files in the destination may be replaced, to mirror hard links in the source. @@ -9657,7 +9660,7 @@ If the response is not affirmative, the file is skipped. @opindex -n @opindex --no-clobber @cindex prompts, omitting -Do not overwrite an existing file. +Do not overwrite an existing file; silently do nothing instead. @mvOptsIfn This option is mutually exclusive with @option{-b} or @option{--backup} option. @@ -9673,6 +9676,8 @@ source timestamp truncated to the resolutions of the destination file system and of the system calls used to update timestamps; this avoids duplicate work if several @samp{mv -u} commands are executed with the same source and destination. +This option is ignored if the @option{-n} or @option{--no-clobber} +option is also specified. @item -v @itemx --verbose diff --git a/src/cp.c b/src/cp.c index 1b5bf7285..d81d41859 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1145,6 +1145,9 @@ main (int argc, char **argv) usage (EXIT_FAILURE); } + if (x.interactive == I_ALWAYS_NO) + x.update = false; + if (make_backups && x.interactive == I_ALWAYS_NO) { error (0, 0, diff --git a/src/mv.c b/src/mv.c index a8df730a7..818ca59b6 100644 --- a/src/mv.c +++ b/src/mv.c @@ -459,6 +459,9 @@ main (int argc, char **argv) quoteaf (file[n_files - 1])); } + if (x.interactive == I_ALWAYS_NO) + x.update = false; + if (make_backups && x.interactive == I_ALWAYS_NO) { error (0, 0, -- 2.14.3 --------------D95BB020AEFCC049E15539F7 Content-Type: text/x-patch; name="0002-mv-improve-n-atomicity.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-mv-improve-n-atomicity.patch" >From 09d45e7c2e9b79a33c41271f9794d4133414f313 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 4 Jan 2018 16:46:24 -0800 Subject: [PATCH 2/2] mv: improve -n atomicity Problem reported by Kamil Dudka (Bug#29961). * NEWS: Mention this. * src/copy.c: Include renameat2.h. (copy_internal): If mv, try renameat2 first thing, with RENAME_NOREPLACE. If this works, skip most of the remaining code. Also, fail quickly if it fails with EEXIST, and we are using -n. --- NEWS | 6 +++++ src/copy.c | 88 +++++++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 4712f5a46..b7ec20085 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,12 @@ GNU coreutils NEWS -*- outline -*- ** Bug fixes + 'mv -n A B' no longer suffers from a race condition that can + overwrite a simultaneously-created B. This bug fix requires + platform support for the renameat2 or renameatx_np syscalls, found + in recent Linux and macOS kernels. + [bug introduced with coreutils-7.1] + 'cp -n -u' and 'mv -n -u' now consistently ignore the -u option. Previously, this option combination suffered from race conditions that caused -u to sometimes override -n. diff --git a/src/copy.c b/src/copy.c index 2a804945e..a1dce8e87 100644 --- a/src/copy.c +++ b/src/copy.c @@ -53,6 +53,7 @@ #include "ignore-value.h" #include "ioblksize.h" #include "quote.h" +#include "renameat2.h" #include "root-uid.h" #include "same.h" #include "savedir.h" @@ -1907,44 +1908,62 @@ copy_internal (char const *src_name, char const *dst_name, bool dereference = should_dereference (x, command_line_arg); - if (!new_dst) + int rename_errno = -1; + if (x->move_mode) { - /* Regular files can be created by writing through symbolic - links, but other files cannot. So use stat on the - destination when copying a regular file, and lstat otherwise. - However, if we intend to unlink or remove the destination - first, use lstat, since a copy won't actually be made to the - destination in that case. */ - bool use_stat = - ((S_ISREG (src_mode) - || (x->copy_as_regular - && ! (S_ISDIR (src_mode) || S_ISLNK (src_mode)))) - && ! (x->move_mode || x->symbolic_link || x->hard_link - || x->backup_type != no_backups - || x->unlink_dest_before_opening)); - if ((use_stat - ? stat (dst_name, &dst_sb) - : lstat (dst_name, &dst_sb)) + if (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name, RENAME_NOREPLACE) != 0) + rename_errno = errno; + else + { + rename_errno = 0; + new_dst = true; + if (rename_succeeded) + *rename_succeeded = true; + } + } + + if (!new_dst) + { + if (! (rename_errno == EEXIST && x->interactive == I_ALWAYS_NO)) { - if (errno != ENOENT) + /* Regular files can be created by writing through symbolic + links, but other files cannot. So use stat on the + destination when copying a regular file, and lstat otherwise. + However, if we intend to unlink or remove the destination + first, use lstat, since a copy won't actually be made to the + destination in that case. */ + bool use_lstat + = ((! S_ISREG (src_mode) + && (! x->copy_as_regular + || S_ISDIR (src_mode) || S_ISLNK (src_mode))) + || x->move_mode || x->symbolic_link || x->hard_link + || x->backup_type != no_backups + || x->unlink_dest_before_opening); + int fstatat_flags = use_lstat ? AT_SYMLINK_NOFOLLOW : 0; + if (fstatat (AT_FDCWD, dst_name, &dst_sb, fstatat_flags) == 0) { - error (0, errno, _("cannot stat %s"), quoteaf (dst_name)); - return false; + have_dst_lstat = use_lstat; + rename_errno = EEXIST; } else { + if (errno != ENOENT) + { + error (0, errno, _("cannot stat %s"), quoteaf (dst_name)); + return false; + } new_dst = true; } } - else - { /* Here, we know that dst_name exists, at least to the point - that it is stat'able or lstat'able. */ - bool return_now; - have_dst_lstat = !use_stat; - if (! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, - x, &return_now)) + if (rename_errno == EEXIST) + { + bool return_now = false; + + if (x->interactive != I_ALWAYS_NO + && ! same_file_ok (src_name, &src_sb, dst_name, &dst_sb, + x, &return_now)) { error (0, 0, _("%s and %s are the same file"), quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); @@ -2233,7 +2252,9 @@ copy_internal (char const *src_name, char const *dst_name, Also, with --recursive, record dev/ino of each command-line directory. We'll use that info to detect this problem: cp -R dir dir. */ - if (x->recursive && S_ISDIR (src_mode)) + if (rename_errno == 0) + earlier_file = NULL; + else if (x->recursive && S_ISDIR (src_mode)) { if (command_line_arg) earlier_file = remember_copied (dst_name, src_sb.st_ino, src_sb.st_dev); @@ -2319,7 +2340,10 @@ copy_internal (char const *src_name, char const *dst_name, if (x->move_mode) { - if (rename (src_name, dst_name) == 0) + if (rename_errno == EEXIST) + rename_errno = rename (src_name, dst_name) == 0 ? 0 : errno; + + if (rename_errno == 0) { if (x->verbose) { @@ -2356,7 +2380,7 @@ copy_internal (char const *src_name, char const *dst_name, /* This happens when attempting to rename a directory to a subdirectory of itself. */ - if (errno == EINVAL) + if (rename_errno == EINVAL) { /* FIXME: this is a little fragile in that it relies on rename(2) failing with a specific errno value. Expect problems on @@ -2391,7 +2415,7 @@ copy_internal (char const *src_name, char const *dst_name, where you'd replace '18' with the integer in parentheses that was output from the perl one-liner above. If necessary, of course, change '/tmp' to some other directory. */ - if (errno != EXDEV) + if (rename_errno != EXDEV) { /* There are many ways this can happen due to a race condition. When something happens between the initial XSTAT and the @@ -2403,7 +2427,7 @@ copy_internal (char const *src_name, char const *dst_name, If the permissions on the directory containing the source or destination file are made too restrictive, the rename will fail. Etc. */ - error (0, errno, + error (0, rename_errno, _("cannot move %s to %s"), quoteaf_n (0, src_name), quoteaf_n (1, dst_name)); forget_created (src_sb.st_ino, src_sb.st_dev); -- 2.14.3 --------------D95BB020AEFCC049E15539F7-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 06:56:01 2018 Received: (at 29961) by debbugs.gnu.org; 5 Jan 2018 11:56:01 +0000 Received: from localhost ([127.0.0.1]:36374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXQbQ-0004a8-P8 for submit@debbugs.gnu.org; Fri, 05 Jan 2018 06:56:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXQbO-0004Zu-LR for 29961@debbugs.gnu.org; Fri, 05 Jan 2018 06:55:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C310F4ACBB; Fri, 5 Jan 2018 11:55:52 +0000 (UTC) Received: from kdudka-nb.localnet (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7497B5D6A6; Fri, 5 Jan 2018 11:55:52 +0000 (UTC) From: Kamil Dudka To: Paul Eggert Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination Date: Fri, 05 Jan 2018 12:56:17 +0100 Message-ID: <36963468.Vlg6Wmr2pZ@kdudka-nb> In-Reply-To: References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <24444770.oSBMtbdO5L@kdudka-nb> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 05 Jan 2018 11:55:52 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, =?ISO-8859-1?Q?P=E1draig?= Brady X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On Friday, January 5, 2018 2:00:52 AM CET Paul Eggert wrote: > On 01/04/2018 03:01 AM, Kamil Dudka wrote: > > On Thursday, January 4, 2018 10:48:56 AM CET Paul Eggert wrote: > >> Kamil Dudka wrote: > >>> - if (rename (src_name, dst_name) == 0) > >>> + int flags = 0; > >>> + if (x->interactive == I_ALWAYS_NO) > >>> + /* do not replace DST_NAME if it was created since our last > >>> check > >>> */ + flags = RENAME_NOREPLACE; > >> > >> By then it's too late, as multiple decisions have been made on the basis > >> of > >> stat/lstat calls that are still subject to races. > > > > Do you mean in the case of mv -n? Which decisions exactly? > > Mostly mv -n, but I suspect problems also for mv without -n. My patch changes nothing but the 'mv -n' behavior. It could hardly break (or even change behavior of) anything else. Your patch reworks the logic of copy_internal(), which itself is very fragile, as you learned from the first version of your patch. > It's all > the decisions that depend on the result of lstat of dst_name, before > abandon_move decides whether to skip the rename. I am only fixing the case where the destination file is created after the lstat() call. In that case, the only result is ENOENT, which is harmless. > With the patch you > proposed, mv -n could call lstat and get a failure (with errno == > ENOENT), then (after another process creates the file) call renameat2 > with RENAME_NOREPLACE and after this fails (with errno == EEXIST) Exactly. That is the only case that my patch intended to fix. > report an error. Nope. It will silently succeed with my patch. Did you try it? > mv -n should silently succeed in that case. I agree. > > Sounds like a corner case. Please consider writing a separate patch > > for that. > > OK, that's pretty straightforward so I installed it. Please see the > first attached patch. > > > I had difficulties trying to evaluate the patch. It does not compile > > That's what I get for sending an untested patch. Sorry. I fixed the bugs > you mentioned and tested the result. Please see the second attached > patch, which I have not installed. Thanks for the fixup! > There is an interesting behavior change with this second patch. > Currently, 'mv -n a a' fails with a diagnostic "mv: 'a' and 'a' are the > same file". With the patch, 'mv -n a a' silently succeeds. The coreutils > documentation allows both behaviors. I doubt whether anyone cares, and > doing it the new way avoids some syscalls so I left it that way. If you decide to apply your patch anyway, please document this change at least in the commit message. Still my concern is that your patch also changes the behavior of 'mv' without '-n', which is neither tested, nor documented. Kamil From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 10:29:59 2018 Received: (at 29961) by debbugs.gnu.org; 5 Jan 2018 15:29:59 +0000 Received: from localhost ([127.0.0.1]:37168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXTwV-00053D-DO for submit@debbugs.gnu.org; Fri, 05 Jan 2018 10:29:59 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:40732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXTwT-000534-MR for 29961@debbugs.gnu.org; Fri, 05 Jan 2018 10:29:58 -0500 Received: from localhost.localdomain (unknown [109.79.81.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 6F05D9A6E; Fri, 5 Jan 2018 15:29:56 +0000 (GMT) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Kamil Dudka , Paul Eggert References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <24444770.oSBMtbdO5L@kdudka-nb> <36963468.Vlg6Wmr2pZ@kdudka-nb> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Fri, 5 Jan 2018 15:29:55 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <36963468.Vlg6Wmr2pZ@kdudka-nb> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 05/01/18 11:56, Kamil Dudka wrote: > On Friday, January 5, 2018 2:00:52 AM CET Paul Eggert wrote: >> On 01/04/2018 03:01 AM, Kamil Dudka wrote: >>> On Thursday, January 4, 2018 10:48:56 AM CET Paul Eggert wrote: >>>> Kamil Dudka wrote: >>>>> - if (rename (src_name, dst_name) == 0) >>>>> + int flags = 0; >>>>> + if (x->interactive == I_ALWAYS_NO) >>>>> + /* do not replace DST_NAME if it was created since our last >>>>> check >>>>> */ + flags = RENAME_NOREPLACE; >>>> >>>> By then it's too late, as multiple decisions have been made on the basis >>>> of >>>> stat/lstat calls that are still subject to races. >>> >>> Do you mean in the case of mv -n? Which decisions exactly? >> >> Mostly mv -n, but I suspect problems also for mv without -n. > > My patch changes nothing but the 'mv -n' behavior. It could hardly break > (or even change behavior of) anything else. Your patch reworks the logic > of copy_internal(), which itself is very fragile, as you learned from the > first version of your patch. > >> It's all >> the decisions that depend on the result of lstat of dst_name, before >> abandon_move decides whether to skip the rename. > > I am only fixing the case where the destination file is created after the > lstat() call. In that case, the only result is ENOENT, which is harmless. > >> With the patch you >> proposed, mv -n could call lstat and get a failure (with errno == >> ENOENT), then (after another process creates the file) call renameat2 >> with RENAME_NOREPLACE and after this fails (with errno == EEXIST) > > Exactly. That is the only case that my patch intended to fix. > >> report an error. > > Nope. It will silently succeed with my patch. Did you try it? > >> mv -n should silently succeed in that case. > > I agree. > >>> Sounds like a corner case. Please consider writing a separate patch >>> for that. >> >> OK, that's pretty straightforward so I installed it. Please see the >> first attached patch. >> >>> I had difficulties trying to evaluate the patch. It does not compile >> >> That's what I get for sending an untested patch. Sorry. I fixed the bugs >> you mentioned and tested the result. Please see the second attached >> patch, which I have not installed. > > Thanks for the fixup! > >> There is an interesting behavior change with this second patch. >> Currently, 'mv -n a a' fails with a diagnostic "mv: 'a' and 'a' are the >> same file". With the patch, 'mv -n a a' silently succeeds. The coreutils >> documentation allows both behaviors. I doubt whether anyone cares, and >> doing it the new way avoids some syscalls so I left it that way. > > If you decide to apply your patch anyway, please document this change > at least in the commit message. Still my concern is that your patch also > changes the behavior of 'mv' without '-n', which is neither tested, nor > documented. Thanks to both of you. The approaches can be summarized as: Orig: --------------------------------- stat() => ENOENT rename() may clobber file Kamil's: --------------------------------- stat() => ENOENT renameat() doesn't clobber file if -n exit early if -n && errno==EEXIST Paul's: --------------------------------- renameat2() => EEXIST -n => exit early if (renameat2_failed) unless EEXIST && -n stat() if (renameat2_failed) rename() I think both patches ensure rename() doesn't clobber when -n is specified. Paul's is more encompassing for the non -n case. For example if a directory was _created_ externally after the stat() in Kamil's logic above, it could be erroneously clobbered. Paul's also avoids a stat() in the common case where the initial renameat2() succeeds. Both versions are still susceptible to erroneous clobbering if the destination file was externally _replaced_ by a directory for example, after the stat(). Though that is less likely. Paul's fix looks good to apply here, since it's more encompassing. cheers, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 11:19:31 2018 Received: (at 29961) by debbugs.gnu.org; 5 Jan 2018 16:19:31 +0000 Received: from localhost ([127.0.0.1]:37196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXUiR-0006Ap-Hv for submit@debbugs.gnu.org; Fri, 05 Jan 2018 11:19:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXUiP-0006Ac-DC for 29961@debbugs.gnu.org; Fri, 05 Jan 2018 11:19:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E31A30EDE8; Fri, 5 Jan 2018 16:19:23 +0000 (UTC) Received: from kdudka-nb.localnet (unknown [10.43.2.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6AED6017B; Fri, 5 Jan 2018 16:19:22 +0000 (UTC) From: Kamil Dudka To: =?ISO-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination Date: Fri, 05 Jan 2018 17:19:47 +0100 Message-ID: <2142549.IgQGA5uHeq@kdudka-nb> In-Reply-To: References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 05 Jan 2018 16:19:23 +0000 (UTC) X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On Friday, January 5, 2018 4:29:55 PM CET P=E1draig Brady wrote: > Thanks to both of you. > The approaches can be summarized as: >=20 > Orig: > --------------------------------- > stat() =3D> ENOENT > > rename() may clobber file >=20 > Kamil's: > --------------------------------- > stat() =3D> ENOENT > > renameat() doesn't clobber file if -n > exit early if -n && errno=3D=3DEEXIST >=20 > Paul's: > --------------------------------- > renameat2() =3D> EEXIST > -n =3D> exit early > if (renameat2_failed) > unless EEXIST && -n > stat() > if (renameat2_failed) > rename() >=20 > I think both patches ensure rename() doesn't clobber when -n is specified. Thanks for the summary! > Paul's is more encompassing for the non -n case. > For example if a directory was _created_ externally > after the stat() in Kamil's logic above, > it could be erroneously clobbered. Do you mean without -n? I am getting the following error message in that case: mv: cannot move 'a' to 'b': Is a directory =2E.. which is consistent with the original behavior. > Paul's also avoids a stat() in the common case > where the initial renameat2() succeeds. At the cost of _not_ avoiding the renameat2() call in the most common case. I think both the solutions are equivalent performance-wise. > Both versions are still susceptible to erroneous clobbering > if the destination file was externally _replaced_ > by a directory for example, after the stat(). > Though that is less likely. >=20 > Paul's fix looks good to apply here, > since it's more encompassing. No problem with that. Anyway, I will go with my conservative (or even the= =20 documentation-only) patch for RHEL-7, which was the trigger of this effort,= =20 because Paul's patch comes with changes of behavior observable beyond the=20 reported scenario. Kamil > cheers, > P=E1draig From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 05 17:59:19 2018 Received: (at 29961) by debbugs.gnu.org; 5 Jan 2018 22:59:19 +0000 Received: from localhost ([127.0.0.1]:37414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXaxL-0002ER-2u for submit@debbugs.gnu.org; Fri, 05 Jan 2018 17:59:19 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXaxH-0002EB-8g for 29961@debbugs.gnu.org; Fri, 05 Jan 2018 17:59:16 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AC458161336; Fri, 5 Jan 2018 14:59:08 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id pgH4btfc6bDX; Fri, 5 Jan 2018 14:59:06 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E7360161588; Fri, 5 Jan 2018 14:59:06 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LiMHqXBi8xXb; Fri, 5 Jan 2018 14:59:06 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BF303161336; Fri, 5 Jan 2018 14:59:06 -0800 (PST) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Kamil Dudka , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> <2142549.IgQGA5uHeq@kdudka-nb> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> Date: Fri, 5 Jan 2018 14:59:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <2142549.IgQGA5uHeq@kdudka-nb> Content-Type: multipart/mixed; boundary="------------D1F8EEB0EC14093A3BDDF2F6" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------D1F8EEB0EC14093A3BDDF2F6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 01/05/2018 08:19 AM, Kamil Dudka wrote: > I am only fixing the case where the destination file is created after t= he > lstat() call. In that case, the only result is ENOENT, which is harmle= ss. > Ah, you're right. Sorry, I misread your patch. It should work. > On Friday, January 5, 2018 4:29:55 PM CET P=C3=A1draig Brady wrote: > >> Paul's also avoids a stat() in the common case >> where the initial renameat2() succeeds. > At the cost of _not_ avoiding the renameat2() call in the most common c= ase. I expect that the most common case is 'mv A B' where B does not already=20 exist. This is the case that avoids the stat of B. Come to think of it, we don't need to stat A either, when the initial=20 renameat2 succeeds. Attached is a revised proposed patchset to do that.=20 The first is the same as before; the second causes 'mv A B' to issue=20 just a renameat2 syscall (with no calls to stat) in the common case=20 where A exists and B does not. > I will go with my conservative (or even the > documentation-only) patch for RHEL-7, which was the trigger of this eff= ort, > because Paul's patch comes with changes of behavior observable beyond t= he Sounds good. --------------D1F8EEB0EC14093A3BDDF2F6 Content-Type: text/plain; charset=UTF-8; name="0001-mv-improve-n-atomicity.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-mv-improve-n-atomicity.txt" RnJvbSAwOWQ0NWU3YzJlOWI3OWEzM2M0MTI3MWY5Nzk0ZDQxMzM0MTRmMzEzIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBUaHUsIDQgSmFuIDIwMTggM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W1lLCAmZHN0X3NiKSkKKyAg ICAgIGlmIChyZW5hbWVhdDIgKEFUX0ZEQ1dELCBzcmNfbmFtZSwgQVRfRkRDV0QsIGRzdF9u YW1lLCBSRU5BTUVfTk9SRVBMQUNFKQogICAgICAgICAgICE9IDApCisgICAgICAgIHJlbmFt ZV9lcnJubyA9IGVycm5vOworICAgICAgZWxzZQorICAgICAgICB7CisgICAgICAgICAgcmVu YW1lX2Vycm5vID0gMDsKKyAgICAgICAgICBuZXdfZHN0ID0gdHJ1ZTsKKyAgICAgICAgICBp ZiAocmVuYW1lX3N1Y2NlZWRlZCkKKyAgICAgICAgICAgICpyZW5hbWVfc3VjY2VlZGVkID0g dHJ1ZTsKKyAgICAgICAgfQorICAgIH0KKworICBpZiAoIW5ld19kc3QpCisgICAgeworICAg ICAgaWYgKCEgKHJlbmFtZV9lcnJubyA9PSBFRVhJU1QgJiYgeC0+aW50ZXJhY3RpdmUgPT0g SV9BTFdBWVNfTk8pKQogICAgICAgICB7Ci0gICAgICAgICAgaWYgKGVycm5vICE9IEVOT0VO VCkKKyAgICAgICAgICAvKiBSZWd1bGFyIGZpbGVzIGNhbiBiZSBjcmVhdGVkIGJ5IHdyaXRp bmcgdGhyb3VnaCBzeW1ib2xpYworICAgICAgICAgICAgIGxpbmtzLCBidXQgb3RoZXIgZmls ZXMgY2Fubm90LiAgU28gdXNlIHN0YXQgb24gdGhlCisgICAgICAgICAgICAgZGVzdGluYXRp b24gd2hlbiBjb3B5aW5nIGEgcmVndWxhciBmaWxlLCBhbmQgbHN0YXQgb3RoZXJ3aXNlLgor ICAgICAgICAgICAgIEhvd2V2ZXIsIGlmIHdlIGludGVuZCB0byB1bmxpbmsgb3IgcmVtb3Zl IHRoZSBkZXN0aW5hdGlvbgorICAgICAgICAgICAgIGZpcnN0LCB1c2UgbHN0YXQsIHNpbmNl IGEgY29weSB3b24ndCBhY3R1YWxseSBiZSBtYWRlIHRvIHRoZQorICAgICAgICAgICAgIGRl c3RpbmF0aW9uIGluIHRoYXQgY2FzZS4gICovCisgICAgICAgICAgYm9vbCB1c2VfbHN0YXQK KyAgICAgICAgICAgID0gKCghIFNfSVNSRUcgKHNyY19tb2RlKQorICAgICAgICAgICAgICAg ICYmICghIHgtPmNvcHlfYXNfcmVndWxhcgorICAgICAgICAgICAgICAgICAgICB8fCBTX0lT RElSIChzcmNfbW9kZSkgfHwgU19JU0xOSyAoc3JjX21vZGUpKSkKKyAgICAgICAgICAgICAg IHx8IHgtPm1vdmVfbW9kZSB8fCB4LT5zeW1ib2xpY19saW5rIHx8IHgtPmhhcmRfbGluawor ICAgICAgICAgICAgICAgfHwgeC0+YmFja3VwX3R5cGUgIT0gbm9fYmFja3VwcworICAgICAg ICAgICAgICAgfHwgeC0+dW5saW5rX2Rlc3RfYmVmb3JlX29wZW5pbmcpOworICAgICAgICAg IGludCBmc3RhdGF0X2ZsYWdzID0gdXNlX2xzdGF0ID8gQVRfU1lNTElOS19OT0ZPTExPVyA6 IDA7CisgICAgICAgICAgaWYgKGZzdGF0YXQgKEFUX0ZEQ1dELCBkc3RfbmFtZSwgJmRzdF9z YiwgZnN0YXRhdF9mbGFncykgPT0gMCkKICAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAg ZXJyb3IgKDAsIGVycm5vLCBfKCJjYW5ub3Qgc3RhdCAlcyIpLCBxdW90ZWFmIChkc3RfbmFt ZSkpOwotICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgICAgICAgIGhhdmVf ZHN0X2xzdGF0ID0gdXNlX2xzdGF0OworICAgICAgICAgICAgICByZW5hbWVfZXJybm8gPSBF RVhJU1Q7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgewor ICAgICAgICAgICAgICBpZiAoZXJybm8gIT0gRU5PRU5UKQorICAgICAgICAgICAgICAgIHsK KyAgICAgICAgICAgICAgICAgIGVycm9yICgwLCBlcnJubywgXygiY2Fubm90IHN0YXQgJXMi KSwgcXVvdGVhZiAoZHN0X25hbWUpKTsKKyAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxz ZTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgIG5ld19kc3QgPSB0cnVlOwog ICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICBlbHNlCi0gICAgICAgIHsgLyogSGVy ZSwgd2Uga25vdyB0aGF0IGRzdF9uYW1lIGV4aXN0cywgYXQgbGVhc3QgdG8gdGhlIHBvaW50 Ci0gICAgICAgICAgICAgdGhhdCBpdCBpcyBzdGF0J2FibGUgb3IgbHN0YXQnYWJsZS4gICov Ci0gICAgICAgICAgYm9vbCByZXR1cm5fbm93OwogCi0gICAgICAgICAgaGF2ZV9kc3RfbHN0 YXQgPSAhdXNlX3N0YXQ7Ci0gICAgICAgICAgaWYgKCEgc2FtZV9maWxlX29rIChzcmNfbmFt ZSwgJnNyY19zYiwgZHN0X25hbWUsICZkc3Rfc2IsCi0gICAgICAgICAgICAgICAgICAgICAg ICAgICAgICB4LCAmcmV0dXJuX25vdykpCisgICAgICBpZiAocmVuYW1lX2Vycm5vID09IEVF WElTVCkKKyAgICAgICAgeworICAgICAgICAgIGJvb2wgcmV0dXJuX25vdyA9IGZhbHNlOwor CisgICAgICAgICAgaWYgKHgtPmludGVyYWN0aXZlICE9IElfQUxXQVlTX05PCisgICAgICAg ICAgICAgICYmICEgc2FtZV9maWxlX29rIChzcmNfbmFtZSwgJnNyY19zYiwgZHN0X25hbWUs ICZkc3Rfc2IsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4LCAmcmV0dXJu X25vdykpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgIGVycm9yICgwLCAwLCBfKCIl cyBhbmQgJXMgYXJlIHRoZSBzYW1lIGZpbGUiKSwKICAgICAgICAgICAgICAgICAgICAgIHF1 b3RlYWZfbiAoMCwgc3JjX25hbWUpLCBxdW90ZWFmX24gKDEsIGRzdF9uYW1lKSk7CkBAIC0y MjMzLDcgKzI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WNlIGNvbmRpdGlvbi4KICAg ICAgICAgICAgICBXaGVuIHNvbWV0aGluZyBoYXBwZW5zIGJldHdlZW4gdGhlIGluaXRpYWwg WFNUQVQgYW5kIHRoZQpAQCAtMjQwMyw3ICsyNDI3LDcgQEAgY29weV9pbnRlcm5hbCAoY2hh ciBjb25zdCAqc3JjX25hbWUsIGNoYXIgY29uc3QgKmRzdF9uYW1lLAogICAgICAgICAgICAg IElmIHRoZSBwZXJtaXNzaW9ucyBvbiB0aGUgZGlyZWN0b3J5IGNvbnRhaW5pbmcgdGhlIHNv dXJjZSBvcgogICAgICAgICAgICAgIGRlc3RpbmF0aW9uIGZpbGUgYXJlIG1hZGUgdG9vIHJl c3RyaWN0aXZlLCB0aGUgcmVuYW1lIHdpbGwKICAgICAgICAgICAgICBmYWlsLiAgRXRjLiAg Ki8KLSAgICAgICAgICBlcnJvciAoMCwgZXJybm8sCisgICAgICAgICAgZXJyb3IgKDAsIHJl bmFtZV9lcnJubywKICAgICAgICAgICAgICAgICAgXygiY2Fubm90IG1vdmUgJXMgdG8gJXMi KSwKICAgICAgICAgICAgICAgICAgcXVvdGVhZl9uICgwLCBzcmNfbmFtZSksIHF1b3RlYWZf biAoMSwgZHN0X25hbWUpKTsKICAgICAgICAgICBmb3JnZXRfY3JlYXRlZCAoc3JjX3NiLnN0 X2lubywgc3JjX3NiLnN0X2Rldik7Ci0tIAoyLjE0LjMKCg== --------------D1F8EEB0EC14093A3BDDF2F6 Content-Type: text/plain; charset=UTF-8; name="0002-mv-fewer-syscalls-for-mv-a-b.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0002-mv-fewer-syscalls-for-mv-a-b.txt" RnJvbSBhNDEyZjhhZmM2MDMzNzhhNzg5Y2U0ZThkMThiYzZkOWM0Y2EzZDEzIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBGcmks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tPmludGVyYWN0aXZlICE9IElfQUxXQVlTX05PKQogICAg IHsKLSAgICAgIGVycm9yICgwLCAwLCAhIHgtPmluc3RhbGxfbW9kZSAvKiBjcCAqLwotICAg ICAgICAgICAgICAgICAgID8gXygiLXIgbm90IHNwZWNpZmllZDsgb21pdHRpbmcgZGlyZWN0 b3J5ICVzIikKLSAgICAgICAgICAgICAgICAgICA6IF8oIm9taXR0aW5nIGRpcmVjdG9yeSAl cyIpLAotICAgICAgICAgICAgIHF1b3RlYWYgKHNyY19uYW1lKSk7Ci0gICAgICByZXR1cm4g ZmFsc2U7CisgICAgICBjaGFyIGNvbnN0ICpuYW1lID0gcmVuYW1lX2Vycm5vID09IDAgPyBk c3RfbmFtZSA6IHNyY19uYW1lOworICAgICAgaWYgKFhTVEFUICh4LCBuYW1lLCAmc3JjX3Ni KSAhPSAwKQorICAgICAgICB7CisgICAgICAgICAgZXJyb3IgKDAsIGVycm5vLCBfKCJjYW5u b3Qgc3RhdCAlcyIpLCBxdW90ZWFmIChuYW1lKSk7CisgICAgICAgICAgcmV0dXJuIGZhbHNl OworICAgICAgICB9CisKKyAgICAgIHNyY19tb2RlID0gc3JjX3NiLnN0X21vZGU7CisKKyAg ICAgIGlmIChTX0lTRElSIChzcmNfbW9kZSkgJiYgIXgtPnJlY3Vyc2l2ZSkKKyAgICAgICAg eworICAgICAgICAgIGVycm9yICgwLCAwLCAhIHgtPmluc3RhbGxfbW9kZSAvKiBjcCAqLwor ICAgICAgICAgICAgICAgICA/IF8oIi1yIG5vdCBzcGVjaWZpZWQ7IG9taXR0aW5nIGRpcmVj dG9yeSAlcyIpCisgICAgICAgICAgICAgICAgIDogXygib21pdHRpbmcgZGlyZWN0b3J5ICVz IiksCisgICAgICAgICAgICAgICAgIHF1b3RlYWYgKHNyY19uYW1lKSk7CisgICAgICAgICAg cmV0dXJuIGZhbHNlOworICAgICAgICB9CiAgICAgfQogCiAgIC8qIERldGVjdCB0aGUgY2Fz ZSBpbiB3aGljaCB0a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c3VjY2VlZGVkKQotICAgICAgICAgICAgKnJlbmFt ZV9zdWNjZWVkZWQgPSB0cnVlOwotICAgICAgICB9Ci0gICAgfQotCiAgIGlmICghbmV3X2Rz dCkKICAgICB7CiAgICAgICBpZiAoISAocmVuYW1lX2Vycm5vID09IEVFWElTVCAmJiB4LT5p bnRlcmFjdGl2ZSA9PSBJX0FMV0FZU19OTykpCkBAIC0xOTcwLDcgKzE5NzAsNyBAQCBjb3B5 X2ludGVybmFsIChjaGFyIGNvbnN0ICpzcmNfbmFtZSwgY2hhciBjb25zdCAqZHN0X25hbWUs CiAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgIH0KIAotICAgICAg ICAgIGlmICghU19JU0RJUiAoc3JjX21vZGUpICYmIHgtPnVwZGF0ZSkKKyAgICAgICAgICBp ZiAoeC0+dXBkYXRlICYmICFTX0lTRElSIChzcmNfbW9kZSkpCiAgICAgICAgICAgICB7CiAg ICAgICAgICAgICAgIC8qIFdoZW4gcHJlc2VydmluZyB0aW1lc3RhbXBzIChidXQgbm90IG1v dmluZyB3aXRoaW4gYSBmaWxlCiAgICAgICAgICAgICAgICAgIHN5c3RlbSksIGRvbid0IHdv cnJ5IGlmIHRoZSBkZXN0aW5hdGlvbiB0aW1lc3RhbXAgaXMKQEAgLTIzNjAsNyArMjM2MCw3 IEBAIGNvcHlfaW50ZXJuYWwgKGNoYXIgY29uc3QgKnNyY19uYW1lLCBjaGFyIGNvbnN0ICpk c3RfbmFtZSwKICAgICAgICAgICBpZiAocmVuYW1lX3N1Y2NlZWRlZCkKICAgICAgICAgICAg ICpyZW5hbWVfc3VjY2VlZGVkID0gdHJ1ZTsKIAotICAgICAgICAgIGlmIChjb21tYW5kX2xp bmVfYXJnKQorICAgICAgICAgIGlmIChjb21tYW5kX2xpbmVfYXJnICYmICF4LT5sYXN0X2Zp bGUpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgIC8qIFJlY29yZCBkZXN0aW5hdGlv biB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SwKKyAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBSRU5BTUVfTk9SRVBMQUNFKQorICAg ICAgICAgICAgICAgICAgICAgICAgICA/IGVycm5vIDogMCk7CisgICAgICBpZiAoeC5yZW5h bWVfZXJybm8gIT0gMCAmJiB0YXJnZXRfZGlyZWN0b3J5X29wZXJhbmQgKGZpbGVbbl9maWxl cyAtIDFdKSkKKyAgICAgICAgeworICAgICAgICAgIHgucmVuYW1lX2Vycm5vID0gLTE7Cisg ICAgICAgICAgdGFyZ2V0X2RpcmVjdG9yeSA9IGZpbGVbLS1uX2ZpbGVzXTsKKyAgICAgICAg fQogICAgICAgZWxzZSBpZiAoMiA8IG5fZmlsZXMpCiAgICAgICAgIGRpZSAoRVhJVF9GQUlM VVJFLCAwLCBfKCJ0YXJnZXQgJXMgaXMgbm90IGEgZGlyZWN0b3J5IiksCiAgICAgICAgICAg ICAgcXVvdGVhZiAoZmlsZVtuX2ZpbGVzIC0gMV0pKTsKQEAgLTQ4NywxMCArNDk1LDE2IEBA IG1haW4gKGludCBhcmdjLCBjaGFyICoqYXJndikKIAogICAgICAgb2sgPSB0cnVlOwogICAg ICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuX2ZpbGVzOyArK2kpCi0gICAgICAgIG9rICY9IG1v dmVmaWxlIChmaWxlW2ldLCB0YXJnZXRfZGlyZWN0b3J5LCB0cnVlLCAmeCk7CisgICAgICAg IHsKKyAgICAgICAgICB4Lmxhc3RfZmlsZSA9IGkgKyAxID09IG5fZmlsZXM7CisgICAgICAg ICAgb2sgJj0gbW92ZWZpbGUgKGZpbGVbaV0sIHRhcmdldF9kaXJlY3RvcnksIHRydWUsICZ4 KTsKKyAgICAgICAgfQogICAgIH0KICAgZWxzZQotICAgIG9rID0gbW92ZWZpbGUgKGZpbGVb MF0sIGZpbGVbMV0sIGZhbHNlLCAmeCk7CisgICAgeworICAgICAgeC5sYXN0X2ZpbGUgPSB0 cnVlOworICAgICAgb2sgPSBtb3ZlZmlsZSAoZmlsZVswXSwgZmlsZVsxXSwgZmFsc2UsICZ4 KTsKKyAgICB9CiAKICAgcmV0dXJuIG9rID8gRVhJVF9TVUNDRVNTIDogRVhJVF9GQUlMVVJF OwogfQotLSAKMi4xNC4zCgo= --------------D1F8EEB0EC14093A3BDDF2F6 Content-Type: text/plain; charset=UTF-8; name="0003-mv-clarify-mv-n-A-A-change.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0003-mv-clarify-mv-n-A-A-change.txt" RnJvbSA1ZTkyMjE5MjRlYjY3YTkyMTM0YjBkY2ZiMjYyOWM4MmQ3N2I5NDNjIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBGcmksIDUgSmFuIDIwMTggMTQ6MzY6MDIgLTA4MDAKU3ViamVjdDogW1BBVENI IDMvM10gPT9VVEYtOD9xP212Oj0yMGNsYXJpZnk9MjA9RTI9ODA9OThtdj0yMC1uPTIwQT0y MEE/PQogPT9VVEYtOD9xPz1FMj04MD05OT0yMGNoYW5nZT89Ck1JTUUtVmVyc2lvbjogMS4w CkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5z ZmVyLUVuY29kaW5nOiA4Yml0CgotLS0KIE5FV1MgfCAzICsrLQogMSBmaWxlIGNoYW5nZWQs IDIgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL05FV1MgYi9O RVdTCmluZGV4IGI3ZWMyMDA4NS4uOGE5ZTA5ZWI0IDEwMDY0NAotLS0gYS9ORVdTCisrKyBi L05FV1MKQEAgLTcsNyArNyw4IEBAIEdOVSBjb3JldXRpbHMgTkVXUyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIC0qLSBvdXRsaW5lIC0qLQogICAnbXYgLW4gQSBCJyBu byBsb25nZXIgc3VmZmVycyBmcm9tIGEgcmFjZSBjb25kaXRpb24gdGhhdCBjYW4KICAgb3Zl cndyaXRlIGEgc2ltdWx0YW5lb3VzbHktY3JlYXRlZCBCLiAgVGhpcyBidWcgZml4IHJlcXVp cmVzCiAgIHBsYXRmb3JtIHN1cHBvcnQgZm9yIHRoZSByZW5hbWVhdDIgb3IgcmVuYW1lYXR4 X25wIHN5c2NhbGxzLCBmb3VuZAotICBpbiByZWNlbnQgTGludXggYW5kIG1hY09TIGtlcm5l bHMuCisgIGluIHJlY2VudCBMaW51eCBhbmQgbWFjT1Mga2VybmVscy4gIEFzIGEgc2lkZSBl ZmZlY3QsIOKAmG12IC1uIEEgQeKAmQorICBub3cgc2lsZW50bHkgZG9lcyBub3RoaW5nIGlm IEEgZXhpc3RzLgogICBbYnVnIGludHJvZHVjZWQgd2l0aCBjb3JldXRpbHMtNy4xXQogCiAg ICdjcCAtbiAtdScgYW5kICdtdiAtbiAtdScgbm93IGNvbnNpc3RlbnRseSBpZ25vcmUgdGhl IC11IG9wdGlvbi4KLS0gCjIuMTQuMwoK --------------D1F8EEB0EC14093A3BDDF2F6-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 04:22:31 2018 Received: (at 29961) by debbugs.gnu.org; 6 Jan 2018 09:22:31 +0000 Received: from localhost ([127.0.0.1]:37560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXkgR-0001si-HO for submit@debbugs.gnu.org; Sat, 06 Jan 2018 04:22:31 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:61963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXkgP-0001sT-PQ for 29961@debbugs.gnu.org; Sat, 06 Jan 2018 04:22:30 -0500 Received: from [192.168.101.10] ([91.12.175.142]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LqnUA-1f2wpm3weI-00eIox; Sat, 06 Jan 2018 10:22:09 +0100 Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Paul Eggert , Kamil Dudka , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> <2142549.IgQGA5uHeq@kdudka-nb> <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> From: Bernhard Voelker Message-ID: Date: Sat, 6 Jan 2018 10:22:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:vcXED75wpomuP6hW1Tf4reM4n5/dak1aun8UjU5zhFK3sTv0of1 5zoeLDoD0qEylGaxnWmqDJuSk4N5fOSniVYWnr3Bpe+bxXZzpt9jLSPb46RvK4YwPoPl0Uz DY3T/bA8jKx/Ww2G6p/GOf+xPD8ZrVv1AYM5+mT4RKfjMymhp3VOeoK9IFYgJk1fzAuK+Bq 7EfeQQa5mkuFe7YGqnruw== X-UI-Out-Filterresults: notjunk:1;V01:K0:JsHXZ1fpAO0=:KKVnc7XDmTsUf6RAW25NF/ 5ArZIZASx4Q3oFRCPzqoR1wsnoqECC5KPFNU+g51HtHK4evldP9ZYg2RlMzngvIbupm+VEcix 0B3ISn+00zBvdwzCjcafF1BsFu4lDLQkit+8I0IhKi9tR5pirpcGoyIS1X8PYdR9F6FHkeD/K Sufj1Bo3d7BQKb7zCWQLoCYoiqQO6j3AbSJp6P2oNq74Y+NJ9KD/Hfn4AQI8g8yJZHepbYa/8 bk2eVlCa0BYwfT6q7LbyZac/F64THfek1j+vsZbpabxPOLFMEDH33moMvpbgmeH1TDB8ATqS5 OEw36fG7U4dwwVccWSBK4u9gwQ3HXyaUMeyCW9KErc9tkJus+yamrZkA8xGAyPdQ9lMTX7dMY wPIhpz8fr3rMUFC9OO25lNwqYNgIYIxuI55A/4QrcfvpJhoA5p4CNOhE1R0kOEz/dk0z3ygbo 3CRtiYEABa1WSsrTpThtDIs4iqgQFWC3VQdUPh9mmlIpZ+CwBeURty10xJ74oE+9K8t1DY5FB KD4aDUpptFMtrADA0elO04yChYAngWkGEM/fn3MS4jPu+C7uk2fPLCKi2l0/B4Ba7WdP9dUnD T3YQrjB8eIE9Ip0xXPP/uIQq+Mz3B52W3QYcZEMeWocql0x3ottGIEmcqzdtphLiz24ur7T3H UfanB3f9kWndhmjo/XF/9hF4+KJFyy59z2SCJSeUkykh6s2Caap/kXftsivlOdjmWS8oDUO83 sTC1YjnswvnYAjEDE08wMhmJ/kfIY1jr2oSXXIRVtLn00NML00LhsMkehfCuY3PCX3+1DYrVL v7UfmG+ X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 01/05/2018 11:59 PM, Paul Eggert wrote: > Attached is a revised proposed patchset to do that. I didn't have a look at the details, but - as we're changing the behavior for some cases - it would be good to also add some tests. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 05:06:08 2018 Received: (at 29961) by debbugs.gnu.org; 6 Jan 2018 10:06:08 +0000 Received: from localhost ([127.0.0.1]:37567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXlMd-0002rd-Vn for submit@debbugs.gnu.org; Sat, 06 Jan 2018 05:06:08 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:46132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXlMc-0002rW-NA for 29961@debbugs.gnu.org; Sat, 06 Jan 2018 05:06:07 -0500 Received: from localhost.localdomain (unknown [109.76.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 80E009F87; Sat, 6 Jan 2018 10:06:05 +0000 (GMT) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Paul Eggert , Kamil Dudka References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> <2142549.IgQGA5uHeq@kdudka-nb> <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sat, 6 Jan 2018 10:06:04 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 05/01/18 22:59, Paul Eggert wrote: > On 01/05/2018 08:19 AM, Kamil Dudka wrote: > >> I am only fixing the case where the destination file is created after the >> lstat() call. In that case, the only result is ENOENT, which is harmless. >> > > Ah, you're right. Sorry, I misread your patch. It should work. > >> On Friday, January 5, 2018 4:29:55 PM CET Pádraig Brady wrote: >> >>> Paul's also avoids a stat() in the common case >>> where the initial renameat2() succeeds. >> At the cost of _not_ avoiding the renameat2() call in the most common case. > > I expect that the most common case is 'mv A B' where B does not already > exist. This is the case that avoids the stat of B. > > Come to think of it, we don't need to stat A either, when the initial > renameat2 succeeds. Attached is a revised proposed patchset to do that. > The first is the same as before; the second causes 'mv A B' to issue > just a renameat2 syscall (with no calls to stat) in the common case > where A exists and B does not. This second patch looks good also. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 06 15:10:09 2018 Received: (at 29961) by debbugs.gnu.org; 6 Jan 2018 20:10:09 +0000 Received: from localhost ([127.0.0.1]:38459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXunB-0005uL-L5 for submit@debbugs.gnu.org; Sat, 06 Jan 2018 15:10:09 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33228) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eXunA-0005u7-15 for 29961@debbugs.gnu.org; Sat, 06 Jan 2018 15:10:08 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1503B161487; Sat, 6 Jan 2018 12:10:02 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id pkumyE5HPZd3; Sat, 6 Jan 2018 12:10:01 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6592816157F; Sat, 6 Jan 2018 12:10:01 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id VuTOK7l-gTnp; Sat, 6 Jan 2018 12:10:01 -0800 (PST) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 3CD5B161487; Sat, 6 Jan 2018 12:10:01 -0800 (PST) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: Bernhard Voelker , Kamil Dudka , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> <2142549.IgQGA5uHeq@kdudka-nb> <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <54433b8c-1e24-e384-931a-0578ac0d8f13@cs.ucla.edu> Date: Sat, 6 Jan 2018 12:10:01 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29961 Cc: 29961@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Bernhard Voelker wrote: > as we're changing the > behavior for some cases - it would be good to also add some tests That would make sense if the edge-case behavior was documented and the ch= ange is=20 something that users could rely on. But the behavior is not documented, a= nd I'm=20 not sure we want to promise that the behavior won't change back. (Maybe I= 'm=20 being too cautious?) From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 10 03:53:16 2018 Received: (at 29961-done) by debbugs.gnu.org; 10 Jan 2018 08:53:16 +0000 Received: from localhost ([127.0.0.1]:50256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZC8K-000617-Jx for submit@debbugs.gnu.org; Wed, 10 Jan 2018 03:53:16 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:42076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZC8I-00060q-Qa for 29961-done@debbugs.gnu.org; Wed, 10 Jan 2018 03:53:15 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 530CC161616; Wed, 10 Jan 2018 00:53:08 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id NSdKwCbF4G5Q; Wed, 10 Jan 2018 00:53:07 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A2AAA16161F; Wed, 10 Jan 2018 00:53:07 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id toG-t3HcW6Qy; Wed, 10 Jan 2018 00:53:07 -0800 (PST) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 7EA8B161616; Wed, 10 Jan 2018 00:53:07 -0800 (PST) Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination To: =?UTF-8?Q?P=c3=a1draig_Brady?= , Kamil Dudka References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> <36963468.Vlg6Wmr2pZ@kdudka-nb> <2142549.IgQGA5uHeq@kdudka-nb> <0e499c4e-f2db-abdb-3d52-cfca734488cf@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Wed, 10 Jan 2018 00:53:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 29961-done Cc: 29961-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) No further comment, so I installed the proposed patches and I'm closing this bug report. From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 10 05:47:47 2018 Received: (at submit) by debbugs.gnu.org; 10 Jan 2018 10:47:47 +0000 Received: from localhost ([127.0.0.1]:50308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZDv9-0000Tg-Ed for submit@debbugs.gnu.org; Wed, 10 Jan 2018 05:47:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:32964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZDv7-0000TN-GR for submit@debbugs.gnu.org; Wed, 10 Jan 2018 05:47:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZDv1-0001pS-Hs for submit@debbugs.gnu.org; Wed, 10 Jan 2018 05:47:40 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZDv1-0001pL-Ee for submit@debbugs.gnu.org; Wed, 10 Jan 2018 05:47:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZDv0-0002kW-9o for bug-coreutils@gnu.org; Wed, 10 Jan 2018 05:47:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZDux-0001mh-4l for bug-coreutils@gnu.org; Wed, 10 Jan 2018 05:47:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZDuw-0001ki-Ub for bug-coreutils@gnu.org; Wed, 10 Jan 2018 05:47:35 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB7C113A88; Wed, 10 Jan 2018 10:47:32 +0000 (UTC) Received: from kdudka-nb.localnet (unknown [10.43.2.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C0C55DD72; Wed, 10 Jan 2018 10:47:32 +0000 (UTC) From: Kamil Dudka To: Paul Eggert Subject: Re: bug#29961: [PATCH] mv -n: do not overwrite the destination Date: Wed, 10 Jan 2018 11:47:55 +0100 Message-ID: <7294964.nnTvCiSjrB@kdudka-nb> In-Reply-To: References: <817e1cb3-76de-7cf8-ef05-9505fab7b83f@draigBrady.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 10 Jan 2018 10:47:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: 29961-done@debbugs.gnu.org, =?ISO-8859-1?Q?P=E1draig?= Brady , bug-coreutils@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) On Wednesday, January 10, 2018 9:53:07 AM CET Paul Eggert wrote: > No further comment, so I installed the proposed patches and I'm closing this > bug report. Sorry. There were just too many changes in your patches for me to review them quickly enough (and most of the changes were unrelated to my initial submission anyway). Thank you for fixing it! Kamil From unknown Tue Jun 24 17:28:09 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 07 Feb 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator