]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
11 years agopwd: assume -L mode by default, as per POSIX
Pádraig Brady [Mon, 30 Jun 2014 09:15:26 +0000 (10:15 +0100)] 
pwd: assume -L mode by default, as per POSIX

* src/pwd.c (main): Adjust default mode to be "logical"
and independent of the POSIXLY_CORRECT env var.
(usage): Mention the default mode of operation.
* doc/coreutils.texi (pwd invocation): Adjust accordingly.
* tests/misc/pwd-option.sh: Likewise.
* NEWS: Mention the change in behavior.

11 years agotests: use predetermined NON_ROOT_GID
Pádraig Brady [Thu, 26 Jun 2014 11:41:01 +0000 (12:41 +0100)] 
tests: use predetermined NON_ROOT_GID

* HACKING: GID is more useful in tests than group name, so rename
input param from NON_ROOT_GROUP to NON_ROOT_GID to make it obvious
that only a group ID is now acceptable, thus allowing GID lookups
to be avoided throughout the tests.
* init.cfg (require_root_): Likewise.
* tests/misc/truncate-owned-by-other.sh: Avoid looking up the GID.
* tests/touch/now-owned-by-other.sh: Likewise.
* tests/misc/chroot-credentials.sh: Likewise.  Also fix an instance
of comparison against NON_ROOT_GROUP which would have given a false
failure if a non numeric value was passed in.
* tests/id/setgid.sh: Use previously looked up gid as a more
accurate base for the subsequent adjustment, and move
the uid lookup within chroot, rather than having the overhead
of a separate `id` invocation.

11 years agomaint: mention when the du cycle warning bug was introduced
Pádraig Brady [Thu, 26 Jun 2014 03:56:04 +0000 (04:56 +0100)] 
maint: mention when the du cycle warning bug was introduced

* NEWS: Mention bug introduced in v8.1 (with commit v8.0-88-g8ba5d1a).

11 years agoid: output the effective group for the process
Petr Stodůlka [Wed, 25 Jun 2014 17:26:23 +0000 (18:26 +0100)] 
id: output the effective group for the process

* src/id.c (print_full_info): When no user is specified,
output the effective group for the _process_, rather than
the default group from the system database, which may be different.
* tests/id/setgid.sh: Add a case for `id` as well as `id -G`.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/7320
Reported at http://bugzilla.redhat.com/1016163

11 years agodf: report correct device in presence of eclipsed mounts
Pádraig Brady [Tue, 24 Jun 2014 14:34:39 +0000 (15:34 +0100)] 
df: report correct device in presence of eclipsed mounts

* src/df.c (last_device_for_mount): A new function to identify
the last device mounted for a mount point.
(get_disk): Use the above to discard mount entries for a device,
where a later mount entry uses a different device name than
that of the user specified device.
* tests/df/over-mount-device.sh: A new root test.
* tests/local.mk: Reference the new test.
* NEWS: Reword for all these related recent fixes.
Discussed at: http://bugs.gnu.org/16539#69

11 years agodf: look for accessible mount points for specified devices
Pádraig Brady [Wed, 18 Jun 2014 12:10:17 +0000 (13:10 +0100)] 
df: look for accessible mount points for specified devices

* src/df.c (get_disk): Include whether we can access the mount dir,
in the mount entry selection criteria.  This handles the case where
a device is (bind) mounted multiple times with the shortest mount path
not being accessible, while some of the other mount points are.
Discussed at: http://bugs.gnu.org/16539#63

11 years agodf: output placeholder values for inaccessible mount points
Pádraig Brady [Tue, 3 Jun 2014 23:09:11 +0000 (00:09 +0100)] 
df: output placeholder values for inaccessible mount points

A system provided mount entry may be unavailable due to TOCTOU race,
or if another device has been over-mounted at that position, or due to
access permissions.  In all these cases output "-" placeholder values
rather than either producing an error, or in the over-mount case
outputting values for the wrong device.

* src/df.c (device_list): A new global list now updated by
filter_mount_list().
(filter_mount_list): Adjust to take a parameter as to whether
update the global mount list, or only the mount <-> device ID mapping.
(get_dev): Use the device ID mapping to ensure we're not outputting
stats for the wrong device.  Also output placeholder values when we
can't access a system specified mount point.
(get_all_entries): Set the DEVICE_ONLY param for filter_mount_list().
(devname_for_dev): A new function to search the mount <-> dev mapping.
* test/df/skip-duplicates.sh: Adjust accordingly.
* NEWS: Mention the bug fixes.

Discussed at: http://bugs.gnu.org/16539

11 years agodu: ignore directory cycles due to bind mounts
Pádraig Brady [Thu, 19 Jun 2014 11:11:00 +0000 (12:11 +0100)] 
du: ignore directory cycles due to bind mounts

* src/du.c (process_file): Treat cycles due to bind mounts
like cycles due to following symlinks.
* tests/du/bind-mount-dir-cycle.sh: Adjust accordingly.
* NEWS: Mention the change in behavior.
Reported at http://bugzilla.redhat.com/836557

11 years agodoc: state in ls --help, that -h affects --size format
Pádraig Brady [Tue, 24 Jun 2014 09:33:41 +0000 (10:33 +0100)] 
doc: state in ls --help, that -h affects --size format

* src/ls.c (usage): State that --human changes --size format.
Fixes http://bugs.gnu.org/17838

11 years agodoc: clarify chgrp restrictions
Pádraig Brady [Thu, 19 Jun 2014 17:49:18 +0000 (18:49 +0100)] 
doc: clarify chgrp restrictions

* doc/coreutils.texi (chown invocation): Mention the system dependent
restrictions on setting groups.
(chgrp invocation): Likewise. Reference the 'chown' superset.
* man/chgrp.x: Cross reference chown(1) which is the superset interface,
and also chown(2) which gives details of the platform restrictions.
Fixes http://bugs.gnu.org/17495

11 years agodf: use all of the last device details provided
Pádraig Brady [Mon, 16 Jun 2014 23:18:47 +0000 (00:18 +0100)] 
df: use all of the last device details provided

* src/df.c (filter_mount_list): Recent commit v8.22-108-g25a2c94
failed to copy file system type along with the updated device name.
Therefore simply replace the existing mount entry with the
current one with all the latest device details.  Note the name,
even if not shorter in this entry, will be replaced with a shorter
name in a subsequent mount entry.
* tests/df/skip-duplicates.sh: Add a test case.

11 years agoseq: fix incorrect output with start or end of -0
Pádraig Brady [Wed, 18 Jun 2014 13:30:57 +0000 (14:30 +0100)] 
seq: fix incorrect output with start or end of -0

* src/seq.c (main): Avoid seq_fast() with a start or end of -0.
* tests/misc/seq.pl: Add test cases.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/17800

11 years agotail: fix --follow to use polling mode for VXFS
Pádraig Brady [Fri, 13 Jun 2014 08:16:31 +0000 (09:16 +0100)] 
tail: fix --follow to use polling mode for VXFS

Veritas File System can run in single instance or clustered mode,
so mark as remote to avoid using inotify for the latter case.

* src/stat.c (human_fstype): Tag VXFS as remote, to use polling
for the clustered variant (VXCFS).
* NEWS: Mention the bug fix.

Reported by Ondřej Vašík in http://bugzilla.redhat.com/1104244
Fixes http://bugs.gnu.org/17770

11 years agomaint: suppress a theoretical buffer overflow warning
Pádraig Brady [Wed, 11 Jun 2014 23:35:14 +0000 (00:35 +0100)] 
maint: suppress a theoretical buffer overflow warning

