platform/upstream/coreutils.git
17 years agoseq no longer mishandles cases like "seq 0 0.000001 0.000003",
Paul Eggert [Sat, 23 Jun 2007 07:27:11 +0000 (09:27 +0200)]
seq no longer mishandles cases like "seq 0 0.000001 0.000003",
where it would not print the desired last number.
* doc/coreutils.texi (seq invocation): Remove advice about workaround
for seq off-by-one problem, since the bug is fixed now.  Replace
it with more-generic advice about rounding errors.
* src/seq.c (long_double_format, print_numbers):
New arg NUMERIC_FORMAT.  All uses changed.

17 years agoAdd test cases for seq off-by-one problem.
Pádraig Brady [Fri, 22 Jun 2007 18:39:56 +0000 (20:39 +0200)]
Add test cases for seq off-by-one problem.

17 years ago* src/stat.c (long_options): Add a FIXME comment to help ensure
Jim Meyering [Fri, 22 Jun 2007 18:26:01 +0000 (20:26 +0200)]
* src/stat.c (long_options): Add a FIXME comment to help ensure
that the deprecated and undocumented "--filesystem" option is
removed someday.

17 years agoA few more symlink-related fixes. Fix a bug triggered by cp
Paul Eggert [Mon, 18 Jun 2007 09:58:47 +0000 (11:58 +0200)]
A few more symlink-related fixes. Fix a bug triggered by cp

