]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
20 months agolslocks: (man) document LEASE type
Masatake YAMATO [Sun, 12 Nov 2023 17:21:43 +0000 (02:21 +0900)] 
lslocks: (man) document LEASE type

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolslocks: (test) add a case
Masatake YAMATO [Sat, 11 Nov 2023 17:39:22 +0000 (02:39 +0900)] 
lslocks: (test) add a case

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agoMerge branch 'lsfd--tty' of https://github.com/masatake/util-linux
Karel Zak [Wed, 8 Nov 2023 11:35:30 +0000 (12:35 +0100)] 
Merge branch 'lsfd--tty' of https://github.com/masatake/util-linux

* 'lsfd--tty' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns of pts fds
  tests: (test_mkfds::pty) add a new factory
  lsfd: fill ENDPOINTS column for pty devices
  lsfd: add attach_xinfo and get_ipc_class methods to cdev_ops
  lsfd: add PTMX.TTY-INDEX column
  lsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices
  lsfd: make the order of calling finalize_* and initialize_* consistent

20 months agoMerge branch 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux
Karel Zak [Tue, 7 Nov 2023 10:21:07 +0000 (11:21 +0100)] 
Merge branch 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux

* 'lslocks--man-missing-fields' of https://github.com/masatake/util-linux:
  lslocks: (man) add missing fields

20 months agolslocks: (man) add missing fields
Masatake YAMATO [Mon, 6 Nov 2023 20:30:33 +0000 (05:30 +0900)] 
lslocks: (man) add missing fields

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolibmount: fix possible NULL dereference [coverity scan]
Karel Zak [Mon, 6 Nov 2023 10:40:27 +0000 (11:40 +0100)] 
libmount: fix possible NULL dereference [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agotests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns...
Masatake YAMATO [Fri, 3 Nov 2023 20:22:21 +0000 (05:22 +0900)] 
tests: (lsfd) add a case testing NAME, SOURCE, ENDPOINTS, and PTMX.TTY-INDEX columns of pts fds

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agotests: (test_mkfds::pty) add a new factory
Masatake YAMATO [Fri, 3 Nov 2023 19:38:52 +0000 (04:38 +0900)] 
tests: (test_mkfds::pty) add a new factory

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolsfd: fill ENDPOINTS column for pty devices
Masatake YAMATO [Wed, 1 Nov 2023 17:47:35 +0000 (02:47 +0900)] 
lsfd: fill ENDPOINTS column for pty devices

An example output:

  $ ./lsfd -o+ENDPOINTS -Q '(COMMAND =~ "tmux") and ((SOURCE == "ptmx") or (SOURCE =~ "pts:.*"))'
  COMMAND          PID   USER ASSOC  XMODE TYPE SOURCE MNTID INODE NAME         ENDPOINTS
  tmux: client 3717086 yamato     0 rw----  CHR  pts:9    27    12 /dev/pts/9   2143274,xfce4-terminal,34rw
  tmux: client 3717086 yamato     1 rw----  CHR  pts:9    27    12 /dev/pts/9   2143274,xfce4-terminal,34rw
  tmux: client 3717086 yamato     2 rw----  CHR  pts:9    27    12 /dev/pts/9   2143274,xfce4-terminal,34rw
  tmux: server 3717088 yamato     5 rw---m  CHR  pts:9    27    12 /dev/pts/9   2143274,xfce4-terminal,34rw
  tmux: server 3717088 yamato     8 rw---m  CHR   ptmx    24   208 tty-index=16 3717089,zsh,0rw
                                                                                3717089,zsh,1rw
                                                                                3717089,zsh,2rw
                                                                                3717089,zsh,10rw

  $ ./lsfd -o+ENDPOINTS -Q '(PID == 3717089) and (FD == 0)'
  COMMAND     PID   USER ASSOC  XMODE TYPE SOURCE MNTID INODE NAME        ENDPOINTS
  zsh     3717089 yamato     0 rw----  CHR pts:16    27    19 /dev/pts/16 3717088,tmux: server,8rw

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolsfd: add attach_xinfo and get_ipc_class methods to cdev_ops
Masatake YAMATO [Wed, 1 Nov 2023 17:42:27 +0000 (02:42 +0900)] 
lsfd: add attach_xinfo and get_ipc_class methods to cdev_ops

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolsfd: add PTMX.TTY-INDEX column
Masatake YAMATO [Wed, 1 Nov 2023 15:44:20 +0000 (00:44 +0900)] 
lsfd: add PTMX.TTY-INDEX column

tty-index field in /proc/$pid/fdinfo/$fd is the data source of
the column. The value is helpful for looking up the conterpart
of /dev/ptmx.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agolsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices
Masatake YAMATO [Wed, 1 Nov 2023 15:05:12 +0000 (00:05 +0900)] 
lsfd: utilize /proc/tty/drivers for filling SOURCE column of tty devices

The original code referenced /proc/devices using major numbers as keys to obtain
the name of the device driver corresponding to a file descriptor.

However, it turnes out that some drivers share a same major number;
there are cases that a key is not unique.

  Character devices:
    1 mem
    4 /dev/vc/0
    4 tty
    4 ttyS
    ...

About tty-related devices, /proc/tty/drivers is better information
source; both major and minor numbers can be used as keys:

  /dev/tty             /dev/tty        5       0 system:/dev/tty
  /dev/console         /dev/console    5       1 system:console
  /dev/ptmx            /dev/ptmx       5       2 system
  /dev/vc/0            /dev/vc/0       4       0 system:vtmaster
  usbserial            /dev/ttyUSB   188 0-511 serial
  dbc_serial           /dev/ttyDBC   242 0-63 serial
  serial               /dev/ttyS       4 64-95 serial
  pty_slave            /dev/pts      136 0-1048575 pty:slave
  pty_master           /dev/ptm      128 0-1048575 pty:master
  unknown              /dev/tty        4 1-63 console

This commit extracts the second column of the /proc/tty/drivers as
driver names after removing "/dev": tty, console, ptmx, ...

With the orinal code:

  # lsfd -n -p 1789 -Q '(FD == 25)'
  systemd-logind  1789 root    25  rw-  CHR /dev/vc/0:6   432    25 /dev/tty6
--------------------------------------------^^^^^^^^^^^
With this commit:

  # ./lsfd -n -p 1789 -Q '(FD == 25)'
  systemd-logind  1789 root    25  rw---- CHR tty:6 432 25 /dev/tty6
----------------------------------------------^^^^^

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
20 months agomeson: install wall executable with group 'tty'
Christian Hesse [Thu, 2 Nov 2023 10:37:33 +0000 (11:37 +0100)] 
meson: install wall executable with group 'tty'

... for proper permissions.

20 months agomeson: install write executable with group 'tty'
Christian Hesse [Tue, 31 Oct 2023 07:38:15 +0000 (08:38 +0100)] 
meson: install write executable with group 'tty'

... to fix:

write: effective gid does not match group of /dev/pts/3

20 months agoMerge branch 'PR/losetup-lost' of github.com:karelzak/util-linux-work
Karel Zak [Thu, 2 Nov 2023 10:34:39 +0000 (11:34 +0100)] 
Merge branch 'PR/losetup-lost' of github.com:karelzak/util-linux-work

* 'PR/losetup-lost' of github.com:karelzak/util-linux-work:
  loopdev: report lost loop devices

20 months agoMerge branch 'libblkid/enum' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 2 Nov 2023 10:34:20 +0000 (11:34 +0100)] 
Merge branch 'libblkid/enum' of https://github.com/t-8ch/util-linux

