Compare commits

...

39 Commits
v8.1 ... v8.2

Author SHA1 Message Date
Jim Meyering
70d023b076 version 8.2
* NEWS: Record release date.
2009-12-11 14:00:40 +01:00
Jim Meyering
ca39c9c308 tests: use a slightly better CU_TEST_NAME setting
* tests/check.mk (CU_TEST_NAME): Better test names.
2009-12-11 13:59:57 +01:00
Jim Meyering
fc4d3f63b0 tail: don't call fstat on an uninitialized FD
This bug showed up via valgrind as a "Conditional jump or move
depends on uninitialized value(s)" error.
* src/tail.c (ignore_fifo_and_pipe): New function.
(main): Use it only when tailing forever.
The code to compute n_viable and mark some F[i] as ignored would call
isapipe on an uninitialized file descriptor.  But n_viable and those
.ignored marks are useful/used only when tailing forever.  This bug
was introduced via commit f0ff8c73 (7.6), "tail: make the new
piped-stdin test as portable as the old one".
* NEWS (Bug fixes): Mention it.
2009-12-11 12:15:13 +01:00
Jim Meyering
3df2108b0d doc: NEWS: mention that gnulib's mgetgroups fix affects id
* NEWS (Bug fixes): Mention the "id" bug fix inherited via this gnulib
change: "mgetgroups: do not write bytes beyond end of malloc'd buffer"
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=51d5e813e9ee6cf23
2009-12-11 08:51:28 +01:00
Jim Meyering
829c418d67 build: update gnulib submodule to latest 2009-12-10 16:50:27 +01:00
Jim Meyering
06e9880c8e tests: avoid spurious failure when run via valgrind
* tests/misc/printenv: Ignore LD_PRELOAD differences.
2009-12-10 16:50:05 +01:00
Jim Meyering
bb4cb10e89 doc: NEWS: the "make distcheck" vulnerability dates back to 5.0
* NEWS (Bug fixes): Correct the introduced-in version number.
This was introduced on 2003-04-02 by commit 722a49ea.
2009-12-09 13:58:12 +01:00
Jim Meyering
23c0cecaa8 doc: NEWS: mention the "make distcheck" vulnerability
* NEWS (Bug fixes): Mention implications of the "make distcheck" change.
This was introduced on 2008-07-22 by commit 9bb0d576, "tests: ensure
"make check" w/tainted build dir no longer impacts $HOME".
2009-12-09 13:09:33 +01:00
Jim Meyering
19b460b239 tests: don't let "umask 077" cause root-only cp/preserve-gid failure
* tests/cp/preserve-gid: Use working_umask_or_skip_ to set umask to 022.
2009-12-09 08:45:30 +01:00
Jim Meyering
0f8bb24ca8 build: update gnulib submodule to latest 2009-12-08 21:34:00 +01:00
Pádraig Brady
321d2901de maint: remove an erroneous comment
* tests/misc/timeout: Remove an erroneous comment
introduced through copy and paste.
2009-12-08 15:33:18 +00:00
Pádraig Brady
f5a97b8269 sort: fix failure if sort's parent has ignored SIGCHLD
* src/sort.c (main): Reset the SIGCHLD handler to the default
as otherwise wait() could return an error.
* tests/misc/sort-compress: Set the CHLD handler in a subshell
to SIG_IGN to ensure the sort command resets it to SIG_DFL.
* NEWS: Mention the fix.
2009-12-08 15:29:27 +00:00
Pádraig Brady
73d4626134 timeout: fix failure if timeout's parent has ignored SIGCHLD
* src/timeout.c (main): Reset the SIGCHLD handler to the default
as otherwise wait() could return -1 and set errno to ECHILD.
This condition was ignored until commit 0b1dcf33, on 31-08-2009,
"timeout: defensive handling of all wait() errors"
but subsequently timeout would run the command correctly
but then fail with an error message.
* tests/misc/timeout: In a subshell set the CHLD handler to
SIG_IGN to ensure the timeout command resets it to SIG_DFL.
* NEWS: Mention the fix.
2009-12-08 15:17:01 +00:00
Pádraig Brady
7ac41f9950 tests: fix stty-row-col failure on small fixed terminals
* tests/misc/stty-row-col: Linux virtual consoles at least,
issue an error if you try to increase their size, so skip the
test if we can't increase the dimensions of the tty by 1 cell.
Reported by Matthew Burgess.
2009-12-08 15:08:44 +00:00
Pádraig Brady
dcff25a925 tests: fix stty failure with serial control settings
* tests/misc/stty: Don't check the serial control settings as
these are ignored by various Linux kernels.
Reported by Matthew Burgess.
2009-12-08 15:06:01 +00:00
Jim Meyering
7a2b0b8f66 build: update gnulib submodule to latest 2009-12-07 18:56:07 +01:00
Jim Meyering
ae034822c5 build: distcheck: do not leave a $TMPDIR/coreutils directory behind
* dist-check.mk (tmpdir): Rename from TMPDIR.  Use ./tests/torture
unconditionally, rather than $TMPDIR-with-default-to-/tmp.
Otherwise, running "make distcheck" could leave an empty /tmp/coreutils
directory behind.
(tp): Simplify, now that it's always in the build-dir.
(taint-distcheck): Set HOME earlier, in case $(MAKE) misbehaves.
(my-instcheck, coreutils-path-check): Add diagnostics, so it's easier
to diagnose when each runs.
(coreutils-path-check): Run configure with --quiet, to reduce output.
Inspired by Ralf Wildenhues' report of /tmp/coreutils being left behind.
2009-12-07 18:54:26 +01:00
Jim Meyering
d8cadda3b9 tests: readdir-mountpoint-inode avoid false-positive w/virtualbox
* tests/ls/readdir-mountpoint-inode: With some systems, stat can
succeed on a mount point and report that the inode number is 0.
Since ls displays "?" for those, that would otherwise show up as a
difference.  Skip such mount points.  Reported by Sergei Steshenko
in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/19142
2009-12-06 08:48:51 +01:00
Pádraig Brady
afd087d414 tests: don't run tail-2/inotify-race by default
* tests/tail-2/inotify-race: Note the caveats of the test.
I.E. the intermittent skips and the gdb hang reported
by Alan Curry.  Add extra info to the log on why the test
is skipped as it may be due to multiple reasons.  Mark
the test as very expensive so that it's not normally run.
2009-12-06 00:42:42 +00:00
Eric Blake
9b4b38f56e id: handle systems without getgroups support
If getgroups failed with ENOSYS, mgetgroups would unnecessarily
fail, and that provoked id into freeing an uninitialized pointer.
Meanwhile, we were not using xalloc_die properly.  Both issues
are better solved in gnulib, by introducing xgetgroups; this
patch uses the new interface.