--parents and symlinks.  Close some race conditions possible when
the destination replaces a newly-created file with a symlink.
* NEWS: Document that 'cp --parents' no longer mishandles
symlinks in file name components of source.
* src/copy.c (HAVE_LCHOWN): Default to false.
(lchown) [!defined HAVE_LCHOWN]: Define to chown, for convenience.
* src/cp.c (lchown) [!HAVE_LCHOWN]: Likewise.
* src/install.c (lchown [!HAVE_LCHOWN]: Likewise.
* src/copy.c (set_owner): Use lchown instead of chown, for safety
in case the file got replaced by a symlink in the meantime.
* src/cp.c (re_protect): Likewise.
* src/install.c (change_attributes): Likewise.
* src/copy.c (copy_internal): Use ordinary C rather than an #if.
* src/cp.c (lchown) [!HAVE_LCHOWN]: Define to chown, for convenience.
(struct dir_attr): Cache the entire struct stat of the directory,
rather than just its mode, so that we needn't stat the directory
twice (which can lead to races).
(re_protect): Don't use XSTAT as that's not appropriate in
this context (symlinks should be followed here).  Instead, use
the cached stat value.
(make_dir_parents_private): Save dir's entire struct stat, not
just its mode.
* tests/cp/cp-parents: Add test to check against bug with
cp --parents and symlinks.

17 years agoUse mreadlink_with_size (doesn't exit), not xreadlink_with_size.
Jim Meyering [Mon, 18 Jun 2007 09:17:30 +0000 (11:17 +0200)]
Use mreadlink_with_size (doesn't exit), not xreadlink_with_size.

* bootstrap.conf (gnulib_modules): Add readlink-with-size.
Remove xreadlink and xreadlink-with-size.
* src/copy.c (copy_internal): Use mreadlink_with_size,
not xreadlink_with_size.
* src/ls.c (get_link_name): Likewise.
* src/readlink.c (main): Likewise.
* src/stat.c (print_stat): Likewise.

17 years ago* README-hacking: Don't mention Gzip 1.2.4, now that 1.3.12 is out.
Jim Meyering [Mon, 18 Jun 2007 09:19:57 +0000 (11:19 +0200)]
* README-hacking: Don't mention Gzip 1.2.4, now that 1.3.12 is out.

17 years agoMake chgrp and chown diagnostics consistent.
Jim Meyering [Sat, 16 Jun 2007 10:53:40 +0000 (12:53 +0200)]
Make chgrp and chown diagnostics consistent.
* src/chown.c (main): Emit the diagnostic before the file name,
not after it, to be consistent with chgrp's diagnostic.
* src/chgrp.c (parse_group): Emit a ":" between the diagnostic
and the file name.
Reported by Egmont Koblinger.
* THANKS: Add Egmont Koblinger.

17 years agoCorrect cp's handling of destination symlinks in some cases.
Paul Eggert [Fri, 15 Jun 2007 20:47:16 +0000 (22:47 +0200)]
Correct cp's handling of destination symlinks in some cases.
* NEWS: "cp" no longer considers a destination symlink to be the
same as the referenced file when copying links or making backups.
* src/copy.c (copy_reg): When following a symlink, use the
followed name in later chown etc. requests, so that the created
file is affected, rather than the symlink.  Use O_NOFOLLOW on
source when not dereferencing symlinks; this avoids a race.
Preserve errno correctly when doing multiple open attempts on the
destination.
(copy_internal): Follow destination symlinks only when copying a
regular file and only when we don't intend to remove or rename the
destination first, regardless of whether following source
symlinks; this is because since POSIX and tradition (e.g.,
FreeBSD) say we should ordinarily follow destination symlinks if
the system calls would ordinarily do so.
* src/copy.h (struct cp_options): Add comment that 'dereference'
is only for source files.
* src/cp.c (usage): Note that --derereference etc. are only for
source files.
(make_dir_parents_private): Follow symlinks, regardless of whether
--dereference is specified, because these are destination symlinks.
* tests/cp/same-file: Adjust tests to match revised behavior.
Filter out perror output since it might vary from host to host.
Use sed alone instead of also using echo.

* doc/coreutils.texi (cp invocation): Document the behavior better when
the destination is a symlink.  Clarify source versus destination
symlinks.  Describe the new behavior for destination symlinks.

2007-06-15  Jim Meyering  <jim@meyering.net>

* src/copy.c: Include "canonicalize.h".
(copy_reg): Use canonicalize_filename_mode to follow the symlink,
so that we can always open with O_EXCL and avoid a race.

17 years agoDon't include "quote.h" when it is not used.
Jim Meyering [Fri, 15 Jun 2007 13:44:15 +0000 (15:44 +0200)]
Don't include "quote.h" when it is not used.
* src/md5sum.c: Remove unnecessary inclusion of "quote.h".
* src/expr.c: Likewise.
* src/shred.c: Likewise.
* Makefile.maint (sc_prohibit_quote_without_use): New rule.
* src/c99-to-c89.diff: Adjust offsets.

17 years agoClarify what "cat" documentation means by "blank" lines.
Paul Eggert [Fri, 15 Jun 2007 07:29:18 +0000 (09:29 +0200)]
Clarify what "cat" documentation means by "blank" lines.
* doc/coreutils.texi (cat invocation): "Blank" lines actually mean
empty lines.
* src/cat.c (usage): Say that "nonblank" means nonempty.  Clarify
--squeeze-blank.

17 years agormdir: give better diagnostics
Jim Meyering [Wed, 13 Jun 2007 13:53:12 +0000 (15:53 +0200)]
rmdir: give better diagnostics
* src/rmdir.c (remove_parents): Give a more descriptive/consistent
diagnostic upon failure.
(main): Likewise.
Suggestion from Joey Hess.
* THANKS: Add Joey Hess.

17 years agoDon't include "quotearg.h" when it is not used.
Jim Meyering [Wed, 13 Jun 2007 13:33:38 +0000 (15:33 +0200)]
Don't include "quotearg.h" when it is not used.
* Makefile.maint (sc_prohibit_quotearg_without_use): New rule.
* src/cp.c: Don't include "quotearg.h".  It wasn't used.

17 years ago* README-hacking: List Gperf as a build-requirement, too.
Jim Meyering [Wed, 13 Jun 2007 06:00:41 +0000 (08:00 +0200)]
* README-hacking: List Gperf as a build-requirement, too.
Reported by Steve Ward.

17 years agoREADME: Also mention README-hacking,
Jim Meyering [Mon, 11 Jun 2007 09:07:21 +0000 (11:07 +0200)]
README: Also mention README-hacking,
for whose who start from
cloned/checked-out sources rather than from a distribution tarball.
Reported by Steve Ward.
* THANKS: Add Steve Ward.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Sun, 10 Jun 2007 16:39:53 +0000 (18:39 +0200)]
Add to .cvsignore and .gitignore files.

17 years agobug-fix: cp would fail to write through a dangling symlink
Jim Meyering [Sun, 10 Jun 2007 12:56:39 +0000 (14:56 +0200)]
bug-fix: cp would fail to write through a dangling symlink
* NEWS: Mention the bug fix.
* src/copy.c (copy_reg): When open fails with EEXIST, the destination
is lstat'able, and a symlink, call open again, but now without O_EXCL.
* tests/cp/thru-dangling: New file, to test for the above fix.
* tests/cp/Makefile.am (TESTS): Add thru-dangling.
* THANKS: Add Michael McLagan.
Bug report from Michael McLagan in <http://bugzilla.redhat.com/243588>.

17 years ago* coreutils.texi (rmdir invocation): Fix a tiny typo.
Jim Meyering [Wed, 6 Jun 2007 06:00:44 +0000 (08:00 +0200)]
* coreutils.texi (rmdir invocation): Fix a tiny typo.

17 years agodoc: -h and --human-readable are equivalent to --block-size=human-readable
Paul Eggert [Mon, 4 Jun 2007 17:31:22 +0000 (19:31 +0200)]
doc: -h and --human-readable are equivalent to --block-size=human-readable
* doc/coreutils.texi (Common options): Mention that -h and
--human-readable are equivalent to --block-size=human-readable.
Documentation problem reported by Steve Ward in
<http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00007.html>.
(du invocation): Use optSi rather than duplicating the macro's
contents (incorrectly, since we claimed a "B" was output).

17 years agoRemove constants.texi from version control.
Jim Meyering [Sun, 3 Jun 2007 19:55:09 +0000 (21:55 +0200)]
Remove constants.texi from version control.

This file has always been generated.
* .gitignore: Add constants.texi.

Signed-off-by: Jim Meyering <jim@meyering.net>
17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Sat, 2 Jun 2007 21:00:09 +0000 (23:00 +0200)]
Add to .cvsignore and .gitignore files.

17 years agoPull printf-related code from gnulib, rather than using forked copy.
Jim Meyering [Thu, 31 May 2007 14:40:51 +0000 (16:40 +0200)]
Pull printf-related code from gnulib, rather than using forked copy.
* bootstrap.conf (gnulib_modules): Don't avoid size_max and xsize
modules.  While I dislike xsize-style overflow avoidance, maintaining
a forked version of e.g., vasnprintf.c was too much work.
* lib/printf-parse.c, lib/vasnprintf.c, lib/unicodeio.c: Remove local
copies, so we now get these files from gnulib.

17 years ago* src/dircolors.hin: Add screen-256color.
Jim Meyering [Thu, 31 May 2007 06:05:02 +0000 (08:05 +0200)]
* src/dircolors.hin: Add screen-256color.
Suggested by sdl.web@gmail.com in <http://bugzilla.redhat.com/239266>.

17 years ago* TODO: Add an entry for comm --output-delimiter=STR
Jim Meyering [Thu, 31 May 2007 06:03:40 +0000 (08:03 +0200)]
* TODO: Add an entry for comm --output-delimiter=STR

17 years agowc: ignore multibyte-character decoding errors
James Youngman [Sat, 26 May 2007 05:08:18 +0000 (07:08 +0200)]
wc: ignore multibyte-character decoding errors
* src/wc.c (wc): Don't issue an error message when mbrtowc
indicates that we have seen an invalid byte sequence.  This
makes "wc /bin/sh" bearable (though the word and line counts
are likely not to be useful).
* NEWS: Mention the change.

17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Sat, 26 May 2007 04:30:30 +0000 (06:30 +0200)]
Add to .cvsignore and .gitignore files.

