]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
14 months agomaint: port test warnings to GCC 14
Paul Eggert [Fri, 17 May 2024 05:44:23 +0000 (22:44 -0700)] 
maint: port test warnings to GCC 14

* configure.ac: Disable GCC 14’s -Wmissing-variable-declarations
in the test directory, as it’s not worth the aggravation there.
Likewise for GCC's -Wsuggest-attribute=cold.

14 months agomaint: update bootstrap from Gnulib
Paul Eggert [Fri, 17 May 2024 04:36:43 +0000 (21:36 -0700)] 
maint: update bootstrap from Gnulib

14 months agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 17 May 2024 04:34:59 +0000 (21:34 -0700)] 
build: update gnulib submodule to latest

14 months agosort: better -Wmissing-variable-declarations
Paul Eggert [Fri, 17 May 2024 04:09:28 +0000 (21:09 -0700)] 
sort: better -Wmissing-variable-declarations

* src/sort.c: Ignore -Wmissing-variable-declarations only
with GCC 14 and newer, since it didn’t exist earlier.
Ignore the warning only when including md5.h, where it
needs to be ignored, as the warning might be useful elsewhere.

14 months agocksum: improve API consistency checking
Paul Eggert [Fri, 17 May 2024 04:06:58 +0000 (21:06 -0700)] 
cksum: improve API consistency checking

* src/cksum.c (main) [CRCTAB]: Generate updated crctab.c (see below).
* src/crctab.c: Include cksum.h, to check consistency
between decl and defn.  Include stdio.h since cksum.h needs it.

14 months agodoc: improve the man page for sleep
Nikolaos Chatzikonstantinou [Tue, 14 May 2024 16:25:47 +0000 (12:25 -0400)] 
doc: improve the man page for sleep

This patch is part of work done for a project from Google Summer of
Code, see the project details at
<https://summerofcode.withgoogle.com/programs/2024/projects/E9Jp7RUx>.

* src/sleep.c (usage): Directly mention the floating-point option,
which is typical for sleeping milliseconds.
Also reorganize the text to be 3 lines rather than 4.

14 months agotests: cksum: add incorrect data to verify --check & --strict
Sylvestre Ledru [Fri, 10 May 2024 20:57:11 +0000 (22:57 +0200)] 
tests: cksum: add incorrect data to verify --check & --strict

* tests/cksum/cksum-c.sh: Add test cases.

14 months agowc: increase I/O size from 16 KiB to 256KiB
Pádraig Brady [Thu, 9 May 2024 13:03:38 +0000 (14:03 +0100)] 
wc: increase I/O size from 16 KiB to 256KiB

Similarly to commit v9.4-143-gfcfba90d0,
and enabled for AVX by commit v9.5-25-g0e4450103.

This was seen to improve AVX performance by about 10%
on an AMD 7800X3D (Ryzen 7 (2023)) CPU,
while having neutral AVX performance,
on an Intel i7-5600U (Broadwell-U (2015)) CPU.
With avx not enabled, this gives about a 3% performance boost,
on an Intel i7-5600U.

* src/wc.c: Use the centrally configured optimum buffer size.
* src/wc_avx2.c: Likewise.
* NEWS: Mention the change in performance.

14 months agowc: simplify and generalize AVX code
Evgeny Nizhibitsky [Sun, 31 Mar 2024 11:23:32 +0000 (12:23 +0100)] 
wc: simplify and generalize AVX code

* src/wc_avx2.c (wc_lines_avx2): Change from
_mm256_sub_epi8() + _mm256_sad_epu8() to
_mm256_movemask_epi8() + __builtin_popcount().
This will allow adjusting the I/O size above 16KiB.
* configure.ac: Align check with routines used in wc_avx2.c.

15 months agodoc: pwd: improve the -P help description
Bruce Jerrick [Tue, 7 May 2024 12:31:44 +0000 (13:31 +0100)] 
doc: pwd: improve the -P help description

* src/pwd.c (usage): Say that symlinks are resolved,
rather than the somewhat ambiguous "avoided".

15 months agomaint: rename octhexdigits macros
Nikolay Nechaev [Sun, 5 May 2024 09:55:00 +0000 (12:55 +0300)] 
maint: rename octhexdigits macros

