Commit Graph

567 Commits

Author SHA1 Message Date
Jim Meyering
f433c3835f "rm -r DIR" would mistakenly prompt about very long names
* src/remove.c (write_protected_non_symlink): Return 0(-1) when
euidaccess_stat pronounces a writable(not-writable) file, not -1(0).
* tests/rm/deep-2: New file.  Test for the above-fixed bug.
* tests/rm/Makefile.am (TESTS): Add deep-2.
Discovered while reviewing this change:
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/13071
2008-03-31 13:46:34 +02:00
Jim Meyering
0d34887fe9 * NEWS: Note the dd bug fix. The bug was introduced over 8 years ago:
9fca49f67c
2008-03-31 09:11:15 +02:00
Jim Meyering
eb8fa94f2c mknod, mkfifo: don't segfault when diagnosing invalid SELinux context
Identical to the bug fixed by 72d052896a.
* src/mkfifo.c (main): Use "scontext", not NULL optarg in diagnostic.
* src/mknod.c (main): Likewise.
Reported by Cristian Cadar, Daniel Dunbar and Dawson Engler.
* tests/mkdir/selinux: Test for the above fixes.
* NEWS: Mention the fixes.
2008-03-28 23:03:27 +01:00
Jim Meyering
cdb16829a6 Fix typo in old NEWS and ChangeLog: s/commmand/command/.
* ChangeLog-2007: Likewise.
* NEWS: Likewise.
Prompted by http://bugzilla.redhat.com/439410
2008-03-28 20:20:49 +01:00
Jim Meyering
b58a8b4ef5 paste -d\\: avoid heap overrun for backslash at end of delim list
* src/paste.c: Include "quotearg.h".
(collapse_escapes): Handle backslash-escaped backslash explicitly.
Handle unescaped backslash at end of string by returning nonzero,
rather than by overrunning memory.
(main): Diagnose an invalid delimiter list -- carefully.
Reported by Cristian Cadar, Daniel Dunbar and Dawson Engler.
* tests/misc/paste-no-nl (delim-bs): Add a test to demonstrate the
heap-smashing capability.
(delim-bs2): Prior to coreutils-5.1.2, this bug was a little harder
to demonstrate: it would corrupt a first-argument containing e.g., \b
* NEWS: Mention the bug fix.
* tests/misc/Makefile.am (TESTS): Reflect renaming.
* tests/misc/paste: Rename from paste-no-nl.

Signed-off-by: Jim Meyering <meyering@redhat.com>
2008-03-27 13:32:38 +01:00
Daniel Dunbar
72d052896a mkdir -Z x d: don't segfault when diagnosing invalid context "x" (tiny change)
* src/mkdir.c (main): Use "scontext", not NULL optarg in diagnostic.
Reported by Cristian Cadar, Daniel Dunbar and Dawson Engler.
* NEWS: Mention the bug fix.
2008-03-26 00:57:29 +01:00
Jim Meyering
a0851554bd ptx: avoid heap overrun for backslash at end of optarg string
* src/ptx.c (copy_unescaped_string): Ignore a lone backslash
at end of string.  Reported by Cristian Cadar, Daniel Dunbar
and Dawson Engler.  Details here:
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/13005>.
* tests/misc/Makefile.am (TESTS): Add ptx-overrun.
* tests/misc/ptx-overrun: New file.  Test for the above fix.
* NEWS: Mention the fix.

Signed-off-by: Jim Meyering <meyering@redhat.com>
2008-03-21 20:58:15 +01:00
Jim Meyering
6e5bbc267a Write NEWS and update c99-to-c89 patch for today's rm improvement.
* NEWS: call this a "portability improvement" ;-)
* src/c99-to-c89.diff: Adjust remove.c offsets.
2008-03-21 16:01:29 +01:00
Jim Meyering
63feb84a2d mv: never unlink a destination file before calling rename
While cp --preserve=links must unlink certain destination files,
mv must never do that.
* src/copy.c (copy_internal): Pull the '! x->move_mode' test "up",
so it affects the entire condition, and not just DEREF_NEVER mode.
Reported by James Ralston in <http://bugzilla.redhat.com/438076>.
* tests/mv/atomic2: New file.  Test for the above fix.
* tests/mv/Makefile.am (TESTS): Add atomic2.
* NEWS: Mention the bug-fix.
[Bug introduced in 367719ba5f]
2008-03-19 13:38:27 +01:00
Ondřej Vašík
9c393fa194 install, rmdir: write --verbose output to stdout, not to stderr.
* src/install.c (announce_mkdir): Write verbose output to stdout,
not to stderr.
* src/mkdir.c (announce mkdir): Use prog_fprintf for verbose output.
* src/prog-fprintf.c (prog_fprintf): New function and file.
* src/prog-fprintf.h: New file.
* src/rmdir.c (main): Write verbose output to stdout, not to stderr.
Quote directory name in a diagnostic.
* src/rmdir.c (remove_parents): Write verbose output to stdout,
not to stderr.
* doc/coreutils.texi: Mention that shred verbose output is to stderr.
* NEWS: Mention the changes.