* src/numfmt.c (double_to_human): The printf format is built up in
a stack buffer which is big enough to hold any of the possible formats.
However the size parameter passed to snprintf was too big by 1
when GROUP was true.  So decrease the buffer available to snprintf
to avoid this theoretical in practise but valid coverity warning.

11 years agotests: fix version printing for ginstall in one test
Pádraig Brady [Wed, 11 Jun 2014 22:50:00 +0000 (23:50 +0100)] 
tests: fix version printing for ginstall in one test

* tests/install/d-slashdot.sh: 'ginstall' is the binary name
in the build directory, not 'install'.

11 years agoinstall: allow options -D and -t to be used together
Bernhard Voelker [Wed, 11 Jun 2014 09:28:03 +0000 (11:28 +0200)] 
install: allow options -D and -t to be used together

* src/install.c (install_file_in_file_parents): Factor out the
creation of any parent directories into ...
(mkancesdirs_safe_wd): ... this new function.
(install_file_in_dir): Add the parameter 'mkdir_and_install', and
call the above new function if it evaluates to true.
(main): During parsing of the -t option, move the check whether
the target_directory exists down  after the option parsing loop,
and do not complain about stat(optarg,...) failing if -D was given.
Pass 'mkdir_and_install' to install_file_in_dir().
* doc/coreutils.texi (install invocation): Remove the (false)
restriction that -D would be ignored together with -t.  Instead,
clarify install's new bahavior.
Fix the node's reference in the top-level @direntry for consistency.
* src/install/basic-1.sh: Add tests for the now-allowed combination
of the -D and -t options.
* NEWS: Mention the improvement.

11 years agobuild: update gnulib submodule and tests/init.sh to latest
Pádraig Brady [Wed, 11 Jun 2014 11:18:45 +0000 (12:18 +0100)] 
build: update gnulib submodule and tests/init.sh to latest

* gnulib: Update to latest.
* tests/init.sh: Update from gnulib.

11 years agobuild: update GCC warnings
Pádraig Brady [Tue, 10 Jun 2014 23:39:45 +0000 (00:39 +0100)] 
build: update GCC warnings

* configure.ac: Remove the -Wsuggest-attribute=pure
enablement on GCC >= 4.7, as that was moot since
gnulib was already enabling that warning in its default set.
The false positive was seen with 4.6.2, but confirmed
not present in 4.6.3, so that's sufficiently old to
just leave this enabled unconditionally.

Remove the -Wsuggest-attribute={const,noreturn}
enablement, as gnulib already has those in the default set.

Enable the -Wlogical-op warning for GCC >= 4.8.0
as that is confirmed OK with coreutils at least, due to
fixing: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43772

Remove the -Wno-logical-op override since the main
-Wlogical-op flag is now sufficient to control this warning
as of GCC 4.6.3 at least.

11 years agotests: consolidate tests for true and false
Pádraig Brady [Tue, 3 Jun 2014 09:50:09 +0000 (10:50 +0100)] 
tests: consolidate tests for true and false

* src/true.c (main): Add a comment about the possibility
of true returning EXIT_FAILURE due to write failure.
* tests/misc/false-status.sh: Fix so we're testing
the tool and not the shell builtin.  Add a case for true(1).
* tests/misc/help-version.sh: Skip /dev/full test
for true as well as false since the exit status is tested separately.
Also remove the iterations for different LC_MESSAGES, as this was only
applied for false(1).  Translations are not honored in the test dir
and so would need separate handling in any case.

11 years agomaint: avoid compiler warnings with some assert() implementations
Ben Walton [Mon, 2 Jun 2014 19:32:16 +0000 (20:32 +0100)] 
maint: avoid compiler warnings with some assert() implementations

* src/df.c (get_dev): asssert() on Solaris 10 is not marked as
__noreturn__ and thus the compiler may think V is uninitialized
later on in the function.
* THANKS.in: Remove the now committer.

11 years agobuild: be more specific about .git repo before enabling warnings
Ben Walton [Mon, 2 Jun 2014 08:54:56 +0000 (09:54 +0100)] 
build: be more specific about .git repo before enabling warnings

* configure.ac: When looking for a .git checkout, exclude repos that
contain a .tarball-version file as these are probably releases
that are imported into git for patch management.

11 years agocut: restore special case handling of -f with -d$'\n'
Pádraig Brady [Fri, 30 May 2014 16:44:32 +0000 (17:44 +0100)] 
cut: restore special case handling of -f with -d$'\n'

commits v8.20-98-g51ce0bf and v8.20-99-gd302aed changed cut(1)
to process each line independently and thus promptly output
each line without buffering.  As part of those changes we removed
the special handling of --delimiter=$'\n' --fields=... which
could be used to select arbitrary (ranges of) lines, so as to
simplify and optimize the implementation while also matching the
behavior of different cut(1) implementations.

However that GNU behavior was in place for a long time, and
could be useful in certain cases like making a separated list like
`seq 10 | cut -f1- -d$'\n' --output-delimiter=,` although other tools
like head(1) and paste(1) are more suited to this operation.
This patch reinstates that functionality but restricts the
"line behind" buffering behavior to only the -d$'\n' case.

We also fix the following related edge case to be more consistent:

  before> printf "\n" | cut -s -d$'\n' -f1- | wc -l
  2
  before> printf "\n" | cut    -d$'\n' -f1- | wc -l
  1
  after > printf "\n" | cut -s -d$'\n' -f1- | wc -l
  1
  after > printf "\n" | cut    -d$'\n' -f1- | wc -l
  1

* src/cut.c (cut_fields): Adjust as discussed above.
* tests/misc/cut.pl: Likewise.
* NEWS: Mention the change in behavior both for v8.21
and this effective revert.
* cfg.mk (old_NEWS_hash): Adjust for originally omitted v8.21 entry.
* src/paste.c: s/delimeter/delimiter/ comment typo fix.

11 years agostat: avoid redundant stat() calls
Pádraig Brady [Thu, 29 May 2014 15:44:50 +0000 (16:44 +0100)] 
stat: avoid redundant stat() calls

* src/stat.c (find_bind_mount): NAME is invariant in the loop,
so only stat(NAME) outside the loop.

11 years agodf: use the last device name provided by the system
Pádraig Brady [Thu, 29 May 2014 14:30:46 +0000 (15:30 +0100)] 
df: use the last device name provided by the system

The device name reported for a particular mount entry
may no longer be valid if the mount point was subsequently
mounted on a different device.  Therefore honor the order
of the mount list returned by the system and use the last
reported device name.

* src/df.c (filter_mount_list): When discarding the current
mount entry, ensure that a new device name is not also discarded.
* tests/df/skip-duplicates.sh: Add a test case.  Also fix
a false failure in the edge case of a system with only a
single file system.
* NEWS: Mention the fix.

11 years agostdbuf: support OS X
Pádraig Brady [Mon, 26 May 2014 08:19:16 +0000 (09:19 +0100)] 
stdbuf: support OS X

* src/stdbuf.c (set_LD_PRELOAD): Adjust to use Mac OS X
specific environment variables on __APPLE__ platforms.
Fixes http://bugs.gnu.org/17590

11 years agobuild: uname: avoid shadowing warning
Jim Meyering [Sun, 25 May 2014 16:44:39 +0000 (09:44 -0700)] 
build: uname: avoid shadowing warning

* src/uname.c (main) [__APPLE__]: Rename inner "s" to "cs",
to avoid gcc shadowing warning.