isodigit -> isoct; octtobin -> fromoct; hextobin -> fromhex.
* src/octhexdigits.h: Rename macros.
* src/stat.c, src/printf.c: Use new macros.

15 months agomaint: factor out common macros of stat and printf
Nikolay Nechaev [Sun, 5 May 2024 09:54:59 +0000 (12:54 +0300)] 
maint: factor out common macros of stat and printf

* src/octhexdigits.h: isodigit, hextobin, octtobin macros.
* src/stat.c, src/printf.c: Use octhexdigits.h.
* src/local.mk: Corresponding adjustments.

15 months agomaint: factor out the common show_date functionality
Nikolay Nechaev [Sun, 5 May 2024 09:06:18 +0000 (12:06 +0300)] 
maint: factor out the common show_date functionality

* src/show-date.{h,c}: Declaration and definition of show_date.
* src/du.c: Wse the common show_date instead of the previous local
function.
* src/date.c: Wse the common show_date via a wrapper show_date_helper.
* src/local.mk: Corresponding adjustments.

15 months agocksum: add tests to verify the presence of "*"
Sylvestre Ledru [Fri, 3 May 2024 17:48:13 +0000 (19:48 +0200)] 
cksum: add tests to verify the presence of "*"

* tests/cksum/cksum-a.sh: Add a test case.

15 months agocp: actually support --update=none-fail
Pádraig Brady [Fri, 3 May 2024 09:18:50 +0000 (10:18 +0100)] 
cp: actually support --update=none-fail

* src/cp.c: Add the entries for the --update=none-fail option.
* tests/mv/update.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/70727

15 months agomaint: pacify GCC 14 -Wmissing-variable-declarations
Collin Funk [Wed, 1 May 2024 13:15:56 +0000 (14:15 +0100)] 
maint: pacify GCC 14 -Wmissing-variable-declarations

* src/local.mk: Include extern decl for 'Version'.
* src/crctab.c (crctab): Add an extern decl.
* src/cksum.c: Generate an extern decl.

15 months agomaint: pacify GCC 14 -Wmissing-variable-declarations wrt md5.h
Pádraig Brady [Wed, 1 May 2024 13:15:28 +0000 (14:15 +0100)] 
maint: pacify GCC 14 -Wmissing-variable-declarations wrt md5.h

* src/sort.c: Use pragmas to avoid warnings with our
openssl adjustment and to minimize coupling with openssl.

15 months agomaint: avoid syntax check failure with long lines
Pádraig Brady [Wed, 1 May 2024 13:31:35 +0000 (14:31 +0100)] 
maint: avoid syntax check failure with long lines

* cfk.mk: Exclude bootstrap from sc_long_lines
as it comes from gnulib.

15 months agobuild: bootstrap with python gnulib-tool by default
Pádraig Brady [Sat, 27 Apr 2024 12:03:45 +0000 (13:03 +0100)] 
build: bootstrap with python gnulib-tool by default

* gnulib: Update to support bootstrapping with python by default.
* bootstrap: Sync with gnulib.
* cfg.mk: Don't force python implementation with `make world`,
rather rely on the auto selection of python if appropriate.

15 months agodoc: sort: give example for sorting on the last field
Pádraig Brady [Tue, 23 Apr 2024 11:58:17 +0000 (12:58 +0100)] 
doc: sort: give example for sorting on the last field

* doc/coreutils.texi (sort invocation): Give a DSU example
for sorting names which may have a variable number of fields.
Addresses https://bugs.gnu.org/70532

15 months agobuild: provide way to bootstrap with python gnulib-tool
Pádraig Brady [Sat, 20 Apr 2024 09:40:06 +0000 (10:40 +0100)] 
build: provide way to bootstrap with python gnulib-tool

* cfg.mk: Add a new "world" default target so that one
can bootstrap (using the python implementation), configure,
and make, by using `make -f cfg.mk`.
* gnulib: Update to latest primarily to test the
bootstrap python implementation which is now in beta test.
* README-hacking: Document the `make -f cfg.mk` shortcut.

15 months agotail: avoid infloop with -c on /dev/zero
Paul Eggert [Sat, 20 Apr 2024 04:44:32 +0000 (21:44 -0700)] 
tail: avoid infloop with -c on /dev/zero