* 'libblkid/enum' of https://github.com/t-8ch/util-linux:
  libblkid: make enum libblkid_endianness lowercase

20 months agolibmount: improve mnt_table_next_child_fs()
Karel Zak [Thu, 2 Nov 2023 09:41:03 +0000 (10:41 +0100)] 
libmount: improve mnt_table_next_child_fs()

The function utilizes the struct libmnt_itr to iterate through the mountinfo file
but neglects the direction specified by the iterator. This a bug. The application
must manage the direction, as, for instance, umount(8) requires the children of
the mountpoint in reverse order.

Fixes: https://github.com/util-linux/util-linux/issues/2552
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agodocs: add SPDX to boilerplate.c
Karel Zak [Wed, 1 Nov 2023 13:58:57 +0000 (14:58 +0100)] 
docs: add SPDX to boilerplate.c

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agodisk-utils: add SPDX and Copyright notices
Karel Zak [Wed, 1 Nov 2023 13:47:41 +0000 (14:47 +0100)] 
disk-utils: add SPDX and Copyright notices

Explicitly state the license (usually GPL-2.0-or-later; our default)
and include copyright statements in all files to prevent false positive
reports from license analysis tools. Add also add SPDX-License-Identifier
tag to all files.

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agoinclude/audit-arch: add missing SPDX
Karel Zak [Wed, 1 Nov 2023 12:56:01 +0000 (13:56 +0100)] 
include/audit-arch: add missing SPDX

Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agosetterm: avoid restoring flags from uninitialized memory
Chris Hofstaedtler [Tue, 31 Oct 2023 13:52:26 +0000 (14:52 +0100)] 
setterm: avoid restoring flags from uninitialized memory

Depending on the used compiler and flags, previously either F_SETFL was called
with 0 or with a random value. Never with the intended previous flags.

