]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 weeks agoMerge branch 'PR/ipcs-fix-counters' of github.com:karelzak/util-linux-work
Karel Zak [Wed, 27 Mar 2024 10:51:04 +0000 (11:51 +0100)] 
Merge branch 'PR/ipcs-fix-counters' of github.com:karelzak/util-linux-work

* 'PR/ipcs-fix-counters' of github.com:karelzak/util-linux-work:
  lsipc: improve variable naming
  lsipc: fix semaphore USED counter

8 weeks agoMerge branch 'blkid/json' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 27 Mar 2024 10:46:01 +0000 (11:46 +0100)] 
Merge branch 'blkid/json' of https://github.com/t-8ch/util-linux

* 'blkid/json' of https://github.com/t-8ch/util-linux:
  blkid: add json output format
  blkid: (tests) test output formats
  blkid: (tests) use correct blkid binary

8 weeks agoautotools: add dependence on libsmartcols for lsclocks
Karel Zak [Tue, 26 Mar 2024 15:17:29 +0000 (16:17 +0100)] 
autotools: add dependence on libsmartcols for lsclocks

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 272c3639d7bdb5f455717d8ce7cd9638419754b6)

8 weeks agoMerge branch 'more' of https://github.com/thkukuk/util-linux
Karel Zak [Tue, 26 Mar 2024 12:11:06 +0000 (13:11 +0100)] 
Merge branch 'more' of https://github.com/thkukuk/util-linux