17 years agoCheck for an up-to-date copyright year in coreutils.texi.
Jim Meyering [Tue, 22 May 2007 18:41:00 +0000 (20:41 +0200)]
Check for an up-to-date copyright year in coreutils.texi.
* Makefile.maint (copyright-check): Also check for an up-to-date
copyright year in doc/$().texi, if that file exists.
* doc/coreutils.texi: Add 2007 to list of Copyright years.
Reported by Karl Berry.

17 years agocut: diagnose a range starting with 0 (-f 0-2) as invalid, and
Jim Meyering [Tue, 22 May 2007 12:25:19 +0000 (14:25 +0200)]
cut: diagnose a range starting with 0 (-f 0-2) as invalid, and
give a better diagnostic for a field-number/offset of 0.
* NEWS: Mention the fix.
* src/cut.c (ADD_RANGE_PAIR): Add an explicit check for 0.
Based on a patch from James Youngman.
* tests/misc/cut: Add tests for the above.

17 years ago"cut -f 2-0" now fails; before, it was equivalent to "cut -f 2-"
Jim Meyering [Tue, 22 May 2007 11:56:34 +0000 (13:56 +0200)]
"cut -f 2-0" now fails; before, it was equivalent to "cut -f 2-"
Also, diagnose the '-' in "cut -f -" as an invalid range, rather
than interpreting it as the unlimited range, "1-".
* NEWS: Mention these changes.
* src/cut.c (set_fields): Don't interpret an accumulator "value"
of 0 as an unspecified range endpoint.
Give better diagnostics.
Adjust a comment so that it is true also for 64-bit size_t.
* tests/cut/Test.pm: Add tests for the above.

17 years agostty: fix a harmless syntax nit
Jim Meyering [Tue, 22 May 2007 05:58:42 +0000 (07:58 +0200)]
stty: fix a harmless syntax nit
* src/stty.c (visible): Use ";" as the statement terminator
between two assignments, not ",".
(integer_arg): Join an unnecessarily wrapped line.

17 years agostty: diagnose an invalid hex value in 35-colon commmand-line argument
Jim Meyering [Sun, 20 May 2007 12:45:38 +0000 (14:45 +0200)]
stty: diagnose an invalid hex value in 35-colon commmand-line argument
* NEWS: Mention this.
* src/stty.c (strtoul_tcflag_t, strtoul_cc_t): New functions.
(recover_mode): Use those functions (not sscanf), to parse the
string robustly.
* tests/stty/invalid: New file.  Test for the above.
* tests/stty/Makefile.am (TESTS): Add invalid.
* .x-sc_prohibit_atoi_atof: Don't exempt stty.c from this check.
Add tests/stty/invalid so we don't have to obfuscate the comment
about sscanf therein.
* Makefile.maint (sc_prohibit_atoi_atof): Mention sscanf in the
diagnostic, too.

17 years ago* TODO: Remove some now-completed or no longer relevant items.
Jim Meyering [Sun, 20 May 2007 12:04:28 +0000 (14:04 +0200)]
* TODO: Remove some now-completed or no longer relevant items.

17 years agoRename uses of futimens -> gl_futimens; glibc now declares the former.
Jim Meyering [Sat, 19 May 2007 16:36:03 +0000 (18:36 +0200)]
Rename uses of futimens -> gl_futimens; glibc now declares the former.
* src/copy.c (copy_reg): Reflect renaming: futimens -> gl_futimens.
* src/touch.c (touch): Likewise.

17 years ago* Makefile.maint (my-distcheck): Remove -pedantic from $(CFLAGS)
Jim Meyering [Fri, 18 May 2007 07:01:03 +0000 (09:01 +0200)]
* Makefile.maint (my-distcheck): Remove -pedantic from $(CFLAGS)
for now, to avoid c89-check failure due to use of #include_next.

17 years agoGenerate a dozen test-related Makefile.am files at bootstrap-time.
Jim Meyering [Tue, 15 May 2007 08:18:48 +0000 (10:18 +0200)]
Generate a dozen test-related Makefile.am files at bootstrap-time.
* README-hacking: Build-from-checkout now require Perl, too.
* bootstrap: Now that these generated Makefile.am files are no longer
under version control, they must be created at bootstrap time.

17 years ago* man/chmod.x: Document chmod's behavior with setuid and setgid bits.
Paul Eggert [Tue, 15 May 2007 05:14:55 +0000 (07:14 +0200)]
* man/chmod.x: Document chmod's behavior with setuid and setgid bits.
Remove misleading implication about leading zero.  Problem
reported by Jan Engelhardt in
<http://lists.gnu.org/archive/html/bug-coreutils/2007-05/msg00134.html>.

