]> git.ipfire.org Git - thirdparty/coreutils.git/log
thirdparty/coreutils.git
4 years agotests: add a test case for recent env fix
Pádraig Brady [Mon, 29 Mar 2021 14:47:20 +0000 (15:47 +0100)] 
tests: add a test case for recent env fix

* tests/misc/env-S.pl: Add a test case for recent commit ec6904f0.

4 years agomaint: ignore all .a files in .gitignore
Pádraig Brady [Mon, 29 Mar 2021 13:02:20 +0000 (14:02 +0100)] 
maint: ignore all .a files in .gitignore

* .gitignore: Rather than add the new src/libcksum_pclmul.a,
just ignore any such libs.
* src/.gitignore: Likewise.
Reported by Kristoffer Brånemyr.

4 years agoenv: prefer ptrdiff_t
Paul Eggert [Fri, 26 Mar 2021 21:56:36 +0000 (14:56 -0700)] 
env: prefer ptrdiff_t

* src/env.c (usvars_used, vnlen, unset_envvars, expansion)
(build_argv): Prefer ptrdiff_t to size_t when either will do.

4 years agoenv: improve whitespace warning
Paul Eggert [Fri, 26 Mar 2021 21:51:55 +0000 (14:51 -0700)] 
env: improve whitespace warning

* src/env.c (main): Issue -S warning for any whitespace,
not just space.

4 years agoenv: use GNU coding style
Paul Eggert [Fri, 26 Mar 2021 21:47:03 +0000 (14:47 -0700)] 
env: use GNU coding style

* src/env.c: Use GNU coding style for recentish changes.

4 years agoenv: remove asserts
Paul Eggert [Fri, 26 Mar 2021 21:06:26 +0000 (14:06 -0700)] 
env: remove asserts

The assertions didn’t help catch the most recent bug which
was in their area, and kind of get in the way.
* src/env.c: Do not include <assert.h>, and remove all assertions.
These seem to have been put in to pacify gcov, but surely there’s
a better way.
(escape_char): Pacify GCC with 'assume' instead.

4 years agodoc: document env fix
Paul Eggert [Fri, 26 Mar 2021 21:00:37 +0000 (14:00 -0700)] 
doc: document env fix

* NEWS, doc/coreutils.texi (env invocation): Document recent change.

4 years agoenv: fix address violation with '\v' in -S
Paul Eggert [Fri, 26 Mar 2021 20:49:49 +0000 (13:49 -0700)] 
env: fix address violation with '\v' in -S

Problem reported by Frank Busse (Bug#47412).
* src/env.c (C_ISSPACE_CHARS): New macro.
(shortopts, build_argv, main): Treate all C-locale space
characters like space and tab, for compatibility with FreeBSD.
(validate_split_str, build_argv, parse_split_string):
Use the C locale, not the current locale, to determine whether a
byte is a space character.

4 years agohostname: pacify valgrind
Paul Eggert [Thu, 25 Mar 2021 18:20:18 +0000 (11:20 -0700)] 
hostname: pacify valgrind

* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).

4 years agohostname: use puts
Paul Eggert [Thu, 25 Mar 2021 16:16:36 +0000 (09:16 -0700)] 
hostname: use puts

* src/hostname.c (main): Prefer puts to printf "%s\n".

4 years agomaint: indenting
Paul Eggert [Thu, 25 Mar 2021 16:15:50 +0000 (09:15 -0700)] 
maint: indenting

* src/ln.c: Fix indenting.

4 years agoln: fix memory leaks in do_link
Kamil Dudka [Thu, 25 Mar 2021 10:57:56 +0000 (11:57 +0100)] 
ln: fix memory leaks in do_link

* src/ln.c (do_link): Free memory allocated by convert_abs_rel
on all code paths (Bug#47373).

4 years agostdbuf: port lib to macOS
Paul Eggert [Wed, 24 Mar 2021 23:59:40 +0000 (16:59 -0700)] 
stdbuf: port lib to macOS

* src/libstdbuf.c (fprintf, free, strtoumax): Undef these too,
since Gnulib might replace them.

4 years agocksum: port recent changes to macOS
Paul Eggert [Wed, 24 Mar 2021 23:43:05 +0000 (16:43 -0700)] 
cksum: port recent changes to macOS

* src/cksum.c (cksum_slice8): Fix bug on little-endian
platforms lacking __bswap_32: the SWAP macro evaluates
its argument multiple times, but the macro has a side effect.

4 years agomaint: update bootstrap from gnulib
Bernhard Voelker [Mon, 22 Mar 2021 22:45:30 +0000 (23:45 +0100)] 
maint: update bootstrap from gnulib

* bootstrap: Sync from gnulib/build-aux/bootstrap; the previous gnulib
update (commit 1a3eb6c30) missed to update that file.

4 years agoptx: remove use of diacrit module
Paul Eggert [Sun, 21 Mar 2021 21:00:26 +0000 (14:00 -0700)] 
ptx: remove use of diacrit module

The diacrit module is obsolete, and ptx’s use of it is obsolete
too; it assumes an 8-bit locale (not that common these days) and
that TeX cannot process the 8-bit characters (nowadays, it can).
* NEWS, doc/coreutils.texi (Charset selection in ptx): Document this.
* bootstrap.conf (gnulib_modules): Remove diacrit.
* src/ptx.c: Do not include diacrit.h.
(print_field, fix_output_parameters): Remove obsolete support
for 8-bit diacritics.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 21 Mar 2021 07:03:28 +0000 (00:03 -0700)] 
build: update gnulib submodule to latest