11 years agodoc: clarify --zero-terminated option
Pádraig Brady [Thu, 22 May 2014 23:45:57 +0000 (00:45 +0100)] 
doc: clarify --zero-terminated option

* src/join.c (usage): Reword to avoid implication that
the NUL byte is only generated as the output delimeter.
* src/sort.c (usage): Likewise.
* src/shuf.c (usage): Likewise. Also since we're changing the
translation string take the opportunity to separate out
the description to a separate string to reduce translation overhead.
* src/uniq.c (usage): Likewise.
* src/stty.c (usage): s/null/NUL/ for consistency.
* src/basename.c (usage): Reword for accuracy/consistency.
* src/dirname.c (usage): Likewise.
* src/du.c (usage): Likewise.
* src/env.c (usage): Likewise.
* src/printenv.c (usage): Likewise.
* src/readlink.c (usage): Likewise.
* src/realpath.c (usage): Likewise.
* doc/coreutils.texi: Consolidate/share the descriptions of
--null, --zero and --zero-terminated.

11 years agobuild: libstdbuf.so: avoid new OS X link failure
Jim Meyering [Sun, 25 May 2014 19:46:00 +0000 (12:46 -0700)] 
build: libstdbuf.so: avoid new OS X link failure

* src/local.mk (src_libstdbuf_so_LDADD): Add $(LIBINTL),
to avoid link failure on OS X.

11 years agocat,cp,split: use a larger buffer for copying
Jim Meyering [Thu, 8 May 2014 18:11:25 +0000 (11:11 -0700)] 
cat,cp,split: use a larger buffer for copying

* src/ioblksize.h (IO_BUFSIZE): Double the size, to 128KB.
Add four more columns to the blksize-vs-bandwidth table

11 years agodoc: use nicer quotes
Paul Eggert [Sat, 24 May 2014 15:43:47 +0000 (08:43 -0700)] 
doc: use nicer quotes

* doc/coreutils.texi: Add "@documentencoding UTF-8".

11 years agostat,tail: improve support for LogFS and ConfigFS
Pádraig Brady [Thu, 22 May 2014 23:20:43 +0000 (00:20 +0100)] 
stat,tail: improve support for LogFS and ConfigFS

* src/stat.c (human_fstype): Add new file system ID definitions.
* NEWS: Mention the improvement.

11 years agomaint: enforce consistent width and case of file system constants
Pádraig Brady [Thu, 22 May 2014 01:16:14 +0000 (02:16 +0100)] 
maint: enforce consistent width and case of file system constants

* src/stat.c (human_fstype): Adjust a couple of existing constants
to be a consistent width and capitalization so that the
src/fs-magic-compare target works without reporting false positives.
* cfg.mk (sc_fs-magic-compare): A new syntax check to enforce this.

Improved by: Jim Meyering

11 years agostdbuf: support compilers other than __GNUC__
Pádraig Brady [Sat, 10 May 2014 03:53:29 +0000 (04:53 +0100)] 
stdbuf: support compilers other than __GNUC__

__SUNPRO_C >= 0x590 /*12.0*/ supports __attribute((constructor))
required by stdbuf, so use a more direct check for this.

Note ensure that --libexecdir is set to the appropriate
install location for libstdbuf.so so that stdbuf works
when installed on the system like it does when running
tests in the build directory.

* configure.ac (stdbuf_supported): Use a test prog to determine support.
* src/libstdbuf.c (stdbuf): Define appropriately for non GCC compilers,
and provide early feedback (compilation warning) if trying to compile
libstdbuf without the necessary support.
* src/stdbuf.c (set_LD_PRELOAD): Add a note on having stdbuf
look for libstdbuf.so in the default lib search path.
* cfg.mk (sc_prohibit-gl-attributes): Adjust so we can exclude
libstdbuf.so from prohibiting '__attribute', since we want
this form to avoid silently eliding this required attribute on non GCC.

Reported and tested by Rich Burridge.

11 years agotests: use chroot --user rather than internal setuidgid tool
Pádraig Brady [Mon, 19 May 2014 17:21:57 +0000 (18:21 +0100)] 
tests: use chroot --user rather than internal setuidgid tool

* init.cfg (require_root_): Adjust to use chroot, and make
`require_built_ chroot` implicit when chroot used in the test.
* po/POTFILES.in: Remove reference to setuidgid tool.
* src/.gitignore: Likewise.
* src/local.mk: Likewise.
* src/setuidgid.c: Remove.
* tests/cp/preserve-gid.sh: s/setuidgid/chroot --user/.
* tests/cp/special-bits.sh: Likewise.
* tests/id/setgid.sh: Likewise.
* tests/misc/truncate-owned-by-other.sh
* tests/mv/sticky-to-xpart.sh: Likewise.
* tests/rm/fail-2eperm.sh: Likewise.
* tests/rm/no-give-up.sh: Likewise.
* tests/touch/now-owned-by-other.sh: Likewise.
* tests/misc/chroot-fail.sh: Skip if chroot not built.

11 years agochroot: make changing root check more robust
Pádraig Brady [Sun, 18 May 2014 16:20:06 +0000 (17:20 +0100)] 
chroot: make changing root check more robust

* src/chroot.c (is_root): A new helper function to
determine if the passed argument is the root directory
based on inode comparison.
(main): Use the new helper rather than comparing strings.
* tests/misc/chroot-fail.sh: Add cases for alternative root paths.

11 years agochroot: exit immediately upon failure
Pádraig Brady [Sun, 18 May 2014 15:48:28 +0000 (16:48 +0100)] 
chroot: exit immediately upon failure

* src/chroot.c (main): Consistently exit with failure status immediately
upon hitting a terminal issue, rather than diagnosing multiple issues
lest users think previous failing actions are optional.

11 years agochroot: with --userspec clear root's supplemental groups
Pádraig Brady [Fri, 16 May 2014 08:50:24 +0000 (09:50 +0100)] 
chroot: with --userspec clear root's supplemental groups

It's dangerous and confusing to leave root's supplemental
groups in place when specifying other users with --userspec.
In the edge case that that is desired one can explicitly
specify --groups.

Also we implicitly set the system defined supplemental groups
for a user.  The existing mechanism where supplemental groups
needed to be explicitly specified is confusing and not general
when the lookup needs to be done within the chroot.

Also we extend the --groups syntax slightly to allow clearing
the set of supplementary groups using --groups=''.

* src/chroot.c (setgroups): On systems without supplemental groups,
clearing then is a noop and so should return success.
(main): Lookup the primary GID with getpwuid() when just a numeric
uid is specified, and also infer the USERNAME from this call,
needed when we're later looking up the supplemental groups for a user.
Support clearing supplemental groups, either implicitly for
unknown users, or explicitly when --groups='' is specified.
* tests/misc/chroot-credentials.sh: Various new test cases
* doc/coreutils.texi (chroot invocation): Adjust for the new behavior.
* NEWS: Mention the change in behavior.

11 years agochroot: don't chdir() if not changing root
Pádraig Brady [Tue, 13 May 2014 14:56:34 +0000 (15:56 +0100)] 
chroot: don't chdir() if not changing root

This allows chroot to be used as a light weight tool
to change user identification for a command,
while not changing the current working directory.
It also makes `chroot / true` consistently succeed on
all platforms for non root users.

* src/chroot.c (main): If the same root is specified. i.e. '/'
then don't change the current working directory, and avoid the
overhead of the other redundant calls.
* tests/misc/chroot-fail.sh: Remove failure guard previously
needed on some systems.  Also add an explicit case to ensure
we don't change directory.
* NEWS: Mention the change in behavior.