[kzak@redhat.com: - tiny coding style change]

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Tested-by: Emanuele Rocca <ema@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
20 months agoloopdev: report lost loop devices
Junxiao Bi [Wed, 25 Oct 2023 20:36:03 +0000 (13:36 -0700)] 
loopdev: report lost loop devices

If a /dev/loopX is lost because someone might have removed it by mistake,
future losetup operations on that loop device will fail and losetup
--all and --list will not report the devices (although kernel still
uses it).

Since /sysfs still have the loop device intact, detect that and report it.

Changes:

* --list and --all add "(lost)" after device node path

  # losetup
  NAME              SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE    DIO LOG-SEC
  /dev/loop0 (lost)         0      0         0  0 /root/l0.img   0     512

  # losetup -a
  /dev/loop0 (lost): []: (/root/l0.img)

* use /sys to get devno rather than stat()

* report warning after failed operation

  # losetup -d /dev/loop0
  losetup: /dev/loop0: detach failed: No such file or directory
  losetup: device node /dev/loop0 (7:0) is lost. You may use mknod(1) to recover it.

* fix copy & past bugs in some API comments

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolsfd: make the order of calling finalize_* and initialize_* consistent
Masatake YAMATO [Tue, 31 Oct 2023 23:18:11 +0000 (08:18 +0900)] 
lsfd: make the order of calling finalize_* and initialize_* consistent

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolibblkid: make enum libblkid_endianness lowercase
Thomas Weißschuh [Tue, 31 Oct 2023 19:55:14 +0000 (20:55 +0100)] 
libblkid: make enum libblkid_endianness lowercase

As discussed in #2548

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agoMerge branch 'refine-the-choice-of-stream-related-functions-in-usage' of https:/...
Karel Zak [Wed, 25 Oct 2023 09:37:21 +0000 (11:37 +0200)] 
Merge branch 'refine-the-choice-of-stream-related-functions-in-usage' of https://github.com/masatake/util-linux

* 'refine-the-choice-of-stream-related-functions-in-usage' of https://github.com/masatake/util-linux:
  Make the ways of using output stream consistent in usage()
  Use fputs instead of fprintf if possible

21 months agoMerge branch 'umount/recursive-bind' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 25 Oct 2023 09:34:43 +0000 (11:34 +0200)] 
Merge branch 'umount/recursive-bind' of https://github.com/t-8ch/util-linux

* 'umount/recursive-bind' of https://github.com/t-8ch/util-linux:
  umount: handle bindmounts during --recursive
  mount: (tests) don't create /dev/nul

21 months agotests: fix memory leak in scols fromfile
Karel Zak [Tue, 24 Oct 2023 18:13:29 +0000 (20:13 +0200)] 
tests: fix memory leak in scols fromfile

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agoMake the ways of using output stream consistent in usage()
Masatake YAMATO [Tue, 24 Oct 2023 17:21:45 +0000 (02:21 +0900)] 
Make the ways of using output stream consistent in usage()

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agoUse fputs instead of fprintf if possible
Masatake YAMATO [Tue, 24 Oct 2023 16:41:58 +0000 (01:41 +0900)] 
Use fputs instead of fprintf if possible

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolibsmartcols: fix uninitialized local variable in sample
Karel Zak [Mon, 23 Oct 2023 13:20:47 +0000 (15:20 +0200)] 
libsmartcols: fix uninitialized local variable in sample

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add wrap-zero test
Karel Zak [Mon, 23 Oct 2023 12:47:35 +0000 (14:47 +0200)] 
libsmartcols: add wrap-zero test

* modify samples/fromfile.c to use scols_wrapzero_nextchunk() callback
  if "wrapzero" specified for the test colum
* add col-wrapzero and data-string-zero to define the column and zero
  separated data

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: support \x?? for data by samples/fromfile.c
Karel Zak [Mon, 23 Oct 2023 12:35:21 +0000 (14:35 +0200)] 
libsmartcols: support \x?? for data by samples/fromfile.c

The test (sample) binary already supports \n in strings to covert it
to the real line-break. It seem more generic to use \x?? (hex) to
support arbitrary byte in the column data.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add new functions to API docs
Karel Zak [Mon, 23 Oct 2023 11:37:51 +0000 (13:37 +0200)] 
libsmartcols: add new functions to API docs

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agofindmnt: use zero to separate lines in multi-line cells
Karel Zak [Thu, 19 Oct 2023 11:42:08 +0000 (13:42 +0200)] 
findmnt: use zero to separate lines in multi-line cells

