mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70d023b076 | ||
|
|
ca39c9c308 | ||
|
|
fc4d3f63b0 | ||
|
|
3df2108b0d | ||
|
|
829c418d67 | ||
|
|
06e9880c8e | ||
|
|
bb4cb10e89 | ||
|
|
23c0cecaa8 | ||
|
|
19b460b239 | ||
|
|
0f8bb24ca8 | ||
|
|
321d2901de | ||
|
|
f5a97b8269 | ||
|
|
73d4626134 | ||
|
|
7ac41f9950 | ||
|
|
dcff25a925 | ||
|
|
7a2b0b8f66 | ||
|
|
ae034822c5 | ||
|
|
d8cadda3b9 | ||
|
|
afd087d414 | ||
|
|
9b4b38f56e | ||
|
|
5224fbd6f9 | ||
|
|
d16a8f6c7f | ||
|
|
0dc1f4c6f3 | ||
|
|
cb775df09e | ||
|
|
b92e0455e1 | ||
|
|
3910144405 | ||
|
|
4bb812ad49 | ||
|
|
b498c58013 | ||
|
|
f9d0bb8481 | ||
|
|
ab6b27eba7 | ||
|
|
9cf9f8e1e0 | ||
|
|
ad1f07b3c4 | ||
|
|
ddea7b1078 | ||
|
|
5eb8d60e6d | ||
|
|
395b1c9375 | ||
|
|
2f2112335c | ||
|
|
30eb606ed5 | ||
|
|
f18eef3284 | ||
|
|
e246d654f3 |
@@ -1 +1 @@
|
||||
8.0
|
||||
8.1
|
||||
|
||||
35
NEWS
35
NEWS
@@ -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
|
||||
|
||||
@@ -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
2
THANKS
@@ -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
|
||||
|
||||
12
bootstrap
12
bootstrap
@@ -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'
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,6 @@ gnulib_modules="
|
||||
verify
|
||||
verror
|
||||
version-etc-fsf
|
||||
warnings
|
||||
wcwidth
|
||||
winsz-ioctl
|
||||
winsz-termios
|
||||
|
||||
18
cfg.mk
18
cfg.mk
@@ -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
|
||||
|
||||
@@ -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 "========================"
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
#include <stdio.h>
|
||||
void xfreopen (char const *filename, char const *mode, FILE *fp);
|
||||
9
gl/modules/link-tests.diff
Normal file
9
gl/modules/link-tests.diff
Normal 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@
|
||||
@@ -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
2
gnulib
Submodule gnulib updated: 0883405cc7...63983c0aac
29
lib/xfts.c
29
lib/xfts.c
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
13
src/chown.c
13
src/chown.c
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
4
src/id.c
4
src/id.c
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
|
||||
14
src/sort.c
14
src/sort.c
@@ -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);
|
||||
|
||||
52
src/tail.c
52
src/tail.c
@@ -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 "-",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)' \
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user