diff options
-rw-r--r-- | .prev-version | 2 | ||||
-rw-r--r-- | ChangeLog | 124 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | README-package-renamed-to-coreutils | 7 | ||||
-rw-r--r-- | bootstrap.conf | 3 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/coreutils.texi | 4 | ||||
-rw-r--r-- | gl/lib/acl.c | 426 | ||||
-rw-r--r-- | gl/lib/savewd.c | 308 | ||||
-rw-r--r-- | lib/.cvsignore | 6 | ||||
-rw-r--r-- | lib/.gitignore | 6 | ||||
-rw-r--r-- | lib/ChangeLog | 6 | ||||
-rw-r--r-- | lib/vasnprintf.c | 5 | ||||
-rw-r--r-- | m4/.cvsignore | 1 | ||||
-rw-r--r-- | m4/.gitignore | 1 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/base64.c | 2 | ||||
-rw-r--r-- | src/basename.c | 2 | ||||
-rw-r--r-- | src/c99-to-c89.diff | 51 | ||||
-rw-r--r-- | src/cat.c | 2 | ||||
-rw-r--r-- | src/chgrp.c | 2 | ||||
-rw-r--r-- | src/chmod.c | 2 | ||||
-rw-r--r-- | src/chown.c | 2 | ||||
-rw-r--r-- | src/chroot.c | 2 | ||||
-rw-r--r-- | src/cksum.c | 2 | ||||
-rw-r--r-- | src/comm.c | 2 | ||||
-rw-r--r-- | src/copy.c | 20 | ||||
-rw-r--r-- | src/cp.c | 2 | ||||
-rw-r--r-- | src/csplit.c | 2 | ||||
-rw-r--r-- | src/cut.c | 2 | ||||
-rw-r--r-- | src/date.c | 2 | ||||
-rw-r--r-- | src/dd.c | 2 | ||||
-rw-r--r-- | src/df.c | 2 | ||||
-rw-r--r-- | src/dircolors.c | 2 | ||||
-rw-r--r-- | src/dirname.c | 2 | ||||
-rw-r--r-- | src/du.c | 2 | ||||
-rw-r--r-- | src/echo.c | 2 | ||||
-rw-r--r-- | src/env.c | 2 | ||||
-rw-r--r-- | src/expand.c | 2 | ||||
-rw-r--r-- | src/expr.c | 2 | ||||
-rw-r--r-- | src/factor.c | 2 | ||||
-rw-r--r-- | src/fmt.c | 2 | ||||
-rw-r--r-- | src/fold.c | 2 | ||||
-rw-r--r-- | src/head.c | 2 | ||||
-rw-r--r-- | src/hostid.c | 2 | ||||
-rw-r--r-- | src/hostname.c | 2 | ||||
-rw-r--r-- | src/id.c | 2 | ||||
-rw-r--r-- | src/install.c | 2 | ||||
-rw-r--r-- | src/join.c | 2 | ||||
-rw-r--r-- | src/kill.c | 2 | ||||
-rw-r--r-- | src/link.c | 2 | ||||
-rw-r--r-- | src/ln.c | 2 | ||||
-rw-r--r-- | src/logname.c | 2 | ||||
-rw-r--r-- | src/ls.c | 2 | ||||
-rw-r--r-- | src/md5sum.c | 2 | ||||
-rw-r--r-- | src/mkdir.c | 2 | ||||
-rw-r--r-- | src/mkfifo.c | 2 | ||||
-rw-r--r-- | src/mknod.c | 2 | ||||
-rw-r--r-- | src/mv.c | 2 | ||||
-rw-r--r-- | src/nice.c | 2 | ||||
-rw-r--r-- | src/nl.c | 2 | ||||
-rw-r--r-- | src/nohup.c | 2 | ||||
-rw-r--r-- | src/od.c | 2 | ||||
-rw-r--r-- | src/paste.c | 2 | ||||
-rw-r--r-- | src/pathchk.c | 5 | ||||
-rw-r--r-- | src/pinky.c | 2 | ||||
-rw-r--r-- | src/pr.c | 2 | ||||
-rw-r--r-- | src/printenv.c | 2 | ||||
-rw-r--r-- | src/printf.c | 2 | ||||
-rw-r--r-- | src/ptx.c | 2 | ||||
-rw-r--r-- | src/pwd.c | 2 | ||||
-rw-r--r-- | src/readlink.c | 2 | ||||
-rw-r--r-- | src/remove.c | 152 | ||||
-rw-r--r-- | src/rm.c | 2 | ||||
-rw-r--r-- | src/rmdir.c | 2 | ||||
-rw-r--r-- | src/seq.c | 2 | ||||
-rw-r--r-- | src/setuidgid.c | 2 | ||||
-rw-r--r-- | src/shred.c | 2 | ||||
-rw-r--r-- | src/shuf.c | 2 | ||||
-rw-r--r-- | src/sleep.c | 2 | ||||
-rw-r--r-- | src/sort.c | 2 | ||||
-rw-r--r-- | src/split.c | 2 | ||||
-rw-r--r-- | src/stat.c | 2 | ||||
-rw-r--r-- | src/stty.c | 5 | ||||
-rw-r--r-- | src/su.c | 2 | ||||
-rw-r--r-- | src/sum.c | 2 | ||||
-rw-r--r-- | src/sync.c | 2 | ||||
-rw-r--r-- | src/system.h | 10 | ||||
-rw-r--r-- | src/tac.c | 2 | ||||
-rw-r--r-- | src/tail.c | 2 | ||||
-rw-r--r-- | src/tee.c | 2 | ||||
-rw-r--r-- | src/test.c | 2 | ||||
-rw-r--r-- | src/touch.c | 2 | ||||
-rw-r--r-- | src/tr.c | 2 | ||||
-rw-r--r-- | src/true.c | 2 | ||||
-rw-r--r-- | src/tsort.c | 2 | ||||
-rw-r--r-- | src/tty.c | 2 | ||||
-rw-r--r-- | src/uname.c | 2 | ||||
-rw-r--r-- | src/unexpand.c | 2 | ||||
-rw-r--r-- | src/uniq.c | 2 | ||||
-rw-r--r-- | src/unlink.c | 2 | ||||
-rw-r--r-- | src/uptime.c | 2 | ||||
-rw-r--r-- | src/users.c | 2 | ||||
-rw-r--r-- | src/wc.c | 2 | ||||
-rw-r--r-- | src/who.c | 5 | ||||
-rw-r--r-- | src/whoami.c | 2 | ||||
-rw-r--r-- | src/yes.c | 2 | ||||
-rwxr-xr-x | tests/du/slink | 12 | ||||
-rwxr-xr-x | tests/install/basic-1 | 18 | ||||
-rwxr-xr-x | tests/mkdir/p-3 | 12 | ||||
-rwxr-xr-x | tests/mv/atomic | 8 | ||||
-rwxr-xr-x | tests/mv/hard-3 | 12 |
114 files changed, 439 insertions, 960 deletions
diff --git a/.prev-version b/.prev-version index 341291e53..12e414129 100644 --- a/.prev-version +++ b/.prev-version @@ -1 +1 @@ -6.7 +6.9 @@ -1,5 +1,129 @@ +2007-03-28 Jim Meyering <jim@meyering.net> + + Help translators include translation team's web or email address. + * src/system.h (emit_bug_reporting_address): New function. + * src/base64.c: Use it rather than a literal printf. + * src/basename.c, src/cat.c, src/chgrp.c, src/chmod.c: + * src/chown.c, src/chroot.c, src/cksum.c, src/comm.c, src/cp.c: + * src/csplit.c, src/cut.c, src/date.c, src/dd.c, src/df.c: + * src/dircolors.c, src/dirname.c, src/du.c, src/echo.c, src/env.c: + * src/expand.c, src/expr.c, src/factor.c, src/fmt.c, src/fold.c: + * src/head.c, src/hostid.c, src/hostname.c, src/id.c, src/install.c: + * src/join.c, src/kill.c, src/link.c, src/ln.c, src/logname.c: + * src/ls.c, src/md5sum.c, src/mkdir.c, src/mkfifo.c, src/mknod.c: + * src/mv.c, src/nice.c, src/nl.c, src/nohup.c, src/od.c: + * src/paste.c, src/pathchk.c, src/pinky.c, src/pr.c, src/printenv.c: + * src/printf.c, src/ptx.c, src/pwd.c, src/readlink.c, src/rm.c: + * src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c, src/shuf.c: + * src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c: + * src/su.c, src/sum.c, src/sync.c, src/system.h, src/tac.c: + * src/tail.c, src/tee.c, src/test.c, src/touch.c, src/tr.c: + * src/true.c, src/tsort.c, src/tty.c, src/uname.c, src/unexpand.c: + * src/uniq.c, src/unlink.c, src/uptime.c, src/users.c, src/wc.c: + * src/who.c, src/whoami.c, src/yes.c: Likewise. + + * src/stty.c: Don't include "vasprintf.h", now that its + declarations are guaranteed to be in gnulib's stdio.h. + * src/who.c: Likewise. + +2007-03-27 Jim Meyering <jim@meyering.net> + + * README: Use "install", not "ginstall" in the list of program names. + * src/Makefile.am (check-README): Substitute s/ginstall/install/. + +2007-03-25 Jim Meyering <jim@meyering.net> + + * src/c99-to-c89.diff: Regenerate. + +2007-03-25 Paul Eggert <eggert@cs.ucla.edu> + + Avoid the need for euidaccess and/or lstat on every directory entry + with 'rm -r dir' (without -f), if we are root, or if we are removing + a directory tree that is full of symbolic links. + * bootstrap.conf (gnulib_modules): Add write-any-file. + * src/copy.c: Include write-any-file.h. + (UNWRITABLE): Remove macro, replacing with.... + (writable_destination): New function, which uses can_write_any_file + to avoid the need for euidaccess when we are privileged. + (overwrite_prompt, abandon_move): Use it. + * src/remove.c: Include write-any-file.h. + (D_TYPE): New macro. + (DT_UNKNOWN, DT_DIR, DT_LNK) [!HAVE_STRUCT_DIRENT_D_TYPE]: New macros. + (write_protected_non_symlink): Don't bother to stat if we can write + any file. + (prompt): New arg PDIRENT_TYPE. All callers changed. + Use readdir dirent type to avoid the need for 'lstat' on each directory + entry in cases like 'rm -r dir', if we are root, or if the tree is + full of symbolic links. + (DT_IS_KNOWN, DT_MUST_BE): Remove. + (remove_entry): New arg DIRENT_TYPE_ARG. All callers changed. + +2007-03-24 Jim Meyering <jim@meyering.net> + + If strace malfunctions, skip the test rather than failing it. + * tests/mv/atomic: Required on a mips-unknown-linux-gnu system + running the aging linux-2.4.27-mipscvs-20040814. + +2007-03-23 Paul Eggert <eggert@cs.ucla.edu> + + * src/pathchk.c: Don't include euidaccess.h, as we don't call + euidaccess. + +2007-03-23 Jim Meyering <jim@meyering.net> + + * README-package-renamed-to-coreutils: Add a URL for the FAQ, + and a couple more archive links. + +2007-03-22 Jim Meyering <jim@meyering.net> + + Post-release version change. + * NEWS: Add a line for 6.9+. + * configure.ac (AC_INIT): Set new version string. + + Version 6.9. + * NEWS: Record release date and new version number. + * configure.ac (AC_INIT): New version number. + + * tests/mv/hard-3: Correct the preceding change: $3 -> $2. + +2007-03-22 Paul Eggert <eggert@cs.ucla.edu> + + Improve a test script. + * tests/mv/hard-3: Check for 'ls' failure, too. + Generate more-useful debugging output when 'ls' fails. + +2007-03-21 Jim Meyering <jim@meyering.net> + + Fix a test script not to claim an ext2 file system is of type xfs. + * tests/du/slink: When using df --local and df --type=TYPE, + test only the exit code. Don't bother with stdout. + Prompted by a report by Thomas Schwinge of an inaccurate diagnostic. + + * gl/lib/savewd.c: Remove this file, since the savewd_save change + is now in gnulib. The other wasn't useful. + +2007-03-20 Jim Meyering <jim@meyering.net> + + * gl/lib/acl.c: Remove this file, now that gnulib's version subsumes it. + + Skip part of this test when "." is not a local file system. + * tests/install/basic-1: Otherwise, it would fail on some NFS + file systems. + * tests/mkdir/p-3: Likewise. + +2007-03-19 Paul Eggert <eggert@cs.ucla.edu> + + * src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): + Add $(LIB_ACL_TRIVIAL). + 2007-03-18 Jim Meyering <jim@meyering.net> + Fix a generic NFS-related test failure. + * tests/mkdir/p-3: When setting up an unreadable "." in an + inaccessible parent, make the parent inaccessible *after* making "." + unreadable. Otherwise, running "chmod a-r ." in an already- + inaccessible parent would fail on NFS with "Stale NFS file handle". + Fix a bug in how pr -m -s works. * NEWS: Describe how the fix affects pr. * src/pr.c (init_parameters): The --merge (-m) option does @@ -1,6 +1,9 @@ GNU coreutils NEWS -*- outline -*- -* Noteworthy changes in release 6.8+ (????-??-??) [not-unstable] +* Noteworthy changes in release 6.9+ (????-??-??) [stable] + + +* Noteworthy changes in release 6.9 (2007-03-22) [stable] ** Bug fixes @@ -9,7 +9,7 @@ The programs that can be built with this package are: [ base64 basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold - ginstall groups head hostid hostname id join kill link ln logname ls + groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split stat stty su sum sync tac diff --git a/README-package-renamed-to-coreutils b/README-package-renamed-to-coreutils index a8109b387..7dc19815f 100644 --- a/README-package-renamed-to-coreutils +++ b/README-package-renamed-to-coreutils @@ -1,6 +1,9 @@ As of 2002-09-01, the GNU fileutils, textutils, and sh-utils packages have been merged into one, called the GNU coreutils. See http://www.gnu.org/software/coreutils/ for a description. +Here's the FAQ list: + + http://www.gnu.org/software/coreutils/faq/ For information on the mailing lists associated with the coreutils package, see these: @@ -10,4 +13,6 @@ coreutils package, see these: mailing list archives are here: - http://mail.gnu.org/pipermail/bug-coreutils/ + http://news.gmane.org/gmane.comp.gnu.coreutils.announce + http://news.gmane.org/gmane.comp.gnu.core-utils.bugs (up to the minute) + http://mail.gnu.org/pipermail/bug-coreutils/ (updated every 12 hours) diff --git a/bootstrap.conf b/bootstrap.conf index 30433216d..4ec43fae6 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -65,7 +65,8 @@ gnulib_modules=" strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset unicodeio unistd-safer unlink-busy unlinkdir unlocked-io uptime userspec utimecmp utimens vasprintf verify version-etc-fsf - wcwidth winsz-ioctl winsz-termios xalloc xgetcwd xgethostname + wcwidth winsz-ioctl winsz-termios write-any-file + xalloc xgetcwd xgethostname xmemcoll xnanosleep xreadlink xreadlink-with-size xstrtod xstrtoimax xstrtol xstrtold xstrtoumax yesno " diff --git a/configure.ac b/configure.ac index 0895aa3ca..b441256db 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ dnl Written by Jim Meyering. AC_PREREQ(2.61) -AC_INIT([GNU coreutils],[6.8+],[bug-coreutils@gnu.org]) +AC_INIT([GNU coreutils],[6.9+],[bug-coreutils@gnu.org]) AC_CONFIG_SRCDIR(src/ls.c) AC_CONFIG_AUX_DIR(build-aux) diff --git a/doc/ChangeLog b/doc/ChangeLog index c4171b8f4..38b5f9dfd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2007-03-21 Eric Blake <ebb9@byu.net> + + * coreutils.texi (md5sum invocation): Document escapes in output + format. Reported by Armijn Hemel. + 2007-03-15 Paul Eggert <eggert@cs.ucla.edu> Fix manual in response to bug reports by Dan Jacobson. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 7a4cc2db0..588147f53 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -3203,6 +3203,10 @@ md5sum [@var{option}]@dots{} [@var{file}]@dots{} For each @var{file}, @samp{md5sum} outputs the MD5 checksum, a flag indicating a binary or text input file, and the file name. +If @var{file} contains a backslash or newline, the +line is started with a backslash, and each problematic character in +the file name is escaped with a backslash, making the output +unambiguous even in the presence of arbitrary file names. If @var{file} is omitted or specified as @samp{-}, standard input is read. The program accepts the following options. Also see @ref{Common options}. diff --git a/gl/lib/acl.c b/gl/lib/acl.c deleted file mode 100644 index 96153d41c..000000000 --- a/gl/lib/acl.c +++ /dev/null @@ -1,426 +0,0 @@ -/* acl.c - access control lists - - Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Written by Paul Eggert and Andreas Gruenbacher. */ - -#include <config.h> - -#include "acl.h" - -#include <stdbool.h> -#include <stdlib.h> -#include <string.h> -#ifndef S_ISLNK -# define S_ISLNK(Mode) 0 -#endif - -#ifdef HAVE_ACL_LIBACL_H -# include <acl/libacl.h> -#endif - -#include "error.h" -#include "quote.h" - -#include <errno.h> -#ifndef ENOSYS -# define ENOSYS (-1) -#endif -#ifndef ENOTSUP -# define ENOTSUP (-1) -#endif - -#if ENABLE_NLS -# include <libintl.h> -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif - -#ifndef HAVE_FCHMOD -# define HAVE_FCHMOD false -# define fchmod(fd, mode) (-1) -#endif - -/* POSIX 1003.1e (draft 17) */ -#ifndef HAVE_ACL_GET_FD -# define HAVE_ACL_GET_FD false -# define acl_get_fd(fd) (NULL) -#endif - -/* POSIX 1003.1e (draft 17) */ -#ifndef HAVE_ACL_SET_FD -# define HAVE_ACL_SET_FD false -# define acl_set_fd(fd, acl) (-1) -#endif - -/* Linux-specific */ -#ifndef HAVE_ACL_EXTENDED_FILE -# define HAVE_ACL_EXTENDED_FILE false -# define acl_extended_file(name) (-1) -#endif - -/* Linux-specific */ -#ifndef HAVE_ACL_FROM_MODE -# define HAVE_ACL_FROM_MODE false -# define acl_from_mode(mode) (NULL) -#endif - -#define ACL_NOT_WELL_SUPPORTED(Errno) \ - (Errno == ENOTSUP || Errno == ENOSYS || Errno == EINVAL) - -/* We detect the presence of POSIX 1003.1e (draft 17 -- abandoned) support - by checking for HAVE_ACL_GET_FILE, HAVE_ACL_SET_FILE, and HAVE_ACL_FREE. - Systems that have acl_get_file, acl_set_file, and acl_free must also - have acl_to_text, acl_from_text, and acl_delete_def_file (all defined - in the draft); systems that don't would hit #error statements here. */ - -#if USE_ACL && HAVE_ACL_GET_FILE && !HAVE_ACL_ENTRIES -# ifndef HAVE_ACL_TO_TEXT -# error Must have acl_to_text (see POSIX 1003.1e draft 17). -# endif - -/* Return the number of entries in ACL. Linux implements acl_entries - as a more efficient extension than using this workaround. */ - -static int -acl_entries (acl_t acl) -{ - char *text = acl_to_text (acl, NULL), *t; - int entries; - if (text == NULL) - return -1; - for (entries = 0, t = text; ; t++, entries++) { - t = strchr (t, '\n'); - if (t == NULL) - break; - } - acl_free (text); - return entries; -} -#endif - -/* If DESC is a valid file descriptor use fchmod to change the - file's mode to MODE on systems that have fchown. On systems - that don't have fchown and if DESC is invalid, use chown on - NAME instead. */ - -int -chmod_or_fchmod (const char *name, int desc, mode_t mode) -{ - if (HAVE_FCHMOD && desc != -1) - return fchmod (desc, mode); - else - return chmod (name, mode); -} - -#if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_SET_FILE && HAVE_ACL_FREE -/* FIXME: use acl_trivial instead, once we have a replacement function */ -static bool -is_trivial_acl (acl_t acl) -{ - int n = acl_entries (acl); - if (n <= 3) - return true; - if (5 <= n) - return false; - - /* Here, we know there are exactly 4 entries. - If they are for user, group, mask, and other, then return true; */ - /* FIXME */ - return false; -} -#endif - -/* Return 1 if NAME has a nontrivial access control list, 0 if - NAME only has no or a base access control list, and -1 on - error. SB must be set to the stat buffer of FILE. */ - -int -file_has_acl (char const *name, struct stat const *sb) -{ -#if USE_ACL && HAVE_ACL && defined GETACLCNT - /* This implementation should work on recent-enough versions of HP-UX, - Solaris, and Unixware. */ - -# ifndef MIN_ACL_ENTRIES -# define MIN_ACL_ENTRIES 4 -# endif - - if (! S_ISLNK (sb->st_mode)) - { - int n = acl (name, GETACLCNT, 0, NULL); - return n < 0 ? (errno == ENOSYS ? 0 : -1) : (MIN_ACL_ENTRIES < n); - } -#elif USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE - /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ - - if (! S_ISLNK (sb->st_mode)) - { - int ret; - - if (HAVE_ACL_EXTENDED_FILE) - ret = acl_extended_file (name); - else - { - acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); - if (acl) - { - ret = !is_trivial_acl (acl); - acl_free (acl); - if (ret == 0 && S_ISDIR (sb->st_mode)) - { - acl = acl_get_file (name, ACL_TYPE_DEFAULT); - if (acl) - { - ret = (0 < acl_entries (acl)); - acl_free (acl); - } - else - ret = -1; - } - } - else - ret = -1; - } - if (ret < 0) - return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1; - return ret; - } -#endif - - /* FIXME: Add support for AIX, Irix, and Tru64. Please see Samba's - source/lib/sysacls.c file for fix-related ideas. */ - - return 0; -} - -/* Copy access control lists from one file to another. If SOURCE_DESC is - a valid file descriptor, use file descriptor operations, else use - filename based operations on SRC_NAME. Likewise for DEST_DESC and - DEST_NAME. - If access control lists are not available, fchmod the target file to - MODE. Also sets the non-permission bits of the destination file - (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set. - System call return value semantics. */ - -int -copy_acl (const char *src_name, int source_desc, const char *dst_name, - int dest_desc, mode_t mode) -{ - int ret; - -#if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_SET_FILE && HAVE_ACL_FREE - /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ - - acl_t acl; - if (HAVE_ACL_GET_FD && source_desc != -1) - acl = acl_get_fd (source_desc); - else - acl = acl_get_file (src_name, ACL_TYPE_ACCESS); - if (acl == NULL) - { - if (ACL_NOT_WELL_SUPPORTED (errno)) - return set_acl (dst_name, dest_desc, mode); - else - { - error (0, errno, "%s", quote (src_name)); - return -1; - } - } - - if (HAVE_ACL_SET_FD && dest_desc != -1) - ret = acl_set_fd (dest_desc, acl); - else - ret = acl_set_file (dst_name, ACL_TYPE_ACCESS, acl); - if (ret != 0) - { - int saved_errno = errno; - - if (ACL_NOT_WELL_SUPPORTED (errno)) - { - bool trivial = is_trivial_acl (acl); - acl_free (acl); - if (trivial) - { - if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0) - saved_errno = errno; - else - return 0; - } - else - chmod_or_fchmod (dst_name, dest_desc, mode); - } - else - { - acl_free (acl); - chmod_or_fchmod (dst_name, dest_desc, mode); - } - error (0, saved_errno, _("preserving permissions for %s"), - quote (dst_name)); - return -1; - } - else - acl_free (acl); - - if (mode & (S_ISUID | S_ISGID | S_ISVTX)) - { - /* We did not call chmod so far, so the special bits have not yet - been set. */ - - if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0) - { - error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); - return -1; - } - } - - if (S_ISDIR (mode)) - { - acl = acl_get_file (src_name, ACL_TYPE_DEFAULT); - if (acl == NULL) - { - error (0, errno, "%s", quote (src_name)); - return -1; - } - - if (acl_set_file (dst_name, ACL_TYPE_DEFAULT, acl)) - { - error (0, errno, _("preserving permissions for %s"), - quote (dst_name)); - acl_free (acl); - return -1; - } - else - acl_free (acl); - } - return 0; -#else - ret = chmod_or_fchmod (dst_name, dest_desc, mode); - if (ret != 0) - error (0, errno, _("preserving permissions for %s"), quote (dst_name)); - return ret; -#endif -} - -/* Set the access control lists of a file. If DESC is a valid file - descriptor, use file descriptor operations where available, else use - filename based operations on NAME. If access control lists are not - available, fchmod the target file to MODE. Also sets the - non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX) - to those from MODE if any are set. System call return value - semantics. */ - -int -set_acl (char const *name, int desc, mode_t mode) -{ -#if USE_ACL && HAVE_ACL_SET_FILE && HAVE_ACL_FREE - /* POSIX 1003.1e draft 17 (abandoned) specific version. */ - - /* We must also have have_acl_from_text and acl_delete_def_file. - (acl_delete_def_file could be emulated with acl_init followed - by acl_set_file, but acl_set_file with an empty acl is - unspecified.) */ - -# ifndef HAVE_ACL_FROM_TEXT -# error Must have acl_from_text (see POSIX 1003.1e draft 17). -# endif -# ifndef HAVE_ACL_DELETE_DEF_FILE -# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17). -# endif - - acl_t acl; - int ret; - - if (HAVE_ACL_FROM_MODE) - { - acl = acl_from_mode (mode); - if (!acl) - { - error (0, errno, "%s", quote (name)); - return -1; - } - } - else - { - char acl_text[] = "u::---,g::---,o::---"; - - if (mode & S_IRUSR) acl_text[ 3] = 'r'; - if (mode & S_IWUSR) acl_text[ 4] = 'w'; - if (mode & S_IXUSR) acl_text[ 5] = 'x'; - if (mode & S_IRGRP) acl_text[10] = 'r'; - if (mode & S_IWGRP) acl_text[11] = 'w'; - if (mode & S_IXGRP) acl_text[12] = 'x'; - if (mode & S_IROTH) acl_text[17] = 'r'; - if (mode & S_IWOTH) acl_text[18] = 'w'; - if (mode & S_IXOTH) acl_text[19] = 'x'; - - acl = acl_from_text (acl_text); - if (!acl) - { - error (0, errno, "%s", quote (name)); - return -1; - } - } - if (HAVE_ACL_SET_FD && desc != -1) - ret = acl_set_fd (desc, acl); - else - ret = acl_set_file (name, ACL_TYPE_ACCESS, acl); - if (ret != 0) - { - int saved_errno = errno; - acl_free (acl); - - if (ACL_NOT_WELL_SUPPORTED (errno)) - { - if (chmod_or_fchmod (name, desc, mode) != 0) - saved_errno = errno; - else - return 0; - } - error (0, saved_errno, _("setting permissions for %s"), quote (name)); - return -1; - } - else - acl_free (acl); - - if (S_ISDIR (mode) && acl_delete_def_file (name)) - { - error (0, errno, _("setting permissions for %s"), quote (name)); - return -1; - } - - if (mode & (S_ISUID | S_ISGID | S_ISVTX)) - { - /* We did not call chmod so far, so the special bits have not yet - been set. */ - - if (chmod_or_fchmod (name, desc, mode)) - { - error (0, errno, _("preserving permissions for %s"), quote (name)); - return -1; - } - } - return 0; -#else - int ret = chmod_or_fchmod (name, desc, mode); - if (ret) - error (0, errno, _("setting permissions for %s"), quote (name)); - return ret; -#endif -} diff --git a/gl/lib/savewd.c b/gl/lib/savewd.c deleted file mode 100644 index a6ee23517..000000000 --- a/gl/lib/savewd.c +++ /dev/null @@ -1,308 +0,0 @@ -/* Save and restore the working directory, possibly using a child process. - - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Written by Paul Eggert. */ - -#include <config.h> - -#include "savewd.h" - -#include <assert.h> -#include <errno.h> -#include <fcntl.h> -#include <signal.h> -#include <stdbool.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -#include "dirname.h" -#include "fcntl-safer.h" - - -/* Save the working directory into *WD, if it hasn't been saved - already. Return true if a child has been forked to do the real - work. */ -static bool -savewd_save (struct savewd *wd) -{ - switch (wd->state) - { - case INITIAL_STATE: - /* Save the working directory, or prepare to fall back if possible. */ - { - int fd = open_safer (".", O_RDONLY); - if (0 <= fd) - { - wd->state = FD_STATE; - wd->val.fd = fd; - break; - } - if (errno != EACCES && errno != ESTALE) - { - wd->state = ERROR_STATE; - wd->val.errnum = errno; - break; - } - } - wd->state = FORKING_STATE; - wd->val.child = -1; - /* Fall through. */ - case FORKING_STATE: - if (wd->val.child < 0) - { - /* "Save" the initial working directory by forking a new - subprocess that will attempt all the work from the chdir - until until the next savewd_restore. */ - wd->val.child = fork (); - if (wd->val.child != 0) - { - if (0 < wd->val.child) - return true; - wd->state = ERROR_STATE; - wd->val.errnum = errno; - } - } - break; - - case FD_STATE: - case FD_POST_CHDIR_STATE: - case ERROR_STATE: - case FINAL_STATE: - break; - - default: - assert (false); - } - - return false; -} - -int -savewd_chdir (struct savewd *wd, char const *dir, int options, - int open_result[2]) -{ - int fd = -1; - int result = 0; - - /* Open the directory if requested, or if avoiding a race condition - is requested and possible. */ - if (open_result - || (options & (HAVE_WORKING_O_NOFOLLOW ? SAVEWD_CHDIR_NOFOLLOW : 0))) - { - fd = open (dir, - (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK - | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0))); - - if (open_result) - { - open_result[0] = fd; - open_result[1] = errno; - } - - if (fd < 0 && ((errno != EACCES && errno != ESTALE) - || (options & SAVEWD_CHDIR_READABLE))) - result = -1; - } - - if (result == 0 && ! (0 <= fd && options & SAVEWD_CHDIR_SKIP_READABLE)) - { - if (savewd_save (wd)) - { - open_result = NULL; - result = -2; - } - else - { - result = (fd < 0 ? chdir (dir) : fchdir (fd)); - - if (result == 0) - switch (wd->state) - { - case FD_STATE: - wd->state = FD_POST_CHDIR_STATE; - break; - - case ERROR_STATE: - case FD_POST_CHDIR_STATE: - case FINAL_STATE: - break; - - case FORKING_STATE: - assert (wd->val.child == 0); - break; - - default: - assert (false); - } - } - } - - if (0 <= fd && ! open_result) - { - int e = errno; - close (fd); - errno = e; - } - - return result; -} - -int -savewd_restore (struct savewd *wd, int status) -{ - switch (wd->state) - { - case INITIAL_STATE: - case FD_STATE: - /* The working directory is the desired directory, so there's no - work to do. */ - break; - - case FD_POST_CHDIR_STATE: - /* Restore the working directory using fchdir. */ - if (fchdir (wd->val.fd) == 0) - { - wd->state = FD_STATE; - break; - } - else - { - int chdir_errno = errno; - close (wd->val.fd); - wd->state = ERROR_STATE; - wd->val.errnum = chdir_errno; - } - /* Fall through. */ - case ERROR_STATE: - /* Report an error if asked to restore the working directory. */ - errno = wd->val.errnum; - return -1; - - case FORKING_STATE: - /* "Restore" the working directory by waiting for the subprocess - to finish. */ - { - pid_t child = wd->val.child; - if (child == 0) - _exit (status); - if (0 < child) - { - int child_status; - while (waitpid (child, &child_status, 0) < 0) - assert (errno == EINTR); - wd->val.child = -1; - if (! WIFEXITED (child_status)) - raise (WTERMSIG (child_status)); - return WEXITSTATUS (child_status); - } - } - break; - - default: - assert (false); - } - - return 0; -} - -void -savewd_finish (struct savewd *wd) -{ - switch (wd->state) - { - case INITIAL_STATE: - case ERROR_STATE: - break; - - case FD_STATE: - case FD_POST_CHDIR_STATE: - close (wd->val.fd); - break; - - case FORKING_STATE: - assert (wd->val.child < 0); - break; - - default: - assert (false); - } - - wd->state = FINAL_STATE; -} - -/* Return true if the actual work is currently being done by a - subprocess. - - A true return means that the caller and the subprocess should - resynchronize later with savewd_restore, using only their own - memory to decide when to resynchronize; they should not consult the - file system to decide, because that might lead to race conditions. - This is why savewd_chdir is broken out into another function; - savewd_chdir's callers _can_ inspect the file system to decide - whether to call savewd_chdir. */ -static inline bool -savewd_delegating (struct savewd const *wd) -{ - return wd->state == FORKING_STATE && 0 < wd->val.child; -} - -int -savewd_process_files (int n_files, char **file, - int (*act) (char *, struct savewd *, void *), - void *options) -{ - int i = 0; - int last_relative; - int exit_status = EXIT_SUCCESS; - struct savewd wd; - savewd_init (&wd); - - for (last_relative = n_files - 1; 0 <= last_relative; last_relative--) - if (! IS_ABSOLUTE_FILE_NAME (file[last_relative])) - break; - - for (; i < last_relative; i++) - { - if (! savewd_delegating (&wd)) - { - int s = act (file[i], &wd, options); - if (exit_status < s) - exit_status = s; - } - - if (! IS_ABSOLUTE_FILE_NAME (file[i + 1])) - { - int r = savewd_restore (&wd, exit_status); - if (exit_status < r) - exit_status = r; - } - } - - savewd_finish (&wd); - - for (; i < n_files; i++) - { - int s = act (file[i], &wd, options); - if (exit_status < s) - exit_status = s; - } - - return exit_status; -} diff --git a/lib/.cvsignore b/lib/.cvsignore index df34a8b6c..d77c4657a 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -3,8 +3,10 @@ Makefile Makefile.in __fpending.c __fpending.h +acl-internal.h acl.c acl.h +acl_entries.c alloca.c alloca.h alloca_.h @@ -84,6 +86,7 @@ fcntl-safer.h fcntl.h fcntl_.h fd-safer.c +file-has-acl.c file-type.c file-type.h fileblocks.c @@ -93,6 +96,7 @@ filenamecat.c filenamecat.h findprog.c findprog.h +float+.h fnmatch.c fnmatch.h fnmatch_.h @@ -380,6 +384,8 @@ wchar_.h wctype.h wctype_.h wcwidth.h +write-any-file.c +write-any-file.h xalloc-die.c xalloc.h xgetcwd.c diff --git a/lib/.gitignore b/lib/.gitignore index d7233fe3d..7e704325a 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,7 +1,9 @@ __fpending.c __fpending.h +acl-internal.h acl.c acl.h +acl_entries.c alloca.c alloca.h alloca_.h @@ -79,6 +81,7 @@ fcntl-safer.h fcntl.h fcntl_.h fd-safer.c +file-has-acl.c file-type.c file-type.h fileblocks.c @@ -88,6 +91,7 @@ filenamecat.c filenamecat.h findprog.c findprog.h +float+.h fnmatch.c fnmatch.h fnmatch_.h @@ -371,6 +375,8 @@ wchar_.h wctype.h wctype_.h wcwidth.h +write-any-file.c +write-any-file.h xalloc-die.c xalloc.h xgetcwd.c diff --git a/lib/ChangeLog b/lib/ChangeLog index 49c0e93c8..e1b4c7aac 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2007-03-20 Jim Meyering <jim@meyering.net> + + Fix a typo in the handling of %x and %X. + * vasnprintf.c (VASNPRINTF): When adding 2 to buffer length, + don't double it. + 2007-03-04 Jim Meyering <jim@meyering.net> * vasnprintf.c (VASNPRINTF): Add missing semicolon. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 8be7ac480..8a9ec9e93 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -415,8 +415,9 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar if (tmp_length < precision) tmp_length = precision; /* Add 2, to account for a leading sign or alternate form. */ - if (tmp_length <= SIZE_MAX / 2) - tmp_length *= 2; + tmp_length += 2; + if (tmp_length < 2) + goto out_of_memory; break; case 'f': case 'F': diff --git a/m4/.cvsignore b/m4/.cvsignore index faa76a48c..62d03641e 100644 --- a/m4/.cvsignore +++ b/m4/.cvsignore @@ -246,6 +246,7 @@ wchar_t.m4 wctype.m4 wcwidth.m4 wint_t.m4 +write-any-file.m4 xalloc.m4 xgetcwd.m4 xnanosleep.m4 diff --git a/m4/.gitignore b/m4/.gitignore index 30fc58e57..7a8bf0773 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -235,6 +235,7 @@ wchar_t.m4 wctype.m4 wcwidth.m4 wint_t.m4 +write-any-file.m4 xalloc.m4 xgetcwd.m4 xnanosleep.m4 diff --git a/src/Makefile.am b/src/Makefile.am index 7aa504b36..076821692 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,9 +104,9 @@ uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS) su_LDADD = $(LDADD) $(LIB_CRYPT) -dir_LDADD += $(LIB_ACL) -ls_LDADD += $(LIB_ACL) -vdir_LDADD += $(LIB_ACL) +dir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL) +ls_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL) +vdir_LDADD += $(LIB_ACL_TRIVIAL) $(LIB_ACL) cp_LDADD += $(LIB_ACL) mv_LDADD += $(LIB_ACL) ginstall_LDADD += $(LIB_ACL) @@ -269,7 +269,7 @@ check: check-README check-misc check-README: rm -rf $(pr) $(pm) echo $(all_programs) \ - | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \ + | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \ | $(ASSORT) -u > $(pm) && \ sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \ | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr) diff --git a/src/base64.c b/src/base64.c index 9f8ff417c..4a278278e 100644 --- a/src/base64.c +++ b/src/base64.c @@ -87,7 +87,7 @@ When decoding, the input may contain newlines in addition to the bytes of\n\ the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\ from any other non-alphabet bytes in the encoded stream.\n"), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); diff --git a/src/basename.c b/src/basename.c index f2617b1ea..22f76fc3b 100644 --- a/src/basename.c +++ b/src/basename.c @@ -70,7 +70,7 @@ Examples:\n\ %s include/stdio.h .h Output \"stdio\".\n\ "), program_name, program_name); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/c99-to-c89.diff b/src/c99-to-c89.diff index 5545f6a11..4e1aa4aa3 100644 --- a/src/c99-to-c89.diff +++ b/src/c99-to-c89.diff @@ -4,9 +4,9 @@ RCS file: /fetish/cu/src/remove.c,v retrieving revision 1.158 diff --git a/src/remove.c b/src/remove.c index 4728bdd..7477da5 100644 ---- a/src/remove.c -+++ b/src/remove.c -@@ -236,9 +236,10 @@ pop_dir (Dirstack_state *ds) +--- a/src/remove.c 2007-03-23 21:49:33.000000000 +0100 ++++ b/src/remove.c 2007-03-25 09:58:29.000000000 +0200 +@@ -254,9 +254,10 @@ pop_dir (Dirstack_state *ds) { size_t n_lengths = obstack_object_size (&ds->len_stack) / sizeof (size_t); size_t *length = obstack_base (&ds->len_stack); @@ -18,7 +18,7 @@ index 4728bdd..7477da5 100644 assert (top_len >= 2); /* Pop the specified length of file name. */ -@@ -370,10 +371,11 @@ AD_stack_top (Dirstack_state const *ds) +@@ -388,10 +389,11 @@ AD_stack_top (Dirstack_state const *ds) static void AD_stack_pop (Dirstack_state *ds) { @@ -31,24 +31,23 @@ index 4728bdd..7477da5 100644 if (top->unremovable) hash_free (top->unremovable); obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent)); -@@ -815,6 +817,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, +@@ -873,6 +875,7 @@ prompt (int fd_cwd, Dirstack_state const + break; + } - if (write_protected || x->interactive == RMI_ALWAYS) - { -+ char const *quoted_name = quote (full_filename (filename)); - if (write_protected <= 0 - && cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) - { -@@ -832,8 +835,6 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, - write_protected = EISDIR; - } ++ { + char const *quoted_name = quote (full_filename (filename)); -- char const *quoted_name = quote (full_filename (filename)); -- if (0 < write_protected) - { - error (0, write_protected, _("cannot remove %s"), quoted_name); -@@ -1487,6 +1488,7 @@ rm_1 (Dirstack_state *ds, char const *filename, +@@ -912,6 +915,7 @@ prompt (int fd_cwd, Dirstack_state const + : _("%s: remove %s %s? ")), + program_name, file_type (sbuf), quoted_name); + } ++ } + + if (!yesno ()) + return RM_USER_DECLINED; +@@ -1512,6 +1516,7 @@ rm_1 (Dirstack_state *ds, char const *fi return RM_ERROR; } @@ -56,23 +55,23 @@ index 4728bdd..7477da5 100644 struct stat st; cache_stat_init (&st); cycle_check_init (&ds->cycle_check_state); -@@ -1509,6 +1511,7 @@ rm_1 (Dirstack_state *ds, char const *filename, +@@ -1534,6 +1539,7 @@ rm_1 (Dirstack_state *ds, char const *fi AD_push_initial (ds); AD_INIT_OTHER_MEMBERS (); + { - enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL); + enum RM_status status = remove_entry (AT_FDCWD, ds, filename, + DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) - { -@@ -1525,6 +1528,8 @@ rm_1 (Dirstack_state *ds, char const *filename, - +@@ -1552,6 +1558,8 @@ rm_1 (Dirstack_state *ds, char const *fi ds_clear (ds); return status; -+ } -+ } } ++ } ++} /* Remove all files and/or directories specified by N_FILES and FILE. + Apply the options in X. */ Index: src/rm.c =================================================================== RCS file: /fetish/cu/src/rm.c,v @@ -125,7 +125,7 @@ Examples:\n\ %s Copy standard input to standard output.\n\ "), program_name, program_name); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/chgrp.c b/src/chgrp.c index faf58d36b..1778a8d69 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -160,7 +160,7 @@ Examples:\n\ %s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\ "), program_name, program_name); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/chmod.c b/src/chmod.c index 028c882d0..707b41561 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -369,7 +369,7 @@ Change the mode of each FILE to MODE.\n\ \n\ Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/chown.c b/src/chown.c index 63a32f5bf..29b75a251 100644 --- a/src/chown.c +++ b/src/chown.c @@ -155,7 +155,7 @@ Examples:\n\ %s -hR root /u Change the owner of /u and subfiles to \"root\".\n\ "), program_name, program_name, program_name); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/chroot.c b/src/chroot.c index d2ae0e580..31af1817c 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -57,7 +57,7 @@ Run COMMAND with root directory set to NEWROOT.\n\ \n\ If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/cksum.c b/src/cksum.c index d93877fa5..7b65c730d 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -273,7 +273,7 @@ Print CRC checksum and byte counts of each FILE.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/comm.c b/src/comm.c index 9b7e03f1f..6ab4938b3 100644 --- a/src/comm.c +++ b/src/comm.c @@ -91,7 +91,7 @@ and column three contains lines common to both files.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/copy.c b/src/copy.c index 4bdb75cbb..786de2f9e 100644 --- a/src/copy.c +++ b/src/copy.c @@ -51,6 +51,7 @@ #include "stat-time.h" #include "utimecmp.h" #include "utimens.h" +#include "write-any-file.h" #include "xreadlink.h" #include "yesno.h" @@ -63,11 +64,6 @@ #define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid) #define SAME_OWNER_AND_GROUP(A, B) (SAME_OWNER (A, B) && SAME_GROUP (A, B)) -#define UNWRITABLE(File_name, File_mode) \ - ( /* euidaccess is not meaningful for symlinks */ \ - ! S_ISLNK (File_mode) \ - && euidaccess (File_name, W_OK) != 0) - struct dir_list { struct dir_list *parent; @@ -793,10 +789,20 @@ same_file_ok (char const *src_name, struct stat const *src_sb, return false; } +/* Return true if FILE, with mode MODE, is writable in the sense of 'mv'. + Always consider a symbolic link to be writable. */ +static bool +writable_destination (char const *file, mode_t mode) +{ + return (S_ISLNK (mode) + || can_write_any_file () + || euidaccess (file, W_OK) == 0); +} + static void overwrite_prompt (char const *dst_name, struct stat const *dst_sb) { - if (euidaccess (dst_name, W_OK) != 0) + if (! writable_destination (dst_name, dst_sb->st_mode)) { char perms[12]; /* "-rwxrwxrwx " ls-style modes. */ strmode (dst_sb->st_mode, perms); @@ -978,7 +984,7 @@ abandon_move (const struct cp_options *x, || ((x->interactive == I_ASK_USER || (x->interactive == I_UNSPECIFIED && x->stdin_tty - && UNWRITABLE (dst_name, dst_sb->st_mode))) + && ! writable_destination (dst_name, dst_sb->st_mode))) && (overwrite_prompt (dst_name, dst_sb), 1) && ! yesno ())); } @@ -249,7 +249,7 @@ As a special case, cp makes a backup of SOURCE when the force and backup\n\ options are given and SOURCE and DEST are the same name for an existing,\n\ regular file.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/csplit.c b/src/csplit.c index c2105bc07..75a5718d1 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1509,7 +1509,7 @@ Read standard input if FILE is -. Each PATTERN may be:\n\ \n\ A line OFFSET is a required `+' or `-' followed by a positive integer.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -234,7 +234,7 @@ Each range is one of:\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/date.c b/src/date.c index c64ab1c04..8102e9921 100644 --- a/src/date.c +++ b/src/date.c @@ -245,7 +245,7 @@ then an optional modifier, which is either\n\ E to use the locale's alternate representations if available, or\n\ O to use the locale's alternate numeric symbols if available.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -507,7 +507,7 @@ Options are:\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -772,7 +772,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ SIZE may be (or may be an integer optionally followed by) one of following:\n\ kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/dircolors.c b/src/dircolors.c index 82eb1e088..51f036d7f 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -116,7 +116,7 @@ If FILE is specified, read it to determine which colors to use for which\n\ file types and extensions. Otherwise, a precompiled database is used.\n\ For details on the format of these files, run `dircolors --print-database'.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); diff --git a/src/dirname.c b/src/dirname.c index 2253391ce..bc2b0f362 100644 --- a/src/dirname.c +++ b/src/dirname.c @@ -64,7 +64,7 @@ Examples:\n\ %s stdio.h Output \".\".\n\ "), program_name, program_name); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -344,7 +344,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ SIZE may be (or may be an integer optionally followed by) one of following:\n\ kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/echo.c b/src/echo.c index 5f8582cc0..fe55cddff 100644 --- a/src/echo.c +++ b/src/echo.c @@ -95,7 +95,7 @@ If -e is in effect, the following sequences are recognized:\n\ \\v vertical tab\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -130,7 +130,7 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\ \n\ A mere - implies -i. If no COMMAND, print the resulting environment.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/expand.c b/src/expand.c index 564520376..42739bd65 100644 --- a/src/expand.c +++ b/src/expand.c @@ -129,7 +129,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/expr.c b/src/expr.c index 352c80cc6..57c259144 100644 --- a/src/expr.c +++ b/src/expr.c @@ -163,7 +163,7 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\ Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null\n\ or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/factor.c b/src/factor.c index dc8f1cc87..5ebe15484 100644 --- a/src/factor.c +++ b/src/factor.c @@ -87,7 +87,7 @@ Print the prime factors of each NUMBER.\n\ Print the prime factors of all specified integer NUMBERs. If no arguments\n\ are specified on the command line, they are read from standard input.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -297,7 +297,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n"), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/fold.c b/src/fold.c index 0d4ea5860..84b6eac7f 100644 --- a/src/fold.c +++ b/src/fold.c @@ -86,7 +86,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/head.c b/src/head.c index 4038722b0..9d830644c 100644 --- a/src/head.c +++ b/src/head.c @@ -137,7 +137,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ N may have a multiplier suffix: b 512, k 1024, m 1024*1024.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/hostid.c b/src/hostid.c index 090b8a04c..edd9e3ddc 100644 --- a/src/hostid.c +++ b/src/hostid.c @@ -54,7 +54,7 @@ Print the numeric identifier (in hexadecimal) for the current host.\n\ program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/hostname.c b/src/hostname.c index f6748a66d..a2666bad5 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -71,7 +71,7 @@ Print or set the hostname of the current system.\n\ program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -92,7 +92,7 @@ Print information for USERNAME, or the current user.\n\ \n\ Without any OPTION, print some useful set of identified information.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/install.c b/src/install.c index 04577518c..6f85a24f4 100644 --- a/src/install.c +++ b/src/install.c @@ -702,7 +702,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/join.c b/src/join.c index b113c543b..c06213c4f 100644 --- a/src/join.c +++ b/src/join.c @@ -169,7 +169,7 @@ separated by CHAR.\n\ Important: FILE1 and FILE2 must be sorted on the join fields.\n\ E.g., use `sort -k 1b,1' if `join' has no options.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/kill.c b/src/kill.c index c59025fa0..0c7ac1242 100644 --- a/src/kill.c +++ b/src/kill.c @@ -114,7 +114,7 @@ or an exit status of a process terminated by a signal.\n\ PID is an integer; if negative it identifies a process group.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/link.c b/src/link.c index 277cf2352..9e1f33970 100644 --- a/src/link.c +++ b/src/link.c @@ -55,7 +55,7 @@ Usage: %s FILE1 FILE2\n\ stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -375,7 +375,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/logname.c b/src/logname.c index dc8296716..422bc657c 100644 --- a/src/logname.c +++ b/src/logname.c @@ -48,7 +48,7 @@ Print the name of the current user.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -4424,7 +4424,7 @@ colors, and can be set easily by the dircolors command.\n\ \n\ Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/md5sum.c b/src/md5sum.c index a8ce1cf27..f637bae39 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -191,7 +191,7 @@ should be a former output of this program. The default mode is to print\n\ a line with checksum, a character indicating type (`*' for binary, ` ' for\n\ text), and name for each FILE.\n"), DIGEST_REFERENCE); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); diff --git a/src/mkdir.c b/src/mkdir.c index 6fa0ac21d..0db72415e 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -71,7 +71,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/mkfifo.c b/src/mkfifo.c index d329b79b8..bd006c441 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -64,7 +64,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/mknod.c b/src/mknod.c index 43a1b9dcc..955f34507 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -79,7 +79,7 @@ otherwise, as decimal. TYPE may be:\n\ c, u create a character (unbuffered) special file\n\ p create a FIFO\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -328,7 +328,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\ existing, nil numbered if numbered backups exist, simple otherwise\n\ simple, never always make simple backups\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/nice.c b/src/nice.c index 19b38bc34..8b6f4d814 100644 --- a/src/nice.c +++ b/src/nice.c @@ -85,7 +85,7 @@ With no COMMAND, print the current niceness. Nicenesses range from\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -226,7 +226,7 @@ FORMAT is one of:\n\ rz right justified, leading zeros\n\ \n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/nohup.c b/src/nohup.c index 1f8e62bc4..dd64410b3 100644 --- a/src/nohup.c +++ b/src/nohup.c @@ -67,7 +67,7 @@ Run COMMAND, ignoring hangup signals.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -392,7 +392,7 @@ of output. \ --string without a number implies 3. --width without a number\n\ implies 32. By default, od uses -A o -t d2 -w16.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/paste.c b/src/paste.c index 414fb8830..808744818 100644 --- a/src/paste.c +++ b/src/paste.c @@ -434,7 +434,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); /* FIXME: add a couple of examples. */ - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/pathchk.c b/src/pathchk.c index 2fc55d346..5e98d5a85 100644 --- a/src/pathchk.c +++ b/src/pathchk.c @@ -1,5 +1,5 @@ /* pathchk -- check whether file names are valid or portable - Copyright (C) 1991-2006 Free Software Foundation, Inc. + Copyright (C) 1991-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ #include "system.h" #include "error.h" -#include "euidaccess.h" #include "quote.h" #include "quotearg.h" @@ -106,7 +105,7 @@ Diagnose unportable constructs in NAME.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/pinky.c b/src/pinky.c index 885012b3d..ccc5d72e8 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -530,7 +530,7 @@ usage (int status) A lightweight `finger' program; print user information.\n\ The utmp file will be %s.\n\ "), UTMP_FILE); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -2872,7 +2872,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -T implied by -l nn when nn <= 10 or <= 3 with -F. With no FILE, or when\n\ FILE is -, read standard input.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/printenv.c b/src/printenv.c index e06b704e2..3412f45f5 100644 --- a/src/printenv.c +++ b/src/printenv.c @@ -68,7 +68,7 @@ If no environment VARIABLE specified, print them all.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/printf.c b/src/printf.c index 6205153bd..61c22bf9c 100644 --- a/src/printf.c +++ b/src/printf.c @@ -135,7 +135,7 @@ and all C format specifications ending with one of diouxXfeEgGcs, with\n\ ARGUMENTs converted to proper type first. Variable widths are handled.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -1922,7 +1922,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE or if FILE is -, read Standard Input. `-F /' by default.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -59,7 +59,7 @@ Print the full filename of the current working directory.\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/readlink.c b/src/readlink.c index 121c7ffcf..0961d235c 100644 --- a/src/readlink.c +++ b/src/readlink.c @@ -86,7 +86,7 @@ usage (int status) "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/remove.c b/src/remove.c index 59ee9e562..804557db9 100644 --- a/src/remove.c +++ b/src/remove.c @@ -39,6 +39,7 @@ #include "remove.h" #include "root-dev-ino.h" #include "unlinkdir.h" +#include "write-any-file.h" #include "yesno.h" /* Avoid shadowing warnings because these are functions declared @@ -112,6 +113,23 @@ struct AD_ent struct dev_ino dev_ino; }; +/* D_TYPE(D) is the type of directory entry D if known, DT_UNKNOWN + otherwise. */ +#if HAVE_STRUCT_DIRENT_D_TYPE +# define D_TYPE(d) ((d)->d_type) +#else +# define D_TYPE(d) DT_UNKNOWN + +/* Any int values will do here, so long as they're distinct. + Undef any existing macros out of the way. */ +# undef DT_UNKNOWN +# undef DT_DIR +# undef DT_LNK +# define DT_UNKNOWN 0 +# define DT_DIR 1 +# define DT_LNK 2 +#endif + extern char *program_name; struct dirstack_state @@ -715,6 +733,8 @@ write_protected_non_symlink (int fd_cwd, Dirstack_state const *ds, struct stat *buf) { + if (can_write_any_file ()) + return 0; if (cache_fstatat (fd_cwd, file, buf, AT_SYMLINK_NOFOLLOW) != 0) return errno; if (S_ISLNK (buf->st_mode)) @@ -791,6 +811,9 @@ write_protected_non_symlink (int fd_cwd, return RM_USER_DECLINED. If not ignoring missing files and we cannot lstat FILENAME, then return RM_ERROR. + *PDIRENT_TYPE is the type of the directory entry; update it to DT_DIR + or DT_LNK as needed. *SBUF is the file's status. + Depending on MODE, ask whether to `descend into' or to `remove' the directory FILENAME. MODE is ignored when FILENAME is not a directory. Set *IS_EMPTY to T_YES if FILENAME is an empty directory, and it is @@ -798,11 +821,12 @@ write_protected_non_symlink (int fd_cwd, Don't even try to set *IS_EMPTY when MODE == PA_REMOVE_DIR. */ static enum RM_status prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, - struct stat *sbuf, + int *pdirent_type, struct stat *sbuf, struct rm_options const *x, enum Prompt_action mode, Ternary *is_empty) { int write_protected = 0; + int dirent_type = *pdirent_type; *is_empty = T_UNKNOWN; @@ -810,27 +834,44 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, return RM_OK; if (!x->ignore_missing_files - & ((x->interactive == RMI_ALWAYS) | x->stdin_tty)) + && ((x->interactive == RMI_ALWAYS) || x->stdin_tty) + && dirent_type != DT_LNK) write_protected = write_protected_non_symlink (fd_cwd, filename, ds, sbuf); if (write_protected || x->interactive == RMI_ALWAYS) { - if (write_protected <= 0 - && cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) + if (write_protected <= 0 && dirent_type == DT_UNKNOWN) { - /* This happens, e.g., with `rm '''. */ - write_protected = errno; + if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) == 0) + { + if (S_ISLNK (sbuf->st_mode)) + dirent_type = DT_LNK; + else if (S_ISDIR (sbuf->st_mode)) + dirent_type = DT_DIR; + /* Otherwise it doesn't matter, so leave it DT_UNKNOWN. */ + *pdirent_type = dirent_type; + } + else + { + /* This happens, e.g., with `rm '''. */ + write_protected = errno; + } } if (write_protected <= 0) - { - /* Using permissions doesn't make sense for symlinks. */ - if (S_ISLNK (sbuf->st_mode) && x->interactive != RMI_ALWAYS) - return RM_OK; + switch (dirent_type) + { + case DT_LNK: + /* Using permissions doesn't make sense for symlinks. */ + if (x->interactive != RMI_ALWAYS) + return RM_OK; + break; - if (S_ISDIR (sbuf->st_mode) && !x->recursive) - write_protected = EISDIR; - } + case DT_DIR: + if (!x->recursive) + write_protected = EISDIR; + break; + } char const *quoted_name = quote (full_filename (filename)); @@ -844,8 +885,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, /* FIXME: use a variant of error (instead of fprintf) that doesn't append a newline. Then we won't have to declare program_name in this file. */ - if (S_ISDIR (sbuf->st_mode) - && x->recursive + if (dirent_type == DT_DIR && mode == PA_DESCEND_INTO_DIR && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO)) == T_NO)) @@ -856,6 +896,12 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, program_name, quoted_name); else { + if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) + { + error (0, errno, _("cannot remove %s"), quoted_name); + return RM_ERROR; + } + /* TRANSLATORS: You may find it more convenient to translate the equivalent of _("%s: remove %s (write-protected) %s? "). It should avoid grammatical problems with the output @@ -888,19 +934,6 @@ is_dir_lstat (char const *filename, struct stat *st) return is_dir; } -#if HAVE_STRUCT_DIRENT_D_TYPE - -/* True if the type of the directory entry D is known. */ -# define DT_IS_KNOWN(d) ((d)->d_type != DT_UNKNOWN) - -/* True if the type of the directory entry D must be T. */ -# define DT_MUST_BE(d, t) ((d)->d_type == (t)) - -#else -# define DT_IS_KNOWN(d) false -# define DT_MUST_BE(d, t) false -#endif - #define DO_UNLINK(Fd_cwd, Filename, X) \ do \ { \ @@ -970,14 +1003,14 @@ ignorable_missing (struct rm_options const *x, int errnum) static enum RM_status remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, - struct stat *st, - struct rm_options const *x, struct dirent const *dp) + int dirent_type_arg, struct stat *st, + struct rm_options const *x) { Ternary is_empty_directory; - enum RM_status s = prompt (fd_cwd, ds, filename, st, x, PA_DESCEND_INTO_DIR, + enum RM_status s = prompt (fd_cwd, ds, filename, &dirent_type_arg, st, x, + PA_DESCEND_INTO_DIR, &is_empty_directory); - bool known_to_be_dir = (cache_stat_ok (st) && S_ISDIR (st->st_mode)); - + int dirent_type = dirent_type_arg; if (s != RM_OK) return s; @@ -997,7 +1030,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, if (cannot_unlink_dir ()) { - if (known_to_be_dir && ! x->recursive) + if (dirent_type == DT_DIR && ! x->recursive) { error (0, EISDIR, _("cannot remove %s"), quote (full_filename (filename))); @@ -1013,10 +1046,11 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, /* If we happen to know that FILENAME is a directory, return now and let the caller remove it -- this saves the overhead of a failed - unlink call. If FILENAME is a command-line argument, then dp is NULL, - so we'll first try to unlink it. Using unlink here is ok, because it - cannot remove a directory. */ - if ((dp && DT_MUST_BE (dp, DT_DIR)) || known_to_be_dir) + unlink call. If FILENAME is a command-line argument, then + DIRENT_TYPE is DT_UNKNOWN so we'll first try to unlink it. + Using unlink here is ok, because it cannot remove a + directory. */ + if (dirent_type == DT_DIR) return RM_NONEMPTY_DIR; DO_UNLINK (fd_cwd, filename, x); @@ -1046,31 +1080,24 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, /* If we don't already know whether FILENAME is a directory, find out now. Then, if it's a non-directory, we can use unlink on it. */ - bool is_dir; - if (cache_statted (st)) - is_dir = known_to_be_dir; - else + if (dirent_type == DT_UNKNOWN) { - if (dp && DT_IS_KNOWN (dp)) - is_dir = DT_MUST_BE (dp, DT_DIR); - else + if (fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW)) { - if (fstatat (fd_cwd, filename, st, AT_SYMLINK_NOFOLLOW)) - { - if (ignorable_missing (x, errno)) - return RM_OK; + if (ignorable_missing (x, errno)) + return RM_OK; - error (0, errno, _("cannot remove %s"), - quote (full_filename (filename))); - return RM_ERROR; - } - - is_dir = !! S_ISDIR (st->st_mode); + error (0, errno, _("cannot remove %s"), + quote (full_filename (filename))); + return RM_ERROR; } + + if (S_ISDIR (st->st_mode)) + dirent_type = DT_DIR; } - if (! is_dir) + if (dirent_type == DT_DIR) { /* At this point, barring race conditions, FILENAME is known to be a non-directory, so it's ok to try to unlink it. */ @@ -1208,7 +1235,8 @@ remove_cwd_entries (DIR **dirp, Systems without the d_type member will have to endure the performance hit of first calling lstat F. */ cache_stat_init (subdir_sb); - tmp_status = remove_entry (dirfd (*dirp), ds, f, subdir_sb, x, dp); + tmp_status = remove_entry (dirfd (*dirp), ds, f, + D_TYPE (dp), subdir_sb, x); switch (tmp_status) { case RM_OK: @@ -1404,13 +1432,10 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, /* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */ if (tmp_status == RM_OK) { - /* This does a little more work than necessary when it actually - prompts the user. E.g., we already know that D is a directory - and that it's almost certainly empty, yet we lstat it. - But that's no big deal since we're interactive. */ struct stat empty_st; Ternary is_empty; - enum RM_status s = prompt (fd, ds, empty_dir, + int dirent_type = DT_DIR; + enum RM_status s = prompt (fd, ds, empty_dir, &dirent_type, cache_stat_init (&empty_st), x, PA_REMOVE_DIR, &is_empty); @@ -1509,7 +1534,8 @@ rm_1 (Dirstack_state *ds, char const *filename, AD_push_initial (ds); AD_INIT_OTHER_MEMBERS (); - enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL); + enum RM_status status = remove_entry (AT_FDCWD, ds, filename, + DT_UNKNOWN, &st, x); if (status == RM_NONEMPTY_DIR) { /* In the event that remove_dir->remove_cwd_entries detects @@ -204,7 +204,7 @@ Note that if you use rm to remove a file, it is usually possible to recover\n\ the contents of that file. If you want more assurance that the contents are\n\ truly unrecoverable, consider using shred.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/rmdir.c b/src/rmdir.c index 39063b4c7..5dd5a35a6 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -152,7 +152,7 @@ Remove the DIRECTORY(ies), if they are empty.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -98,7 +98,7 @@ FORMAT must be suitable for printing one argument of type `double';\n\ it defaults to %.PRECf if FIRST, INCREMENT, and LAST are all fixed point\n\ decimal numbers with maximum precision PREC, and to %g otherwise.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/setuidgid.c b/src/setuidgid.c index 3a51225dc..27c4c7991 100644 --- a/src/setuidgid.c +++ b/src/setuidgid.c @@ -64,7 +64,7 @@ This program is useful only when run by root (user ID zero).\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/shred.c b/src/shred.c index 23a4944b0..fc6ad67f1 100644 --- a/src/shred.c +++ b/src/shred.c @@ -236,7 +236,7 @@ In addition, file system backups and remote mirrors may contain copies\n\ of the file that cannot be removed, and that will allow a shredded file\n\ to be recovered later.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/shuf.c b/src/shuf.c index bfc9f30a2..a40c88dd7 100644 --- a/src/shuf.c +++ b/src/shuf.c @@ -75,7 +75,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); diff --git a/src/sleep.c b/src/sleep.c index 730b19d17..53bad0223 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -57,7 +57,7 @@ specified by the sum of their values.\n\ program_name, program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/sort.c b/src/sort.c index 58ca66a2e..ff021aa92 100644 --- a/src/sort.c +++ b/src/sort.c @@ -380,7 +380,7 @@ The locale specified by the environment affects sort order.\n\ Set LC_ALL=C to get the traditional sort order that uses\n\ native byte values.\n\ "), stdout ); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); diff --git a/src/split.c b/src/split.c index 1f0f3d727..2fc6ecfcf 100644 --- a/src/split.c +++ b/src/split.c @@ -133,7 +133,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/stat.c b/src/stat.c index ca8423677..29a222ac5 100644 --- a/src/stat.c +++ b/src/stat.c @@ -903,7 +903,7 @@ Valid format sequences for file systems:\n\ %T Type in human readable form\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/stty.c b/src/stty.c index 33a821d25..ce0cb0cae 100644 --- a/src/stty.c +++ b/src/stty.c @@ -1,5 +1,5 @@ /* stty -- change and print terminal line settings - Copyright (C) 1990-2005 Free Software Foundation, Inc. + Copyright (C) 1990-2005, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -62,7 +62,6 @@ #include "error.h" #include "fd-reopen.h" #include "quote.h" -#include "vasprintf.h" #include "xstrtol.h" /* The official name of this program (e.g., no `g' prefix). */ @@ -721,7 +720,7 @@ prints baud rate, line discipline, and deviations from stty sane. In\n\ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\ 127; special values ^- or undef used to disable special characters.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -399,7 +399,7 @@ Change the effective user id and group id to that of USER.\n\ \n\ A mere - implies -l. If USER not given, assume root.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -72,7 +72,7 @@ Print checksum and block counts for each FILE.\n\ \n\ With no FILE, or when FILE is -, read standard input.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/sync.c b/src/sync.c index 5e94afbdd..ce3fc0531 100644 --- a/src/sync.c +++ b/src/sync.c @@ -49,7 +49,7 @@ Force changed blocks to disk, update the super block.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/system.h b/src/system.h index 763909bac..e72e4811b 100644 --- a/src/system.h +++ b/src/system.h @@ -581,3 +581,13 @@ ptr_align (void const *ptr, size_t alignment) || (Type) ((Accum) * 10 + (Digit_val)) < (Accum)) \ ? false : (((Accum) = (Accum) * 10 + (Digit_val)), true)) \ ) + +static inline void +emit_bug_reporting_address (void) +{ + /* TRANSLATORS: The placeholder indicates the bug-reporting address + for this package. Please add _another line_ saying + "Report translation bugs to <...>\n" with the address for translation + bugs (typically your translation team's web or email address). */ + printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); +} @@ -149,7 +149,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/tail.c b/src/tail.c index 2582b9d69..210a68178 100644 --- a/src/tail.c +++ b/src/tail.c @@ -282,7 +282,7 @@ rotation). Use --follow=name in that case. That causes tail to track the\n\ named file by reopening it periodically to see if it has been removed and\n\ recreated by some other program.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -72,7 +72,7 @@ Copy standard input to each FILE, and also to standard output.\n\ \n\ If a FILE is -, copy again to standard output.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/test.c b/src/test.c index b25436b1f..fcb68ef37 100644 --- a/src/test.c +++ b/src/test.c @@ -774,7 +774,7 @@ Beware that parentheses need to be escaped (e.g., by backslashes) for shells.\n\ INTEGER may also be -l STRING, which evaluates to the length of STRING.\n\ "), stdout); printf (USAGE_BUILTIN_WARNING, _("test and/or [")); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/touch.c b/src/touch.c index a79c26d97..cb54f4828 100644 --- a/src/touch.c +++ b/src/touch.c @@ -260,7 +260,7 @@ Note that the -d and -t options accept different time-date formats.\n\ \n\ If a FILE is -, touch standard output.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -356,7 +356,7 @@ only be used in pairs to specify case conversion. \ translating nor deleting; else squeezing uses SET2 and occurs after\n\ translation or deletion.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/true.c b/src/true.c index 55490f90e..be20ed6d0 100644 --- a/src/true.c +++ b/src/true.c @@ -51,7 +51,7 @@ Usage: %s [ignored command line arguments]\n\ fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); exit (status); } diff --git a/src/tsort.c b/src/tsort.c index 939323213..cfb12acb6 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -91,7 +91,7 @@ With no FILE, or when FILE is -, read standard input.\n\ "), program_name); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); @@ -74,7 +74,7 @@ Print the file name of the terminal connected to standard input.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/uname.c b/src/uname.c index 0715e07cd..7389d422e 100644 --- a/src/uname.c +++ b/src/uname.c @@ -133,7 +133,7 @@ Print certain system information. With no OPTION, same as -s.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/unexpand.c b/src/unexpand.c index cbceca0f4..051fe72e4 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -138,7 +138,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/uniq.c b/src/uniq.c index 6c38ed807..ac0840b03 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -167,7 +167,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ A field is a run of whitespace, then non-whitespace characters.\n\ Fields are skipped before chars.\n\ "), stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/unlink.c b/src/unlink.c index 725507649..beef5a5a9 100644 --- a/src/unlink.c +++ b/src/unlink.c @@ -54,7 +54,7 @@ Usage: %s FILE\n\ stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/uptime.c b/src/uptime.c index 6b2a7240a..c7bd7a453 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -205,7 +205,7 @@ If FILE is not specified, use %s. %s as FILE is common.\n\ UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/users.c b/src/users.c index dba470113..8071acd92 100644 --- a/src/users.c +++ b/src/users.c @@ -114,7 +114,7 @@ If FILE is not specified, use %s. %s as FILE is common.\n\ UTMP_FILE, WTMP_FILE); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -126,7 +126,7 @@ read standard input.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -1,5 +1,5 @@ /* GNU's who. - Copyright (C) 1992-2006 Free Software Foundation, Inc. + Copyright (C) 1992-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,7 +37,6 @@ #include "hard-locale.h" #include "inttostr.h" #include "quote.h" -#include "vasprintf.h" /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "who" @@ -665,7 +664,7 @@ usage (int status) If FILE is not specified, use %s. %s as FILE is common.\n\ If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.\n\ "), UTMP_FILE, WTMP_FILE); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/src/whoami.c b/src/whoami.c index c4a2b5e82..d1167164b 100644 --- a/src/whoami.c +++ b/src/whoami.c @@ -55,7 +55,7 @@ Same as id -un.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -55,7 +55,7 @@ Repeatedly output a line with all specified STRING(s), or `y'.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } diff --git a/tests/du/slink b/tests/du/slink index 21679345d..8be1a3072 100755 --- a/tests/du/slink +++ b/tests/du/slink @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that the size of a long-named-symlink is > 0. -# Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,25 +34,23 @@ cd $tmp || framework_failure=1 # Determine if `.' is on a local (would non-NFS be sufficient?) file system. # On at least some NFS implementations, symlinks never take up space, -df --local . | tail -n +2 > tmp + # So if this is a non-local file system, skip the test. -if test -s tmp; then +if df --local . >/dev/null 2>&1; then : # Ok. else echo "$0: skipping this test, since \`.' is on a non-local file system" 1>&2 (exit 77); exit 77 fi -df --type=xfs . | tail -n +2 > tmp -if test -s tmp; then +if df --type=xfs . >/dev/null 2>&1; then # At least on Irix-6.5.19, when using an xfs file system, # each created symlink (name lengths up to 255) would have a size of `0'. echo "$0: skipping this test, since \`.' is on an XFS file system" 1>&2 (exit 77); exit 77 fi -df --type=nfsv3 . | tail -n +2 > tmp -if test -s tmp; then +if df --type=nfsv3 . >/dev/null 2>&1; then # At least on OSF/1 4.0d, when using an nfsv3 file system, # each created symlink can end up having a size of 0. echo "$0: skipping this test, since \`.' is on an NFS file system" 1>&2 diff --git a/tests/install/basic-1 b/tests/install/basic-1 index 78a837552..327060404 100755 --- a/tests/install/basic-1 +++ b/tests/install/basic-1 @@ -129,13 +129,17 @@ test -d xx/rel && fail=1 # Test that we can install from an unreadable directory with an # inaccessible parent. coreutils 5.97 fails this test. -mkdir -p sub1/d || fail=1 -(cd sub1/d && chmod a-r . && chmod a-rx .. && - ginstall -d "$abs/xx/zz" rel/a rel/b) || fail=1 -chmod 755 sub1 sub1/d || fail=1 -test -d xx/zz || fail=1 -test -d sub1/d/rel/a || fail=1 -test -d sub1/d/rel/b || fail=1 +# Perform this test only if "." is on a local file system. +# Otherwise, it would fail e.g., on an NFS-mounted file system. +if df --local . >/dev/null 2>&1; then + mkdir -p sub1/d || fail=1 + (cd sub1/d && chmod a-r . && chmod a-rx .. && + ginstall -d "$abs/xx/zz" rel/a rel/b) || fail=1 + chmod 755 sub1 sub1/d || fail=1 + test -d xx/zz || fail=1 + test -d sub1/d/rel/a || fail=1 + test -d sub1/d/rel/b || fail=1 +fi touch file || fail=1 ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1 diff --git a/tests/mkdir/p-3 b/tests/mkdir/p-3 index 7f367178e..54e99e172 100755 --- a/tests/mkdir/p-3 +++ b/tests/mkdir/p-3 @@ -3,7 +3,7 @@ # causes immediate failure. Also, ensure that we don't create # subsequent, relative command-line arguments in the wrong place. -# Copyright (C) 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2005-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -54,9 +54,13 @@ test -d "$p/b/b" && test -d "$p/z" || fail=1 # Same as above, but a trailing relative name in an unreadable directory # whose parent is inaccessible. coreutils 5.97 fails this test. -(cd no-acce3s/d && chmod a-rx .. && chmod a-r . && mkdir -p a/b "$p/b/c" d/e && - test -d a/b && test -d d/e) || fail=1 -test -d "$p/b/c" || fail=1 +# Perform this test only if "." is on a local file system. +# Otherwise, it would fail e.g., on an NFS-mounted file system. +if df --local . >/dev/null 2>&1; then + (cd no-acce3s/d && chmod a-r . && chmod a-rx .. && + mkdir -p a/b "$p/b/c" d/e && test -d a/b && test -d d/e) || fail=1 + test -d "$p/b/c" || fail=1 +fi b=`ls "$p/a" | tr -d '\n'` # With coreutils-5.3.0, this would fail with $b=bu. diff --git a/tests/mv/atomic b/tests/mv/atomic index 1fa07360f..728bbfa1f 100755 --- a/tests/mv/atomic +++ b/tests/mv/atomic @@ -1,7 +1,7 @@ #!/bin/sh # ensure that mv doesn't first unlink its destination in one particular case -# Copyright (C) 2006, 2006 Free Software Foundation, Inc. +# Copyright (C) 2006-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,6 +55,12 @@ if test "$skip" = 1; then (exit 77); exit 77 fi +strace -qe unlink echo > /dev/null 2>&1 || skip=1 +if test "$skip" = 1; then + echo "$0: strace doesn't work, so skipping this test" 1>&2 + (exit 77); exit 77 +fi + fail=0 strace -qe unlink mv -T s1 s2 > out 2>&1 || fail=1 diff --git a/tests/mv/hard-3 b/tests/mv/hard-3 index 0ab9521fa..ce8372840 100755 --- a/tests/mv/hard-3 +++ b/tests/mv/hard-3 @@ -2,7 +2,7 @@ # Ensure that using `cp --preserve=link' to copy hard-linked arguments # onto existing destinations works, even when one of the link operations fails. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -78,12 +78,12 @@ test -f x/b || fail=1 test -f c || fail=1 # The i-node numbers of a and c must be the same. -ia=`ls -i a|sed 's/ a$//'` -ic=`ls -i c|sed 's/ c$//'` -test $ia = $ic || fail=1 +ia=`ls -i a` || fail=1; set x $ia; ia=$2 +ic=`ls -i c` || fail=1; set x $ic; ic=$2 +test "$ia" = "$ic" || fail=1 # The i-node number of x/b must be different. -ib=`ls -i x/b|sed 's/ x.b$//'` -test $ia = $ib && fail=1 +ib=`ls -i x/b` || fail=1; set x $ib; ib=$2 +test "$ia" = "$ib" && fail=1 (exit $fail); exit $fail |