Regression introduced by commit 6a31fd8d7.

* gnulib: Update, for mgetgroups improvments.
* src/id.c (print_full_info): Adjust caller to die on allocation
failure, and no longer worry about ENOSYS.
* src/group-list.c (print_group_list): Likewise.
* src/setuidgid.c (main): Likewise.
* NEWS: Mention the fix.
* THANKS: Update.
Reported by Scott Harrison.
2009-12-04 19:18:06 -07:00
Jim Meyering
5224fbd6f9 tests: fix a bug in sanitize_path_ that inhibited verbose output
* tests/test-lib.sh (sanitize_path_): Use "set -- ...", not "set - ...",
since the latter turns off the -x setting we rely on for VERBOSE=yes
output.
2009-12-03 17:04:16 +01:00
Eric Blake
d16a8f6c7f sort: fix link failure on Solaris
Commit f9d0bb8481 made sort depend on xnanosleep.

* src/Makefile.am (sort_LDADD): Add LIB_NANOSLEEP.
2009-12-01 13:07:48 -07:00
Jim Meyering
0dc1f4c6f3 rm: fix empty-name bug introduced with conversion to use fts
While "rm ''" would properly fail, "rm F1 '' F2" would fail
to remove F1 and F2, due to the empty string argument.
This bug was introduced on 2009-07-12, via commit 4f73ecaf,
"rm: rewrite to use fts".
* gnulib: Update to latest, for fixed fts.c.
* NEWS (Bug fixes): Describe it.
* tests/rm/empty-name: Adjust for changed diagnostic.
(mk_file): Define, copied from misc/ls-misc.
(empty-name-2): New test, for today's fix.
* lib/xfts.c (xfts_open): Reflect the change in fts_open, now that
it no longer fails immediately when one argument is the empty string.
Assert that the bit flags were not the cause of failure.
* po/POTFILES.in: Remove xfts.c.
* THANKS: Update.
Reported by Ladislav Hagara.
2009-12-01 14:38:39 +01:00
Pádraig Brady
cb775df09e bootstrap: fix handling of various perl --version formats
* bootstrap (get_version): Don't use perl's $] special
variable, as that requires updating all bootstrap.conf files to
use perl's x.yyyzzz version format.  Instead make the regular
expression more general to support version formats from older
perl-5.005_002 (5.5.2) and perl-5.11 which has other numbers
in the version line.
2009-11-30 14:04:43 +01:00
Jim Meyering
b92e0455e1 bootstrap: update from gnulib, for perl-5.11.x support
* bootstrap (get_version): Handle perl separately,
since perl-5.11's --version output is different.
2009-11-29 14:04:09 +01:00
Jim Meyering
3910144405 build: update gnulib submodule to latest 2009-11-29 10:56:57 +01:00
Jim Meyering
4bb812ad49 maint: chown.c: remove a comment
* src/chown.c: Remove old spec-like comment.
2009-11-28 06:48:03 +01:00
Eric Blake
b498c58013 tests: fix link failure on cygwin
Counterpart to commit 8fe40b84bd, since test-link.c uses rename,
and we override gnulib with a rename() replacement that can xalloc_die.

