Compare commits

...

12 Commits
rawhide ... f12

Author SHA1 Message Date
Fedora Release Engineering 71510bd605 dist-git conversion 2010-07-28 12:11:17 +00:00
Ondrej Vasik f28f512e31 cumulative update with various fixes 2010-04-28 15:48:52 +00:00
Dennis Gilmore 12226c563d add patch for mkstemp on sparc64 2010-03-03 19:13:44 +00:00
Ondrej Vasik e496961922 defuzz 2010-01-12 14:30:31 +00:00
Ondrej Vasik 2799d996f6 regexp fixes not required 2010-01-12 14:18:57 +00:00
Ondrej Vasik c46649f534 Rebase tail.c to coreutils-8.3 version, many tail (especially -F) fixes,
too complex to backport easily
2010-01-12 14:05:50 +00:00
Ondrej Vasik 75b71596fc require gmp-devel/gmp for large numbers support(#552846), use grep instead
of deprecated egrep in colorls.sh script(#548174), fix
    DIR_COLORS.256color file
2010-01-12 12:49:18 +00:00
Ondrej Vasik 851fdcd87c CVE-2009-4135 : Unsafe temporary directory use in distcheck rule 2009-12-11 18:38:30 +00:00
Bill Nottingham 84ce36b59c Fix typo that causes a failure to update the common directory. (releng
#2781)
2009-11-26 01:33:09 +00:00
Ondrej Vasik 769f191019 Release++ to prevent conflict with accident devel-branch tag 2009-11-23 09:56:03 +00:00
Ondrej Vasik 8724b4e49e Various fixes from rawhide 2009-11-23 09:53:12 +00:00
Jesse Keating c7a8b3346b Initialize branch F-12 for coreutils 2009-09-29 04:40:27 +00:00
18 changed files with 1237 additions and 155 deletions

View File

View File

@ -1,21 +0,0 @@
# Makefile for source rpm: coreutils
# $Id$
NAME := coreutils
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attempt a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View File

@ -0,0 +1,24 @@
diff -urNp coreutils-7.6-orig/lib/fts.c coreutils-7.6/lib/fts.c
--- coreutils-7.6-orig/lib/fts.c 2009-09-10 19:33:40.000000000 +0200
+++ coreutils-7.6/lib/fts.c 2009-11-18 14:34:17.000000000 +0100
@@ -1276,6 +1276,20 @@ fts_build (register FTS *sp, int type)
opening it. */
if (cur->fts_info == FTS_NSOK)
cur->fts_info = fts_stat(sp, cur, false);
+ else if (sp->fts_options & FTS_TIGHT_CYCLE_CHECK) {
+ /* Now read the stat info again after opening a directory to
+ * reveal eventual changes caused by a submount triggered by
+ * the traversal. But do it only for utilities which use
+ * FTS_TIGHT_CYCLE_CHECK. Therefore, only find and du
+ * benefit/suffer from this feature for now.
+ */
+ LEAVE_DIR (sp, cur, "4");
+ fts_stat (sp, cur, false);
+ if (! enter_dir (sp, cur)) {
+ __set_errno (ENOMEM);
+ return NULL;
+ }
+ }
/*
* Nlinks is the number of possible entries of type directory in the

View File

@ -0,0 +1,65 @@
diff -urNp coreutils-7.6-orig/src/ls.c coreutils-7.6/src/ls.c
--- coreutils-7.6-orig/src/ls.c 2009-11-23 10:31:08.000000000 +0100
+++ coreutils-7.6/src/ls.c 2009-11-23 10:35:47.000000000 +0100
@@ -3592,6 +3592,18 @@ format_group_width (gid_t g)
}
+/* Return a pointer to a formatted version of F->stat.st_ino,
+ possibly using buffer, BUF, of length BUFLEN, which must be at least
+ INT_BUFSIZE_BOUND (uintmax_t) bytes. */
+static char *
+format_inode (char *buf, size_t buflen, const struct fileinfo *f)
+{
+ assert (INT_BUFSIZE_BOUND (uintmax_t) <= buflen);
+ return (f->stat.st_ino == NOT_AN_INODE_NUMBER
+ ? (char *) "?"
+ : umaxtostr (f->stat.st_ino, buf));
+}
+
/* Print info about f in scontext format */
static void
print_scontext_format (const struct fileinfo *f)
@@ -3713,9 +3725,7 @@ print_long_format (const struct fileinfo
{
char hbuf[INT_BUFSIZE_BOUND (uintmax_t)];
sprintf (p, "%*s ", inode_number_width,
- (f->stat.st_ino == NOT_AN_INODE_NUMBER
- ? "?"
- : umaxtostr (f->stat.st_ino, hbuf)));
+ format_inode (hbuf, sizeof hbuf, f));
/* Increment by strlen (p) here, rather than by inode_number_width + 1.
The latter is wrong when inode_number_width is zero. */
p += strlen (p);
@@ -4105,7 +4115,7 @@ print_file_name_and_frills (const struct
if (print_inode)
printf ("%*s ", format == with_commas ? 0 : inode_number_width,
- umaxtostr (f->stat.st_ino, buf));
+ format_inode (buf, sizeof buf, f));
if (print_block_size)
printf ("%*s ", format == with_commas ? 0 : block_size_width,
diff -urNp coreutils-7.6-orig/tests/ls/dangle coreutils-7.6/tests/ls/dangle
--- coreutils-7.6-orig/tests/ls/dangle 2009-09-01 13:01:16.000000000 +0200
+++ coreutils-7.6/tests/ls/dangle 2009-11-23 10:37:44.000000000 +0100
@@ -26,6 +26,9 @@ fi
ln -s no-such-file dangle || framework_failure
mkdir -p dir/sub || framework_failure
ln -s dir slink-to-dir || framework_failure
+mkdir d || framework_failure
+ln -s no-such d/dangle || framework_failure
+echo '? dangle' > subdir_exp || framework_failure
fail=0
@@ -50,4 +53,9 @@ EOF
compare out exp || fail=1
+# Ensure that ls -Li prints "?" as the inode of a dangling symlink.
+rm -f out
+ls -Li d > out 2>/dev/null && fail=1
+compare out subdir_exp || fail=1
+
Exit $fail

View File

@ -0,0 +1,71 @@
diff -urNp coreutils-7.6-orig/doc/coreutils.texi coreutils-7.6/doc/coreutils.texi
--- coreutils-7.6-orig/doc/coreutils.texi 2009-11-23 10:21:55.000000000 +0100
+++ coreutils-7.6/doc/coreutils.texi 2009-11-23 10:24:03.000000000 +0100
@@ -6113,8 +6113,9 @@ Exit status:
1 minor problems (e.g., failure to access a file or directory not
specified as a command line argument. This happens when listing a
directory in which entries are actively being removed or renamed.)
-2 serious trouble (e.g., memory exhausted, invalid option or failure
- to access file or directory specified as a command line argument)
+2 serious trouble (e.g., memory exhausted, invalid option, failure
+ to access a file or directory specified as a command line argument
+ or a directory loop)
@end display
Also see @ref{Common options}.
diff -urNp coreutils-7.6-orig/src/ls.c coreutils-7.6/src/ls.c
--- coreutils-7.6-orig/src/ls.c 2009-11-23 10:21:55.000000000 +0100
+++ coreutils-7.6/src/ls.c 2009-11-23 10:24:40.000000000 +0100
@@ -2494,6 +2494,7 @@ print_dir (char const *name, char const
error (0, 0, _("%s: not listing already-listed directory"),
quotearg_colon (name));
closedir (dirp);
+ set_exit_status (true);
return;
}
diff -urNp coreutils-7.6-orig/tests/ls/infloop coreutils-7.6/tests/ls/infloop
--- coreutils-7.6-orig/tests/ls/infloop 2009-09-01 13:01:16.000000000 +0200
+++ coreutils-7.6/tests/ls/infloop 2009-11-23 10:28:45.000000000 +0100
@@ -2,6 +2,7 @@
# show that the following no longer makes ls infloop
# mkdir loop; cd loop; ln -s ../loop sub; ls -RL
+# Also ensure ls exits with status = 2 in that case.
# Copyright (C) 2001-2002, 2004, 2006-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -27,21 +28,22 @@ fi
mkdir loop || framework_failure
ln -s ../loop loop/sub || framework_failure
-fail=0
-
-ls -RL loop 2>err | head -n 7 > out
-# With an inf-looping ls, out will contain these 7 lines:
-cat <<EOF > bad
+cat <<\EOF > exp-out || framework_failure
loop:
sub
+EOF
-loop/sub:
-sub
-
-loop/sub/sub:
+cat <<\EOF > exp-err || framework_failure
+ls: loop/sub: not listing already-listed directory
EOF
-# Make sure we don't get the "bad" output.
-compare out bad > /dev/null 2>&1 && fail=1
+fail=0
+
+timeout 1 ls -RL loop 2>err > out
+# Ensure that ls exits with status 2 upon detecting a cycle
+test $? = 2 || fail=1
+
+compare err exp-err || fail=1
+compare out exp-out || fail=1
Exit $fail

View File

@ -0,0 +1,18 @@
diff -urNp coreutils-7.6-orig/src/tail.c coreutils-7.6/src/tail.c
--- coreutils-7.6-orig/src/tail.c 2009-09-10 19:33:26.000000000 +0200
+++ coreutils-7.6/src/tail.c 2009-11-18 14:43:19.000000000 +0100
@@ -1357,7 +1357,13 @@ tail_forever_inotify (int wd, struct Fil
if (ev->mask & (IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF))
{
- if (ev->mask & (IN_DELETE_SELF | IN_MOVE_SELF))
+ /* For IN_DELETE_SELF, we always want to remove the watch.
+ However, for IN_MOVE_SELF (the file we're watching has
+ been clobbered via a rename), when tailing by NAME, we
+ must continue to watch the file. It's only when following
+ by file descriptor that we must remove the watch. */
+ if ((ev->mask & IN_DELETE_SELF)
+ || ((ev->mask & IN_MOVE_SELF) && follow_mode == Follow_descriptor))
{
inotify_rm_watch (wd, f[i].wd);
hash_delete (wd_table, &(f[i]));

View File

@ -0,0 +1,670 @@
diff -urNp coreutils-7.6-orig/src/tail.c coreutils-7.6/src/tail.c
--- coreutils-7.6-orig/src/tail.c 2010-01-12 15:26:31.000000000 +0100
+++ coreutils-7.6/src/tail.c 2010-01-12 15:27:18.000000000 +0100
@@ -1,6 +1,5 @@
/* tail -- output the last part of file(s)
- Copyright (C) 1989, 90, 91, 1995-2006, 2008-2009 Free Software
- Foundation, Inc.
+ Copyright (C) 1989-1991, 1995-2006, 2008-2010 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
@@ -52,6 +51,12 @@
# include <sys/inotify.h>
/* `select' is used by tail_forever_inotify. */
# include <sys/select.h>
+
+/* inotify needs to know if a file is local. */
+# include "fs.h"
+# if HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+# endif
#endif
/* The official name of this program (e.g., no `g' prefix). */
@@ -105,9 +110,6 @@ struct File_spec
/* The actual file name, or "-" for stdin. */
char *name;
- /* File descriptor on which the file is open; -1 if it's not open. */
- int fd;
-
/* Attributes of the file the last time we checked. */
off_t size;
struct timespec mtime;
@@ -115,24 +117,27 @@ struct File_spec
ino_t ino;
mode_t mode;
- /* 1 if O_NONBLOCK is clear, 0 if set, -1 if not known. */
- int blocking;
-
/* The specified name initially referred to a directory or some other
type for which tail isn't meaningful. Unlike for a permission problem
(tailable, below) once this is set, the name is not checked ever again. */
bool ignore;
- /* See description of DEFAULT_MAX_N_... below. */
- uintmax_t n_unchanged_stats;
+ /* See the description of fremote. */
+ bool remote;
/* A file is tailable if it exists, is readable, and is of type
IS_TAILABLE_FILE_TYPE. */
bool tailable;
+ /* File descriptor on which the file is open; -1 if it's not open. */
+ int fd;
+
/* The value of errno seen last time we checked this file. */
int errnum;
+ /* 1 if O_NONBLOCK is clear, 0 if set, -1 if not known. */
+ int blocking;
+
#if HAVE_INOTIFY
/* The watch descriptor used by inotify. */
int wd;
@@ -144,6 +149,9 @@ struct File_spec
/* Offset in NAME of the basename part. */
size_t basename_start;
#endif
+
+ /* See description of DEFAULT_MAX_N_... below. */
+ uintmax_t n_unchanged_stats;
};
#if HAVE_INOTIFY
@@ -201,8 +209,7 @@ static bool have_read_stdin;
more expensive) code unconditionally. Intended solely for testing. */
static bool presume_input_pipe;
-/* If nonzero then don't use inotify even if available.
- Intended solely for testing. */
+/* If nonzero then don't use inotify even if available. */
static bool disable_inotify;
/* For long options that have no equivalent short option, use a
@@ -260,8 +267,8 @@ With no FILE, or when FILE is -, read st
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
- -c, --bytes=K output the last K bytes; alternatively, use +K to\n\
- output bytes starting with the Kth of each file\n\
+ -c, --bytes=K output the last K bytes; alternatively, use -c +K\n\
+ to output bytes starting with the Kth of each file\n\
"), stdout);
fputs (_("\
-f, --follow[={name|descriptor}]\n\
@@ -272,7 +279,7 @@ Mandatory arguments to long options are
"), stdout);
printf (_("\
-n, --lines=K output the last K lines, instead of the last %d;\n\
- or use +K to output lines starting with the Kth\n\
+ or use -n +K to output lines starting with the Kth\n\
--max-unchanged-stats=N\n\
with --follow=name, reopen a FILE which has not\n\
changed size after N (default %d) iterations\n\
@@ -308,14 +315,10 @@ GB 1000*1000*1000, G 1024*1024*1024, and
fputs (_("\
With --follow (-f), tail defaults to following the file descriptor, which\n\
means that even if a tail'ed file is renamed, tail will continue to track\n\
-its end. \
-"), stdout);
- fputs (_("\
-This default behavior is not desirable when you really want to\n\
+its end. This default behavior is not desirable when you really want to\n\
track the actual name of the file, not the file descriptor (e.g., log\n\
rotation). Use --follow=name in that case. That causes tail to track the\n\
-named file by reopening it periodically to see if it has been removed and\n\
-recreated by some other program.\n\
+named file in a way that accommodates renaming, removal and creation.\n\
"), stdout);
emit_bug_reporting_address ();
}
@@ -865,6 +868,50 @@ start_lines (const char *pretty_filename
}
}
+#if HAVE_INOTIFY
+/* Without inotify support, always return false. Otherwise, return false
+ when FD is open on a file known to reside on a local file system.
+ If fstatfs fails, give a diagnostic and return true.
+ If fstatfs cannot be called, return true. */
+static bool
+fremote (int fd, const char *name)
+{
+ bool remote = true; /* be conservative (poll by default). */
+
+# if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__
+ struct statfs buf;
+ int err = fstatfs (fd, &buf);
+ if (err != 0)
+ {
+ error (0, errno, _("cannot determine location of %s. "
+ "reverting to polling"), quote (name));
+ }
+ else
+ {
+ switch (buf.f_type)
+ {
+ case S_MAGIC_CODA:
+ case S_MAGIC_FUSECTL:
+ case S_MAGIC_LUSTRE:
+ case S_MAGIC_NCP:
+ case S_MAGIC_NFS:
+ case S_MAGIC_NFSD:
+ case S_MAGIC_SMB:
+ break;
+ default:
+ remote = false;
+ }
+ }
+# endif
+
+ return remote;
+}
+#else
+/* Without inotify support, whether a file is remote is irrelevant.
+ Always return "false" in that case. */
+# define fremote(fd, name) false
+#endif
+
/* FIXME: describe */
static void
@@ -921,6 +968,15 @@ recheck (struct File_spec *f, bool block
quote (pretty_name (f)));
f->ignore = true;
}
+ else if (!disable_inotify && fremote (fd, pretty_name (f)))
+ {
+ ok = false;
+ f->errnum = -1;
+ error (0, 0, _("%s has been replaced with a remote file. "
+ "giving up on this name"), quote (pretty_name (f)));
+ f->ignore = true;
+ f->remote = true;
+ }
else
{
f->errnum = 0;
@@ -1126,7 +1182,7 @@ tail_forever (struct File_spec *f, size_
break;
}
- if ((!any_input | blocking) && fflush (stdout) != 0)
+ if ((!any_input || blocking) && fflush (stdout) != 0)
error (EXIT_FAILURE, errno, _("write error"));
/* If nothing was read, sleep and/or check for dead writers. */
@@ -1135,9 +1191,6 @@ tail_forever (struct File_spec *f, size_
if (writer_is_dead)
break;
- if (xnanosleep (sleep_interval))
- error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
-
/* Once the writer is dead, read the files once more to
avoid a race condition. */
writer_is_dead = (pid != 0
@@ -1146,12 +1199,44 @@ tail_forever (struct File_spec *f, size_
signal to the writer, so kill fails and sets
errno to EPERM. */
&& errno != EPERM);
+
+ if (!writer_is_dead && xnanosleep (sleep_interval))
+ error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
+
}
}
}
#if HAVE_INOTIFY
+/* Return true if any of the N_FILES files in F is remote, i.e., has
+ an open file descriptor and is on a network file system. */
+
+static bool
+any_remote_file (const struct File_spec *f, size_t n_files)
+{
+ size_t i;
+
+ for (i = 0; i < n_files; i++)
+ if (0 <= f[i].fd && f[i].remote)
+ return true;
+ return false;
+}
+
+/* Return true if any of the N_FILES files in F represents
+ stdin and is tailable. */
+
+static bool
+tailable_stdin (const struct File_spec *f, size_t n_files)
+{
+ size_t i;
+
+ for (i = 0; i < n_files; i++)
+ if (!f[i].ignore && STREQ (f[i].name, "-"))
+ return true;
+ return false;
+}
+
static size_t
wd_hasher (const void *entry, size_t tabsize)
{
@@ -1167,31 +1252,73 @@ wd_comparator (const void *e1, const voi
return spec1->wd == spec2->wd;
}
+/* Helper function used by `tail_forever_inotify'. */
+static void
+check_fspec (struct File_spec *fspec, int wd, int *prev_wd)
+{
+ struct stat stats;
+ char const *name = pretty_name (fspec);
+
+ if (fstat (fspec->fd, &stats) != 0)
+ {
+ close_fd (fspec->fd, name);
+ fspec->fd = -1;
+ fspec->errnum = errno;
+ return;
+ }
+
+ if (S_ISREG (fspec->mode) && stats.st_size < fspec->size)
+ {
+ error (0, 0, _("%s: file truncated"), name);
+ *prev_wd = wd;
+ xlseek (fspec->fd, stats.st_size, SEEK_SET, name);
+ fspec->size = stats.st_size;
+ }
+ else if (S_ISREG (fspec->mode) && stats.st_size == fspec->size
+ && timespec_cmp (fspec->mtime, get_stat_mtime (&stats)) == 0)
+ return;
+
+ if (wd != *prev_wd)
+ {
+ if (print_headers)
+ write_header (name);
+ *prev_wd = wd;
+ }
+
+ uintmax_t bytes_read = dump_remainder (name, fspec->fd, COPY_TO_EOF);
+ fspec->size += bytes_read;
+
+ if (fflush (stdout) != 0)
+ error (EXIT_FAILURE, errno, _("write error"));
+}
+
/* Tail N_FILES files forever, or until killed.
Check modifications using the inotify events system. */
-
static void
tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
double sleep_interval)
{
- size_t i;
unsigned int max_realloc = 3;
- Hash_table *wd_table;
+
+ /* Map an inotify watch descriptor to the name of the file it's watching. */
+ Hash_table *wd_to_name;
bool found_watchable = false;
+ bool writer_is_dead = false;
int prev_wd;
size_t evlen = 0;
char *evbuf;
size_t evbuf_off = 0;
size_t len = 0;
- wd_table = hash_initialize (n_files, NULL, wd_hasher, wd_comparator, NULL);
- if (! wd_table)
+ wd_to_name = hash_initialize (n_files, NULL, wd_hasher, wd_comparator, NULL);
+ if (! wd_to_name)
xalloc_die ();
/* Add an inotify watch for each watched file. If -F is specified then watch
its parent directory too, in this way when they re-appear we can add them
again to the watch list. */
+ size_t i;
for (i = 0; i < n_files; i++)
{
if (!f[i].ignore)
@@ -1235,7 +1362,7 @@ tail_forever_inotify (int wd, struct Fil
continue;
}
- if (hash_insert (wd_table, &(f[i])) == NULL)
+ if (hash_insert (wd_to_name, &(f[i])) == NULL)
xalloc_die ();
found_watchable = true;
@@ -1247,6 +1374,14 @@ tail_forever_inotify (int wd, struct Fil
prev_wd = f[n_files - 1].wd;
+ /* Check files again. New data can be available since last time we checked
+ and before they are watched by inotify. */
+ for (i = 0; i < n_files; i++)
+ {
+ if (!f[i].ignore)
+ check_fspec (&f[i], f[i].wd, &prev_wd);
+ }
+
evlen += sizeof (struct inotify_event) + 1;
evbuf = xmalloc (evlen);
@@ -1255,41 +1390,37 @@ tail_forever_inotify (int wd, struct Fil
This loop sleeps on the `safe_read' call until a new event is notified. */
while (1)
{
- char const *name;
struct File_spec *fspec;
- uintmax_t bytes_read;
- struct stat stats;
-
struct inotify_event *ev;
/* When watching a PID, ensure that a read from WD will not block
- indefinetely. */
+ indefinitely. */
if (pid)
{
- fd_set rfd;
- struct timeval select_timeout;
- int n_descriptors;
-
- FD_ZERO (&rfd);
- FD_SET (wd, &rfd);
+ if (writer_is_dead)
+ exit (EXIT_SUCCESS);
- select_timeout.tv_sec = (time_t) sleep_interval;
- select_timeout.tv_usec = 1000000 * (sleep_interval
- - select_timeout.tv_sec);
+ writer_is_dead = (kill (pid, 0) != 0 && errno != EPERM);
- n_descriptors = select (wd + 1, &rfd, NULL, NULL, &select_timeout);
+ struct timeval delay; /* how long to wait for file changes. */
+ if (writer_is_dead)
+ delay.tv_sec = delay.tv_usec = 0;
+ else
+ {
+ delay.tv_sec = (time_t) sleep_interval;
+ delay.tv_usec = 1000000 * (sleep_interval - delay.tv_sec);
+ }
- if (n_descriptors == -1)
- error (EXIT_FAILURE, errno, _("error monitoring inotify event"));
+ fd_set rfd;
+ FD_ZERO (&rfd);
+ FD_SET (wd, &rfd);
- if (n_descriptors == 0)
- {
- /* See if the process we are monitoring is still alive. */
- if (kill (pid, 0) != 0 && errno != EPERM)
- exit (EXIT_SUCCESS);
+ int file_change = select (wd + 1, &rfd, NULL, NULL, &delay);
- continue;
- }
+ if (file_change == 0)
+ continue;
+ else if (file_change == -1)
+ error (EXIT_FAILURE, errno, _("error monitoring inotify event"));
}
if (len <= evbuf_off)
@@ -1315,41 +1446,59 @@ tail_forever_inotify (int wd, struct Fil
ev = (struct inotify_event *) (evbuf + evbuf_off);
evbuf_off += sizeof (*ev) + ev->len;
- if (ev->len)
+ if (ev->len) /* event on ev->name in watched directory */
{
- for (i = 0; i < n_files; i++)
+ size_t j;
+ for (j = 0; j < n_files; j++)
{
/* With N=hundreds of frequently-changing files, this O(N^2)
process might be a problem. FIXME: use a hash table? */
- if (f[i].parent_wd == ev->wd
- && STREQ (ev->name, f[i].name + f[i].basename_start))
+ if (f[j].parent_wd == ev->wd
+ && STREQ (ev->name, f[j].name + f[j].basename_start))
break;
}
/* It is not a watched file. */
- if (i == n_files)
+ if (j == n_files)
continue;
- f[i].wd = inotify_add_watch (wd, f[i].name, inotify_wd_mask);
-
- if (f[i].wd < 0)
+ /* It's fine to add the same file more than once. */
+ int new_wd = inotify_add_watch (wd, f[j].name, inotify_wd_mask);
+ if (new_wd < 0)
{
- error (0, errno, _("cannot watch %s"), quote (f[i].name));
+ error (0, errno, _("cannot watch %s"), quote (f[j].name));
continue;
}
- fspec = &(f[i]);
- if (hash_insert (wd_table, fspec) == NULL)
+ fspec = &(f[j]);
+
+ /* Remove `fspec' and re-add it using `new_fd' as its key. */
+ hash_delete (wd_to_name, fspec);
+ fspec->wd = new_wd;
+
+ /* If the file was moved then inotify will use the source file wd for
+ the destination file. Make sure the key is not present in the
+ table. */
+ struct File_spec *prev = hash_delete (wd_to_name, fspec);
+ if (prev && prev != fspec)
+ {
+ if (follow_mode == Follow_name)
+ recheck (prev, false);
+ prev->wd = -1;
+ close_fd (prev->fd, pretty_name (prev));
+ }
+
+ if (hash_insert (wd_to_name, fspec) == NULL)
xalloc_die ();
if (follow_mode == Follow_name)
- recheck (&(f[i]), false);
+ recheck (fspec, false);
}
else
{
struct File_spec key;
key.wd = ev->wd;
- fspec = hash_lookup (wd_table, &key);
+ fspec = hash_lookup (wd_to_name, &key);
}
if (! fspec)
@@ -1357,53 +1506,23 @@ tail_forever_inotify (int wd, struct Fil
if (ev->mask & (IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF))
{
- /* For IN_DELETE_SELF, we always want to remove the watch.
- However, for IN_MOVE_SELF (the file we're watching has
- been clobbered via a rename), when tailing by NAME, we
- must continue to watch the file. It's only when following
- by file descriptor that we must remove the watch. */
- if ((ev->mask & IN_DELETE_SELF)
- || ((ev->mask & IN_MOVE_SELF) && follow_mode == Follow_descriptor))
+ /* For IN_DELETE_SELF, we always want to remove the watch.
+ However, for IN_MOVE_SELF (the file we're watching has
+ been clobbered via a rename), when tailing by NAME, we
+ must continue to watch the file. It's only when following
+ by file descriptor that we must remove the watch. */
+ if ((ev->mask & IN_DELETE_SELF)
+ || ((ev->mask & IN_MOVE_SELF) && follow_mode == Follow_descriptor))
{
- inotify_rm_watch (wd, f[i].wd);
- hash_delete (wd_table, &(f[i]));
+ inotify_rm_watch (wd, fspec->wd);
+ hash_delete (wd_to_name, fspec);
}
if (follow_mode == Follow_name)
recheck (fspec, false);
continue;
}
-
- name = pretty_name (fspec);
-
- if (fstat (fspec->fd, &stats) != 0)
- {
- close_fd (fspec->fd, name);
- fspec->fd = -1;
- fspec->errnum = errno;
- continue;
- }
-
- if (S_ISREG (fspec->mode) && stats.st_size < fspec->size)
- {
- error (0, 0, _("%s: file truncated"), name);
- prev_wd = ev->wd;
- xlseek (fspec->fd, stats.st_size, SEEK_SET, name);
- fspec->size = stats.st_size;
- }
-
- if (ev->wd != prev_wd)
- {
- if (print_headers)
- write_header (name);
- prev_wd = ev->wd;
- }
-
- bytes_read = dump_remainder (name, fspec->fd, COPY_TO_EOF);
- fspec->size += bytes_read;
-
- if (fflush (stdout) != 0)
- error (EXIT_FAILURE, errno, _("write error"));
+ check_fspec (fspec, ev->wd, &prev_wd);
}
}
#endif
@@ -1602,7 +1721,7 @@ tail_file (struct File_spec *f, uintmax_
/* 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)
@@ -1632,6 +1751,7 @@ tail_file (struct File_spec *f, uintmax_
to avoid a race condition described by Ken Raeburn:
http://mail.gnu.org/archive/html/bug-textutils/2003-05/msg00007.html */
record_open_fd (f, fd, read_pos, &stats, (is_stdin ? -1 : 1));
+ f->remote = fremote (fd, pretty_name (f));
}
}
else
@@ -1872,6 +1992,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)
{
@@ -1963,41 +2112,31 @@ 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 "-",
- or implicitly by providing no arguments, we won't use inotify.
+ /* tailable_stdin() checks if the user specifies stdin via "-",
+ or implicitly by providing no arguments. If so, we won't use inotify.
Technically, on systems with a working /dev/stdin, we *could*,
but would it be worth it? Verifying that it's a real device
and hooked up to stdin is not trivial, while reverting to
- non-inotify-based tail_forever is easy and portable. */
- bool stdin_cmdline_arg = false;
+ non-inotify-based tail_forever is easy and portable.
- for (i = 0; i < n_files; i++)
- if (!F[i].ignore && STREQ (F[i].name, "-"))
- stdin_cmdline_arg = true;
+ any_remote_file() checks if the user has specified any
+ files that reside on remote file systems. inotify is not used
+ in this case because it would miss any updates to the file
+ that were not initiated from the local system.
+
+ FIXME: inotify doesn't give any notification when a new
+ (remote) file or directory is mounted on top a watched file.
+ When follow_mode == Follow_name we would ideally like to detect that.
+ Note if there is a change to the original file then we'll
+ recheck it and follow the new file, or ignore it if the
+ file has changed to being remote. */
+ if (tailable_stdin (F, n_files) || any_remote_file (F, n_files))
+ disable_inotify = true;
- if (!disable_inotify && !stdin_cmdline_arg)
+ if (!disable_inotify)
{
int wd = inotify_init ();
if (wd < 0)

View File

@ -0,0 +1,30 @@
diff -urNp coreutils-7.6-orig/src/true.c coreutils-7.6/src/true.c
--- coreutils-7.6-orig/src/true.c 2009-09-01 13:01:16.000000000 +0200
+++ coreutils-7.6/src/true.c 2009-11-18 15:00:22.000000000 +0100
@@ -54,18 +54,19 @@ Usage: %s [ignored command line argument
int
main (int argc, char **argv)
{
- initialize_main (&argc, &argv);
- set_program_name (argv[0]);
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
-
- atexit (close_stdout);
/* Recognize --help or --version only if it's the only command-line
argument. */
if (argc == 2)
{
+ initialize_main (&argc, &argv);
+ set_program_name (argv[0]);
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
+ atexit (close_stdout);
+
if (STREQ (argv[1], "--help"))
usage (EXIT_STATUS);

View File

@ -0,0 +1,75 @@
diff -urNp coreutils-7.6-orig/m4/jm-macros.m4 coreutils-7.6/m4/jm-macros.m4
--- coreutils-7.6-orig/m4/jm-macros.m4 2010-04-28 17:44:36.000000000 +0200
+++ coreutils-7.6/m4/jm-macros.m4 2010-04-28 17:45:01.000000000 +0200
@@ -146,6 +146,25 @@ AC_DEFUN([coreutils_MACROS],
])
AC_REQUIRE([AM_LANGINFO_CODESET])
+
+ # Accept configure options: --with-tty-group[=GROUP], --without-tty-group
+ # You can determine the group of a TTY via 'stat --format %G /dev/tty'
+ # Omitting this option is equivalent to using --without-tty-group.
+ AC_ARG_WITH([tty-group],
+ AS_HELP_STRING([--with-tty-group[[[=NAME]]]],
+ [group used by system for TTYs, "tty" when not specified]
+ [ (default: do not rely on any group used for TTYs)]),
+ [tty_group_name=$withval],
+ [tty_group_name=no])
+
+ if test "x$tty_group_name" != xno; then
+ if test "x$tty_group_name" = xyes; then
+ tty_group_name=tty
+ fi
+ AC_MSG_NOTICE([TTY group used by system set to "$tty_group_name"])
+ AC_DEFINE_UNQUOTED([TTY_GROUP_NAME], ["$tty_group_name"],
+ [group used by system for TTYs])
+ fi
])
AC_DEFUN([gl_CHECK_ALL_HEADERS],
diff -urNp coreutils-7.6-orig/src/who.c coreutils-7.6/src/who.c
--- coreutils-7.6-orig/src/who.c 2010-04-28 17:44:36.000000000 +0200
+++ coreutils-7.6/src/who.c 2010-04-28 17:45:01.000000000 +0200
@@ -36,6 +36,10 @@
#include "error.h"
#include "quote.h"
+#ifdef TTY_GROUP_NAME
+# include <grp.h>
+#endif
+
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "who"
@@ -307,6 +311,22 @@ print_line (int userlen, const char *use
free (x_exitstr);
}
+/* Return true if a terminal device given as PSTAT allows other users
+ to send messages to; false otherwise */
+static bool
+is_tty_writable (struct stat const *pstat)
+{
+#ifdef TTY_GROUP_NAME
+ /* Ensure the group of the TTY device matches TTY_GROUP_NAME, more info at
+ https://bugzilla.redhat.com/454261 */
+ struct group *ttygr = getgrnam (TTY_GROUP_NAME);
+ if (!ttygr || (pstat->st_gid != ttygr->gr_gid))
+ return false;
+#endif
+
+ return pstat->st_mode & S_IWGRP;
+}
+
/* Send properly parsed USER_PROCESS info to print_line. The most
recent boot time is BOOTTIME. */
static void
@@ -345,7 +365,7 @@ print_user (const STRUCT_UTMP *utmp_ent,
if (stat (line, &stats) == 0)
{
- mesg = (stats.st_mode & S_IWGRP) ? '+' : '-';
+ mesg = is_tty_writable (&stats) ? '+' : '-';
last_change = stats.st_atime;
}
else

View File

@ -0,0 +1,67 @@
diff -urNp coreutils-7.6-orig/dist-check.mk coreutils-7.6/dist-check.mk
--- coreutils-7.6-orig/dist-check.mk 2009-09-01 13:01:16.000000000 +0200
+++ coreutils-7.6/dist-check.mk 2009-12-11 19:25:01.231452251 +0100
@@ -4,14 +4,14 @@ 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 +30,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 +53,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 +72,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 +120,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-c
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 +131,7 @@ my-distcheck: $(DIST_ARCHIVES) $(local-c
&& $(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,5 +1,5 @@
# Configuration file for the color ls utility
# Synchronized with coreutils 7.1 dircolors
# Synchronized with coreutils 8.5 dircolors
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
@ -45,9 +45,11 @@ TERM mach-color
TERM mlterm
TERM putty
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode256
TERM screen
TERM screen-256color
TERM screen-256color-bce
@ -94,7 +96,6 @@ STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;32
@ -183,6 +184,8 @@ EXEC 01;32
.xcf 01;35
.xwd 01;35
.yuv 01;35
.cgm 01;35
.emf 01;35
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 01;35

View File

@ -1,6 +1,6 @@
# Configuration file for the 256color ls utility
# This file goes in the /etc directory, and must be world readable.
# Synchronized with coreutils 7.1 dircolors
# Synchronized with coreutils 8.5 dircolors
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# In the case that you are not satisfied with supplied colors, please
@ -23,6 +23,7 @@ OPTIONS -F -T 0
# Below, there should be one TERM entry for each termtype that is colorizable
TERM putty-256color
TERM rxvt-256color
TERM rxvt-unicode256
TERM screen-256color
TERM xterm-256color
TERM gnome-256color
@ -52,17 +53,17 @@ EIGHTBIT 1
#NORMAL 00 # global default, no color code at all
#FILE 00 # normal file, use no color at all
RESET 0 # reset to "normal" color
DIR 01;38;5;27 # directory
LINK 01;38;5;51 # symbolic link (If you set this to 'target' instead of a
DIR 38;5;27 # directory
LINK 38;5;51 # symbolic link (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 44;38;5;15 # regular file with more than one link
FIFO 40;38;5;11 # pipe
SOCK 01;38;5;13 # socket
DOOR 01;38;5;5 # door
BLK 01;48;5;232;38;5;11 # block device driver
CHR 01;48;5;232;38;5;3 # character device driver
ORPHAN 01;48;5;232;38;5;9 # symlink to nonexistent file, or non-stat'able file
MISSING 01;05;48;5;232;38;5;15 # ... and the files they point to
SOCK 38;5;13 # socket
DOOR 38;5;5 # door
BLK 48;5;232;38;5;11 # block device driver
CHR 48;5;232;38;5;3 # character device driver
ORPHAN 48;5;232;38;5;9 # symlink to nonexistent file, or non-stat'able file
MISSING 05;48;5;232;38;5;15 # ... and the files they point to
SETUID 48;5;196;38;5;15 # file that is setuid (u+s)
SETGID 48;5;11;38;5;16 # file that is setgid (g+s)
CAPABILITY 48;5;196;38;5;226 # file with capability
@ -71,115 +72,117 @@ OTHER_WRITABLE 48;5;10;38;5;21 # dir that is other-writable (o+w) and not sticky
STICKY 48;5;21;38;5;15 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;38;5;34
EXEC 38;5;34
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# executables (bright green)
#.cmd 01;38;5;34
#.exe 01;38;5;34
#.com 01;38;5;34
#.btm 01;38;5;34
#.bat 01;38;5;34
#.sh 01;38;5;34
#.csh 01;38;5;34
#.cmd 38;5;34
#.exe 38;5;34
#.com 38;5;34
#.btm 38;5;34
#.bat 38;5;34
#.sh 38;5;34
#.csh 38;5;34
# archives or compressed (bright red)
.tar 01;38;5;9
.tgz 01;38;5;9
.arj 01;38;5;9
.taz 01;38;5;9
.lzh 01;38;5;9
.lzma 01;38;5;9
.tlz 01;38;5;9
.txz 01;38;5;9
.zip 01;38;5;9
.z 01;38;5;9
.Z 01;38;5;9
.dz 01;38;5;9
.gz 01;38;5;9
.lz 01;38;5;9
.xz 01;38;5;9
.bz2 01;38;5;9
.tbz 01;38;5;9
.tbz2 01;38;5;9
.bz 01;38;5;9
.tz 01;38;5;9
.deb 01;38;5;9
.rpm 01;38;5;9
.jar 01;38;5;9
.rar 01;38;5;9
.ace 01;38;5;9
.zoo 01;38;5;9
.cpio 01;38;5;9
.7z 01;38;5;9
.rz 01;38;5;9
.tar 38;5;9
.tgz 38;5;9
.arj 38;5;9
.taz 38;5;9
.lzh 38;5;9
.lzma 38;5;9
.tlz 38;5;9
.txz 38;5;9
.zip 38;5;9
.z 38;5;9
.Z 38;5;9
.dz 38;5;9
.gz 38;5;9
.lz 38;5;9
.xz 38;5;9
.bz2 38;5;9
.tbz 38;5;9
.tbz2 38;5;9
.bz 38;5;9
.tz 38;5;9
.deb 38;5;9
.rpm 38;5;9
.jar 38;5;9
.rar 38;5;9
.ace 38;5;9
.zoo 38;5;9
.cpio 38;5;9
.7z 38;5;9
.rz 38;5;9
# image formats (magenta)
.jpg 01;38;5;13
.jpeg 01;38;5;13
.gif 01;38;5;13
.bmp 01;38;5;13
.pbm 01;38;5;13
.pgm 01;38;5;13
.ppm 01;38;5;13
.tga 01;38;5;13
.xbm 01;38;5;13
.xpm 01;38;5;13
.tif 01;38;5;13
.tiff 01;38;5;13
.png 01;38;5;13
.svg 01;38;5;13
.svgz 01;38;5;13
.mng 01;38;5;13
.pcx 01;38;5;13
.mov 01;38;5;13
.mpg 01;38;5;13
.mpeg 01;38;5;13
.m2v 01;38;5;13
.mkv 01;38;5;13
.ogm 01;38;5;13
.mp4 01;38;5;13
.m4v 01;38;5;13
.mp4v 01;38;5;13
.vob 01;38;5;13
.qt 01;38;5;13
.nuv 01;38;5;13
.wmv 01;38;5;13
.asf 01;38;5;13
.rm 01;38;5;13
.rmvb 01;38;5;13
.flc 01;38;5;13
.avi 01;38;5;13
.fli 01;38;5;13
.flv 01;38;5;13
.gl 01;38;5;13
.dl 01;38;5;13
.xcf 01;38;5;13
.xwd 01;38;5;13
.yuv 01;38;5;13
.jpg 38;5;13
.jpeg 38;5;13
.gif 38;5;13
.bmp 38;5;13
.pbm 38;5;13
.pgm 38;5;13
.ppm 38;5;13
.tga 38;5;13
.xbm 38;5;13
.xpm 38;5;13
.tif 38;5;13
.tiff 38;5;13
.png 38;5;13
.svg 38;5;13
.svgz 38;5;13
.mng 38;5;13
.pcx 38;5;13
.mov 38;5;13
.mpg 38;5;13
.mpeg 38;5;13
.m2v 38;5;13
.mkv 38;5;13
.ogm 38;5;13
.mp4 38;5;13
.m4v 38;5;13
.mp4v 38;5;13
.vob 38;5;13
.qt 38;5;13
.nuv 38;5;13
.wmv 38;5;13
.asf 38;5;13
.rm 38;5;13
.rmvb 38;5;13
.flc 38;5;13
.avi 38;5;13
.fli 38;5;13
.flv 38;5;13
.gl 38;5;13
.dl 38;5;13
.xcf 38;5;13
.xwd 38;5;13
.yuv 38;5;13
.cgm 38;5;13
.emf 38;5;13
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 01;38;5;13
.anx 01;38;5;13
.ogv 01;38;5;13
.ogx 01;38;5;13
.axv 38;5;13
.anx 38;5;13
.ogv 38;5;13
.ogx 38;5;13
# audio formats (cyan)
.aac 01;38;5;45
.au 01;38;5;45
.flac 01;38;5;45
.mid 01;38;5;45
.midi 01;38;5;45
.mka 01;38;5;45
.mp3 01;38;5;45
.mpc 01;38;5;45
.ogg 01;38;5;45
.ra 01;38;5;45
.wav 01;38;5;45
.aac 38;5;45
.au 38;5;45
.flac 38;5;45
.mid 38;5;45
.midi 38;5;45
.mka 38;5;45
.mp3 38;5;45
.mpc 38;5;45
.ogg 38;5;45
.ra 38;5;45
.wav 38;5;45
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa 01;38;5;45
.oga 01;38;5;45
.spx 01;38;5;45
.xspf 01;38;5;45
.axa 38;5;45
.oga 38;5;45
.spx 38;5;45
.xspf 38;5;45

View File

@ -1,5 +1,5 @@
# Configuration file for the color ls utility - modified for gray backgrounds
# Synchronized with coreutils 7.1 dircolors
# Synchronized with coreutils 8.5 dircolors
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
@ -34,7 +34,9 @@ TERM xterm-16color
TERM xterm-88color
TERM xterm-256color
TERM rxvt
TERM rxvt-256color
TERM rxvt-unicode
TERM rxvt-unicode256
TERM xterm-color
TERM color-xterm
TERM vt100
@ -160,6 +162,8 @@ EXEC 00;32
.xcf 00;35
.xwd 00;35
.yuv 00;35
.cgm 00;35
.emf 00;35
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 00;35

View File

@ -2,7 +2,7 @@
# color-ls initialization
if ( $?USER_LS_COLORS ) then
if ( "$USER_LS_COLORS" != "" ) then
#when USER_LS_COLORS defined do not override user
#when USER_LS_COLORS defined do not override user
#specified LS_COLORS and use them
goto finish
endif
@ -12,14 +12,14 @@ alias ll 'ls -l'
alias l. 'ls -d .*'
set COLORS=/etc/DIR_COLORS
if ($?TERM) then
if ( -e "/etc/DIR_COLORS.$TERM" ) then
if ( -e "/etc/DIR_COLORS.$TERM" ) then
set COLORS="/etc/DIR_COLORS.$TERM"
endif
endif
if ( -e "/etc/DIR_COLORS.256color" ) then
if ( "`tput colors`" == "256" ) then
if ( "`tty -s && tput colors`" == "256" ) then
set COLORS=/etc/DIR_COLORS.256color
endif
endif
endif
if ( -f ~/.dircolors ) set COLORS=~/.dircolors
if ( -f ~/.dir_colors ) set COLORS=~/.dir_colors
@ -30,11 +30,11 @@ endif
if ( ! -e "$COLORS" ) exit
eval `dircolors -c $COLORS`
eval "`dircolors -c $COLORS`"
if ( "$LS_COLORS" == '' ) exit
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
if ( "$color_none" != '' ) then
if ( "$color_none" != '' ) then
unset color_none
exit
endif

View File

@ -18,7 +18,7 @@ if [ -z "$USER_LS_COLORS" ]; then
done
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \
[ "x`tput colors 2>/dev/null`" = "x256" ] && \
[ "x`tty -s && tput colors 2>/dev/null`" = "x256" ] && \
COLORS="/etc/DIR_COLORS.256color"
if [ -z "$COLORS" ]; then
@ -30,9 +30,9 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return
eval `dircolors --sh "$COLORS" 2>/dev/null`
eval "`dircolors --sh "$COLORS" 2>/dev/null`"
[ -z "$LS_COLORS" ] && return
egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
fi
alias ll='ls -l --color=auto' 2>/dev/null

9
coreutils-mkstemp.patch Normal file
View File

@ -0,0 +1,9 @@
--- coreutils-7.6/lib/mkstemp.c.BAD 2010-03-03 18:17:52.000000000 +0000
+++ coreutils-7.6/lib/mkstemp.c 2010-03-03 18:18:28.000000000 +0000
@@ -40,5 +40,5 @@
mkstemp (template)
char *template;
{
- return __gen_tempname (template, 0, __GT_FILE);
+ return __gen_tempname (template, __GT_FILE);
}

View File

@ -265,7 +265,7 @@
shell_basename = last_component (shell);
arg0 = xmalloc (strlen (shell_basename) + 2);
arg0[0] = '-';
@@ -360,6 +512,66 @@
@@ -360,6 +512,67 @@
error (0, errno, "%s", shell);
exit (exit_status);
}
@ -303,12 +303,12 @@
+
+ pid = waitpid(-1, &status, WUNTRACED);
+
+ if (WIFSTOPPED(status)) {
+ kill(getpid(), SIGSTOP);
+ if (((pid_t)-1 != pid) && (0 != WIFSTOPPED (status))) {
+ kill(getpid(), WSTOPSIG(status));
+ /* once we get here, we must have resumed */
+ kill(pid, SIGCONT);
+ }
+ } while (WIFSTOPPED(status));
+ } while (0 != WIFSTOPPED(status));
+ }
+
+ if (caught) {
@ -327,7 +327,8 @@
+ fprintf(stderr, " ...killed.\n");
+ exit(-1);
+ }
+ exit (WEXITSTATUS(status));
+ exit ((0 != WIFEXITED (status)) ? WEXITSTATUS (status)
+ : WTERMSIG (status) + 128);
+#endif /* USE_PAM */
}

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 7.6
Release: 5%{?dist}
Release: 11%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -20,6 +20,15 @@ Source203: coreutils-runuser-l.pamd
# From upstream
Patch1: coreutils-cpxattrreadonly.patch
Patch2: coreutils-7.6-lzipcolor.patch
Patch3: coreutils-7.6-ftssubmount.patch
Patch4: coreutils-7.6-tail-F-renaming.patch
Patch5: coreutils-7.6-trueexecve.patch
Patch6: coreutils-7.6-ls-infloop.patch
Patch7: coreutils-7.6-ls-derefdanglinginode.patch
Patch8: coreutils-CVE-2009-4135.patch
Patch9: coreutils-7.6-tail-rebase.patch
Patch10: coreutils-mkstemp.patch
Patch11: coreutils-7.6-who-msgstatus.patch
# Our patches
Patch100: coreutils-6.10-configuration.patch
@ -61,6 +70,7 @@ BuildRequires: automake >= 1.10.1
BuildRequires: libcap-devel >= 2.0.6
BuildRequires: libattr-devel
BuildRequires: attr
BuildRequires: gmp-devel
Requires(post): libselinux >= 1.25.6-1
Requires: libattr
@ -74,6 +84,7 @@ Requires(post): grep
%{?!nopam:Requires: pam >= 0.66-12}
Requires(post): libcap >= 2.0.6
Requires: ncurses
Requires: gmp
Requires: %{name}-libs = %{version}-%{release}
# Require a C library that doesn't put LC_TIME files in our way.
@ -111,6 +122,14 @@ Libraries for coreutils package.
# From upstream
%patch1 -p1 -b .roxattr
%patch2 -p1 -b .lzip
%patch3 -p1 -b .ftssubmount
%patch4 -p1 -b .renaming
%patch5 -p1 -b .execve
%patch6 -p1 -b .infloop
%patch8 -p1 -b .unsafetmp
%patch9 -p1 -b .rebase
%patch10 -p1 -b .mkstemp
%patch11 -p1 -b .whomsg
# Our patches
%patch100 -p1 -b .configure
@ -138,6 +157,9 @@ Libraries for coreutils package.
%patch950 -p1 -b .selinux
%patch951 -p1 -b .selinuxman
#upstream apply later
%patch7 -p1 -b .inode
chmod a+x tests/misc/sort-mb-tests
#fix typos/mistakes in localized documentation(#439410, #440056)
@ -161,6 +183,7 @@ automake --copy --add-missing
%configure --enable-largefile --with-afs %{?!nopam:--enable-pam} \
--enable-selinux \
--enable-install-program=su,hostname,arch \
--with-tty-group \
DEFAULT_POSIX2_VERSION=200112 alternative=199209 || :
# Regenerate manpages
@ -196,15 +219,15 @@ bzip2 -9f ChangeLog
# let be compatible with old fileutils, sh-utils and textutils packages :
mkdir -p $RPM_BUILD_ROOT{/bin,%_bindir,%_sbindir,/sbin}
%{?!nopam:mkdir -p $RPM_BUILD_ROOT%_sysconfdir/pam.d}
for f in arch basename cat chgrp chmod chown cp cut date dd df echo env false link ln ls mkdir mknod mktemp mv nice pwd rm rmdir sleep sort stty sync touch true uname unlink
for f in arch basename cat chgrp chmod chown cp cut date dd df echo env false link ln ls mkdir mknod mktemp mv nice pwd readlink rm rmdir sleep sort stty sync touch true uname unlink
do
mv $RPM_BUILD_ROOT{%_bindir,/bin}/$f
done
# chroot was in /usr/sbin :
mv $RPM_BUILD_ROOT{%_bindir,%_sbindir}/chroot
# {cat,sort,cut} were previously moved from bin to /usr/bin and linked into
for i in env cut; do ln -sf ../../bin/$i $RPM_BUILD_ROOT/usr/bin; done
# {env,cut,readlink} were previously moved from /usr/bin to /bin and linked into
for i in env cut readlink; do ln -sf ../../bin/$i $RPM_BUILD_ROOT/usr/bin; done
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -p -c -m644 %SOURCE101 $RPM_BUILD_ROOT%{_sysconfdir}/DIR_COLORS
@ -254,15 +277,15 @@ rm -rf $RPM_BUILD_ROOT
# coreutils.info. else their postun'll be run too late
# and install-info will fail badly because of duplicates
for file in sh-utils textutils fileutils; do
if [ -f %{_infodir}/$file.info ]; then
/sbin/install-info --delete %{_infodir}/$file.info --dir=%{_infodir}/dir &> /dev/null || :
if [ -f %{_infodir}/$file.info.gz ]; then
/sbin/install-info --delete %{_infodir}/$file.info.gz --dir=%{_infodir}/dir &> /dev/null || :
fi
done
%preun
if [ $1 = 0 ]; then
if [ -f %{_infodir}/%{name}.info ]; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
if [ -f %{_infodir}/%{name}.info.gz ]; then
/sbin/install-info --delete %{_infodir}/%{name}.info.gz %{_infodir}/dir || :
fi
fi
@ -270,8 +293,8 @@ fi
/bin/grep -v '(sh-utils)\|(fileutils)\|(textutils)' %{_infodir}/dir > \
%{_infodir}/dir.rpmmodify || exit 0
/bin/mv -f %{_infodir}/dir.rpmmodify %{_infodir}/dir
if [ -f %{_infodir}/%{name}.info ]; then
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
if [ -f %{_infodir}/%{name}.info.gz ]; then
/sbin/install-info %{_infodir}/%{name}.info.gz %{_infodir}/dir || :
fi
%files -f %{name}.lang
@ -306,6 +329,7 @@ fi
/bin/mv
/bin/nice
/bin/pwd
/bin/readlink
/bin/rm
/bin/rmdir
/bin/sleep
@ -329,6 +353,45 @@ fi
%{_libdir}/coreutils
%changelog
* Wed Apr 28 2010 Ondrej Vasik <ovasik@redhat.com> - 7.6-11
- doublequote LS_COLORS in colorls.*sh scripts to speedup
shell start(#586029)
- update /etc/DIR_COLORS* files
- move readlink from /usr/bin to bin, keep symlink in
/usr/bin(#580682)
- run tput colors in colorls profile.d scripts only
in the interactive mode(#450424)
- fix exit status of terminated child processes in su with
pam(#559098)
- who doesn't determine user's message status correctly
(#454261)
* Wed Mar 03 2010 Dennis Gilmore <dennis@ausil.us> - 7.6-10
- add patch for mkstemp on sparc64
* Tue Jan 12 2010 Ondrej Vasik <ovasik@redhat.com> - 7.6-9
- require gmp-devel/gmp for large numbers support(#552846)
- use grep instead of deprecated egrep in colorls.sh script
(#548174)
- fix DIR_COLORS.256color file
- upstream fixes for tail -F (maybe related to #547509)
* Fri Dec 11 2009 Ondrej Vasik <ovasik@redhat.com> - 7.6-8
- CVE-2009-4135 : Unsafe temporary directory use in "distcheck" rule
* Mon Nov 23 2009 Ondrej Vasik <ovasik@redhat.com> - 7.6-7
- update /etc/DIR_COLORS* files
- ls -LR exits with status 2, not 0, when it encounters
a cycle(#525402)
- ls: print "?", not "0" as inode of dereferenced dangling
symlink(#525400)
- /bin/{true,false} - do not segfault with abusive
execve() usage (#537684)
- tail -F no longer can fail to track a file after
it's been rotated (#537664)
- du - do not fail on a submount during traversal (#501848)
- call the install-info on .gz info files
* Tue Sep 22 2009 Ondrej Vasik <ovasik@redhat.com> - 7.6-5
- improve and correct runuser documentation (#524805)