Karel Zak [Wed, 1 May 2024 19:17:52 +0000 (21:17 +0200)]
Merge branch 'lsfd/fcntl' of https://github.com/t-8ch/util-linux
* 'lsfd/fcntl' of https://github.com/t-8ch/util-linux:
lsfd: include buffer.h in decode-file-flags.h
buffer: replace include of c.h with stddef.h
lsfd: move interface of decode-file-flags to header
Karel Zak [Mon, 29 Apr 2024 08:26:25 +0000 (10:26 +0200)]
Merge branch 'lsns--debug-ioctl_ns-test-for-master' of https://github.com/masatake/util-linux
* 'lsns--debug-ioctl_ns-test-for-master' of https://github.com/masatake/util-linux:
tests: (lsns::ioctl_ns) add more debug print
tests: (lsns::ioctl_ns) record stdout/stderr for debugging the case
coresched: Manage core scheduling cookies for tasks
Co-authored-by: Phil Auld <pauld@redhat.com> Signed-off-by: Phil Auld <pauld@redhat.com> Signed-off-by: Thijs Raymakers <thijs@raymakers.nl> Signed-off-by: Karel Zak <kzak@redhat.com> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Thomas Weißschuh [Sun, 28 Apr 2024 21:35:12 +0000 (23:35 +0200)]
lsfd: include linux/fcntl.h
asm/-headers are implementation details and not meant to be included
directly. Instead use the linux/ header which will always include the
correct asm/-headers.
flock: add support for using fcntl() with open file description locks
Currently, there is no way for shell scripts to safely access
resources protected by POSIX locking (fcntl with the F_SETLK/F_SETLKW
commands). For example, the glibc function lckpwdf(), used to
protect access to the /etc/shadow database, works by taking a
F_SETLKW on /etc/.pwd.lock .
Due to the odd semantics of POSIX locking (e.g. released when any file
descriptor associated to the inode is closed), we cannot usefully
directly expose the POSIX F_SETLK/F_SETLKW commands. However, linux
3.15 introduced F_OFD_SETLK[W], with semantics wrt. ownership and
release better matching those of flock(2), and crucially they do
conflict with locks obtained via F_SETLK[W]. With this, a shell script
can do
exec 4> /etc/.pwd.lock
flock --fcntl 4
<access/modify /etc/shadow ...>
flock --fcntl --unlock 4 # or just exit
without conflicting with passwd(1) or other utilities that
access/modify /etc/shadow.
No single-letter shorthand is defined for the option, because this is
somewhat low-level and the user really needs to know what he is doing.
Also, this leaves the door open for teaching --fcntl to accept an
optional argument: "ofd", the default, and "posix", should anyone find
a use for flock(1) taking a F_SETLK[W] lock.
tests: (lsns::ioctl_ns) record stdout/stderr for debugging the case
When the test case runs successfully, we expect the case test prints
nothing to stderr. If something is printed to stderr, it helps us
debug lsns command and the test case.
Karel Zak [Thu, 25 Apr 2024 09:22:32 +0000 (11:22 +0200)]
Merge branch 'meson-more-build-options' of https://github.com/jwillikers/util-linux
* 'meson-more-build-options' of https://github.com/jwillikers/util-linux: (21 commits)
meson: Add build-lsclocks option
meson: Add build-enosys option
meson: Define _DARWIN_C_SOURCE on macOS as is done in Autotools
strutils.h: Include strings.h header for strncasecmp function
xalloc.h: Include stdio.h header for vasprintf function
meson: Fix build by default and install behavior for build-pipesz option
meson: Add build-fadvise option
meson: Add build-scriptlive option
meson: Add build-script option
meson: Require pty for the su and runuser executables
meson: Add have_pty variable to check if pty is available
meson: Add build-blockdev option
meson: Add build-chcpu option
meson: Use has_type instead of sizeof to detect cpu_set_t type
meson: Add build-setarch option
meson: Add build-rtcwake option
meson: Add build-ldattach option
meson: Add build-blkdiscard option
meson: Add build-fsfreeze option
meson: Add build-blkzone option
...
Jordan Williams [Mon, 22 Apr 2024 14:42:25 +0000 (09:42 -0500)]
meson: Add build-blockdev option
Only build blockdev on Linux.
The BLKROSET macro is used in blockdev.c from blkdev.h.
The blkdev.h header only defines this macro when it is missing on Linux.
Add blockdev to the list of executables, which appears to have been
omitted previously.
Signed-off-by: Jordan Williams <jordan@jwillikers.com>
Karel Zak [Wed, 24 Apr 2024 10:01:57 +0000 (12:01 +0200)]
Merge branch 'lsfd' of https://github.com/jwilk-forks/util-linux
* 'lsfd' of https://github.com/jwilk-forks/util-linux:
lsfd: (man) add commas between SEE ALSO items
lsfd: (man) fix license name
lsfd: (man) fix typos
Karel Zak [Mon, 22 Apr 2024 12:28:52 +0000 (14:28 +0200)]
lsns: fix netns use
# ip netns add vpn
# lsns -T -t net
Segmentation fault (core dumped)
The function interpolate_missing_namespaces() reads data from /proc.
However, in the case of a persistent namespace, there is no procfs
entry for the namespace. Therefore, this function should ignore it.
Fixes: https://github.com/util-linux/util-linux/issues/2982 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 22 Apr 2024 11:09:04 +0000 (13:09 +0200)]
libmount: Fix access check for utab in context
The function mnt_has_regular_utab() properly detects that the utab is
not writable, but this is ignored by the high-level context API. As a
result, the library later attempts to update the file and ends up with
a warning in mount(8):
$ mkdir sys
$ unshare --map-root-user --mount
$ mount --rbind /sys sys
$ umount --lazy sys; echo $?
umount: /home/user/sys: filesystem was unmounted, but failed to update userspace mount table.
16
In this case, the utab should be ignored.
Fixes: https://github.com/util-linux/util-linux/issues/2981 Signed-off-by: Karel Zak <kzak@redhat.com>
Thomas Weißschuh [Sun, 21 Apr 2024 18:00:31 +0000 (20:00 +0200)]
findmnt: always zero-terminate SOURCES data
libsmartcols expects it's data fields to be zero terminated.
See the call to strlen() in scols_column_greatest_wrap().
ul_buffer however does not guarantee that termination,
ul_buffer_append_strings() discard the zero-termination.
Always zero-terminate in get_data_col_sources() and drop the now
unnecessary variable "i".
Closes: https://github.com/util-linux/util-linux/issues/2980 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
Karel Zak [Thu, 18 Apr 2024 07:42:25 +0000 (09:42 +0200)]
Merge branch 'meson-fix-build-ipcrm-option' of https://github.com/jwillikers/util-linux
* 'meson-fix-build-ipcrm-option' of https://github.com/jwillikers/util-linux:
meson: Require the seminfo type for ipcmk, ipcrm, and ipcs
meson: Add build-ipcmk option
meson: Add missing check for build-ipcrm option
Karel Zak [Wed, 17 Apr 2024 07:50:52 +0000 (09:50 +0200)]
Merge branch 'PR/libsmartcols-fix-wrap' of github.com:karelzak/util-linux-work
* 'PR/libsmartcols-fix-wrap' of github.com:karelzak/util-linux-work:
libsmartcols: (sample) add wrap repeating example
libsmartcols: reset wrap after calculation
Karel Zak [Tue, 16 Apr 2024 11:31:55 +0000 (13:31 +0200)]
libfdisk: add fdisk_ask_menu()
Currently, only libfdisk has the ability to prompt the user with a
menu. However, this functionality is not accessible through the public
library API. This commit exports this functionality through the use of
a simple function, fdisk_ask_menu().