]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
5 months agosys-utils: cleanup license lines, add SPDX
Karel Zak [Mon, 11 Dec 2023 12:37:41 +0000 (13:37 +0100)] 
sys-utils: cleanup license lines, add SPDX

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'uuid-time64_t' of https://github.com/thkukuk/util-linux
Karel Zak [Mon, 11 Dec 2023 09:57:27 +0000 (10:57 +0100)] 
Merge branch 'uuid-time64_t' of https://github.com/thkukuk/util-linux

* 'uuid-time64_t' of https://github.com/thkukuk/util-linux:
  libuuid: Add uuid_time64 for 64bit time_t on 32bit

5 months agoMerge branch 'master' of https://github.com/goldwynr/util-linux
Karel Zak [Mon, 11 Dec 2023 09:52:47 +0000 (10:52 +0100)] 
Merge branch 'master' of https://github.com/goldwynr/util-linux

* 'master' of https://github.com/goldwynr/util-linux:
  more: exit if POLLERR and POLLHUP on stdin is received

5 months agoMerge branch 'fix-bash-completion-rules' of https://github.com/masatake/util-linux
Karel Zak [Mon, 11 Dec 2023 09:52:11 +0000 (10:52 +0100)] 
Merge branch 'fix-bash-completion-rules' of https://github.com/masatake/util-linux

* 'fix-bash-completion-rules' of https://github.com/masatake/util-linux:
  bash-completion: (lslocks): add --bytes option to the rules
  bash-completion: (fadvise): fix a typo

5 months agobash-completion: (lslocks): add --bytes option to the rules
Masatake YAMATO [Fri, 8 Dec 2023 17:33:40 +0000 (02:33 +0900)] 
bash-completion: (lslocks): add --bytes option to the rules

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agobash-completion: (fadvise): fix a typo
Masatake YAMATO [Fri, 8 Dec 2023 17:33:14 +0000 (02:33 +0900)] 
bash-completion: (fadvise): fix a typo

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agofdisk: add support for partition resizing
Thomas Weißschuh [Sun, 19 Nov 2023 16:20:55 +0000 (17:20 +0100)] 
fdisk: add support for partition resizing

Fixes #2555
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agomore: exit if POLLERR and POLLHUP on stdin is received
Goldwyn Rodrigues [Fri, 8 Dec 2023 15:04:39 +0000 (09:04 -0600)] 
more: exit if POLLERR and POLLHUP on stdin is received

more command continues to run in case stdin have closed the file and it
takes 100% of CPU. This is because revents on stdin send
POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even
though it is not requested in events. This is common Linux behaviour to
never mask out POLLHUP or POLLERR. The loop in more_key_command() runs
infinitely because more_poll() returns 0 and read_command() reads 0
bytes.

Check for POLLERR and POLLHUP, and exit more in case of an error.

Steps to reproduce:
1. Setup /etc/systemd/logind.conf with KillUserProcesses=no
2. Add config "Defaults use_pty" in /etc/sudoers
3. Start an ssh session to the machine
4. # sudo su -
5. # more <big enough file>
6. kill the parent ssh process, say close the tab

At this time "more" runs with 100% CPU utilization.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
5 months agolibuuid: Add uuid_time64 for 64bit time_t on 32bit
Thorsten Kukuk [Thu, 30 Nov 2023 15:28:53 +0000 (16:28 +0100)] 
libuuid: Add uuid_time64 for 64bit time_t on 32bit

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
5 months agoRevert "more: exit if POLLHUP or POLLERR on stdin is received"
Karel Zak [Fri, 8 Dec 2023 12:26:52 +0000 (13:26 +0100)] 
Revert "more: exit if POLLHUP or POLLERR on stdin is received"

the regression test more/regexp failed.

This reverts commit 9be4122b1d8c1c2b8eb270998838c73bae7ff2ff.

5 months agohwclock: reuse error message
Karel Zak [Fri, 8 Dec 2023 12:16:23 +0000 (13:16 +0100)] 
hwclock: reuse error message

The only hwclock is the place we use this message.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agobash-completion: make sure that "lastb" actually completes
Eli Schwartz [Thu, 7 Dec 2023 00:40:44 +0000 (19:40 -0500)] 
bash-completion: make sure that "lastb" actually completes

Building util-linux logs a warning on Gentoo:

```
 * Problems with installed bash completions were found:
 *
 *  lastb: incorrect name, no completions for 'lastb' command defined.
 *
 * For more details on installing bash-completions, please see:
 * https://wiki.gentoo.org/wiki/Bash/Installing_completion_files
```

A bash-completion file is usually composed of two parts:
- a function that knows how to produce completions
- a specification of which command should be completed

In cases where multiple commands have the same options, e.g. commands
that are symlinked to each other, it is common to symlink the completion
files as well. This shares the first part. But the second part cannot be
shared, it must be implemented twice by specifying two different
commands to be completed.