* 'more' of https://github.com/thkukuk/util-linux:
  more: remove second check for EOF (#2714)

8 weeks agoMerge branch 'uuidgen' of https://github.com/thkukuk/util-linux
Karel Zak [Tue, 26 Mar 2024 12:10:52 +0000 (13:10 +0100)] 
Merge branch 'uuidgen' of https://github.com/thkukuk/util-linux

* 'uuidgen' of https://github.com/thkukuk/util-linux:
  uuidgen: use xmalloc instead of malloc (#2714)

8 weeks agoMerge branch 'lscpu' of https://github.com/thkukuk/util-linux
Karel Zak [Tue, 26 Mar 2024 12:10:39 +0000 (13:10 +0100)] 
Merge branch 'lscpu' of https://github.com/thkukuk/util-linux

* 'lscpu' of https://github.com/thkukuk/util-linux:
  lscpu: initialize all variables (#2714)

8 weeks agolsipc: improve variable naming
Karel Zak [Tue, 26 Mar 2024 11:56:50 +0000 (12:56 +0100)] 
lsipc: improve variable naming

* Life is too short to use long variable names
* Reduce the possibility of making typos between "xyz" and "xyzp"

Signed-off-by: Karel Zak <kzak@redhat.com>
8 weeks agolsipc: fix semaphore USED counter
Karel Zak [Tue, 26 Mar 2024 11:45:24 +0000 (12:45 +0100)] 
lsipc: fix semaphore USED counter

The code incorrectly counts only with the first item in the linked
list (due to a typo). It seems rather fragile to use "semds" and
"semdsp" as variable names in the same code ...

 # lsipc -gs

Old:

 KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION                                LIMIT USED  USE%
                          SEMMNI   Number of semaphore identifiers            32000    3 0.01%
                          SEMMNS   Total number of semaphores            1024000000  369 0.00%
                          SEMMSL   Max semaphores per semaphore set.          32000    -     -
                          SEMOPM   Max number of operations per semop(2)        500    -     -
                          SEMVMX   Semaphore max value                        32767    -     -

Fixed:

 KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION                                LIMIT USED  USE%
                          SEMMNI   Number of semaphore identifiers            32000    3 0.01%
                          SEMMNS   Total number of semaphores            1024000000  156 0.00%
                          SEMMSL   Max semaphores per semaphore set.          32000    -     -
                          SEMOPM   Max number of operations per semop(2)        500    -     -
                          SEMVMX   Semaphore max value                        32767    -     -

Addresses: https://issues.redhat.com/browse/RHEL-30269
Signed-off-by: Karel Zak <kzak@redhat.com>
8 weeks agomore: remove second check for EOF (#2714)
Thorsten Kukuk [Tue, 26 Mar 2024 09:50:30 +0000 (10:50 +0100)] 
more: remove second check for EOF (#2714)

The second EOF check (c == EOF) will never be reached.

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
8 weeks agouuidgen: use xmalloc instead of malloc (#2714)
Thorsten Kukuk [Tue, 26 Mar 2024 08:49:22 +0000 (09:49 +0100)] 
uuidgen: use xmalloc instead of malloc (#2714)

Use xmalloc to make sure we don't reference a NULL pointer in error
case.

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
8 weeks agolscpu: initialize all variables (#2714)
Thorsten Kukuk [Tue, 26 Mar 2024 08:33:32 +0000 (09:33 +0100)] 
lscpu: initialize all variables (#2714)

cpu->bookid got initialized twice instead of drawerid

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
8 weeks agorev: Check for wchar conversion errors
Tim Hallmann [Sun, 24 Mar 2024 19:14:30 +0000 (20:14 +0100)] 
rev: Check for wchar conversion errors

Commit c9cc84621ca98ef85499e83ca56f05f12055f193 introduced a regression
where only the actual EOF is handled, not other error conditions
returning WEOF. This leads to an infinite loop upon encountering
conversion errors. For example (using LC_CTYPE="en_US.UTF-8"):

$ printf '\x80' | rev

Signed-off-by: Tim Hallmann <tim@t8w.de>
8 weeks agoMerge branch 'clang-18' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 25 Mar 2024 09:03:58 +0000 (10:03 +0100)] 
Merge branch 'clang-18' of https://github.com/t-8ch/util-linux

* 'clang-18' of https://github.com/t-8ch/util-linux:
  ci: use clang 18
  lscpu: restructure op-mode printing

2 months agosys-utils: hwclock-rtc: fix pointer usage
Karthikeyan Krishnasamy [Sat, 23 Mar 2024 08:09:55 +0000 (13:39 +0530)] 
sys-utils: hwclock-rtc: fix pointer usage

passing double pointer doesn't fill param value

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
2 months agoMerge branch 'PR/libmount-sepnodata' of github.com:karelzak/util-linux-work
Karel Zak [Fri, 22 Mar 2024 10:33:32 +0000 (11:33 +0100)] 
Merge branch 'PR/libmount-sepnodata' of github.com:karelzak/util-linux-work

* 'PR/libmount-sepnodata' of github.com:karelzak/util-linux-work:
  libmount: make sure "option=" is used as string

2 months agomeson: Only build blkzone and blkpr if the required linux header exists
Jordan Williams [Wed, 20 Mar 2024 16:41:49 +0000 (11:41 -0500)] 
meson: Only build blkzone and blkpr if the required linux header exists

Checks for the required headers for blkzone and blkptr are done for
 Autotools.
This logic wasn't carried over to Meson.
This PR just adds the same checks.

Fixes #2850.

Signed-off-by: Jordan Williams <jordan@jwillikers.com>
2 months agolibmount: make sure "option=" is used as string
Karel Zak [Wed, 20 Mar 2024 15:08:16 +0000 (16:08 +0100)] 
libmount: make sure "option=" is used as string

mount(8) cares about case when option specified as "name=" (it means
without data). See for example 727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5.

We need this also for new mount API and use FSCONFIG_SET_STRING rather
than FSCONFIG_SET_FLAG.

strace -e fsconfig ./mount -o usrjquota= /dev/sdc1 /mnt/test

Old:
fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc1", 0) = 0
fsconfig(3, FSCONFIG_SET_FLAG, "usrjquota", NULL, 0) = -1 EINVAL (Invalid argument)

Fixed:
fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc1", 0) = 0
fsconfig(3, FSCONFIG_SET_STRING, "usrjquota", "", 0) = 0

Fixes: https://github.com/util-linux/util-linux/issues/2837
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agochcpu(8): document limitations of -g
Stanislav Brabec [Mon, 18 Mar 2024 17:39:36 +0000 (18:39 +0100)] 
chcpu(8): document limitations of -g

Document that chcpu -g is not supported on IBM z/VM because the detach cpu
would CLEAR the running zVM guest memory.

References:
https://www.ibm.com/docs/en/linux-on-z?topic=mc-changing-state-1
https://www.ibm.com/docs/en/zvm/7.3?topic=commands-detach-cpu

Reported-by: Heikki Ylipiessa <heikki.ylipiessa@suse.com>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2 months agolib/sha1: fix for old glibc
Karel Zak [Wed, 20 Mar 2024 14:03:05 +0000 (15:03 +0100)] 
lib/sha1: fix for old glibc

Fixes: https://github.com/util-linux/util-linux/issues/2830
References: http://github.com/util-linux/util-linux/commit/a8902e4cdd6149e5124383b25db8688dcdacd790
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agolscpu: don't use NULL sharedmap
Karel Zak [Wed, 20 Mar 2024 13:42:28 +0000 (14:42 +0100)] 
lscpu: don't use NULL sharedmap

Fixes: https://github.com/util-linux/util-linux/issues/2846
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoci: reduce aslr level to avoid issues with ASAN
Thomas Weißschuh [Tue, 19 Mar 2024 21:21:54 +0000 (22:21 +0100)] 
ci: reduce aslr level to avoid issues with ASAN

As we have multiple different configurations using ASAN just disable it
for all of them.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agolast: avoid out of bounds array access
biubiuzy [Fri, 23 Feb 2024 09:44:12 +0000 (17:44 +0800)] 
last: avoid out of bounds array access

2 months agofindmnt: remove deleted option from manual
Chris Hofstaedtler [Fri, 15 Mar 2024 16:54:17 +0000 (17:54 +0100)] 
findmnt: remove deleted option from manual

Bug-Debian: 1066843
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reported-by: Francesco Potortì <Potorti@isti.cnr.it>
2 months agolib/pty-session: Don't ignore SIGHUP.
Kuniyuki Iwashima [Mon, 11 Mar 2024 18:12:02 +0000 (18:12 +0000)] 
lib/pty-session: Don't ignore SIGHUP.

The blamed commit converted script to use the generic pty code that
was added by commit 6954895cae34 ("lib/pty-session: add generic PTY
container code").

Commit ec10634e7ec4 says the new pty stuff is based on script.
However, there is difference in signal handling.

Before the commit, only the signals that the script was interested
in were blocked and handled by signalfd.

After the commit, all signals are blocked and only the interested
signals are handled.

This causes regression in the following scenario:

  1. run `script` via /etc/profile.d for ssh session
  2. login to a ssh session using bash
  3. run `sudo -i`
  4. wait until ssh session timeout

After 3., the process tree will be like this.

  $ pstree -p | grep script
  |-sshd(2652)-sshd(637993)---sshd(637996)---bash(637997)---script(638028)---bash(638029)---sudo(638057)---sudo(638059)-+

The notable thing here is that script is in the parent's process
group (637997).

  $ ps -eo pid,pgid,ppid,stat,sig,comm | grep script
  638028  637997  637997 S+   0000000000000000 script

Thus, the parent bash will send SIGHUP to script, when the timeout
occurs at 4.

  $ sudo /usr/share/bcc/tools/killsnoop
  TIME      PID      COMM             SIG  TPID     RESULT
  18:46:57  637997   bash             1    637997   0

  $ ps -eo pid,pgid,ppid,stat,sig,comm | grep script
  638028  637997       1 S    0000000000020001 script

However, this is not handled, so the script is reaped but remains
forever.

  $ pstree -p | grep script
  |-script(638028)---bash(638029)

To avoid such a situation, we need to handle SIGHUP in script.

With this patch, script will receive SIGHUP from the parrent and
kill its child processes.

  $ pstree -p | grep script
  |-sshd(2652)-sshd(638400)---sshd(638404)---bash(638405)---script(638436)---bash(638437)---sudo(638465)---sudo(638467)-+

  $ sudo /usr/share/bcc/tools/killsnoop
  TIME      PID      COMM             SIG  TPID     RESULT
  18:50:11  638405   bash             1    638405   0
  18:50:11  638436   script           15   638437   0
  18:50:11  638436   script           15   638437   0
  18:50:13  638436   script           9    638437   0

Fixes: ec10634e7ec4 ("script: use lib/pty-session")
Reported-by: Ayame Suzuki <ayameszk@amazon.co.jp>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
2 months agodmesg: print object closing brace while waiting for next message
Thomas Weißschuh [Sun, 10 Mar 2024 09:43:20 +0000 (10:43 +0100)] 
dmesg: print object closing brace while waiting for next message

Allow incremental parsers to process the full object as it is written by
dmesg.

Closes #2833

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agojsonwrt: add ul_jsonwrt_flush
Thomas Weißschuh [Sun, 10 Mar 2024 06:17:25 +0000 (07:17 +0100)] 
jsonwrt: add ul_jsonwrt_flush

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agoci: use clang 18
Thomas Weißschuh [Tue, 19 Mar 2024 21:25:29 +0000 (22:25 +0100)] 
ci: use clang 18

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agolscpu: restructure op-mode printing
Thomas Weißschuh [Tue, 19 Mar 2024 21:49:31 +0000 (22:49 +0100)] 
lscpu: restructure op-mode printing

The existing logic can confuse ASAN.
Restructure it so it is shorter and easer to understand for humans.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agolibmount: Fix export of mnt_context_is_lazy and mnt_context_is_onlyonce
Matt Turner [Tue, 19 Mar 2024 01:29:13 +0000 (21:29 -0400)] 
libmount: Fix export of mnt_context_is_lazy and mnt_context_is_onlyonce

[kzak@redhat.com: - fix also function docs]

Bug: https://bugs.gentoo.org/927258
Closes: https://github.com/util-linux/util-linux/issues/2844
Fixes: 3d1c41c8c ("libmount: add --onlyonce")
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoblkid: add json output format
Thomas Weißschuh [Wed, 6 Mar 2024 16:36:52 +0000 (17:36 +0100)] 
blkid: add json output format

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2 months agoblkid: (tests) test output formats
Thomas Weißschuh [Wed, 6 Mar 2024 16:36:47 +0000 (17:36 +0100)] 
blkid: (tests) test output formats

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2 months agoblkid: (tests) use correct blkid binary
Thomas Weißschuh [Wed, 6 Mar 2024 16:36:41 +0000 (17:36 +0100)] 
blkid: (tests) use correct blkid binary

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
2 months agoMerge branch 'blockdev' of https://github.com/EvgeniyRogov/util-linux
Karel Zak [Tue, 5 Mar 2024 09:14:08 +0000 (10:14 +0100)] 
Merge branch 'blockdev' of https://github.com/EvgeniyRogov/util-linux

* 'blockdev' of https://github.com/EvgeniyRogov/util-linux:
  - Fixed report error code in blockdev. - Minor: Added a period at the end of "--rereadpt" description.

2 months agosu: fix use after free in run_shell
Tanish Yadav [Mon, 4 Mar 2024 19:21:41 +0000 (00:51 +0530)] 
su: fix use after free in run_shell

Do not free tmp for non login branch as basename may return a pointer to
some part of it.

[kzak@redhat.com: - improve coding style of the function]

Signed-off-by: Tanish Yadav <devtany@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months ago- Fixed report error code in blockdev.
EvgeniyRogov [Fri, 1 Mar 2024 11:13:11 +0000 (14:13 +0300)] 
- Fixed report error code in blockdev.
- Minor: Added a period at the end of "--rereadpt" description.

2 months agosu, agetty: don't use program_invocation_short_name for openlog()
Karel Zak [Mon, 4 Mar 2024 12:30:10 +0000 (13:30 +0100)] 
su, agetty: don't use program_invocation_short_name for openlog()

Make sure the program name is hardcoded when write to the log.

Reported-by: "Serge E. Hallyn" <serge@hallyn.com>
Reported-by: "Skyler Ferrante (RIT Student)" <sjf5462@rit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoMerge branch 'spelling' of https://github.com/jwilk-forks/util-linux
Karel Zak [Mon, 4 Mar 2024 11:53:42 +0000 (12:53 +0100)] 
Merge branch 'spelling' of https://github.com/jwilk-forks/util-linux

* 'spelling' of https://github.com/jwilk-forks/util-linux:
  docs: fix typos

2 months agoMerge branch 'lsfd--github-issue-2819' of https://github.com/masatake/util-linux
Karel Zak [Mon, 4 Mar 2024 11:38:35 +0000 (12:38 +0100)] 
Merge branch 'lsfd--github-issue-2819' of https://github.com/masatake/util-linux

* 'lsfd--github-issue-2819' of https://github.com/masatake/util-linux:
  tests: (lsfd::mkfds-inotify) consider environments not having / as a mount point

2 months agobuild-sys: make sure everywhere is localstatedir
Karel Zak [Mon, 4 Mar 2024 11:35:09 +0000 (12:35 +0100)] 
build-sys: make sure everywhere is localstatedir

_PATH_LOCALSTATEDIR and @localstatedir@ are defined by build-systems
and it's necessary to use it everywhere to keep things consistent.

Reference: https://github.com/util-linux/util-linux/pull/2825
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agotests: (lsfd::mkfds-inotify) consider environments not having / as a mount point
Masatake YAMATO [Sat, 2 Mar 2024 21:51:15 +0000 (06:51 +0900)] 
tests: (lsfd::mkfds-inotify) consider environments not having / as a mount point

Close #2819.

In the original test case, test_mkfds monitored / and /etc/fstab.

As reported in #2819, if a test platform doesn't have / as a
mount point, the test case doesn't work.

So we use /proc and /proc/cmdnline instead.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Acked-by: Chris Hofstaedtler <zeha@debian.org>
2 months agodocs: fix typos
Jakub Wilk [Fri, 1 Mar 2024 09:33:46 +0000 (10:33 +0100)] 
docs: fix typos

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2 months agodocs: add note about stable branches
Karel Zak [Thu, 29 Feb 2024 22:00:10 +0000 (23:00 +0100)] 
docs: add note about stable branches

Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agolslocks: fix buffer overflow
Karel Zak [Thu, 29 Feb 2024 19:43:35 +0000 (20:43 +0100)] 
lslocks: fix buffer overflow

* don't use memset() to init variables
* use xreaddir() to reduce code
* use ssize_t for readlinkat() return value to avoid buffer overflow

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit f030775ffeaa8627c88434f7d0cba1a454aa0ffa)

2 months agosetterm: Document behavior of redirection
Stanislav Brabec [Wed, 28 Feb 2024 14:06:14 +0000 (15:06 +0100)] 
setterm: Document behavior of redirection

Debugging an error of setterm, I realized that setterm --powerdown operates
on stdout but setterm --powersave operates on stdin. Such unexpected
behavior should be documented.

I prefer a less accurate generic "always redirect both stdin and stdout"
over recommending of the correct I/O stream for each option separately.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2 months agomeson: fix LIBBLKID_VERSION definition
Karel Zak [Thu, 29 Feb 2024 10:09:11 +0000 (11:09 +0100)] 
meson: fix LIBBLKID_VERSION definition

Fixes: https://github.com/util-linux/util-linux/issues/2802
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoMerge branch 'lsfd--btrfs' of https://github.com/masatake/util-linux
Karel Zak [Thu, 29 Feb 2024 08:50:59 +0000 (09:50 +0100)] 
Merge branch 'lsfd--btrfs' of https://github.com/masatake/util-linux

* 'lsfd--btrfs' of https://github.com/masatake/util-linux:
  tests: (lsfd::mkfds-inotify-btrfs) test INOTIFY.INODES cooked output
  lsfd: extend nodev table to decode "btrfs" on SOURCE column
  lsfd: (refactor) rename a member of struct proc
  lsfd: (refactor) rename a local variable and a parameter
  lsfd: (refactor) split the function processing mountinfo file
  lsfd: (refactor) store a mnt_namespace object to struct process
  lsfd: (refactor) use a binary tree as the implementation for mnt_namespaces
  lsfd: read /proc/$pid/ns/mnt earlier
  lsfd: (refactor) rename add_nodevs to read_mountinfo
  lsfd: make the way to read /proc/$pid/mountinfo robust
  lsfd: (cosmetic) normalize whitespaces

2 months agobuild-sys: introduce localstatedir
Karel Zak [Wed, 28 Feb 2024 12:07:39 +0000 (13:07 +0100)] 
build-sys: introduce localstatedir

The directory is already used by ./configure.ac, but it has never been
exported to the Makefile.am or used by meson.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Christian Hesse <mail@eworm.de>
2 months agolastlog2: rename tmpfiles
Christian Hesse [Tue, 27 Feb 2024 21:36:13 +0000 (22:36 +0100)] 
lastlog2: rename tmpfiles

Signed-off-by: Christian Hesse <mail@eworm.de>
2 months agotmpfiles: depend on systemd...
Christian Hesse [Thu, 22 Feb 2024 07:50:52 +0000 (08:50 +0100)] 
tmpfiles: depend on systemd...

... as systemd-tmpfiles is required to handle this.

Signed-off-by: Christian Hesse <mail@eworm.de>
2 months agouuidd.rc: create localstatedir in init script
Christian Hesse [Tue, 27 Feb 2024 12:07:30 +0000 (13:07 +0100)] 
uuidd.rc: create localstatedir in init script

Signed-off-by: Christian Hesse <mail@eworm.de>
2 months agotmpfiles: add and install for uuidd, generate /run/uuidd & /var/lib/libuuid
Christian Hesse [Thu, 22 Feb 2024 07:48:55 +0000 (08:48 +0100)] 
tmpfiles: add and install for uuidd, generate /run/uuidd & /var/lib/libuuid

These directories are requird for uuidd, so let systemd-tmpfiles create them.

Signed-off-by: Christian Hesse <mail@eworm.de>
2 months agodocs: move GPL-2.0 license text to Docimentation directory
Karel Zak [Wed, 28 Feb 2024 13:37:25 +0000 (14:37 +0100)] 
docs: move GPL-2.0 license text to Docimentation directory

Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agodocs: use proper XSPD identifier for GPL-2.0
Karel Zak [Wed, 28 Feb 2024 12:22:51 +0000 (13:22 +0100)] 
docs: use proper XSPD identifier for GPL-2.0

Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoMerge branch 'PR/hexdump-overflow' of github.com:karelzak/util-linux-work
Karel Zak [Wed, 28 Feb 2024 11:16:25 +0000 (12:16 +0100)] 
Merge branch 'PR/hexdump-overflow' of github.com:karelzak/util-linux-work

* 'PR/hexdump-overflow' of github.com:karelzak/util-linux-work:
  hexdump: check blocksize when display data

2 months agoMerge branch 'enosys/dump' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 28 Feb 2024 10:49:51 +0000 (11:49 +0100)] 
Merge branch 'enosys/dump' of https://github.com/t-8ch/util-linux

* 'enosys/dump' of https://github.com/t-8ch/util-linux:
  enosys: allow dumping to file
  codeql: don't report world-writable files

2 months agoMerge branch 'PR/libmount-errmsg' of github.com:karelzak/util-linux-work
Karel Zak [Wed, 28 Feb 2024 10:49:37 +0000 (11:49 +0100)] 
Merge branch 'PR/libmount-errmsg' of github.com:karelzak/util-linux-work

* 'PR/libmount-errmsg' of github.com:karelzak/util-linux-work:
  libmount: report kernel message from new API

2 months agoenosys: allow dumping to file
Thomas Weißschuh [Thu, 22 Feb 2024 21:54:41 +0000 (22:54 +0100)] 
enosys: allow dumping to file

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agocodeql: don't report world-writable files
Thomas Weißschuh [Tue, 27 Feb 2024 19:54:33 +0000 (20:54 +0100)] 
codeql: don't report world-writable files

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agohexdump: check blocksize when display data
Karel Zak [Tue, 27 Feb 2024 17:38:02 +0000 (18:38 +0100)] 
hexdump: check blocksize when display data

hexdump(1) stores input to buffer and apply format unit when prints
the output. The unit can move pointer which points to the buffer, but
code does not check for limits.

Fixes: https://github.com/util-linux/util-linux/issues/2806
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoMerge branch 'PR/dmesg-2807' of github.com:karelzak/util-linux-work
Karel Zak [Tue, 27 Feb 2024 15:10:22 +0000 (16:10 +0100)] 
Merge branch 'PR/dmesg-2807' of github.com:karelzak/util-linux-work

* 'PR/dmesg-2807' of github.com:karelzak/util-linux-work:
  dmesg: fix wrong size calculation

2 months agolibmount: report kernel message from new API
Karel Zak [Mon, 26 Feb 2024 11:44:10 +0000 (12:44 +0100)] 
libmount: report kernel message from new API

This is a very minimalistic implementation for v2.40 designed to print
error messages from the kernel. It exclusively displays errors, and
the patch does not introduce any new library interface for this
purpose. Instead, it simply replaces hardcoded messages within
libmount with kernel messages.

It's worth noting that the final implementation will necessitate
per-hook error handling in libmount and likely a new library API to
access other types of messages (warnings, notices, etc.).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoMerge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux
Karel Zak [Tue, 27 Feb 2024 13:28:48 +0000 (14:28 +0100)] 
Merge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux

* 'patch-1' of https://github.com/ThomasKaiser/util-linux:
  Adding Neoverse-V3/-N3 ARM cores

2 months agomeson: avoid future-deprecated feature
Thomas Weißschuh [Mon, 26 Feb 2024 19:01:45 +0000 (20:01 +0100)] 
meson: avoid future-deprecated feature

Avoid the following message from meson:

  NOTICE: Future-deprecated features used:
   * 1.1.0: {'"boolean option" keyword argument "value" of type str'}

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 months agodmesg: fix wrong size calculation
Karel Zak [Mon, 26 Feb 2024 13:30:55 +0000 (14:30 +0100)] 
dmesg: fix wrong size calculation

* don't use string based function strspn() if work with non-zero terminated
  buffer

* make sure that message size is calculated from within buffer pointers

Fixes: https://github.com/util-linux/util-linux/issues/2807
Signed-off-by: Karel Zak <kzak@redhat.com>
2 months agoAdding Neoverse-V3/-N3 ARM cores
Thomas Kaiser [Mon, 26 Feb 2024 11:20:11 +0000 (12:20 +0100)] 
Adding Neoverse-V3/-N3 ARM cores

2 months agoMerge branch 'meson/gnu-source' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 26 Feb 2024 08:51:54 +0000 (09:51 +0100)] 
Merge branch 'meson/gnu-source' of https://github.com/t-8ch/util-linux

* 'meson/gnu-source' of https://github.com/t-8ch/util-linux:
  meson: run compiler checks with -D_GNU_SOURCE when necessary

2 months agolibmount: don't hold write fd to mounted device
Jan Kara [Wed, 21 Feb 2024 17:30:50 +0000 (18:30 +0100)] 
libmount: don't hold write fd to mounted device

Avoid holding writeable fd to a loop device that is being mounted. In
the hardened configurations (CONFIG_BLK_DEV_WRITE_MOUNTED = n) the
kernel wants to make sure nobody else has the block device writeably
open when mounting so this makes the mount fail.

Reported-by: JunChao Sun <sunjunchao2870@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Christian Brauner <brauner@kernel.org>
2 months agotests: (lsfd::mkfds-inotify-btrfs) test INOTIFY.INODES cooked output
Masatake YAMATO [Sat, 24 Feb 2024 17:46:37 +0000 (02:46 +0900)] 
tests: (lsfd::mkfds-inotify-btrfs) test INOTIFY.INODES cooked output

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: extend nodev table to decode "btrfs" on SOURCE column
Masatake YAMATO [Fri, 5 Jan 2024 05:31:46 +0000 (14:31 +0900)] 
lsfd: extend nodev table to decode "btrfs" on SOURCE column

When filling SOURCE column, lsfd decodes the name of the device where the
file object is. If the file object is sourced from a file system, lsfd
fills the column with the file system's name.

As #2349 and #2308, if the file system is btrfs, lsfd couldn't decode
the name correctly. This change and its preceding changes fix this bug.

"devnum offset" causes the trouble.  On btrfs, the device number
reported by stat syscall and proc fs are different.
For the details of "devnum offset", see "Mechanism behind the
devnum offset". About the way to fix it, see "How to adjust the output of lsfd".

Without this change:

    $ ./lsfd -Q '(ASSOC == "exe")' -p $$
    COMMAND   PID   USER ASSOC  XMODE TYPE SOURCE MNTID  INODE NAME
    zsh     19318 yamato   exe ------  REG   0:38     0 589767 /usr/bin/zsh

With this change:

    $ ./lsfd -Q '(ASSOC == "exe")' -p $$
    COMMAND   PID   USER ASSOC  XMODE TYPE SOURCE MNTID  INODE NAME
    zsh     19318 yamato   exe ------  REG  btrfs     0 589767 /usr/bin/zsh

Mechanisum behind the devnum offset
-----------------------------------
Both stat command and the inotify field in fdinfo refer to an inode.

filename_lookup(https://elixir.bootlin.com/linux/v6.2.9/source/fs/namei.c#L2495)
is the function getting the inode for a given file
name. filename_lookup returns a struct path.  Via path->detnry->inode,
the caller of filename_lookup can get the inode.

stat command calls statx system call. statx calls filename_lookup
eventually.

inotify_add_watch system call takes a file name. The inotify_add_watch
calls the filename_lookup eventually for getting the inode for the
file name.  The inode number that inotify_add_watch gets via
filename_lookup is printed in the inotify field in fdinfo.

The device number, the subject of this issue, can be obtained via
path->detnry->inode->i_sb->s_dev. Both the stat command and the
inotify field in fdinfo use the filename_lookup for getting path. If
they use the same function, why don't the device numbers match? I
monitored the device numbers obtained via
path->detnry->inode->i_sb->s_dev by inserting a systemtap probe to
filename_lookup. I saw the numbers matched.

However, the number monitored via systemtap did not match the number
printed by the stat command.  statx system call doesn't use
path->detnry->inode->i_sb->s_dev , the value obtained via
filename_lookup, directly.  statx calls vfs_statx. vfs_statx calls
vfs_getattr after calling the filename_lookup for filling struct
kstat. vfs_getattr calls inode->i_op->getattr, a file system specific
method for filling struct kstat if it is available.  btrfs has an
implementation for the method,
btrfs_getattr(https://elixir.bootlin.com/linux/v6.2.9/source/fs/btrfs/inode.c#L9007):

    stat->dev = BTRFS_I(inode)->root->anon_dev;

The dev member is overwritten with btrfs specific value.

How to adjust the output of lsfd
--------------------------------
lsfd already reads mountinfo files.

1. Get the "rawnum" and mount point

   The device numbers in a mountinfo file are raw; btrfs is not
   considered. Let's call the number "rawnum" here. When reading the
   mountinfo file, lsfd can know the mount points of btrfs.

       grep btrfs /proc/self/mountinfo
       72 1 0:35 /root / rw,relatime shared:1 - btrfs

2. Get the cooked num

   By calling "stat" system call for the mount point getting in the
   step 1, lsdf can know the device number the btrfs customizes with
   its getattr method. Let's call the device number "cookednum".

3. Make a table mapping "rawnum" to "cookednum".

4. Look up the table when printing inodes.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) rename a member of struct proc
Masatake YAMATO [Fri, 5 Jan 2024 01:27:42 +0000 (10:27 +0900)] 
lsfd: (refactor) rename a member of struct proc

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) rename a local variable and a parameter
Masatake YAMATO [Fri, 5 Jan 2024 01:26:35 +0000 (10:26 +0900)] 
lsfd: (refactor) rename a local variable and a parameter

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) split the function processing mountinfo file
Masatake YAMATO [Thu, 4 Jan 2024 07:02:03 +0000 (16:02 +0900)] 
lsfd: (refactor) split the function processing mountinfo file

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) store a mnt_namespace object to struct process
Masatake YAMATO [Thu, 4 Jan 2024 22:59:04 +0000 (07:59 +0900)] 
lsfd: (refactor) store a mnt_namespace object to struct process

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) use a binary tree as the implementation for mnt_namespaces
Masatake YAMATO [Thu, 4 Jan 2024 22:35:58 +0000 (07:35 +0900)] 
lsfd: (refactor) use a binary tree as the implementation for mnt_namespaces

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: read /proc/$pid/ns/mnt earlier
Masatake YAMATO [Wed, 3 Jan 2024 07:33:19 +0000 (16:33 +0900)] 
lsfd: read /proc/$pid/ns/mnt earlier

The change fba9898fd5b1d20a2ed350b7b542d9f8a3597a0c I introduced
unexpectedly canceled the optimization technique introduced in
a7f70ce17a925f1085bfa4b292427f8741d7e2a2 that reduced the number of
times reading /proc/$pid/mountinfo.

This change reenables the technique.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (refactor) rename add_nodevs to read_mountinfo
Masatake YAMATO [Wed, 3 Jan 2024 06:54:03 +0000 (15:54 +0900)] 
lsfd: (refactor) rename add_nodevs to read_mountinfo

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: make the way to read /proc/$pid/mountinfo robust
Masatake YAMATO [Wed, 3 Jan 2024 17:19:28 +0000 (02:19 +0900)] 
lsfd: make the way to read /proc/$pid/mountinfo robust

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 months agolsfd: (cosmetic) normalize whitespaces
Masatake YAMATO [Wed, 3 Jan 2024 19:57:25 +0000 (04:57 +0900)] 
lsfd: (cosmetic) normalize whitespaces

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 months agomeson: run compiler checks with -D_GNU_SOURCE when necessary
Thomas Weißschuh [Fri, 23 Feb 2024 07:15:32 +0000 (08:15 +0100)] 
meson: run compiler checks with -D_GNU_SOURCE when necessary

Through the addition of default_options: c_std=c99 some build-time
checks were incorrect. Explicitly add -D_GNU_SOURCE where necessary.

Fixes: 6240e4458cdf ("build: use -std=c99 and -std=c++11 by default")
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 months agoMerge branch 'lastlog2_error' of https://github.com/schubi2/util-linux
Karel Zak [Thu, 22 Feb 2024 09:44:41 +0000 (10:44 +0100)] 
Merge branch 'lastlog2_error' of https://github.com/schubi2/util-linux

* 'lastlog2_error' of https://github.com/schubi2/util-linux:
  liblastlog2: Improved sqlite3 error handling

3 months agoMerge branch 'PR/more-poll' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 22 Feb 2024 09:39:03 +0000 (10:39 +0100)] 
Merge branch 'PR/more-poll' of github.com:karelzak/util-linux-work

* 'PR/more-poll' of github.com:karelzak/util-linux-work:
  more: fix poll() use

3 months agoMerge branch 'PR/lastlog2-cleanup' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 22 Feb 2024 09:38:25 +0000 (10:38 +0100)] 
Merge branch 'PR/lastlog2-cleanup' of github.com:karelzak/util-linux-work

* 'PR/lastlog2-cleanup' of github.com:karelzak/util-linux-work:
  lastlog2: convert check_user() to boolean-like macro
  lastlog: cleanup function definitions
  lastlog2: make longopts[] static-const
  lastlog: improve errors printing
  lastlog2: improve coding style

3 months agoenosys: add support for alternative error codes
Thomas Weißschuh [Sun, 4 Feb 2024 10:56:58 +0000 (11:56 +0100)] 
enosys: add support for alternative error codes

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 months agoenosys: generalize named number parsing
Thomas Weißschuh [Sun, 4 Feb 2024 10:36:54 +0000 (11:36 +0100)] 
enosys: generalize named number parsing

[kzak@redhat.com: - resolve merge conflict in main()]

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 months agoautotools: make errnos.h available without lsfd
Thomas Weißschuh [Sat, 17 Feb 2024 09:03:22 +0000 (10:03 +0100)] 
autotools: make errnos.h available without lsfd

enosys will use it.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 months agoMerge branch 'enosys/dump' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 22 Feb 2024 09:26:15 +0000 (10:26 +0100)] 
Merge branch 'enosys/dump' of https://github.com/t-8ch/util-linux