4 years agocksum: don't exit immediately if a single file overflows
Pádraig Brady [Mon, 15 Mar 2021 13:08:26 +0000 (13:08 +0000)] 
cksum: don't exit immediately if a single file overflows

This behavior was introduced in commit FILEUTILS-4_0_44-4-g519b707b4.

* src/cksum.c (cksum_slice8): Only report the overflow, and continue.
* src/cksum_pclmul.c (cksum_pclmul): Likewise.

4 years agocksum: add --debug to diagnose which implementation used
Pádraig Brady [Sat, 13 Mar 2021 18:10:12 +0000 (18:10 +0000)] 
cksum: add --debug to diagnose which implementation used

* src/cksum.c: (main): Use getopt_long to parse options,
and handle the new --debug option.
(pclmul_supported): Diagnose various failures and attempts.
* NEWS: Mention the new option.

4 years agocksum: use pclmul hardware instruction for CRC32 calculation
Kristoffer Brånemyr [Wed, 3 Feb 2021 09:35:22 +0000 (10:35 +0100)] 
cksum: use pclmul hardware instruction for CRC32 calculation

Use cpuid to detect CPU support for hardware instruction.
Fall back to slice by 8 algorithm if not supported.
A 500MiB file improves from 1.40s to 0.67s on an i3-2310M

* configure.ac [USE_PCLMUL_CRC32]: A new conditional,
set when __get_cpuid() and clmul compiler intrinsics are supported.
* src/cksum.c (pclmul_supported): A new function using __get_cpuid()
to determine if pclmul instructions are supported.
(cksum): A new function refactored from cksum_slice8(),
which calls pclmul_supported() and then cksum_slice8()
or cksum_pclmul() as appropriate.
* src/cksum.h: Export the crctab array for use in the new module.
* src/cksum_pclmul.c: A new module to implement using pclmul intrinsics.
* po/POTFILES.in: Reference the new cksum_pclmul module.
* src/local.mk: Likewise.  Note we build it as a separate library
so that it can be portably built with separate -mavx etc. flags.
* tests/misc/cksum.sh: Add new test modes for pertinent buffer sizes.

4 years agomaint: propagate DEPENDENCIES to libs in single binary mode
Pádraig Brady [Sun, 14 Mar 2021 22:43:42 +0000 (22:43 +0000)] 
maint: propagate DEPENDENCIES to libs in single binary mode

build-aux/gen-single-binary.sh (override_single): A new function
to refactor the existing mappings for dir, vdir, and arch.
This function now also sets the DEPENDENCIES variable so that these
dependencies can be maintained later in the script, where
we now propagate the automake generated $(src_$cmd_DEPENDENCIES)
to our equivalent src_libsinglebin_$cmd_a_DEPENDENCIES.
This will ensure that any required libs are built,
which we require in a following change to cksum that
builds part of it as a separate library.

4 years agormdir: diagnose non following of symlinks with trailing slash
Pádraig Brady [Tue, 16 Feb 2021 05:07:40 +0000 (05:07 +0000)] 
rmdir: diagnose non following of symlinks with trailing slash

GNU/Linux is unusual here in that rmdir("symlink/") returns ENOTDIR,
whereas Solaris and FreeBSD at least, will follow the symlink
and remove the target directory.  We don't make the behavior
on Linux kernels consistent, but at least clarify
the confusing error message.

* src/rmdir (main): Output a specific error message for the above case.
(remove_parents): In the error message, don't assume intermediate paths
are directories, as they could be symlinks.
* tests/rmdir/symlink-errors.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.

4 years agostat,tail: add support for the exfat file system
Kamil Dudka [Thu, 18 Feb 2021 10:18:04 +0000 (11:18 +0100)] 
stat,tail: add support for the exfat file system

Bug: https://bugzilla.redhat.com/1921427

* src/stat.c (human_fstype): Add case for the 'exfat' file system type.
* NEWS: Mention the Improvement.
Fixes https://bugs.gnu.org/46613

4 years agopr: fix alignment of input tabs to multiple columns
Erik Auerswald [Mon, 15 Feb 2021 21:21:17 +0000 (21:21 +0000)] 
pr: fix alignment of input tabs to multiple columns

This regression was introduced in commit COREUTILS-6_8-58-g553d347d3

* src/pr.c (init_parameters): Process tabs for multiple columns.
* tests/pr/pr-tests.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46422

4 years agocat: extend --show-ends to show \r\n as ^M$
Pádraig Brady [Tue, 9 Feb 2021 23:01:34 +0000 (23:01 +0000)] 
cat: extend --show-ends to show \r\n as ^M$

  - \r\n is common a line end combination
  - catting such a file without options causes it to display normally
  - overwriting the first char with $, loses info

* src/cat.c (cat): Convert \r preceeding a \n to ^M.
* tests/misc/cat-E.sh: New test.
* tests/local.mk: Reference new test.
* tests/misc/cat-proc.sh: Fix typo.
* doc/coreutils.texi (cat invocation): Mention the new behavior.
* NEWS: Mention the improvement.

4 years agoexpr: fix bug with unmatched \(...\)
Paul Eggert [Tue, 26 Jan 2021 17:23:54 +0000 (09:23 -0800)] 
expr: fix bug with unmatched \(...\)

Problem reported by Qiuhao Li.
* NEWS: Mention this.
* doc/coreutils.texi (String expressions):
Document the correct behavior, which POSIX requires.
* src/expr.c (docolon): Treat unmatched \(...\) as empty.
* tests/misc/expr.pl: New test.