"lastb" had a symlinked completion, but when the completion system
processes /usr/share/bash-completion/completions/lastb, it would only
define a completion for "last".

Define both completions in one file, so that sourcing it works
regardless of command used.

5 months agomore: exit if POLLHUP or POLLERR on stdin is received
Goldwyn Rodrigues [Wed, 6 Dec 2023 19:19:17 +0000 (13:19 -0600)] 
more: exit if POLLHUP or POLLERR on stdin is received

more command continues to run in case stdin have closed the file and it
takes 100% of CPU. This is because revents on stdin send
POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even
though it is not requested in events. This is common Linux behaviour to
never mask out POLLHUP or POLLERR. The loop in more_key_command() runs
infinitely because more_poll() returns 0 and read_command() reads 0
bytes.

Steps to reproduce:
1. Setup /etc/systemd/logind.conf with KillUserProcesses=no
2. Add config "Defaults use_pty" in /etc/sudoers
3. Start an ssh session to the machine
4. # sudo su -
5. # more <big enough file>
6. kill the parent ssh process, say close the tab

At this time "more" runs with 100% CPU utilization.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
5 months agoMerge branch 'PR/list-columns' of github.com:karelzak/util-linux-work
Karel Zak [Fri, 8 Dec 2023 10:31:03 +0000 (11:31 +0100)] 
Merge branch 'PR/list-columns' of github.com:karelzak/util-linux-work

* 'PR/list-columns' of github.com:karelzak/util-linux-work:
  findmnt: add --list-columns
  lslocks: improve --list-columns
  lsblk: add --list-columns

5 months agotests: (lslcoks) insert a sleep between taking a lock and running lslocks
Masatake YAMATO [Thu, 7 Dec 2023 19:35:29 +0000 (04:35 +0900)] 
tests: (lslcoks) insert a sleep between taking a lock and running lslocks

Close #2624.

It appears that there is a time lag between locking and its visibility
in /proc/locks.  See the unstbale results of errors I observed in
https://github.com/util-linux/util-linux/pull/2629.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agofindmnt: add --list-columns
Karel Zak [Wed, 6 Dec 2023 12:56:28 +0000 (13:56 +0100)] 
findmnt: add --list-columns

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolslocks: improve --list-columns
Karel Zak [Wed, 6 Dec 2023 12:25:20 +0000 (13:25 +0100)] 
lslocks: improve --list-columns

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolsblk: add --list-columns
Karel Zak [Wed, 6 Dec 2023 12:19:34 +0000 (13:19 +0100)] 
lsblk: add --list-columns

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agounshare: make sure map_range.next is initialized [coverity scan]
Karel Zak [Thu, 7 Dec 2023 12:54:26 +0000 (13:54 +0100)] 
unshare: make sure map_range.next is initialized [coverity scan]

* initialize during declaration (if possible), unspecified fields
  defaults to zero in this case.

* fix coverity warnings:
 CID 410290:  Uninitialized variables  (UNINIT)
 Using uninitialized value "mid". Field "mid.next" is uninitialized when calling "insert_map_range".

 CID 410289:  Uninitialized variables  (UNINIT)
 Using uninitialized value "hi". Field "hi.next" is uninitialized when calling "insert_map_range".

 CID 410288:  Uninitialized variables  (UNINIT)
 Using uninitialized value "lo". Field "lo.next" is uninitialized when calling "insert_map_range".

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'master' of https://github.com/mystuffs/util-linux
Karel Zak [Thu, 7 Dec 2023 10:30:26 +0000 (11:30 +0100)] 
Merge branch 'master' of https://github.com/mystuffs/util-linux

* 'master' of https://github.com/mystuffs/util-linux:
  lscpu-cputype.c: assign value to multiple variables (ar->bit32 and ar->bit64) clang with -Wcomma will emit an warning of "misuse of comma operator". Since the value that will be assigned, is the same for both (bit32 and bit64), just assigning directly to both variables seems reasonable.

5 months agoMerge branch 'lslocks-issue-2624' of https://github.com/masatake/util-linux
Karel Zak [Thu, 7 Dec 2023 10:29:29 +0000 (11:29 +0100)] 
Merge branch 'lslocks-issue-2624' of https://github.com/masatake/util-linux

* 'lslocks-issue-2624' of https://github.com/masatake/util-linux:
  tests: (lslocks) add missing ts_finalize call

5 months agoMerge branch 'usr_etc' of https://github.com/schubi2/util-linux
Karel Zak [Thu, 7 Dec 2023 10:29:13 +0000 (11:29 +0100)] 
Merge branch 'usr_etc' of https://github.com/schubi2/util-linux

* 'usr_etc' of https://github.com/schubi2/util-linux:
  using libeconf for reading blkid.conf