Signed-off-by: Ondřej Vašík <ovasik@redhat.com>
2008-03-10 19:47:15 +01:00
ribalba
b7a836c0a3 Work around AFS bug: id and groups would print invalid group number.
* src/id.c (main): Call print_group_list with a user name, if possible.
* src/groups.c (main): Likewise.
* NEWS: Mention this.
For details, see
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12852
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12875

Signed-off-by: ribalba <geerd.dietger.hoffmann@gmail.com>
2008-03-05 11:38:26 +01:00
James Youngman
49f7ebaac4 id: use getgrouplist when possible
* gl/m4/mgetgroups.m4: Check for getgrouplist.
* gl/lib/mgetgroups.c (mgetgroups): Use getgrouplist, if available.
* TODO: Remove the item about switching to getgrouplist.
* NEWS: mention this
2008-02-21 15:02:07 +01:00
Andreas Schwab
cb3147d298 sort: add --sort=... option.
* src/sort.c (SORT_OPTION): New enum.
(sort_args, sort_types): Define.
(usage, long_options, main): New option --sort.
* tests/sort/Test.pm: Test it.
* doc/coreutils.texi (sort invocation): Document --sort option.
* NEWS: Mention this.
2008-02-20 08:41:29 +01:00
Steven Schubiger
4f3ff2e700 seq: give better diagnostics for invalid formats.
* src/seq.c: (validate_format): New function.
(main): Use it.
* tests/misc/seq (fmt-d, fmt-e): Test for expected diagnostics with
invalid formats.
* NEWS: Mention this change.
* TODO: Remove this item.
[jm: src/seq.c: make diagnostics more consistent
 tests/misc/seq (fmt-eos1): adjust the expected diagnostic ]