4 years agosplit: fix --number=K/N to output correct part of file
Pádraig Brady [Mon, 25 Jan 2021 14:12:48 +0000 (14:12 +0000)] 
split: fix --number=K/N to output correct part of file

This functionality regressed with the adjustments
in commit v8.25-4-g62e7af032

* src/split.c (bytes_chunk_extract): Account for already read data
when seeking into the file.
* tests/split/b-chunk.sh: Use the hidden ---io-blksize option,
to test this functionality.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/46048

4 years agodoc: rmdir --recursive substitutes
Paul Eggert [Tue, 19 Jan 2021 05:08:39 +0000 (21:08 -0800)] 
doc: rmdir --recursive substitutes

* doc/coreutils.texi (rmdir invocation): Add note on how to remove
empty subdirectories recursively.

4 years agomkdir: fix bug when -m's more generous than umask
Paul Eggert [Fri, 15 Jan 2021 10:57:59 +0000 (02:57 -0800)] 
mkdir: fix bug when -m's more generous than umask

Problem reported by David McCall (Bug#45886).
I introduced this problem when fixing Bug#14371.
* NEWS: Mention the fix.
* src/mkdir.c (struct mkdir_options): New members umask_ancestor,
umask_self, replacing umask_value.
(make_ancestor): Use them when temporarily adjusting umask.
(main): Set them, and set the umask to umask_self instead
of leaving it alone.
* tests/mkdir/perm.sh (tests): Add test case for bug.

4 years agodoc: modernize and fix regexp xref
Paul Eggert [Sat, 9 Jan 2021 21:04:40 +0000 (13:04 -0800)] 
doc: modernize and fix regexp xref

* doc/coreutils.texi: Fix regexp cross-reference that had become
out-of-date (Bug#45749).  Also, fix some obsolete references to
SunOS and to /usr/dict/words, and change “Linux” to “GNU/Linux”
where appropriate.  Unfortunately the pipeline example gets more
complicated since /usr/share/dict/words is not sorted the way that
‘comm’ wants.

4 years agodoc: make formatting of SEE ALSO in cat.1 and tac.1 consistent
Bernhard Voelker [Sat, 2 Jan 2021 13:57:03 +0000 (14:57 +0100)] 
doc: make formatting of SEE ALSO in cat.1 and tac.1 consistent

None of the coreutils man pages - but the two above - are using bold
setting for the references to other man pages in the SEE ALSO section.

* man/cat.x (SEE ALSO): Remove '\fB...\fP' setting.
* man/tac.x: Likewise, and add a reference to cat(1).

4 years agomaint: exempt 'doc/fdl.texi' from 'make update-copyright'
Bernhard Voelker [Sat, 2 Jan 2021 00:36:19 +0000 (01:36 +0100)] 
maint: exempt 'doc/fdl.texi' from 'make update-copyright'

This file is a copy from gnulib and therefore should not get changed
by the yearly update.

* .x-update-copyright: Add pattern for the above file.
* doc/fdl.texi: Revert the previous change.

4 years agomaint: update all copyright year number ranges
Pádraig Brady [Fri, 1 Jan 2021 16:36:09 +0000 (16:36 +0000)] 
maint: update all copyright year number ranges

Run "make update-copyright" and then...

* gnulib: Update to latest with copyright year adjusted.
* tests/init.sh: Sync with gnulib to pick up copyright year.
* bootstrap: Likewise.
* tests/sample-test: Adjust to use the single most recent year.

4 years agotests: add a test for cksum
Pádraig Brady [Mon, 28 Dec 2020 15:04:54 +0000 (15:04 +0000)] 
tests: add a test for cksum

* tests/misc/cksum.sh: Test basic operation.
* tests/local.mk: Reference the new test.

4 years agocksum: use more efficient slice by 8 algorithm
Kristoffer Brånemyr [Sat, 26 Dec 2020 23:40:10 +0000 (23:40 +0000)] 
cksum: use more efficient slice by 8 algorithm

A 100MB file improves from 2.50s to 1.80s on a Sparc T5220
A 100MB file improves from 0.54s to 0.13s on an i3-2310M

* bootstrap.conf: Explicitly depend on byteswap,
since now used directly by coreutils.
* src/cksum.c (cksum): Process in multiples of 8 bytes.
(main): Adjust for generation of expanded crctab.
* src/cksum.h: Split now larger crctab to separate header.
* src/local.mk: Reference the new header.
* NEWS: Mention the improvement.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 25 Dec 2020 04:58:22 +0000 (20:58 -0800)] 
build: update gnulib submodule to latest

* src/make-prime-list.c (free): Undef, since Gnulib's free-posix
module now defines this to rpl_free on some platforms.

4 years agodoc: remove extraneous ./src/ prefix from examples
Pádraig Brady [Fri, 18 Dec 2020 14:58:59 +0000 (14:58 +0000)] 
doc: remove extraneous ./src/ prefix from examples

* doc/coreutils.texi (numfmt invocation): s|./src/numfmt|numfmt|

4 years agodoc: add `seq inf` and `sleep inf` examples to texinfo
Pádraig Brady [Fri, 18 Dec 2020 14:49:27 +0000 (14:49 +0000)] 
doc: add `seq inf` and `sleep inf` examples to texinfo

* doc/coreutils.texi (seq invocation): Mention "inf" is supported,
and describe that it's handled specially to generate infinite
whole integer sequences.  Also mention that such infinite generation
is supported for integer steps up to 200.
(sleep invocation): Give `sleep inf` as an example to sleep forever.
* src/seq.c: Add a comment on SEQ_FAST_STEP_LIMIT, to say it's
reflected in the texinfo description.

4 years agodoc: document mkdir -m -p better
Paul Eggert [Tue, 15 Dec 2020 19:52:19 +0000 (11:52 -0800)] 
doc: document mkdir -m -p better

Chris Colohan wrote that the man page did not do enough to dispel
a common misunderstanding that “contributed to one of the scariest
outages Google has ever seen” (Bug#45258).
* doc/coreutils.texi (mkdir invocation):
* src/mkdir.c (usage): Document -m vs -p better.

4 years agonl: fix --section-delimiter handling of single characters
KOBAYASHI Takashi [Mon, 14 Dec 2020 16:17:10 +0000 (16:17 +0000)] 
nl: fix --section-delimiter handling of single characters

* src/nl.c (main): Enforce the POSIX specified
behavior of assuming ':' is specified after a single
character argument to -d.
* tests/misc/nl.sh: Add a test case.
* NEWS: Mention the bug fix.

4 years agodoc: mention the GNU extensions to nl --section-delimiter
Pádraig Brady [Tue, 15 Dec 2020 01:06:50 +0000 (01:06 +0000)] 
doc: mention the GNU extensions to nl --section-delimiter

* doc/coreutils.texi (nl invocation): Mention the GNU extensions
of allowing arbitrary length and empty delimiter strings.
* src/nl.c (usage): Likewise.
* tests/misc/nl.sh: Add test cases for the GNU extensions.

4 years agomaint: refactor nl section delimiter handling
Pádraig Brady [Tue, 15 Dec 2020 01:02:32 +0000 (01:02 +0000)] 
maint: refactor nl section delimiter handling

* src/nl.c (main): Update the default delimiter characters
when passed two characters with --section-delimiter.
Avoid redundant copies for the body and footer delimiter strings,
and instead, just offset into the header string.
(check_section): Avoid redundant comparing of 2 bytes of memory
for an empty delimiter.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 12 Dec 2020 02:15:34 +0000 (18:15 -0800)] 
build: update gnulib submodule to latest

4 years agochroot,comm,join: fix usage options style
Arman Absalan [Mon, 7 Dec 2020 21:18:57 +0000 (00:48 +0330)] 
chroot,comm,join: fix usage options style

* src/chroot.c (usage): Fix indentation of options.
* src/comm.c: Likewise.
* src/join.c: Likewise.

4 years agodate: with --debug, show the output format
Pádraig Brady [Mon, 30 Nov 2020 19:06:59 +0000 (19:06 +0000)] 
date: with --debug, show the output format

The format can be determined from --options or the locale,
so it's useful to output the format string being used.

* src/date.c (show_date): Show the output format
along with the date being shown.
* tests/misc/date-debug.sh: Adjust accordingly.
Addresses https://bugs.gnu.org/44960

4 years agomaint: fix typo, characteres -> characters
Tim Gates [Fri, 27 Nov 2020 19:56:02 +0000 (19:56 +0000)] 
maint: fix typo, characteres -> characters

* src/expr.c: Fix typo in comment.

4 years agorm: do not skip files upon failure to remove an empty dir
Nishant Nayan [Thu, 26 Nov 2020 14:35:17 +0000 (14:35 +0000)] 
rm: do not skip files upon failure to remove an empty dir

When removing a directory fails for some reason, and that directory
is empty, the rm_fts code gets the return value of the excise call
confused with the return value of its earlier call to prompt,
causing fts_skip_tree to be called again and the next file
that rm would otherwise have deleted to survive.

* src/remove.c (rm_fts): Ensure we only skip a single fts entry,
when processing empty dirs.  I.e. only skip the entry
having successfully removed it.
* tests/rm/empty-immutable-skip.sh: New root-only test.
* tests/local.mk: Add it.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/44883

4 years agomaint: mention in NEWS about new df remote fs types
Pádraig Brady [Thu, 26 Nov 2020 14:29:57 +0000 (14:29 +0000)] 
maint: mention in NEWS about new df remote fs types

* NEWS: Mention new remote file system types
recognized since gnulib commit dd1fc46b.

4 years agomaint: remove no longer needed se_const helper
Pádraig Brady [Mon, 23 Nov 2020 15:13:05 +0000 (15:13 +0000)] 
maint: remove no longer needed se_const helper

This was needed before libselinux-2.3 (May 2014),
but modern releases have the correct const declarations.

* src/chcon.c: Remove se_const() wrapper.
* src/cp.c: Likewise.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
* src/system.h: Likewise.
* gnulib: update to pick up const correctness fixes in selinux stubs.

4 years agomaint: fix syntax-check failure
Pádraig Brady [Mon, 23 Nov 2020 14:09:51 +0000 (14:09 +0000)] 
maint: fix syntax-check failure

* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.

4 years agoinstall: suppress "Operation not supported" false alarms
Paul Eggert [Mon, 23 Nov 2020 09:48:15 +0000 (01:48 -0800)] 
install: suppress "Operation not supported" false alarms

At least, I *think* they are false alarms.  An SELinux expert eye
would be welcome.
* src/install.c (setdefaultfilecon): If selabel_lookup fails
due to either ENOTSUP or ENODATA, don’t diagnose the issue.
Problem reported by Kamil Dudka in:
https://lists.gnu.org/r/coreutils/2020-11/msg00050.html

4 years agomaint: propagate errno better in selinux.c
Paul Eggert [Mon, 23 Nov 2020 08:52:00 +0000 (00:52 -0800)] 
maint: propagate errno better in selinux.c

* src/selinux.c: Don’t include die.h; no longer needed.
(computecon, defaultcon, restorecon): Propagate errno.
(defaultcon, restorecon): Don’t diagnose errors or exit, as that’s
the caller’s responsibility.

4 years agomaint: use absolute paths with selabel_lookup
Pádraig Brady [Sun, 22 Nov 2020 17:46:52 +0000 (17:46 +0000)] 
maint: use absolute paths with selabel_lookup

* src/selinux.c: selabel_lookup requires absolute paths
(while only older matchpathcon before libselinux < 2.1.5 2011-0826 did).
* po/POTFILES.in: Readd src/selinux.c since we now have
a translatable error message.

4 years agomaint: minor cleanup
Bernhard Voelker [Sun, 22 Nov 2020 12:05:29 +0000 (13:05 +0100)] 
maint: minor cleanup

The previous commit introduced a couple of syntax-check failures.

* .gitignore (/lib/se-label.h): Add entry to silence the
sc_gitignore_missing check.  Sort entries in C locale.
* po/POTFILES.in (src/selinux.c): Remove entry as this source doesn't
contain any translatable strings anymore; avoids a sc_po_check failure.
* src/mv.c: Replace tabs by spaces to avoid complaints by
sc_prohibit_tab_based_indentation.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sun, 22 Nov 2020 03:05:16 +0000 (19:05 -0800)] 
build: update gnulib submodule to latest