17 years agoRemove the generated tests/*/Makefile.am files from version control.
Jim Meyering [Sun, 13 May 2007 16:23:41 +0000 (18:23 +0200)]
Remove the generated tests/*/Makefile.am files from version control.
* tests/cut/Makefile.am: git-remove this generated file.
* tests/head/Makefile.am: Likewise.
* tests/join/Makefile.am: Likewise.
* tests/pr/Makefile.am: Likewise.
* tests/sort/Makefile.am: Likewise.
* tests/tac/Makefile.am: Likewise.
* tests/tail/Makefile.am: Likewise.
* tests/test/Makefile.am: Likewise.
* tests/tr/Makefile.am: Likewise.
* tests/uniq/Makefile.am: Likewise.
* tests/wc/Makefile.am: Likewise.
* .cvsignore, .gitignore: Ignore these generated files.

* src/.cvsignore, src/.gitignore: Add chcon here, ...
* .cvsignore, .gitignore: ... not here.

17 years agoTest uniq's new --zero-terminated (-z) option.
Jim Meyering [Sun, 13 May 2007 09:08:01 +0000 (11:08 +0200)]
Test uniq's new --zero-terminated (-z) option.
* tests/uniq/Test.pm: When possible, create a "-z"-testing variant
of each existing test.
(2z, 3z, 4z, 5z, 20z, 122, 123): New tests from James Youngman.

17 years agoAdd -z option to uniq. Originally proposed by Egmont Koblinger.
James Youngman [Sun, 13 May 2007 09:02:43 +0000 (11:02 +0200)]
Add -z option to uniq.  Originally proposed by Egmont Koblinger.
* NEWS: Mention uniq's new option: --zero-terminated (-z).
* src/uniq.c: Add new option, --zero-terminated (-z), to make
uniq use the NUL byte as separator/delimiter rather than newline.
(check_file): Add a parameter: delimiter.  Update caller.
Use readlinebuffer_delim in place of readlinebuffer everywhere.
(main): Handle the new option.
(usage): Describe new option the same way sort does.
* doc/coreutils.texi (uniq invocation): Describe the new option.

17 years ago* NEWS: Mention that last week's tr bug dates back to 1992.
Jim Meyering [Mon, 7 May 2007 19:56:27 +0000 (21:56 +0200)]
* NEWS: Mention that last week's tr bug dates back to 1992.

17 years agoAvoid test failure when run with an unusual umask.
Jim Meyering [Fri, 4 May 2007 11:32:46 +0000 (13:32 +0200)]
Avoid test failure when run with an unusual umask.
* tests/ls/color-dtype-dir: Set umask to 022.
Suggestion from AIDA Shinra.

17 years agoAvoid failure of root-only test when run with a restrictive umask.
Jim Meyering [Fri, 4 May 2007 10:01:43 +0000 (12:01 +0200)]
Avoid failure of root-only test when run with a restrictive umask.
* tests/rm/no-give-up: Ensure that non-root can access "d/" through
root-owned ".".  Reported by AIDA Shinra.

17 years agotr -c: don't abort when translating with S2 larger than complement of S1
Jim Meyering [Fri, 4 May 2007 07:57:10 +0000 (09:57 +0200)]
tr -c: don't abort when translating with S2 larger than complement of S1
* src/tr.c (main): Remove invalid assertion triggered by e.g.,
tr -c a '[b*256]'.  There's nothing wrong with having Set2 larger
than Set1.  Reported by Guntram Blohm.
* tests/tr/Test.pm (no-abort-1): Test for the above.
* NEWS: Mention this bug fix.
* THANKS: Add Guntram Blohm.

17 years agoAvoid test failure when run with a permissive umask.
Jim Meyering [Thu, 3 May 2007 17:36:34 +0000 (19:36 +0200)]
Avoid test failure when run with a permissive umask.
* tests/rm/no-give-up: Set permissions of test directory properly,
i.e., not depending on umask prohibiting go=w.
Reported by AIDA Shinra.

17 years agoThe following commands and options now support the standard size
Paul Eggert [Thu, 3 May 2007 11:45:26 +0000 (13:45 +0200)]
The following commands and options now support the standard size
suffixes kB, M, MB, G, GB, and so on for T, P, Y, Z, and Y:
head -c, head -n, od -j, od -N, od -S, split -b, split -C,
tail -c, tail -n.
* doc/coreutils.texi (od invocation, head invocation, tail invocation):
Document support for new size suffixes.
(head invocation, tail invocation):
Document that -n uses the same suffixes as -c.
(tail invocation): More-clearly document what leading "+" does.
* src/head.c (usage, string_to_integer): Support new suffixes.
* src/od.c (usage, main): Likewise.
* src/split.c (usage, main): Likewise.
* src/tail.c (usage, parse_options): Likewise.
Prompted by a patch from Evan Hunt.

17 years ago* src/du.c (usage): Tweak description of --dereference-args (-D) again.
Jim Meyering [Wed, 2 May 2007 21:37:55 +0000 (23:37 +0200)]
* src/du.c (usage): Tweak description of --dereference-args (-D) again.
Prompted by another request for clarification from Justin Pryzby.

17 years agoInvoke rm via 'setuidgid ... env PATH="$PATH" ...', as in fail-eperm.
Jim Meyering [Wed, 2 May 2007 21:30:00 +0000 (23:30 +0200)]
Invoke rm via 'setuidgid ... env PATH="$PATH" ...', as in fail-eperm.
* tests/rm/fail-2eperm: Patch from AIDA Shinra.
Reported by Peter Dyballa.
* THANKS: Add AIDA Shinra and Peter Dyballa.