Fixes: https://github.com/util-linux/util-linux/issues/2533
Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: improve cell data preparation for non-wrapping cases
Karel Zak [Mon, 23 Oct 2023 19:33:38 +0000 (21:33 +0200)] 
libsmartcols: improve cell data preparation for non-wrapping cases

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add --{export,raw,json} to wrap sample
Karel Zak [Thu, 19 Oct 2023 10:42:35 +0000 (12:42 +0200)] 
libsmartcols: add --{export,raw,json} to wrap sample

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: make calculation more robust
Karel Zak [Thu, 19 Oct 2023 09:23:20 +0000 (11:23 +0200)] 
libsmartcols: make calculation more robust

* add debug messages
* make columns stat debug more compact
* default to zero if data undefined
* fix "extreme" column enlarging

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: reset cell wrapping if all done
Karel Zak [Thu, 19 Oct 2023 08:48:59 +0000 (10:48 +0200)] 
libsmartcols: reset cell wrapping if all done

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolsblk: use zero to separate lines in multi-line cells
Karel Zak [Wed, 18 Oct 2023 10:29:17 +0000 (12:29 +0200)] 
lsblk: use zero to separate lines in multi-line cells

Fixes: https://github.com/util-linux/util-linux/issues/2533
Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add support for zero separated wrap data
Karel Zak [Wed, 18 Oct 2023 10:28:40 +0000 (12:28 +0200)] 
libsmartcols: add support for zero separated wrap data

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add scols_cell_refer_memory()
Karel Zak [Wed, 18 Oct 2023 08:20:12 +0000 (10:20 +0200)] 
libsmartcols: add scols_cell_refer_memory()

* allow to use non-string data
* use memcpy() rather than strdup() for data

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: always print vertical symbol
Karel Zak [Thu, 12 Oct 2023 21:15:06 +0000 (23:15 +0200)] 
libsmartcols: always print vertical symbol

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: multi-line cells refactoring
Karel Zak [Thu, 12 Oct 2023 20:38:43 +0000 (22:38 +0200)] 
libsmartcols: multi-line cells refactoring

* move data wrapping code to column.c
* do data wrapping on one place when copy cell data to buffer
* use table cursor in affected functions
* calculate tree ASCII-art to wrapped data
* mark wrap_chunksize() callback as deprecated; library calculates
  the size itself from real data

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolibsmartcols: add table cursor
Karel Zak [Thu, 12 Oct 2023 09:57:10 +0000 (11:57 +0200)] 
libsmartcols: add table cursor

The cursor makes it simple for callbacks to access information about
the current cell, line and column. It will reduce number of necessary
arguments for callbacks.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolib/mbsalign: calculate size of decoded string
Karel Zak [Thu, 12 Oct 2023 20:12:58 +0000 (22:12 +0200)] 
lib/mbsalign: calculate size of decoded string

The "safe" encoding replaces each unsafe byte with \x<hex>, the new
function mbs_safe_decoded_size() calculates the original size of the
string.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolib/buffer: make buffer usable for non-string data
Karel Zak [Tue, 10 Oct 2023 17:35:34 +0000 (19:35 +0200)] 
lib/buffer: make buffer usable for non-string data

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolib/strutils: add ul_next_string()
Karel Zak [Wed, 11 Oct 2023 10:37:40 +0000 (12:37 +0200)] 
lib/strutils: add ul_next_string()

The function jumps to the next string in buffer where strings are
separated by \0.

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agoMerge branch 'master' of https://github.com/Connor-GH/util-linux
Karel Zak [Mon, 23 Oct 2023 10:50:22 +0000 (12:50 +0200)] 
Merge branch 'master' of https://github.com/Connor-GH/util-linux

* 'master' of https://github.com/Connor-GH/util-linux:
  Fix man page for col to correct documentation error
  Update col.c to fix option mistake

21 months agoMerge branch 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:47:19 +0000 (12:47 +0200)] 
Merge branch 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux

* 'libblkid/vxfs/cleanup' of https://github.com/t-8ch/util-linux:
  libblkid: (vxfs) simplify prober
  libblkid: (superblocks) add helper blkid32_to_cpu()
  libblkid: (vxfs) use hex escape for magic
  libblkid: (vxfs) add test files

21 months agoMerge branch 'wdctl/sysfs' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:37:19 +0000 (12:37 +0200)] 
Merge branch 'wdctl/sysfs' of https://github.com/t-8ch/util-linux

* 'wdctl/sysfs' of https://github.com/t-8ch/util-linux:
  wdctl: use only sysfs if sufficient

21 months agoMerge branch 'libmount/null-api' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:35:57 +0000 (12:35 +0200)] 
Merge branch 'libmount/null-api' of https://github.com/t-8ch/util-linux

* 'libmount/null-api' of https://github.com/t-8ch/util-linux:
  libmount: guard against sysapi == NULL

