Compare commits

...

196 Commits
v7.6 ... v8.1

Author SHA1 Message Date
Jim Meyering
447d245551 version 8.1
* NEWS: Record release date.
2009-11-18 19:38:50 +01:00
Jim Meyering
fee722471c build: update gnulib for Solaris utimens workaround 2009-11-18 15:58:20 +01:00
Jim Meyering
630f4ba107 build: update gnulib submodule to latest 2009-11-18 07:33:02 +01:00
Jim Meyering
2fccfaab19 maint: remove local gnulib-related patches
* gl/lib/printf-args.c.diff: Remove file.  No longer needed.
* gl/lib/vasnprintf.c.diff: Likewise.
2009-11-17 21:44:37 +01:00
Jim Meyering
2b18a4c138 build: update gnulib for Solaris 10 unsetenv work-around 2009-11-17 21:44:30 +01:00
Jim Meyering
6609ccbf87 doc: mention the du/fts vs. NFSv4 mount-point work-around
* NEWS (Changes in behavior): Mention it.
2009-11-17 08:56:12 +01:00
Jim Meyering
d863533752 build: update from gnulib for (un)setenv fixes 2009-11-17 08:48:15 +01:00
Jim Meyering
bf5af9aef8 build: update gnulib submodule to latest 2009-11-16 11:37:09 +01:00
Jim Meyering
161e5120d4 true, false: perform initialization only when argc == 2
* src/true.c (main): There is no reason to examine argv[0],
call atexit, etc., in the usual case in which we're about to exit.
This has the side effect of making it so that these programs
no longer segfault when subjected to execve abuse.
Before this change, these commands would make "true" segfault:
  printf '%s\n' '#include <unistd.h>' 'int main(int c, char**v)' \
    '{ execve (v[1], 0, 0); }' > k.c && gcc k.c && ./a.out $PWD/true
Now it succeeds.  Reported by Tetsuo Handa and Bart Van Assche
via Ondřej Vašík in http://bugzilla.redhat.com/537684.
2009-11-16 09:30:50 +01:00
Jim Meyering
3b997a9bcb tail -F can fail to track a file after it's been rotated
Tailing forever and by-name (--follow=name, -F), tail would
sometimes fail to follow a file that had been removed via rename.
If you can't apply this patch and have tail 7.6 or newer, you can
work around the bug via the undocumented --disable-inotify option.
* src/tail.c (tail_forever_inotify): When tailing by name (-F),
do not un-watch a file upon receipt of the IN_MOVE_SELF event.
Reported by Arjan Opmeer in http://bugs.debian.org/548439.
* NEWS (Bug fixes): Mention it.
Also see http://marc.info/?l=coreutils-bug&m=125829031916515
* tests/Makefile.am (TESTS): Add tail-2/inotify-rotate.
* tests/tail-2/inotify-rotate: New test.
2009-11-16 09:30:43 +01:00
Jim Meyering
00f0cabaec tests: help-version: exit nonzero when $built_programs is empty
* tests/misc/help-version: Use "Exit 1", rather than "Exit $fail"
with fail defined to 0 when $built_programs is empty.
2009-11-14 15:01:44 +01:00
Jim Meyering
5cf6fb3b12 build: do use AM_GNU_GETTEXT's "need-formatstring-macros" option
* configure.ac: Revert commit 49741b61 and add a comment.
Reported by Eric Blake.
2009-11-14 15:01:44 +01:00
Pádraig Brady
9ed5048148 tests: avoid a spurious failure on a loaded system
* tests/misc/timeout-parameters: This test could fail due to
the 1-second timeout expiring before a command of "no_such"
could be exec'd and fail.  Increase to 10 seconds.
2009-11-14 13:53:17 +00:00
Jim Meyering
c3744b25f2 build: require gettext-0.17
* configure.ac: Require gettext-0.17; it was released two years ago.
2009-11-13 17:54:07 +01:00
Jim Meyering
49741b61b7 build: correct gettext configure-time support
* configure.ac: Use AM_GNU_GETTEXT([external], [need-ngettext]),
rather than AM_GNU_GETTEXT([external], [need-formatstring-macros]).
Reported by Martin Jacobs in
http://thread.gmane.org/gmane.comp.parsers.bison.bugs/3181
* THANKS: Add his name.
2009-11-13 17:54:07 +01:00
Jim Meyering
9a91b2a928 build: update gnulib to latest, for fixed test-getgroups.c 2009-11-13 16:39:11 +01:00
Jim Meyering
4c9e7e01fa tests: avoid a spurious timeout on a heavily-loaded system
* tests/misc/timeout-parameters: This test would fail due to
the 1-second timeout expiring before a command of "." could
be exec'd and fail.  Increase to 10 seconds.
2009-11-13 16:38:20 +01:00
Eric Blake
6a31fd8d73 build: update gnulib, for getgroups improvements
A replacement getgroups is now guaranteed to exist, but it may
fail with ENOSYS.  mgetgroups is moved to gnulib, and now takes
gid_t instead of GETGROUPS_T (but setgroups still needs GETGROUPS_T).

* gnulib: Update to latest.
* gl/modules/mgetgroups: Delete, moved to gnulib.
* gl/m4/mgetgroups.m4: Likewise.
* gl/lib/mgetgroups.h: Likewise.
* gl/lib/mgetgroups.c: Likewise.
* src/group-list.c (print_group_list): Adjust callers.
* src/id.c (print_full_info): Likewise.
2009-11-13 07:50:20 -07:00
Jim Meyering
719a95aa9d build: bootstrap: add a comment; generalize autoheader check
* bootstrap: Sync from gnulib and diff.
2009-11-12 09:51:54 +01:00
Jim Meyering
1313107c5c build: update gnulib to latest; more *BSD and Solaris work-arounds 2009-11-12 07:53:42 +01:00
Jim Meyering
cf1bc9810d bootstrap: use git_modules_config in one more place
* bootstrap: Make bootstrap's --gnulib-srcdir more useful (for testing).
2009-11-11 19:07:37 +01:00
Eric Blake
622cf39be6 doc: fix typo
* doc/coreutils.texi (mktemp invocation): Quote shell variable.
2009-11-10 05:56:22 -07:00
Jim Meyering
3aff3ed137 build: update gnulib submodule to latest for its FreeBSD fixes 2009-11-09 11:00:42 +01:00
Pádraig Brady
10d97b3191 ls: fix capability coloring
Capability checking was incorrectly done on just the base name
rather than on the whole path.  Consequently there could be both
false positives and negatives when coloring files with capabilities.
Also capability checking was not done at all in certain cases for
non executable files.  Note passing absolute rather than relative
names to cap_get_file() reduces the has_capability() overhead
from around 33% to 30%.  I.E. ls --color is now around 3% faster.

* src/ls.c (struct fileinfo): Add a has_capability member.
(print_color_indicator): Refactor to pass just a fileinfo pointer
and a flag to say if we're dealing with a symlink target.
(print_name_with_quoting): Likewise.
(gobble_file): Set has_capability in the fileinfo struct.  Also do
a capability check even if executable coloring is disabled.
Ditto for SETUID and SETUID coloring.
Comment on how expensive has_capability() is.
(print_long_format): Adjust to refactored print_name_with_quoting.
(quote_name): Likewise.
(print_file_name_and_frills): Likewise.
* tests/ls/capability: Test the various false positive and negatives.
* THANKS: Add reporter (Ivan Labath).
* NEWS: Mention the fix.
2009-11-09 08:16:20 +00:00
Eric Blake
56b85e035b build: consistently use freopen-safer
cat, head, ptx, shuf, tac, tail, tee, tr, and uniq used freopen
on stdout, and were potentially vulnerable.  dircolors, du, and
tsort only used it on stdin, which is unaffected by freopen_safer,
but this covers all uses for consistency.

* cfg.mk (sc_require_stdio_safer): New rule.
* gl/modules/xfreopen (Depends-on): Add freopen-safer.
* gl/lib/xfreopen.c (includes): Use stdio--.h.
* src/ptx.c (includes): Likewise.
* src/shuf.c (includes): Likewise.
* src/uniq.c (includes): Likewise.
* src/dircolors.c (includes): Likewise.
* src/du.c (includes): Likewise.
* src/tsort.c (includes): Likewise.
2009-11-07 10:10:28 -07:00
Eric Blake
c768e2231b mktemp: fix bug with -q and closed stdout
If stdin or stdout is closed, then freopen(,stderr) can violate
the premise that STDERR_FILENO==fileno(stderr), which in turn
breaks mktemp -q.

* bootstrap.conf (gnulib_modules): Add freopen-safer.
* src/mktemp.c (includes): Use stdio--.h.
* tests/misc/close-stdout: Enhance test to catch bug.
2009-11-07 10:10:25 -07:00
Jim Meyering
9a8d8f46a5 maint: make du's cycle-detection code consistent
* src/du.c (process_file): Revert the du.c-changing part of
commit 8ba5d1a7. Use cycle_warning_required instead.
2009-11-07 08:43:05 +01:00
Jim Meyering
d9dbbb9a45 chcon, chgrp, chmod and chown now diagnose a directory cycle
* lib/xfts.c (cycle_warning_required): New function.
* lib/xfts.h: Declare it.
* src/chown-core.c (change_file_owner): Diagnose a cycle.
* src/chmod.c (process_file): Likewise.
* src/chcon.c (process_file): Likewise.
* NEWS (Bug fixes): Mention this.
2009-11-07 08:43:00 +01:00
Giuseppe Scrivano
74cf4cb26d nproc: A new program to count the available processors
* AUTHORS: Add my name.
* NEWS: Mention it.
* README: Likewise.
* bootstrap.conf (gnulib_modules): Add nproc.
* doc/coreutils.texi (nproc invocation): Add nproc info.
* man/Makefile.am (nproc.1): Add dependency.
* man/nproc.x: New template.
* man/.gitignore: Ignore generated man page.
* po/POTFILES.in: Add src/nproc.c.
* src/.gitignore: Exclude nproc.
* src/Makefile.am (EXTRA_PROGRAMS): Add nproc.
* src/nproc.c: New file.
* tests/Makefile.am (TESTS): Add misc/nproc-{avail,positive}.
* tests/misc/nproc-avail: New file.
* tests/misc/nproc-positive: New file.
2009-11-06 16:54:12 +00:00
Jim Meyering
41456fac8a build: move do-release-commit-and-tag to gnulib
* bootstrap.conf (gnulib_modules): Add do-release-commit-and-tag.
* build-aux/do-release-commit-and-tag: Remove file.  Now it's in gnulib.
* gnulib: Update submodule to the latest, to get the just-moved script.
2009-11-06 11:20:16 +01:00
Eric Blake
dde83c27b4 mktemp: use more robust means to avoid double-close of stdout
Reverts earlier patch - fflush() can succeed but fclose() fail for
some cases of write failures, and we want to catch those.

* src/mktemp.c (stdout_closed): New variable.
(maybe_close_stdout): New function, borrowed from dd.c.
(main): Track whether stdout has been closed.
2009-11-05 13:12:35 -07:00
Eric Blake
20e5a0d562 mktemp: enhance test to catch just-fixed typo behavior
Penance for botching the conflict resolution while rebasing my series.

* tests/misc/mktemp (check_tmp): Test for the bug when wrong parameter
is used.
2009-11-05 13:12:33 -07:00
Jim Meyering
22e4276ed1 mktemp: don't try to close stdout twice
* src/mktemp.c (main): Rather than calling close_stream (which would
make atexit-called close_stdout try to close it a second time),
check for write failure via ferror and fflush.
2009-11-05 16:32:52 +01:00
Jim Meyering
25d2460ae3 mktemp: don't use suff_len in place of #-of-`X's variable
* src/mktemp.c (mkstemp_len, mkdtemp_len): Pass x_len as final
argument, and not suff_len.
2009-11-05 16:23:59 +01:00
Eric Blake
31a9937081 mktemp: add suffix handling
Now that mkstemps is supported, we might as well use it.

* src/mktemp.c (TMPDIR_OPTION): New enum value.
(longopts): Add new option.
(usage): Document it.
(count_trailing_X_s): Rename...
(count_consecutive_X_s): ...to this, and add parameter.
(mkstemp_len, mkdtemp_len): Add parameter.
(main): Implement new option.
(AUTHORS): Add myself.
* AUTHORS (mktemp): Likewise.
* tests/misc/mktemp: Test new option.
* doc/coreutils.texi (mktemp invocation): Document it.
* NEWS: Likewise.
Fixes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316.
2009-11-05 07:10:40 -07:00
Eric Blake
d431c61873 build: reflect gnulib changes to tempname
In glibc 2.11 and gnulib, gen_tempname added a parameter
suffixlen (unfortunately, it is typed as int rather than
size_t, for historical compatibility to a poor choice by BSD).

* gnulib: Import latest changes.
* gl/lib/tempname.h.diff: Accommodate new suffixlen parameter.
* gl/lib/tempname.c.diff (check_x_suffix): Allow for X in suffix
beyond x_suffix_len.
(gen_tempname_len): Add suffixlen parameter.
(__gen_tempname): Update caller.
* src/mktemp.c (mkstemp_len, mkdtemp_len): Update callers.
2009-11-05 07:00:52 -07:00
Eric Blake
5f29d118df build: override gnulib tempname via diff
Diffs are more robust than wholesale replacement, because bootstrap
will inform us of any incompatible changes made in upstream gnulib.

* gl/lib/tempname.h: Change...
* gl/lib/tempname.h.diff: ...to diff.
* gl/lib/tempname.c: Change...
* gl/lib/tempname.c.diff: ...to diff.
2009-11-05 06:59:21 -07:00
Eric Blake
0c5ae3a8ac mktemp: rearrange --help output
* src/mktemp.c (usage): Align indentation and sort by long
options.  Describe valid templates.
Suggested by http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548316.
2009-11-05 06:59:03 -07:00
Eric Blake
e89a5e9b13 tests: enhance mktemp test
* tests/misc/mktemp: Add more coverage.
2009-11-05 06:54:56 -07:00
Eric Blake
bcca26e838 doc: document mktemp
* doc/coreutils.texi (mktemp invocation): New node.
* TODO: Delete completed task.
2009-11-05 06:54:50 -07:00
Eric Blake
41b3a8ed8b mktemp: don't leave file behind on write failure
* src/mktemp.c (main): Remove just-created file if stdout had
problems.
* bootstrap.conf (gnulib_modules): Add remove.
* tests/misc/close-stdout: Test it.
* NEWS: Document it.
2009-11-05 06:53:21 -07:00
Jim Meyering
cd65f11c4f du: cleanup: remove dead-code vestige of already-removed option
* src/du.c (MEGABYTES_LONG_OPTION, main): Remove vestiges
of already-removed long option, --megabytes.
2009-11-05 08:37:12 +01:00
Jim Meyering
8ba5d1a70c du now diagnoses cycles, rather than ignoring them
* src/du.c (symlink_deref_bits): New global, decl moved from ...
(main): ...here.
(process_file): When fts detects a directory cycle that can't
be due to symlinks, report it and arrange to exit nonzero.
* NEWS (Bug fixes): Mention it.
2009-11-05 08:32:31 +01:00
Jim Meyering
38cb824673 maint: factor out cycle warning, now that du will use it, too
* src/system.h (emit_cycle_warning): Define.  Factored out of...
* src/remove.c (rm_fts): ...here.  Use the new macro.
2009-11-05 08:32:31 +01:00
Jim Meyering
d4b96c26ce tests: rm: add test for today's change in behavior
* tests/Makefile.am (root_tests): Add rm/read-only to the list.
* tests/rm/read-only: New file.
2009-11-03 14:48:10 +01:00
Jim Meyering
7bf2e3db23 rm -f: ignore EROFS when it's really ENOENT
rm -f must not print a diagnostic for a nonexistent file.  However,
most linux-based kernel unlinkat functions set errno to EROFS when
the named file (regardless of whether it exists) would lie on a
read-only file system.  remove.c now performs an extra fstatat call
in that case, to determine whether the file exists.
* src/remove.c (excise): Map EROFS to ENOENT, if a file is nonexistent.
Reported by Steven Drake in <http://savannah.gnu.org/bugs/?27923>.
* NEWS (Changes in behavior): Mention it.
2009-11-03 14:14:00 +01:00
Jim Meyering
87bf834dd3 tests: inotify-race: don't let malfunctioning gdb hang the test
* tests/tail-2/inotify-race: Apply timeout to each gdb invocation.
2009-11-03 14:14:00 +01:00
Eric Blake
8fe40b84bd build: avoid some warnings
* gl/lib/mbsalign.c (mbsalign): Mark unused parameter.
* bootstrap.conf (gnulib_modules): Remove obsolete
rename-dest-slash.
* gnulib-tests/Makefile.am (AM_CFLAGS): Reduce set of warnings for
gnulib tests.
* gl/modules/rename-tests.diff (Makefile.am): New file, to add
LIBINTL to LDADD, since we avoid canonicalize-lgpl module.
* gl/lib/regcomp.c.diff (regerror, calc_next)
(build_collating_symbol, parse_bracket_element, build_equiv_class)
(free_tree): Mark unused parameters.
* gl/lib/regex_internal.h.diff (re_string_elem_size_at): New file,
to mark unused parameters.
* gl/lib/printf-args.c.diff (PRINTF_FETCHARGS): New file, to avoid
type mismatch.
* gl/lib/vasnprintf.c (VASNPRINTF): New file, to avoid shadowing
local variable name.
* .gitignore: Ignore temporary build artifacts.
2009-11-02 06:34:24 -07:00
Eric Blake
565e5f6827 build: update gnulib submodule to latest, for fewer compiler warnings 2009-11-02 06:26:55 -07:00
Jim Meyering
6eb457eaba admin: automate one more part of the release process
This script automates the process of updating NEWS, performs
the resulting final commit (thus with a consistent log message),
and applies a signed tag (v$VERSION) to the result.
* build-aux/do-release-commit-and-tag: New script.
* README-release: Document it.
2009-10-31 11:08:03 +01:00
Jim Meyering
a276ba2dd4 admin: fix typo in release procedure
* README-release: s/gzip/coreutils/
2009-10-31 08:49:46 +01:00
Jim Meyering
71c2f88155 tests: prohibit fail=0 initialization
* cfg.mk (sc_prohibit_fail_0): New rule.
* .x-sc_prohibit_fail_0: New file.
* Makefile.am (syntax_check_exceptions): Distribute the new file.
2009-10-30 12:50:31 +01:00
Jim Meyering
3c88587b2e tests: factor 350 fail=0 initializations into test-lib.sh
Run this command to remove the factored-out "fail=0" lines.
perl -ni -e '/^fail=0$/ or print' $(g grep -l '^fail=0$')
* tests/test-lib.sh: Initialize fail=0 here, not in 300+ scripts.
* tests/...: nearly all bourne shell scripts
Suggested by Eric Blake.
2009-10-30 12:50:12 +01:00
Jim Meyering
12a0a583f6 tests: remove the less-regular fail=0 assignments manually
* tests/tail-2/assert-2:
* tests/tail-2/assert:
* tests/cp/file-perm-race:
* tests/misc/df:
* tests/misc/truncate-dir-fail:
2009-10-30 10:49:22 +01:00
Jim Meyering
39da66f979 tests: don't let a fail=1 env. setting induce unwarranted test failure
* cfg.mk (sc_fail_is_initialized): New rule.
Fix the offenders:
* tests/cp/acl: Set fail=0
* tests/cp/backup-is-src: Likewise.
* tests/cp/file-perm-race: Likewise.
* tests/cp/reflink-auto: Likewise.
* tests/cp/same-file: Likewise.
* tests/ln/backup-1: Likewise.
* tests/misc/su-fail: Likewise.
* tests/misc/truncate-owned-by-other: Likewise.
* tests/mkdir/p-3: Likewise.
* tests/mkdir/selinux: Likewise.
* tests/mkdir/special-1: Likewise.
* tests/mv/acl: Likewise.
* tests/mv/backup-is-src: Likewise.
* tests/mv/diag: Likewise.
* tests/mv/force: Likewise.
* tests/mv/hard-link-1: Likewise.
* tests/mv/into-self-3: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/touch/now-owned-by-other: Likewise.
2009-10-29 16:51:07 +01:00
Jim Meyering
22776f84cb remove stray closing comment delimiter, "*/", in previous change
* gl/lib/regexec.c.diff: Fix a typo.
2009-10-29 14:53:45 +01:00
Eric Blake
17b7d09bf2 maint: avoid exiting with magic number
Cope with gnulib's new sc_prohibit_magic_number_exit rule.