17 years ago* src/nohup.c (usage): Describe how standard input and output are redirected.
Paul Eggert [Sat, 28 Apr 2007 18:47:29 +0000 (20:47 +0200)]
* src/nohup.c (usage): Describe how standard input and output are redirected.

17 years agoAdd "runcon" to .cvsignore and .gitignore files.
Jim Meyering [Wed, 25 Apr 2007 13:52:53 +0000 (15:52 +0200)]
Add "runcon" to .cvsignore and .gitignore files.

17 years ago* src/du.c (usage): Clarify description of --dereference-args (-D).
Jim Meyering [Wed, 25 Apr 2007 11:54:21 +0000 (13:54 +0200)]
* src/du.c (usage): Clarify description of --dereference-args (-D).
Prompted by a report from Justin Pryzby.

17 years ago* bootstrap.conf (gnulib_modules): Add autobuild.
Jim Meyering [Wed, 25 Apr 2007 09:29:27 +0000 (11:29 +0200)]
* bootstrap.conf (gnulib_modules): Add autobuild.
* m4/autobuild.m4: Remove file.  Now, provided by gnulib.

17 years ago* bootstrap.conf (gnulib_modules): Add fseeko and ftello.
Jim Meyering [Wed, 25 Apr 2007 08:55:56 +0000 (10:55 +0200)]
* bootstrap.conf (gnulib_modules): Add fseeko and ftello.

17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Wed, 25 Apr 2007 08:55:35 +0000 (10:55 +0200)]
Add to .cvsignore and .gitignore files.

17 years ago* bootstrap.conf (gnulib_modules): Add fseeko.
Jim Meyering [Wed, 25 Apr 2007 08:40:12 +0000 (10:40 +0200)]
* bootstrap.conf (gnulib_modules): Add fseeko.

17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Wed, 25 Apr 2007 08:39:48 +0000 (10:39 +0200)]
Add to .cvsignore and .gitignore files.

17 years ago* THANKS: Add Andreas Frische.
Jim Meyering [Tue, 24 Apr 2007 07:20:52 +0000 (09:20 +0200)]
* THANKS: Add Andreas Frische.
* NEWS: Mention today's ls --color fix.
* tests/ls-2/tests (sl-dangle): Add a test for today's fix.

17 years agols --color once again colors dangling symlinks correctly
Eric Blake [Tue, 24 Apr 2007 07:18:56 +0000 (09:18 +0200)]
ls --color once again colors dangling symlinks correctly
* src/ls.c (gobble_file): Much like the 2007-04-07 fix,
add a term to the expression that decides whether we need
stat and/or lstat calls.  Reported by Andreas Frische.

17 years agocut synopsis: fix coreutils.texi, too.
Jim Meyering [Mon, 16 Apr 2007 20:00:28 +0000 (22:00 +0200)]
cut synopsis: fix coreutils.texi, too.
* doc/coreutils.texi (cut invocation): Adjust synopsis to show that an
* THANKS: Add Rudolf Kastl.
OPTION is required.  Reported by Rudolf Kastl.

17 years ago* src/cut.c (usage): Adjust synopsis to show that an OPTION is required.
Jim Meyering [Mon, 16 Apr 2007 14:26:13 +0000 (16:26 +0200)]
* src/cut.c (usage): Adjust synopsis to show that an OPTION is required.
Reported by Rudolf Kastl.

17 years agoAdd to .cvsignore and .gitignore files.
Jim Meyering [Thu, 12 Apr 2007 12:48:50 +0000 (14:48 +0200)]
Add to .cvsignore and .gitignore files.

17 years agosplit --line-bytes=N (-C N): don't create an empty file.
Paul Eggert [Wed, 11 Apr 2007 22:21:25 +0000 (00:21 +0200)]
split --line-bytes=N (-C N): don't create an empty file.
* src/split.c (line_bytes_split): Don't create an empty line
afterwards if the last buffer happens to be exactly full.
* tests/misc/split-fail: Add a test case for this.
* NEWS: mention this.

17 years agols: don't form or compute the length of strings that won't be used.
Jim Meyering [Mon, 9 Apr 2007 22:18:25 +0000 (00:18 +0200)]
ls: don't form or compute the length of strings that won't be used.
* src/ls.c (gobble_file): Form and compute length of strings for
block size, owner, group, author, major+minor numbers and file size
only if they'll actually be used.  I.e., don't form most of them
when not producing long format output.

17 years agoAdd a test for, and document, today's fix.
Jim Meyering [Sat, 7 Apr 2007 18:46:27 +0000 (20:46 +0200)]
Add a test for, and document, today's fix.
* NEWS: Mention today's ls --color fix.
* tests/ls-2/tests (sl-target): Add a test for today's fix.
* THANKS: Add Kirk Kelsey.

17 years agoFix a bug in how the LS_COLORS ln=target attribute is handled.
Eric Blake [Sat, 7 Apr 2007 18:14:07 +0000 (20:14 +0200)]
Fix a bug in how the LS_COLORS ln=target attribute is handled.
* src/ls.c (gobble_file): Use "stat" (not lstat) also when the
ln=target attribute applies.  Reported by Kirk Kelsey.

17 years ago* src/copy.c (copy_reg): Initialize local "con", before calling
Jim Meyering [Mon, 2 Apr 2007 20:06:22 +0000 (22:06 +0200)]
* src/copy.c (copy_reg): Initialize local "con", before calling
getfscreatecon, in case that function (or its inline stub) does
not set it.