21 months agoMerge branch 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work
Karel Zak [Mon, 23 Oct 2023 10:35:34 +0000 (12:35 +0200)] 
Merge branch 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work

* 'PR/lscpu-caches-sep' of github.com:karelzak/util-linux-work:
  lscpu: fix caches separator for --parse=<list>

21 months agoMerge branch 'chfn_gecos' of https://github.com/mator/util-linux
Karel Zak [Mon, 23 Oct 2023 10:34:56 +0000 (12:34 +0200)] 
Merge branch 'chfn_gecos' of https://github.com/mator/util-linux

* 'chfn_gecos' of https://github.com/mator/util-linux:
  Use empty libuser config file.

21 months agoMerge branch 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/Yuezha...
Karel Zak [Mon, 23 Oct 2023 10:32:58 +0000 (12:32 +0200)] 
Merge branch 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/YuezhangMo/util-linux

* 'topic-fix-fail-to-find-exfat-volume-label' of https://github.com/YuezhangMo/util-linux:
  libblkid: exfat: fix fail to find volume label

21 months agoMerge branch 'misc/fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:29:50 +0000 (12:29 +0200)] 
Merge branch 'misc/fixes' of https://github.com/t-8ch/util-linux

* 'misc/fixes' of https://github.com/t-8ch/util-linux:
  meson: don't try to build test_ca without libcap-ng
  blkpr: store return value of getopt_long in int

21 months agoMerge branch 'meson/int-cmp' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 23 Oct 2023 10:28:26 +0000 (12:28 +0200)] 
Merge branch 'meson/int-cmp' of https://github.com/t-8ch/util-linux

* 'meson/int-cmp' of https://github.com/t-8ch/util-linux:
  meson: avoid int operation with non-int

21 months agoMerge branch 'path' of https://github.com/stoeckmann/util-linux
Karel Zak [Mon, 23 Oct 2023 10:26:45 +0000 (12:26 +0200)] 
Merge branch 'path' of https://github.com/stoeckmann/util-linux

* 'path' of https://github.com/stoeckmann/util-linux:
  sys-utils/lscpu: Use ul_path_scanf where possible
  lib/path: Set errno in case of fgets failure
  lib/path: fix typos
  lib/path: remove ul_prefix_fopen
  lib/path: set errno in case of error
  lib/path: fix possible out of boundary access

21 months agoMerge branch 'login-simplify' of https://github.com/stoeckmann/util-linux
Karel Zak [Mon, 23 Oct 2023 10:23:51 +0000 (12:23 +0200)] 
Merge branch 'login-simplify' of https://github.com/stoeckmann/util-linux

* 'login-simplify' of https://github.com/stoeckmann/util-linux:
  login: access login.noauth file directly
  login: use xasprintf

21 months agoFix man page for col to correct documentation error
Connor-GH [Sat, 21 Oct 2023 22:58:36 +0000 (17:58 -0500)] 
Fix man page for col to correct documentation error

21 months agoUpdate col.c to fix option mistake
Connor-GH [Sat, 21 Oct 2023 22:55:49 +0000 (17:55 -0500)] 
Update col.c to fix option mistake

21 months agoumount: handle bindmounts during --recursive
Thomas Weißschuh [Tue, 17 Oct 2023 16:06:15 +0000 (18:06 +0200)] 
umount: handle bindmounts during --recursive

Fixes #2551

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agomount: (tests) don't create /dev/nul
Thomas Weißschuh [Tue, 17 Oct 2023 16:01:31 +0000 (18:01 +0200)] 
mount: (tests) don't create /dev/nul

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agowdctl: use only sysfs if sufficient
Thomas Weißschuh [Fri, 13 Oct 2023 14:44:51 +0000 (16:44 +0200)] 
wdctl: use only sysfs if sufficient

Also avoid opening device if nowayout is set.

Opening the device node starts the watchdog.
With 'nowayout' enabled unstoppably.

Also the device node can only be opened once at the same time which can
be problematic.

Prefer to retrieve the information via sysfs which does not have such
problems.

Fixes #2543

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibblkid: (vxfs) simplify prober
Thomas Weißschuh [Sat, 14 Oct 2023 10:56:42 +0000 (12:56 +0200)] 
libblkid: (vxfs) simplify prober

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibblkid: (superblocks) add helper blkid32_to_cpu()
Thomas Weißschuh [Sat, 14 Oct 2023 10:56:04 +0000 (12:56 +0200)] 
libblkid: (superblocks) add helper blkid32_to_cpu()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibblkid: (vxfs) use hex escape for magic
Thomas Weißschuh [Sat, 14 Oct 2023 10:18:14 +0000 (12:18 +0200)] 
libblkid: (vxfs) use hex escape for magic