* gl/modules/link-tests.diff: New file.
2009-11-24 06:36:13 -07:00
Eric Blake
f9d0bb8481 build: fix link failure on cygwin
Cygwin 1.5 has a broken sleep, and the gnulib tests dragged in
rpl_sleep which then caused a link failure because it wasn't in
libcoreutils.a.  We could solve it by using the gnulib sleep module.
However, sleep and usleep may interact poorly with SIGALRM, and they
have less granularity; so it is better to adopt a policy that if we
must sleep, prefer xnanosleep.

* src/sort.c (pipe_fork): Use xnanosleep, to avoid the need for
rpl_sleep on cygwin, and to reduce granularity.
(MAX_FORK_TRIES_COMPRESS, MAX_FORK_TRIES_DECOMPRESS): Increase,
to account for reduction in granularity.
* src/tail.c (tail_file): Use xnanosleep in debug code.
* cfg.mk (sc_prohibit_sleep): New rule.
2009-11-24 06:36:07 -07:00
Jim Meyering
ab6b27eba7 tests: avoid test failures when PATH contains an unsearchable directory
* tests/test-lib.sh (sanitize_path_): New function.
Always call it.
2009-11-23 17:49:39 +01:00
Dmitry V. Levin
9cf9f8e1e0 tests: do not fail on read-only root file system
* tests/touch/not-owner: Handle the case when the root file system is
mounted read-only.
Reported by Solar Designer.
2009-11-22 16:40:18 +01:00
Jim Meyering
ad1f07b3c4 maint: cfg.mk: remove factored-out ftp host/dir definitions
* cfg.mk (gnu_ftp_host-alpha, gnu_ftp_host-beta gnu_ftp_host-stable):
(gnu_rel_host, url_dir_list): Remove definitions.  The defaults,
now provided by maint.mk, are the same.
* gnulib: Update for latest, including those maint.mk additions.
2009-11-20 16:39:24 +01:00
Jim Meyering
ddea7b1078 maint: correct comments in test scripts
* tests/misc/pwd-long: Fix spelling of cygwin1.dll in comment.
* tests/rm/fail-eperm: Likewise.
Reported by Eric Blake.
2009-11-20 12:58:51 +01:00
Jim Meyering
5eb8d60e6d maint: don't list "warnings" module explicitly
* bootstrap.conf (gnulib_modules): Remove "warnings", now that
it's pulled in automatically via "manywarnings".
2009-11-20 08:17:24 +01:00
Jim Meyering
395b1c9375 maint: move xfreopen module to gnulib
* gl/lib/xfreopen.c: Remove file.
* gl/lib/xfreopen.h: Likewise.
* gl/modules/xfreopen: Likewise.
2009-11-20 07:37:56 +01:00
Jim Meyering
2f2112335c build: update gnulib submodule to latest 2009-11-20 07:37:56 +01:00
Jim Meyering
30eb606ed5 tests: avoid spurious failures due to insecure directory in PATH
These tests perform no PATH search, and used to simply delete PATH from
the environment.  However, that is not portable, as seen on Cygwin,
where cygwin.dll must be resolvable via PATH when starting a sub-shell.
With commit 0cc04241, we took the alternate approach of untainting the
incoming $ENV{PATH}, but that fails when it contains an other-writable
directory.  Instead, now we hard code it to '/bin:/usr/bin'.

* tests/misc/pwd-long: Hard code $ENV{PATH} to a safe value.
* tests/rm/fail-eperm: Likewise.
Reported by Gilles Espinasse, Andreas Schwab, and Bauke Jan Douma.
2009-11-19 11:12:29 +01:00
Jim Meyering
f18eef3284 build: "make stable" emitted an invalid gnupload command
* cfg.mk (gnu_ftp_host-stable): Rename from gnu_ftp_host-major.
* README-release: Change another s/major/stable/.
2009-11-18 21:04:52 +01:00
Jim Meyering
e246d654f3 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2009-11-18 19:56:25 +01:00
37 changed files with 242 additions and 184 deletions

View File

@@ -1 +1 @@
8.0
8.1

35
NEWS
View File

@@ -1,5 +1,40 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.2 (2009-12-11) [stable]
** Bug fixes
id's use of mgetgroups no longer writes beyond the end of a malloc'd buffer
[bug introduced in coreutils-8.1]
id no longer crashes on systems without supplementary group support.
[bug introduced in coreutils-8.1]
rm once again handles zero-length arguments properly.
The rewrite to make rm use fts introduced a regression whereby
a command like "rm a '' b" would fail to remove "a" and "b", due to
the presence of the empty string argument.
[bug introduced in coreutils-8.0]
sort is now immune to the signal handling of its parent.
Specifically sort now doesn't exit with an error message
if it uses helper processes for compression and its parent
ignores CHLD signals. [bug introduced in coreutils-6.9]
tail without -f no longer access uninitialized memory
[bug introduced in coreutils-7.6]
timeout is now immune to the signal handling of its parent.
Specifically timeout now doesn't exit with an error message
if its parent ignores CHLD signals. [bug introduced in coreutils-7.6]
a user running "make distcheck" in the coreutils source directory,
with TMPDIR unset or set to the name of a world-writable directory,
and with a malicious user on the same system
was vulnerable to arbitrary code execution
[bug introduced in coreutils-5.0]
* Noteworthy changes in release 8.1 (2009-11-18) [stable]
** Bug fixes