5 months agoMerge branch 'util-linux:master' into master
rilysh [Wed, 6 Dec 2023 16:35:04 +0000 (11:35 -0500)] 
Merge branch 'util-linux:master' into master

5 months agotests: (lslocks) add missing ts_finalize call
Masatake YAMATO [Wed, 6 Dec 2023 15:05:34 +0000 (00:05 +0900)] 
tests: (lslocks) add missing ts_finalize call

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolsfd: cleanup --list-columns
Karel Zak [Wed, 6 Dec 2023 11:37:10 +0000 (12:37 +0100)] 
lsfd: cleanup --list-columns

* remove dependence on command-line options order ("-H -J" vs. "-J -H")

References: https://github.com/util-linux/util-linux/pull/2602
Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolslocks: cleanup --list-columns
Karel Zak [Wed, 6 Dec 2023 11:26:39 +0000 (12:26 +0100)] 
lslocks: cleanup --list-columns

* remove "Available columns" from --help
* remove dependence on command-line options order ("-H -J" vs. "-J -H")
* remove global variable shadowing for 'raw' and 'json'
* keep --list-columns in "help & version block" in usage() output

References: https://github.com/util-linux/util-linux/pull/2602
Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'list-columns-options' of https://github.com/masatake/util-linux
Karel Zak [Wed, 6 Dec 2023 10:59:37 +0000 (11:59 +0100)] 
Merge branch 'list-columns-options' of https://github.com/masatake/util-linux

* 'list-columns-options' of https://github.com/masatake/util-linux:
  lslocks: add -H option printing avaiable columns
  lslocks: (refactor) add a helper function returning JSON type for a given column
  lslocks: (fix) set JSON type for COL_SIZE even when --bytes is specified
  lsfd: use helper functions in column-list-table.h
  add helper functions for implementing -H/--list-columns option

5 months agousing libeconf for reading blkid.conf
Stefan Schubert [Fri, 1 Dec 2023 17:33:12 +0000 (18:33 +0100)] 
using libeconf for reading blkid.conf

5 months agogithub: add labeler
Karel Zak [Tue, 5 Dec 2023 14:55:31 +0000 (15:55 +0100)] 
github: add labeler

For more details see https://github.com/actions/labeler

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolscpu-cputype.c: assign value to multiple variables (ar->bit32 and ar->bit64)
rilysh [Wed, 6 Dec 2023 05:21:27 +0000 (00:21 -0500)] 
lscpu-cputype.c: assign value to multiple variables (ar->bit32 and ar->bit64)
clang with -Wcomma will emit an warning of "misuse of comma operator".
Since the value that will be assigned, is the same for both (bit32 and bit64),
just assigning directly to both variables seems reasonable.

Signed-off-by: rilysh <nightquick@proton.me>
5 months agoMerge branch 'fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 12:52:03 +0000 (13:52 +0100)] 
Merge branch 'fixes' of https://github.com/t-8ch/util-linux

* 'fixes' of https://github.com/t-8ch/util-linux:
  build: use -std=c99 and -std=c++11 by default
  coverage.h: mark _exit as noreturn
  lsfd: switch to c99-conformant alignment specification
  blkdev.h: avoid some unused argument warnings
  m4: update pkg.m4
  include/c.h: implement reallocarray
  libblkid: avoid use of non-standard typeof()
  meson: bump required version to 0.60.0

5 months agoMerge branch 'rename-basename' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 10:34:11 +0000 (11:34 +0100)] 
Merge branch 'rename-basename' of https://github.com/t-8ch/util-linux

* 'rename-basename' of https://github.com/t-8ch/util-linux:
  rename: properly handle directories with trailing slash

5 months agolibblkid: improve portability
Samuel Thibault [Tue, 5 Dec 2023 10:13:04 +0000 (11:13 +0100)] 
libblkid: improve portability

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agotests: increase delay for waitpid test
Goldwyn Rodrigues [Wed, 29 Nov 2023 17:36:23 +0000 (11:36 -0600)] 
tests: increase delay for waitpid test

In some test executions on s390x, the waitpid test fails because 1
gets printed before 2.

[  557s] --- /home/abuild/rpmbuild/BUILD/util-linux-2.39.2/tests/expected/misc/waitpid-normal 2023-06-14 09:11:15.910887765 +0000
[  557s] +++ /home/abuild/rpmbuild/BUILD/util-linux-2.39.2/tests/output/misc/waitpid-normal 2023-11-27 23:30:30.406675022 +0000
[  557s] @@ -1,4 +1,4 @@
[  557s]  3
[  557s] -2
[  557s]  1
[  557s] +2
[  557s]  4

Increase the time to print 1, so the test numbers are printed in
expected order.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
5 months agoMerge branch 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work
Karel Zak [Tue, 5 Dec 2023 10:09:38 +0000 (11:09 +0100)] 
Merge branch 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work