* 'enosys/dump' of https://github.com/t-8ch/util-linux:
  setpriv: (tests) add seccomp test
  setpriv: add support for seccomp filters
  enosys: add functionality to dump filter
  include: introduce seccomp.h

3 months agoliblastlog2: Improved sqlite3 error handling
Stefan Schubert [Wed, 21 Feb 2024 12:09:52 +0000 (13:09 +0100)] 
liblastlog2: Improved sqlite3 error handling

3 months agodocs: cleanup public domain license texts
Karel Zak [Wed, 21 Feb 2024 09:13:50 +0000 (10:13 +0100)] 
docs: cleanup public domain license texts

The absence of an official 'Public domain' definition is the reason
why, for example, the Fedora distribution aggregates all variants from
various projects to make them reviewable.

This commit unifies the 'Public domain' statements to make it simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agomore: fix poll() use
Karel Zak [Tue, 20 Feb 2024 11:26:33 +0000 (12:26 +0100)] 
more: fix poll() use

The more(1) command utilizes signalfd() to monitor signals and reads
commands from the user via stderr (as stdin is typically used for
piping and not for user interaction).

However, the current more_poll() implementation ignores stderr. As a result,
more(1) waits on read(stderr) while completely ignoring signals. This issue
becomes evident when using commands like:

    grep foo /path/file | more