11 years agomaint: avoid clang -Wtautological-constant-out-of-range-compare warning
Pádraig Brady [Mon, 12 May 2014 14:46:43 +0000 (15:46 +0100)] 
maint: avoid clang -Wtautological-constant-out-of-range-compare warning

* src/df.c (decode_output_arg): Use only enum constants to avoid
clang "warning: comparison of constant -1 with expression of
type 'display_field_t' is always false"

11 years agodf: ignore non file system entries in /proc/mounts
Pádraig Brady [Mon, 12 May 2014 13:49:13 +0000 (14:49 +0100)] 
df: ignore non file system entries in /proc/mounts

Linux with network namespaces contains entries in /proc/mounts like:
  proc net:[4026532464] proc rw,nosuid,nodev,noexec,relatime 0 0
resulting in a failure to stat 'net:[...]', inducing a warning
and an exit with failure status.

* src/df.c (get_dev): Ignore all relative mount points.
* tests/df/skip-duplicates.sh: Add an entry to test relative dirs.

11 years agodf: fix handling of symlinks in mount list
Pádraig Brady [Mon, 12 May 2014 12:29:01 +0000 (13:29 +0100)] 
df: fix handling of symlinks in mount list

The symlink handling in commit v8.21-172-g33660b4 was incomplete
in the case where there were symlinks in the mount list itself.
For example, in the case where /dev/mapper/fedora-home was in the
mount list and that in turn was a symlink to /dev/dm-2, we have:

  before> df --out=source /dev/mapper/fedora-home
          devtmpfs

  after > df --out=source /dev/mapper/fedora-home
          /dev/mapper/fedora-home

* src/df.c (get_disk): Compare canonicalized device names from
the mount list.  Note we still display the non canonicalized name,
even if longer, as we assume that is the most representative.
* tests/df/df-symlink.sh: This could theoretically fail on some systems
depending on the content of the mount list, but adjust to fail on any
system where symlinks are present in the mount list for the current dir.

11 years agodf: also deduplicate virtual file systems
Pádraig Brady [Sat, 25 Jan 2014 01:14:29 +0000 (01:14 +0000)] 
df: also deduplicate virtual file systems

* src/df.c (filter_mountlist): Remove the constraint that
a '/' needs to be in the device name for a mount entry to
be considered for deduplication.  Virtual file systems also
have storage associated with them (like tmpfs for example),
and thus need to be deduplicated since they will be shown
in the default df output and subject to --total processing also.
* test/df/skip-duplicates.sh: Add a test to ensure we deduplicate
all entries, even for virtual file systems.  Also avoid possible
length operations on many remote file systems in the initial
check of df operation.  Also avoid the assumption that "/root"
is on the same file system as "/".
* NEWS: Mention the change in behavior.

11 years agotests: fix spurious failure with leading spaces in file names
Pádraig Brady [Tue, 13 May 2014 08:54:29 +0000 (09:54 +0100)] 
tests: fix spurious failure with leading spaces in file names

* tests/ls/stat-vs-dirent.sh: This test lists all parent directories,
and would spuriously fail if any of those had a file name with a
leading space as the first entry.  There is only ever a single space
between the right aligned inode number and the file name, so
process accordingly.

11 years agobuild: avoid bootstrap error with gettext 0.18.3.1
Assaf Gordon [Mon, 12 May 2014 16:17:06 +0000 (12:17 -0400)] 
build: avoid bootstrap error with gettext 0.18.3.1

* bootstrap: Create critical bootstrap files for autopoint,
before gnulib re-generates them, avoiding the issue.  See:
http://lists.gnu.org/archive/html/coreutils/2013-11/msg00038.html
http://savannah.gnu.org/bugs/?40083
https://pad.lv/1311895

11 years agoshred: don't infloop upon negative size
Jim Meyering [Sat, 10 May 2014 19:36:16 +0000 (12:36 -0700)] 
shred: don't infloop upon negative size

* src/shred.c (main): With the preceding change, shred -s-2 FILE
would write 64KB blocks forever -- or until disk full. This change
makes shred reject a negative size.
* tests/misc/shred-negative.sh: New file.
* tests/local.mk (all_tests): Add it.

11 years agoshred: fix overflow checking of command-line options
Paul Eggert [Sat, 10 May 2014 18:42:38 +0000 (11:42 -0700)] 
shred: fix overflow checking of command-line options

* src/shred.c (main): Limit -n (number of passes) value to
ULONG_MAX, not to UINT32_MAX, since the vars are unsigned long.
Limit the -s (file size) value to OFF_T_MAX.

11 years agotests: improve new ascii test of dd
Bernhard Voelker [Wed, 7 May 2014 16:42:03 +0000 (18:42 +0200)] 
tests: improve new ascii test of dd

* tests/dd/ascii.sh: Avoid unnecessary subshells.  Catch dd's
exit code.  Remove testing artifact.  In the case of a comparison
failure, show the differences in octal format in addition to
"binary files differ".  Simplify the creation of the 'in' file.

11 years agodd: fix conv=ascii, conv=ebcdic, conv=ibm to match POSIX
Paul Eggert [Wed, 7 May 2014 01:38:09 +0000 (18:38 -0700)] 
dd: fix conv=ascii, conv=ebcdic, conv=ibm to match POSIX

Problem reported by Don Baggett in <http:/bugs.gnu.org/17422>.
* NEWS:
* doc/coreutils.texi (dd invocation): Document this.
* src/dd.c (conversions): conv=ascii implies conv=unblock.
conv=ebcdic and conv=ibm imply conv=block.
(ascii_to_ebcdic, ebcdic_to_ascii): Correct to match
POSIX 1003.1-2013.
* tests/dd/ascii.sh: New file.
* tests/local.mk (all_tests): Add it.

11 years agotests: improve diagnostics when asserting empty files
Pádraig Brady [Tue, 6 May 2014 01:37:43 +0000 (02:37 +0100)] 
tests: improve diagnostics when asserting empty files

* tests/chmod/c-option.sh: Use `compare /dev/null ... || fail=1`
rather than `test -s ... && fail=1`, so that the file contents
are output, thus improving diagnostics for failing tests.
* tests/cp/acl.sh: Likewise.
* tests/cp/cp-a-selinux.sh: Likewise.
* tests/cp/cp-mv-enotsup-xattr.sh: Likewise.
* tests/cp/reflink-perm.sh: Likewise.
* tests/dd/misc.sh: Likewise.
* tests/misc/env-null.sh: Likewise.
* tests/misc/env.sh: Likewise.
* tests/misc/nice.sh: Likewise.
* tests/misc/nohup.sh: Likewise.
* tests/misc/printenv.sh: Likewise.
* tests/misc/xattr.sh: Likewise.
* tests/mv/update.sh: Likewise.
* tests/rm/deep-2.sh: Likewise.
* tests/rm/read-only.sh: Likewise.
* tests/split/r-chunk.sh: Likewise.
* tests/tail-2/follow-stdin.sh: Likewise.
* tests/tail-2/inotify-race.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/touch/no-dereference.sh: Likewise.

* cfg.mk (sc_prohibit_test_empty:): New syntax-check.
* tests/cp/proc-zero-len.sh: Adjust to avoid false syntax-check failure.
* tests/cp/proc-zero-len.sh: Likewise.
* tests/mv/part-symlink.sh: Likewise.
* tests/tail-2/infloop-1.sh: Likewise.

11 years agomv,cp: preserve symlink xattrs when copying across file systems
Pádraig Brady [Fri, 2 May 2014 21:54:32 +0000 (22:54 +0100)] 
mv,cp: preserve symlink xattrs when copying across file systems

