mv -n: provide more reliable diagnostic messages
This commit is contained in:
parent
de3dc267d7
commit
d75d1537e7
|
@ -24,8 +24,8 @@ Fixes https://bugs.gnu.org/29961
|
|||
lib/renameat2.h | 30 ++++++
|
||||
m4/gnulib-comp.m4 | 22 ++++
|
||||
m4/renameat.m4 | 25 +++++
|
||||
src/copy.c | 17 +++-
|
||||
12 files changed, 801 insertions(+), 2 deletions(-)
|
||||
src/copy.c | 27 ++++-
|
||||
12 files changed, 808 insertions(+), 5 deletions(-)
|
||||
create mode 100644 gnulib-tests/test-renameat.c
|
||||
create mode 100644 gnulib-tests/test-renameat2.c
|
||||
create mode 100644 lib/renameat.c
|
||||
|
@ -957,7 +957,19 @@ index 2a804945e..be4e357a8 100644
|
|||
#include "root-uid.h"
|
||||
#include "same.h"
|
||||
#include "savedir.h"
|
||||
@@ -2312,7 +2313,12 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
@@ -2192,8 +2193,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
/* If the source is a directory, we don't always create the destination
|
||||
directory. So --verbose should not announce anything until we're
|
||||
- sure we'll create a directory. */
|
||||
- if (x->verbose && !S_ISDIR (src_mode))
|
||||
+ sure we'll create a directory. In move mode we delay the diagnostic
|
||||
+ message until we know whether renameat2() has actually succeeded. */
|
||||
+ if (x->verbose && !S_ISDIR (src_mode) && !x->move_mode)
|
||||
emit_verbose (src_name, dst_name, backup_succeeded ? dst_backup : NULL);
|
||||
|
||||
/* Associate the destination file name with the source device and inode
|
||||
@@ -2312,9 +2314,14 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
|
||||
if (x->move_mode)
|
||||
{
|
||||
|
@ -969,9 +981,12 @@ index 2a804945e..be4e357a8 100644
|
|||
+
|
||||
+ if (renameat2 (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) == 0)
|
||||
{
|
||||
if (x->verbose && S_ISDIR (src_mode))
|
||||
- if (x->verbose && S_ISDIR (src_mode))
|
||||
+ if (x->verbose)
|
||||
emit_verbose (src_name, dst_name,
|
||||
@@ -2342,6 +2348,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
backup_succeeded ? dst_backup : NULL);
|
||||
|
||||
@@ -2342,6 +2349,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -987,6 +1002,16 @@ index 2a804945e..be4e357a8 100644
|
|||
/* FIXME: someday, consider what to do when moving a directory into
|
||||
itself but when source and destination are on different devices. */
|
||||
|
||||
@@ -2417,6 +2433,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (x->verbose && !S_ISDIR (src_mode))
|
||||
+ emit_verbose (src_name, dst_name, backup_succeeded ? dst_backup : NULL);
|
||||
+
|
||||
new_dst = true;
|
||||
}
|
||||
|
||||
--
|
||||
2.13.6
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||
Name: coreutils
|
||||
Version: 8.27
|
||||
Release: 18%{?dist}
|
||||
Release: 19%{?dist}
|
||||
License: GPLv3+
|
||||
Group: System Environment/Base
|
||||
Url: https://www.gnu.org/software/coreutils/
|
||||
|
@ -306,6 +306,9 @@ fi
|
|||
%license COPYING
|
||||
|
||||
%changelog
|
||||
* Thu Jan 25 2018 Kamil Dudka <kdudka@redhat.com> - 8.27-19
|
||||
- mv -n: provide more reliable diagnostic messages
|
||||
|
||||
* Tue Jan 23 2018 Kamil Dudka <kdudka@redhat.com> - 8.27-18
|
||||
- doc: warn about following symlinks recursively in chown/chgrp (CVE-2017-18018)
|
||||
- mv -n: do not overwrite the destination
|
||||
|
|
Loading…
Reference in New Issue