Commit Graph

30077 Commits

Author SHA1 Message Date
Pádraig Brady
a51af43294 tests: avoid triggering obsolete tail option processing
* tests/ls/dired.sh: With 2 options, the latter is taken
as a file name on some systems.  This avoids a false
failure on Solaris and FreeBSD at least.
2024-03-25 13:02:52 +00:00
Pádraig Brady
ecb2fecdf9 tests: remove debugging from a test
* tests/ls/dired.sh: Remove temp debugging output.
2024-03-25 12:22:52 +00:00
Pádraig Brady
4cb2742d70 tests: fix false failure on systems that can chmod symlinks
* tests/chmod/symlinks.sh: The count of adjusted modes was
one more on systems where symlink modes can be adjusted.
Therefore only include the non symlinks in the count.
2024-03-25 12:12:19 +00:00
Pádraig Brady
26fd96a96c doc: fix translation issue in chown/chgrp amalgamation
* src/chown-core.h (emit_from_option_description): The conditional
string composition here caused issues for translators.
Instead move to a more general description ...
(src/chown.c (usage): ... here.
Fixes https://bugs.gnu.org/69985
2024-03-24 20:25:37 +00:00
Pádraig Brady
6259593ac7 doc: fix various translation issues
src/chown.c (usage): Translate parameterized strings.
 src/copy.c (copy_internal): Translate each part of ternary.
* src/cp.c (usage): Fix typo; s/exisiting/existing/.
2024-03-24 19:57:29 +00:00
Pádraig Brady
f77a6352fb test: avoid false failure with setgid directories
* tests/chmod/symlinks.sh: Ensure this new test is immune
to setgid directories by resetting modes with =777 rather than 777.
Also output more debugging in all failure cases.
2024-03-24 19:46:57 +00:00
Pádraig Brady
c45fcb2ed2 tests: avoid false failure on new mv --exchange test
* tests/mv/mv-exchange.sh: Canonicalize different
"operation not supported" messages, so we can ignore correctly.
Reported by Bruno Haible on AIX, NetBSD, and OpenBSD.
2024-03-24 18:32:34 +00:00
Pádraig Brady
e0cce6b62a doc: update THANKS related to env --argv0 option
* THANKS.in: Add Matheus who was central to the env --argv0
addition in commit v9.4-167-g193449b17.
2024-03-24 17:56:36 +00:00
Stephane Chazelas
7ebbeeb03d doc: ls: detail output format for device files
* doc/coreutils.texi (ls invocation): State that device numbers
are output, instead of file size.
2024-03-24 17:52:32 +00:00
Pádraig Brady
7b2064216c doc: remove older ChangeLog items
* Makefile.am: Update the oldest documented version
to 8.31 which is now about 5 years old.
2024-03-23 16:02:52 +00:00
Paul Eggert
5a1d00e450 mv: treat --exchange more like non-exchange
Also, improve quality of diagnostics.
Problems/suggestions by Bernhard Voelker in
<https://bugs.gnu.org/69532#82>.
* src/copy.c (emit_verbose): New arg FORMAT.  All uses changed,
to improve quality of diagnostics when --exchange is used.
(copy_internal): Don’t try to optimize --exchange so much; this
simplifies the code and keeps it closer to the non --exchange case.
2024-03-22 18:39:27 -07:00
Paul Eggert
ff42adb55e cp,ln,mv: improve dir vs nondir diagnostics
* src/copy.c (copy_internal): Simplify logic for copying
from directory to non-directory or vice versa, and always
diagnose with both source and destination file names.
2024-03-22 18:39:27 -07:00
Pádraig Brady
193449b173 env: add -a,--argv0 to set the first argument passed to exec
Using the shell's exec -a feature can be awkward
so add support for setting overriding argv[0].
This gives env full control over the arguments it passes.

* src/env.c: Accept -a,--argv0 and set argv[0] appropriately.
* tests/env/env.sh: Add test cases.
* doc/coreutils.texi (env invocation): Describe -a,--argv0.
* NEWS: Mention the new feature.
2024-03-22 13:12:52 +00:00
Pádraig Brady
91e69cd2d0 doc: pr: give solution to expanding TABs in multicolumn output
* doc/coreutils.texi (pr invocation): Explicitly state that
multicolumn output will convert spaces to TABs, and show that
this can be undone with the `pr -t -e` or `expand` commands.
Suggested by Douglas McIlroy in https://bugs.gnu.org/69807
2024-03-21 15:32:13 +00:00
Paul Eggert
1913bfcf57 doc: clarify mv --exchange
In the manual, say it exchanges all data and metadata.
Suggested by Pádraig Brady in:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69532#59
2024-03-20 15:01:07 -07:00
Paul Eggert
5d3fd24f42 mv: new option --exchange
* src/copy.h (struct cp_options): New member 'exchange'.
* src/copy.c (copy_internal): Support the new member.
* src/mv.c (EXCHANGE_OPTION): New constant.
(long_options): Add --exchange.
(usage): Document --exchange.
(main): Support --exchange.
* tests/mv/mv-exchange.sh: New test case.
* tests/local.mk (all_tests): Add it.
2024-03-20 14:40:29 -07:00
Pádraig Brady
425b8a2f53 chmod: fix TOCTOU security issue with symlink replacement
This is an issue with -[H]R mode, where an attacker
may replace a traversed file with a symlink
between where we stat() the file and chmod() the file.

* src/chmod.c (process_file): Remove the first !S_ISLNK guard
as that's now just an optimization, and instead consistently
apply fchmodat() to files/symlinks.  Ensure AT_SYMLINK_NOFOLLOW
is set when traversing in default (-H) mode.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/11108
2024-03-19 23:56:45 +00:00
Pádraig Brady
07a69fc3ba chmod: add support for -h, -H,-L,-P, --dereference options
There have been various requests to add -h to avoid following symlinks
for security reasons.  This wasn't provided previously as chmod(1)
already ignored symlinks unless specified on the command line.
Note chmod defaults to -H mode rather than the chown default of -P,
as usually chown can work directly on symlinks and so defaults
to not traversing those specified on the command line.
Note FreeBSD chmod does default to -P mode, but we retain the -H mode
default also for compatibility with existing chmod behavior.

Adding -HLP will allow chmod to disable traversing CLI symlinks to dirs.
Adding -h will allow to disable following CLI symlinks to files/dirs,
  also operating on all symlinks on systems that support that.
Adding --dereference will be significant with -H (the default).  I.e.
  symlinks to dirs not recursed, but symlinks are dereferenced.
Adding these options will also be consistent with chown(1), chgrp(1),
and chmod(1) on other systems.

Note since chmod(1) currently ignores symlinks by default,
and -h is primarily a mechanism to avoid following symlinks, rather than
for operating on the symlink itself, we make -h try to chmod a symlink,
but ignore ENOTSUP.  In that way we're consistent with chown(1)
where it also ignores ENOTSUP for symlinks, and we don't fail when
trying to be extra secure with command line params.

* doc/coreutils.texi (chmod invocation): Reference the -H,-L,-P
descriptions, and adjust the corresponding macros to say
the default is -H or -P as appropriate.
Add --dereference and -h,--no-dereference descriptions.
* man/chmod.x: Adjust discussion of symlink handling.
* src/chmod.c (main): Accept new options and set
fts flags appropriately.
(process_file): Process / dereference symlinks as necessary.
* src/system.h (emit_symlink_recurse_options): A new function
refactored from chown.c and chmod.c usage().
* tests/chmod/symlinks.sh: New test for the new options.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.
2024-03-19 23:43:53 +00:00
Pádraig Brady
a46f34bb56 maint: basenc: consistently check buffer bounds when encoding
* src/basenc.c (base16_encode, base2msbf_encode, base2lsbf_encode):
Ensure we don't overflow the output buffer, whose length is
passed in the OUTLEN parameter.  This issue was flagged by clang
with -Wunused-but-set-parameter.
2024-03-19 23:43:53 +00:00
Pádraig Brady
bf73a7602a pinky: disable location canonicalization by default
Behave like who(1) in requiring --lookup to enable this
often slow feature.  pinky(1) is supposed to be lightweight after all.

* doc/coreutils.texi (who invocation): Adjust the description to no
longer reference dialup, and be more general about the still significant
delays.
(pinky invocation): Reference the same --lookup description.
* src/pinky.c (main): Accept --lookup to enable DNS lookups.
* NEWS: Mention the change in behavior.
Fixes https://bugs.debian.org/628815
2024-03-19 23:43:53 +00:00
Pádraig Brady
48cd67663d doc: fix stale --dereference info for chown/chgrp
Following v5.2.1-679-g7e29ef8b8 symlinks specified on the command line
no longer induce an error if lchown() is not supported on the system.

* doc/coreutils.texi (chown invocation, chgrp invocation): Adjust
accordingly, and also use a macro to avoid duplication.
* src/chown-core.c: Use our more standard is_ENOTSUP() wrapper
in the code related to this.
2024-03-18 18:40:21 +00:00
Paul Eggert
dda89eb5d3 build: update gnulib submodule to latest 2024-03-16 22:49:45 -07:00
Pádraig Brady
c07a7d999e build: provide a cross-compiling default for 16 bit float checks
* configure.ac: Provide a conservative 16 bit float support default
when cross-compiling, to avoid configure failing in that case.
2024-03-15 11:38:28 +00:00
Grisha Levit
b8d1b00e21 env,kill,timeout: support unnamed signals
Some signals with values less that the max signal number for the system
do not have defined names.  For example, currently on amd64 Linux,
signals 32 and 33 do not have defined names, and Android has a wider
gap of undefined names where it reserves some realtime signals.

Previously the signal listing in env ended up reusing the name
of the last printed valid signal (the repeated HUP below):

    $ env --list-signal-handling true
    HUP        ( 1): IGNORE
    HUP        (32): BLOCK
    HUP        (38): IGNORE

..and the corresponding signal numbers were rejected as operands for the
env, kill, and timeout commands.

This patch removes the requirement that sig2str returns 0 for a signal
number associated with an operand.  This allows unnamed signals to be in
the sets `env' attempts to manipulate when a --*-signal option is used
with no argument, and kill(1) and timeout(1) to send such unnamed
signals.

* src/operand2sig.c (operand2sig): Drop signame argument, accept all
signal numbers <= SIGNUM_BOUND.  All callers updated.
* src/env.c (parse_signal_action_params, reset_signal_handlers)
(parse_block_signal_params, set_signal_proc_mask)
(list_signal_handling): Accept all signal numbers <= SIGNUM_BOUND,
use SIG%d for printing if necessary.
* src/kill.c (list_signals, main): Likewise.
(send_signals): Check errno from kill(3) for bad signo.
* src/timeout.c (main): Update operand2sig call.
* tests/misc/kill.sh: Test listing all signal numbers.
* NEWS: Mention the improvement.
2024-03-13 16:15:35 +00:00
Pádraig Brady
c7f422940a build: add caching for involved configure checks
* configure.ac: Wrap the following with AC_CACHE_VAL,
so that they can be cached / overridden.  We use
the "utils_cv_" prefix as they're coreutils specific overrides.
utils_cv_avx2_intrinsic_exists,
utils_cv_brain_16_bit_supported,
utils_cv_ieee_16_bit_supported,
utils_cv_pclmul_intrinsic_exists,
utils_cv_stdbuf_supported.
2024-03-13 12:31:32 +00:00
Grisha Levit
0cafa1524f build: strengthen 16 bit float support checks
Recent clang provides __bf16 on aarch64 but it is broken.

If built with -O0, the conversion is wrong:

    $ printf '\x3F\x80' | od --end=big -An -tfB | tr -d ' '
    1.875

If built with -O1 or higher, compilation fails:

    fatal error: error in backend:
    Cannot select: 0xb400007a58d29780: f32 = fp_extend 0xb40000...
    0xb40000...: bf16,ch = CopyFromReg 0xb40000..., Register:bf16 %13
    0xb40000...: bf16 = Register %13
    In function: print_bfloat

The latter issue does not cause the existing configure test to fail
because the promotion is optimized out.

* configure.ac: Ensure 16 bit float promotion code does not get
optimized out, and produces an expected result.
2024-03-13 11:49:30 +00:00
Collin Funk
00a34a05f5 maint: prefer minmax.h instead of defining our own
* src/comm.c (min): Remove.
(compare_files): Use MIN which is referenced by system.h.
2024-03-12 20:04:56 +00:00
Ville Skyttä
9a50494875 dircolors: add more archive extensions
* src/dircolors.hin: Add .apk (Alpine Linux/Android package); .drpm
(delta rpm); .egg, .pyz, and .whl (Python related); and .udeb (form of
.deb).
2024-03-12 15:22:01 +00:00
Collin Funk
44c9578a08 doc: add basic documentation for 'pinky'
* doc/coreutils.texi: Add 'pinky' under 'who'.
2024-03-12 14:57:51 +00:00
Pádraig Brady
ab4ffc8503 timeout: fix narrow race in failing to kill processes
* src/timeout.c (main): Block cleanup signals earlier so that cleanup()
is not runnable until monitored_pid is in a deterministic state.
This ensures we always send a termination signal to the child
once it's forked.
* NEWS: Mention the bug fix.
Reported at https://github.com/coreutils/coreutils/issues/82
2024-03-12 14:57:47 +00:00
Pádraig Brady
c1cf5148a1 timeout: fix race where we might kill arbitrary processes
* src/timeout.c (cleanup): Handle the case where monitored_pid
might be -1, which could happen if a signal was received
immediately after a failed fork() call.  In that case it would
send the termination signal to all processes that the timeout
process has permission to send signals too.
* NEWS: Mention the bug fix.
2024-03-11 15:12:36 +00:00
Pádraig Brady
7b92e9fb26 cksum: ensure appropriate "binary" mode with --untagged
* src/digest.c (main): If --binary was enabled with a previous --tag,
then reset the binary mode to auto select if --untagged then specified.
* tests/cksum/cksum-a.sh: Add a test case.
2024-03-06 21:54:02 +00:00
Pádraig Brady
9d8890d872 mv: revert add --swap (-x) option
Since this functionality is recently available
in the exch(1) utility from util-linux,
it was thought best not to complicate mv with it.

This reverts commit 6cd2d5e533
2024-03-05 21:34:00 +00:00
Pádraig Brady
fea833591b cksum: consistently validate --length attributes
* src/digest.c (main): Only validate the last used --length
for being a multiple of 8.
* tests/cksum/b2sum.sh: Add a test case.
Fixes https://bugs.gnu.org/69546
2024-03-04 16:35:27 +00:00
Pádraig Brady
c877c7c1ee doc: fix spellings in NEWS
* NEWS: s/user/uses/; s/exisiting/existing/
2024-03-03 12:27:07 +00:00
Petr Malat
6cd2d5e533 mv: add --swap (-x) option to atomically swap 2 paths
renameat2() syscall allows atomically swapping 2 paths on one
file system. Expose this ability to the user with --swap.

* doc/coreutils.texi: Describe mv --swap option.
* src/mv.c (main): Support --swap.
* tests/mv/mv-swap.sh: Add test for mv -x.
* tests/local.mk: Reference new test.
* NEWS: Mention the new option.
2024-03-03 12:18:45 +00:00
Pádraig Brady
fcfba90d0d cat,cp,mv,dd,install,split: set the default IO size to 256KiB
* src/ioblksize.h: Add updated test results and
increase value from 128KiB to 256KiB, which was last
updated 10 years ago.
* NEWS: Mention the improvement.
2024-02-28 22:26:52 +00:00
lvgenggeng
e397ba1a31 mktemp: fix template diagnostic with --suffix
* src/mktemp.c (main): When --suffix is specified, TEMPLATE
points to the meraged buffer DEST_NAME. As X's in the suffix are
not significant to the generated random characters, the diagnostic
for too few X's should only refer to the template portion.
* tests/misc/mktemp.pl: Adjust accordingly.
* NEWS: Mention the bug fix.
2024-02-27 14:59:33 +00:00
Pádraig Brady
f3bcb59ebd tests: move join tests to their own directory
* tests/misc/join-utf8.sh: Move to tests/join
since there are now multiple join tests.
* tests/misc/join.pl: Likewise.
2024-02-27 14:27:04 +00:00
Pádraig Brady
79c628901d tests: simplify treatment of the $LOCALE_FR_UTF8 variable
* tests/df/problematic-chars.sh: Rely on gnulib setting
this to "none" where not usable.
* tests/misc/sleep.sh: Likewise.
* tests/printf/printf-mb.sh: Likewise.
* tests/printf/printf-quote.sh: Likewise.
* tests/sort/sort-debug-keys.sh: Likewise.
2024-02-27 14:27:04 +00:00
Bruno Haible
f2e70e2d19 join: avoid test failure on systems with no French UTF-8 locale
* tests/misc/join-utf8.sh: Test the value of LOCALE_FR_UTF8 against
'none', not against a missing value.
Fixes https://bugs.gnu.org/69418
2024-02-27 14:26:35 +00:00
Bruno Haible
df5fa309c2 sort: make the startup time optimization effective on glibc < 2.34
* configure.ac: Test where to find the dlopen function. Set LIB_DL.
Use it in the DLOPEN_LIBCRYPTO test.
* src/local.mk (src_sort_LDADD): Add $(LIB_DL).
2024-02-27 13:39:06 +00:00
Pádraig Brady
45411e3fc6 build: improve libcrypto library detection
* configure.ac: Match literal '.' in the file name
to avoid potential mismatches with similarly named libs.
Reported by Andreas Schwab
2024-02-26 19:10:14 +00:00
Aearil
feda512e97 wc: fix -w with breaking space over UCHAR_MAX
* src/wc.c (wc): Fix regression introduced in commit v9.4-48-gf40c6b5cf.
* tests/wc/wc-nbsh.sh: Add test cases for "standard" spaces.
Fixes https://bugs.gnu.org/69369
2024-02-26 17:33:02 +00:00
Pádraig Brady
49912bac28 cp,mv: add --update=none-fail to fail if existing files
* src/cp.c (main): Add support for --update=none-fail to provide the
functionality of diagnosing files in the destination,
and exiting with failure status.
(usage): Mark -n as deprecated.
* src/mv.c: Likewise.
* src/copy.h: Add UPDATE_NONE_FAIL definition.
* src/system.h (emit_update_parameters_note): Add --update=none-fail
description.
* doc/coreutils.texi (cp invocation): Likewise.
Also mention why -n is deprecated.
* tests/mv/update.sh: Add a test case, including precedence
with -n and other --update options.
* tests/cp/cp-i.sh: Verify that --backup and --update=none{,-fail}
are mutually exclusive.
* tests/mv/mv-n.sh: Likewise.
* NEWS: Mention the new feature.
Addresses https://bugs.gnu.org/62572
2024-02-26 17:33:02 +00:00
Pádraig Brady
9907b6f5dc cp,mv: reinstate that -n exits with success if files skipped
* src/cp.c (main): Adjust so that -n will exit success if skipped files.
* src/mv.c (main): Likewise.
* doc/coreutils.texi (cp invocation): Adjust the description of -n.
* src/system.h (emit_update_parameters_note): Adjust --update=none
comparison.
* tests/cp/cp-i.sh: Adjust -n exit status checks.
* tests/mv/mv-n.sh: Likewise.
* NEWS: Mention the change in behavior.
Fixes https://bugs.gnu.org/62572
2024-02-26 17:33:02 +00:00
Pádraig Brady
3bbdb39388 build: fix libcrypto version linked by sort at runtime
One should link the versioned lib at runtime,
and the unversioned lib at build time,
as the unversioned lib may not be installed,
and better couples the binary with the required version.

* configure.ac: Define LIBCRYPTO_SONAME, determined from
the test binary linked with -lcrypto.  Also document
why we use SHA512() in the check, rather than MD5().
* src/sort.c (link_libcrypto): Use the versioned lib in dlopen().
2024-02-26 17:33:02 +00:00
Pádraig Brady
10be42f033 maint: avoid sc_tight_scope failure in sort.c
* cfg.mk: Exclude the ptr_MD5_* symbols added in
commit v9.4-130-g7f57ac2d2, as there is no way
to declare these static given they way they're defined.
2024-02-26 17:33:02 +00:00
Paul Eggert
d9dc02b09a doc: mention -lcrypto change in NEWS 2024-02-25 21:24:04 -08:00
Paul Eggert
7f57ac2d20 sort: dynamically link -lcrypto if -R
This saves time in the usual case, which does not need -lcrypto.
* configure.ac (DLOPEN_LIBCRYPTO): New macro.
* src/sort.c [DLOPEN_LIBCRYPTO && HAVE_OPENSSL_MD5]: New macros
MD5_Init, MD5_Update, MD5_Final.  Include "md5.h" after defining
them.  Include <dlfcn.h>, and define new functions link_failure
and symbol_address.
(link_libcrypto): New function.
(random_md5_state_init): Call it before using crypto functions.
2024-02-25 18:55:16 -08:00