* src/copy.c (copy_internal): Include the copy_attr() call for symlinks.
This should not dereference symlinks, since llistxattr() is used
in attr_copy_file() in libattr, and so should copy all but the filtered
extended attributes.  Note we don't just move the copy_attr() call
before the set_owner() call, as that would break capabilities
for non symlinks.
* tests/cp/cp-mv-enotsup-xattr.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/16131

11 years agotests: initial SMACK tests
Jarkko Sakkinen [Tue, 31 Dec 2013 16:09:14 +0000 (18:09 +0200)] 
tests: initial SMACK tests

* init.cfg (require_smack_): New function.
* local.mk: Referenced new tests.
* tests/id/smack.sh: SMACK tests (new file).
* tests/mkdir/smack-no-root.sh: SMACK tests (new file).
* tests/mkdir/smack-root.sh: SMACK tests (new file).

11 years agomaint: autotools-install: update tool version numbers to latest
Jim Meyering [Sat, 29 Mar 2014 16:23:05 +0000 (08:23 -0800)] 
maint: autotools-install: update tool version numbers to latest

* scripts/autotools-install (tarballs): Update to latest.

11 years agomaint: don't let envvar setting break ChangeLog generation
Jim Meyering [Sat, 3 May 2014 16:23:46 +0000 (09:23 -0700)] 
maint: don't let envvar setting break ChangeLog generation

* Makefile.am (gen-ChangeLog): Clear amend_git_log when we
don't set it, so that an envvar setting cannot cause trouble.

11 years agonumfmt: improve processing throughput by 800%
Pádraig Brady [Fri, 2 May 2014 00:23:21 +0000 (01:23 +0100)] 
numfmt: improve processing throughput by 800%

The devmsg() calls that took quote_n() arguments,
didn't normally output anything, but still incurred
the overhead of those quote_n() calls.

* src/numfmt.c (devmsg): Move the inline function
with _internal_ enablement check to...
* src/system.h: ...here as a variadic macro, with
the enablement check at the outer level.
* src/factor.c: As per numfmt.c but there is no
performance change in this case.
* NEWS: Mention the significant performance improvement.

11 years agonumfmt: support zero padding using --format="%010f"
Pádraig Brady [Wed, 30 Apr 2014 14:05:15 +0000 (15:05 +0100)] 
numfmt: support zero padding using --format="%010f"

* src/numfmt.c (setup_padding_buffer): Simplify the code by not
explicitly dealing with heap exhaustion.
(parse_format_string): Likewise.  Handle multiple grouping
modifiers as does the standard printf.  Handle the new leading
zero --format modifier.
(double_to_human): Use more defensive coding against overwriting
stack buffers.  Honor the leading zeros width.
(usage): Mention the leading zero --format modifier.
(main): Allow --padding in combo with a --format (width),
as the number of leading zeros are useful independent of
the main field width.
* doc/coreutils.texi (numfmt invocation): Likewise.
* tests/misc/numfmt.pl: Add new test cases.
* NEWS: Mention the improvement.

11 years agodoc: clarify the pr --page-width descriptions
Pádraig Brady [Tue, 29 Apr 2014 15:31:22 +0000 (16:31 +0100)] 
doc: clarify the pr --page-width descriptions

* doc/coreutils.texi (pr invocation): Clarify that -w or -W
will be rounded down so that each column has the same width.
Adjust the wording for -W, to avoid the implication that the
width of -S is insignificant to the page width.
* src/pr.c (usage): Add a period to avoid ambiguity in
the man page output.

11 years agoptx: fix whitespace trimming with multiple files
Pádraig Brady [Mon, 28 Apr 2014 12:29:41 +0000 (13:29 +0100)] 
ptx: fix whitespace trimming with multiple files

This issue was identified by running the test suite with
http://code.google.com/p/address-sanitizer/
which is included in GCC 4.8 and enabled with -fsanitize=address

This was checked on Fedora 20 with GCC 4.8 as follows:

  $ yum install libasan  # http://bugzilla.redhat.com/991003
  $ rm -f src/ptx.o
  $ make check AM_CFLAGS='-fsanitize=address' SUBDIRS=. VERBOSE=yes
  $ failure identified in tests/test-suite.log

To see this particular failure triggered with multiple files:

  $ src/ptx <(echo a) <(echo a) 2>&1 | asan_symbolize.py -d

=================================================================
==32178==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60200000e74f at pc 0x435442 bp 0x7fffe8a1b290 sp 0x7fffe8a1b288
READ of size 1 at 0x60200000e74f thread T0
    #0 0x435441 in define_all_fields coreutils/src/ptx.c:1425
    #1 0x7fa206d31d64 in __libc_start_main ??:?
    #2 0x42f77c in _start ??:?
0x60200000e74f is located 1 bytes to the left of 3-byte region
[0x60200000e750,0x60200000e753) allocated by thread T0 here:
    #0 0x421809 in realloc ??:?
    #1 0x439b4e in fread_file coreutils/lib/read-file.c:97
Shadow bytes around the buggy address:
  0x0c047fff9c90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9ca0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cb0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9cd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fd fd
=>0x0c047fff9ce0: fa fa 03 fa fa fa fd fd fa[fa]03 fa fa fa 00 00
  0x0c047fff9cf0: fa fa 04 fa fa fa 04 fa fa fa fd fa fa fa fd fa
  0x0c047fff9d00: fa fa 00 fa fa fa fd fa fa fa 00 fa fa fa 00 fa
  0x0c047fff9d10: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff9d20: fa fa fd fa fa fa fd fa fa fa fd fa fa fa fd fa
  0x0c047fff9d30: fa fa fd fa fa fa 00 fa fa fa 00 fa fa fa 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:     fa
  Heap right redzone:    fb
  Freed heap region:     fd
  Stack left redzone:    f1
  Stack mid redzone:     f2
  Stack right redzone:   f3
  Stack partial redzone: f4
  Stack after return:    f5
  Stack use after scope: f8
  Global redzone:        f9
  Global init order:     f6
  Poisoned by user:      f7
  ASan internal:         fe
==32178==ABORTING

The initial report and high level analysis were from Jim Meyering...

  "The underlying problem is that swallow_file_in_memory()
  is setting the contents of the global text_buffer for the first file,
  then updating it (clobbering old value) for the second file.
  Yet, some pointers to the initial buffer have been squirreled away
  and later, one of them (keyafter) is presumed to point into
  the new "text_buffer", which it does not.  The subsequent
  SKIP_WHITE_BACKWARDS use backs up "cursor" and goes out of bounds."

* src/ptx.c (text_buffers): Maintain references for the limits of each
buffer corresponding to each file, rather than just the last processed.
(struct OCCURS): Add a member to map back to the corresponding file.
Note normally this could be computed from the "reference" member
rather than needing the extra storage, however this is not possible
when in --references mode.
(find_occurs_in_text): Reference the array rather than a single entry.
(define_all_fields): Likewise.  Also avoid computing the file index
since this is now stored directly.
(main): Update text_buffers[] array rather than a single text_buffer.
* tests/misc/ptx-overrun.sh: Even though this issue is already triggered
with AddressSanitizer, add a new case to demonstrate the whitespace
trimming issue, and to trigger without AddressSanitizer.
Fixes https://bugs.gnu.org/16171

11 years agomaint: make ChangeLog generation more robust
Pádraig Brady [Sat, 19 Apr 2014 11:45:11 +0000 (12:45 +0100)] 
maint: make ChangeLog generation more robust