* .x-sc_prohibit_magic_number_exit: New file, to add exemptions.
* Makefile.am (syntax_check_exceptions): Distribute it.
* lib/euidaccess-stat.c (main): Fix culprits.
* src/chcon.c (main): Likewise.
* src/runcon.c (main): Likewise.
* src/setuidgid.c (main): Likewise.
2009-10-29 07:31:23 -06:00
Jim Meyering
f2859424cb build (--enable-gcc-warnings): enable gcc's -Werror also in lib/
* configure.ac (GNULIB_WARN_CFLAGS): Define.
* lib/Makefile.am (AM_CFLAGS): Use $(GNULIB_WARN_CFLAGS)
rather than $(WARN_CFLAGS) and add $(WERROR_CFLAGS).
* gl/lib/regcomp.c.diff: New file.
* gl/lib/regex_internal.c.diff: New file.
* gl/lib/regexec.c.diff: New file.
2009-10-29 08:14:42 +01:00
Jim Meyering
56a66d78ff build: update gnulib submodule to latest 2009-10-29 08:14:42 +01:00
Jim Meyering
e26cb21e6b build: allow whitespace violations in gl/lib/*.diff files
* .gitattributes: Exempt gl/lib/*.diff.
* .x-sc_prohibit_tab_based_indentation: Likewise.
* .x-sc_space_tab:Likewise.
2009-10-29 08:14:42 +01:00
Eric Blake
1c59bb3cef nice, nohup, su: detect write failure to stderr
These programs can print non-fatal diagnostics to stderr prior to
exec'ing a subsidiary program.  However, if we thought the situation
warranted a diagnostic, we insist that the diagnostic be printed
without error, rather than blindly exec, as it may be a security risk.

For an example, try 'nice -n -1 nice 2>/dev/full'.  Failure to raise
priority (by lowering niceness) is not fatal, but failure to inform
the user about failure to change priority is dangerous.

* src/nice.c (main): Declare failure if writing advisory message
to stderr fails.
* src/nohup.c (main): Likewise.
* src/su.c (main): Likewise.
* tests/misc/nice: Test this.
* tests/misc/nohup: Likewise.
* NEWS: Document this.
2009-10-28 21:12:41 -06:00
Jim Meyering
536a1fbe5f doc: tell --enable-gcc-warnings users where to report problems
* README-hacking: Add a caveat for --enable-gcc-warnings.
2009-10-28 18:13:44 +01:00
Jim Meyering
ce22916610 build: make doc checks more user-friendly
* doc/Makefile.am (check-texinfo): Begin moving each individual test
into its own rules.
(sc-avoid-builtin, sc-avoid-path): New rules.
Extracted from check-texinfo.
(syntax_checks): Add them.
2009-10-28 18:07:22 +01:00
Jim Meyering
da17f99b20 doc: avoid failing "make check"
* doc/coreutils.texi (env invocation): s/builtin/built-in/
2009-10-28 18:07:21 +01:00
Pádraig Brady
c07b181396 doc: improve the echo and printf help on escapes
* src/printf.c (usage): Merge strings with echo.c to
aid translators.  Move the description for \NNN beside
the other numeric escape codes.  Don't mention
"character" as that suggests character conversion.
* src/echo.c (usage): Likewise.
Also mention the \xHH escape sequence.
2009-10-28 17:01:29 +00:00
Pádraig Brady
2904d675a4 echo, printf: interpret \e as the Escape character
Match gcc, perl, bash, ksh, tcsh, ... in supporting \e.
* src/printf.c (print_escape_char): Output \x1B when \e encountered.
* src/echo.c (main): Likewise.
* src/stat.c (print_escape_char): Likewise.
* doc/coreutils.texi (echo invocation): Add \e to the list.
* tests/misc/printf: Verify that \e outputs \x1B.
* NEWS: Mention the change in behaviour.
2009-10-28 16:37:07 +00:00
Eric Blake
54491d2751 printenv: ignore bogus variable names
Exposed by env a=b=c printenv a=b.

* src/printenv.c (main): Silently reject = in names.
* tests/misc/printenv: Test for it.
* NEWS: Document this.
2009-10-28 06:24:52 -06:00
Pádraig Brady
42d12b45d3 maint: avoid "make syntax-check" failure
* src/printenv.c: Remove unused "long-options.h"
2009-10-28 11:50:54 +00:00
Eric Blake
75efc921b0 doc: turn env comments into documentation
* src/env.c: Convert introductory comments...
* doc/coreutils.texi (env invocation): ...into documentation.
Suggested by Jim Meyering.
2009-10-27 19:55:37 -06:00
Eric Blake
d6de2f198e env, printenv: add -0/--null option
Allows for unambiguous processing when environment values (or even
non-portable names!) contain newline.

* src/env.c (longopts): Add new option.
(usage): Document it.
(main): Implement it.
* src/printenv.c (longopts): New variable.
(usage): Document new option.
(main): Implement it.
* doc/coreutils.texi (Common options): New macro optNull.
(du invocation, env invocation, printenv invocation): Use it.
* NEWS: Mention this.
* tests/misc/env-null: New test.
* tests/Makefile.am (TESTS): Run it.
2009-10-27 19:55:35 -06:00
Eric Blake
1a81342089 tests: add printenv coverage
* tests/misc/printenv: New test.
* tests/Makefile.am (TESTS): Run it.
* .gitignore: Ignore more cruft.
2009-10-27 19:53:37 -06:00
Eric Blake
0cc0424119 tests: fix PATH problems on cygwin
* tests/misc/sort-compress: Remove non-portable over-restriction
of PATH; besides, commit 3ea177e changed sort to no longer default
to gzip.
* tests/rm/fail-eperm: Untaint, rather than clear, PATH.
* tests/misc/pwd-long: Likewise.  Also skip test if long path
cannot be created.
(normalize_to_cwd_relative): Use eq rather than ==, since cygwin
perl doesn't properly handle 64-bit ino_t numerically.
2009-10-27 18:53:44 -06:00
Eric Blake
f00bbe33e4 tests: clean up tests of env -- handling
The comment in env.c about -- handling has not matched the behavior
in the code since the initial commit back in 1992.

* src/env.c: Fix bogus comment.
* tests/misc/env: Further tweaks, avoiding PATH problems inherent
in testing -i, and testing program name containing =.
* doc/coreutils.texi (env invocation): Mention that intermediate
program is needed to invoke program with name containing =.
2009-10-26 21:30:34 -06:00
Eric Blake
0f3f6bf6bf doc: document PATH interactions with env
* doc/coreutils.texi (env invocation): Mention that PATH is
modified prior to exec.
* tests/misc/env: Test this.
2009-10-26 21:30:32 -06:00
Eric Blake
243f1b1c71 env: reject bogus -u arguments
* src/env.c (main): Use unsetenv rather than putenv to remove
items from environ, and check for failure.
* bootstrap.conf (gnulib_modules): Add unsetenv.
* tests/misc/env: Test this.
* NEWS: Document it.
2009-10-26 21:30:30 -06:00
Eric Blake
c6900474ef maint: let gnulib provide environ
* bootstrap.conf (gnulib_modules): Add environ.
* src/env.c (environ): Delete declaration.
* src/printenv.c (environ): Likewise.
* src/stdbuf.c (environ): Likewise.
* src/su.c (environ): Likewise.
2009-10-26 21:30:28 -06:00
Eric Blake
dae24f5ffc tests: avoid file name not portable to cygwin
* tests/misc/chroot-fail: Use 'no_such', not '...', since cygwin
1.5 silently strips trailing dots.
* tests/misc/nice-fail: Likewise.
* tests/misc/stdbuf: Likewise.
* tests/misc/timeout-parameters: Likewise.
2009-10-26 06:05:44 -06:00
Jim Meyering
c695781753 tests: rm/one-file-system: work around umount failure
* tests/rm/one-file-system (cleanup_): Unmount a/b, rather than
"$other_partition_tmpdir", to accommodate those who link /etc/mtab
to /proc/mounts.  Reported by Gilles Espinasse in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18508
2009-10-26 10:21:25 +01:00
Jim Meyering
d9cf7c911f tests: adjust new env test not to fail
* tests/misc/env: Create ./-i as a link to our "echo" binary,
rather than as a bourne shell script, so that env can exec it.
Set PATH to ".".
2009-10-26 09:59:32 +01:00
Jim Meyering
50e837b1c4 tests: nice: adjust new tests to work more portably
* tests/misc/nice (tests): Accommodate a nice program for which
"nice -n -1 nice" prints nothing.  It should print -1 or (usually) 0.
Otherwise, we'd get syntax errors.
2009-10-26 08:25:34 +01:00
Jim Meyering
501bf7b589 nice: execute program even when setpriority fails due to EACCES
* src/nice.c (perm_related_errno): New function.
(main): Use it, rather than testing only errno == EPERM.
* NEWS (Bug fixes): Mention it.
2009-10-26 08:25:34 +01:00
Pádraig Brady
69fbfd400c timeout: don't orphan monitored programs if they ignore specified signals
* src/timeout.c (install_signal_handlers): Handle any user
specified signal, so that if it does not cause the child
to exit then we don't exit and orphan the child. Previously this
for example, would leave an orphan dd process running:
timeout -sUSR1 1s dd if=/dev/zero of=/dev/null
* NEWS: Mention the fix.
2009-10-25 23:28:38 +00:00
Eric Blake
30e4b6e84b tests: test recent status changes
* tests/misc/nice: Enhance test.
* tests/misc/chroot-fail: New test.
* tests/misc/env: Likewise.
* tests/misc/nice-fail: Likewise.
* tests/misc/su-fail: Likewise.
* tests/Makefile.am (TESTS): Run new tests.
2009-10-23 16:32:26 -06:00
Eric Blake
2122247aca maint: move chroot test
* tests/chroot/credentials: Move...
* tests/misc/chroot-credentials: ...here, to reduce number of
directories.
* tests/Makefile.am (root_tests): Reflect rename.
2009-10-23 16:31:34 -06:00
Eric Blake
bd933c1250 tests: enhance stdbuf and timeout tests
* tests/misc/timeout-parameters: Validate exact exit status.
* tests/misc/stdbuf: Likewise.
* tests/misc/timeout: Likewise.  Use require_built_.
* tests/misc/arch: Likewise.
2009-10-23 16:31:23 -06:00
Eric Blake
1ce9e1e5ca nohup: use EXIT_CANCELED if not POSIXLY_CORRECT
* src/nohup.c (NOHUP_FAILURE): Rename...
(POSIX_NOHUP_FAILURE): ...to this.
(main): Pay attention to POSIXLY_CORRECT, to determine whether to
use status 125 or 127.
* doc/coreutils.texi (nohup invocation): Document this.
* NEWS: Likewise.
* tests/misc/invalid-opt (exit_status): Adjust expected results.
* tests/misc/help-version (expected_failure_status): Likewise.
* tests/misc/nohup: Likewise.
2009-10-23 16:24:08 -06:00
Eric Blake
b6540b96ba chroot, env, nice, su: use EXIT_CANCELED for internal failure
* src/chroot.c (main): Use EXIT_CANCELED, not EXIT_FAILURE.
* src/env.c (main): Likewise.
* src/nice.c (main): Likewise.
* src/su.c (change_identity, main): Likewise.
* doc/coreutils.texi (chroot invocation, env invocation)
(nice invocation, su invocation): Document this.
* NEWS: Likewise.
* tests/misc/invalid-opt (exit_status): Adjust expected results.
* tests/misc/help-version (expected_failure_status): Likewise.
2009-10-23 16:24:05 -06:00
Eric Blake
97777f559a tests: accommodate BSD getopt
* tests/misc/invalid-opt (err_subst): Support alternate spelling.
2009-10-23 16:24:02 -06:00
Eric Blake
c0dcf3238b build: prohibit improper use of stat and lstat
* cfg.mk (sc_prohibit_stat_macro_address): New rule.
* src/ln.c (do_link): Adjust comment to avoid false positive.
* src/stat.c (do_stat): Likewise.
* src/touch.c (main): Likewise.
2009-10-23 06:29:54 -06:00
Eric Blake
a08e13a0fb build: update gnulib submodule to latest, for test cleanups 2009-10-22 21:25:39 -06:00
Eric Blake
5e361387d0 maint: turn on compiler warnings for gnulib tests
* gnulib-tests/Makefile.am (AM_CFLAGS): Add WARN_CFLAGS.
* configure.ac (enable-gcc-warnings): Also use -funit-at-a-time,
to silence gcc 4.3.4 -Wdisabled-optimization.
* .gitignore: Ignore some more files.
2009-10-22 08:05:09 -06:00
Jim Meyering
cbf36952d8 build: prohibit direct use of readlink or readlinkat
* cfg.mk (sc_prohibit_readlink): New rule.
Suggested by Eric Blake.
2009-10-22 12:12:24 +02:00
Giuseppe Scrivano
029b6b14c5 tests: add a test for the `tail -f' race condition bug
If new data becomes available between the initial read and when tail
registers the inotify watch descriptors, ensure that it is read
before a new event happens on the file.
* tests/Makefile.am (TESTS): Add tail-2/inotify-race.
* tests/tail-2/inotify-race: New file.
2009-10-22 10:25:58 +02:00
Giuseppe Scrivano
cd0f3036f6 tail -f: avoid a race condition
* NEWS (Bug fixes): Mention it.
* src/tail.c (check_fspec): New function.
(tail_forever_inotify): Ensure there is no new data before entering the
inotify events wait loop.
2009-10-22 09:11:24 +02:00
Eric Blake
9abbe32c2e build: update gnulib submodule to latest, for utimens enhancements 2009-10-21 21:44:56 -06:00
Eric Blake
54645c195c tests: ensure touch honors trailing slash
* tests/touch/trailing-slash: New test.
* tests/Makefile.am (TESTS): Run it.
2009-10-21 20:45:27 -06:00
Pádraig Brady
710fe413fe md5sum, sha*sum, sum: line-buffer the printed checksums
* src/md5sum.c (main): Set stdout to line buffered mode
to ensure parallel running instances don't intersperse
their output.  This adds 5% to the run time in the worst case
of many zero length files, or 2% with standard file sizes.
* src/sum.c (main): Likewise.
* tests/misc/md5sum-parallel: New test for atomic output.
* tests/Makefile.am: Reference it.
* NEWS: Mention the fix
2009-10-21 16:56:00 +01:00
Pádraig Brady
71adb516de maint: issue warnings for more missing optional libraries
* README-hacking: Suggest to use ./configure --quiet so that
any warnings are easily noticed.
* m4/gmp.m4 (cu_GMP): Warn if libgmp is not available.
* m4/jm-macros.m4 (coreutils_MACROS): Normalize the libcap warning.
* m4/xattr.m4 (gl_FUNC_XATTR): Warn if libattr is not available.
2009-10-20 17:11:00 +01:00
Jim Meyering
6ac6c7e4b7 build: use gnulib's isblank module
* bootstrap.conf (gnulib_modules): Add isblank.
* src/system.h (isblank): Don't define.
* m4/check-decl.m4: Don't check for isblank declaration.
* gnulib: Update submodule to latest.
2009-10-19 07:57:15 +02:00
Jim Meyering
f26508204b maint: factor out duplication in currently unused rules
* src/Makefile.am (fs_normalize_perl_subst): Define.
(fs-magic, fs-kernel-magic): Use it.
2009-10-18 10:26:15 +02:00
Eric Blake
9e13b6a0b4 touch: add -h to change symlink timestamps, where supported
* src/touch.c (no_dereference): New flag variable.
(longopts): Add -h/--no-dereference.
(touch): Add symlink handling.
(usage): Document new option.
(main): Accept new option.
* NEWS: Document it.
* doc/coreutils.texi (touch invocation): Likewise.  Also mention
birthtime.
* tests/touch/no-dereference: New test.
* tests/Makefile.am (TESTS): Run it.
2009-10-17 14:36:28 -06:00
Jim Meyering
527fb951de tests: abmon-align: avoid test failure
* tests/ls/abmon-align: Don't remove (1d;) the first line of output.
That was making the test consider only 11 of 12 month names.
Rewrite not to use \(.*\), as that provoked a malfunction in GNU sed
on powerpc Mac OS X (though we don't know yet whether this is due to a
sed bug, or to miscompilation).  Nelson Beebe reported the test failure.
2009-10-17 12:21:52 +02:00
Jim Meyering
f8653f2af3 build: update gnulib submodule to latest 2009-10-17 12:20:41 +02:00
Jim Meyering
2fa407885c build: don't let environment settings perturb build
Setting the envvars, LIB_FDATASYNC, LIB_XATTR or LIB_CRYPT
could cause a configure-time and/or build-time malfunction.
Typically, a configure-time function-in-library test is performed
via code like this:

  LIB_VAR=
  AC_SUBST([LIB_VAR])
  prefix_saved_LIBS=$LIBS
    AC_SEARCH_LIBS([FUNC], [LIB_NAME],
                   [test "$ac_cv_search_FUNC" = "none required" ||
                    LIB_VAR=$ac_cv_search_FUNC])
  LIBS=$prefix_saved_LIBS

However, in each of the files affected by this change, the LIB_VAR=
initialization was omitted.  Thus, when set in the environment, its
value would propagate into generated Makefiles when FUNC is not found
in LIB_NAME.
* m4/jm-macros.m4 (coreutils_MACROS): Initialize AC_SUBST'd var
* m4/lib-check.m4 (cu_LIB_CHECK): Likewise.
* m4/xattr.m4 (gl_FUNC_XATTR): Likewise.
2009-10-15 21:03:40 +02:00
C de-Avillez
b3cfa712ca tail: add add missing backslash at the end of a line in usage
* src/tail.c (usage): Add missing backslash at the end of a line.
2009-10-13 11:20:20 +02:00
Eric Blake
f25273d7f1 tail: tweak usage for more clarity
* src/tail.c (usage): Spell out -n +K.
* THANKS: Update.
Reported by Jan-Pawel Wrozstinski.
2009-10-12 07:00:12 -06:00
Eric Blake
26e8e602a8 touch: optimize use of utimens
* src/touch.c (main): Use UTIME_NOW rather than calling gettime.
(touch): Use UTIME_OMIT rather than stat.
2009-10-10 15:16:55 -06:00
Eric Blake
7280a913a1 copy: allow symlink timestamp preservation on more systems
* src/copy.c (utimens_symlink): Simplify by using lutimens.
* m4/jm-macros.m4 (coreutils_MACROS): Drop utimensat; gnulib does
this for us.
* tests/cp/preserve-slink-time: Recognize lutimes support.
2009-10-10 15:16:52 -06:00
Eric Blake
7ff00ca82f build: update gnulib submodule to latest, for utimens improvements 2009-10-10 15:16:50 -06:00
Jim Meyering
f7b1873805 tests: adjust tail-2/pid to work around FreeBSD 6.1 failure
* tests/tail-2/pid: Run tail -f --pid=... on an actual file, not on
/dev/null, to avoid this failure on FreeBSD 6.1: tail: /dev/null:
cannot change nonblocking mode: Inappropriate ioctl for device
2009-10-10 15:05:09 +02:00
Eric Blake
c2bebf63ed maint: touch up previous LDADD patch
* src/Makefile.am (dir_LDADD): Delete; the ls_LDADD line covers this.
2009-10-10 06:28:40 -06:00
Jim Meyering
d74a1b005c build: build uname(1) unconditionally
Before, on a system without the uname function, the build
system would detect that and not build/install a uname program.
Now that gnulib guarantees a uname function, ...
* configure.ac: Don't check for the uname function.
* src/Makefile.am (build_if_possible__progs): Move uname...
(EXTRA_PROGRAMS): ...to this list.
2009-10-10 09:03:15 +02:00
Jim Meyering
4f1a3eda10 maint: list program names one per line
* src/Makefile.am (EXTRA_PROGRAMS): List them one per line.
(build_if_possible__progs): Likewise.
2009-10-10 08:58:43 +02:00
Jim Meyering
c9e7b8844b build: ls: fix link failure due to missing -lacl
* src/Makefile.am (ls_LDADD): Re-add $(LIB_ACL).
Inadvertently-removed by commit 78c93601.
2009-10-10 08:24:02 +02:00
Eric Blake
219f2f0538 maint: touch up previous LDADD patch
* src/Makefile.am (stdbuf_LDADD): Add missing primer.
(hostname_LDADD, uname_LDADD): Add GETHOSTNAME_LIB.
* bootstrap.conf (gnulib_modules): Add uname.
2009-10-09 20:08:03 -06:00
Eric Blake
78c9360178 maint: improve additional library tracking
* src/Makefile.am (LDADD): Refactor, to make per-library additions
to individual programs easier to maintain.
2009-10-09 19:28:07 -06:00
Jim Meyering
0023f65fd7 chcon: don't disable just because SELinux is disabled
* src/chcon.c (main): Now that gnulib provides getfilecon wrappers,
we can revert most of the 2009-10-05 commit 3a97d664, "chcon: exit
immediately if SELinux is disabled", since chcon is still useful as
long as the file system provides handlers for the security.*
name space.  gnulib's getfilecon wrappers ensure that an offending
context now evokes a return value of -1.
Prompted by comments from Stephen Smalley in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18394
* NEWS (Bug fixes): Mention it.
2009-10-09 14:33:10 +02:00
Jim Meyering
57d9263ca5 ls: remove explicit getfilecon work-around
* src/ls.c (gobble_file): Remove l?getfilecon work-around,
now that the gnulib wrappers handle it for us.
2009-10-09 14:33:10 +02:00
Jim Meyering
e11a0319b3 build: update gnulib submodule to latest, for getfilecon wrappers 2009-10-09 14:33:10 +02:00
Eric Blake
c039c96449 maint: use X2NREALLOC in more places
* src/chroot.c (set_additional_groups): Use X2NREALLOC rather than
x2nrealloc.
* src/factor.c (emit_factor): Likewise.
* src/setuidgid.c (main): Likewise.
2009-10-08 20:30:08 -06:00
Eric Blake
aa092ccf6a maint: remove unused macros and declarations
* src/system.h (EDQUOT, EISDIR, ENOSYS, EOVERFLOW, F_OK, X_OK)
(W_OK, R_OK): Delete; macros provided by gnulib.
(includes): Gnulib guarantees both <time.h> and <sys/time.h>, in
either order.
(free, malloc, memchr, realloc, getenv, lseek): Delete, gnulib
guarantees these declarations.
* m4/check-decl.m4 (gl_CHECK_DECLS): Delete checks now done by
gnulib.
2009-10-08 20:30:06 -06:00
Eric Blake
2a876d901d maint: move timeout exit statuses
* src/timeout.c (EXIT_TIMEDOUT, EXIT_CANCELED): Remove as
macros...
* src/system.h (EXIT_TIMEDOUT, EXIT_CANCELED): ...and provide as
enum values instead.
* src/stdbuf.c (EXIT_CANCELED): Delete.
2009-10-08 20:30:03 -06:00
Eric Blake
a797c4d7d3 stat: test recent patch
* tests/misc/stat-slash: New test.
* tests/Makefile.am (TESTS): Run it.
2009-10-08 20:30:00 -06:00
Eric Blake
7a3bc1bf27 stdbuf: improve path search
* src/stdbuf.c (set_program_path): Use gnulib methods for better
file name handling.
* bootstrap.conf (gnulib_modules): Add xreadlink.
2009-10-08 06:52:18 -06:00
Eric Blake
00674c7475 stat: work with recent gnulib changes
* src/stat.c (do_stat): Don't mask function-like stat macro.
2009-10-08 06:52:15 -06:00
Jim Meyering
eb5f06f2a6 stat: add support for many more file system types
* src/stat.c (human_fstype): Add the following FS types,
from <linux/magic.h>: afs, anon-inode FS, btrfs, cgroupfs,
cramfs-wend, debugfs, futexfs, inotifyfs, minux3, securityfs,
selinux, xenfs.
Also add "nilfs".
* src/Makefile.am (fs-kernel-magic): New rule.
* NEWS (Bug fixes): Mention this.
2009-10-08 10:18:28 +02:00
Jim Meyering
8e32390716 stat: recognize CIFS and HFS file system types
* src/stat.c (human_fstype) [CIFS, HFS]: Add new file system types.
Prompted by a report from Stuart Kemp.
Normalize the form of a few hexadecimal magic numbers.
Alphabetize on S_MAGIC_ case names.
* src/Makefile.am (fs-magic-compare, fs-def, fs-magic): New rules, to
automate comparison of our list with that in the Linux statfs man page.
* NEWS (Bug fixes): Mention it.
2009-10-08 09:07:12 +02:00
Guenter Knauf
b95be30e3f md5sum, sha*sum: also accept openssl checksum syntax
* src/md5sum.c (split_3): Accept openssl checksum syntax, which
differs only by two spaces from that of the bsd checksum tools:
openssl: MD5(f)= d41d8cd98f00b204e9800998ecf8427e
bsd:     MD5 (f) = d41d8cd98f00b204e9800998ecf8427e
2009-10-07 09:31:27 +02:00
Jim Meyering
d183a15cbb maint: make release-making instructions more generic
* README-release: Make instructions more generic.
2009-10-06 16:49:36 +02:00
Jim Meyering
96829a9ff0 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2009-10-06 13:20:18 +02:00
Jim Meyering
ca1e31f3c5 version 8.0
* NEWS: Record release date.
2009-10-06 13:04:16 +02:00
Jim Meyering
3c40fdfba6 build: update gnulib submodule to latest 2009-10-06 11:15:54 +02:00
Ondřej Vašík
3a97d664b9 chcon: exit immediately if SELinux is disabled
This change happens to avoid an abort in chcon when SELinux is
disabled while operating on a file with an "unlabeled" context from
back in 2006.  However, that same abort can still be triggered by the
same file when running chcon with SELinux enabled.  This bug in chcon
will be fixed in a subsequent commit via a getfilecon wrapper.  See
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/18378/focus=18384
for how to correct your disk attributes to avoid triggering this bug.
* src/chcon.c (main): Exit immediately if SELinux is disabled.
Reported in http://bugzilla.redhat.com/527142 by Yanko Kaneti.
* src/runcon.c (main): Do not hardcode program name in error message.
* THANKS: Update.
2009-10-06 10:10:51 +02:00
Jim Meyering
addb62da92 build: update gnulib submodule to latest 2009-10-03 06:56:55 +02:00
James R. Van Zandt
569df689e3 dircolors: highlight .cgm and .emf as images
* src/dircolors.hin: Add .cgm, .emf.
* THANKS: Update.
2009-10-02 10:58:05 -06:00
Jim Meyering
df0c0381ab maint: remove obsolete syntax-check exclusion
* cfg.mk (local-checks-to-skip): Remove strftime-check.
2009-10-02 15:48:08 +02:00
Pádraig Brady
f8726e05c4 tail: avoid a race where we could miss new data with --pid
* src/tail.c (tail_forever, tail_forever_inotify): Close a race in
tail_forever_inotify where new data written after the file check by
a now dead process, but before the pid check, is not output.  We use
the POSIX guarantee that read() and write() are serialized wrt each
other even in separate processes, to assume full file consistency
after exit() and so poll for new data _after_ the writer has exited.
This also allows us to not redundantly _wait_ for new data if the
process is dead.
* tests/tail-2/pid: Remove the now partially invalid sub second sleep
check as we now don't unconditionally wait, and replace it with a check
for the redundant sleep.  Also clarify some of the existing comments.
* NEWS: Mention the fix.
2009-10-02 14:00:06 +01:00
Jim Meyering
95c01c656e maint: move gnu-web-doc-update script to gnulib
* bootstrap.conf (gnulib_modules): Add gnu-web-doc-update.
Remove gendocs, since gnu-web-doc-update depends on it.
* gnu-web-doc-update: Remove file, now that we get it from gnulib.
2009-10-02 12:10:21 +02:00
Jim Meyering
8a7f66feb4 build: update gnulib submodule to latest 2009-10-02 12:10:21 +02:00
Jim Meyering
30a227673e tests: tail-2/pid: use a 3-second timeout, not 1
* tests/tail-2/pid: When using the timeout program to ensuring that
tail -s.1 --pid=$PID_T_MAX does not wait forever, use a timeout longer
than 1 second.  A 1-second timeout could be too short on a very busy
system, and result in a timeout, and hence false-positive failure.

2009-09-30  Jim Meyering  <meyering@redhat.com>
2009-09-30 23:28:13 +02:00
Jim Meyering
dd8db19cc7 build: update gnulib submodule to latest 2009-09-30 17:46:42 +02:00
Jim Meyering
569e387b8a build: translate diagnostics from two new files
* po/POTFILES.in: Add two new files: lib/siglist.h, lib/strsignal.c
2009-09-30 17:04:29 +02:00
Jim Meyering
9ca7d6b49e build: now that we use the lock module, don't exclude lock.m4
* bootstrap.conf: Don't exclude lock.m4.
2009-09-30 17:04:29 +02:00
Pádraig Brady
d4c7114bce ls: always print "?" for allocated size of a dereferenced dangling symlink
Previously for `ls -Ls` (but not `ls -Lsl`), we referenced
the st_blocks returned from the previous failed stat() call.
This undefined value was seen to be 0 for dangling symlinks at least.
* src/ls.c (print_file_name_and_frills, length_of_file_name_and_frills):
Don't use st_blocks if the previous stat() failed
* tests/ls/dangle: Add a test case
* NEWS: Mention the fix, and roll up related items into a single entry.
2009-09-30 15:42:35 +01:00
Jim Meyering
ce1069c215 build: use gnulib's freopen module
* bootstrap.conf (gnulib_modules): Add freopen, strsignal, fsync.
Exposed via make CFLAGS=-DGNULIB_POSIXCHECK 2>&1 \
|perl -lne '/.* use gnulib module (\S+).*/ and print $1' \
|sort |uniq -c|sort -nr
(avoided_gnulib_modules): Don't avoid the "lock" module.
Now it's required, as a dependency of the strsignal module.
2009-09-30 09:39:48 +02:00
Jim Meyering
a033e28737 stat: interpret "-" as standard input
* src/stat.c (do_stat): Interpret a command line argument of "-"
to mean "standard input", like many other tools do.
(do_statfs): Fail upon any attempt to use "-".
* NEWS (Changes in behavior): Mention it.
* tests/misc/stat-hyphen: New test, to exercise the above.
* tests/Makefile.am (TESTS): Add misc/stat-hyphen.
2009-09-29 16:04:12 +02:00
Jim Meyering
b7aaa0da8b ls: don't use an undefined struct stat after failed stat/lstat
* src/ls.c (format_inode): Access f->stat only if f->stat_ok is set.
* NEWS (Bug fixes): Mention it.
Improved-by: Pádraig Brady <P@draigBrady.com>
2009-09-29 14:12:30 +02:00
Jim Meyering
36edf7bad2 ls: print "?", not "0" as inode of dereferenced dangling symlink
ls prints inode numbers two ways: for long (-l) listings,
and for short ones, e.g., ls -li and ls -i.  The code to print
long listings properly printed "?" when the inode was unknown,
but the code for handling short listings would print 0 instead.
Factor out the formatting code into a new function so ls prints
the right string ("?") from both places:
* NEWS (Bug fixes): Mention it.
* src/ls.c (format_inode): New function.
(print_long_format): Use it here.
(print_file_name_and_frills): Use it here, too.
* tests/ls/dangle: Exercise this fix.
Reported by Yang Ren in http://bugzilla.redhat.com/525400
2009-09-29 11:42:45 +02:00
Jim Meyering
242689c7f9 ls: with -LR, exit with status 2 upon detecting a cycle
* src/ls.c (print_dir): Diagnosing the cycle is not enough.
Also set exit status to 2.  This is what Solaris' /bin/ls does, too.
* tests/ls/infloop: Rework test: match both expected stdout and stderr.
Require an exit status of 2 in this case.
* doc/coreutils.texi (ls invocation): Mention that a loop provokes
in an exit status of 2.
* NEWS (Bug fixes): Mention it.
Reported by Yang Ren in http://bugzilla.redhat.com/525402.
* THANKS: Correct ordering of Yang Ren's names.
2009-09-29 07:28:39 +02:00
Jim Meyering
30c65cd49c maint: factor coreutils-specific code out of bootstrap
* bootstrap (bootstrap_epilogue): Define a default, empty function.
Remove coreutils-specific code, and instead,
invoke this new function at the end of this script.
* bootstrap.conf (bootstrap_epilogue): Define, to override the default.
2009-09-26 14:45:50 +02:00
Eric Blake
ca9e212cf8 cp, mv: use linkat to guarantee semantics
* src/copy.c (copy_internal): Use linkat, not link.
2009-09-25 07:03:36 -06:00
Eric Blake
efcee783e4 ln: add -L/-P options
* src/ln.c (STAT_LIKE_LINK): Delete.
(logical): New flag.
(long_options): Add -L, -P.
(usage): Mention them.
(main): Choose between them.
(do_link): Perform correct action.
* tests/ln/misc: Move hard-to-sym portion of test...
* tests/ln/hard-to-sym: ...into new test, and add more.
* tests/Makefile.am (TESTS): Run new test.
* NEWS: Document this.
* doc/coreutils.texi (link invocation, ln invocation): Likewise.
* bootstrap.conf (gnulib_modules): Add linkat.
2009-09-25 07:03:03 -06:00
Eric Blake
fb59d72f0a build: update gnulib submodule to latest 2009-09-24 19:40:31 -06:00
Pádraig Brady
a037e838e1 maint: Use logical rather than bitwise operators on bools
This is because bitwise operators are:
- confusing and inconsistent in a boolean context
- non short circuiting
- brittle in C89 where bool can be an int (so > 1)
2009-09-23 14:33:40 +01:00
Pádraig Brady
ade8dd2096 maint: expr: avoid compiler warnings without GMP
* src/expr.c (mpz_clear, mpz_get_str, mpz_out_str)
[!HAVE_GMP]: Reference unused arguments.
2009-09-23 14:32:07 +01:00
Eric Blake
0cce690850 build: update gnulib submodule to latest 2009-09-23 06:47:46 -06:00
Eric Blake
82124c3c06 maint: summarize gnulib changes
* NEWS: Provide a blurb about recent gnulib improvements.  Fix typo
in readlink blurb.
2009-09-23 06:45:07 -06:00
Jim Meyering
38f1c2006e doc: ls: further improve --help message re --color
* src/ls.c (usage): Correct grammar, change voice, shorten.
Inspired by a report from Bruno Schulenberg.
2009-09-23 09:11:08 +02:00
Eric Blake
8a1edc971f readlink: pick up gnulib changes to readlink -f
* bootstrap.conf (obsolete_gnulib_modules): Move rename...
(gnulib_modules): ...here.  Add symlink.
* NEWS: Document the change in readlink.
* doc/coreutils.texi (readlink invocation): Likewise.
* tests/readlink/can-f: Update test to new semantics, and add test
of loop.
2009-09-23 08:45:08 +02:00
Jim Meyering
70253e9179 maint: df.c: adapt to newer gnulib
* src/df.c: Don't include "canonicalize.h".  No longer needed,
since canonicalize_file_name is now guaranteed to be declared
in <stdlib.h>, thanks to gnulib.
2009-09-23 08:38:00 +02:00
Jim Meyering
b18b6912e8 build: update gnulib submodule to latest 2009-09-23 08:37:59 +02:00
Pádraig Brady
fbfca3c675 doc: stdbuf: mention it can have a non standard exit status
* doc/coreutils.texi (Exit status): Add stdbuf to the list
2009-09-22 12:22:47 +01:00
Pádraig Brady
7a404d10f5 maint: uptime: fix a theoretical compile warning
* src/uptime.c (print_uptime) [!HAVE_UTMPX_H && !HAVE_UTMP_H]:
Reference possibly unused arguments.
2009-09-22 12:21:00 +01:00
Pádraig Brady
8c92bb3441 ls: fix a performance regression
* src/ls.c (print_color_indicator): This reinstates commit f3f1ccfd,
21-10-2008, "ls: make it possible to disable file capabilities checking"
which was inadvertently reverted with commit 3a169f4c, 14-09-2009,
"ls: handle disabling of colors consistently ...".
2009-09-22 10:07:21 +01:00
Eric Blake
32f987af12 build: avoid compiler warnings on cygwin 1.5
* src/copy.c (utimens_symlink): Avoid unused variables.
* src/su.c (getusershell): Rely on gnulib for prototype.
2009-09-21 20:42:16 -06:00
Jim Meyering
fee8694886 doc: ls: add an article, "the"
* src/ls.c (usage): Tweak wording.
2009-09-21 15:30:38 +02:00
Pádraig Brady
3a169f4c5d ls: handle disabling of colors consistently for all tile types
* src/ls.c (print_color_indicator): Use consistent syntax for
all file and directory subtypes, and fall back to the color
of the base type if there is no enabled color for the subtype.
This allows turning off specific colors for o+w dirs for example.
* tests/ls/color-dtype-dir: Add a case to test that turning off
coloring for o+w directories, falls back to standard dir color.
* NEWS: Mention the fix
Introduced by commit ac467814, 2005-09-05,
"Colorize set-user-ID ... files and sticky ... directories."
2009-09-21 13:16:44 +01:00
Pádraig Brady
29ec834c3b doc: ls: make help for --color more concise and accurate
* src/ls.c (usage): Shorten the --color ancillary info by
two lines, while replacing --color=none with --color=never.
Mention "always" is the default parameter of the --color option,
along with the primary help for that option.
Mention the ancillary --color info in the --color primary help.
2009-09-21 12:44:35 +01:00
Pádraig Brady
9837344837 doc: normalize and add missing entries to texinfo menu
* doc/coreutils.texi: Add the missing arch, base64, link, readlink,
and unlink entries.  Also remove extraneous '.' from some entries
and try to align all entries on the same column.
* THANKS: Add Benno Schulenberg.
2009-09-21 12:42:19 +01:00
Pádraig Brady
5d4f09d83a doc: mention the texinfo documentation in --help
* src/system.h: Rename emit_bug_reporting_address() to
emit_ancillary_info() and update it to not print the translation
project address in en_* locales, and _do_ print it in the 'C'
(and other) locales so that it's included in the default man page.
Also mention how to invoke the texinfo documentation for each command.
Also move the "hard-locale.h" include to the 8 files that now use it.
* man/help2man: Strip the newly added texinfo reference from the
--help output as a more verbose version is already added by help2man.
Suggestion from C de-Avillez
2009-09-21 12:37:57 +01:00
Jim Meyering
c48003a53c maint: automate the web-doc updating procedure
* gnu-web-doc-update: New script, destined for gnulib.
* README-release: Refer to the new script.
2009-09-21 08:56:17 +02:00
Jim Meyering
a2883947bc dircolors: arrange to highlight names with the .lz suffix
* src/dircolors.hin: Add .lz, for GNU lzip.
Suggested by Matias A. Fonzo.
2009-09-19 12:26:41 +02:00
Jim Meyering
99f59aaaf8 mktemp: adapt to new, 3-argument gen_tempname_len
* src/mktemp.c (mkstemp_len, mkdtemp_len): Update callers of
gen_tempname_len.
* gl/lib/tempname.c, gl/lib/tempname.h: Rebase against recently
API-modified copy of tempname module in gnulib.
Reported by Lluís Batlle.
2009-09-19 11:16:56 +02:00
Jim Meyering
6504d7e193 build: merge bootstrap changes from gnulib
* bootstrap: Update from gnulib.
2009-09-17 14:30:01 +02:00
Eric Blake
2bad8c0dea rm, rmdir: improve cross-compilation support
* bootstrap.conf (gnulib_modules): Drop rmdir-errno.
* src/rmdir.c (errno_rmdir_non_empty): Check both cases allowed by
POSIX, rather than relying on configure-time check that might
fail during cross-compilation.  Reverts commit 9b6eb98d41.
2009-09-16 21:26:58 -06:00
Ondřej Vašík
fe6f4e305c cp: fix a probably redundant chmod when setting xattrs
* src/copy.c (copy_reg): Fix initial value of access_changed variable.
This was introduced by Pádraig Brady in commit cca83faf, 2009-09-14,
"cp,mv: preserve extended attributes even for read-only files"
2009-09-15 10:51:13 +01:00
Jim Meyering
a77fb35364 doc: NEWS: mention origin of touch -t ....60 bug
* NEWS: It is an old bug.
2009-09-14 15:57:13 +02:00
Jim Meyering
94eca76776 doc: touch, document that it accepts .60
* doc/coreutils.texi (touch invocation): Document that SS may be 60.
2009-09-14 15:37:26 +02:00
Jim Meyering
20761ce686 touch: don't reject "60" as number of seconds in a legacy time stamp
A valid command like "touch -t 197101010000.60 F" would fail due
to the suffix of ".60".  This bug is fixed via the latest change
to gnulib's posixtm module.
* tests/touch/60-seconds: New test.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
2009-09-14 15:27:51 +02:00
Jim Meyering
df84346ebc build: update gnulib submodule to latest, for fixed posixtm module 2009-09-14 15:27:51 +02:00
Jim Meyering
71bac0dac3 maint: use #!/bin/sh consistently in shell-based test scripts
* tests/misc/sort-continue: Change first line to standard #!/bin/sh,
not #!/bin/bash (though it doesn't matter, since each is invoked
via $(SHELL) dir/test-name.
2009-09-14 15:27:02 +02:00
Pádraig Brady
d41dbb187f tests: fix dd/skip-seek-past-file to work on ecryptfs
* tests/dd/skip-seek-past-file: Require sparse support
to ensure that when we're checking if we can create an
$OFF_T_MAX length file, that we don't actually allocate
any space.  This was an issue on ecryptfs and was reported
by Bert Wesarg.
2009-09-14 14:22:02 +01:00
Ondřej Vašík
cca83fafa6 cp,mv: preserve extended attributes even for read-only files
* src/copy.c (copy_reg): Temporarily set u+rw on the destination file
to allow GNU/Linux to set xattrs.
* tests/misc/xattr: Test that change.
* NEWS (Bug fixes): Mention it.
Reported by Ernest N. Mamikonyan.
2009-09-14 14:19:03 +01:00
Jim Meyering
eb1299481a doc: improve timeout's --help message
* src/timeout.c (usage): Improve --help description.
2009-09-14 09:18:30 +02:00
Jim Meyering
255a6a201e maint: use consistent cpp indentation in all .c files
* src/stty.c: Make cpp indentation reflect nesting.
* src/factor.c: Likewise.
2009-09-13 22:05:37 +02:00
Jim Meyering
f6f78f093b doc: NEWS: say quadratic and linear, rather than O(N^2) and O(N)
* NEWS: Use a slightly less technical description.
Suggested by Andreas Schwab.
2009-09-13 12:11:57 +02:00
Jim Meyering
21b617b78b doc: improve NEWS
* NEWS (rm -r, without -f): Mention that the N in "O(N)" represents
hierarchy depth.  Suggested by Ralf Wildenhues.
(rm -r, standards conformance): Make wording more accurate.
2009-09-13 11:58:48 +02:00
Jim Meyering
ebbf0a1f0f id: don't print context=... when POSIXLY_CORRECT is set
* src/id.c (print_full_info) [POSIXLY_CORRECT]: Don't print context.
Reported by Ulrich Drepper.
* NEWS (Changes in behavior): Mention it.
* doc/coreutils.texi (id invocation): Document that id also prints the
security context, when possible, and when POSIXLY_CORRECT is not set.
* tests/id/no-context: New file.  Test for this.
* tests/Makefile.am (TESTS): Add it.
2009-09-11 19:58:18 +02:00
Eric Blake
398749b0cc rm: avoid compiler warning
* src/remove.c (rm_fts): Don't allow fall-through when assertions
are disabled.
2009-09-11 14:08:58 +02:00
Eric Blake
e5dba03d2f euidaccess-stat: remove unnecessary macros
* lib/euidaccess-stat.c (F_OK, R_OK, W_OK, X_OK): Delete; now
guaranteed by gnulib.
2009-09-11 14:08:58 +02:00
Eric Blake
c756343503 rm: use gnulib faccessat
* bootstrap.conf (gnulib_modules): Add faccessat.  Replace strdup
with strdup-posix.
* m4/jm-macros.m4 (coreutils_MACROS): Revert previous change, now
that gnulib does it for us.
* src/remove.c (write_protected_non_symlink): Use faccessat in
more situations.
2009-09-11 14:08:58 +02:00
Jim Meyering
722287e443 rm: improve efficiency of rm -r (without -f) from O(N^2) to O(N)
where N is the depth of the deepest hierarchy rm is processing.
* src/remove.c (write_protected_non_symlink): Use faccessat to
avoid O(N)-per-entry cost of calling euidaccess.
* m4/jm-macros.m4 (coreutils_MACROS): Check for faccessat.
* NEWS (Improvements): Mention it.
2009-09-11 14:08:58 +02:00
Jim Meyering
9966c92dd4 build: placate gcc's new -Wskip-jump-init
* remove.c (rm_fts): Put braces around each of the two offending blocks.
* configure.ac: Don't turn off -Wjump-misses-init.
With the rewrite of remove.c, it is no longer needed.
2009-09-11 14:08:58 +02:00
Jim Meyering
4f73ecaf7d rm: rewrite to use fts
* remove.c: Don't include "unlinkdir.h"; no longer used.
Do not include <setjmp.h> or "cycle-check.h".  Likewise.
Include "xfts.h".
(dir_name, dir_len): Remove definitions.
(CONSECUTIVE_READDIR_UNLINK_THRESHOLD): Likewise.
(INODE_SORT_DIR_ENTRIES_THRESHOLD, NEED_REWIND, D_TYPE): Likewise.
(struct dirstack_state, Dirstack_state): Likewise.
(g_buf, g_n_allocated): Remove declarations.
(hash_freer, hash_compare_strings, rm_malloc): Remove functions.
(rm_free, push_dir, top_dir, pop_dir, right_justify): Likewise.
(full_filename0, xfull_filename, full_filename_): Likewise.
(AD_stack_height, AD_stack_top, AD_stack_pop, AD_stack_clear): Likewise.
(obstack_init_minimal, ds_init, ds_clear, ds_free): Likewise.
(AD_pop_and_chdir, AD_ensure_initialized, AD_mark_helper): Likewise.
(AD_mark_as_unremovable, AD_mark_current_as_unremovable): Likewise.
(AD_push_initial, AD_push, AD_push, AD_is_removable): Likewise.
(write_protected_non_symlink): Change 3rd parameter from
dirstack_state "ds" to full_name.
(prompt): Adjust parameters.  Now, state comes from FTS/FTSENT pair.
Those replace fd_cwd and "ds".  Remove "filename".  Remove pdirent_type
in favor of new "is_dir" parameter.  Rename is_empty to is_empty_p.
(DO_RMDIR, DO_UNLINK): Remove definitions.
(remove_entry, fd_to_subdirp, compare_ino): Remove functions.
(dirent_count, dirent_inode_sort_may_be_useful): Likewise.
(preprocess_dir): Likewise.
(fts_skip_tree, mark_ancestor_dirs, excise, rm_fts): New functions.
(remove_cwd_entries, remove_dir, rm_1): Remove functions.
(rm): Rewrite as a simple loop calling fts_read and dispatching
each entry via rm_fts.
* src/rm.c (main): Adapt to new signature of rm().
* bootstrap.conf (gnulib_modules): Remove unlinkdir, no longer used.
* src/Makefile.am (sc_tight_scope): Also recognize an extern "enum"
declaration.
* tests/rm/empty-name: Adjust expected output to match new diagnostic.
* NEWS (Improvements): Mention it.
2009-09-11 14:08:51 +02:00
Jim Meyering
880a6e7723 maint: doc: adjust README-release
* README-release: Remove mention of bootstrap's old
--gnulib-srcdir=/gnulib option.  No longer needed, and its
use can lead to subtle problems.
2009-09-11 13:14:07 +02:00
Jim Meyering
bd11475627 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2009-09-11 08:16:18 +02:00
506 changed files with 4593 additions and 3669 deletions