* 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work:
  tests: make mount/special more robust
  tests: add missing file and improve options-missing test
  libmount: test utab options after helper call
  libmount: add missing utab options after helper call
  libmount: add private mnt_optstr_get_missing()

5 months agoMerge branch 'unshare-maps' of https://github.com/arachsys-prs/util-linux
Karel Zak [Tue, 5 Dec 2023 10:08:57 +0000 (11:08 +0100)] 
Merge branch 'unshare-maps' of https://github.com/arachsys-prs/util-linux

* 'unshare-maps' of https://github.com/arachsys-prs/util-linux:
  unshare: Add --map-users=all and --map-groups=all
  unshare: Set uid and gid maps directly when run as root
  unshare: Support multiple ID ranges for user and group maps

5 months agoMerge branch 'unblockable-kill' of https://github.com/arachsys-prs/util-linux
Karel Zak [Tue, 5 Dec 2023 10:08:15 +0000 (11:08 +0100)] 
Merge branch 'unblockable-kill' of https://github.com/arachsys-prs/util-linux

* 'unblockable-kill' of https://github.com/arachsys-prs/util-linux:
  unshare: don't try to reset the disposition of SIGKILL

5 months agoMerge branch 'kraj/basename' of https://github.com/kraj/util-linux
Karel Zak [Tue, 5 Dec 2023 10:06:57 +0000 (11:06 +0100)] 
Merge branch 'kraj/basename' of https://github.com/kraj/util-linux

* 'kraj/basename' of https://github.com/kraj/util-linux:
  login-utils: include libgen.h for basename API

5 months agoMerge branch 'audit-arch/alpha' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 10:01:25 +0000 (11:01 +0100)] 
Merge branch 'audit-arch/alpha' of https://github.com/t-8ch/util-linux

* 'audit-arch/alpha' of https://github.com/t-8ch/util-linux:
  audit-arch: add support for alpha

5 months agoMerge branch 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 Dec 2023 09:51:43 +0000 (10:51 +0100)] 
Merge branch 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux

* 'libblkid/wipe-all' of https://github.com/t-8ch/util-linux:
  libfdisk: use new blkid_wipe_all helper
  libblkid: introduce blkid_wipe_all

5 months agotests: make mount/special more robust
Karel Zak [Fri, 1 Dec 2023 10:45:10 +0000 (11:45 +0100)] 
tests: make mount/special more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agorename: properly handle directories with trailing slash
Thomas Weißschuh [Mon, 4 Dec 2023 23:06:59 +0000 (00:06 +0100)] 
rename: properly handle directories with trailing slash

Instead of hand-rolling a basename() function use the standard one which
provides the functionality that we want to use.

Also add a testcase.

Fixes #2569
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agounshare: don't try to reset the disposition of SIGKILL
Chris Webb [Mon, 4 Dec 2023 18:15:14 +0000 (18:15 +0000)] 
unshare: don't try to reset the disposition of SIGKILL

If the child process is killed with SIGKILL, don't attempt to reset the
disposition of SIGKILL (which can't be caught or ignored anyway) before
self-signalling. This caused a misleading 'sigprocmask unblock failed'
error instead of dying with the same SIGKILL status as the child.

Fixes: https://github.com/util-linux/util-linux/issues/2614
Signed-off-by: Chris Webb <chris@arachsys.com>
5 months agologin-utils: include libgen.h for basename API
Khem Raj [Mon, 4 Dec 2023 03:59:46 +0000 (19:59 -0800)] 
login-utils: include libgen.h for basename API

musl has removed the non-prototype declaration of basename from string.h [1] which now results in build errors with clang-17+ compiler

include libgen.h for using the posix declaration of the funciton.

Fixes

../util-linux-2.39.2/login-utils/su-common.c:847:20: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  847 |                 shell_basename = basename(shell);
      |                                  ^

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
5 months agolibmount: fix fsconfig value unescaping
Karel Zak [Fri, 1 Dec 2023 10:10:50 +0000 (11:10 +0100)] 
libmount: fix fsconfig value unescaping

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoaudit-arch: add support for alpha
Thomas Weißschuh [Fri, 1 Dec 2023 08:45:21 +0000 (09:45 +0100)] 
audit-arch: add support for alpha

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agobuild: use -std=c99 and -std=c++11 by default
Thomas Weißschuh [Thu, 30 Nov 2023 22:24:37 +0000 (23:24 +0100)] 
build: use -std=c99 and -std=c++11 by default

Relying on the compiler default is problematic:

* New constructs may be introduced accidentally that break backwards
  compatibility.
* Older compilers may default to a more restricted standard than the
  codebase is actually developed with.

Explicitly select C99 (and C++11 for the fuzzing part).

Autotools does not want to default to C99, so set it explcitly during
CI.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agocoverage.h: mark _exit as noreturn
Thomas Weißschuh [Fri, 1 Dec 2023 07:59:22 +0000 (08:59 +0100)] 
coverage.h: mark _exit as noreturn

Otherwise the compiler may complain:

././include/coverage.h: In function ‘_coverage__exit’:
././include/coverage.h:22:1: error: ‘noreturn’ function does return [-Werror]
   22 | }

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agolsfd: switch to c99-conformant alignment specification
Thomas Weißschuh [Fri, 1 Dec 2023 07:54:36 +0000 (08:54 +0100)] 
lsfd: switch to c99-conformant alignment specification