It's easier to read and more consistent.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibblkid: (vxfs) add test files
Thomas Weißschuh [Sat, 14 Oct 2023 10:14:42 +0000 (12:14 +0200)] 
libblkid: (vxfs) add test files

The test files have been constructed manually from the prober.
While not providing a real test at least they make sure that the
existing logic stays stable.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibmount: guard against sysapi == NULL
Thomas Weißschuh [Fri, 13 Oct 2023 08:17:16 +0000 (10:17 +0200)] 
libmount: guard against sysapi == NULL

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolscpu: fix caches separator for --parse=<list>
Karel Zak [Thu, 12 Oct 2023 22:03:15 +0000 (00:03 +0200)] 
lscpu: fix caches separator for --parse=<list>

Fixes: https://github.com/util-linux/util-linux/issues/2544
Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agoUse empty libuser config file.
Anatoly Pugachev [Thu, 12 Oct 2023 11:13:02 +0000 (14:13 +0300)] 
Use empty libuser config file.

In case of an absence /etc/libuser.conf, use empty file by pointing
LIBUSER_CONF to /dev/null. This allows chfn/gecos to pass without error.

PS: The "libuser" library is no longer maintained, and it was recommended
by the original author to not use it anymore.

21 months agomeson: don't try to build test_ca without libcap-ng
Thomas Weißschuh [Wed, 11 Oct 2023 14:35:45 +0000 (16:35 +0200)] 
meson: don't try to build test_ca without libcap-ng

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibblkid: exfat: fix fail to find volume label
Yuezhang Mo [Wed, 11 Oct 2023 10:42:11 +0000 (18:42 +0800)] 
libblkid: exfat: fix fail to find volume label

Commit f98b56326 set the maximum number of iterations to 10000.
If the volume label is after the 10000th entry, the volume label
will not be found. So this commit sets the maximum number of
iterations to correct value 256×1024×1024/32.

Fixes: f98b56326 ("libblkid: [exfat] Limit maximum number of iterations in find_label")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
21 months agoblkpr: store return value of getopt_long in int
Thomas Weißschuh [Wed, 11 Oct 2023 05:20:43 +0000 (07:20 +0200)] 
blkpr: store return value of getopt_long in int

getopt_long returns an int. Don't try to store it in a char.

See #2538.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agosys-utils/lscpu: Use ul_path_scanf where possible
Tobias Stoeckmann [Tue, 10 Oct 2023 19:08:41 +0000 (21:08 +0200)] 
sys-utils/lscpu: Use ul_path_scanf where possible

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agolib/path: Set errno in case of fgets failure
Tobias Stoeckmann [Tue, 10 Oct 2023 19:00:48 +0000 (21:00 +0200)] 
lib/path: Set errno in case of fgets failure

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agologin: access login.noauth file directly
Tobias Stoeckmann [Sun, 8 Oct 2023 18:22:47 +0000 (20:22 +0200)] 
login: access login.noauth file directly

There is no need to scan a directory if we already know the filename
we are looking for.

While at it, close resources afterwards.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agologin: use xasprintf
Tobias Stoeckmann [Sun, 8 Oct 2023 18:21:04 +0000 (20:21 +0200)] 
login: use xasprintf

It is easier to use xasprintf than performing all its internals
explicitly in login's code base.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agoMerge branch 'libmount/errormsg' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 9 Oct 2023 11:04:07 +0000 (13:04 +0200)] 
Merge branch 'libmount/errormsg' of https://github.com/t-8ch/util-linux

* 'libmount/errormsg' of https://github.com/t-8ch/util-linux:
  libmount: report all kernel messages for fd-based mount API
  libmount: add helper to log mount messages as emitted by kernel
  libmount: change syscall status macros to be functions

21 months agoMerge branch 'lsfs--sockdiag-RW' of https://github.com/masatake/util-linux
Karel Zak [Mon, 9 Oct 2023 10:26:37 +0000 (12:26 +0200)] 
Merge branch 'lsfs--sockdiag-RW' of https://github.com/masatake/util-linux