In such cases, it's only possible to exit 'more' by pressing 'q';
CTRL+C does not work.

Changes:

- Refactor more_poll() code:
  - Introduce an enum to access pfd[] items instead of using magical constants.
  - Implement a while() loop to handle EAGAIN or POLLHUP.

- Ignore stdin after POLLHUP (indicating that the pipe's peer closed).
- Ensure stderr is also checked.
- Use return codes akin to classic poll().

Note: I have doubts regarding the usability of stdin in more_poll(),
as the function is primarily used to wait for user input (via stderr)
and to monitor signals. Nevertheless, it is retained for potential use
in detecting when the pipe's peer (or the entire session) has been
terminated (see commit 68e14d3d5f4116ad3aca0e392d008645ea90cf70).

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog2: convert check_user() to boolean-like macro
Karel Zak [Tue, 20 Feb 2024 09:37:02 +0000 (10:37 +0100)] 
lastlog2: convert check_user() to boolean-like macro

Let's make simple and stupid.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog: cleanup function definitions
Karel Zak [Tue, 20 Feb 2024 09:28:06 +0000 (10:28 +0100)] 
lastlog: cleanup function definitions

- let's make it more compatible with the rest of util-linux

- don't initialize global static variables (it's unnecessary)

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog2: make longopts[] static-const
Karel Zak [Tue, 20 Feb 2024 09:20:10 +0000 (10:20 +0100)] 
lastlog2: make longopts[] static-const

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog: improve errors printing
Karel Zak [Tue, 20 Feb 2024 09:12:19 +0000 (10:12 +0100)] 
lastlog: improve errors printing