4 years agomaint: port from matchpathcon to selabel_lookup
Paul Eggert [Sun, 22 Nov 2020 00:59:25 +0000 (16:59 -0800)] 
maint: port from matchpathcon to selabel_lookup

Ubuntu 20.10 is using a newer version of libselinux that
complains that matchpathcon is obsolete.  Rewrite the code
that it uses the recommended selabel_lookup instead.
* m4/jm-macros.m4 (coreutils_MACROS): Do not check for
matchpathcon_init_prefix, as it is no longer used.
* src/copy.c (set_file_security_ctx): Omit process_local arg,
as it is equivalent to !x->set_security_context.  All callers changed.
* src/copy.h (struct cp_options): set_security_context is now of
type struct selabel_handle *, not bool.  All uses changed.
* src/cp.c, src/install.c, src/mkdir.c, src/mkfifo.c, src/mknod.c:
* src/mv.c: Include selinux/label.h.
(main): Use selabel_open for set_security context.
* src/install.c (matchpathcon_init_prefix): Remove; now unused.
(get_labeling_handle): New static function.
(setdefaultfilecon, main): Use it.
(setdefaultfilecon): Do something regardless of
ENABLE_MATCHPATHCON, which seems to be a revenant macro.
(setdefaultfilecon): Use selabel_lookup instead of the obsolescent
matchpathcon.  Report an error unless it fails due to ENOENT.
* src/local.mk (src_ginstall_CPPFLAGS): Remove.
* src/selinux.c: Include selinux/label.h
Do not include die.h, error.h, canonicalize.h.
(defaultcon, restorecon_private, restorecon):
New arg HANDLE.  All callers changed.
Use selabel_lookup rather than matchpathcon.
(restorecon_private, restorecon): Don’t lose track of errno.
* src/selinux.c, src/selinux.h:
(restorecon): Don’t call ‘error’; that’s the caller’s job.
Use HAVE_SELINUX_LABEL_H, not HAVE_SELINUX_SELINUX_H,
in case there is some weird system with the former but not the latter.
* src/selinux.h (struct selinux_handle): Add forward decl.