Problem reported by Ionut Nicula in:
https://bugs.gnu.org/70477
* src/tail.c (tail_bytes): Do not loop forever on commands
like 'tail -c 4096 /dev/zero'.
* tests/tail/tail-c.sh: Test this fix.

15 months agols: -f now means -a -U
Paul Eggert [Wed, 17 Apr 2024 20:40:46 +0000 (13:40 -0700)] 
ls: -f now means -a -U

Problem reported by Toby Kelsey <https://bugs.gnu.org/70418>.
* src/ls.c (decode_switches): -f now simply means -a -U.
(usage): Adjust to match.

15 months agomaint: remove unnecessary stdbool.h include
Collin Funk [Tue, 16 Apr 2024 20:38:06 +0000 (13:38 -0700)] 
maint: remove unnecessary stdbool.h include

* src/temp-stream.c: Don't include <stdbool.h> since it is defined in
config.h if the compiler does not support the C23 keyword.

15 months agojoin: fix error message for -a and -v
Pádraig Brady [Fri, 12 Apr 2024 19:25:21 +0000 (20:25 +0100)] 
join: fix error message for -a and -v

* src/join.c (main): s/field/file/ in the error message
for -a and -v, introduced in TEXTUTILS-1_13-24-g6f63d53e1.
Reported at https://bugs.debian.org/1068864

16 months agodoc: NEWS: mention sort being more efficient with /proc files
Pádraig Brady [Sun, 7 Apr 2024 12:50:13 +0000 (13:50 +0100)] 
doc: NEWS: mention sort being more efficient with /proc files

* NEWS: Mention the improvement in commit v9.5-6-g8ff390328

16 months agosplit: don’t trust st_size on /proc files
Paul Eggert [Sat, 6 Apr 2024 22:18:04 +0000 (15:18 -0700)] 
split: don’t trust st_size on /proc files

* src/split.c (create): Don’t trust st_size == 0.

16 months agosort: don’t trust st_size on /proc files
Paul Eggert [Sat, 6 Apr 2024 22:17:14 +0000 (15:17 -0700)] 
sort: don’t trust st_size on /proc files

Problem and fix reported by Takashi Kusumi in:
https://bugs.gnu.org/70231
* src/sort.c (sort_buffer_size): Don’t trust st_size == 0.

16 months agodd: don’t trust st_size on /proc/files
Paul Eggert [Sat, 6 Apr 2024 22:15:04 +0000 (15:15 -0700)] 
dd: don’t trust st_size on /proc/files

* src/dd.c (skip): Don’t trust st_size == 0.

16 months agocat: don’t trust st_size on /proc files
Paul Eggert [Sat, 6 Apr 2024 22:13:23 +0000 (15:13 -0700)] 
cat: don’t trust st_size on /proc files

* src/cat.c (main):
Improve test for when copying will exhaust the output device.
Do not rely on st_size, which is unreliable in /proc.
Use lseek instead; this is good enough here.
* tests/cat/cat-self.sh: Test the relaxation of the heuristic
for self-copying.

16 months agobuild: update gnulib submodule to latest
Pádraig Brady [Thu, 4 Apr 2024 10:19:40 +0000 (11:19 +0100)] 
build: update gnulib submodule to latest

* gnulib: Update to latest.
* NEWS: Document 2 bugs fixed.

16 months agodoc: chown,chgrp: fix missing full stop in --help
Pádraig Brady [Mon, 1 Apr 2024 19:24:55 +0000 (20:24 +0100)] 
doc: chown,chgrp: fix missing full stop in --help

* src/chown.c (usage): Add a missing full stop.
Fixes https://bugs.gnu.org/70126

16 months agomaint: post-release administrivia
Pádraig Brady [Thu, 28 Mar 2024 15:13:45 +0000 (15:13 +0000)] 
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

16 months agoversion 9.5 v9.5
Pádraig Brady [Thu, 28 Mar 2024 14:47:20 +0000 (14:47 +0000)] 
version 9.5

* NEWS: Record release date.

16 months agotests: od: avoid outputting undefined floating point values
Bruno Haible [Wed, 27 Mar 2024 12:30:31 +0000 (12:30 +0000)] 
tests: od: avoid outputting undefined floating point values