* Makefile.am (gen-ChangeLog): Sync changes from GNU hello,
to ensure exit status is propagated, and to support an optional
git-log-fix file.

11 years agomaint: remove trailing comma from enum to make gl/ c89 compat
Edgars Irmejs [Wed, 23 Apr 2014 19:20:40 +0000 (22:20 +0300)] 
maint: remove trailing comma from enum to make gl/ c89 compat

* gl/lib/fadvise.c (fadvice_t): This might go to gnulib some day so
remove the trailing comma.
Fixes http://bugs.gnu.org/17329

11 years agodoc: clarify meaning of stat's mtime and ctime formats
Assaf Gordon [Mon, 21 Apr 2014 18:31:23 +0000 (14:31 -0400)] 
doc: clarify meaning of stat's mtime and ctime formats

* src/stat.c (usage): s/modification time/data modification time/;
s/change time/status change time/
* doc/coreutils.texi: Ditto.

11 years agotests: make ls tests independent of COLORTERM env
Pádraig Brady [Fri, 18 Apr 2014 10:19:10 +0000 (11:19 +0100)] 
tests: make ls tests independent of COLORTERM env

Since the recent commit v8.22-68-g08783f1, ls coloring
is now dependent on the COLORTERM environment variable.

* tests/envvar-check: Unset COLORTERM from test environment.
* tests/ls/color-dtype-dir.sh: Ensure coloring is used.
* tests/misc/ls-misc.pl: Likewise.

Prompted by the continuous integration build failure at:
http://hydra.nixos.org/build/10397646

11 years agodoc: disambiguate chmod man page reference to (a) users
Pádraig Brady [Wed, 16 Apr 2014 23:03:00 +0000 (00:03 +0100)] 
doc: disambiguate chmod man page reference to (a) users

* man/chmod.x: Don't rely on the bold markup for 'a' to
distinguish it as that's not done in all cases.

11 years agodircolors: add hurd and mach-gnu-color terminal types
David Michael [Thu, 17 Apr 2014 16:43:16 +0000 (12:43 -0400)] 
dircolors: add hurd and mach-gnu-color terminal types

mach-color was replaced by mach-gnu-color in Hurd in 2012.
mach-color is left for compatibility and corresponding
definitions for mach-color are still found in ncurses.

* src/dircolors.hin: Add hurd and mach-gnu-color.

11 years agols: don't output colors with unknown TERM env variable
Guilherme de Almeida Suckevicz [Wed, 16 Apr 2014 15:38:49 +0000 (16:38 +0100)] 
ls: don't output colors with unknown TERM env variable

--colors controls whether to output colors depending on
whether we're connected to a terminal or not, while this
change gives control over which terminals we output colors to.

* NEWS: Mention the change in behavior.
* src/ls.c (known_term_type): A new function to search the static
list from dircolors.h
(parse_ls_colors): Honor the TERM when both LS_COLORS and COLORTERM
are non empty.
* tests/ls/color-term.sh: A new test.
* tests/local.mk: Reference the new test.
Fixes http://bugs.gnu.org/15992

11 years agodoc: improve remove prompt translator comment
Benno Schulenberg [Wed, 16 Apr 2014 19:26:54 +0000 (21:26 +0200)] 
doc: improve remove prompt translator comment

* src/remove.c (prompt): Explain where the difficulty with translating
these two strings resides, and suggest an alternative: the one that
Paul Eggert first proposed back in 2002, which seems fully resistant.

11 years agomaint: df: avoid sizeof(char**) static analysis warning
Bernhard Voelker [Wed, 16 Apr 2014 08:43:09 +0000 (10:43 +0200)] 
maint: df: avoid sizeof(char**) static analysis warning

* src/df.c (alloc_table_row): Use the size of char** to enlarge
the table.  Spotted by Coverity.

11 years agotests: fix false dd conv=sparse failure on newer XFS
Pádraig Brady [Fri, 11 Apr 2014 22:44:13 +0000 (23:44 +0100)] 
tests: fix false dd conv=sparse failure on newer XFS

* tests/dd/sparse.sh: When testing that a hole is created,
use an existing sparse destination file, so that we're
not write extending the file size, and thus avoiding
speculative preallocation which can result in smaller
holes than requested.
Workaround suggested by Brian Foster

11 years agomaint: avoid static analysis warnings in ln.c
Pádraig Brady [Thu, 10 Apr 2014 16:09:57 +0000 (17:09 +0100)] 
maint: avoid static analysis warnings in ln.c

* src/ln.c (do_link): It's not obvious that record_file() is a noop
in the symlink case (in that case dest_set is NULL and so ignored).
So to make it obvious, and to avoid false positives seen in coverity,
add the explicit condition here.

11 years agomaint: document timeout --preserve-status in v8.21 NEWS
Pádraig Brady [Wed, 9 Apr 2014 21:04:21 +0000 (22:04 +0100)] 
maint: document timeout --preserve-status in v8.21 NEWS

* NEWS: Add the omitted new feature.
* cfk.mk (old_NEWS_hash): Adjust accordingly.

11 years agodoc: clarify in --help that -Z doesn't take an argument
Pádraig Brady [Wed, 9 Apr 2014 12:37:42 +0000 (13:37 +0100)] 
doc: clarify in --help that -Z doesn't take an argument

* NEWS: Fix a confusing old entry.
* cfg.mk (old_NEWS_hash): Adjust accordingly.
* src/cp.c (usage): Separate the -Z and --context descriptions.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
Fixes http://bugs.gnu.org/17220

11 years agomaint: various cleanups
Pádraig Brady [Fri, 7 Mar 2014 23:56:20 +0000 (23:56 +0000)] 
maint: various cleanups

* tests/misc/numfmt.pl: Fix comment misspelling.
* src/cut.c: Likewise.
* src/tsort.c (detect_loop): Replace an fprintf() with error().

11 years agoshred: overwrite inode storage used by some file systems
Pádraig Brady [Fri, 4 Apr 2014 12:35:56 +0000 (13:35 +0100)] 
shred: overwrite inode storage used by some file systems

* doc/coreutils.texi (shred invocation): Mention some reasons
why clearing slack space might be useful.
* src/shred.c (do_wipefd): Add initial writes for each pass
for small regular files in case the storage for those is
in the inode, and thus a larger write up to a block size would
bypass that.  Move the direct I/O control to...
(dopass): ... here so we can avoid enabling it for these small
initial writes.  It's better to retry direct I/O for each pass
anyway to handle the case where direct I/O is disabled for only
the last portion of a file when the size is not a multiple of
the block size.  Note we don't avoid the sync for the initial
write as it will be small but more importantly could be on a
different part of the disk and so worth doing independently
to ensure the write is not discarded.
* tests/misc/shred-exact.sh: Check some more direct I/O cases.
* NEWS: Mention the improvements.
The inode storage issue was mentioned by Paul Eggert.

11 years agoshred: avoid a data pass on empty files
Pádraig Brady [Thu, 3 Apr 2014 12:47:48 +0000 (13:47 +0100)] 
shred: avoid a data pass on empty files

* src/shred.c (do_wipefd): Don't increase the size written
for an empty file up to a full block.  Also increase the size
to OFF_T_MAX in the edge case where we do overflow.
* NEWS: Mention the shred improvements from recent changes.
* tests/misc/shred-passes.sh: Adjust as we no longer
write a BLKSIZE of data for empty files.

11 years agocp: don't reserve a device number
Paul Eggert [Thu, 3 Apr 2014 16:48:22 +0000 (09:48 -0700)] 
cp: don't reserve a device number