2
.gitattributes vendored
View File

@@ -5,3 +5,5 @@
# # Derived from the regexp in emacs' lisp/add-log.el.
# [diff "texinfo"]
# funcname = "^@node[ \t][ \t]*\\([^,][^,]*\\)"
gl/lib/*.diff -whitespace

5
.gitignore vendored
View File

@@ -3,6 +3,7 @@
*.o
*/.deps
*~
._bootmp
.gdb-history
.kludge-stamp
.tarball-version
@@ -47,11 +48,13 @@ lib/arpa
lib/binary-io.h
lib/charset.alias
lib/configmake.h
lib/glthread
lib/libcoreutils.a
lib/printf.c
lib/progname.c
lib/progname.h
lib/selinux
lib/unistr
lib/uniwidth
m4/.cvsignore
m4/.gitignore
@@ -72,3 +75,5 @@ src/version.c
src/version.h
stamp-h1
tests/*/*.log
tests/t?
tests/test-suite.log

View File

@@ -1 +1 @@
7.5
8.0

3
.x-sc_prohibit_fail_0 Normal file
View File

@@ -0,0 +1,3 @@
\.mk$
/Makefile\.am$
^tests/test-lib\.sh$

View File

@@ -0,0 +1,3 @@
configure.ac
*.m4
ChangeLog*

View File

@@ -4,3 +4,4 @@ Makefile\.am$
^tests/pr/
ChangeLog.*
^man/help2man$
^gl/lib/.*\.c\.diff$

View File

@@ -9,3 +9,4 @@ m4/lib-prefix.m4
m4/po.m4
aclocal.m4
src/c99-to-c89.diff
^gl/lib/.*\.c\.diff$

View File

@@ -46,11 +46,12 @@ md5sum: Ulrich Drepper, Scott Miller, David Madore
mkdir: David MacKenzie
mkfifo: David MacKenzie
mknod: David MacKenzie
mktemp: Jim Meyering
mktemp: Jim Meyering, Eric Blake
mv: Mike Parker, David MacKenzie, Jim Meyering
nice: David MacKenzie
nl: Scott Bartram, David MacKenzie
nohup: Jim Meyering
nproc: Giuseppe Scrivano
od: Jim Meyering
paste: David M. Ihnat, David MacKenzie
pathchk: Paul Eggert, David MacKenzie, Jim Meyering

View File

@@ -47,6 +47,8 @@ syntax_check_exceptions = \
.x-sc_po_check \
.x-sc_program_name \
.x-sc_prohibit_atoi_atof \
.x-sc_prohibit_fail_0 \
.x-sc_prohibit_magic_number_exit \
.x-sc_prohibit_stat_st_blocks \
.x-sc_prohibit_strcmp \
.x-sc_prohibit_tab_based_indentation \

171
NEWS
View File

@@ -1,5 +1,176 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.1 (2009-11-18) [stable]
** Bug fixes
chcon no longer exits immediately just because SELinux is disabled.
Even then, chcon may still be useful.
[bug introduced in coreutils-8.0]
chcon, chgrp, chmod, chown and du now diagnose an ostensible directory cycle
and arrange to exit nonzero. Before, they would silently ignore the
offending directory and all "contents."
env -u A=B now fails, rather than silently adding A to the
environment. Likewise, printenv A=B silently ignores the invalid
name. [the bugs date back to the initial implementation]
ls --color now handles files with capabilities correctly. Previously
files with capabilities were often not colored, and also sometimes, files
without capabilites were colored in error. [bug introduced in coreutils-7.0]
md5sum now prints checksums atomically so that concurrent
processes will not intersperse their output.
This also affected sum, sha1sum, sha224sum, sha384sum and sha512sum.
[the bug dates back to the initial implementation]
mktemp no longer leaves a temporary file behind if it was unable to
output the name of the file to stdout.
[the bug dates back to the initial implementation]
nice -n -1 PROGRAM now runs PROGRAM even when its internal setpriority
call fails with errno == EACCES.
[the bug dates back to the initial implementation]
nice, nohup, and su now refuse to execute the subsidiary program if
they detect write failure in printing an otherwise non-fatal warning
message to stderr.
stat -f recognizes more file system types: afs, cifs, anon-inode FS,
btrfs, cgroupfs, cramfs-wend, debugfs, futexfs, hfs, inotifyfs, minux3,
nilfs, securityfs, selinux, xenfs
tail -f (inotify-enabled) now avoids a race condition.
Before, any data appended in the tiny interval between the initial
read-to-EOF and the inotify watch initialization would be ignored
initially (until more data was appended), or forever, if the file
were first renamed or unlinked or never modified.
[The race was introduced in coreutils-7.5]
tail -F (inotify-enabled) now consistently tails a file that has been
replaced via renaming. That operation provokes either of two sequences
of inotify events. The less common sequence is now handled as well.
[The bug came with the implementation change in coreutils-7.5]
timeout now doesn't exit unless the command it is monitoring does,
for any specified signal. [bug introduced in coreutils-7.0].
** Changes in behavior
chroot, env, nice, and su fail with status 125, rather than 1, on
internal error such as failure to parse command line arguments; this
is for consistency with stdbuf and timeout, and avoids ambiguity
with the invoked command failing with status 1. Likewise, nohup
fails with status 125 instead of 127.
du (due to a change in gnulib's fts) can now traverse NFSv4 automounted
directories in which the stat'd device number of the mount point differs
during a traversal. Before, it would fail, because such a mismatch would
usually represent a serious error or a subversion attempt.
echo and printf now interpret \e as the Escape character (0x1B).
rm -f /read-only-fs/nonexistent now succeeds and prints no diagnostic
on systems with an unlinkat syscall that sets errno to EROFS in that case.
Before, it would fail with a "Read-only file system" diagnostic.
Also, "rm /read-only-fs/nonexistent" now reports "file not found" rather
than the less precise "Read-only file system" error.
** New programs
nproc: Print the number of processing units available to a process.
** New features
env and printenv now accept the option --null (-0), as a means to
avoid ambiguity with newlines embedded in the environment.
md5sum --check now also accepts openssl-style checksums.
So do sha1sum, sha224sum, sha384sum and sha512sum.
mktemp now accepts the option --suffix to provide a known suffix
after the substitution in the template. Additionally, uses such as
"mktemp fileXXXXXX.txt" are able to infer an appropriate --suffix.
touch now accepts the option --no-dereference (-h), as a means to
change symlink timestamps on platforms with enough support.
* Noteworthy changes in release 8.0 (2009-10-06) [beta]
** Bug fixes
cp --preserve=xattr and --archive now preserve extended attributes even
when the source file doesn't have write access.
[bug introduced in coreutils-7.1]
touch -t [[CC]YY]MMDDhhmm[.ss] now accepts a timestamp string ending in .60,
to accommodate leap seconds.
[the bug dates back to the initial implementation]
ls --color now reverts to the color of a base file type consistently
when the color of a more specific type is disabled.
[bug introduced in coreutils-5.90]
ls -LR exits with status 2, not 0, when it encounters a cycle
ls -is is now consistent with ls -lis in ignoring values returned
from a failed stat/lstat. For example ls -Lis now prints "?", not "0",
for the inode number and allocated size of a dereferenced dangling symlink.
tail --follow --pid now avoids a race condition where data written
just before the process dies might not have been output by tail.
Also, tail no longer delays at all when the specified pid is not live.
[The race was introduced in coreutils-7.5,
and the unnecessary delay was present since textutils-1.22o]
** Portability
On Solaris 9, many commands would mistakenly treat file/ the same as
file. Now, even on such a system, path resolution obeys the POSIX
rules that a trailing slash ensures that the preceeding name is a
directory or a symlink to a directory.
** Changes in behavior
id no longer prints SELinux " context=..." when the POSIXLY_CORRECT
environment variable is set.
readlink -f now ignores a trailing slash when deciding if the
last component (possibly via a dangling symlink) can be created,
since mkdir will succeed in that case.
** New features
ln now accepts the options --logical (-L) and --physical (-P),
added by POSIX 2008. The default behavior is -P on systems like
GNU/Linux where link(2) creates hard links to symlinks, and -L on
BSD systems where link(2) follows symlinks.
stat: without -f, a command-line argument of "-" now means standard input.
With --file-system (-f), an argument of "-" is now rejected.
If you really must operate on a file named "-", specify it as
"./-" or use "--" to separate options from arguments.
** Improvements
rm: rewrite to use gnulib's fts
This makes rm -rf significantly faster (400-500%) in some pathological
cases, and slightly slower (20%) in at least one pathological case.
rm -r deletes deep hierarchies more efficiently. Before, execution time
was quadratic in the depth of the hierarchy, now it is merely linear.
However, this improvement is not as pronounced as might be expected for
very deep trees, because prior to this change, for any relative name
length longer than 8KiB, rm -r would sacrifice official conformance to
avoid the disproportionate quadratic performance penalty. Leading to
another improvement:
rm -r is now slightly more standards-conformant when operating on
write-protected files with relative names longer than 8KiB.
* Noteworthy changes in release 7.6 (2009-09-11) [stable]
** Bug fixes

2
README
View File

@@ -11,7 +11,7 @@ The programs that can be built with this package are:
csplit cut date dd df dir dircolors dirname du echo env expand expr
factor false fmt fold groups head hostid hostname id install join kill
link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup
od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir
nproc od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir
runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf
sleep sort split stat stdbuf stty su sum sync tac tail tee test timeout
touch tr true truncate tsort tty uname unexpand uniq unlink uptime users

View File

@@ -35,7 +35,7 @@ which are extracted from other source packages:
And there you are! Just
$ ./configure #[--enable-gcc-warnings]
$ ./configure --quiet #[--enable-gcc-warnings] [*]
$ make
$ make check
@@ -48,6 +48,12 @@ should output no difference.
Enjoy!
[*] The --enable-gcc-warnings option is useful only with glibc
and with a very recent version of gcc. You'll probably also have
to use recent system headers. If you configure with this option,
and spot a problem, please be sure to send the report to the bug
reporting address of this package, and not to that of gnulib, even
if the problem seems to originate in a gnulib-provided file.
-----
Copyright (C) 2002-2009 Free Software Foundation, Inc.

View File

@@ -7,19 +7,18 @@ Here are most of the steps we (maintainers) follow when making a release.
* Run ./configure && make maintainer-clean
* Ensure that the desired versions of autoconf, automake, bison, etc.
are in your PATH. See HACKING for the complete list.
are in your PATH. See the buildreq list in bootstrap.conf for
the complete list.
* Ensure that you're on "master" with no uncommitted diffs.
This should produce no output: git checkout master; git diff
* Make sure your local gnulib directory is up to date.
* Run bootstrap, (assuming your local copy of gnulib is in /gnulib):
./bootstrap --gnulib-srcdir=/gnulib
* Run bootstrap: ./bootstrap
FIXME: enable excluded programs like arch? to get their manual pages?
* Pre-release testing:
Ensure that make check syntax-check succeeds.
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
run all tests, both root-only and regular.
Run *all* non-root tests, including expensive and very expensive ones i.e.,
@@ -30,19 +29,17 @@ FIXME: enable excluded programs like arch? to get their manual pages?
* Run "make distcheck"
* Manually set the date, version number, and [stable/alpha/beta] on
line 3 of NEWS, then do e.g.,:
* Set the date, version number, and release type [stable/alpha/beta] on
line 3 of NEWS, commit that, and tag the release by running e.g.,
v=7.3
git commit -F <(printf 'version '$v'\n\n* NEWS: Record release date.\n') -a
git tag -s -m "coreutils $v" v$v HEAD
build-aux/do-release-commit-and-tag 8.1 beta
* Run the following to create release tarballs. Your choice selects the
corresponding upload-to destination in the emitted gnupload command.
The different destinations are specified in cfg.mk. See the definitions
of gnu_ftp_host-{alpha,beta,major}.
of gnu_ftp_host-{alpha,beta,stable}.
# "TYPE" must be major, beta or alpha
# "TYPE" must be stable, beta or alpha
make TYPE
* Test the tarball. copy it to a few odd-ball systems and ensure that
@@ -60,12 +57,15 @@ Once all the builds and tests have passed,
that they're all valid.
* Push the new tag:
git push origin tag v<JUST_RELEASED_VERSION_NUMBER>
v=$(cat .prev-version)
git push origin tag v$v
* Send the gpg-signed announcement mail, e.g.,
To: info-gnu@gnu.org, coreutils-announce@gnu.org
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
Subject: coreutils-7.1 released [stable]
Subject: coreutils-8.0 released [beta]
* Approve the announcement here:
http://lists.gnu.org/mailman/admindb/coreutils-announce
@@ -74,25 +74,21 @@ Once all the builds and tests have passed,
From here:
https://savannah.gnu.org/projects/coreutils/
click on the "submit news", then write something like the following:
(If there is no such button, then enable "News" for the project via
the Main -> "Select Features" menu item, or via this link:
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=coreutils)
Subject: coreutils-7.2 released [stable]
Subject: coreutils-0.0 released [beta]
The announcement is here:
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/49
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/54
Then go here to approve it:
https://savannah.gnu.org/news/approve.php?group=coreutils
* For non-alpha releases, update the on-line manual at
* After each non-alpha release, update the on-line manual accessible via
http://www.gnu.org/software/coreutils/manual/
Run `make web-manual', then copy the contents of doc/manual
into a CVS checkout of the coreutils manual repository.
Also edit coreutils.html (FIXME? why?) before doing a CVS commit.
by running this:
CVS_RSH=ssh \
cvs -d:ext:$USER@cvs.savannah.gnu.org:/web/coreutils co coreutils
Be sure to "cvs add -ko" any files that "cvs status" marks with "?".
That is necessary whenever a new texinfo node is added. Each becomes
a new file in html_node that must then be "cvs add"ed.
build-aux/gnu-web-doc-update

17
THANKS
View File

@@ -52,6 +52,7 @@ Andy Longton alongton@metamark.com
Anthony Thyssen anthony@griffith.edu.au
Antonio Rendas ajrendas@yahoo.com
Ariel Faigon ariel@cthulhu.engr.sgi.com
Arjan Opmeer arjan.opmeer@gmail.com
Arne H. Juul arnej@solan.unit.no
Arne Henrik Juul arnej@imf.unit.no
Arnold Robbins arnold@skeeve.com
@@ -66,8 +67,9 @@ Barry Kelly http://barrkel.blogspot.com/
Bauke Jan Douma bjdouma@xs4all.nl
Ben Elliston bje@air.net.au
Ben Harris bjh21@netbsd.org
Benjamin Cutler cutlerbc@simla.colostate.edu
Bengt Martensson bengt@mathematik.uni-Bremen.de
Benjamin Cutler cutlerbc@simla.colostate.edu
Benno Schulenberg bensberg@justemail.net
Bernard Giroud bernard.giroud@creditlyonnais.ch
Bernd Eckenfels ecki@debian.org
Bernd Leibing bernd.leibing@rz.uni-ulm.de
@@ -209,6 +211,7 @@ Geoff Whale geoffw@cse.unsw.EDU.AU
Gerald Pfeifer gerald@pfeifer.com
Gerhard Poul gpoul@gnu.org
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
Gilles Espinasse g.esp@free.fr
Glen Lenker glen.lenker@gmail.com
Göran Uddeborg goeran@uddeborg.se
Guochun Shi gshi@ncsa.uiuc.edu
@@ -245,12 +248,14 @@ Ian Turner vectro@pipeline.com
Iida Yosiaki iida@gnu.org
Ilya N. Golubev gin@mo.msk.ru
Ingo Saitz ingo@debian.org
Ivan Labath labath3@st.fmph.uniba.sk
Ivo Timmermans ivo@debian.org
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Lemley James.Lemley@acxiom.com
James Hunt jamesodhunt@hotmail.com
James Ralston ralston@pobox.com
James R. Van Zandt jrvz@comcast.net
James Sneeringer jvs@ocslink.com
James Tanis jtt@soscorp.com
James Youngman jay@gnu.org
@@ -260,6 +265,7 @@ Jan Engelhardt jengelh@medozas.de
Jan Fedak J.Fedak@sh.cvut.cz
Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
Jan-Pawel Wrozstinski jpwroz@gmail.com
Janos Farkas chexum@shadow.banki.hu
Jarkko Hietaniemi jhi@epsilon.hut.fi
Jarod Wilson jwilson@redhat.com
@@ -334,6 +340,7 @@ Leah Q eequor@earthlink.net
Lehti Rami rammer@cs.tut.fi
Leonard N. Zubkoff lnz@dandelion.com
Leonardo Milano lmilano@udel.edu
Lluís Batlle viriketo@gmail.com
Lorne Baker lbaker@nitro.avint.net
Luke Hassell lukehassell@yahoo.com
Luke Kendall lukekendall@optushome.com.au
@@ -365,6 +372,7 @@ Martin martin@dresden.nacamar.de
Martin Buck martin.buck@ascom.ch
Martin Gallant martyg@goodbit.net
Martin Hippe martin.hippe@schlund.de
Martin Jacobs martin.jacobs@arcor.de
Martin Michlmayr tbm@cyrius.com
Martin Mitchell martin@debian.org
Martin P.J. Zinser zinser@decus.de
@@ -372,6 +380,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com
Masami Takikawa takikawm@CS.ORST.EDU
Mate Wierdl mw@moni.msci.memphis.edu
Matej Vela mvela@public.srce.hr
Matias A. Fonzo selk@dragora.org
Matt Kraai kraai@ftbfs.org
Matt Perry matt@primefactor.com
Matt Pham mattvpham@gmail.com
@@ -393,7 +402,7 @@ Max Chang maxchang@ucla.edu
Meelis Roos mroos@tartu.cyber.ee
Michael michael@aplatform.com
Michael ??? michael@roka.net
Michael Bacarella mbac@netgraft.com>
Michael Bacarella mbac@netgraft.com
Michael Deutschmann michael@talamasca.ocis.net
Michael Elizabeth Chastain mec.gnu@mindspring.com
Michael Gaughen mgaughen@polyserve.com
@@ -490,7 +499,7 @@ Ralph Loader loader@maths.ox.ac.uk
Raul Miller moth@magenta.com
Raúl Núñez de Arenas Coronado raul@pleyades.net
Reuben Thomas rrt@sc3d.org
Ren Yang ryang@redhat.com
Yang Ren ryang@redhat.com
Richard A Downing richard.downing@bcs.org.uk
Richard Braakman dark@xs4all.nl
Richard Dawe rich@phekda.freeserve.co.uk
@@ -535,6 +544,7 @@ Stephen Smoogen smooge@mindspring.com
Steve McConnel steve@acadcomp.sil.org
Steve McIntyre steve@einval.com
Steve Ward planet36@gmail.com
Steven Drake sbd@users.sourceforge.net
Steven G. Johnson stevenj@alum.mit.edu
Steven Mocking ufo@quicknet.nl
Steven Parkes smparkes@smparkes.net
@@ -608,6 +618,7 @@ Wis Macomson wis.macomson@intel.com
Wojciech Purczynski cliph@isec.pl
Wolfram Kleff kleff@cs.uni-bonn.de
Won-kyu Park wkpark@chem.skku.ac.kr
Yanko Kaneti yaneti@declera.com
Yann Dirson dirson@debian.org
Zvi Har'El rl@math.technion.ac.il

1
TODO
View File

@@ -12,7 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime
Discussed more recently on <http://bugs.debian.org/497514>.
document the following in coreutils.texi:
mktemp
[
pinky

View File

@@ -70,6 +70,10 @@ gnulib_modules=
# Any gnulib files needed that are not in modules.
gnulib_files=
# A function to be called after everything else in this script.
# Override it via your own definition in bootstrap.conf.
bootstrap_epilogue() { :; }
# The command to download all .po files for a specified domain into
# a specified directory. Fill in the first %s is the domain name, and
# the second with the destination directory. Use rsync's -L and -r
@@ -150,12 +154,18 @@ vc_ignore=auto
# find_tool ENVVAR NAMES...
# -------------------------
# Search for a required program. Use the value of ENVVAR, if set,
# otherwise find the first of the NAMES that can be run (i.e.,
# supports --version). If found, set ENVVAR to the program name,
# die otherwise.
find_tool ()
{
# Find sha1sum, named gsha1sum on MacPorts.
find_tool_envvar=$1
shift
if eval test x"\$$find_tool_envvar" = x; then
find_tool_names=$@
eval "find_tool_res=\$$find_tool_envvar"
if test x"$find_tool_res" = x; then
for i
do
if ($i --version </dev/null) >/dev/null 2>&1; then
@@ -163,16 +173,18 @@ find_tool ()
break
fi
done
else
find_tool_error_prefix="\$$find_tool_envvar: "
fi
if test x"$find_tool_res" = x; then
echo >&2 "$0: $find_tool_name is required"
echo >&2 "$0: one of these is required: $find_tool_names"
exit 1
fi
($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
echo >&2 "$0: cannot run $find_tool_res --version"
echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
exit 1
}
eval "$find_tool_envvar=\"$find_tool_res\""
eval "$find_tool_envvar=\$find_tool_res"
eval "export $find_tool_envvar"
}
@@ -405,7 +417,7 @@ case ${GNULIB_SRCDIR--} in
git_modules_config submodule.gnulib.url >/dev/null; then
git submodule init
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
echo "$0: getting gnulib files..."
git submodule update || exit $?
GNULIB_SRCDIR=gnulib
@@ -721,6 +733,10 @@ find "$m4_base" "$source_base" \
# Reconfigure, getting other files.
# Skip autoheader if it's not needed.
grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
AUTOHEADER=true
for command in \
libtool \
"${ACLOCAL-aclocal} --force -I m4" \
@@ -789,10 +805,6 @@ if test $with_gettext = yes; then
fi
fi
# Horrible, coreutils-specific kludges.
# Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
m=gnulib-tests/gnulib.mk
sed 's,\.\./\.\.,..,g' $m > $m-t
mv -f $m-t $m
bootstrap_epilogue
echo "$0: done. Now you can run './configure'."

View File

@@ -20,7 +20,6 @@
avoided_gnulib_modules='
--avoid=canonicalize-lgpl
--avoid=dummy
--avoid=lock
'
# These modules are obsolete and can probably be removed soon,
@@ -31,7 +30,6 @@ obsolete_gnulib_modules='
memcpy
memmove
memset
rename
strcspn
strtod
strtol
@@ -73,11 +71,14 @@ gnulib_modules="
diacrit
dirfd
dirname
do-release-commit-and-tag
dup2
environ
error
euidaccess
exclude
exitfail
faccessat
fchdir
fcntl
fcntl-safer
@@ -90,12 +91,14 @@ gnulib_modules="
fnmatch-gnu
fopen-safer
fprintftime
freopen
freopen-safer
fseeko
fsusage
fsync
ftello
ftruncate
fts
gendocs
getdate
getgroups
gethrxtime
@@ -113,6 +116,7 @@ gnulib_modules="
git-version-gen
gitlog-to-changelog
gnu-make
gnu-web-doc-update
gnumakefile
gnupload
group-member
@@ -126,12 +130,14 @@ gnulib_modules="
inttostr
inttypes
isapipe
isblank
lchmod
lchown
lib-ignore
linebuffer
link
link-follow
linkat
long-options
lstat
maintainer-makefile
@@ -154,6 +160,7 @@ gnulib_modules="
modechange
mountlist
mpsort
nproc
obstack
pathmax
perl
@@ -176,9 +183,9 @@ gnulib_modules="
readutmp
realloc
regex
rename-dest-slash
remove
rename
rmdir
rmdir-errno
root-dev-ino
rpmatch
safe-read
@@ -197,20 +204,23 @@ gnulib_modules="
stdlib-safer
stpcpy
stpncpy
strdup
strdup-posix
strftime
strpbrk
strsignal
strtoimax
strtoumax
strverscmp
symlink
sys_stat
timespec
tzset
uname
unicodeio
unistd-safer
unlink-busy
unlinkdir
unlocked-io
unsetenv
update-copyright
uptime
useless-if-before-free
@@ -235,6 +245,7 @@ gnulib_modules="
xnanosleep
xprintf
xprintf-posix
xreadlink
xstrtod
xstrtoimax
xstrtol
@@ -291,7 +302,6 @@ if test $gettext_external = 1; then
m4/glibc2.m4
m4/intdiv0.m4
m4/lcmessage.m4
m4/lock.m4
m4/uintmax_t.m4
m4/ulonglong.m4
m4/visibility.m4
@@ -318,3 +328,11 @@ tar -
# Automake requires that ChangeLog exist.
touch ChangeLog || exit 1
bootstrap_epilogue()
{
# Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
m=gnulib-tests/gnulib.mk
sed 's,\.\./\.\.,..,g' $m > $m-t
mv -f $m-t $m
}

35
cfg.mk
View File

@@ -31,7 +31,7 @@ url_dir_list = \
gpg_key_ID = B9AB9A16
# Tests not to run as part of "make distcheck".
local-checks-to-skip = strftime-check
local-checks-to-skip =
# Tools used to bootstrap this package, used for "announcement".
bootstrap-tools = autoconf,automake,gnulib,bison
@@ -39,7 +39,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = 93ff8e5850f630855f9e834fec416830
old_NEWS_hash = 785e51bc9af87e7eb004f9ba24a0ca27
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
dd = $(srcdir)/src/dd.c
@@ -191,6 +191,18 @@ sc_no_exec_perl_coreutils:
exit 1; } || :; \
fi
# Don't use "readlink" or "readlinkat" directly
sc_prohibit_readlink:
@re='\<readlink(at)? \(' \
msg='do not use readlink(at); use via xreadlink or areadlink*' \
$(_prohibit_regexp)
# Don't use address of "stat" or "lstat" functions
sc_prohibit_stat_macro_address:
@re='\<l?stat '':|&l?stat\>' \
msg='stat() and lstat() may be function-like macros' \
$(_prohibit_regexp)
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
# which date accepts but GNU strftime does not.
@@ -218,4 +230,23 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
msg='use of emacs indent-tabs-mode: setting' \
$(_prohibit_regexp)
# Ensure that each file that contains fail=1 also contains fail=0.
# Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
sc_prohibit_fail_0:
@re='\<fail=0\>' \
msg='fail=0 initialization' \
$(_prohibit_regexp)
# Ensure that "stdio--.h" is used where appropriate.
sc_require_stdio_safer:
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
| grep '\.[ch]$$')); \
test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
| grep . && \
{ echo '$(ME): the above files should use "stdio--.h"' \
1>&2; exit 1; } || :; \
else :; \
fi
include $(srcdir)/dist-check.mk

View File

@@ -101,14 +101,12 @@ if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
# Offenders in pre-fts remove.c; FIXME: remove upon remove.c rewrite
gl_WARN_ADD([-Wno-jump-misses-init])
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
gl_WARN_ADD([-Wno-logical-op])
gl_WARN_ADD([-fdiagnostics-show-option])
gl_WARN_ADD([-funit-at-a-time])
AC_SUBST([WARN_CFLAGS])
@@ -116,13 +114,21 @@ if test "$gl_gcc_warnings" = yes; then
AC_DEFINE([_FORTIFY_SOURCE], [2],
[enable compile-time and run-time bounds-checking, and some warnings])
AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
# We use a slightly smaller set of warning options for lib/.
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
nw=
nw="$nw -Wuninitialized"
nw="$nw -Wunused-macros"
nw="$nw -Wmissing-prototypes"
nw="$nw -Wold-style-definition"
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
fi
AC_FUNC_FORK
optional_bin_progs=
AC_CHECK_FUNCS([uname],
gl_ADD_PROG([optional_bin_progs], [uname]))
AC_CHECK_FUNCS([chroot],
gl_ADD_PROG([optional_bin_progs], [chroot]))
AC_CHECK_FUNCS([gethostid],
@@ -423,8 +429,10 @@ CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
############################################################################
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
# translatable strings, we must use need-formatstring-macros here.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.15])
AM_GNU_GETTEXT_VERSION([0.17])
# For a test of uniq: it uses the $LOCALE_FR envvar.
gt_LOCALE_FR

View File

@@ -48,8 +48,10 @@ _W = (^|[^A-Za-z0-9_])
W_ = ([^A-Za-z0-9_]|$$)
syntax_checks = \
sc-avoid-builtin \
sc-avoid-io \
sc-avoid-non-zero \
sc-avoid-path \
sc-avoid-timezone \
sc-avoid-zeroes \
sc-exponent-grouping \
@@ -70,9 +72,18 @@ check-texinfo: $(syntax_checks)
$(PERL) -e 1 2> /dev/null && { $(PERL) -ne \
'/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \
$(srcdir)/*.texi 2> /dev/null || fail=1; }; \
$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
exit $$fail
sc-avoid-builtin:
$(AM_V_GEN)$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi \
&& exit 1 || :
sc-avoid-path:
$(AM_V_GEN)fail=0; \
$(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
| $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
| $(EGREP) -v \
'PATH=|path search|search path|@vindex PATH$$|@env[{]PATH[}]' \
&& fail=1; \
exit $$fail
# Use `time zone', not `timezone'.

File diff suppressed because it is too large Load Diff

View File

@@ -129,7 +129,7 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
size_t
mbsalign (const char *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
size_t *width, mbs_align_t align, int flags _UNUSED_PARAMETER_)
{
size_t ret = -1;
size_t src_size = strlen (src) + 1;

View File

@@ -1,142 +0,0 @@
/* mgetgroups.c -- return a list of the groups a user is in
Copyright (C) 2007-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/>. */
/* Extracted from coreutils' src/id.c. */
#include <config.h>
#include "mgetgroups.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#if HAVE_GETGROUPLIST
# include <grp.h>
#endif
#include "getugroups.h"
#include "xalloc.h"
static GETGROUPS_T *
realloc_groupbuf (GETGROUPS_T *g, size_t num)
{
if (xalloc_oversized (num, sizeof (*g)))
{
errno = ENOMEM;
return NULL;
}
return realloc (g, num * sizeof (*g));
}
/* Like getugroups, but store the result in malloc'd storage.
Set *GROUPS to the malloc'd list of all group IDs of which USERNAME
is a member. If GID is not -1, store it first. GID should be the
group ID (pw_gid) obtained from getpwuid, in case USERNAME is not
listed in the groups database (e.g., /etc/groups). Upon failure,
don't modify *GROUPS, set errno, and return -1. Otherwise, return
the number of groups. */
int
mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
{
int max_n_groups;
int ng;
GETGROUPS_T *g;
#if HAVE_GETGROUPLIST
/* We prefer to use getgrouplist if available, because it has better
performance characteristics.
In glibc 2.3.2, getgrouplist is buggy. If you pass a zero as the
length of the output buffer, getgrouplist will still write to the
buffer. Contrary to what some versions of the getgrouplist
manpage say, this doesn't happen with nonzero buffer sizes.
Therefore our usage here just avoids a zero sized buffer. */
if (username)
{
enum { N_GROUPS_INIT = 10 };
max_n_groups = N_GROUPS_INIT;
g = realloc_groupbuf (NULL, max_n_groups);
if (g == NULL)
return -1;
while (1)
{
GETGROUPS_T *h;
int last_n_groups = max_n_groups;
/* getgrouplist updates max_n_groups to num required. */
ng = getgrouplist (username, gid, g, &max_n_groups);
/* Some systems (like Darwin) have a bug where they
never increase max_n_groups. */
if (ng < 0 && last_n_groups == max_n_groups)
max_n_groups *= 2;
if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
{
int saved_errno = errno;
free (g);
errno = saved_errno;
return -1;
}
g = h;
if (0 <= ng)
{
*groups = g;
/* On success some systems just return 0 from getgrouplist,
so return max_n_groups rather than ng. */
return max_n_groups;
}
}
}
/* else no username, so fall through and use getgroups. */
#endif
max_n_groups = (username
? getugroups (0, NULL, username, gid)
: getgroups (0, NULL));
/* If we failed to count groups with NULL for a buffer,
try again with a non-NULL one, just in case. */
if (max_n_groups < 0)
max_n_groups = 5;
g = realloc_groupbuf (NULL, max_n_groups);
if (g == NULL)
return -1;
ng = (username
? getugroups (max_n_groups, g, username, gid)
: getgroups (max_n_groups, g));
if (ng < 0)
{
int saved_errno = errno;
free (g);
errno = saved_errno;
return -1;
}
*groups = g;
return ng;
}