od was seen to abort() on glibc on ia64 and m68k with the error:
Fatal glibc error: printf_fp.c:501 (__printf_fp_buffer_1):
assertion failed:
  cy == 1 || (p.frac[p.fracsize - 2] == 0 && p.frac[0] == 0)

* tests/od/od-multiple-t.sh: Avoid outputting long double floats
to avoid undefined behavior. 'float' and 'double' are standardized
by IEEE 754 (except on Linux/m68k) and don't have undefined values.

16 months agobuild: update with gnulib fixes
Pádraig Brady [Tue, 26 Mar 2024 21:39:11 +0000 (21:39 +0000)] 
build: update with gnulib fixes

* gnulib: Update to incorporate gnulib fixes
from Bruno Haible

16 months agotests: numfmt: fix false failures on some systems
Pádraig Brady [Tue, 26 Mar 2024 19:17:16 +0000 (19:17 +0000)] 
tests: numfmt: fix false failures on some systems

* tests/misc/numfmt.pl: Verify that printf field width specs
count characters and not bytes before enabling locale tests.
This was seen on FreeBSD 14.0 and Solaris 11 OpenIndiana.
Reported by Bruno Haible

16 months agols: avoid ENOENT from readdir() on FreeBSD 14
Pádraig Brady [Tue, 26 Mar 2024 18:27:00 +0000 (18:27 +0000)] 
ls: avoid ENOENT from readdir() on FreeBSD 14

* src/ls.c (print_dir): readdir() on FreeBSD 14 was
seen to pass ENOENT through.  ENOENT in this context
means "Directory unlinked but still open".
Reported by Bruno Haible with tests/ls/removed-directory.sh

16 months agotests: avoid false failure due to mismatched isblank()
Pádraig Brady [Tue, 26 Mar 2024 15:02:17 +0000 (15:02 +0000)] 
tests: avoid false failure due to mismatched isblank()

There is a mismatch between isblank() used by tr and c32isblank() now
used by uniq on Solaris 11 OpenIndiana. isblank() was seen to return
true for non breaking space, while c32isblank() returned false.
Interestingly on Solaris, non breaking space is considered a blank
character, and isblank() and c32isblank() honor this in all locales.

* tests/uniq/uniq.pl: Adjust the blank check to use join(1) rather than
tr(1), as join uses the same blank determination routines as uniq(1).

16 months agocp: with --no-preserve=mode ensure set-group-ID bits maintained on dirs
Pádraig Brady [Mon, 25 Mar 2024 22:17:35 +0000 (22:17 +0000)] 
cp: with --no-preserve=mode ensure set-group-ID bits maintained on dirs

This issue was introduced in commit v8.19-145-g24ebca6

* src/copy.c (copy_internal): On systems that don't support ACLs,
the fallback default chmod done on directories should maintain
the set-group-ID, as that's generally auto-set by the system.
* NEWS: Mention the fix.
Reported by Bruno Haible on Alpine (with tests/cp/preserve-mode.sh)

16 months agotests: avoid false failure with partial locale info
Pádraig Brady [Mon, 25 Mar 2024 18:27:13 +0000 (18:27 +0000)] 
tests: avoid false failure with partial locale info

* tests/misc/numfmt.pl: Some systems with the fr_FR.UTF-8
locale installed, do not have a thousands grouping character defined.
In this case we skip the locale tests which depend on a non empty
grouping character.

16 months agotests: avoid triggering obsolete tail option processing
Pádraig Brady [Mon, 25 Mar 2024 13:01:33 +0000 (13:01 +0000)] 
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.

16 months agotests: remove debugging from a test
Pádraig Brady [Mon, 25 Mar 2024 12:21:35 +0000 (12:21 +0000)] 
tests: remove debugging from a test

* tests/ls/dired.sh: Remove temp debugging output.

16 months agotests: fix false failure on systems that can chmod symlinks
Pádraig Brady [Mon, 25 Mar 2024 12:12:19 +0000 (12:12 +0000)] 
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.

16 months agodoc: fix translation issue in chown/chgrp amalgamation
Pádraig Brady [Sun, 24 Mar 2024 20:12:53 +0000 (20:12 +0000)] 
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