* 'lsfs--sockdiag-RW' of https://github.com/masatake/util-linux:
  lsfd: (man) update the description of ENDPOINTS column of UNIX-Stream sockets
  tests: (lsfd) extend the mkfds-socketpair case to test ENDPOINTS with SOCK.SHUTDOWN info
  lsfd: append SOCK.SHUTDOWN value to ENDPOINTS column of UNIX-STREAM sockets
  tests: (lsfd) add a case for testing SOCK.SHUTDOWN column
  tests: (test_mkfds::socketpair) add "halfclose" parameter
  lsfd: don't capitalize the help strings for the columns
  lsfd: (man) write about SOCK.SHUTDOWN column
  lsfd: add SOCK.SHUTDOWN column
  lsfd: call xinfo backend method before calling socket generic method when filling columns
  tests: (lsfd) add a case for testing ENDPOINTS column of UNIX-STREAM sockets
  tests: (lsfd::mkfds-socketpair) make a case for testing DGRAM a subtest and add a subtest for STREAM
  lsfd: (man) document the ENDPOINT column for UNIX socket
  lsfd: fill ENDPOINTS column of unix socket using UNIX_DIAG_PEER information
  lsfd: make the sock_xinfo layer be able to prepare an ipc_class for a given socket
  lsfd: initialize the ipc table before loading lists of unix socket peers via netlink diag

21 months agoautotools: fix AC_DEFINE_UNQUOTED() use
Karel Zak [Mon, 9 Oct 2023 10:18:31 +0000 (12:18 +0200)] 
autotools: fix AC_DEFINE_UNQUOTED() use

Let's use AC_DEFINE_UNQUOTED() for string-like content, otherwise use
a simple AC_DEFINE().

Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agoautotools: fix librtas check
Karel Zak [Mon, 9 Oct 2023 10:15:20 +0000 (12:15 +0200)] 
autotools: fix librtas check

Fixes: https://github.com/util-linux/util-linux/discussions/2527
Signed-off-by: Karel Zak <kzak@redhat.com>
21 months agolsfd: (man) update the description of ENDPOINTS column of UNIX-Stream sockets
Masatake YAMATO [Mon, 2 Oct 2023 14:56:47 +0000 (23:56 +0900)] 
lsfd: (man) update the description of ENDPOINTS column of UNIX-Stream sockets

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agotests: (lsfd) extend the mkfds-socketpair case to test ENDPOINTS with SOCK.SHUTDOWN...
Masatake YAMATO [Mon, 2 Oct 2023 12:52:00 +0000 (21:52 +0900)] 
tests: (lsfd) extend the mkfds-socketpair case to test ENDPOINTS with SOCK.SHUTDOWN info

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolsfd: append SOCK.SHUTDOWN value to ENDPOINTS column of UNIX-STREAM sockets
Masatake YAMATO [Mon, 2 Oct 2023 14:50:21 +0000 (23:50 +0900)] 
lsfd: append SOCK.SHUTDOWN value to ENDPOINTS column of UNIX-STREAM sockets

An example output:

   # ./lsfd -Q '((PID == 1) || (PID == 1896)) && (TYPE == "UNIX-STREAM") && ((FD == 1) || (FD == 278))' -o+ENDPOINTS
   COMMAND        PID USER ASSOC  XMODE        TYPE SOURCE MNTID INODE NAME                                             ENDPOINTS
   systemd          1 root   278 rw---m UNIX-STREAM sockfs     9 37012 state=connected path=/run/systemd/journal/stdout 1896,ModemManager,1-w
   ModemManager  1896 root     1 rw---- UNIX-STREAM sockfs     9 43126 state=connected                                  1,systemd,278r-
                                                                                                                        1870458,systemd-journal,68r-

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agotests: (lsfd) add a case for testing SOCK.SHUTDOWN column
Masatake YAMATO [Mon, 2 Oct 2023 14:35:46 +0000 (23:35 +0900)] 
tests: (lsfd) add a case for testing SOCK.SHUTDOWN column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agotests: (test_mkfds::socketpair) add "halfclose" parameter
Masatake YAMATO [Mon, 2 Oct 2023 12:44:13 +0000 (21:44 +0900)] 
tests: (test_mkfds::socketpair) add "halfclose" parameter

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolsfd: don't capitalize the help strings for the columns
Masatake YAMATO [Mon, 2 Oct 2023 14:19:51 +0000 (23:19 +0900)] 
lsfd: don't capitalize the help strings for the columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolsfd: (man) write about SOCK.SHUTDOWN column
Masatake YAMATO [Mon, 2 Oct 2023 14:15:59 +0000 (23:15 +0900)] 
lsfd: (man) write about SOCK.SHUTDOWN column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolsfd: add SOCK.SHUTDOWN column
Masatake YAMATO [Mon, 2 Oct 2023 14:03:06 +0000 (23:03 +0900)] 
lsfd: add SOCK.SHUTDOWN column

