The directory can be directly used by libuuid, for example, by running
"uuidgen --time" as root, even if the uuidd daemon is not installed.
In this case, we must create a clock.txt file with the uuidd group to
prevent any potential ownership mismatch if the uuidd daemon is
installed later. The 2xxx mode (setgid) forces open(O_CREAT) in
libuuid to create the file with the uuidd group.
Please note that mode 2755 is the standard used for years in RHEL.
David Gibson [Tue, 9 Jul 2024 05:44:31 +0000 (15:44 +1000)]
unshare: Add options to identity map the user's subordinate uids and gids
--map-users=auto, --map-groups=auto and --map-auto allow automatically
mapping the first block of user or group IDs owned by the effective user
from /etc/sub[ug]id to a block starting at user ID 0. Add options
--map-users=subids, --map-groups=subids and --map-subids to perform a
mapping of the same IDs, but as an identity mapping instead of to UID 0.
This is useful in similar situations to --map-current-user, but preserves
access to the user's subordinate IDs. That allows nested namespaces to
be created with more complex user mappings, either with unshare or with
a container runtime such as podman.
Fixes: https://github.com/util-linux/util-linux/issues/3120 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
column: Adds option -S <num> so whitespaces are used instead of tabs in non table mode.
Entries are padded with whitespaces, then <num> spaces are added to separate the columns.
This should fix https://github.com/util-linux/util-linux/issues/1551
Karel Zak [Tue, 2 Jul 2024 09:14:06 +0000 (11:14 +0200)]
lib/fileutils: add ul_basename()
Unfortunately, the basename() function can be affected by the
creativity of different libc authors, resulting in varying behavior
across implementations.
Instead, use a local implementation to ensure consistency and
portability.
Karel Zak [Tue, 2 Jul 2024 07:32:19 +0000 (09:32 +0200)]
Merge branch 'automake/install-dependency' of https://github.com/t-8ch/util-linux
* 'automake/install-dependency' of https://github.com/t-8ch/util-linux:
autotools: Properly order install dependencies of pam_lastlog2
autotools: make pam install path configurable
Unfortunately, the behavior is different between DOS (original docs)
and GPT. Due to the need for backward compatibility, it is likely
impossible to change the default setting ...
Addresses: https://github.com/util-linux/util-linux/issues/3097 Signed-off-by: Karel Zak <kzak@redhat.com>
Thomas Weißschuh [Sun, 30 Jun 2024 09:23:53 +0000 (11:23 +0200)]
autotools: Properly order install dependencies of pam_lastlog2
As pam_lastlog2 is relinked during installation, all its dependencies
need to already be installed.
This is the same issue that affected pylibmount which was fixed in
commit 324330aca644 ("build-sys: Properly order install dependencies of pylibmount").
Extend the logic added in that commit to also apply to pam_lastlog2.
Closes: #3011 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
While at it, also move the initial definition of
usesecurelib_exec_LTLIBRARIES into Makefile.am.
Also add "exec" to the target name which is recognized by automake to
mark the targets as architecture-specific.
Stanislav Brabec [Wed, 19 Jun 2024 15:31:34 +0000 (17:31 +0200)]
umount, losetup: Document loop destroy behavior
The loop device detach runs asynchronously in the background. It can cause
unexpected errors. Document the possible existence of the loop device after
exit of losetup -d or umount and need of "udevadm settle".
Laurent Vivier [Wed, 19 Jun 2024 08:19:51 +0000 (10:19 +0200)]
unshare: load binfmt_misc interpreter
add -l, --load-interp <file> to load a binfmt_misc interpreter at startup.
The interpreter is loaded from the initial fileystem if the 'F' flags is
provided, otherwise from inside the new namespace
This makes possible to start a chroot of another architecture without
being root.
Thomas Weißschuh [Wed, 12 Jun 2024 21:32:15 +0000 (23:32 +0200)]
lib/sysfs: zero-terminate result of sysfs_blkdev_get_devchain()
sysfs_blkdev_get_devchain() does not zero-terminate its result, but the
caller expects a C-string.
Use ul_buffer_get_string() which includes a trailing zero-byte.
Now it's also valid for sz and bufsz to be equal.
See #3088. Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Thu, 13 Jun 2024 09:39:34 +0000 (11:39 +0200)]
lib/buffer: introduce ul_buffer_get_string()
Some users need a zero-byte-terminated string.
As the buffer internally already maintains a zero-termination, add a
helper function that exposes this to users.
wdctl: always query device node when sysfs is unavailable
When there is no sysfs at all for the watchdog, fall back to reading
from the device node.
This is also useful if the legacy compat /dev/watchdog device which
never has a sysfs interface.
Closes: #3073 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Mon, 29 Apr 2024 06:11:57 +0000 (08:11 +0200)]
lsfd: (tests) skip tests using fd flags on qemu-user
The flags value visible in /proc/$PID/fdinfo/ is encoded using the
platform the kernel is running on.
Not all platforms use the same numeric flag value,
making this cross-platform interpretation brittle.
Karel Zak [Mon, 3 Jun 2024 10:33:01 +0000 (12:33 +0200)]
libmount: fix tree FD usage in subdir hook
* Initialize the tree file descriptor in the hook_subdir.c module if
it has not been initialized yet. (hook_mount.c does not open the
tree if the mount.<type> helper will be executed.)
* Move the function to open the tree to context.c to make it more
generic and usable in more places.
Reported-by: Linus Heckemann <git@sphalerite.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 3 Jun 2024 12:32:18 +0000 (14:32 +0200)]
wall: always use utmp as fallback
Wall(1) can be compiled with systemd support to read the names of ttys
from the systemd session list. However, this may not work on all systems.
In case of failure, the best option is to use the traditional
utmp method as a fallback.
This commit uses strv (string vector) to collect tty names from both
sources (systemd and utmp) and then sends a message to all ttys.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2283049 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 30 May 2024 12:11:38 +0000 (14:11 +0200)]
tests: update lscpu vmware_fpe output
The cpuinfo for vmware_fpe defines two types of CPUs, which differ in
their flags. However, this difference is ignored by lscpu. The latest
version now uses the flags that were defined later.
Karel Zak [Thu, 30 May 2024 11:59:16 +0000 (13:59 +0200)]
lscpu: use CPU types de-duplication
The new CPU type was always allocated when a new relevant value for
the type was found in the cpuinfo file. However, this solution is
fragile because it can result in the parser creating a cputype struct
with incomplete information.
For instance, on ARM systems with multiple CPU types, a new CPU type
would be triggered by a different "CPU part ID". In cases where the
vendor remained the same, a new type would be created later but the
vendor would not be initialized.
The new implementation creates a new CPU type for each CPU (almost)
and then later de-duplicates the array based on vendor, model, etc.
Addresses: https://github.com/util-linux/util-linux/issues/3062 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 28 May 2024 10:32:49 +0000 (12:32 +0200)]
Merge branch 'scriptreplay/add-interactive-playback/2999' of https://github.com/jNullj/util-linux
* 'scriptreplay/add-interactive-playback/2999' of https://github.com/jNullj/util-linux:
format: fix switch case indent
fix clang compile
replace fgetwc with fgetc
format: fix comments and if braces format
format: CamelCase to SnakeCase
Refactor convoluted switch case into if else
fix formatting and add mising break
Add missing author
Add interactive playback docs
Add right arrow key to step forward in playback
Remove uneeded veriable
Add support for adjusting replay speed with arrow keys
Refactor to handle responsive input
Add pause functionality to replay
Refactor delay_for function signature to use const struct timeval
Set stdin to nonblock
Karel Zak [Mon, 27 May 2024 09:51:46 +0000 (11:51 +0200)]
Merge branch 'fix-unnecessary-remake' of https://github.com/ChenQi1989/util-linux
* 'fix-unnecessary-remake' of https://github.com/ChenQi1989/util-linux:
libsmartcols/src/Makemodule.am: ensure filter-scanner/paser.c file is newer than the .h file
Karel Zak [Mon, 27 May 2024 09:48:49 +0000 (11:48 +0200)]
Merge branch 'PR/cal-fix-weeknumber-colors' of github.com:karelzak/util-linux-work
* 'PR/cal-fix-weeknumber-colors' of github.com:karelzak/util-linux-work:
tests: add color schema to cal(1) tests
cal: colorize --vertical output.
cal: properly colorize the week number in vertical output.
cal: fix --week use and colors
Karel Zak [Mon, 27 May 2024 09:48:13 +0000 (11:48 +0200)]
Merge branch 'PR/libmount-errmsg' of github.com:karelzak/util-linux-work
* 'PR/libmount-errmsg' of github.com:karelzak/util-linux-work:
libmount: (loop) detect and report lost loop nodes
libmount: add mnt_context_sprintf_errmsg()
libmount: add functions to use error buffer
libmount: use regular function to save/reset syscalls status
Chen Qi [Sat, 25 May 2024 03:41:35 +0000 (11:41 +0800)]
libsmartcols/src/Makemodule.am: ensure filter-scanner/paser.c file is newer than the .h file
In released tarball, for filter-scanner/parser, the .h and the .c
file has the same mtime. The 'make' tool thinks .h is newer than
the .c file, thus deciding to remake it. This will not only cause
unnecessary rebuild, but also parallel make error. For example,
after 'make', when running 'make install', the libmount.la and findmnt
are both rebuilt and findmnt building will somethings error out complaining
'libmount.so: no such file or directory' or 'libmount.so: file format
not recognized'.
Touch the generated .c file to ensure it's newer than the .h file.
In this way, in new released tarballs in the future, there will
be no unnecessary remake.
jNullj [Fri, 24 May 2024 19:23:48 +0000 (22:23 +0300)]
replace fgetwc with fgetc
there is no real reason to use fgetwc here as arrow key press is not read as a multi-byte by fgetwc and the logic implemented here also reads the keypress byte by bytes.
Karel Zak [Wed, 22 May 2024 10:14:43 +0000 (12:14 +0200)]
Merge branch 'libuuid/coverity' of https://github.com/t-8ch/util-linux
* 'libuuid/coverity' of https://github.com/t-8ch/util-linux:
libuuid: construct UUIDv7 without "struct uuid"
libuuid: construct UUIDv6 without "struct uuid"
libuuid: add helper to set version and variant in uuid_t
Karel Zak [Wed, 22 May 2024 10:12:34 +0000 (12:12 +0200)]
Merge branch 'libuuid/fork' of https://github.com/t-8ch/util-linux
* 'libuuid/fork' of https://github.com/t-8ch/util-linux:
libuuid: clear uuidd cache on fork()
libuuid: split uuidd cache into dedicated struct
libuuid: drop check for HAVE_TLS