16 months agodoc: fix various translation issues
Pádraig Brady [Sun, 24 Mar 2024 19:55:30 +0000 (19:55 +0000)] 
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/.

16 months agotest: avoid false failure with setgid directories
Pádraig Brady [Sun, 24 Mar 2024 19:46:57 +0000 (19:46 +0000)] 
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.

16 months agotests: avoid false failure on new mv --exchange test
Pádraig Brady [Sun, 24 Mar 2024 18:30:54 +0000 (18:30 +0000)] 
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.

16 months agodoc: update THANKS related to env --argv0 option
Pádraig Brady [Sun, 24 Mar 2024 17:55:53 +0000 (17:55 +0000)] 
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.

16 months agodoc: ls: detail output format for device files
Stephane Chazelas [Sun, 24 Mar 2024 17:52:32 +0000 (17:52 +0000)] 
doc: ls: detail output format for device files

* doc/coreutils.texi (ls invocation): State that device numbers
are output, instead of file size.

16 months agodoc: remove older ChangeLog items
Pádraig Brady [Sat, 23 Mar 2024 16:02:52 +0000 (16:02 +0000)] 
doc: remove older ChangeLog items

* Makefile.am: Update the oldest documented version
to 8.31 which is now about 5 years old.

16 months agomv: treat --exchange more like non-exchange
Paul Eggert [Sat, 23 Mar 2024 01:38:08 +0000 (18:38 -0700)] 
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.

16 months agocp,ln,mv: improve dir vs nondir diagnostics
Paul Eggert [Fri, 22 Mar 2024 19:02:41 +0000 (12:02 -0700)] 
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.

16 months agoenv: add -a,--argv0 to set the first argument passed to exec
Pádraig Brady [Thu, 2 Mar 2023 14:56:18 +0000 (11:56 -0300)] 
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.

16 months agodoc: pr: give solution to expanding TABs in multicolumn output
Pádraig Brady [Thu, 21 Mar 2024 15:26:48 +0000 (15:26 +0000)] 
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

16 months agodoc: clarify mv --exchange
Paul Eggert [Wed, 20 Mar 2024 22:01:07 +0000 (15:01 -0700)] 
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

16 months agomv: new option --exchange
Paul Eggert [Wed, 20 Mar 2024 21:00:25 +0000 (14:00 -0700)] 
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.

16 months agochmod: fix TOCTOU security issue with symlink replacement
Pádraig Brady [Tue, 19 Mar 2024 23:34:31 +0000 (23:34 +0000)] 
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

16 months agochmod: add support for -h, -H,-L,-P, --dereference options
Pádraig Brady [Mon, 28 Nov 2016 08:13:39 +0000 (09:13 +0100)] 
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.

16 months agomaint: basenc: consistently check buffer bounds when encoding
Pádraig Brady [Tue, 19 Mar 2024 15:55:18 +0000 (15:55 +0000)] 
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.

16 months agopinky: disable location canonicalization by default
Pádraig Brady [Tue, 19 Mar 2024 13:19:16 +0000 (13:19 +0000)] 
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

16 months agodoc: fix stale --dereference info for chown/chgrp
Pádraig Brady [Sun, 17 Mar 2024 12:18:25 +0000 (12:18 +0000)] 
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.

16 months agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 17 Mar 2024 05:39:12 +0000 (22:39 -0700)] 
build: update gnulib submodule to latest

16 months agobuild: provide a cross-compiling default for 16 bit float checks
Pádraig Brady [Fri, 15 Mar 2024 11:38:28 +0000 (11:38 +0000)] 
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.

16 months agoenv,kill,timeout: support unnamed signals
Grisha Levit [Thu, 25 Jan 2024 19:52:50 +0000 (14:52 -0500)] 
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.

16 months agobuild: add caching for involved configure checks
Pádraig Brady [Wed, 13 Mar 2024 12:31:32 +0000 (12:31 +0000)] 
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.

16 months agobuild: strengthen 16 bit float support checks
Grisha Levit [Wed, 13 Mar 2024 02:24:34 +0000 (22:24 -0400)] 
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.