17 years ago* src/ls.c (print_horizontal): Fix bug reported by Mike Frysinger:
Paul Eggert [Mon, 2 Apr 2007 16:27:34 +0000 (18:27 +0200)]
* src/ls.c (print_horizontal): Fix bug reported by Mike Frysinger:
ls -x DIR would sometimes output the wrong string in place of the
first entry.
* NEWS: Mention the bug fix.
* tests/ls/x-option: New file.
* tests/ls/Makefile.am (TESTS): Add x-option.

17 years agognulib moved md5 and sha1 modules into a new crypt/ directory; adapt
Paul Eggert [Mon, 2 Apr 2007 12:48:35 +0000 (14:48 +0200)]
gnulib moved md5 and sha1 modules into a new crypt/ directory; adapt
* bootstrap.conf (gnulib_modules): Adjust to gnulib's renaming of
md5 to crypt/md5 and sha1 to crypt/sha1.

17 years ago* NEWS: Mention these SELinux changes.
Jim Meyering [Fri, 30 Mar 2007 14:02:54 +0000 (16:02 +0200)]
* NEWS: Mention these SELinux changes.

17 years ago* ChangeLog-selinux: Remove file.
Jim Meyering [Fri, 30 Mar 2007 09:16:00 +0000 (11:16 +0200)]
* ChangeLog-selinux: Remove file.
Move its contents into this file, removing old dates.

17 years ago* src/runcon.c (main): Don't reorder arguments. Reported by
Jim Meyering [Sun, 18 Mar 2007 17:04:30 +0000 (18:04 +0100)]
* src/runcon.c (main): Don't reorder arguments. Reported by

Ulrich Drepper in <http://bugzilla.redhat.com/232652>.
* tests/misc/runcon-no-reorder: New file.  Test for the above.
* tests/misc/Makefile.am (TESTS): Add runcon-no-reorder.

17 years ago* src/runcon.c (main): Remove "." at end of a diagnostic.
Jim Meyering [Sun, 18 Mar 2007 16:52:00 +0000 (17:52 +0100)]
* src/runcon.c (main): Remove "." at end of a diagnostic.

17 years agoArrange for "make check-root" to run the new root-only test.
Jim Meyering [Mon, 12 Feb 2007 18:35:25 +0000 (19:35 +0100)]
Arrange for "make check-root" to run the new root-only test.

* tests/Makefile.am (t9): New target, to run tests/cp/cp-a-selinux.
(all_t): Add t9.

Use a directory on a loopback device mounted with -o context=...
* tests/cp/cp-a-selinux: Since this test now runs mount and umount,
it is a root-only one.

17 years ago* src/runcon.c: New program.
Jim Meyering [Fri, 2 Feb 2007 17:58:41 +0000 (18:58 +0100)]
* src/runcon.c: New program.

* src/Makefile.am (bin_PROGRAMS): Add runcon.
(runcon_LDADD): Define.
* README: Add runcon to the list of programs.
* AUTHORS: Add this: runcon: Russell Coker
* tests/help-version: Add runcon as an exception.
* man/Makefile.am (dist_man_MANS): Add runcon.1.
(runcon.1): New dependency.
* po/POTFILES.in: Add src/runcon.c.

17 years agoRegenerate .cvsignore and .gitignore files.
Jim Meyering [Thu, 1 Feb 2007 17:07:36 +0000 (18:07 +0100)]
Regenerate .cvsignore and .gitignore files.

17 years agomkfifo, mknod: Accept new "-Z, --context=C" option.
Jim Meyering [Wed, 31 Jan 2007 23:26:07 +0000 (00:26 +0100)]
mkfifo, mknod: Accept new "-Z, --context=C" option.

* src/mkfifo.c, src/mknod.c: Include <selinux/selinux.h>.
(main): Honor it.
* src/Makefile.am (mkfifo_LDADD, mknod_LDADD): Use $(LIB_SELINUX).

17 years agomkdir: Accept new "-Z, --context=C" option.
Jim Meyering [Wed, 31 Jan 2007 22:59:46 +0000 (23:59 +0100)]
mkdir: Accept new "-Z, --context=C" option.

* src/mkdir.c: Include <selinux/selinux.h>.
(main): Honor it.
* src/Makefile.am (mkdir_LDADD): Use $(LIB_SELINUX).

17 years ago* tests/cp/cp-a-selinux: New file. Test for the bug reported in
Jim Meyering [Wed, 31 Jan 2007 22:01:50 +0000 (23:01 +0100)]
* tests/cp/cp-a-selinux: New file. Test for the bug reported in

* tests/cp/Makefile.am (TESTS): Add cp-a-selinux.

* tests/selinux: New file.
* tests/Makefile.am (EXTRA_DIST): Add selinux.
* tests/misc/selinux: Source the new script, rather than open coding it.

Change how "cp -a" and "cp --preserve=context" work with SELinux.
Now, cp -a attempts to preserve context, but failure to do so does
not change cp's exit status.  However "cp --preserve=context" is
similar, but failure *does* cause cp to exit with nonzero status.
* src/copy.h (struct cp_options) [require_preserve_context]: New member.
* src/copy.c (copy_reg, copy_internal): Implement the above.
* src/mv.c (cp_option_init): Initialize the new member.
* src/install.c (cp_option_init): Likewise.
* src/cp.c (cp_option_init): Likewise.
(decode_preserve_arg): Set it or reset it.

FIXME: add an on-writable-NFS-only test

17 years ago* src/system.h (GETOPT_SELINUX_CONTEXT_OPTION_DECL): Define.
Jim Meyering [Sat, 20 Jan 2007 15:33:00 +0000 (16:33 +0100)]
* src/system.h (GETOPT_SELINUX_CONTEXT_OPTION_DECL): Define.