2008-02-19 15:41:16 +01:00
James Youngman
a1e715698a join: new options: --check-order and --nocheck-order.
* src/join.c: Support --check-order and --nocheck-order.
New variables check_input_order, seen_unpairable and
issued_disorder_warning[]. For --check-order, verify that the
input files are in sorted order.  For the default case, check the
order only if there are unpairable lines.
(join): Perform ordering checks after reaching EOF on either
input.
(usage): Mention --check-order and --nocheck-order.
(dupline): Save a copy of the previously-read input line so that
we can detect disorder on the input.
(get_line): Temporarily save a copy of the previous line (by
calling dupline) and check relative ordering (by calling
checkorder) before returning the newly-read line.
(getseq, join): Tell get_line which file we are reading from.
(advance_seq): New function, factoring out some of the code
commonly surrounding calls to getseq.
(checkorder): New function.  Verifies that a pair of consecutive
input lines are in sorted order.
* doc/coreutils.texi (join invocation): Document the new options
--check-order and --nocheck-order.
* tests/join/Test.pm (tv): Added tests for --check-order and
--nocheck-order.
* NEWS: Mention this new feature.
2008-02-19 15:17:39 +01:00
Jim Meyering
b8108fd2dd seq: give a proper diagnostic for an invalid --format=% option
* src/seq.c (long_double_format): Handle '%' at end of string.
* tests/misc/seq [fmt-eos1, fmt-eos2]: New tests for the bug.
* NEWS: Mention this.
Reported by Pádraig Brady.
2008-02-18 18:38:52 +01:00
Ed Avis
483297d5dd ls --color no longer outputs unnecessary escape sequences
In --color mode, plain files do not get any color, not even white.
When no highlighting is required, ls outputs no escape sequence at all.
* src/ls.c (print_with_color):
(used_color): New global.
(indicator_no) [C_RESET]: New enum value.
(indicator_name) ["rs"]: Corresponding new string.
(color_indicator): Make the 'normal' and 'file' markers be NULL.
Use "rs" (C_RESET) to reset to ordinary colors.
(process_signals): Restore default colors only if necessary.
(main): Don't call prep_non_filename_text here.
(print_name_with_quoting): Call it here, instead.
(prep_non_filename_text): Use C_RESET, not C_NORM.
(print_color_indicator): Return bool, not void.
Print nothing, when possible.
(put_indicator): Call prep_non_filename_text the first time.
* tests/misc/ls-misc: Test for above.
* tests/ls/color-dtype-dir: Adapt: no escapes around regular file name.
* TODO: Remove item.
* NEWS: Mention this.
2008-02-17 11:16:08 +01:00
James Youngman
167b8025ac Replace groups.sh with groups.c.
* src/groups.c (main): New file, replacing groups.sh.
* src/group-list.c, src/group-list.h: New files, factored out of id.c,
implementing the functionality that "id" and "groups" have in common.
* src/id.c (print_full_info): Avoid a segfault when trying to print
an error message if getgroups fails.
(print_group_list): Move to group-list.c.
(print_group): Likewise.
* man/Makefile.am: When building groups.1, obtain the help text
from src/groups.c, not src/groups.sh.
(noinst_HEADERS): Add group-list.h.
(group): Remove rule.
(dist_man_MANS): Remove groups.1.
* doc/coreutils.texi (groups: Print group names a user is in):
Explain why "groups" and "groups $(id -un)" give different results
in existing login sessions after you change the group database.
(id: Print user identity): Likewise for "id".
* po/POTFILES.in: Add src/group-list.c and src/groups.c.
* NEWS: mention this.
* AUTHORS: Update.
2008-02-13 14:37:22 +01:00
Jim Meyering
dcc6638e46 NEWS [6.9.90]: head, od, split and tail accept the standard size suffixes 2008-02-07 22:58:38 +01:00
Steven Schubiger
a09dadf100 mkdir, split: write --verbose output to stdout, not stderr.
* src/mkdir.c (verbose_output): New function.
(announce_mkdir): Use it.
* src/split.c (usage): Update.
* src/split.c (cwrite): Write to stdout, not stderr.
* doc/coreutils.texi (split invocation): Remove the mention
of --verbose output being printed to stderr.
* tests/mkdir/p-v: Redirect stdout, not stderr.
* tests/misc/split-a: Likewise.
* NEWS: Mention this change.
* TODO: Remove this item.
2008-02-07 08:26:48 +01:00
Jim Meyering
ed5c4e770a Improve "rmdir --ignore-fail-on-non-empty"
* src/rmdir.c (remove_parents, main): With --ignore-fail-on-non-empty,
suppress a diagnostic also for other errno values, which can arise
with read-only media or when the parent directory has the immutable
attribute (set via chattr +i).
(errno_may_be_empty, ignorable_failure): New functions.
* src/remove.c (is_empty_dir): Move function to ...
* src/system.h (is_empty_dir): ...here, and make it inline.
Suggested by Josselin Mouette in <http://bugs.debian.org/363011>
via Bob Proulx.
* NEWS: Mention the improvement.
2008-01-30 13:51:38 +01:00
Jim Meyering
533391a2a7 ls: don't segfault on files in /proc with an old libselinux
* src/ls.c (gobble_file): Work around a bug in libselinux1-2.0.15
whereby getfilecon returns 0 yet sets the context to NULL.
Reported by Jan Moringen via Michael Stone in
http://bugs.debian.org/463043
* tests/ls/Makefile.am (TESTS): Add proc-selinux-segfault.
* tests/ls/proc-selinux-segfault: Test for the above fix.
* NEWS: Mention the fix.
2008-01-29 09:23:51 +01:00
Jim Meyering
9675ed627d * NEWS: Record release date. 2008-01-22 00:30:14 +01:00
Jim Meyering
0702758ca4 NEWS: Mention the configure.ac fix. 2008-01-16 21:20:36 +01:00
Jim Meyering
8ad8aa5322 Version 6.9.92 2008-01-12 00:34:31 +01:00
Jim Meyering
e52a7c28ac tests/tr/Test.pm: Prefer en_US.ISO-8859-1 to en_US.iso88591.
Suggestions from James Youngman and Pádraig Brady in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218/focus=12227
2008-01-11 10:07:01 +01:00
Jim Meyering
ab1c9b54b1 NEWS: Mention the cp bug fix. 2008-01-07 12:18:00 +01:00
Jim Meyering
9b76bc2b54 touch: add a test for today's change.
* tests/touch/now-owned-by-other: New script.  Test today's change.
* tests/touch/Makefile.am (TESTS): Add now-owned-by-other.
* tests/Makefile.am (all_t): Add td, a new root-only test.
(td): New target.
* NEWS: Mention the improvement.
2008-01-06 12:50:54 +01:00
Jim Meyering
6efd10462d Avoid tr case-conversion failure in some locales.
* src/tr.c (skip_construct): New function.
(main): When processing a pair of case-converting classes, don't
iterate through the elements of each [:upper:] or [:lower:] class.
Reported by Gerald Pfeifer in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/12218>.
* tests/tr/Test.pm [tolower-F]: New test for the above fix.
[upcase-xtra, dncase-xtra]: New tests, for a related code path.
* NEWS: Mention the tr bug fix.
2008-01-06 00:09:29 +01:00
Jim Meyering
e19a5aa428 Note that sorting uniq's input is often useful.
Suggested by Eric Blake.
2007-12-18 11:20:45 +01:00
Jim Meyering
7477cd1662 Version 6.9.91. 2007-12-15 09:44:40 +01:00
Jim Meyering
7407dc042a Add a test to exercise today's bug fix.
* tests/misc/selinux: Test for today's bug fix.
* NEWS: Mention the SELinux "ls -l" fix.
2007-12-11 21:41:52 +01:00
Jim Meyering
291eb90a0a * NEWS: Add the "Bug fixes" heading. 2007-12-11 19:08:03 +01:00
Jim Meyering
de5b055bbf "rm" as root would fail to unlink a non-directory on OS X 10.4.x
* src/remove.c (remove_entry) ["can unlink directories"]: Fix a
mistakenly reversed condition.
* NEWS: Mention this bug fix.
Reported by Pieter Bowman.
2007-12-09 00:57:00 +01:00
Jim Meyering
b1a1db5900 * NEWS: Add the usual "Noteworthy changes in release 6.9.91..." line. 2007-12-02 18:39:40 +01:00
Jim Meyering
bb5c20212f NEWS: Remove the now-untrue statement about cp vs. dangling symlinks 2007-12-01 22:46:05 +01:00
Jim Meyering
ab73462d4b * NEWS: Mention some of the SELinux changes.
Record release date and new version number.
* src/stat.c (main): Adjust a comment.
2007-12-01 18:48:43 +01:00
Lasse Collin
cbc06bb639 "cp -p" tries to preserve GID even if preserving the UID fails.
* NEWS: Mention this new feature.
* src/copy.c (set_owner): Try to preserve just the GID,
when initial fchown/lchown fails.
* src/cp.c (re_protect): Likewise.
2007-11-24 15:06:43 +01:00
Jim Meyering
0e9b06482e Add tests to show new class of strings accepted by date -d.
* tests/misc/date (rel-1day, rel-plus1): New tests for the recent
change in gnulib's getdate.y.
* NEWS: Mention the fix.
2007-11-23 08:27:16 +01:00
Jim Meyering
2bdc481219 cp: by default, refuse to copy through a dangling destination symlink
* NEWS: Mention this change.
* doc/coreutils.texi (cp invocation): Describe the new behavior.
* src/copy.c: No longer include "canonicalize.h".
(copy_reg): Upon failure to open a dangling destination symlink, don't
canonicalize the name, but rather fail (default) or, with POSIXLY_CORRECT,
repeat the open call without O_EXCL (potentially dangerous).
* src/copy.h (struct cp_options) [open_dangling_dest_symlink]:
New member.  Reorder the others, grouping "bool" and "enum"
members together.
* tests/cp/thru-dangling: Test for changed and new behavior.
* src/cp.c (cp_option_init): Initialize new member.
* src/install.c (cp_option_init): Likewise.
* src/mv.c (cp_option_init): Likewise.