4 years agobuild: port to Solaris 10
Paul Eggert [Sat, 21 Nov 2020 21:18:55 +0000 (13:18 -0800)] 
build: port to Solaris 10

* src/local.mk (src_ln_LDADD, src_mktemp_LDADD, src_tac_LDADD):
Add $(LIB_CLOCK_GETTIME), since these use tempname which uses
clock_gettime if getrandom fails.  On platforms like Solaris 10,
clock_gettime is not in the standard C library.

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Sat, 21 Nov 2020 20:59:09 +0000 (12:59 -0800)] 
build: update gnulib submodule to latest

4 years agodoc: mention that sort -g supports hex numbers
Pádraig Brady [Wed, 18 Nov 2020 14:00:43 +0000 (14:00 +0000)] 
doc: mention that sort -g supports hex numbers

* doc/coreutils.texi (sort invocation): Mention explicitly
that --general-numeric-sort supports arbitrary format hex numbers,
but also mention that consistent case/width hex numbers can
be sorted faster with a standard sort.

4 years agotr: fix crash validating -c with some case char classes
Pádraig Brady [Sat, 14 Nov 2020 16:47:05 +0000 (16:47 +0000)] 
tr: fix crash validating -c with some case char classes

This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v8.5-163-g3f48829c2

* src/tr.c (validate_case_classes): Don't apply these
extra case alignment checks in the --complement case,
which is even more restrictive as to the contents of SET2.
* tests/misc/tr-case-class.sh: Add a test case,
for a large SET1, which caused the length adjustment
in validate_case_classes to underflow and trigger the assert.
* NEWS: Mention the bug fix.