View File

@@ -50,7 +50,7 @@ FIXME: enable excluded programs like arch? to get their manual pages?
Once all the builds and tests have passed,
* Run the gnupload command that was suggested by your "make major" run above.
* Run the gnupload command that was suggested by your "make stable" run above.
* Wait a few minutes (maybe up to 30?) and then use the release URLs to
download all tarball/signature pairs and use gpg --verify to ensure

2
THANKS
View File

@@ -334,6 +334,7 @@ Kirk Kelsey kirk.kelsey@0x4b.net
Kristin E Thomas kristint@us.ibm.com
Kjetil Torgrim Homme kjetilho@ifi.uio.no
Kristoffer Rose kris@diku.dk
Ladislav Hagara ladislav.hagara@unob.cz
Larry McVoy lm@sgi.com
Lars Hecking lhecking@nmrc.ucc.ie
Leah Q eequor@earthlink.net
@@ -528,6 +529,7 @@ Samuli Karkkainen Samuli.Karkkainen@hut.fi
Sander van Malssen svm@kozmix.ow.nl
Santiago Vila Doncel sanvila@unex.es
Savochkin Andrey Vladimirovich saw@msu.ru
Scott Harrison scott.gnu.2009@scottrix.co.uk
Scott Lurndal slurn@griffin.engr.sgi.com
Sébastien Maret smaret@umich.edu
Sergei Steshenko sergstesh@yahoo.com

View File

@@ -314,10 +314,20 @@ get_version() {
$app --version >/dev/null 2>&1 || return 1
$app --version 2>&1 |
sed -n 's/[^0-9.]*\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/p
sed -n '# extract version within line
s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
t done
# extract version at start of line
s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
t done
d
:done
#the following essentially does s/5.005/5.5/
s/\.0*\([1-9]\)/.\1/g
p
q'
}

View File

@@ -232,7 +232,6 @@ gnulib_modules="
verify
verror
version-etc-fsf
warnings
wcwidth
winsz-ioctl
winsz-termios

18
cfg.mk
View File

@@ -14,19 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Use alpha.gnu.org for alpha and beta releases.
# Use ftp.gnu.org for major releases.
gnu_ftp_host-alpha = alpha.gnu.org
gnu_ftp_host-beta = alpha.gnu.org
gnu_ftp_host-major = ftp.gnu.org
gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
# Used in maint.mk's web-manual rule
manual_title = Core GNU utilities
url_dir_list = \
ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
# The GnuPG ID of the key used to sign the tarballs.
gpg_key_ID = B9AB9A16
@@ -39,7 +29,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = 785e51bc9af87e7eb004f9ba24a0ca27
old_NEWS_hash = 2a36ca50a949f959645d9bfac8ec83ce
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
@@ -249,4 +239,10 @@ sc_require_stdio_safer:
else :; \
fi
# Prefer xnanosleep over other less-precise sleep methods
sc_prohibit_sleep:
@re='\<(nano|u)?sleep \(' \
msg='prefer xnanosleep over other sleep interfaces' \
$(_prohibit_regexp)
include $(srcdir)/dist-check.mk

View File