Signed-off-by: Jim Meyering <meyering@redhat.com>
2007-11-22 00:19:06 +01:00
Jim Meyering
a03811f519 "seq .1 .1" would mistakenly generate no output on some systems
* NEWS: Say this.
* src/seq.c (print_numbers): Handle another floating point corner case.
This avoids failure of seq's eq-wid-7 test on FreeBSD 6.1.
2007-11-17 09:39:42 +01:00
Paul Eggert
a860ca32b0 Fix bug with "seq 10.8 0.1 10.95", plus another bug with %% in format.
* NEWS: Mention the %%-in-format bug fix.
* src/seq.c (struct layout): New type.
(long_double_format): New arg LAYOUT.  Fill it in.  Fix mishandling
of %% in formats.
(print_numbers): New arg LAYOUT.  Don't convert LAST to output format
when deciding whether to go slightly past LAST.  Instead, convert
X to output format and back.  This fixes a bug reported by
Andreas Schwab in
<http://lists.gnu.org/archive/html/bug-coreutils/2007-10/msg00237.html>
where "seq 10.8 0.1 10.95" would output 11.0 on platforms where
10.95 rounds to a value that prints as 11.0 when only one digit
past the decimal point is asked for.
(main): Compute layout, for benefit of print_numbers.
* tests/misc/seq (float-3): Undo previous change, since the bug
should be fixed now.
(fmt-b): New test, for the %% bug.
2007-11-03 10:00:26 +01:00
Jim Meyering
ffa639900b * NEWS: Mention the printf fix. 2007-10-21 18:17:30 +02:00
Jim Meyering
af5d0c363a tr: do not reject an unmatched [:lower:] or [:upper:] in SET1.
* NEWS: Mention this.
* src/tr.c (get_next) [RE_CHAR_CLASS]: Don't skip the loop when
processing [:lower:] and [:upper:].
(main): Require [:lower:] or [:upper:] in SET1 only when
when one of those is specified in SET2.
* tests/tr/Test.pm: Add tests for this fix.
Reported by Per Starbäck.