16 months agomaint: prefer minmax.h instead of defining our own
Collin Funk [Tue, 12 Mar 2024 17:48:38 +0000 (10:48 -0700)] 
maint: prefer minmax.h instead of defining our own

* src/comm.c (min): Remove.
(compare_files): Use MIN which is referenced by system.h.

16 months agodircolors: add more archive extensions
Ville Skyttä [Mon, 11 Mar 2024 07:43:11 +0000 (09:43 +0200)] 
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).

16 months agodoc: add basic documentation for 'pinky'
Collin Funk [Tue, 12 Mar 2024 13:30:52 +0000 (06:30 -0700)] 
doc: add basic documentation for 'pinky'

* doc/coreutils.texi: Add 'pinky' under 'who'.

16 months agotimeout: fix narrow race in failing to kill processes
Pádraig Brady [Mon, 11 Mar 2024 13:46:24 +0000 (13:46 +0000)] 
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

16 months agotimeout: fix race where we might kill arbitrary processes
Pádraig Brady [Mon, 11 Mar 2024 13:18:37 +0000 (13:18 +0000)] 
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.

17 months agocksum: ensure appropriate "binary" mode with --untagged
Pádraig Brady [Wed, 6 Mar 2024 21:54:02 +0000 (21:54 +0000)] 
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.

17 months agomv: revert add --swap (-x) option
Pádraig Brady [Tue, 5 Mar 2024 21:31:34 +0000 (21:31 +0000)] 
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 6cd2d5e5335b5c286ff39e154e9dd38ba6923775

17 months agocksum: consistently validate --length attributes
Pádraig Brady [Mon, 4 Mar 2024 16:33:23 +0000 (16:33 +0000)] 
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

17 months agodoc: fix spellings in NEWS
Pádraig Brady [Fri, 8 Dec 2023 14:19:06 +0000 (14:19 +0000)] 
doc: fix spellings in NEWS

* NEWS: s/user/uses/; s/exisiting/existing/

17 months agomv: add --swap (-x) option to atomically swap 2 paths
Petr Malat [Thu, 29 Feb 2024 22:02:03 +0000 (23:02 +0100)] 
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.

17 months agocat,cp,mv,dd,install,split: set the default IO size to 256KiB
Pádraig Brady [Wed, 28 Feb 2024 16:41:40 +0000 (16:41 +0000)] 
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.

17 months agomktemp: fix template diagnostic with --suffix
lvgenggeng [Tue, 27 Feb 2024 01:41:27 +0000 (09:41 +0800)] 
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.

17 months agotests: move join tests to their own directory
Pádraig Brady [Tue, 27 Feb 2024 14:12:27 +0000 (14:12 +0000)] 
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.

17 months agotests: simplify treatment of the $LOCALE_FR_UTF8 variable
Pádraig Brady [Tue, 27 Feb 2024 14:05:49 +0000 (14:05 +0000)] 
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.

17 months agojoin: avoid test failure on systems with no French UTF-8 locale
Bruno Haible [Mon, 26 Feb 2024 21:33:18 +0000 (22:33 +0100)] 
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

17 months agosort: make the startup time optimization effective on glibc < 2.34
Bruno Haible [Tue, 27 Feb 2024 11:12:59 +0000 (12:12 +0100)] 
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).

17 months agobuild: improve libcrypto library detection
Pádraig Brady [Mon, 26 Feb 2024 19:10:14 +0000 (19:10 +0000)] 
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

17 months agowc: fix -w with breaking space over UCHAR_MAX
Aearil [Sat, 24 Feb 2024 20:44:24 +0000 (21:44 +0100)] 
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

17 months agocp,mv: add --update=none-fail to fail if existing files
Pádraig Brady [Mon, 5 Feb 2024 15:55:07 +0000 (15:55 +0000)] 
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

17 months agocp,mv: reinstate that -n exits with success if files skipped
Pádraig Brady [Sat, 24 Feb 2024 19:51:56 +0000 (19:51 +0000)] 
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

17 months agobuild: fix libcrypto version linked by sort at runtime
Pádraig Brady [Mon, 26 Feb 2024 16:38:41 +0000 (16:38 +0000)] 
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().

17 months agomaint: avoid sc_tight_scope failure in sort.c
Pádraig Brady [Mon, 26 Feb 2024 14:42:40 +0000 (14:42 +0000)] 
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.