4 years agodoc: clarify in texinfo that `test == ...` is non portable
Ben Pfaff [Thu, 12 Nov 2020 18:59:31 +0000 (18:59 +0000)] 
doc: clarify in texinfo that `test == ...` is non portable

* doc/coreutils.texi (test invocation): Mention non portability
of the double equals form.

4 years agols: fix crash printing SELinux context for unstatable files
Pádraig Brady [Wed, 11 Nov 2020 17:22:33 +0000 (17:22 +0000)] 
ls: fix crash printing SELinux context for unstatable files

This crash was identified by Cyber Independent Testing Lab:
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
and was introduced with commit v6.9.90-11-g4245876e2

* src/ls.c (gobble_file): Ensure scontext is initialized
in the case where files are not statable.
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
and added test case for broken symlinks.
* tests/local.mk: Adjust for the renamed test.
* NEWS: Mention the bug fix.

4 years agotimeout: support sub-second timeouts on macOS
Pádraig Brady [Sat, 7 Nov 2020 21:35:01 +0000 (21:35 +0000)] 
timeout: support sub-second timeouts on macOS

* m4/jm-macros.m4: Check for setitimer.
* src/timeout.c: Use setitimer if timer_settime is not available.
* NEWS: Mention the improvement.

4 years agomaint: avoid strncat warning on GCC
Pádraig Brady [Sat, 7 Nov 2020 21:04:12 +0000 (21:04 +0000)] 
maint: avoid strncat warning on GCC

GCC 10.1.1 without optimization gives:

  error: ‘strncat’ argument 2 declared attribute ‘nonstring’
    [-Werror=stringop-overflow=]
    strncat (comment, UT_ID (utmp_ent), utmpsize);

Note the strncat man page says that:
  "src does not need to be null-terminated
   if it contains n or more bytes."
And the POSIX spec says that the second (source) parameter
is an array not a string.
So I think it's incorrect for strncat to require src be a string type.
This constraint seems to be being added to the gcc builtin strncat,
as specifiying -fno-builtin also avoids the warning.
Note specifying any optimization level also avoids the warning.

* src/who.c (make_id_equals_comment): Avoid the issue by using
stpcpy + stzncpy, instead of strcpy + strncat.
This pattern is used elsewhere in who.c

4 years agostat,tail: sync file system constants from the linux kernel
Pádraig Brady [Tue, 27 Oct 2020 20:15:43 +0000 (20:15 +0000)] 
stat,tail: sync file system constants from the linux kernel

* src/stat.c: Add magic constants for "devmem", and
"zonefs" file systems.
* NEWS: Mention the improvement.

4 years agomaint: cleanup operation of fs-magic-compare
Pádraig Brady [Tue, 27 Oct 2020 20:00:43 +0000 (20:00 +0000)] 
maint: cleanup operation of fs-magic-compare

* src/local.mk: Ensure we map 2 hex digits to 4,
so that we don't output already handled Z3FOLD file system (0x33).
Also hide the generation command for src/fs.h.

4 years agodoc: make blank lines before --help consistent
Pádraig Brady [Tue, 27 Oct 2020 14:10:14 +0000 (14:10 +0000)] 
doc: make blank lines before --help consistent

* src/basenc.c (usage): Remove extraneous blank line,
to be consistent with other utilities that have options.
* src/realpath.c: Likewise.
* src/runcon.c: Likewise.
Addresses https://bugs.gnu.org/44248

4 years agomaint: avoid new sort.c warning from upcoming GCC11
Jim Meyering [Sun, 25 Oct 2020 17:04:19 +0000 (10:04 -0700)] 
maint: avoid new sort.c warning from upcoming GCC11

gcc version 11.0.0 20201025 (experimental) warns that
src/sort.c:1655:1: warning: function might be candidate for attribute \
  'pure' if it is known to return normally [-Wsuggest-attribute=pure]
* src/sort.c (limfield): Mark as pure.

4 years agodd: drop old workaround for lseek() bug in Linux kernel
Kamil Dudka [Mon, 26 Oct 2020 10:44:44 +0000 (11:44 +0100)] 
dd: drop old workaround for lseek() bug in Linux kernel

The workaround triggers warnings from newer kernel versions in case
a user does not have sufficient privileges for the MTIOCGET ioctl.

* src/dd.c (skip_via_lseek): Drop wrapper function no longer needed.
(skip): Use lseek() directly.
(advance_input_after_read_error): Likewise.

Reported-by: Nir Soffer at https://bugzilla.redhat.com/1876840
Fixes https://bugs.gnu.org/44235

4 years agonl: support a negative --line-increment
KOBAYASHI Takashi [Sun, 25 Oct 2020 17:09:04 +0000 (17:09 +0000)] 
nl: support a negative --line-increment

* src/nl.c (main): Allow -i to accept down to INTMAX_MIN.
* tests/misc/nl.sh: Add test cases.
* NEWS: Mention the new feature.

4 years agonl: only fail if need to output overflowed numbers
Pádraig Brady [Sun, 25 Oct 2020 16:40:35 +0000 (16:40 +0000)] 
nl: only fail if need to output overflowed numbers

Previously we would have failed immediately upon internal overflow,
which didn't output the full line being processed, and assumed
there would be another numbered line.

* src/nl.c (line_no_overflow): A new global to track overflow.
(print_lineno): Only fail if about to output an overflowed number.
(reset_lineno): A new function to refactor resetting of the number,
and which also clears line_no_overflow.
* tests/misc/nl.sh: Add a test case.