View File

@@ -1,19 +0,0 @@
/* Get a list of all group IDs associated with a specified user ID.
Copyright (C) 2007, 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 <sys/types.h>
int mgetgroups (const char *username, gid_t gid, GETGROUPS_T **groups);

82
gl/lib/regcomp.c.diff Normal file
View File

@@ -0,0 +1,82 @@
diff --git c/lib/regcomp.c i/lib/regcomp.c
index 6472ff6..665b2ab 100644
--- c/lib/regcomp.c
+++ i/lib/regcomp.c
@@ -18,6 +18,8 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#include "intprops.h"
+#include "verify.h"
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
static void re_compile_fastmap_iter (regex_t *bufp,
@@ -541,7 +543,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
size_t errbuf_size;
#else /* size_t might promote */
size_t
-regerror (int errcode, const regex_t *_Restrict_ preg,
+regerror (int errcode, const regex_t *_Restrict_ preg _UNUSED_PARAMETER_,
char *_Restrict_ errbuf, size_t errbuf_size)
#endif
{
@@ -1375,7 +1377,7 @@ calc_first (void *extra, bin_tree_t *node)
/* Pass 2: compute NEXT on the tree. Preorder visit. */
static reg_errcode_t
-calc_next (void *extra, bin_tree_t *node)
+calc_next (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
{
switch (node->token.type)
{
@@ -2571,7 +2573,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
/* This loop is actually executed only when end != REG_MISSING,
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
already created the start+1-th copy. */
- if ((Idx) -1 < 0 || end != REG_MISSING)
+ verify (! TYPE_SIGNED (Idx));
+ if (end != REG_MISSING)
for (i = start + 2; i <= end; ++i)
{
elem = duplicate_tree (elem, dfa);
@@ -2731,7 +2734,8 @@ static reg_errcode_t
internal_function
build_collating_symbol (bitset_t sbcset,
# ifdef RE_ENABLE_I18N
- re_charset_t *mbcset, Idx *coll_sym_alloc,
+ re_charset_t *mbcset _UNUSED_PARAMETER_,
+ Idx *coll_sym_alloc _UNUSED_PARAMETER_,
# endif
const unsigned char *name)
{
@@ -3309,7 +3313,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
static reg_errcode_t
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
- re_token_t *token, int token_len, re_dfa_t *dfa,
+ re_token_t *token, int token_len,
+ re_dfa_t *dfa _UNUSED_PARAMETER_,
reg_syntax_t syntax, bool accept_hyphen)
{
#ifdef RE_ENABLE_I18N
@@ -3396,8 +3401,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
static reg_errcode_t
#ifdef RE_ENABLE_I18N
-build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
- Idx *equiv_class_alloc, const unsigned char *name)
+build_equiv_class (bitset_t sbcset, re_charset_t *mbcset _UNUSED_PARAMETER_,
+ Idx *equiv_class_alloc _UNUSED_PARAMETER_,
+ const unsigned char *name)
#else /* not RE_ENABLE_I18N */
build_equiv_class (bitset_t sbcset, const unsigned char *name)
#endif /* not RE_ENABLE_I18N */
@@ -3798,7 +3804,7 @@ free_token (re_token_t *node)
and its children. */
static reg_errcode_t
-free_tree (void *extra, bin_tree_t *node)
+free_tree (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
{
free_token (&node->token);
return REG_NOERROR;

View File

@@ -0,0 +1,25 @@
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 904b88e..61c8d9d 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -18,6 +18,8 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#include "verify.h"
+#include "intprops.h"
static void re_string_construct_common (const char *str, Idx len,
re_string_t *pstr,
RE_TRANSLATE_TYPE trans, bool icase,
@@ -1390,7 +1392,10 @@ static void
internal_function
re_node_set_remove_at (re_node_set *set, Idx idx)
{
- if (idx < 0 || idx >= set->nelem)
+ verify (! TYPE_SIGNED (Idx));
+ /* if (idx < 0)
+ return; */
+ if (idx >= set->nelem)
return;
--set->nelem;
for (; idx < set->nelem; idx++)

View File

@@ -0,0 +1,14 @@
diff --git i/lib/regex_internal.h w/lib/regex_internal.h
index 859832f..3c7fe06 100644
--- i/lib/regex_internal.h
+++ w/lib/regex_internal.h
@@ -826,7 +826,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
static int
internal_function __attribute ((pure))
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_,
+ Idx idx _UNUSED_PARAMETER_)
{
# ifdef _LIBC
const unsigned char *p, *extra;

45
gl/lib/regexec.c.diff Normal file
View File

@@ -0,0 +1,45 @@
diff --git a/lib/regexec.c b/lib/regexec.c
index 21a8166..7762437 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -18,6 +18,8 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#include "verify.h"
+#include "intprops.h"
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
Idx n) internal_function;
static void match_ctx_clean (re_match_context_t *mctx) internal_function;
@@ -378,8 +380,11 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
Idx len = length1 + length2;
char *s = NULL;
- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
- return -2;
+ verify (! TYPE_SIGNED (Idx));
+ if (BE (len < length1, 0))
+ return -2;
+ /* if (BE (length1 < 0 || length2 < 0 || stop < 0, 0))
+ return -2; */
/* Concatenate the strings. */
if (length2 > 0)
@@ -431,11 +436,14 @@ re_search_stub (struct re_pattern_buffer *bufp,
Idx last_start = start + range;
/* Check for out-of-range. */
- if (BE (start < 0 || start > length, 0))
- return -1;
+ verify (! TYPE_SIGNED (Idx));
+ /* if (BE (start < 0, 0))
+ return -1; */
+ if (BE (start > length, 0))
+ return -1;
if (BE (length < last_start || (0 <= range && last_start < start), 0))
last_start = length;
- else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
+ else if (BE (/* last_start < 0 || */ (range < 0 && start <= last_start), 0))
last_start = 0;
__libc_lock_lock (dfa->lock);

View File

@@ -1,301 +0,0 @@
/* tempname.c - generate the name of a temporary file.
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2005, 2006, 2007, 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/>. */
/* Extracted from glibc sysdeps/posix/tempname.c. See also tmpdir.c. */
#if !_LIBC
# include <config.h>
# include "tempname.h"
# include "randint.h"
#endif
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#ifndef __set_errno
# define __set_errno(Val) errno = (Val)
#endif
#include <stdio.h>
#ifndef P_tmpdir
# define P_tmpdir "/tmp"
#endif
#ifndef TMP_MAX
# define TMP_MAX 238328
#endif
#ifndef __GT_FILE
# define __GT_FILE 0
# define __GT_BIGFILE 1
# define __GT_DIR 2
# define __GT_NOCREATE 3
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/time.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/stat.h>
#if _LIBC
# define struct_stat64 struct stat64
# define small_open __open
# define large_open __open64
#else
# define struct_stat64 struct stat
# define small_open open
# define large_open open
# define __gen_tempname gen_tempname
# define __getpid getpid
# define __gettimeofday gettimeofday
# define __mkdir mkdir
# define __lxstat64(version, file, buf) lstat (file, buf)
# define __xstat64(version, file, buf) stat (file, buf)
#endif
#if ! (HAVE___SECURE_GETENV || _LIBC)
# define __secure_getenv getenv
#endif
#if _LIBC
/* Return nonzero if DIR is an existent directory. */
static int
direxists (const char *dir)
{
struct_stat64 buf;
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
}
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
doesn't exist, none of the searched dirs exists, or there's not
enough space in TMPL. */
int
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
int try_tmpdir)
{
const char *d;
size_t dlen, plen;
if (!pfx || !pfx[0])
{
pfx = "file";
plen = 4;
}
else
{
plen = strlen (pfx);
if (plen > 5)
plen = 5;
}
if (try_tmpdir)
{
d = __secure_getenv ("TMPDIR");
if (d != NULL && direxists (d))
dir = d;
else if (dir != NULL && direxists (dir))
/* nothing */ ;
else
dir = NULL;
}
if (dir == NULL)
{
if (direxists (P_tmpdir))
dir = P_tmpdir;
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
dir = "/tmp";
else
{
__set_errno (ENOENT);
return -1;
}
}
dlen = strlen (dir);
while (dlen > 1 && dir[dlen - 1] == '/')
dlen--; /* remove trailing slashes */
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
if (tmpl_len < dlen + 1 + plen + 6 + 1)
{
__set_errno (EINVAL);
return -1;
}
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
return 0;
}
#endif /* _LIBC */
static inline bool
check_x_suffix (char const *s, size_t len)
{
return strspn (s, "X") == len;
}
/* These are the characters used in temporary file names. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* Generate a temporary file name based on TMPL. TMPL must end in a
a sequence of at least X_SUFFIX_LEN "X"s. The name constructed
does not exist at the time of the call to __gen_tempname. TMPL is
overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
at the time of the call.
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
__GT_BIGFILE: same as __GT_FILE but use open64().
__GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
int
gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len)
{
size_t len;
char *XXXXXX;
unsigned int count;
int fd = -1;
int save_errno = errno;
struct_stat64 st;
struct randint_source *rand_src;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
give the system administrator the chance to remove the problems. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
conform to POSIX, this must be no smaller than TMP_MAX. */
#if ATTEMPTS_MIN < TMP_MAX
unsigned int attempts = TMP_MAX;
#else
unsigned int attempts = ATTEMPTS_MIN;
#endif
len = strlen (tmpl);
if (len < x_suffix_len || ! check_x_suffix (&tmpl[len - x_suffix_len],
x_suffix_len))
{
__set_errno (EINVAL);
return -1;
}
rand_src = randint_all_new (NULL, 8);
if (! rand_src)
return -1;
/* This is where the Xs start. */
XXXXXX = &tmpl[len - x_suffix_len];
for (count = 0; count < attempts; ++count)
{
size_t i;
for (i = 0; i < x_suffix_len; i++)
{
XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
}
switch (kind)
{
case __GT_FILE:
fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
break;
case __GT_BIGFILE:
fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
break;
case __GT_DIR:
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
break;
case __GT_NOCREATE:
/* This case is backward from the other three. This function
succeeds if __xstat fails because the name does not exist.
Note the continue to bypass the common logic at the bottom
of the loop. */
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
{
if (errno == ENOENT)
{
__set_errno (save_errno);
fd = 0;
goto done;
}
else
{
/* Give up now. */
fd = -1;
goto done;
}
}
continue;
default:
assert (! "invalid KIND in __gen_tempname");
}
if (fd >= 0)
{
__set_errno (save_errno);
goto done;
}
else if (errno != EEXIST)
{
fd = -1;
goto done;
}
}
randint_all_free (rand_src);
/* We got out of the loop because we ran out of combinations to try. */
__set_errno (EEXIST);
return -1;
done:
{
int saved_errno = errno;
randint_all_free (rand_src);
__set_errno (saved_errno);
}
return fd;
}
int
__gen_tempname (char *tmpl, int kind)
{
return gen_tempname_len (tmpl, kind, 6);
}

193
gl/lib/tempname.c.diff Normal file
View File

@@ -0,0 +1,193 @@
diff --git c/lib/tempname.c i/lib/tempname.c
index 2da5afe..562955a 100644
--- c/lib/tempname.c
+++ i/lib/tempname.c
@@ -22,6 +22,7 @@
#if !_LIBC
# include <config.h>
# include "tempname.h"
+# include "randint.h"
#endif
#include <sys/types.h>
@@ -49,6 +50,7 @@
# error report this to bug-gnulib@gnu.org
#endif
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -179,14 +181,21 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
}
#endif /* _LIBC */
+static inline bool
+check_x_suffix (char const *s, size_t len)
+{
+ return len <= strspn (s, "X");
+}
+
/* These are the characters used in temporary file names. */
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/* Generate a temporary file name based on TMPL. TMPL must match the
- rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
+ rules for mk[s]temp (i.e. end in at least X_SUFFIX_LEN "X"s,
+ possibly with a suffix).
The name constructed does not exist at the time of the call to
- __gen_tempname. TMPL is overwritten with the result.
+ this function. TMPL is overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
@@ -197,23 +206,24 @@ static const char letters[] =
We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len)
{
- int len;
+ size_t len;
char *XXXXXX;
- static uint64_t value;
- uint64_t random_time_bits;
unsigned int count;
int fd = -1;
int save_errno = errno;
struct_stat64 st;
+ struct randint_source *rand_src;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
can exist for a given template is 62**6. It should never be
necessary to try all these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
- give the system administrator the chance to remove the problems. */
+ give the system administrator the chance to remove the problems.
+ This value requires that X_SUFFIX_LEN be at least 3. */
#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
@@ -225,43 +235,28 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
#endif
len = strlen (tmpl);
- if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
+ if (len < x_suffix_len + suffixlen
+ || ! check_x_suffix (&tmpl[len - x_suffix_len - suffixlen],
+ x_suffix_len))
{
__set_errno (EINVAL);
return -1;
}
/* This is where the Xs start. */
- XXXXXX = &tmpl[len - 6 - suffixlen];
+ XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
/* Get some more or less random data. */
-#ifdef RANDOM_BITS
- RANDOM_BITS (random_time_bits);
-#else
- {
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
- }
-#endif
- value += random_time_bits ^ __getpid ();
+ rand_src = randint_all_new (NULL, 8);
+ if (! rand_src)
+ return -1;
- for (count = 0; count < attempts; value += 7777, ++count)
+ for (count = 0; count < attempts; ++count)
{
- uint64_t v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
+ size_t i;
+
+ for (i = 0; i < x_suffix_len; i++)
+ XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
switch (kind)
{
@@ -276,7 +271,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
break;
case __GT_NOCREATE:
- /* This case is backward from the other three. __gen_tempname
+ /* This case is backward from the other three. This function
succeeds if __xstat fails because the name does not exist.
Note the continue to bypass the common logic at the bottom
of the loop. */
@@ -285,11 +280,15 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
if (errno == ENOENT)
{
__set_errno (save_errno);
- return 0;
+ fd = 0;
+ goto done;
}
else
- /* Give up now. */
- return -1;
+ {
+ /* Give up now. */
+ fd = -1;
+ goto done;
+ }
}
continue;
@@ -301,13 +300,32 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
if (fd >= 0)
{
__set_errno (save_errno);
- return fd;
+ goto done;
}
else if (errno != EEXIST)
- return -1;
+ {
+ fd = -1;
+ goto done;
+ }
}
+ randint_all_free (rand_src);
+
/* We got out of the loop because we ran out of combinations to try. */
__set_errno (EEXIST);
return -1;
+
+ done:
+ {
+ int saved_errno = errno;
+ randint_all_free (rand_src);
+ __set_errno (saved_errno);
+ }
+ return fd;
+}
+
+int
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+{
+ return gen_tempname_len (tmpl, suffixlen, flags, kind, 6);
}

View File

@@ -1,41 +0,0 @@
/* Create a temporary file or directory.
Copyright (C) 2006, 2007, 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/>. */
/* header written by Eric Blake */
/* In gnulib, always prefer large files. GT_FILE maps to
__GT_BIGFILE, not __GT_FILE, for a reason. */
#define GT_FILE 1
#define GT_DIR 2
#define GT_NOCREATE 3
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
does not exist at the time of the call to gen_tempname. TMPL is
overwritten with the result.
KIND may be one of:
GT_NOCREATE: simply verify that the name does not exist
at the time of the call.
GT_FILE: create a large file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
#include <stddef.h>
extern int gen_tempname (char *tmpl, int kind);
extern int gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len);

12
gl/lib/tempname.h.diff Normal file
View File

@@ -0,0 +1,12 @@
diff --git c/lib/tempname.h i/lib/tempname.h
index cd69e7d..9757db2 100644
--- c/lib/tempname.h
+++ i/lib/tempname.h
@@ -46,5 +46,7 @@
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
+extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len);
#endif /* GL_TEMPNAME_H */

View File

@@ -21,6 +21,7 @@
#include "error.h"
#include "exitfail.h"
#include "quote.h"
#include "stdio--.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)

View File

@@ -1,11 +0,0 @@
#serial 3
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_MGETGROUPS],
[
AC_CHECK_FUNCS([getgrouplist])
AC_LIBOBJ([mgetgroups])
])

View File

@@ -1,24 +0,0 @@
Description:
Return the group IDs of a user in malloc'd storage.
Files:
lib/mgetgroups.c
lib/mgetgroups.h
m4/mgetgroups.m4
Depends-on:
getugroups
xalloc
configure.ac:
gl_MGETGROUPS
Makefile.am:
Include:
License:
LGPL
Maintainer:
Jim Meyering

View File

@@ -0,0 +1,9 @@
diff --git a/modules/rename-tests b/modules/rename-tests
index be1b423..fea330a 100644
--- a/modules/rename-tests
+++ b/modules/rename-tests
@@ -14,3 +14,4 @@ configure.ac:
Makefile.am:
TESTS += test-rename
check_PROGRAMS += test-rename
+test_rename_LDADD = $(LDADD) @LIBINTL@

View File

@@ -8,6 +8,7 @@ lib/xfreopen.h
Depends-on:
error
exitfail
freopen-safer
quote
configure.ac:

2
gnulib

Submodule gnulib updated: 10322ac9be...0883405cc7

View File

@@ -1 +1,3 @@
include gnulib.mk
AM_CFLAGS = $(GNULIB_WARN_CFLAGS) # $(WERROR_CFLAGS)

View File

@@ -17,7 +17,7 @@
include gnulib.mk
AM_CFLAGS += $(WARN_CFLAGS) # $(WERROR_CFLAGS)
AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
libcoreutils_a_SOURCES += \
buffer-lcm.c buffer-lcm.h \

View File

@@ -25,13 +25,6 @@
#include <unistd.h>
#ifndef F_OK
# define F_OK 0
# define X_OK 1
# define W_OK 2
# define R_OK 4
#endif
#include "group-member.h"
#include "stat-macros.h"
@@ -137,6 +130,6 @@ main (int argc, char **argv)
ok = euidaccess_stat (&st, mode);
printf ("%s: %s\n", file, ok ? "y" : "n");
exit (0);
return 0;
}
#endif

View File

@@ -61,3 +61,22 @@ xfts_open (char * const *argv, int options,
return fts;
}
/* When fts_read returns FTS_DC to indicate a directory cycle,
it may or may not indicate a real problem. When a program like
chgrp performs a recursive traversal that requires traversing
symbolic links, it is *not* a problem. However, when invoked
with "-P -R", it deserves a warning. The fts_options member
records the options that control this aspect of fts's behavior,
so test that. */
bool
cycle_warning_required (FTS const *fts, FTSENT const *ent)
{
#define ISSET(Fts,Opt) ((Fts)->fts_options & (Opt))
/* When dereferencing no symlinks, or when dereferencing only
those listed on the command line and we're not processing
a command-line argument, then a cycle is a serious problem. */
return ((ISSET (fts, FTS_PHYSICAL) && !ISSET (fts, FTS_COMFOLLOW))
|| (ISSET (fts, FTS_PHYSICAL) && ISSET (fts, FTS_COMFOLLOW)
&& ent->fts_level != FTS_ROOTLEVEL));
}

View File

@@ -1,5 +1,9 @@
#include <stdbool.h>
#include "fts_.h"
FTS *
xfts_open (char * const *, int options,
int (*) (const FTSENT **, const FTSENT **));
bool
cycle_warning_required (FTS const *fts, FTSENT const *ent);

View File

@@ -1,4 +1,4 @@
#serial 24
#serial 26
# Check declarations for this package.
dnl Copyright (C) 1997-2001, 2003-2006, 2008-2009 Free Software
@@ -35,15 +35,7 @@ AC_DEFUN([gl_CHECK_DECLS],
getpwuid,
ttyname], , , $headers)
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
AC_CHECK_DECLS_ONCE([free])
AC_CHECK_DECLS_ONCE([getenv])
AC_CHECK_DECLS_ONCE([geteuid])
AC_CHECK_DECLS_ONCE([getlogin])
AC_CHECK_DECLS_ONCE([getuid])
AC_CHECK_DECLS_ONCE([lseek])
AC_CHECK_DECLS_ONCE([malloc])
AC_CHECK_DECLS_ONCE([memchr])
AC_CHECK_DECLS_ONCE([realloc])
])