17 months agodoc: mention -lcrypto change in NEWS
Paul Eggert [Mon, 26 Feb 2024 05:24:04 +0000 (21:24 -0800)] 
doc: mention -lcrypto change in NEWS

17 months agosort: dynamically link -lcrypto if -R
Paul Eggert [Mon, 26 Feb 2024 01:13:12 +0000 (17:13 -0800)] 
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.

17 months agodoc: de-“note” the documentation
Paul Eggert [Sat, 24 Feb 2024 22:03:42 +0000 (14:03 -0800)] 
doc: de-“note” the documentation

* doc/coreutils.texi, man/readlink.x, man/runcon.x:
* src/comm.c (usage):
* src/digest.c (usage):
* src/echo.c (usage):
* src/join.c (usage):
* src/ln.c (usage):
* src/rm.c (usage):
* src/stat.c (usage):
* src/system.h (USAGE_BUILTIN_WARNING):
* src/test.c (usage):
* src/touch.c (usage):
* src/uniq.c (usage):
Rewrite to avoid most uses of “Note that” and similar wording.
These circumlocutions are rarely needed, and avoiding them
improves readability and lessens preaching.

17 months agocp: add --keep-directory-symlink option
Daan De Meyer [Thu, 25 Jan 2024 13:02:32 +0000 (14:02 +0100)] 
cp: add --keep-directory-symlink option

When recursively copying files into OS trees, it often happens that
some subdirectory of the source directory is a symlink in the target
directory. Currently, cp will fail in that scenario with the error:

"cannot overwrite non-directory %s with directory %s"

However, we'd like cp in this scenario to follow the destination
directory symlink and copy the files into the symlinked directory
instead. Let's support this by adding a new option
--keep-directory-symlink that makes cp follow destination directory
symlinks.

We name the option --keep-directory-symlink to keep consistent with
tar which has the same option with the same effect.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/copy.h: Add the new setting.
* src/copy.h: Adjust to follow symlinks if setting enabled.
* src/cp.c (usage): Describe the new option.
(main): Accept the new option.
* tests/cp/keep-directory-symlink.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the new feature.

17 months agodircolors: update list of archive file extensions
Michel Lind [Fri, 16 Feb 2024 16:24:32 +0000 (10:24 -0600)] 
dircolors: update list of archive file extensions

* src/dircolors.hin: Sort archive section by extension.
Treat .crate (Rust archives) as archive files
(they're essentially tar.gz files).

17 months agomaint: prefer #include <...> for gnulib substitute headers
Collin Funk [Sun, 18 Feb 2024 20:23:07 +0000 (12:23 -0800)] 
maint: prefer #include <...> for gnulib substitute headers

* src/shuf.c: Change #include "getopt.h" to #include <getopt.h>.
* src/stat.c: Change #include "getopt.h" to #include <getopt.h>.
* src/system.h: Change #include "error.h" to #include <error.h>.

Copyright-paperwork-exempt: Yes

17 months agodoc: add '[' to the info index
Pádraig Brady [Mon, 19 Feb 2024 14:14:21 +0000 (14:14 +0000)] 
doc: add '[' to the info index

* doc/coreutils.texi (test invocation): Add '[' to the index.

17 months agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 18 Feb 2024 05:55:56 +0000 (21:55 -0800)] 
build: update gnulib submodule to latest

17 months agonohup: document GCC bug number
Paul Eggert [Sun, 18 Feb 2024 05:51:46 +0000 (21:51 -0800)] 
nohup: document GCC bug number

* src/nohup.c: Add GCC bug number to comment.

17 months agols: remove unnecessary pragmas
Paul Eggert [Sun, 18 Feb 2024 05:51:03 +0000 (21:51 -0800)] 
ls: remove unnecessary pragmas

* src/ls.c (decode_switches): Remove pragmas.  They are no longer
needed to pacify GCC 13.2.1 with --enable-gcc-checking, and there’s
little point keeping them around for older GCC versions.

17 months agomaint: update GCC version comment
Paul Eggert [Sun, 18 Feb 2024 05:48:15 +0000 (21:48 -0800)] 
maint: update GCC version comment

* src/copy.c: Update comment.