4 years agomaint: add lib/parse-datetime-gen.h to .gitignore
Pádraig Brady [Sun, 25 Oct 2020 13:35:40 +0000 (13:35 +0000)] 
maint: add lib/parse-datetime-gen.h to .gitignore

* .gitignore: update to ignore new file
generated by the latest gnulib update.

4 years agomaint: sync help2man to latest version
Pádraig Brady [Sun, 25 Oct 2020 13:10:32 +0000 (13:10 +0000)] 
maint: sync help2man to latest version

* man/help2man: sync to changes from version 1.47.16.
Note this doesn't materially change the generated man pages.
Addresses https://bugs.gnu.org/44105

4 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 19 Oct 2020 17:47:32 +0000 (10:47 -0700)] 
build: update gnulib submodule to latest

* gl/lib/randperm.c, src/cp-hash.c, src/ls.c, src/sort.c, src/tail.c:
Change all instaces of hash_delete to hash_remove to accommodate
change to Gnulib API.

4 years agomaint: remove already handled FIXME in tail.c
Grigorii Sokolik [Sat, 17 Oct 2020 15:54:17 +0000 (16:54 +0100)] 
maint: remove already handled FIXME in tail.c

* src/tail.c: Remove FIXME to follow a file name in a recreated
directory. The comment was added in commit v8.5-191-g61b77891c
while the fix (albeit not using inotify) was added in
commit v8.27-21-gba5fe2d4b

4 years agomaint: update docs for build prerequisites
Grigorii Sokolik [Sat, 17 Oct 2020 15:52:17 +0000 (16:52 +0100)] 
maint: update docs for build prerequisites

* README-prereq: Explicitly pull tags,
and update the xz git repo url.

4 years agodoc: fix punctuation in stat --help
Benno Schulenberg [Tue, 29 Sep 2020 12:31:52 +0000 (14:31 +0200)] 
doc: fix punctuation in stat --help

* src/stat.c (usage): Replace a mistaken semicolon with a colon,
and replace mistaken backticks with single quotes.  Also reorder
some words, for clarity.
Fixes https://bugs.gnu.org/43707

4 years agodoc: clarify timeout --foreground description
Pádraig Brady [Wed, 12 Aug 2020 17:40:04 +0000 (18:40 +0100)] 
doc: clarify timeout --foreground description

* doc/coreutils.texi (timeout invocation): Avoid any implication
that `timeout --foreground` could be used to retroactively
timeout commands not already invoked by timeout(1).
Fixes bug https://bugs.gnu.org/42831

4 years agocsplit: fix regex suppression with specific match count
Emanuele Giacomelli [Sat, 8 Aug 2020 20:29:13 +0000 (21:29 +0100)] 
csplit: fix regex suppression with specific match count

* src/csplit.c (process_regexp): Process the line suppression
in all invocations so that the last match is suppressed.
Previously with a non infinite match count,
the last regex pattern was not suppressed.
* NEWS: Mention the bug fix.
* tests/misc/csplit-suppress-matched.pl: Add a test case.
Fixes https://bugs.gnu.org/42764

5 years agotests: skip some parts of 'tests/rmdir/ignore.sh' if run as root
Bernhard Voelker [Fri, 31 Jul 2020 17:49:35 +0000 (19:49 +0200)] 
tests: skip some parts of 'tests/rmdir/ignore.sh' if run as root

Parts of this test expect that the rmdir syscall returns with EPERM,
but the root user does not see that.

* tests/rmdir/ignore.sh: Add uid_is_privileged_ guards around parts
of the test which expect rmdir() to fail with EPERM.

Reported by Nick Alcock <nix@esperi.org.uk> in
https://bugs.gnu.org/42633

5 years agodoc: show version in title of HTML manual
Bernhard Voelker [Tue, 28 Jul 2020 21:28:45 +0000 (23:28 +0200)] 
doc: show version in title of HTML manual

* doc/coreutils.texi (@include version.texi): Move before ...
(@settitle): ... this.  Add the version after the package name.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-07/msg00021.html

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Mon, 27 Jul 2020 21:06:10 +0000 (14:06 -0700)] 
build: update gnulib submodule to latest

* src/local.mk (src_expr_LDADD, src_factor_LDADD):
Adjust to Gnulib renaming of LIB_GMP to LIBGMP.

5 years agodoc: fix typo in env --split-string documentation
Pádraig Brady [Mon, 27 Jul 2020 12:10:55 +0000 (13:10 +0100)] 
doc: fix typo in env --split-string documentation

* doc/coreutils.texi: Fix grammar.

5 years agodate: clarify the Epoch
Paul Eggert [Fri, 24 Jul 2020 20:33:09 +0000 (13:33 -0700)] 
date: clarify the Epoch

* src/date.c (usage): Mention the Epoch under %s for clarity,
and capitalize.

5 years agodoc: modernize date examples
Paul Eggert [Fri, 24 Jul 2020 20:31:10 +0000 (13:31 -0700)] 
doc: modernize date examples

* doc/coreutils.texi: Use more-modern date examples.
Capitalize “Epoch” to be consistent with POSIX.

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Fri, 24 Jul 2020 19:22:29 +0000 (12:22 -0700)] 
build: update gnulib submodule to latest

* bootstrap.conf (gnulib_modules): Add hash-triple.

5 years agodoc: clarify 'timeout -k' behavior
Bernhard Voelker [Sat, 4 Jul 2020 23:20:10 +0000 (01:20 +0200)] 
doc: clarify 'timeout -k' behavior