While the new standard specifier is nicer, it's not compatible with C99.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agoblkdev.h: avoid some unused argument warnings
Thomas Weißschuh [Fri, 1 Dec 2023 07:07:50 +0000 (08:07 +0100)] 
blkdev.h: avoid some unused argument warnings

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agom4: update pkg.m4
Thomas Weißschuh [Fri, 1 Dec 2023 07:07:06 +0000 (08:07 +0100)] 
m4: update pkg.m4

configure.ac uses PKG_CHECK_VAR which needs a newer version of pkg.m4.
Import the file from pkg-config 2.0.3.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agoinclude/c.h: implement reallocarray
Thomas Weißschuh [Fri, 22 Sep 2023 10:23:03 +0000 (12:23 +0200)] 
include/c.h: implement reallocarray

reallocarray() is not specified by any standard and may be missing from
older versions of glibc.

Fixes #2491
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agolibblkid: avoid use of non-standard typeof()
Thomas Weißschuh [Thu, 30 Nov 2023 22:26:27 +0000 (23:26 +0100)] 
libblkid: avoid use of non-standard typeof()

__typeof__ is also non-standard but it's obviously so and consistent
with the rest of the codebase.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agomeson: bump required version to 0.60.0
Thomas Weißschuh [Thu, 30 Nov 2023 22:23:33 +0000 (23:23 +0100)] 
meson: bump required version to 0.60.0

We already rely on 0.60.0 features:
libsmartcols/meson.build:44: WARNING: Project targets '>=0.57.0' but uses feature introduced in '0.60.0': list.<plus>. The right hand operand was not a list.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agotests: add missing file and improve options-missing test
Karel Zak [Thu, 30 Nov 2023 09:25:45 +0000 (10:25 +0100)] 
tests: add missing file and improve options-missing test

* remove optional ID= field (not on systems without statx())
* add missing tests/expected/mount/special-missing-options
* make sure utab is created
* use udevadm settle to wait for systemd

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'ci/meson-werror' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 30 Nov 2023 10:28:21 +0000 (11:28 +0100)] 
Merge branch 'ci/meson-werror' of https://github.com/t-8ch/util-linux

* 'ci/meson-werror' of https://github.com/t-8ch/util-linux:
  ci: enable -Werror for meson

5 months agolslocks: add -H option printing avaiable columns
Masatake YAMATO [Thu, 30 Nov 2023 03:30:20 +0000 (12:30 +0900)] 
lslocks: add -H option printing avaiable columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: (refactor) add a helper function returning JSON type for a given column
Masatake YAMATO [Thu, 30 Nov 2023 02:41:11 +0000 (11:41 +0900)] 
lslocks: (refactor) add a helper function returning JSON type for a given column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: (fix) set JSON type for COL_SIZE even when --bytes is specified
Masatake YAMATO [Thu, 30 Nov 2023 02:56:31 +0000 (11:56 +0900)] 
lslocks: (fix) set JSON type for COL_SIZE even when --bytes is specified

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolsfd: use helper functions in column-list-table.h
Masatake YAMATO [Fri, 24 Nov 2023 16:07:44 +0000 (01:07 +0900)] 
lsfd: use helper functions in column-list-table.h