17 years agocp, mv, install: add SELinux support, but unlike with the Red Hat
Jim Meyering [Sat, 20 Jan 2007 15:10:43 +0000 (16:10 +0100)]
cp, mv, install: add SELinux support, but unlike with the Red Hat

patch, mv and cp do not provide the "-Z context" option.
* src/copy.c: Include <selinux/selinux.h>.
(restore_default_fscreatecon): New function.
(copy_reg): Make cp --preserve=context work for existing destination.
(copy_internal): Likewise for new destinations.
* src/copy.h (cp_options) [preserve_security_context]: New member.
* src/cp.c: Include <selinux/selinux.h>.
(selinux_enabled): New global.
(usage): Mention new --preserve=context option.
(PRESERVE_CONTEXT): Define/use.
(decode_preserve_arg): Handle PRESERVE_CONTEXT.
(main): Remove an obsolete comment.
If --preserve=context is specified on a system without SELinux
enabled, give a diagnostic and fail.
* src/mv.c: Include <selinux/selinux.h>.
Set x->preserve_security_context if SELinux is enabled.
* src/install.c: Accept new "-Z, --context=C" option.
Accept --preserve-context option (but not -P option).
Accept alternate spelling: --preserve_context, for now.
Include <selinux/selinux.h> and "quotearg.h".
(selinux_enabled, use_default_selinux_context): New globals.
(PRESERVE_CONTEXT_OPTION): Define.
(cp_option_init): Default: do not preserve security context.
(setdefaultfilecon): New function.
(main): Honor new options.
* src/Makefile.am (mv_LDADD, cp_LDADD, ginstall_LDADD):
Add $(LIB_SELINUX).

17 years ago* tests/misc/selinux [VERBOSE]: Print version info for each
Jim Meyering [Sat, 13 Jan 2007 18:29:21 +0000 (19:29 +0100)]
* tests/misc/selinux [VERBOSE]: Print version info for each

of the tested tools, not just ls.

17 years ago* src/c99-to-c89.diff: Remove the ls.c patch, now that I've
Jim Meyering [Sat, 13 Jan 2007 18:27:41 +0000 (19:27 +0100)]
* src/c99-to-c89.diff: Remove the ls.c patch, now that I've

temporarily removed the offending c99'ism.

17 years ago* src/chcon.c (usage): Split a string literal that was longer than 509.
Jim Meyering [Sat, 13 Jan 2007 17:24:06 +0000 (18:24 +0100)]
* src/chcon.c (usage): Split a string literal that was longer than 509.

17 years ago* src/ls.c (gobble_file): Don't call getfilecon unless print_scontext.
Jim Meyering [Sat, 13 Jan 2007 17:22:46 +0000 (18:22 +0100)]
* src/ls.c (gobble_file): Don't call getfilecon unless print_scontext.

Upon failed getfilecon, accept not just ENOTSUP, but also ENODATA.

17 years ago* src/c99-to-c89.diff: Adjust offsets.
Jim Meyering [Sat, 13 Jan 2007 17:12:01 +0000 (18:12 +0100)]
* src/c99-to-c89.diff: Adjust offsets.

17 years ago* AUTHORS: Add chcon.
Jim Meyering [Sat, 13 Jan 2007 16:49:17 +0000 (17:49 +0100)]
* AUTHORS: Add chcon.

17 years ago* src/c99-to-c89.diff: Remove trailing blanks.
Jim Meyering [Sat, 13 Jan 2007 16:22:57 +0000 (17:22 +0100)]
* src/c99-to-c89.diff: Remove trailing blanks.

17 years ago* src/chcon.c: Don't include "dirname.h". system.h already includes it.
Jim Meyering [Sat, 13 Jan 2007 16:19:16 +0000 (17:19 +0100)]
* src/chcon.c: Don't include "dirname.h". system.h already includes it.

17 years ago* gl/lib/selinux-at.c: Remove a use of HAVE_CONFIG_H.
Jim Meyering [Sat, 13 Jan 2007 16:17:19 +0000 (17:17 +0100)]
* gl/lib/selinux-at.c: Remove a use of HAVE_CONFIG_H.

17 years ago* src/c99-to-c89.diff: Handle a new c99'ism in ls.c.
Jim Meyering [Sat, 13 Jan 2007 16:13:49 +0000 (17:13 +0100)]
* src/c99-to-c89.diff: Handle a new c99'ism in ls.c.

17 years ago* src/id.c (main): Tweak id -Z diagnostic.
Jim Meyering [Sat, 13 Jan 2007 15:43:07 +0000 (16:43 +0100)]
* src/id.c (main): Tweak id -Z diagnostic.

17 years ago* POTFILES.in: Add src/chcon.c.
Jim Meyering [Sat, 13 Jan 2007 15:30:04 +0000 (16:30 +0100)]
* POTFILES.in: Add src/chcon.c.

17 years agoid: Add SELinux support: -Z option.
Jim Meyering [Sat, 13 Jan 2007 15:15:41 +0000 (16:15 +0100)]
id: Add SELinux support: -Z option.