An example output:

   # ./lsfd -p1 -Q '(TYPE == "UNIX-STREAM")' -o+SOCK.SHUTDOWN
   systemd   1 root   443 rw---m UNIX-STREAM sockfs     9 183103884 state=connected path=/run/systemd/journal/stdout r-
   systemd   1 root   462 rw---- UNIX-STREAM sockfs     9  11172039 state=listen path=/run/libvirt/libvirt-sock      rw

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agolsfd: call xinfo backend method before calling socket generic method when filling...
Masatake YAMATO [Mon, 2 Oct 2023 14:00:41 +0000 (23:00 +0900)] 
lsfd: call xinfo backend method before calling socket generic method when filling columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agotests: (lsfd) add a case for testing ENDPOINTS column of UNIX-STREAM sockets
Masatake YAMATO [Thu, 3 Aug 2023 16:29:53 +0000 (01:29 +0900)] 
tests: (lsfd) add a case for testing ENDPOINTS column of UNIX-STREAM sockets

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agotests: (lsfd::mkfds-socketpair) make a case for testing DGRAM a subtest and add a...
Masatake YAMATO [Mon, 9 Oct 2023 06:29:40 +0000 (15:29 +0900)] 
tests: (lsfd::mkfds-socketpair) make a case for testing DGRAM a subtest and add a subtest for STREAM

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
21 months agomeson: avoid int operation with non-int
Thomas Weißschuh [Mon, 9 Oct 2023 05:34:46 +0000 (07:34 +0200)] 
meson: avoid int operation with non-int

`conf` as configuration_data() object can contain any datatype.
For `HAVE_FOO` variables this will be a `1` int to generate
`#define HAVE_FOO 1` or a `false` bool to generate `#undef HAVE_FOO`
in `conf.h`.

When retrieving and testing `HAVE_FOO` from `conf` it can be both types.
Newer versions of meson are unhappy about comparisions of int with
non-int

    ../meson.build:734: DEPRECATION: Project uses feature that was always broken, and is now deprecated since '1.2.0': int operations with non-int. It is not commutative and only worked because of leaky Python abstractions.

    WARNING: Broken features used:
     * 1.2.0: {'int operations with non-int'}

As both `int` and `bool` support a `.to_string()` method, we can use
that to convert them into a well-known type and compare that.

Unfortunately meson does not implement a way to determine the type of a
value.
A method `int.to_int()` would also have worked but does not exist.

This broken feature was actually first recognized in util-linux.
See #2312 and https://github.com/mesonbuild/meson/pull/11879.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolib/path: fix typos
Tobias Stoeckmann [Sun, 8 Oct 2023 18:51:07 +0000 (20:51 +0200)] 
lib/path: fix typos

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agolib/path: remove ul_prefix_fopen
Tobias Stoeckmann [Sun, 8 Oct 2023 18:49:31 +0000 (20:49 +0200)] 
lib/path: remove ul_prefix_fopen

The function ul_prefix_fopen does not properly check for paths which are
too long. Since the only caller of ul_prefix_fopen can be easily
converted to ul_path_fopen, remove the function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agolib/path: set errno in case of error
Tobias Stoeckmann [Sun, 8 Oct 2023 18:47:53 +0000 (20:47 +0200)] 
lib/path: set errno in case of error

Some programs like lscpu expect errno to be set if ul_path_cpuparse
fails.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agolib/path: fix possible out of boundary access
Tobias Stoeckmann [Sun, 8 Oct 2023 18:41:29 +0000 (20:41 +0200)] 
lib/path: fix possible out of boundary access

If fgets reads from a file starting with a NUL byte in ul_path_cpuparse,
then the check for newline leads to an out of boundary access.

Proof of Concept (compile with --enable-asan):

1. Prepare /tmp/poc with required files
```
$ install -d /tmp/poc/sys/devices/system/cpu
$ dd if=/dev/zero of=/tmp/poc/sys/devices/system/cpu/possible bs=1 count=1
$ install -D /dev/null /tmp/poc/proc/cpuinfo
```

2. Run lscpu with sysroot option
```
$ lscpu --sysroot /tmp/poc
=================================================================
==78238==ERROR: AddressSanitizer: heap-buffer-overflow
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
21 months agolibmount: report all kernel messages for fd-based mount API
Thomas Weißschuh [Thu, 5 Oct 2023 11:21:23 +0000 (13:21 +0200)] 
libmount: report all kernel messages for fd-based mount API

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibmount: add helper to log mount messages as emitted by kernel
Thomas Weißschuh [Thu, 5 Oct 2023 11:19:14 +0000 (13:19 +0200)] 
libmount: add helper to log mount messages as emitted by kernel

The kernel helpfully provides feedback about failed operations via the
filesystem descriptor. Read that information and expose it via libmounts
debug facilities.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
21 months agolibmount: change syscall status macros to be functions
Thomas Weißschuh [Thu, 5 Oct 2023 11:18:15 +0000 (13:18 +0200)] 
libmount: change syscall status macros to be functions

Functions are easier to modify and reason about.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>