With this change, the combination of "--json -H" works like:

  $ ./lsfd --json -H | head
  {
     "lsfd-columns": [
        {
           "holder": "AINODECLASS",
           "type": "<string>",
           "desc": "class of anonymous inode"
        },{
           "holder": "ASSOC",
           "type": "<string>",
           "desc": "association between file and process"
   ...

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agoadd helper functions for implementing -H/--list-columns option
Masatake YAMATO [Fri, 24 Nov 2023 16:07:03 +0000 (01:07 +0900)] 
add helper functions for implementing -H/--list-columns option

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agounshare: Add --map-users=all and --map-groups=all
Chris Webb [Thu, 23 Nov 2023 14:06:02 +0000 (14:06 +0000)] 
unshare: Add --map-users=all and --map-groups=all

Accept the special value 'all' for --map-users and --map-groups,
configuring a pass-through mapping of every user or group ID available
in the parent user namespace.

These are invaluable for scripting tests, for example when you want to
remap users leaving groups unchanged, remap groups leaving users unchanged,
or create a pass-through user namespace which maps the same users and
groups as its parent but has no capabilities in that parent namespace.

In the root user namespace, 'all' is equivalent to '0:0:4294967295', but
in child namespaces it may represent a fragmented mapping corresponding
to multiple --map-users or --map-groups options.

Signed-off-by: Chris Webb <chris@arachsys.com>
5 months agounshare: Set uid and gid maps directly when run as root
Chris Webb [Thu, 23 Nov 2023 13:14:58 +0000 (13:14 +0000)] 
unshare: Set uid and gid maps directly when run as root

The newuidmap and newgidmap setuid helpers provided by shadow don't allow
root to set up arbitrary mappings without explicit wildcard configuration
in /etc/subuid and /etc/subgid, and are an unnecessary dependency when
unshare is run privileged.

ID-mapped mount already knows how to create uid/gid maps directly for new
user namespaces, so teach unshare to do the same thing when run as root.
Continue to use the setuid helpers when we are not sufficiently privileged
to do the job ourselves.

Signed-off-by: Chris Webb <chris@arachsys.com>
5 months agounshare: Support multiple ID ranges for user and group maps
Chris Webb [Thu, 23 Nov 2023 12:24:58 +0000 (12:24 +0000)] 
unshare: Support multiple ID ranges for user and group maps

Accept multiple --map-users and --map-groups options to specify disjoint ID
ranges to map inside a user namespace. This was already supported by mount
--map-groups and --map-users, but paradoxically not by unshare itself.

Factor out the hole-punching logic which removes single-ID mappings set
with --map-user and --map-group from range mappings set with --map-users
and --map-groups. add_single_map_range() now performs this fixup for
every given range before prepending the single-ID mapping.

Signed-off-by: Chris Webb <chris@arachsys.com>
5 months agolibfdisk: use new blkid_wipe_all helper
Thomas Weißschuh [Wed, 29 Nov 2023 18:51:49 +0000 (19:51 +0100)] 
libfdisk: use new blkid_wipe_all helper

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agolibblkid: introduce blkid_wipe_all
Thomas Weißschuh [Wed, 29 Nov 2023 18:51:37 +0000 (19:51 +0100)] 
libblkid: introduce blkid_wipe_all

This helper makes the common task of wiping all signatures easier.

Fixes #2592
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agolibmount: test utab options after helper call
Thomas Weißschuh [Wed, 29 Nov 2023 18:15:47 +0000 (19:15 +0100)] 
libmount: test utab options after helper call

See #2607

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agolibmount: add missing utab options after helper call
Karel Zak [Wed, 29 Nov 2023 11:37:52 +0000 (12:37 +0100)] 
libmount: add missing utab options after helper call

libmount is able to add missing entry to /run/mount/utab after
external /sbin/mouht.<type> helper execution. This is not enough, it's
possible that the helper write proper entry to the utab, but there is
missing some options expected by libmount (usually because the options
are irrelevant fro the helper.

Reproducer:

 Create a stupid mount.foo which writes x-foo=123 to utab:

   # echo -e '#!/bin/bash\n\n/bin/mount -i "$1" "$2" -o x-foo=123' > /sbin/mount.foo
   # chmod +x /sbin/mount.foo

 Run mount which needs to write x-bar=BAR options to utab and executes
 the helper (due to "-t foo", /dev/sdc1 is ext4):

   # mount -t foo /dev/sdc1 /mnt/test -o x-bar=BAR

 old mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123

 fixed mount:

   # cat /run/mount/utab
   ID=121 SRC=/dev/sdc1 TARGET=/mnt/test ROOT=/ OPTS=x-foo=123,x-bar=BAR

Fixes: https://github.com/util-linux/util-linux/issues/2554
Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolibmount: add private mnt_optstr_get_missing()
Karel Zak [Wed, 29 Nov 2023 11:19:55 +0000 (12:19 +0100)] 
libmount: add private mnt_optstr_get_missing()

The function compares two options strings and returns options which
are missing.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'chsh-getusershell' of https://github.com/thkukuk/util-linux
Karel Zak [Wed, 29 Nov 2023 08:39:41 +0000 (09:39 +0100)] 
Merge branch 'chsh-getusershell' of https://github.com/thkukuk/util-linux

* 'chsh-getusershell' of https://github.com/thkukuk/util-linux:
  chsh: use libeconf to read /etc/shells

5 months agoAdd Phytium FTC310 & FTC664 support
zuoqian [Wed, 29 Nov 2023 02:57:52 +0000 (02:57 +0000)] 
Add Phytium FTC310 & FTC664 support

Signed-off-by: zuoqian <zuoqian2023@gmail.com>
5 months agochsh: use libeconf to read /etc/shells
Thorsten Kukuk [Thu, 23 Nov 2023 13:23:00 +0000 (14:23 +0100)] 
chsh: use libeconf to read /etc/shells

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
5 months agolibmount: accept '\' as escape for options separator
Karel Zak [Tue, 28 Nov 2023 13:40:48 +0000 (14:40 +0100)] 
libmount: accept '\' as escape for options separator

The libmount library can accept any characters as an option value when
the value is quoted (e.g., foo="b,a,r"). However, overlayfs users have
been using '\' as an escape character (e.g., lowerdir=foo\,bar).

Although this escaping mechanism was never officially supported by
libmount/mount, it worked for the old mount(2) API because it kept the
options string unparsed for the mount(2) syscall.

The introduction of the new mount API, which utilizes fsconfig(2) per
option, has brought attention to this issue.

This patch addresses the problem by introducing official support for
'\' as an escape character for options separator.

Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
References: https://lore.kernel.org/all/CAOQ4uxhgUSPkYAV8SJu-SFszkJcVO3-M4DXf46nJUtXODrPk2g@mail.gmail.com/T/#ma8e6cfc1ce7229abc089e03eed99b23b90d701e5
Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolosetup: report lost loop devices for finding free loop
Junxiao Bi [Tue, 7 Nov 2023 18:48:06 +0000 (10:48 -0800)] 
losetup: report lost loop devices for finding free loop

commit a6ca0456cc6d("loopdev: report lost loop devices") forgot to
report lost loop device for finding free loop case. With this path,
it will show the following if next free loop device is lost.

 # ./losetup -f
 /dev/loop1 (lost)
 # ./losetup -f /tmp/test.img
 lt-losetup: /tmp/test.img: failed to set up loop device: No such file or directory
 lt-losetup: device node /dev/loop1 (7:1) is lost. You may use mknod(1) to recover it.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
5 months agoci: enable -Werror for meson
Thomas Weißschuh [Fri, 24 Nov 2023 10:38:12 +0000 (11:38 +0100)] 
ci: enable -Werror for meson

Now that all warnings have been eliminated from the meson build, make
sure no new ones are introduced.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 months agoMerge branch 'minor-changes-about-new-filter' of https://github.com/masatake/util...
Karel Zak [Fri, 24 Nov 2023 09:21:58 +0000 (10:21 +0100)] 
Merge branch 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux

* 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux:
  lsfd: (man) document --list-columns as the way to list columns
  lsfd: (man) refer to scols-filter(5)
  libsmartcols: (man) fix typos

5 months agoMerge branch 'lslocks--co-holders' of https://github.com/masatake/util-linux
Karel Zak [Fri, 24 Nov 2023 09:21:36 +0000 (10:21 +0100)] 
Merge branch 'lslocks--co-holders' of https://github.com/masatake/util-linux

* 'lslocks--co-holders' of https://github.com/masatake/util-linux:
  tests: (lslocks) add cases testing HOLDERS column
  tests: (cosmetic,lslocks) trim whitespaces at the end of line
  tests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"
  lslocks: add HOLDERS column
  lslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinfo/$fd
  tests: (test_mkfds) initialize a proper union member
  xalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend
  lsfd: (refactor) make the code comparing struct lock objects reusable
  lslocks: add a missing "break;" in a switch/case statement
  lslocks: (preparation) add a fd number to the lock struct when loading lock info from /proc/$pid/fdinfo/$fd
  lslocks: (refactor) use a tree for storing lock information extracted from /proc/$pid/fdinfo/$fd
  lslocks: (refactor) make the data structure for storing lock information replacable

5 months agolibsmartcols: (filter) fix dereferences and leaks [coverity scann]
Karel Zak [Fri, 24 Nov 2023 09:20:54 +0000 (10:20 +0100)] 
libsmartcols: (filter) fix dereferences and leaks [coverity scann]

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agolsfd: (man) document --list-columns as the way to list columns
Masatake YAMATO [Thu, 23 Nov 2023 13:48:52 +0000 (22:48 +0900)] 
lsfd: (man) document --list-columns as the way to list columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolsfd: (man) refer to scols-filter(5)
Masatake YAMATO [Thu, 23 Nov 2023 13:41:38 +0000 (22:41 +0900)] 
lsfd: (man) refer to scols-filter(5)

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolibsmartcols: (man) fix typos
Masatake YAMATO [Thu, 23 Nov 2023 13:36:26 +0000 (22:36 +0900)] 
libsmartcols: (man) fix typos

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agotests: (lslocks) add cases testing HOLDERS column
Masatake YAMATO [Tue, 21 Nov 2023 19:37:30 +0000 (04:37 +0900)] 
tests: (lslocks) add cases testing HOLDERS column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agotests: (cosmetic,lslocks) trim whitespaces at the end of line
Masatake YAMATO [Thu, 23 Nov 2023 13:29:41 +0000 (22:29 +0900)] 
tests: (cosmetic,lslocks) trim whitespaces at the end of line

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agotests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"
Masatake YAMATO [Tue, 21 Nov 2023 19:00:50 +0000 (04:00 +0900)] 
tests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: add HOLDERS column
Masatake YAMATO [Tue, 21 Nov 2023 18:58:51 +0000 (03:58 +0900)] 
lslocks: add HOLDERS column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinf...
Masatake YAMATO [Tue, 21 Nov 2023 19:30:59 +0000 (04:30 +0900)] 
lslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agotests: (test_mkfds) initialize a proper union member
Masatake YAMATO [Tue, 21 Nov 2023 18:57:54 +0000 (03:57 +0900)] 
tests: (test_mkfds) initialize a proper union member

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agoxalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend
Masatake YAMATO [Tue, 21 Nov 2023 13:19:29 +0000 (22:19 +0900)] 
xalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolsfd: (refactor) make the code comparing struct lock objects reusable
Masatake YAMATO [Wed, 15 Nov 2023 19:03:23 +0000 (04:03 +0900)] 
lsfd: (refactor) make the code comparing struct lock objects reusable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: add a missing "break;" in a switch/case statement
Masatake YAMATO [Wed, 15 Nov 2023 10:45:53 +0000 (19:45 +0900)] 
lslocks: add a missing "break;" in a switch/case statement

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: (preparation) add a fd number to the lock struct when loading lock info...
Masatake YAMATO [Wed, 15 Nov 2023 10:41:09 +0000 (19:41 +0900)] 
lslocks: (preparation) add a fd number to the lock struct when loading lock info from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: (refactor) use a tree for storing lock information extracted from /proc...
Masatake YAMATO [Wed, 15 Nov 2023 10:35:00 +0000 (19:35 +0900)] 
lslocks: (refactor) use a tree for storing lock information extracted from /proc/$pid/fdinfo/$fd

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agolslocks: (refactor) make the data structure for storing lock information replacable
Masatake YAMATO [Wed, 15 Nov 2023 08:04:04 +0000 (17:04 +0900)] 
lslocks: (refactor) make the data structure for storing lock information replacable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
5 months agoMerge branch 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 23 Nov 2023 11:51:38 +0000 (12:51 +0100)] 
Merge branch 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work

* 'PR/libsmartcols-filter' of github.com:karelzak/util-linux-work: (88 commits)
  meson: remove scols filter sample
  tests: use array keys in more robust way
  lsblk: update after rebase
  tests: add libsmartcols filter tests
  libsmartcols: (sample) fix error message
  tests: use scols_column_set_properties() in 'fromfile' sample
  libsmartcols: improve and fix scols_column_set_properties()
  libsmartcols: (samples) remove filter.c
  libsmartcols: add filter support to 'fromfile' sample
  libsmartcols: fix filter param copying
  tests: don't keep bison messages in tests
  autotools: use stamp file to build filter parser, improve portability
  meson: use bison --defines=HEADER
  libsmartcols: fix typo in parser tokens
  libsmartcols: add scols-filter.5 man page
  libsmartcols: (filter) add upper case EQ,NE,LE,LT,GT and GE operators
  ci: packit: add flex
  meson: fix copy & past error
  libsmartcols: build filter scanner and parser header files too
  meson: add missing scols sample
  ...

5 months agoMerge branch 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux
Karel Zak [Thu, 23 Nov 2023 10:36:48 +0000 (11:36 +0100)] 
Merge branch 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux

* 'irqtop-fix-sort' of https://github.com/nbuwe/util-linux:
  irqtop: fix numeric sorting

5 months agomeson: remove scols filter sample
Karel Zak [Thu, 23 Nov 2023 10:32:37 +0000 (11:32 +0100)] 
meson: remove scols filter sample

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agotests: use array keys in more robust way
Karel Zak [Thu, 23 Nov 2023 10:08:17 +0000 (11:08 +0100)] 
tests: use array keys in more robust way

Let's use while-loop to support arbitrary key and to avoid fragile
quotes for strings .

Signed-off-by: Karel Zak <kzak@redhat.com>
5 months agoMerge branch 'unused' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 23 Nov 2023 09:41:47 +0000 (10:41 +0100)] 
Merge branch 'unused' of https://github.com/t-8ch/util-linux

* 'unused' of https://github.com/t-8ch/util-linux:
  treewide: explicitly mark unused arguments

5 months agoMerge branch 'undefined' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 23 Nov 2023 09:40:18 +0000 (10:40 +0100)] 
Merge branch 'undefined' of https://github.com/t-8ch/util-linux

* 'undefined' of https://github.com/t-8ch/util-linux:
  lsfd: avoid undefined behavior

5 months agolsblk: add hint that partition start is in sectors
Karel Zak [Wed, 22 Nov 2023 11:12:01 +0000 (12:12 +0100)] 
lsblk: add hint that partition start is in sectors

Reported-by: Dusty Mabe <dustymabe@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>