View File

@@ -30,7 +30,9 @@ AC_DEFUN([cu_GMP],
LIB_GMP=$ac_cv_search___gmpz_init
AC_DEFINE([HAVE_GMP], [1],
[Define if you have GNU libgmp (or replacement)])
}])
}],
[AC_MSG_WARN([libgmp development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
LIBS=$cu_saved_libs
fi
])

View File

@@ -89,14 +89,12 @@ AC_DEFUN([coreutils_MACROS],
tcgetpgrp \
)
# for cp.c
AC_CHECK_FUNCS_ONCE([utimensat])
dnl This can't use AC_REQUIRE; I'm not quite sure why.
cu_PREREQ_STAT_PROG
# for dd.c and shred.c
coreutils_saved_libs=$LIBS
LIB_FDATASYNC=
AC_SEARCH_LIBS([fdatasync], [rt posix4],
[test "$ac_cv_search_fdatasync" = "none required" ||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
@@ -118,7 +116,8 @@ AC_DEFUN([coreutils_MACROS],
if test "X$enable_libcap" = "Xyes"; then
AC_MSG_ERROR([libcap library was not found or not usable])
else
AC_MSG_WARN([libcap library was not found or not usable, support for libcap will not be built])
AC_MSG_WARN([libcap library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without capability support.])
fi
fi
else

View File

@@ -51,6 +51,7 @@ $ac_includes_default
# SCO-ODT-3.0 is reported to need -lufc for crypt.
# NetBSD needs -lcrypt for crypt.
LIB_CRYPT=
cu_saved_libs="$LIBS"
AC_SEARCH_LIBS([crypt], [ufc crypt],
[test "$ac_cv_search_crypt" = "none required" ||

View File

@@ -22,9 +22,12 @@ AC_DEFUN([gl_FUNC_XATTR],
use_xattr=1
else
use_xattr=0
AC_MSG_WARN([libattr development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
fi
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
[Define if you want extended attribute support.])
LIB_XATTR=
xattr_saved_LIBS=$LIBS
AC_SEARCH_LIBS([attr_copy_file], [attr],
[test "$ac_cv_search_attr_copy_file" = "none required" ||

1
man/.gitignore vendored
View File

@@ -48,6 +48,7 @@ mv.1
nice.1
nl.1
nohup.1
nproc.1
od.1
paste.1
pathchk.1

View File

@@ -80,6 +80,7 @@ mv.1: $(common_dep) $(srcdir)/mv.x ../src/mv.c
nice.1: $(common_dep) $(srcdir)/nice.x ../src/nice.c
nl.1: $(common_dep) $(srcdir)/nl.x ../src/nl.c
nohup.1: $(common_dep) $(srcdir)/nohup.x ../src/nohup.c
nproc.1: $(common_dep) $(srcdir)/nproc.x ../src/nproc.c
od.1: $(common_dep) $(srcdir)/od.x ../src/od.c
paste.1: $(common_dep) $(srcdir)/paste.x ../src/paste.c
pathchk.1: $(common_dep) $(srcdir)/pathchk.x ../src/pathchk.c

View File

@@ -373,6 +373,7 @@ my $PAT_AUTHOR = _('Written +by');
my $PAT_OPTIONS = _('Options');
my $PAT_EXAMPLES = _('Examples');
my $PAT_FREE_SOFTWARE = _('This +is +free +software');
my $PAT_INFO = _('For +complete +documentation');
# Start a new paragraph (if required) for these.
s/([^\n])\n($PAT_BUGS|$PAT_AUTHOR)/$1\n\n$2/og;
@@ -392,6 +393,11 @@ while (length)
$sect = _('EXAMPLES');
next;
}
# Skip any texinfo reference as that's handled separately
if (s/($PAT_INFO).*\n//o)
{
next;
}
# Copyright section
if (/^Copyright +[(\xa9]/)

4
man/nproc.x Normal file
View File

@@ -0,0 +1,4 @@
[NAME]
nproc \- print the number of processing units available
[DESCRIPTION]
.\" Add any additional description here

View File

@@ -20,6 +20,8 @@ lib/regcomp.c
lib/root-dev-ino.h
lib/rpmatch.c
lib/set-mode-acl.c
lib/siglist.h
lib/strsignal.c
lib/unicodeio.c
lib/userspec.c
lib/verror.c
@@ -87,6 +89,7 @@ src/mv.c
src/nice.c
src/nl.c
src/nohup.c
src/nproc.c
src/od.c
src/operand2sig.c
src/paste.c

1
src/.gitignore vendored
View File

@@ -56,6 +56,7 @@ mv
nice
nl
nohup
nproc
od
paste
pathchk

View File

@@ -24,25 +24,115 @@ no_install__progs = \
arch hostname su
build_if_possible__progs = \
chroot df hostid nice pinky stdbuf libstdbuf.so stty su uname uptime users who
chroot \
df \
hostid \
libstdbuf.so \
nice \
pinky \
stdbuf \
stty \
su \
uptime \
users \
who
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
EXTRA_PROGRAMS = \
$(no_install__progs) \
$(build_if_possible__progs) \
[ chcon chgrp chown chmod cp dd dircolors du \
ginstall link ln dir vdir ls mkdir \
mkfifo mknod mktemp \
mv nohup readlink rm rmdir shred stat sync touch unlink \
cat cksum comm csplit cut expand fmt fold head join groups md5sum \
nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
shuf sort split sum tac tail tr tsort unexpand uniq wc \
basename date dirname echo env expr factor false \
id kill logname pathchk printenv printf pwd \
runcon seq sleep tee \
test timeout true truncate tty whoami yes \
base64
[ \
base64 \
basename \
cat \
chcon \
chgrp \
chmod \
chown \
cksum \
comm \
cp \
csplit \
cut \
date \
dd \
dir \
dircolors \
dirname \
du \
echo \
env \
expand \
expr \
factor \
false \
fmt \
fold \
ginstall \
groups \
head \
id \
join \
kill \
link \
ln \
logname \
ls \
md5sum \
mkdir \
mkfifo \
mknod \
mktemp \
mv \
nl \
nproc \
nohup \
od \
paste \
pathchk \
pr \
printenv \
printf \
ptx \
pwd \
readlink \
rm \
rmdir \
runcon \
seq \
sha1sum \
sha224sum \
sha256sum \
sha384sum \
sha512sum \
shred \
shuf \
sleep \
sort \
split \
stat \
sum \
sync \
tac \
tail \
tee \
test \
timeout \
touch \
tr \
true \
truncate \
tsort \
tty \
uname \
unexpand \
uniq \
unlink \
vdir \
wc \
whoami \
yes
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
@@ -50,20 +140,20 @@ noinst_PROGRAMS = setuidgid getlimits
pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
noinst_HEADERS = \
chown-core.h \
copy.h \
cp-hash.h \
dircolors.h \
fs.h \
group-list.h \
ls.h \
operand2sig.h \
prog-fprintf.h \
remove.h \
system.h \
wheel-size.h \
wheel.h \
noinst_HEADERS = \
chown-core.h \
copy.h \
cp-hash.h \
dircolors.h \
fs.h \
group-list.h \
ls.h \
operand2sig.h \
prog-fprintf.h \
remove.h \
system.h \
wheel-size.h \
wheel.h \
uname.h
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
@@ -87,99 +177,217 @@ nodist_libver_a_SOURCES = version.c version.h
# replacement functions defined in libcoreutils.a.
LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
# First, list all programs, to make listing per-program libraries easier.
# See [ below.
arch_LDADD = $(LDADD)
base64_LDADD = $(LDADD)
basename_LDADD = $(LDADD)
cat_LDADD = $(LDADD)
chcon_LDADD = $(LDADD)
chgrp_LDADD = $(LDADD)
chmod_LDADD = $(LDADD)
chown_LDADD = $(LDADD)
chroot_LDADD = $(LDADD)
cksum_LDADD = $(LDADD)
comm_LDADD = $(LDADD)
nproc_LDADD = $(LDADD)
cp_LDADD = $(LDADD)
csplit_LDADD = $(LDADD)
cut_LDADD = $(LDADD)
date_LDADD = $(LDADD)
dd_LDADD = $(LDADD)
df_LDADD = $(LDADD)
# See dir_LDADD below
dircolors_LDADD = $(LDADD)
dirname_LDADD = $(LDADD)
du_LDADD = $(LDADD)
echo_LDADD = $(LDADD)
env_LDADD = $(LDADD)
expand_LDADD = $(LDADD)
expr_LDADD = $(LDADD)
factor_LDADD = $(LDADD)
false_LDADD = $(LDADD)
fmt_LDADD = $(LDADD)
fold_LDADD = $(LDADD)
getlimits_LDADD = $(LDADD)
ginstall_LDADD = $(LDADD)
groups_LDADD = $(LDADD)
head_LDADD = $(LDADD)
hostid_LDADD = $(LDADD)
hostname_LDADD = $(LDADD)
id_LDADD = $(LDADD)
join_LDADD = $(LDADD)
kill_LDADD = $(LDADD)
link_LDADD = $(LDADD)
ln_LDADD = $(LDADD)
logname_LDADD = $(LDADD)
ls_LDADD = $(LDADD)
md5sum_LDADD = $(LDADD)
mkdir_LDADD = $(LDADD)
mkfifo_LDADD = $(LDADD)
mknod_LDADD = $(LDADD)
mktemp_LDADD = $(LDADD)
mv_LDADD = $(LDADD)
nice_LDADD = $(LDADD)
nl_LDADD = $(LDADD)
nohup_LDADD = $(LDADD)
od_LDADD = $(LDADD)
paste_LDADD = $(LDADD)
pathchk_LDADD = $(LDADD)
pinky_LDADD = $(LDADD)
pr_LDADD = $(LDADD)
printenv_LDADD = $(LDADD)
printf_LDADD = $(LDADD)
ptx_LDADD = $(LDADD)
pwd_LDADD = $(LDADD)
readlink_LDADD = $(LDADD)
rm_LDADD = $(LDADD)
rmdir_LDADD = $(LDADD)
runcon_LDADD = $(LDADD)
seq_LDADD = $(LDADD)
setuidgid_LDADD = $(LDADD)
sha1sum_LDADD = $(LDADD)
sha224sum_LDADD = $(LDADD)
sha256sum_LDADD = $(LDADD)
sha384sum_LDADD = $(LDADD)
sha512sum_LDADD = $(LDADD)
shred_LDADD = $(LDADD)
shuf_LDADD = $(LDADD)
sleep_LDADD = $(LDADD)
sort_LDADD = $(LDADD)
split_LDADD = $(LDADD)
stat_LDADD = $(LDADD)
stdbuf_LDADD = $(LDADD)
stty_LDADD = $(LDADD)
su_LDADD = $(LDADD)
sum_LDADD = $(LDADD)
sync_LDADD = $(LDADD)
tac_LDADD = $(LDADD)
tail_LDADD = $(LDADD)
tee_LDADD = $(LDADD)
test_LDADD = $(LDADD)
timeout_LDADD = $(LDADD)
touch_LDADD = $(LDADD)
tr_LDADD = $(LDADD)
true_LDADD = $(LDADD)
truncate_LDADD = $(LDADD)
tsort_LDADD = $(LDADD)
tty_LDADD = $(LDADD)
uname_LDADD = $(LDADD)
unexpand_LDADD = $(LDADD)
uniq_LDADD = $(LDADD)
unlink_LDADD = $(LDADD)
uptime_LDADD = $(LDADD)
users_LDADD = $(LDADD)
# See vdir_LDADD below
wc_LDADD = $(LDADD)
who_LDADD = $(LDADD)
whoami_LDADD = $(LDADD)
yes_LDADD = $(LDADD)
# for eaccess in lib/euidaccess.c.
chcon_LDADD = $(LDADD) $(LIB_SELINUX)
cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
mknod_LDADD = $(LDADD) $(LIB_SELINUX)
mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
runcon_LDADD = $(LDADD) $(LIB_SELINUX)
pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
rm_LDADD = $(LDADD) $(LIB_EACCESS)
test_LDADD = $(LDADD) $(LIB_EACCESS)
# This is for the '[' program. Automake transliterates '[' to '_'.
__LDADD = $(LDADD) $(LIB_EACCESS)
# Synonyms. Recall that Automake transliterates '[' to '_'.
__LDADD = $(test_LDADD)
dir_LDADD = $(ls_LDADD)
vdir_LDADD = $(ls_LDADD)
# for clock_gettime and fdatasync
dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
id_LDADD = $(LDADD) $(LIB_SELINUX)
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
# Shared files
copy_LDADD =
cp_LDADD += $(copy_LDADD)
ginstall_LDADD += $(copy_LDADD)
mv_LDADD += $(copy_LDADD)
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
remove_LDADD =
mv_LDADD += $(remove_LDADD)
rm_LDADD += $(remove_LDADD)
# for get_date and gettime
date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
# for eaccess, euidaccess
copy_LDADD += $(LIB_EACCESS)
remove_LDADD += $(LIB_EACCESS)
test_LDADD += $(LIB_EACCESS)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
# If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
# for selinux use
chcon_LDADD += $(LIB_SELINUX)
copy_LDADD += $(LIB_SELINUX)
ginstall_LDADD += $(LIB_SELINUX)
id_LDADD += $(LIB_SELINUX)
ls_LDADD += $(LIB_SELINUX)
mkdir_LDADD += $(LIB_SELINUX)
mkfifo_LDADD += $(LIB_SELINUX)
mknod_LDADD += $(LIB_SELINUX)
runcon_LDADD += $(LIB_SELINUX)
stat_LDADD += $(LIB_SELINUX)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
seq_LDADD = $(LDADD) $(POW_LIB)
# for gettime, settime, utimecmp, utimens
copy_LDADD += $(LIB_CLOCK_GETTIME)
date_LDADD += $(LIB_CLOCK_GETTIME)
ginstall_LDADD += $(LIB_CLOCK_GETTIME)
ls_LDADD += $(LIB_CLOCK_GETTIME)
pr_LDADD += $(LIB_CLOCK_GETTIME)
touch_LDADD += $(LIB_CLOCK_GETTIME)
# If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
# and the `nanosleep' reference in lib/xnanosleep.c.
nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
# for gethrxtime, randint, randread, gen_tempname
dd_LDADD += $(LIB_GETHRXTIME)
mktemp_LDADD += $(LIB_GETHRXTIME)
shred_LDADD += $(LIB_GETHRXTIME)
shuf_LDADD += $(LIB_GETHRXTIME)
sort_LDADD += $(LIB_GETHRXTIME)
# for cap_get_file
ls_LDADD += $(LIB_CAP)
# for fdatasync
dd_LDADD += $(LIB_FDATASYNC)
shred_LDADD += $(LIB_FDATASYNC)
# for strtod, strtold
printf_LDADD += $(POW_LIB)
seq_LDADD += $(POW_LIB)
sleep_LDADD += $(POW_LIB)
sort_LDADD += $(POW_LIB)
tail_LDADD += $(POW_LIB)
uptime_LDADD += $(POW_LIB)
# for xnanosleep
sleep_LDADD += $(LIB_NANOSLEEP)
tail_LDADD += $(LIB_NANOSLEEP)
# for various GMP functions
expr_LDADD = $(LDADD) $(LIB_GMP)
expr_LDADD += $(LIB_GMP)
factor_LDADD += $(LIB_GMP)
# for various GMP functions
factor_LDADD = $(LDADD) $(LIB_GMP)
# for getloadavg
uptime_LDADD += $(GETLOADAVG_LIBS)
sleep_LDADD = $(nanosec_libs)
tail_LDADD = $(nanosec_libs)
# for crypt
su_LDADD += $(LIB_CRYPT)
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
su_LDADD = $(LDADD) $(LIB_CRYPT)
dir_LDADD += $(LIB_ACL)
# for various ACL functions
copy_LDADD += $(LIB_ACL)
ls_LDADD += $(LIB_ACL)
vdir_LDADD += $(LIB_ACL)
cp_LDADD += $(LIB_ACL) $(LIB_XATTR)
mv_LDADD += $(LIB_ACL) $(LIB_XATTR)
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR)
stat_LDADD = $(LDADD) $(LIB_SELINUX)
# for various xattr functions
copy_LDADD += $(LIB_XATTR)
# Append $(LIBICONV) to each program that uses proper_name_utf8.
# for print_unicode_char, proper_name_utf8
cat_LDADD += $(LIBICONV)
cp_LDADD += $(LIBICONV)
df_LDADD += $(LIBICONV)
du_LDADD += $(LIBICONV)
getlimits_LDADD += $(LIBICONV)
printf_LDADD += $(LIBICONV)
ptx_LDADD += $(LIBICONV)
split_LDADD += $(LIBICONV)
stdbuf_LDADD += $(LIBICONV)
timeout_LDADD += $(LIBICONV)
truncate_LDADD += $(LIBICONV)
# programs that use getaddrinfo (e.g., via canon_host)
pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB)
who_LDADD = $(LDADD) $(GETADDRINFO_LIB)
# for canon_host
pinky_LDADD += $(GETADDRINFO_LIB)
who_LDADD += $(GETADDRINFO_LIB)
# for gethostname, uname
hostname_LDADD += $(GETHOSTNAME_LIB)
uname_LDADD += $(GETHOSTNAME_LIB)
$(PROGRAMS): ../lib/libcoreutils.a
@@ -274,6 +482,7 @@ rmdir_SOURCES = rmdir.c prog-fprintf.c
uname_SOURCES = uname.c uname-uname.c
arch_SOURCES = uname.c uname-arch.c
nproc_SOURCES = nproc.c
md5sum_SOURCES = md5sum.c
md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
@@ -330,6 +539,59 @@ wheel.h: wheel-gen.pl Makefile.am
# Tell automake to exempt then from that installcheck test.
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
# Compare fs.h with the list of file system names/magic-numbers in the
# Linux statfs man page. This target prints any new name/number pairs.
# Also compare against /usr/include/linux/magic.h
.PHONY: fs-magic-compare
fs-magic-compare: fs-magic fs-kernel-magic fs-def
join -v1 -t@ fs-magic fs-def
join -v1 -t@ fs-kernel-magic fs-def
CLEANFILES += fs-def
fs-def: fs.h
grep '^# *define ' $< > $@-t && mv $@-t $@
# Massage bits of the statfs man page and definitions from
# /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
fs_normalize_perl_subst = \
-e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
-e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
-e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
-e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
-e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
-e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
-e 's/(_SUPER)?_MAGIC//;' \
-e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
-e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
-e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
-e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
-e 's/^\s+//;' \
-e 's/^\#define\s+//;' \
-e 's/^_(XIAFS)/$$1/;' \
-e 's/^USBDEVICE/USBDEVFS/;' \
-e 's/NTFS_SB/NTFS/;' \
-e 's/^/\# define S_MAGIC_/;' \
-e 's,\s*/\* .*? \*/,,;'
CLEANFILES += fs-magic
fs-magic: Makefile
man statfs \
|perl -ne '/File system types:/.../Nobody kno/ and print' \
|grep 0x | perl -p \
$(fs_normalize_perl_subst) \
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
| LC_ALL=C sort \
> $@-t && mv $@-t $@
CLEANFILES += fs-kernel-magic
fs-kernel-magic: Makefile
perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \
| perl -p \
$(fs_normalize_perl_subst) \
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
| LC_ALL=C sort \
> $@-t && mv $@-t $@
BUILT_SOURCES += fs.h
fs.h: stat.c extract-magic
$(AM_V_GEN)rm -f $@
@@ -453,7 +715,7 @@ sc_tight_scope: $(bin_PROGRAMS)
( printf 'main\nusage\n_.*\n'; \
grep -h -A1 '^extern .*[^;]$$' $$src \
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
perl -ne '/^extern (?:enum )?\S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
nm -e *.$(OBJEXT) \
| sed -n 's/.* T //p' \

View File

@@ -81,7 +81,7 @@ When decoding, the input may contain newlines in addition to the bytes of\n\
the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\
from any other non-alphabet bytes in the encoded stream.\n"),
stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);

View File

@@ -66,7 +66,7 @@ Examples:\n\
%s include/stdio.h .h Output \"stdio\".\n\
"),
program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -119,7 +119,7 @@ Examples:\n\
%s Copy standard input to standard output.\n\
"),
program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -388,7 +388,7 @@ cat (
/* Are line numbers to be written at empty lines (-n)? */
if (number & !number_nonblank)
if (number && !number_nonblank)
{
next_line_num ();
bpout = stpcpy (bpout, line_num_print);
@@ -657,7 +657,7 @@ main (int argc, char **argv)
#endif
}
if (! (number | show_ends | squeeze_blank))
if (! (number || show_ends || squeeze_blank))
{
file_open_mode |= O_BINARY;
if (O_BINARY && ! isatty (STDOUT_FILENO))
@@ -719,8 +719,8 @@ main (int argc, char **argv)
/* Select which version of `cat' to use. If any format-oriented
options were given use `cat'; otherwise use `simple_cat'. */
if (! (number | show_ends | show_nonprinting
| show_tabs | squeeze_blank))
if (! (number || show_ends || show_nonprinting
|| show_tabs || squeeze_blank))
{
insize = MAX (insize, outsize);
inbuf = xmalloc (insize + page_size - 1);

View File

@@ -267,6 +267,14 @@ process_file (FTS *fts, FTSENT *ent)
ok = false;
break;
case FTS_DC: /* directory that causes cycles */
if (cycle_warning_required (fts, ent))
{
emit_cycle_warning (file_full_name);
return false;
}
break;
default:
break;
}
@@ -380,7 +388,7 @@ one takes effect.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -546,10 +554,10 @@ main (int argc, char **argv)
if (reference_file && component_specified)
{
error (0, 0, _("conflicting security context specifiers given"));
usage (1);
usage (EXIT_FAILURE);
}
if (recurse & preserve_root)
if (recurse && preserve_root)
{
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);

View File

@@ -158,7 +158,7 @@ Examples:\n\
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
"),
program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -293,7 +293,7 @@ main (int argc, char **argv)
gid = parse_group (group_name);
}
if (chopt.recurse & preserve_root)
if (chopt.recurse && preserve_root)
{
static struct dev_ino dev_ino_buf;
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);

View File

@@ -228,6 +228,15 @@ process_file (FTS *fts, FTSENT *ent)
error (0, 0, _("cannot operate on dangling symlink %s"),
quote (file_full_name));
ok = false;
break;
case FTS_DC: /* directory that causes cycles */
if (cycle_warning_required (fts, ent))
{
emit_cycle_warning (file_full_name);
return false;
}
break;
default:
break;
@@ -279,7 +288,7 @@ process_file (FTS *fts, FTSENT *ent)
}
}
if (chmod_succeeded & diagnose_surprises)
if (chmod_succeeded && diagnose_surprises)
{
mode_t naively_expected_mode =
mode_adjust (old_mode, S_ISDIR (old_mode) != 0, 0, change, NULL);
@@ -379,7 +388,7 @@ Change the mode of each FILE to MODE.\n\
\n\
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -523,7 +532,7 @@ main (int argc, char **argv)
umask_value = umask (0);
}
if (recurse & preserve_root)
if (recurse && preserve_root)
{
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);

View File

@@ -316,6 +316,14 @@ change_file_owner (FTS *fts, FTSENT *ent,
ok = false;
break;
case FTS_DC: /* directory that causes cycles */
if (cycle_warning_required (fts, ent))
{
emit_cycle_warning (file_full_name);
return false;
}
break;
default:
break;
}
@@ -440,7 +448,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
if (chopt->verbosity != V_off)
{
bool changed =
((do_chown & ok & symlink_changed)
((do_chown && ok && symlink_changed)
&& ! ((uid == (uid_t) -1 || uid == file_stats->st_uid)
&& (gid == (gid_t) -1 || gid == file_stats->st_gid)));

View File

@@ -153,7 +153,7 @@ Examples:\n\
%s -hR root /u Change the owner of /u and subfiles to \"root\".\n\
"),
program_name, program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -317,7 +317,7 @@ main (int argc, char **argv)
optind++;
}
if (chopt.recurse & preserve_root)
if (chopt.recurse && preserve_root)
{
static struct dev_ino dev_ino_buf;
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);

View File

@@ -91,7 +91,7 @@ set_additional_groups (char const *groups)
}
if (n_gids == n_gids_allocated)
gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids);
gids = X2NREALLOC (gids, &n_gids_allocated);
gids[n_gids++] = value;
}
@@ -142,7 +142,7 @@ Run COMMAND with root directory set to NEWROOT.\n\
\n\
If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -160,7 +160,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
initialize_exit_failure (EXIT_FAILURE);
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
@@ -177,22 +177,22 @@ main (int argc, char **argv)
groups = optarg;
break;
default:
usage (EXIT_FAILURE);
usage (EXIT_CANCELED);
}
}
if (argc <= optind)
{
error (0, 0, _("missing operand"));
usage (EXIT_FAILURE);
usage (EXIT_CANCELED);
}
if (chroot (argv[optind]) != 0)
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"),
error (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
argv[optind]);
if (chdir ("/"))
error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
error (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
if (argc == optind + 1)
{
@@ -223,7 +223,7 @@ main (int argc, char **argv)
char const *err = parse_user_spec (userspec, &uid, &gid, &user, &group);
if (err)
error (EXIT_FAILURE, errno, "%s", err);
error (EXIT_CANCELED, errno, "%s", err);
free (user);
free (group);
@@ -254,7 +254,7 @@ main (int argc, char **argv)
}
if (fail)
exit (EXIT_FAILURE);
exit (EXIT_CANCELED);
/* Execute the given command. */
execvp (argv[0], argv);

View File

@@ -269,7 +269,7 @@ Print CRC checksum and byte counts of each FILE.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -23,6 +23,7 @@
#include "system.h"
#include "linebuffer.h"
#include "error.h"
#include "hard-locale.h"
#include "quote.h"
#include "stdio--.h"
#include "memcmp2.h"
@@ -140,7 +141,7 @@ Examples:\n\
%s -3 file1 file2 Print lines in file1 not in file2, and vice versa.\n\
"),
program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -123,17 +123,12 @@ static char const *top_level_dst_name;
static inline int
utimens_symlink (char const *file, struct timespec const *timespec)
{
int err = 0;
#if HAVE_UTIMENSAT
err = utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW);
int err = lutimens (file, timespec);
/* When configuring on a system with new headers and libraries, and
running on one with a kernel that is old enough to lack the syscall,
utimensat fails with ENOSYS. Ignore that. */
if (err && errno == ENOSYS)
err = 0;
#endif
return err;
}
@@ -360,11 +355,11 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
group. Avoid the window by first changing to a restrictive
temporary mode if necessary. */
if (!new_dst && (x->preserve_mode | x->move_mode | x->set_mode))
if (!new_dst && (x->preserve_mode || x->move_mode || x->set_mode))
{
mode_t old_mode = dst_sb->st_mode;
mode_t new_mode =
(x->preserve_mode | x->move_mode ? src_sb->st_mode : x->mode);
(x->preserve_mode || x->move_mode ? src_sb->st_mode : x->mode);
mode_t restrictive_temp_mode = old_mode & new_mode & S_IRWXU;
if ((USE_ACL
@@ -834,6 +829,24 @@ copy_reg (char const *src_name, char const *dst_name,
}
}
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
This workaround is required as an inode permission check is done
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
if (x->preserve_xattr)
{
bool access_changed = false;
if (!(sb.st_mode & S_IWUSR) && geteuid() != 0)
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
&& x->require_preserve_xattr)
return_val = false;
if (access_changed)
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
}
if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb))
{
switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb))
@@ -850,11 +863,6 @@ copy_reg (char const *src_name, char const *dst_name,
set_author (dst_name, dest_desc, src_sb);
if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc,
dst_name, dest_desc, x)
&& x->require_preserve_xattr)
return_val = false;
if (x->preserve_mode || x->move_mode)
{
if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
@@ -1671,7 +1679,9 @@ copy_internal (char const *src_name, char const *dst_name,
}
else
{
bool link_failed = (link (earlier_file, dst_name) != 0);
/* We want to guarantee that symlinks are not followed. */
bool link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
dst_name, 0) != 0);
/* If the link failed because of an existing destination,
remove that file and then call link again. */
@@ -1684,7 +1694,8 @@ copy_internal (char const *src_name, char const *dst_name,
}
if (x->verbose)
printf (_("removed %s\n"), quote (dst_name));
link_failed = (link (earlier_file, dst_name) != 0);
link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
dst_name, 0) != 0);
}
if (link_failed)
@@ -1974,25 +1985,15 @@ copy_internal (char const *src_name, char const *dst_name,
}
}
/* POSIX 2008 states that it is implementation-defined whether
link() on a symlink creates a hard-link to the symlink, or only
to the referent (effectively dereferencing the symlink) (POSIX
2001 required the latter behavior, although many systems provided
the former). Yet cp, invoked with `--link --no-dereference',
should not follow the link. We can approximate the desired
behavior by skipping this hard-link creating block and instead
copying the symlink, via the `S_ISLNK'- copying code below.
LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know
how link() behaves, so we use the fallback case for safety.
FIXME - use a gnulib linkat emulation for more fine-tuned
emulation, particularly when LINK_FOLLOWS_SYMLINKS is -1. */
/* cp, invoked with `--link --no-dereference', should not follow the
link; we guarantee this with gnulib's linkat module (on systems
where link(2) follows the link, gnulib creates a symlink with
identical contents, which is good enough for our purposes). */
else if (x->hard_link
&& (!LINK_FOLLOWS_SYMLINKS
|| !S_ISLNK (src_mode)
&& (!S_ISLNK (src_mode)
|| x->dereference != DEREF_NEVER))
{
if (link (src_name, dst_name))
if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0))
{
error (0, errno, _("cannot create link %s"), quote (dst_name));
goto un_backup;

View File

@@ -257,7 +257,7 @@ As a special case, cp makes a backup of SOURCE when the force and backup\n\
options are given and SOURCE and DEST are the same name for an existing,\n\
regular file.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -1089,7 +1089,7 @@ main (int argc, char **argv)
}
}
if (x.hard_link & x.symbolic_link)
if (x.hard_link && x.symbolic_link)
{
error (0, 0, _("cannot make both hard and symbolic links"));
usage (EXIT_FAILURE);
@@ -1130,7 +1130,7 @@ main (int argc, char **argv)
/* If --force (-f) was specified and we're in link-creation mode,
first remove any existing destination file. */
if (x.unlink_dest_after_failed_open & (x.hard_link | x.symbolic_link))
if (x.unlink_dest_after_failed_open && (x.hard_link || x.symbolic_link))
x.unlink_dest_before_opening = true;
if (x.preserve_security_context)

View File

@@ -1481,7 +1481,7 @@ Read standard input if FILE is -. Each PATTERN may be:\n\
\n\
A line OFFSET is a required `+' or `-' followed by a positive integer.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -235,7 +235,7 @@ Each range is one of:\n\
\n\
With no FILE, or when FILE is -, read standard input.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -236,7 +236,7 @@ then an optional modifier, which is either\n\
E to use the locale's alternate representations if available, or\n\
O to use the locale's alternate numeric symbols if available.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -575,7 +575,7 @@ Options are:\n\
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -769,7 +769,7 @@ install_signal_handlers (void)
static void
process_signals (void)
{
while (interrupt_signal | info_signal_count)
while (interrupt_signal || info_signal_count)
{
int interrupt;
int infos;

View File

@@ -24,7 +24,6 @@
#include <getopt.h>
#include "system.h"
#include "canonicalize.h"
#include "error.h"
#include "fsusage.h"
#include "human.h"
@@ -333,10 +332,10 @@ show_dev (char const *disk, char const *mount_point,
bool negate_used;
double pct = -1;
if (me_remote & show_local_fs)
if (me_remote && show_local_fs)
return;
if (me_dummy & !show_all_fs & !show_listed_fs)
if (me_dummy && !show_all_fs && !show_listed_fs)
return;
if (!selected_fstype (fstype) || excluded_fstype (fstype))
@@ -431,7 +430,7 @@ show_dev (char const *disk, char const *mount_point,
total = fsu.fsu_blocks;
available = fsu.fsu_bavail;
negate_available = (fsu.fsu_bavail_top_bit_set
& known_value (available));
&& known_value (available));
available_to_root = fsu.fsu_bfree;
if (known_value (total))
@@ -835,7 +834,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_blocksize_note ("DF");
emit_size_note ();
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -19,7 +19,6 @@
#include <sys/types.h>
#include <getopt.h>
#include <stdio.h>
#include "system.h"
#include "dircolors.h"
@@ -27,6 +26,7 @@
#include "error.h"
#include "obstack.h"
#include "quote.h"
#include "stdio--.h"
#include "xstrndup.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -112,7 +112,7 @@ If FILE is specified, read it to determine which colors to use for which\n\
file types and extensions. Otherwise, a precompiled database is used.\n\
For details on the format of these files, run `dircolors --print-database'.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);

View File

@@ -116,6 +116,7 @@ EXEC 01;32
.Z 01;31
.dz 01;31
.gz 01;31
.lz 01;31
.xz 01;31
.bz2 01;31
.bz 01;31
@@ -175,6 +176,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

@@ -61,7 +61,7 @@ Examples:\n\
%s stdio.h Output \".\".\n\
"),
program_name, program_name);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -24,7 +24,6 @@
Rewritten to use nftw, then to use fts by Jim Meyering. */
#include <config.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
#include <assert.h>
@@ -40,6 +39,7 @@
#include "quotearg.h"
#include "same.h"
#include "stat-time.h"
#include "stdio--.h"
#include "xfts.h"
#include "xstrtol.h"
@@ -67,7 +67,6 @@ extern bool fts_debug;
/* Hash structure for inode and device numbers. The separate entry
structure makes it easier to rehash "in place". */
struct entry
{
ino_t st_ino;
@@ -194,7 +193,6 @@ enum
FILES0_FROM_OPTION,
HUMAN_SI_OPTION,
MAX_DEPTH_OPTION,
MEGABYTES_LONG_OPTION,
TIME_OPTION,
TIME_STYLE_OPTION
};
@@ -332,7 +330,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_blocksize_note ("DU");
emit_size_note ();
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -495,6 +493,15 @@ process_file (FTS *fts, FTSENT *ent)
ok = false;
break;
case FTS_DC: /* directory that causes cycles */
if (cycle_warning_required (fts, ent))
{
emit_cycle_warning (file);
return false;
}
ok = true;
break;
default:
ok = true;
break;
@@ -755,10 +762,6 @@ main (int argc, char **argv)
}
break;
case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */
error (0, 0,
_("the --megabytes option is deprecated; use -m instead"));
/* fall through */
case 'm':
human_output_opts = 0;
output_block_size = 1024 * 1024;
@@ -843,7 +846,7 @@ main (int argc, char **argv)
if (!ok)
usage (EXIT_FAILURE);
if (opt_all & opt_summarize_only)
if (opt_all && opt_summarize_only)
{
error (0, 0, _("cannot both summarize and show all entries"));
usage (EXIT_FAILURE);

View File

@@ -63,21 +63,25 @@ Echo the STRING(s) to standard output.\n\
\n\
If -e is in effect, the following sequences are recognized:\n\
\n\
\\0NNN the character whose ASCII code is NNN (octal)\n\
\\\\ backslash\n\
\\a alert (BEL)\n\
\\b backspace\n\
"), stdout);
fputs (_("\
\\c produce no further output\n\
\\f form feed\n\
\\n new line\n\
\\r carriage return\n\
\\t horizontal tab\n\
\\v vertical tab\n\
\\\\ backslash\n\
\\a alert (BEL)\n\
\\b backspace\n\
\\c produce no further output\n\
\\e escape\n\
\\f form feed\n\
\\n new line\n\
\\r carriage return\n\
\\t horizontal tab\n\
\\v vertical tab\n\
"), stdout);
fputs (_("\
\\0NNN byte with octal value NNN (1 to 3 digits)\n\
\\xHH byte with hexadecimal value HH (1 to 2 digits)\n\
"), stdout);
printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -203,6 +207,7 @@ just_echo:
case 'a': c = '\a'; break;
case 'b': c = '\b'; break;
case 'c': exit (EXIT_SUCCESS);
case 'e': c = '\x1B'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;

102
src/env.c
View File

@@ -16,66 +16,6 @@
/* Richard Mlynarik and David MacKenzie */
/* Options:
-
-i
--ignore-environment
Construct a new environment from scratch; normally the
environment is inherited from the parent process, except as
modified by other options.
-u variable
--unset=variable
Unset variable VARIABLE (remove it from the environment).
If VARIABLE was not set, does nothing.
variable=value (an arg containing a "=" character)
Set the environment variable VARIABLE to value VALUE. VALUE
may be of zero length ("variable="). Setting a variable to a
zero-length value is different from unsetting it.
--
Indicate that the following argument is the program
to invoke. This is necessary when the program's name
begins with "-" or contains a "=".
The first remaining argument specifies a program to invoke;
it is searched for according to the specification of the PATH
environment variable. Any arguments following that are
passed as arguments to that program.
If no command name is specified following the environment
specifications, the resulting environment is printed.
This is like specifying a command name of "printenv".
Examples:
If the environment passed to "env" is
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks }
env - foo
runs "foo" in a null environment.
env foo
runs "foo" in the environment
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks }
env DISPLAY=gnu:0 nemacs
runs "nemacs" in the environment
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 }
env - LOGNAME=foo /hacks/hack bar baz
runs the "hack" program on arguments "bar" and "baz" in an
environment in which the only variable is "LOGNAME". Note that
the "-" option clears out the PATH variable, so one should be
careful to specify in which directory to find the program to
call.
env -u EDITOR LOGNAME=foo PATH=/energy -- e=mc2 bar baz
runs the program "/energy/e=mc2" with environment
{ LOGNAME=foo PATH=/energy }
*/
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
@@ -83,6 +23,7 @@
#include "system.h"
#include "error.h"
#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "env"
@@ -91,11 +32,10 @@
proper_name ("Richard Mlynarik"), \
proper_name ("David MacKenzie")
extern char **environ;
static struct option const longopts[] =
{
{"ignore-environment", no_argument, NULL, 'i'},
{"null", no_argument, NULL, '0'},
{"unset", required_argument, NULL, 'u'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
@@ -116,8 +56,9 @@ Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n"),
fputs (_("\
Set each NAME to VALUE in the environment and run COMMAND.\n\
\n\
-i, --ignore-environment start with an empty environment\n\
-u, --unset=NAME remove variable from the environment\n\
-i, --ignore-environment start with an empty environment\n\
-0, --null end each output line with 0 byte rather than newline\n\
-u, --unset=NAME remove variable from the environment\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -125,7 +66,7 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\
\n\
A mere - implies -i. If no COMMAND, print the resulting environment.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -135,6 +76,7 @@ main (int argc, char **argv)
{
int optc;
bool ignore_environment = false;
bool opt_nul_terminate_output = false;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -142,10 +84,10 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
initialize_exit_failure (EXIT_FAILURE);
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
{
switch (optc)
{
@@ -154,10 +96,13 @@ main (int argc, char **argv)
break;
case 'u':
break;
case '0':
opt_nul_terminate_output = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
usage (EXIT_FAILURE);
usage (EXIT_CANCELED);
}
}
@@ -171,25 +116,36 @@ main (int argc, char **argv)
}
optind = 0; /* Force GNU getopt to re-initialize. */
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
if (optc == 'u')
putenv (optarg); /* Requires GNU putenv. */
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
if (optc == 'u' && unsetenv (optarg))
error (EXIT_CANCELED, errno, _("cannot unset %s"), quote (optarg));
if (optind < argc && STREQ (argv[optind], "-"))
++optind;
while (optind < argc && strchr (argv[optind], '='))
putenv (argv[optind++]);
if (putenv (argv[optind++]))
{
char *name = argv[optind - 1];
*(strchr (name, '=')) = '\0';
error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name));
}
/* If no program is specified, print the environment and exit. */
if (argc <= optind)
{
char *const *e = environ;
while (*e)
puts (*e++);
printf ("%s%c", *e++, opt_nul_terminate_output ? '\0' : '\n');
exit (EXIT_SUCCESS);
}
if (opt_nul_terminate_output)
{
error (0, errno, _("cannot specify --null (-0) with command"));
usage (EXIT_CANCELED);
}
execvp (argv[optind], &argv[optind]);
{

View File

@@ -121,7 +121,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -344,7 +344,7 @@ expand (void)
error (EXIT_FAILURE, 0, _("input line is too long"));
}
convert &= convert_entire_line | !! isblank (c);
convert &= convert_entire_line || !! isblank (c);
}
if (c < 0)

View File

@@ -55,7 +55,7 @@ static void integer_overflow (char) ATTRIBUTE_NORETURN;
#else
/* Approximate gmp.h well enough for expr.c's purposes. */
typedef intmax_t mpz_t[1];
static void mpz_clear (mpz_t z) {}
static void mpz_clear (mpz_t z) { (void) z; }
static void mpz_init_set_ui (mpz_t z, unsigned long int i) { z[0] = i; }
static int
mpz_init_set_str (mpz_t z, char *s, int base)
@@ -116,6 +116,7 @@ mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
static char *
mpz_get_str (char const *str, int base, mpz_t z)
{
(void) str; (void) base;
char buf[INT_BUFSIZE_BOUND (intmax_t)];
return xstrdup (imaxtostr (z[0], buf));
}
@@ -137,6 +138,7 @@ mpz_get_ui (mpz_t z)
static int
mpz_out_str (FILE *stream, int base, mpz_t z)
{
(void) base;
char buf[INT_BUFSIZE_BOUND (intmax_t)];
return fputs (imaxtostr (z[0], buf), stream) != EOF;
}
@@ -265,7 +267,7 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\
Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null\n\
or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -923,7 +925,7 @@ eval1 (bool evaluate)
{
if (nextarg ("&"))
{
r = eval2 (evaluate & ~ null (l));
r = eval2 (evaluate && !null (l));
if (null (l) || null (r))
{
freev (l);
@@ -954,7 +956,7 @@ eval (bool evaluate)
{
if (nextarg ("|"))
{
r = eval1 (evaluate & null (l));
r = eval1 (evaluate && null (l));
if (null (l))
{
freev (l);

View File

@@ -26,7 +26,7 @@
#include <stdio.h>
#include <sys/types.h>
#if HAVE_GMP
#include <gmp.h>
# include <gmp.h>
#endif
#include <assert.h>
@@ -67,7 +67,7 @@ static void
emit_factor (mpz_t n)
{
if (nfactors_found == nfactors_allocated)
factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor);
factor = X2NREALLOC (factor, &nfactors_allocated);
mpz_init (factor[nfactors_found]);
mpz_set (factor[nfactors_found], n);
++nfactors_found;
@@ -502,7 +502,7 @@ are specified on the command line, read them from standard input.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -293,7 +293,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
\n\
With no FILE, or when FILE is -, read standard input.\n"),
stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -82,7 +82,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -73,7 +73,7 @@ Output platform dependent limits in a format useful for shell scripts.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -54,14 +54,13 @@ print_group_list (const char *username,
ok = false;
}
#if HAVE_GETGROUPS
{
GETGROUPS_T *groups;
gid_t *groups;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
if (n_groups < 0)
if (n_groups < 0 && errno != ENOSYS)
{
if (username)
{
@@ -84,7 +83,6 @@ print_group_list (const char *username,
}
free (groups);
}
#endif /* HAVE_GETGROUPS */
return ok;
}

View File

@@ -58,7 +58,7 @@ the current process (which may differ if the groups database has changed).\n"),
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -138,7 +138,7 @@ K may have a multiplier suffix:\n\
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -48,7 +48,7 @@ Print the numeric identifier (in hexadecimal) for the current host.\n\
"), program_name);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -63,7 +63,7 @@ Print or set the hostname of the current system.\n\
program_name, program_name);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -98,7 +98,7 @@ or (when USERNAME omitted) for the current user.\n\
\n\
Without any OPTION, print some useful set of identified information.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -187,7 +187,7 @@ main (int argc, char **argv)
if (just_user + just_group + just_group_list + just_context > 1)
error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
if (just_user + just_group + just_group_list == 0 && (use_real | use_name))
if (just_user + just_group + just_group_list == 0 && (use_real || use_name))
error (EXIT_FAILURE, 0,
_("cannot print only names or real IDs in default format"));
@@ -292,14 +292,13 @@ print_full_info (const char *username)
printf ("(%s)", grp->gr_name);
}
#if HAVE_GETGROUPS
{
GETGROUPS_T *groups;
gid_t *groups;
int i;
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&groups);
if (n_groups < 0)
if (n_groups < 0 && errno != ENOSYS)
{
if (username)
{
@@ -327,7 +326,9 @@ print_full_info (const char *username)
}
free (groups);
}
#endif /* HAVE_GETGROUPS */
if (context != NULL)
/* POSIX mandates the precise output format, and that it not include
any context=... part, so skip that if POSIXLY_CORRECT is set. */
if (context != NULL && ! getenv ("POSIXLY_CORRECT"))
printf (_(" context=%s"), context);
}

View File

@@ -563,7 +563,7 @@ main (int argc, char **argv)
}
/* Check for invalid combinations of arguments. */
if (dir_arg & strip_files)
if (dir_arg && strip_files)
error (EXIT_FAILURE, 0,
_("the strip option may not be used when installing a directory"));
if (dir_arg && target_directory)
@@ -1005,7 +1005,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\
existing, nil numbered if numbered backups exist, simple otherwise\n\
simple, never always make simple backups\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -24,6 +24,7 @@
#include "system.h"
#include "error.h"
#include "hard-locale.h"
#include "linebuffer.h"
#include "memcasecmp.h"
#include "quote.h"
@@ -208,7 +209,7 @@ Note, comparisons honor the rules specified by `LC_COLLATE'.\n\
If the input is not sorted and some lines cannot be joined, a\n\
warning message will be given.\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -111,7 +111,7 @@ or the exit status of a process terminated by a signal.\n\
PID is an integer; if negative it identifies a process group.\n\
"), stdout);
printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -51,7 +51,7 @@ Usage: %s FILE1 FILE2\n\
stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -39,26 +39,15 @@
proper_name ("Mike Parker"), \
proper_name ("David MacKenzie")
/* In being careful not even to try to make hard links to directories,
we have to know whether link(2) follows symlinks. If it does, then
we have to *stat* the `source' to see if the resulting link would be
to a directory. Otherwise, we have to use *lstat* so that we allow
users to make hard links to symlinks-that-point-to-directories. */
#if LINK_FOLLOWS_SYMLINKS
# define STAT_LIKE_LINK(File, Stat_buf) \
stat (File, Stat_buf)
#else
# define STAT_LIKE_LINK(File, Stat_buf) \
lstat (File, Stat_buf)
#endif
/* FIXME: document */
static enum backup_type backup_type;
/* If true, make symbolic links; otherwise, make hard links. */
static bool symbolic_link;
/* If true, hard links are logical rather than physical. */
static bool logical = !!LINK_FOLLOWS_SYMLINKS;
/* If true, ask the user before removing existing files. */
static bool interactive;
@@ -71,7 +60,7 @@ static bool verbose;
/* If true, allow the superuser to *attempt* to make hard links
to directories. However, it appears that this option is not useful
in practice, since even the superuser is prohibited from hard-linking
directories on most (all?) existing systems. */
directories on most existing systems (Solaris being an exception). */
static bool hard_dir_link;
/* If nonzero, and the specified destination is a symbolic link to a
@@ -99,6 +88,8 @@ static struct option const long_options[] =
{"interactive", no_argument, NULL, 'i'},
{"suffix", required_argument, NULL, 'S'},
{"target-directory", required_argument, NULL, 't'},
{"logical", no_argument, NULL, 'L'},
{"physical", no_argument, NULL, 'P'},
{"symbolic", no_argument, NULL, 's'},
{"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
@@ -143,18 +134,15 @@ do_link (const char *source, const char *dest)
bool source_is_dir = false;
bool ok;
/* Use stat here instead of lstat.
On SVR4, link does not follow symlinks, so this check disallows
making hard links to symlinks that point to directories. Big deal.
On other systems, link follows symlinks, so this check is right.
FIXME - POSIX 2008 added the AT_SYMLINK_FOLLOW flag to linkat so
that we can specify either behavior, via the new options -L
(hard-link to symlinks) and -P (hard-link to the referent). Once
gnulib has a decent implementation, we should use it here. */
if (!symbolic_link)
{
if (STAT_LIKE_LINK (source, &source_stats) != 0)
/* Which stat to use depends on whether linkat will follow the
symlink. We can't use the shorter
(logical?stat:lstat) (source, &source_stats)
since stat might be a function-like macro. */
if ((logical ? stat (source, &source_stats)
: lstat (source, &source_stats))
!= 0)
{
error (0, errno, _("accessing %s"), quote (source));
return false;
@@ -258,7 +246,9 @@ do_link (const char *source, const char *dest)
}
}
ok = ((symbolic_link ? symlink (source, dest) : link (source, dest))
ok = ((symbolic_link ? symlink (source, dest)
: linkat (AT_FDCWD, source, AT_FDCWD, dest,
logical ? AT_SYMLINK_FOLLOW : 0))
== 0);
/* If the attempt to create a link failed and we are removing or
@@ -289,7 +279,9 @@ do_link (const char *source, const char *dest)
return false;
}
ok = ((symbolic_link ? symlink (source, dest) : link (source, dest))
ok = ((symbolic_link ? symlink (source, dest)
: linkat (AT_FDCWD, source, AT_FDCWD, dest,
logical ? AT_SYMLINK_FOLLOW : 0))
== 0);
}
@@ -370,9 +362,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-f, --force remove existing destination files\n\
"), stdout);
fputs (_("\
-i, --interactive prompt whether to remove destinations\n\
-L, --logical make hard links to symbolic link references\n\
-n, --no-dereference treat destination that is a symlink to a\n\
directory as if it were a normal file\n\
-i, --interactive prompt whether to remove destinations\n\
-P, --physical make hard links directly to symbolic links\n\
-s, --symbolic make symbolic links instead of hard links\n\
"), stdout);
fputs (_("\
@@ -391,13 +385,18 @@ The version control method may be selected via the --backup option or through\n\
the VERSION_CONTROL environment variable. Here are the values:\n\
\n\
"), stdout);
printf (_("\
Using -s ignores -L and -P. Otherwise, the last option specified controls\n\
behavior when the source is a symbolic link, defaulting to %s.\n\
\n\
"), LINK_FOLLOWS_SYMLINKS ? "-L" : "-P");
fputs (_("\
none, off never make backups (even if --backup is given)\n\
numbered, t make numbered backups\n\
existing, nil numbered if numbered backups exist, simple otherwise\n\
simple, never always make simple backups\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}
@@ -430,7 +429,7 @@ main (int argc, char **argv)
symbolic_link = remove_existing_files = interactive = verbose
= hard_dir_link = false;
while ((c = getopt_long (argc, argv, "bdfinst:vFS:T", long_options, NULL))
while ((c = getopt_long (argc, argv, "bdfinst:vFLPS:T", long_options, NULL))
!= -1)
{
switch (c)
@@ -452,9 +451,15 @@ main (int argc, char **argv)
remove_existing_files = false;
interactive = true;
break;
case 'L':
logical = true;
break;
case 'n':
dereference_dest_dir_symlinks = false;
break;
case 'P':
logical = false;
break;
case 's':
symbolic_link = true;
break;

View File

@@ -44,7 +44,7 @@ Print the name of the current user.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

236
src/ls.c
View File

@@ -93,6 +93,7 @@
#include "dev-ino.h"
#include "error.h"
#include "filenamecat.h"
#include "hard-locale.h"
#include "hash.h"
#include "human.h"
#include "filemode.h"
@@ -213,6 +214,9 @@ struct fileinfo
/* For long listings, true if the file has an access control list,
or an SELinux security context. */
enum acl_type acl_type;
/* For color listings, true if a regular file has capability info. */
bool has_capability;
};
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
@@ -240,9 +244,8 @@ static bool file_ignored (char const *name);
static uintmax_t gobble_file (char const *name, enum filetype type,
ino_t inode, bool command_line_arg,
char const *dirname);
static bool print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype type,
nlink_t nlink);
static bool print_color_indicator (const struct fileinfo *f,
bool symlink_target);
static void put_indicator (const struct bin_str *ind);
static void add_ignore_pattern (const char *pattern);
static void attach (char *dest, const char *dirname, const char *name);
@@ -263,11 +266,9 @@ static int format_user_width (uid_t u);
static int format_group_width (gid_t g);
static void print_long_format (const struct fileinfo *f);
static void print_many_per_line (void);
static size_t print_name_with_quoting (const char *p, mode_t mode,
int linkok, bool stat_ok,
enum filetype type,
static size_t print_name_with_quoting (const struct fileinfo *f,
bool symlink_target,
struct obstack *stack,
nlink_t nlink,
size_t start_col);
static void prep_non_filename_text (void);
static bool print_type_indicator (bool stat_ok, mode_t mode,
@@ -323,7 +324,7 @@ static bool color_symlink_as_referent;
/* mode of appropriate file for colorization */
#define FILE_OR_LINK_MODE(File) \
((color_symlink_as_referent & (File)->linkok) \
((color_symlink_as_referent && (File)->linkok) \
? (File)->linkmode : (File)->stat.st_mode)
@@ -1175,7 +1176,7 @@ stophandler (int sig)
static void
process_signals (void)
{
while (interrupt_signal | stop_signal_count)
while (interrupt_signal || stop_signal_count)
{
int sig;
int stops;
@@ -2470,13 +2471,14 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
error (0, 0, _("%s: not listing already-listed directory"),
quotearg_colon (name));
closedir (dirp);
set_exit_status (true);
return;
}
DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
}
if (recursive | print_dir_name)
if (recursive || print_dir_name)
{
if (!first)
DIRED_PUTCHAR ('\n');
@@ -2635,6 +2637,37 @@ unsigned_file_size (off_t size)
return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
}
#ifdef HAVE_CAP
/* Return true if NAME has a capability (see linux/capability.h) */
static bool
has_capability (char const *name)
{
char *result;
bool has_cap;
cap_t cap_d = cap_get_file (name);
if (cap_d == NULL)
return false;
result = cap_to_text (cap_d, NULL);
cap_free (cap_d);
if (!result)
return false;
/* check if human-readable capability string is empty */
has_cap = !!*result;
cap_free (result);
return has_cap;
}
#else
static bool
has_capability (char const *name ATTRIBUTE_UNUSED)
{
return false;
}
#endif
/* Enter and remove entries in the table `cwd_file'. */
/* Empty the table of files. */
@@ -2716,11 +2749,16 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
to see if it's executable. */
|| (type == normal && (indicator_style == classify
/* This is so that --color ends up
highlighting files with the executable
bit set even when options like -F are
not specified. */
highlighting files with these mode
bits set even when options like -F are
not specified. Note we do a redundant
stat in the very unlikely case where
C_CAP is set but not the others. */
|| (print_with_color
&& is_colored (C_EXEC))
&& (is_colored (C_EXEC)
|| is_colored (C_SETUID)
|| is_colored (C_SETGID)
|| is_colored (C_CAP)))
)))))
{
@@ -2791,6 +2829,11 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
f->stat_ok = true;
/* Note has_capability() adds around 30% runtime to `ls --color` */
if ((type == normal || S_ISREG (f->stat.st_mode))
&& print_with_color && is_colored (C_CAP))
f->has_capability = has_capability (absolute_name);
if (format == long_format || print_scontext)
{
bool have_selinux = false;
@@ -2800,17 +2843,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
: lgetfilecon (absolute_name, &f->scontext));
err = (attr_len < 0);
/* Contrary to its documented API, getfilecon may return 0,
yet set f->scontext to NULL (on at least Debian's libselinux1
2.0.15-2+b1), so work around that bug.
FIXME: remove this work-around in 2011, or whenever affected
versions of libselinux are long gone. */
if (attr_len == 0)
{
err = 0;
f->scontext = xstrdup ("unlabeled");
}
if (err == 0)
have_selinux = ! STREQ ("unlabeled", f->scontext);
else
@@ -2884,7 +2916,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
f->filetype = symbolic_link;
else if (S_ISDIR (f->stat.st_mode))
{
if (command_line_arg & !immediate_dirs)
if (command_line_arg && !immediate_dirs)
f->filetype = arg_directory;
else
f->filetype = directory;
@@ -3554,9 +3586,19 @@ format_group_width (gid_t g)
return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), 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_ok && f->stat.st_ino != NOT_AN_INODE_NUMBER
? umaxtostr (f->stat.st_ino, buf)
: (char *) "?");
}
/* Print information about F in long format. */
static void
print_long_format (const struct fileinfo *f)
{
@@ -3613,9 +3655,7 @@ print_long_format (const struct fileinfo *f)
{
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);
@@ -3651,7 +3691,7 @@ print_long_format (const struct fileinfo *f)
DIRED_INDENT ();
if (print_owner | print_group | print_author | print_scontext)
if (print_owner || print_group || print_author || print_scontext)
{
DIRED_FPUTS (buf, stdout, p - buf);
@@ -3762,18 +3802,14 @@ print_long_format (const struct fileinfo *f)
}
DIRED_FPUTS (buf, stdout, p - buf);
size_t w = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
f->stat_ok, f->filetype, &dired_obstack,
f->stat.st_nlink, p - buf);
size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf);
if (f->filetype == symbolic_link)
{
if (f->linkname)
{
DIRED_FPUTS_LITERAL (" -> ", stdout);
print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
f->stat_ok, f->filetype, NULL,
f->stat.st_nlink, (p - buf) + w + 4);
print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
if (indicator_style != none)
print_type_indicator (true, f->linkmode, unknown);
}
@@ -3949,19 +3985,20 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
}
static size_t
print_name_with_quoting (const char *p, mode_t mode, int linkok,
bool stat_ok, enum filetype type,
struct obstack *stack, nlink_t nlink,
print_name_with_quoting (const struct fileinfo *f,
bool symlink_target,
struct obstack *stack,
size_t start_col)
{
const char* name = symlink_target ? f->linkname : f->name;
bool used_color_this_time
= (print_with_color
&& print_color_indicator (p, mode, linkok, stat_ok, type, nlink));
= (print_with_color && print_color_indicator (f, symlink_target));
if (stack)
PUSH_CURRENT_DIRED_POS (stack);
size_t width = quote_name (stdout, p, filename_quoting_options, NULL);
size_t width = quote_name (stdout, name, filename_quoting_options, NULL);
dired_pos += width;
if (stack)
@@ -4002,19 +4039,18 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col)
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,
human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
ST_NBLOCKSIZE, output_block_size));
! f->stat_ok ? "?"
: human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
ST_NBLOCKSIZE, output_block_size));
if (print_scontext)
printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f),
f->linkok, f->stat_ok, f->filetype,
NULL, f->stat.st_nlink, start_col);
size_t width = print_name_with_quoting (f, false, NULL, start_col);
if (indicator_style != none)
width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
@@ -4065,82 +4101,67 @@ print_type_indicator (bool stat_ok, mode_t mode, enum filetype type)
return !!c;
}
#ifdef HAVE_CAP
/* Return true if NAME has a capability (see linux/capability.h) */
static bool
has_capability (char const *name)
{
char *result;
bool has_cap;
cap_t cap_d = cap_get_file (name);
if (cap_d == NULL)
return false;
result = cap_to_text (cap_d, NULL);
cap_free (cap_d);
if (!result)
return false;
/* check if human-readable capability string is empty */
has_cap = !!*result;
cap_free (result);
return has_cap;
}
#else
static bool
has_capability (char const *name ATTRIBUTE_UNUSED)
{
return false;
}
#endif
/* Returns whether any color sequence was printed. */
static bool
print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype filetype,
nlink_t nlink)
print_color_indicator (const struct fileinfo *f, bool symlink_target)
{
int type;
enum indicator_no type;
struct color_ext_type *ext; /* Color extension */
size_t len; /* Length of name */
const char* name;
mode_t mode;
int linkok;
if (symlink_target)
{
name = f->linkname;
mode = f->linkmode;
linkok = f->linkok - 1;
}
else
{
name = f->name;
mode = FILE_OR_LINK_MODE (f);
linkok = f->linkok;
}
/* Is this a nonexistent file? If so, linkok == -1. */
if (linkok == -1 && color_indicator[C_MISSING].string != NULL)
type = C_MISSING;
else if (! stat_ok)
else if (!f->stat_ok)
{
static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;
type = filetype_indicator[filetype];
type = filetype_indicator[f->filetype];
}
else
{
if (S_ISREG (mode))
{
type = C_FILE;
if ((mode & S_ISUID) != 0)
if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
type = C_SETUID;
else if ((mode & S_ISGID) != 0)
else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
type = C_SETGID;
else if (is_colored (C_CAP) && has_capability (name))
else if (is_colored (C_CAP) && f->has_capability)
type = C_CAP;
else if ((mode & S_IXUGO) != 0)
else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
type = C_EXEC;
else if (is_colored (C_MULTIHARDLINK) && (1 < nlink))
else if ((1 < f->stat.st_nlink) && is_colored (C_MULTIHARDLINK))
type = C_MULTIHARDLINK;
}
else if (S_ISDIR (mode))
{
if ((mode & S_ISVTX) && (mode & S_IWOTH))
type = C_DIR;
if ((mode & S_ISVTX) && (mode & S_IWOTH)
&& is_colored (C_STICKY_OTHER_WRITABLE))
type = C_STICKY_OTHER_WRITABLE;
else if ((mode & S_IWOTH) != 0)
else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
type = C_OTHER_WRITABLE;
else if ((mode & S_ISVTX) != 0)
else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
type = C_STICKY;
else
type = C_DIR;
}
else if (S_ISLNK (mode))
type = ((!linkok && color_indicator[C_ORPHAN].string)
@@ -4221,9 +4242,10 @@ length_of_file_name_and_frills (const struct fileinfo *f)
if (print_block_size)
len += 1 + (format == with_commas
? strlen (human_readable (ST_NBLOCKS (f->stat), buf,
human_output_opts, ST_NBLOCKSIZE,
output_block_size))
? strlen (! f->stat_ok ? "?"
: human_readable (ST_NBLOCKS (f->stat), buf,
human_output_opts, ST_NBLOCKSIZE,
output_block_size))
: block_size_width);
if (print_scontext)
@@ -4552,8 +4574,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-C list entries by columns\n\
--color[=WHEN] control whether color is used to distinguish file\n\
types. WHEN may be `never', `always', or `auto'\n\
--color[=WHEN] colorize the output. WHEN defaults to `always'\n\
or can be `never' or `auto'. More info below\n\
-d, --directory list directory entries instead of contents,\n\
and do not dereference symbolic links\n\
-D, --dired generate output designed for Emacs' dired mode\n\
@@ -4667,12 +4689,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
emit_size_note ();
fputs (_("\
\n\
By default, color is not used to distinguish types of files. That is\n\
equivalent to using --color=none. Using the --color option without the\n\
optional WHEN argument is equivalent to using --color=always. With\n\
--color=auto, color codes are output only if standard output is connected\n\
to a terminal (tty). The environment variable LS_COLORS can influence the\n\
colors, and can be set easily by the dircolors command.\n\
Using color to distinguish file types is disabled both by default and\n\
with --color=never. With --color=auto, ls emits color codes only when\n\
standard output is connected to a terminal. The LS_COLORS environment\n\
variable can change the settings. Use the dircolors command to set it.\n\
"), stdout);
fputs (_("\
\n\
@@ -4681,7 +4701,7 @@ Exit status:\n\
1 if minor problems (e.g., cannot access subdirectory),\n\
2 if serious trouble (e.g., cannot access command-line argument).\n\
"), stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

View File

@@ -195,7 +195,7 @@ should be a former output of this program. The default mode is to print\n\
a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
text), and name for each FILE.\n"),
DIGEST_REFERENCE);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
@@ -251,11 +251,10 @@ static bool
split_3 (char *s, size_t s_len,
unsigned char **hex_digest, int *binary, char **file_name)
{
size_t i;
bool escaped_filename = false;
size_t algo_name_len;
i = 0;
size_t i = 0;
while (ISWHITE (s[i]))
++i;
@@ -263,11 +262,13 @@ split_3 (char *s, size_t s_len,
algo_name_len = strlen (DIGEST_TYPE_STRING);
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
{
if (strncmp (s + i + algo_name_len, " (", 2) == 0)
if (s[i + algo_name_len] == ' ')
++i;
if (s[i + algo_name_len] == '(')
{
*binary = 0;
return bsd_split_3 (s + i + algo_name_len + 2,
s_len - (i + algo_name_len + 2),
return bsd_split_3 (s + i + algo_name_len + 1,
s_len - (i + algo_name_len + 1),
hex_digest, file_name);
}
}
@@ -512,7 +513,6 @@ digest_check (const char *checkfile_name)
if (!status_only)
{
printf (_("%s: FAILED open or read\n"), filename);
fflush (stdout);
}
}
else
@@ -538,7 +538,6 @@ digest_check (const char *checkfile_name)
printf ("%s: %s\n", filename, _("FAILED"));
else if (!quiet)
printf ("%s: %s\n", filename, _("OK"));
fflush (stdout);
}
}
}
@@ -618,6 +617,10 @@ main (int argc, char **argv)
atexit (close_stdout);
/* Line buffer stdout to ensure lines are written atomically and immediately
so that processes running in parallel do not intersperse their output. */
setvbuf (stdout, NULL, _IOLBF, 0);
while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
switch (opt)
{
@@ -661,21 +664,21 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
if (status_only & !do_check)
if (status_only && !do_check)
{
error (0, 0,
_("the --status option is meaningful only when verifying checksums"));
usage (EXIT_FAILURE);
}
if (warn & !do_check)
if (warn && !do_check)
{
error (0, 0,
_("the --warn option is meaningful only when verifying checksums"));
usage (EXIT_FAILURE);
}
if (quiet & !do_check)
if (quiet && !do_check)
{
error (0, 0,
_("the --quiet option is meaningful only when verifying checksums"));

View File

@@ -71,7 +71,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_bug_reporting_address ();
emit_ancillary_info ();
}
exit (status);
}

Some files were not shown because too many files have changed in this diff Show More