* src/copy.c (copy_internal): Replace dev_t arg DEVICE with struct
stat pointer arg PARENT.  All callers changed.  This removes an
unwarranted assumption that dev_t values of 0 cannot occur in file
systems.  See: http://bugs.gnu.org/17179

11 years agoshred: shred one block even for empty files
Paul Eggert [Thu, 3 Apr 2014 16:42:53 +0000 (09:42 -0700)] 
shred: shred one block even for empty files

* src/shred.c (do_wipefd): Shred one block of empty regular files.
This reverts an unintended part of the previous change.

11 years agoshred: port to GNU/Linux behavior with tape drives
Paul Eggert [Thu, 3 Apr 2014 06:28:20 +0000 (23:28 -0700)] 
shred: port to GNU/Linux behavior with tape drives

See: http://bugs.gnu.org/17149
* src/shred.c [__linux__]: Include <sys/mtio.h>.
(dorewind): New function, which works around the lseek problem with
tape drives on GNU/Linux, the same way that dd does.
(dopass): Use it.  New arg ST, needed for dorewind.  All uses changed.
(do_wipefd): Don't rely on undefined behavior on integer overflow
of file sizes.  Use INT_ADD_OVERFLOW instead.

11 years agohead: port to Darwin and use simpler seeks
Paul Eggert [Mon, 31 Mar 2014 19:16:44 +0000 (12:16 -0700)] 
head: port to Darwin and use simpler seeks

This removes an unportable assumption that if lseek succeeds, the
file is capable of seeking.  See: http://bugs.gnu.org/17145
* src/head.c (elseek): New function, for consistency in reporting
lseek failures.
(elide_tail_bytes_file, elide_tail_lines_seekable)
(elide_tail_lines_file, head_lines, head): Use it.
(elide_tail_bytes_file, elide_tail_lines_file):
New args CURRENT_POS and SIZE.  All uses changed.  Don't bother
invoking lseek, since we know the file's pos and size now.
(elide_tail_bytes_file): Change a local from uintmax_t to off_t,
since it fits.
(head): Use lseek only on regular files, since its behavior on
unseekable devices is implementation-defined.
* NEWS: Document this.

11 years agohead: fix bug with head -c-N when stdin is not at start
Paul Eggert [Mon, 31 Mar 2014 17:21:58 +0000 (10:21 -0700)] 
head: fix bug with head -c-N when stdin is not at start

* src/head.c (elide_tail_bytes_file): Fix typo in lseek invocation.
* tests/misc/head-c.sh: Add test for this bug.
* NEWS: Document this.

11 years agomv: fix issues with previous prompt adjustments
Pádraig Brady [Wed, 26 Mar 2014 13:36:16 +0000 (13:36 +0000)] 
mv: fix issues with previous prompt adjustments

* src/copy.c (overwrite_ok): Fix the gettext calls so
that the second string is tagged for translation.
Display the correct "replace ..." prompt when in move_mode.
* tests/mv/i-3.sh: Display the output on failure to ease debugging.

11 years agoptx: avoid --format long option falling through into --help
Bernhard Voelker [Wed, 26 Mar 2014 08:02:42 +0000 (09:02 +0100)] 
ptx: avoid --format long option falling through into --help

* src/ptx.c (main): Add a 'break' after the --format handling case.
Otherwise it would fall through into the usage case.
* tests/misc/ptx.pl: Add test cases for --format=tex and --format=roff.
* NEWS (Bug fixes): Mention the fix.
Bug introduced in 1999-04-04 commit, SH-UTILS-1_16f-269-gd815c15.
Spotted by coverity (MISSING_BREAK).

11 years agobasename: mention that the -s option implies -a in usage
Bernhard Voelker [Tue, 25 Mar 2014 22:41:45 +0000 (23:41 +0100)] 
basename: mention that the -s option implies -a in usage

* src/basename.c (usage): Mention that -s implies -a.
(main): Add "fall through" comment to case 's'.

Spotted by coverity: MISSING_BREAK.

11 years agocp: simplify overwrite logic
Paul Eggert [Tue, 25 Mar 2014 06:17:02 +0000 (23:17 -0700)] 
cp: simplify overwrite logic

* src/copy.c (overwrite_ok): Rename from overwrite_prompt.  Invoke
yesno instead of having the caller do it; that's cleaner.  Return
bool, not void.  All callers changed.

11 years agocp: improve quality of overwrite prompt
Paul Eggert [Tue, 25 Mar 2014 06:14:43 +0000 (23:14 -0700)] 
cp: improve quality of overwrite prompt