* doc/coreutils.texi (timeout invocation): Document that the the
duration of --kill-after=DURATION begins when sending the initial
signal.  Also mention that -k does not have any effect if timeout's
duration is 0.

Suggested by Jonny Grant <jg@jguk.org>.

5 years agofactor: port to --without-libgmp
Paul Eggert [Sun, 19 Jul 2020 01:45:06 +0000 (18:45 -0700)] 
factor: port to --without-libgmp

* src/factor.c (mp_factor_using_division): Use mpz_fdiv_q_2exp
instead of its no-longer-documented mpz_div_2exp alias.
(print_factors): Use mpz_out_str instead of gmp_printf.

5 years agobuild: be less aggressive about -fanalyzer
Paul Eggert [Fri, 10 Jul 2020 22:54:51 +0000 (15:54 -0700)] 
build: be less aggressive about -fanalyzer

* configure.ac: Don’t enable -fanalyzer unless configured with the
new --enable-gcc-warnings=expensive option.  See thread at:
https://lists.gnu.org/r/coreutils/2020-07/msg00011.html

5 years agofactor: explain why non-GMP code (Bug#42269)
Paul Eggert [Thu, 9 Jul 2020 01:58:18 +0000 (18:58 -0700)] 
factor: explain why non-GMP code (Bug#42269)

* doc/coreutils.texi (factor invocation):
* src/factor.c: Explain why the two-word algorithm is useful.

5 years agodoc: mention expr and factor bignums
Paul Eggert [Wed, 8 Jul 2020 15:09:31 +0000 (08:09 -0700)] 
doc: mention expr and factor bignums

* NEWS:
* doc/coreutils.texi (expr invocation, factor invocation):
Mention bignum support on all platforms.  Modernize timings.

5 years agofactor: treat ' +bignum' like non-bignum
Paul Eggert [Wed, 8 Jul 2020 15:05:06 +0000 (08:05 -0700)] 
factor: treat ' +bignum' like non-bignum

* src/factor.c (strto2uintmax): Instead of here ...
(print_factors): ... skip spaces and '+' here, so that
bignums are treated like non-bignums.
* tests/misc/factor.pl (bug-gmp-plus_2_sup_128_plus_1): New test.

5 years agotests: simplify since expr now works on bignums
Paul Eggert [Wed, 8 Jul 2020 14:45:05 +0000 (07:45 -0700)] 
tests: simplify since expr now works on bignums

* cfg.mk (sc_prohibit_expr_unsigned): Remove.
* tests/dd/skip-seek-past-dev.sh (DEV_OFLOW):
* tests/id/setgid.sh (gp1):
* tests/misc/cut-huge-range.sh (CUT_MAX):
* tests/misc/expr.pl:
* tests/misc/sort-discrim.sh:
Assume expr works on bignums.
* tests/misc/cut-huge-range.sh (subtract_one):
Remove; no longer needed.

5 years agofactor: simplify tests by assuming libgmp
Paul Eggert [Wed, 8 Jul 2020 06:48:53 +0000 (23:48 -0700)] 
factor: simplify tests by assuming libgmp

* tests/misc/factor.pl: Test bignums even if !HAVE_GMP.

5 years agomaint: use Gnulib libgmp module
Paul Eggert [Tue, 7 Jul 2020 17:39:10 +0000 (10:39 -0700)] 
maint: use Gnulib libgmp module

This lets use assume multiple-precision arithmetic on all
platforms, simplifying the code.
* bootstrap.conf (gnulib_modules): Add libgmp.
* configure.ac: Don’t call cu_GMP, as this is now done by Gnulib.
* m4/gmp.m4: Remove.
* src/expr.c, src/factor.c: Use gmp.h unconditionally.
* src/factor.c: Use the simpler ‘#ifndef mpz_inits’ to
determine whether there is an mpz_inits macro.

5 years agobuild: update gnulib submodule to latest
Paul Eggert [Tue, 7 Jul 2020 03:35:25 +0000 (20:35 -0700)] 
build: update gnulib submodule to latest

5 years agodoc: add timeout examples
Bernhard Voelker [Fri, 3 Jul 2020 22:19:31 +0000 (00:19 +0200)] 
doc: add timeout examples

* doc/coreutils.texi (timeout invocation): Add examples.

Suggested by Jonny Grant <jg@jguk.org> in
https://lists.gnu.org/r/bug-coreutils/2020-06/msg00018.html

5 years agotests: avoid spurious testsuite failure
Andreas Schwab [Tue, 30 Jun 2020 11:05:55 +0000 (13:05 +0200)] 
tests: avoid spurious testsuite failure

* tests/dd/stats.sh: Increase timeout.
Fixes https://bugs.gnu.org/42135

5 years agotests: fix false failure with valgrind and reflink
Pádraig Brady [Fri, 26 Jun 2020 18:57:09 +0000 (19:57 +0100)] 
tests: fix false failure with valgrind and reflink

* tests/cp/fiemap-FMR.sh: Avoid FICLONE ioctl,
which would avoid the point of the test (fiemap testing).
Also it avoids a valgrind bug with this ioctl:
https://bugs.kde.org/show_bug.cgi?id=397605

5 years agocp: use copy_file_range if available
Paul Eggert [Fri, 26 Jun 2020 00:34:23 +0000 (17:34 -0700)] 
cp: use copy_file_range if available

* NEWS: Mention this.
* bootstrap.conf (gnulib_modules): Add copy-file-range.
* src/copy.c (sparse_copy): Try copy_file_range if not
looking for holes.