Signed-off-by: Jim Meyering <meyering@redhat.com>
2007-10-21 14:01:28 +02:00
Jim Meyering
689186b88c rm could malfunction under unusual circumstances:
When operating on a relative name longer than 511 bytes,
and (when either processing a directory that is neither writable
nor readable (but still searchable) or when determining whether
to prompt), and encountering an ENOMEM error while forming the
file name, rm would operate on a truncated-to-511-byte name
starting with "[...]" rather than the intended one.
* NEWS: Describe the bugs.
* src/remove.c: Correct two misuses of full_filename:
(full_filename0, xfull_filename): New functions.
(full_filename_): Rewrite to use full_filename0.
(AD_pop_and_chdir): Use xfull_filename, not full_filename.
(write_protected_non_symlink): Likewise.
2007-10-08 10:26:05 +02:00
Jim Meyering
99b039fead New program: mktemp.
* NEWS: Mention this.
* README: Add mktemp to the list.
* AUTHORS: Add this: mktemp: Jim Meyering
* src/mktemp.c: New file.
* src/Makefile.am (bin_PROGRAMS): Add mktemp.
(mktemp_LDADD): Add $(LIB_GETHRXTIME).
* man/mktemp.x: New file.
* man/Makefile.am (dist_man_MANS): Add mktemp.1.
(mktemp.1): New dependency.
* man/.cvsignore: Add mktemp.1.
* man/.gitignore: New file.
* src/.cvsignore, src/.gitignore: Add mktemp.
* tests/misc/mktemp: New file.
* tests/misc/Makefile.am (TESTS): Add mktemp.
* tests/Coreutils.pm (run_tests): Give the POST-test function
access to stdout and stderr contents, so it can verify that
the named-on-stdout file/dir does indeed exist and has proper
permissions, etc.
[po/ChangeLog]
* POTFILES.in: Add src/mktemp.c.
2007-10-07 19:44:38 +02:00
Jim Meyering
e2a6cbca3b * NEWS: The recent rm-diagnostic fix also affects cross-partition "mv". 2007-09-24 16:33:35 +02:00
Jim Meyering
a7ec8caffe rm: give a sensible diagnostic when failing to remove a symlink
On some systems (those with openat et al), when rm would fail to
remove a symlink, it would fail with the misleading diagnostic,
"Too many levels of symbolic links".
* NEWS: Mention the bug fix.
* src/remove.c (is_nondir_lstat): New function.
(remove_entry): Use it to catch failed-to-remove symlink (and any
other non-dir) here so that we don't fall through and try to treat
it as directory, which -- with a symlink -- would provoke the bogus
ELOOP failure.
* tests/rm/fail-eacces: Add a test for the above.
* src/c99-to-c89.diff: Adjust offsets.
2007-09-22 13:27:57 +02:00
Jim Meyering
500eccdbe4 chmod: don't ignore a dangling symlink
* NEWS: Mention the bug fix.
* src/chmod.c (process_file): Handle the case of FTS_SLNONE,
i.e., give a diagnostic saying we cannot operate on such a file.
* tests/chmod/thru-dangling: Compare new stderr output with expected.
2007-09-07 10:45:22 +02:00
Jim Meyering
d02e4e7775 Don't let ln be a party to destroying user data.
* src/ln.c: Include "file-set.h", "hash.h" and "hash-triple.h".
(dest_set, DEST_INFO_INITIAL_CAPACITY): New globals.
(do_link): Refuse to remove a just-created link.
Record a name,dev,ino triple for each link we create.
(main): Initialize dest_set, if needed.
* tests/mv/childproof: Test for the above fix.
* NEWS: Document this.
Reported by Eric Blake.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-08-23 14:00:35 +02:00