* src/copy.c (overwrite_prompt): New arg X.  All callers changed.
Use X to improve the quality of the prompt (Bug#17087).
* tests/mv/i-2.sh, tests/mv/i-3.sh: Change test to match new prompt.

11 years agosplit: avoid unnecessary input buffering
Pádraig Brady [Thu, 20 Mar 2014 10:00:13 +0000 (10:00 +0000)] 
split: avoid unnecessary input buffering

Input buffering is best avoided because it introduces
delayed processing of output for intermittent input,
especially when the output size is less than that of
the input buffer.  This is significant when output
is being further processed which could happen if split
is writing to precreated fifos, or through --filter.

If input is arriving quickly from a pipe then this will
already be buffered before we read it, so fast arriving
input shouldn't be a performance issue.

* src/split.c (lines_split, lines_bytes_split, bytes_split,
lines_chunk_split, bytes_chunk_extract): s/full_read/safe_read/.
* THANKS.in: Mention the reporter.
* NEWS: Mention the improvement.

11 years agodoc: clarify the operation of uniq -uD
Pádraig Brady [Wed, 19 Mar 2014 17:01:28 +0000 (17:01 +0000)] 
doc: clarify the operation of uniq -uD

The description of -u was inaccurate when combined with -D:

  $ printf '%s\n' '1 a' '2 a' | uniq -uD -f1
  1 a

* doc/coreutils.texi (uniq invocation): Clarify that it's
the last repeated line that is suppressed from the output.

Fixes http://bugs.gnu.org/17022

11 years agodoc: avoid regex ambiguity in chmod mode description
Edward Welbourne [Wed, 19 Mar 2014 16:19:08 +0000 (16:19 +0000)] 
doc: avoid regex ambiguity in chmod mode description

* man/chmod.x: s/[+-=]/[-+=]/
* doc/perm.texi (Symbolic Modes): Likewise.
* THANKS.in: Remove patch owner.
Fixes http://bugs.gnu.org/17041

11 years agochroot: always diagnose failure to set supplemental groups
Pádraig Brady [Thu, 13 Mar 2014 01:32:46 +0000 (01:32 +0000)] 
chroot: always diagnose failure to set supplemental groups

* src/chroot.c (setgroups): Change this replacement to
fail when called so that platforms like Interix without support for
supplemental groups don't silently ignore a --groups option.

11 years agochmod: fix erroneous warnings with -R --changes
Dylan Simon [Tue, 18 Mar 2014 15:50:29 +0000 (11:50 -0400)] 
chmod: fix erroneous warnings with -R --changes

For files with "special" bits set, we would stat the relative
file name in the wrong directory, giving an erroneous ENOENT diagnostic.
This issue was introduced with commit v5.92-653-gc1994c1
which changed fts to not change directory on traversal.

* src/chmod.c (mode_changed): Use fts->fts_cwd_fd with fstatat rather
than stat.  All callers changed.
* tests/chmod/c-option.sh: Add a test case.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/17035

11 years agomaint: fix typo in comment in fadvise.c
Bernhard Voelker [Tue, 18 Mar 2014 22:48:14 +0000 (23:48 +0100)] 
maint: fix typo in comment in fadvise.c

* gl/lib/fadvise.c: s/the the/the/, indroduced in commit
v8.22-40-g4f21182.  Promted by sc_prohibit_doubled_word.
While at it, also s/be candidate/be a candidate/.

11 years agostat: port birthtime to Solaris 11
Paul Eggert [Tue, 18 Mar 2014 23:12:26 +0000 (16:12 -0700)] 
stat: port birthtime to Solaris 11

Problem reported by Rich Burridge.
* src/stat.c [HAVE_GETATTRAT]: Include <attr.h>, <sys/nvpair.h>.
(print_statfs, print_stat, print_it):
Pass fd, too, for the benefit of get_birthtime.
All uses changed.
(get_birthtime): New function, for porting to Solaris 11.
(print_stat): Use it.

* configure.ac (getattrat, LIB_NVPAIR): New checks.
* src/local.mk (src_stat_LDADD): Add $(LIB_NVPAIR).

11 years agoln: with -sr, don't segfault for a TARGET of ''
Jim Meyering [Fri, 14 Mar 2014 00:05:04 +0000 (17:05 -0700)] 
ln: with -sr, don't segfault for a TARGET of ''

Prior to this change, "ln -sr '' F" would segfault, attempting
to read path2[1] in relpath.c's path_common_prefix function.
This problem arises whenever canonicalize_filename_mode returns
NULL.
* src/ln.c (convert_abs_rel): Call relpath only when
both canonicalize_filename_mode calls return non-NULL.
* tests/ln/relative.sh: Add a test to trigger this failure.
* THANKS.in: List reporter's name/address.
* NEWS (Bug fixes): Mention it.
Reported by Erik Bernstein in 739752@bugs.debian.org.
Fixes http://bugs.gnu.org/17010.

11 years agomaint: avoid "attribute-const"-suggesting warning from gcc
Jim Meyering [Mon, 18 Nov 2013 18:13:06 +0000 (10:13 -0800)] 
maint: avoid "attribute-const"-suggesting warning from gcc

* gl/lib/fadvise.c: Use a pragma to turn off this warning option:
-Wsuggest-attribute=const.  Without this change, building with
--enable-gcc-warnings would evoke this error:

    lib/fadvise.c:25:1: error: function might be candidate for\
    attribute 'const' [-Werror=suggest-attribute=const]

11 years agoscripts: autotools-install: update
Jim Meyering [Mon, 5 Aug 2013 14:28:34 +0000 (07:28 -0700)] 
scripts: autotools-install: update

* scripts/autotools-install: Update version numbers of latest
automake and gettext packages.

11 years agochroot: improve --userspec and --groups look-up
Pádraig Brady [Mon, 3 Mar 2014 01:54:36 +0000 (01:54 +0000)] 
chroot: improve --userspec and --groups look-up

- Support arbitrary numbers in --groups, consistent with
  what is already done for --userspec
- Avoid look-ups entirely for --groups items with a leading '+'
- Support names that are actually numbers in --groups
- Ignore an empty --groups="" option for consistency with --userspec
- Look up both inside and outside the chroot with inside taking
  precedence.  The look-up outside may load required libraries
  to complete the look-up inside the chroot.  This can happen for
  example with a 32 bit chroot on a 64 bit system, where the
  32 bit NSS plugins within the chroot fail to load.

* src/chroot.c (parse_additional_groups): A new function refactored
from set_addition_groups(), to just do the parsing.  The actual
setgroups() call is separated out for calling from the chroot later.
(main): Call parse_user_spec() and parse_additional_groups()
both outside and inside the chroot for the reasons outlined above.
* tests/misc/chroot-credentials.sh: Ensure arbitrary numeric IDs
can be specified without causing look-up errors.
* NEWS: Mention the improvements.
* THANKS.in: Add Norihiro Kamae who initially reported the issue
with a proposed patch.
Also thanks to Dmitry V. Levin for his diagnosis and sample patch.

11 years agodoc: fix typo in texinfo docs
Aleksej Serdjukov [Sun, 9 Mar 2014 17:49:55 +0000 (17:49 +0000)] 
doc: fix typo in texinfo docs

* doc/coreutils.texi (Operating on characters): s/This/These/.
Fixes http://bug.gnu.org/16973

11 years agodoc: fix readpath typo in texinfo contents
Pádraig Brady [Fri, 7 Mar 2014 17:02:48 +0000 (17:02 +0000)] 
doc: fix readpath typo in texinfo contents

* docs/coreutils.texi: s/readpath/realpath/
Fixes http://bugs.gnu.org/16964

11 years agotests: avoid the :> construct which can hide errors
Pádraig Brady [Wed, 5 Mar 2014 18:41:16 +0000 (18:41 +0000)] 
tests: avoid the :> construct which can hide errors

On most shells `:>file || framework_failure_` will not evaluate
the framework_failure_ even if there was an error writing the file.
shells which do evaluate the failure are ksh 93u+ and bash 4.2,
while shells wich don't include bash 4.3, solaris, freebsd, dash.

Furthermore this construct is problematic on Solaris 10 sh,
which will try to optimize away a `:' command in a loop
after the first iteration, even if it is redirected.

* tests/cp/link-deref.sh: Remove the leading colon on redirections.
* tests/cp/reflink-perm.sh: Likewise.
* tests/id/zero.sh: Likewise.
* tests/install/install-C.sh: Likewise.
* tests/misc/env.sh: Likewise.
* tests/misc/md5sum-bsd.sh: Likewise.
* tests/misc/runcon-no-reorder.sh: Likewise.
* tests/mv/partition-perm.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/split/l-chunk.sh: Likewise.
* tests/split/line-bytes.sh: Likewise.
* tests/tail-2/inotify-rotate.sh: Likewise.
* tests/tail-2/retry.sh: Likewise.
* tests/tail-2/symlink.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.
* tests/touch/read-only.sh: Likewise.
+ cfg.mk (sc_prohibit_colon_redirection): A new syntax check
to avoid further instances of this creeping in.

11 years agotests: fix false failure in nohup.sh in non tty builds
Pádraig Brady [Wed, 5 Mar 2014 15:14:07 +0000 (15:14 +0000)] 
tests: fix false failure in nohup.sh in non tty builds

* tests/misc/nohup.sh: When running tests without a controlling tty,
an exec failure is triggered in a subshell, which causes POSIX
shells to immediately exit the subshell.  This was brought
to notice by the newly conforming bash 4.3.
Fixes http:/bugs.gnu.org/16940

11 years agodoc: improve df --human and --si, help and man page
Pádraig Brady [Mon, 3 Mar 2014 02:49:25 +0000 (02:49 +0000)] 
doc: improve df --human and --si, help and man page

* src/df.c (usage): Adjust the --human and --si descriptions
to not depend on each other.  Also include an example that is
illustrative of the rounding, suffix, width, and localized fractions.
* src/system.h (emit_size_note). Adjust so that it's obvious the
description is pertaining to the input SIZE argument, and not
to any sizes that might be output by df for example.
Fixes http://bugs.gnu.org/16922

11 years agodate: fix crash or infinite loop when parsing a malformed TZ=""
Pádraig Brady [Thu, 27 Feb 2014 23:43:34 +0000 (23:43 +0000)] 
date: fix crash or infinite loop when parsing a malformed TZ=""

* NEWS: Mention the fix.
* gnulib: Update to incorporate the fix.
This is the only change in this gnulib update.
* tests/misc/date.pl: Add a test for this case.

Fixes http://bugs.gnu.org/16872