- single exit by goto

- always print specific error (e.g. "Couldn't update login time ...")
  and then optionally generic ll2 error

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog2: improve coding style
Karel Zak [Tue, 20 Feb 2024 08:55:48 +0000 (09:55 +0100)] 
lastlog2: improve coding style

- use space around operators
- remove unnecessary line breaks from errx() calls

Signed-off-by: Karel Zak <kzak@redhat.com>
3 months agolastlog2: Don't print space if Service column is not printed
Miika Alikirri [Mon, 19 Feb 2024 10:09:13 +0000 (12:09 +0200)] 
lastlog2: Don't print space if Service column is not printed

3 months agoMerge branch 'foo' of https://github.com/emanuele6/util-linux
Karel Zak [Mon, 19 Feb 2024 09:22:11 +0000 (10:22 +0100)] 
Merge branch 'foo' of https://github.com/emanuele6/util-linux

* 'foo' of https://github.com/emanuele6/util-linux:
  docs: remove duplicated author name in namei.1.adoc

3 months agoMerge branch 'patch-2' of https://github.com/ThomasKaiser/util-linux
Karel Zak [Mon, 19 Feb 2024 09:20:42 +0000 (10:20 +0100)] 
Merge branch 'patch-2' of https://github.com/ThomasKaiser/util-linux

* 'patch-2' of https://github.com/ThomasKaiser/util-linux:
  Add Microsoft as vendor and Cobalt 100 core

3 months agoMerge branch 'meson/lslogins' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 19 Feb 2024 09:13:59 +0000 (10:13 +0100)] 
Merge branch 'meson/lslogins' of https://github.com/t-8ch/util-linux

* 'meson/lslogins' of https://github.com/t-8ch/util-linux:
  meson: fix build of lslogins with -Dbuild-liblastlog2=disabled

3 months agoMerge branch 'fix-luks-offset' of https://github.com/mbroz/util-linux
Karel Zak [Mon, 19 Feb 2024 09:13:42 +0000 (10:13 +0100)] 
Merge branch 'fix-luks-offset' of https://github.com/mbroz/util-linux

* 'fix-luks-offset' of https://github.com/mbroz/util-linux:
  libblkid: Check offset in LUKS2 header

3 months agodocs: improve howto-pull-request
Karel Zak [Mon, 19 Feb 2024 09:10:56 +0000 (10:10 +0100)] 
docs: improve howto-pull-request

* improve branch naming suggestions

* recommend GitHub, make Mailing-List optional

Signed-off-by: Karel Zak <kzak@redhat.com>