* src/id.c (main): Apply patches from Fedora, with these changes:
Remove #ifdef WITH_SELINUX.
Use error (EXIT_FAILURE, not fprintf+exit(1).
* src/Makefile.am (id_LDADD): Define, so as to add $(LIB_SELINUX).

17 years agoKeep SELinux-related ChangLog entries here.
Jim Meyering [Sat, 13 Jan 2007 11:12:03 +0000 (12:12 +0100)]
Keep SELinux-related ChangLog entries here.

17 years agostat: Add support for SELinux in the form of a %C format directive.
Jim Meyering [Sun, 7 Jan 2007 08:15:42 +0000 (09:15 +0100)]
stat: Add support for SELinux in the form of a %C format directive.

* src/stat.c (follow_links): Make this variable file-global.
(out_file_context): New function.
(print_statfs): Honor %C.
(print_stat): Honor %C.
(do_stat): Remove follow_links parameter.
(usage): Document the two %C directives.
(main): Accept -Z (though it's a no-op).
* src/Makefile.am (stat_LDADD): Define.

17 years agoadd chcon
Jim Meyering [Sat, 6 Jan 2007 17:38:51 +0000 (18:38 +0100)]
add chcon

17 years agols: Add support for SELinux and a slightly modified -Z option.
Jim Meyering [Fri, 5 Jan 2007 17:23:54 +0000 (18:23 +0100)]
ls: Add support for SELinux and a slightly modified -Z option.

I started with the patches from Red Hat.
The entries below tell how the code evolved.

* src/ls.c (print_long_format, print_file_name_and_frills): When
there is no security context (due to getfilecon/lgetfilecon failing
with e.g. ENOTSUP), print it as "?", not "".
* src/ls.c (print_file_name_and_frills): Make -Z work without -l.
(length_of_file_name_and_frills): Likewise.

* src/ls.c: Remove the --lcontext and --scontext options.
Change the way -Z, --context work so that it no longer implies -l.
Thus, -Z -l will work like -lcontext and -Z without -l will work
like --scontext.

Adjust tests to reflect new 'ls -l' syntax -- affects only
systems with SELinux when operating on a file with no ACL.
These tests assumed that everything before the first space on
each line is the 10-byte mode string.  But there may also be a "+"
in the 11th column, just before the space.  However, note that this
is not new.  The same thing would have happened even without the
change below, when listing a file with an ACL.
* tests/chmod/equals, tests/cp/cp-parents, tests/cp/fail-perm:
* tests/cp/link-preserve, tests/install/basic-1, tests/misc/mknod:
* tests/mkdir/parents, tests/mkdir/special-1, tests/mv/partition-perm:

Don't make compilation depend on USE_ACL.  An SELinux security
context counts as an "alternate access control method", so ls
must output a "+" for each file with a security context.
* src/ls.c [struct fileinfo] (have_acl): Declare unconditionally.
(FILE_HAS_ACL): Remove macro definition.  Use f->have_acl directly.
(gobble_file): Record whether a file has a security context, and
update the condition used to determine whether to print the "+".
(gobble_file): Call getfilecon/lgetfilecon also when
format == long_format, so that we get the "+".

* src/ls.c (gobble_file): Add a comment explaining why (with a
security context option) ls doesn't exit nonzero due to e.g.,
getfilecon failing with errno == ENOTSUP.

* src/ls.c (gobble_file): Ignore failure of getfilecon if it's due
to ENOTSUP.

* src/ls.c (gobble_file): Factor out three small blocks using
getfilecon and lgetfilecon.
Don't ignore return value from getfilecon and lgetfilecon.

* src/ls.c (print_long_format): Don't use ?: (empty 2nd arg with C
ternary operator).
(print_scontext_format): Likewise.
(print_scontext): Declare to be "bool", not int.  Adjust uses.

* src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): Add $(LIB_SELINUX).

* tests/misc/chcon: New file.
* tests/misc/chcon-fail: New file.
* tests/Makefile.am (check-root): Run new, root-only misc/chcon test.
* tests/misc/Makefile.am (TESTS): Add chcon and chcon-fail.

* tests/misc/Makefile.am (TESTS): Add selinux.
* tests/misc/selinux: New file.
* tests/help-version: Skip chcon.

17 years ago* man/chcon.x: New file.
Jim Meyering [Thu, 4 Jan 2007 15:41:46 +0000 (16:41 +0100)]
* man/chcon.x: New file.

* man/Makefile.am: Build chcon.1.

17 years ago.cvsignore, .gitignore: update
Jim Meyering [Thu, 4 Jan 2007 15:35:31 +0000 (16:35 +0100)]
.cvsignore, .gitignore: update

17 years agoNew program: chcon
Jim Meyering [Thu, 4 Jan 2007 15:33:43 +0000 (16:33 +0100)]
New program: chcon

* gl/modules/selinux-at: New module.  Check for libselinux and set
LIB_SELINUX here, unconditionally, rather than depending on
the configure-time --enable-selinux option.
* gl/modules/selinux-h: New module.
* bootstrap.conf (gnulib_modules): Add selinux-at.
* gl/lib/selinux-at.c, gl/lib/selinux-at.h: New files.
* gl/lib/se-selinux_.h: New file.
* gl/lib/se-context_.h: New file.
* gl/m4/selinux-selinux-h.m4: New file.
* gl/m4/selinux-context-h.m4: New file.
* src/Makefile.am (bin_PROGRAMS): Add chcon.
(chcon_LDADD): Define.
* README: Add chcon to the list of programs.
* src/chcon.c: Rewrite the original (Red Hat) chcon to use fts.

17 years agoMerge branch 'master' of /cu
Jim Meyering [Thu, 29 Mar 2007 19:36:38 +0000 (21:36 +0200)]
Merge branch 'master' of /cu

17 years ago* .vg-suppressions: Add libc-getpwuid-leak.
Jim Meyering [Thu, 29 Mar 2007 19:35:20 +0000 (21:35 +0200)]
* .vg-suppressions: Add libc-getpwuid-leak.