@@ -4,14 +4,15 @@ bin=bin-$$$$
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
TMPDIR ?= /tmp
t=$(TMPDIR)/$(PACKAGE)/test
tmpdir = $(abs_top_builddir)/tests/torture
t=$(tmpdir)/$(PACKAGE)/test
pfx=$(t)/i
# More than once, tainted build and source directory names would
# have caused at least one "make check" test to apply "chmod 700"
# to all directories under $HOME. Make sure it doesn't happen again.
tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
tp = $(tmpdir)/taint
t_prefix = $(tp)/a
t_taint = '$(t_prefix) b'
fake_home = $(tp)/home
@@ -30,10 +31,11 @@ taint-distcheck: $(DIST_ARCHIVES)
touch $(fake_home)/f
mkdir -p $(fake_home)/d/e
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
HOME=$(fake_home); export HOME; \
cd $(t_taint)/$(distdir) \
&& ./configure \
&& $(MAKE) \
&& HOME=$(fake_home) $(MAKE) check \
&& $(MAKE) check \
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
&& diff $(tp)/.ls-before $(tp)/.ls-after \
&& test -d $(t_prefix)
@@ -52,6 +54,7 @@ endef
# Install, then verify that all binaries and man pages are in place.
# Note that neither the binary, ginstall, nor the ].1 man page is installed.
define my-instcheck
echo running my-instcheck; \
$(MAKE) prefix=$(pfx) install \
&& test ! -f $(pfx)/bin/ginstall \
&& { fail=0; \
@@ -70,6 +73,7 @@ endef
define coreutils-path-check
{ \
echo running coreutils-path-check; \
if test -f $(srcdir)/src/true.c; then \
fail=1; \
mkdir $(bin) \
@@ -117,7 +121,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
mkdir -p $(t)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
cd $(t)/$(distdir) \
&& ./configure --enable-gcc-warnings --disable-nls \
&& ./configure --quiet --enable-gcc-warnings --disable-nls \
&& $(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
&& $(MAKE) dvi \
&& $(install-transform-check) \
@@ -128,6 +132,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-check)
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
-rm -rf $(t)
rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"

View File

@@ -1,42 +0,0 @@
/* a wrapper for frepoen
Copyright (C) 2008-2009 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include "xfreopen.h"
#include <errno.h>
#include "error.h"
#include "exitfail.h"
#include "quote.h"
#include "stdio--.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
void
xfreopen (char const *filename, char const *mode, FILE *fp)
{
if (!freopen (filename, mode, fp))
{
char const *f = (filename ? filename
: (fp == stdin ? _("stdin")
: (fp == stdout ? _("stdout")
: (fp == stderr ? _("stderr")
: _("unknown stream")))));
error (exit_failure, errno, _("failed to reopen %s with mode %s"),
quote_n (0, f), quote_n (1, mode));
}
}

View File

@@ -1,2 +0,0 @@
#include <stdio.h>
void xfreopen (char const *filename, char const *mode, FILE *fp);

View File

@@ -0,0 +1,9 @@
diff --git i/modules/link-tests w/modules/link-tests
index d8e7b1a..aca0e74 100644
--- i/modules/link-tests
+++ w/modules/link-tests
@@ -12,3 +12,4 @@ configure.ac:
Makefile.am:
TESTS += test-link
check_PROGRAMS += test-link
+test_link_LDADD = $(LDADD) @LIBINTL@

View File

@@ -1,26 +0,0 @@
Description:
a wrapper for frepoen
Files:
lib/xfreopen.c
lib/xfreopen.h
Depends-on:
error
exitfail
freopen-safer
quote
configure.ac:
Makefile.am:
lib_SOURCES += xfreopen.c xfreopen.h
Include:
"xfreopen.h"
License:
LGPL
Maintainer:
Jim Meyering

2
gnulib

Submodule gnulib updated: 0883405cc7...63983c0aac

View File

@@ -21,13 +21,9 @@
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include "error.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "quote.h"
#include "xalloc.h"
#include "xfts.h"
@@ -40,23 +36,10 @@ xfts_open (char * const *argv, int options,
FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
if (fts == NULL)
{
/* This can fail in three ways: out of memory, invalid bit_flags,
and one or more of the FILES is an empty string. We could try
to decipher that errno==EINVAL means invalid bit_flags and
errno==ENOENT means there's an empty string, but that seems wrong.
Ideally, fts_open would return a proper error indicator. For now,
we'll presume that the bit_flags are valid and just check for
empty strings. */
bool invalid_arg = false;
for (; *argv; ++argv)
{
if (**argv == '\0')
invalid_arg = true;
}
if (invalid_arg)
error (EXIT_FAILURE, 0, _("invalid argument: %s"), quote (""));
else
xalloc_die ();
/* This can fail in two ways: out of memory or with errno==EINVAL,
which indicates it was called with invalid bit_flags. */
assert (errno != EINVAL);
xalloc_die ();
}
return fts;

View File

@@ -28,7 +28,6 @@ lib/verror.c
lib/version-etc.c
lib/xalloc-die.c
lib/xfreopen.c
lib/xfts.c
lib/xmemcoll.c
lib/xmemxfrm.c
lib/xprintf.c

View File

@@ -349,6 +349,7 @@ uptime_LDADD += $(POW_LIB)
# for xnanosleep
sleep_LDADD += $(LIB_NANOSLEEP)
sort_LDADD += $(LIB_NANOSLEEP)
tail_LDADD += $(LIB_NANOSLEEP)
# for various GMP functions

View File

@@ -14,18 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*
| user
| unchanged explicit
-------------|-------------------------+-------------------------|
g unchanged | --- | chown u |
r |-------------------------+-------------------------|
o explicit | chgrp g or chown .g | chown u.g |
u |-------------------------+-------------------------|
p from passwd| --- | chown u. |
|-------------------------+-------------------------|
Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#include <config.h>
#include <stdio.h>

View File

@@ -58,9 +58,9 @@ print_group_list (const char *username,
gid_t *groups;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
if (n_groups < 0 && errno != ENOSYS)
if (n_groups < 0)
{
if (username)
{

View File

@@ -296,9 +296,9 @@ print_full_info (const char *username)
gid_t *groups;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
if (n_groups < 0 && errno != ENOSYS)
if (n_groups < 0)
{
if (username)
{

View File

@@ -179,7 +179,7 @@ main (int argc, char **argv)
#if HAVE_SETGROUPS
if (n_gids == 0)
{
int n = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
int n = xgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
if (n <= 0)
error (EXIT_FAILURE, errno, _("failed to get groups for user %s"),
quote (pwd->pw_name));

View File

@@ -44,6 +44,7 @@
#include "strnumcmp.h"
#include "xmemcoll.h"
#include "xmemxfrm.h"
#include "xnanosleep.h"
#include "xstrtol.h"
#if HAVE_SYS_RESOURCE_H
@@ -107,13 +108,13 @@ enum
/* The number of times we should try to fork a compression process
(we retry if the fork call fails). We don't _need_ to compress
temp files, this is just to reduce disk access, so this number
can be small. */
MAX_FORK_TRIES_COMPRESS = 2,
can be small. Each retry doubles in duration. */
MAX_FORK_TRIES_COMPRESS = 4,
/* The number of times we should try to fork a decompression process.
If we can't fork a decompression process, we can't sort, so this
number should be big. */
MAX_FORK_TRIES_DECOMPRESS = 8
number should be big. Each retry doubles in duration. */
MAX_FORK_TRIES_DECOMPRESS = 9
};
/* The representation of the decimal point in the current locale. */
@@ -868,7 +869,7 @@ pipe_fork (int pipefds[2], size_t tries)
#if HAVE_WORKING_FORK
struct tempnode *saved_temphead;
int saved_errno;
unsigned int wait_retry = 1;
double wait_retry = 0.25;
pid_t pid IF_LINT (= -1);
struct cs_status cs;
@@ -895,7 +896,7 @@ pipe_fork (int pipefds[2], size_t tries)
break;
else
{
sleep (wait_retry);
xnanosleep (wait_retry);
wait_retry *= 2;
reap_some ();
}
@@ -3253,6 +3254,7 @@ main (int argc, char **argv)
}
#endif
}
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
/* The signal mask is known, so it is safe to invoke exit_cleanup. */
atexit (exit_cleanup);

View File

@@ -1619,7 +1619,7 @@ tail_file (struct File_spec *f, uintmax_t n_units)
/* Before the tail function provided `read_pos', there was
a race condition described in the URL below. This sleep
call made the window big enough to exercise the problem. */
sleep (1);
xnanosleep (1);
#endif
f->errnum = ok - 1;
if (fstat (fd, &stats) < 0)
@@ -1889,6 +1889,35 @@ parse_options (int argc, char **argv,
}
}
/* Mark as '.ignore'd each member of F that corresponds to a
pipe or fifo, and return the number of non-ignored members. */
static size_t
ignore_fifo_and_pipe (struct File_spec *f, size_t n_files)
{
/* When there is no FILE operand and stdin is a pipe or FIFO
POSIX requires that tail ignore the -f option.
Since we allow multiple FILE operands, we extend that to say: with -f,
ignore any "-" operand that corresponds to a pipe or FIFO. */
size_t n_viable = 0;
size_t i;
for (i = 0; i < n_files; i++)
{
bool is_a_fifo_or_pipe =
(STREQ (f[i].name, "-")
&& !f[i].ignore
&& 0 <= f[i].fd
&& (S_ISFIFO (f[i].mode)
|| (HAVE_FIFO_PIPES != 1 && isapipe (f[i].fd))));
if (is_a_fifo_or_pipe)
f[i].ignore = true;
else
++n_viable;
}
return n_viable;
}
int
main (int argc, char **argv)
{
@@ -1980,26 +2009,7 @@ main (int argc, char **argv)
for (i = 0; i < n_files; i++)
ok &= tail_file (&F[i], n_units);
/* When there is no FILE operand and stdin is a pipe or FIFO
POSIX requires that tail ignore the -f option.
Since we allow multiple FILE operands, we extend that to say:
ignore any "-" operand that corresponds to a pipe or FIFO. */
size_t n_viable = 0;
for (i = 0; i < n_files; i++)
{
bool is_a_fifo_or_pipe =
(STREQ (F[i].name, "-")
&& !F[i].ignore
&& 0 <= F[i].fd
&& (S_ISFIFO (F[i].mode)
|| (HAVE_FIFO_PIPES != 1 && isapipe (F[i].fd))));
if (is_a_fifo_or_pipe)
F[i].ignore = true;
else
++n_viable;
}
if (forever && n_viable)
if (forever && ignore_fifo_and_pipe (F, n_files))
{
#if HAVE_INOTIFY
/* If the user specifies stdin via a command line argument of "-",

View File

@@ -275,6 +275,7 @@ main (int argc, char **argv)
install_signal_handlers (term_signal);
signal (SIGTTIN, SIG_IGN); /* don't sTop if background child needs tty. */
signal (SIGTTOU, SIG_IGN); /* don't sTop if background child needs tty. */
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
monitored_pid = fork ();
if (monitored_pid == -1)

View File

@@ -80,7 +80,7 @@ TESTS_ENVIRONMENT = \
srcdir='$(srcdir)' \
top_srcdir='$(top_srcdir)' \
CONFIG_HEADER='$(abs_top_builddir)/lib/config.h' \
CU_TEST_NAME=`basename '$(abs_srcdir)'`,$$tst \
CU_TEST_NAME=`basename '$(abs_srcdir)'`,`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
CC='$(CC)' \
AWK='$(AWK)' \
EGREP='$(EGREP)' \

View File

@@ -19,6 +19,9 @@
. $srcdir/test-lib.sh
require_root_
# Some of the tests expect a umask that grants group and/or world read access.
working_umask_or_skip_
# Record primary group number, usually 0.
# This is the group ID used when cp (without -p) creates a new file.
primary_group_num=$(id -g)

View File

@@ -65,6 +65,8 @@ inode_via_readdir()
for dir in $mount_points; do
readdir_inode=$(inode_via_readdir $dir)
stat_inode=$(env stat --format=%i $dir)
# If stat fails or says the inode is 0, skip $dir.
case $stat_inode in 0|'') continue;; esac
test "$readdir_inode" = "$stat_inode" || fail=1
done

View File

@@ -25,10 +25,11 @@ fi
# Without arguments, printenv behaves like env. Some shells provide
# printenv as a builtin, so we must test via absolute name.
# printenv as a builtin, so we must invoke it via "env".
# But beware of $_, set by many shells to the last command run.
env | grep -v '^_' > exp || framework_failure
env -- printenv | grep -v '^_' > out || fail=1
# Also, filter out LD_PRELOAD, which is set when running under valgrind.
env | grep -Ev '^(_|LD_LIBRARY=)' > exp || framework_failure
env -- printenv | grep -Ev '^(_|LD_LIBRARY=)' > out || fail=1
compare exp out || fail=1
# POSIX is clear that environ may, but need not be, sorted.

View File

@@ -56,11 +56,11 @@ sub normalize_to_cwd_relative ($$$)
# Set up a safe, well-known environment
delete @ENV{qw(BASH_ENV CDPATH ENV)};
$ENV{IFS} = '';
# PATH is tricky - we can't just clear it, or cygwin will fail. But we
# can't use it as-is, or taint checking in `` will stop us. For this
# script, it is enough to scrub the incoming $PATH first.
$ENV{'PATH'} =~ /(.*)/;
$ENV{'PATH'} = "$1";
# Taint checking requires a sanitized $PATH. This script performs no $PATH
# search, so on most Unix-based systems, it is fine simply to clear $ENV{PATH}.
# However, on Cygwin, it's used to find cygwin1.dll, so set it.
$ENV{PATH} = '/bin:/usr/bin';
# Save CWD's device and inode numbers.
my ($dev, $ino) = (stat '.')[0, 1];

View File

@@ -30,7 +30,6 @@ SORT="$abs_top_builddir/src/sort"
# Ensure that $TMPDIR is valid.
TMPDIR=.; export TMPDIR
# This should force the use of temp files
sort -S 1k in > out || fail=1
compare exp out || fail=1
@@ -44,6 +43,16 @@ EOF
chmod +x gzip
# Ensure `sort` is immune to parent's SIGCHLD handler
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
(
# ash doesn't support "trap '' CHLD"; it knows only signal numbers.
sig=`"$abs_top_builddir/src/kill" -l CHLD 2>/dev/null` && trap '' $sig
# This should force the use of child processes for "compression"
PATH=.:$PATH exec sort -S 1k --compress-program=gzip in > /dev/null
) || fail=1
# This will find our new gzip in PATH
PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1
compare exp out || fail=1

View File

@@ -63,8 +63,10 @@ options=`stty -a | tr -s ';' '\n' | sed "s/^ //;$sed_del;s/-//g"`
for opt in $options; do
# `stty parenb' and `stty -parenb' fail with this message
# stty: standard input: unable to perform all requested operations
# on Linux 2.2.0-pre4 kernels, so skip those tests.
test $opt = parenb && continue
# on Linux 2.2.0-pre4 kernels. Also since around Linux 2.6.30
# other serial control settings give the same error. So skip them.
case $opt in parenb|parodd|cstopb|crtscts) continue;; esac
stty $opt || fail=1
# Likewise, `stty -cread' would fail, so skip that, too.

View File

@@ -60,6 +60,15 @@ set $tests
saved_size=`stty size` && test -n "$saved_size" \
|| skip_test_ "can't get window size"
# Linux virtual consoles issue an error if you
# try to increase their size. So skip in that case.
if test "x$saved_size" != "x0 0"; then
srow=$(echo $saved_size | cut -d ' ' -f1)
scol=$(echo $saved_size | cut -d ' ' -f2)
stty rows $(expr $srow + 1) cols $(expr $scol + 1) ||
skip_test_ "can't increase window size"
fi
while :; do
test_name=$1
args=$2

View File

@@ -23,7 +23,6 @@ fi
. $srcdir/test-lib.sh
# no timeout
timeout 1 true || fail=1
@@ -42,4 +41,13 @@ test $? = 2 || fail=1
timeout 1 sleep 2
test $? = 124 || fail=1
# Ensure `timeout` is immune to parent's SIGCHLD handler
# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
(
# ash doesn't support "trap '' CHLD"; it knows only signal numbers.
sig=`"$abs_top_builddir/src/kill" -l CHLD 2>/dev/null` && trap '' $sig
exec timeout 1 true
) || fail=1
Exit $fail

View File

@@ -29,12 +29,28 @@ use strict;
my $prog = 'rm';
# FIXME: copied from misc/ls-misc; factor into Coreutils.pm?
sub mk_file(@)
{
foreach my $f (@_)
{
open (F, '>', $f) && close F
or die "creating $f: $!\n";
}
}
my @Tests =
(
# test-name options input expected-output
#
['empty-name-1', "''", {EXIT => 1},
{ERR => "$prog: invalid argument: `'\n"}],
{ERR => "$prog: cannot remove `': No such file or directory\n"}],
['empty-name-2', "a '' b", {EXIT => 1},
{ERR => "$prog: cannot remove `': No such file or directory\n"},
{PRE => sub { mk_file qw(a b) }},
{POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }},
],
);
my $save_temps = $ENV{SAVE_TEMPS};

View File

@@ -34,11 +34,11 @@ $ENV{LC_ALL} = 'C';
# Set up a safe, well-known environment
delete @ENV{qw(BASH_ENV CDPATH ENV)};
$ENV{IFS} = '';
# PATH is tricky - we can't just clear it, or cygwin will fail. But we
# can't use it as-is, or taint checking in `` will stop us. For this
# script, it is enough to scrub the incoming $PATH first.
$ENV{'PATH'} =~ /(.*)/;
$ENV{'PATH'} = "$1";
# Taint checking requires a sanitized $PATH. This script performs no $PATH
# search, so on most Unix-based systems, it is fine simply to clear $ENV{PATH}.
# However, on Cygwin, it's used to find cygwin1.dll, so set it.
$ENV{PATH} = '/bin:/usr/bin';
my @dir_list = qw(/tmp /var/tmp /usr/tmp);
my $rm = "$ENV{abs_top_builddir}/src/rm";

View File

@@ -27,6 +27,10 @@ fi
. $srcdir/test-lib.sh
# Don't run this test by default because sometimes it's skipped as noted below.
# Also gdb has a bug in Debian's gdb-6.8-3 at least that causes it to not
# cleanup and exit correctly when it receives a SIGTERM, thus hanging the test.
very_expensive_
touch file || framework_failure
touch tail.out || framework_failure
@@ -37,14 +41,18 @@ case $(cat gdb.out) in
*) skip_test_ "can't run gdb";;
esac
# See if gdb works:
timeout 10s gdb -nx --batch-silent \
# See if gdb works and
# tail_forever_inotify is compiled and not inlined
timeout 10s gdb -nx --batch-silent \
--eval-command='break tail_forever_inotify' \
--eval-command='run -f file' \
--eval-command='quit' \
tail < /dev/null > gdb.out 2>&1
test -s gdb.out && skip_test_ "can't set breakpoints in tail"
# FIXME: The above is seen to _intermittently_ fail with:
# warning: .dynamic section for "/lib/libc.so.6" is not at the expected address
# warning: difference appears to be caused by prelink, adjusting expectations
test -s gdb.out && { cat gdb.out; skip_test_ "can't set breakpoints in tail"; }
# Run "tail -f file", stopping to append a line just before
# inotify initialization, and then continue. Before the fix,
@@ -55,7 +63,7 @@ timeout 10s gdb -nx --batch-silent \
--eval-command="shell echo never-seen-with-tail-7.5 >> file" \
--eval-command='continue' \
--eval-command='quit' \
tail < /dev/null &
tail < /dev/null > /dev/null 2>&1 &
pid=$!
tail --pid=$pid -f tail.out | (read; kill $pid)

View File

@@ -23,6 +23,31 @@ if test $? != 11; then
Exit 77
fi
# Having an unsearchable directory in PATH causes execve to fail with EACCES
# when applied to an unresolvable program name, contrary to the desired ENOENT.
# Avoid the problem by rewriting PATH to exclude unsearchable directories.
sanitize_path_()
{
local saved_IFS=$IFS
IFS=:
set -- $PATH
IFS=$saved_IFS
local d d1
local colon=
local new_path=
for d in "$@"; do
test -z "$d" && d1=. || d1=$d
if ls -d "$d1/." > /dev/null 2>&1; then
new_path="$new_path$colon$d"
colon=':'
fi
done
PATH=$new_path
export PATH
}
skip_test_()
{
echo "$0: skipping test: $@" | head -1 1>&9
@@ -54,7 +79,6 @@ require_selinux_enforcing_()
|| skip_test_ "This test is useful only with SELinux in Enforcing mode."
}
require_openat_support_()
{
# Skip this test if your system has neither the openat-style functions
@@ -396,5 +420,7 @@ else
compare() { cmp "$@"; }
fi
sanitize_path_
# Initialize; all bourne shell scripts end with "Exit $fail".
fail=0

View File

@@ -42,7 +42,10 @@ touch / > out 2>&1 && fail=1
# On SunOS4, EPERM is `Not owner'.
# On some *BSD systems it's `Operation not permitted'.
for msg in 'Not owner' 'Operation not permitted' 'Permission denied'; do
# On a system where root file system is mounted read-only
# it's `Read-only file system'.
for msg in 'Not owner' 'Operation not permitted' 'Permission denied' \
'Read-only file system'; do
cat > exp <<EOF
touch: setting times of \`/': $msg
EOF