Karel Zak [Tue, 5 Dec 2023 12:52:03 +0000 (13:52 +0100)]
Merge branch 'fixes' of https://github.com/t-8ch/util-linux
* 'fixes' of https://github.com/t-8ch/util-linux:
build: use -std=c99 and -std=c++11 by default
coverage.h: mark _exit as noreturn
lsfd: switch to c99-conformant alignment specification
blkdev.h: avoid some unused argument warnings
m4: update pkg.m4
include/c.h: implement reallocarray
libblkid: avoid use of non-standard typeof()
meson: bump required version to 0.60.0
Karel Zak [Tue, 5 Dec 2023 10:09:38 +0000 (11:09 +0100)]
Merge branch 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work
* 'PR/libmount-utab-external' of github.com:karelzak/util-linux-work:
tests: make mount/special more robust
tests: add missing file and improve options-missing test
libmount: test utab options after helper call
libmount: add missing utab options after helper call
libmount: add private mnt_optstr_get_missing()
Karel Zak [Tue, 5 Dec 2023 10:08:57 +0000 (11:08 +0100)]
Merge branch 'unshare-maps' of https://github.com/arachsys-prs/util-linux
* 'unshare-maps' of https://github.com/arachsys-prs/util-linux:
unshare: Add --map-users=all and --map-groups=all
unshare: Set uid and gid maps directly when run as root
unshare: Support multiple ID ranges for user and group maps
Chris Webb [Mon, 4 Dec 2023 18:15:14 +0000 (18:15 +0000)]
unshare: don't try to reset the disposition of SIGKILL
If the child process is killed with SIGKILL, don't attempt to reset the
disposition of SIGKILL (which can't be caught or ignored anyway) before
self-signalling. This caused a misleading 'sigprocmask unblock failed'
error instead of dying with the same SIGKILL status as the child.
Fixes: https://github.com/util-linux/util-linux/issues/2614 Signed-off-by: Chris Webb <chris@arachsys.com>
Khem Raj [Mon, 4 Dec 2023 03:59:46 +0000 (19:59 -0800)]
login-utils: include libgen.h for basename API
musl has removed the non-prototype declaration of basename from string.h [1] which now results in build errors with clang-17+ compiler
include libgen.h for using the posix declaration of the funciton.
Fixes
../util-linux-2.39.2/login-utils/su-common.c:847:20: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
847 | shell_basename = basename(shell);
| ^
Thomas Weißschuh [Thu, 30 Nov 2023 22:24:37 +0000 (23:24 +0100)]
build: use -std=c99 and -std=c++11 by default
Relying on the compiler default is problematic:
* New constructs may be introduced accidentally that break backwards
compatibility.
* Older compilers may default to a more restricted standard than the
codebase is actually developed with.
Explicitly select C99 (and C++11 for the fuzzing part).
Autotools does not want to default to C99, so set it explcitly during
CI.
Thomas Weißschuh [Thu, 30 Nov 2023 22:23:33 +0000 (23:23 +0100)]
meson: bump required version to 0.60.0
We already rely on 0.60.0 features:
libsmartcols/meson.build:44: WARNING: Project targets '>=0.57.0' but uses feature introduced in '0.60.0': list.<plus>. The right hand operand was not a list.
Karel Zak [Thu, 30 Nov 2023 09:25:45 +0000 (10:25 +0100)]
tests: add missing file and improve options-missing test
* remove optional ID= field (not on systems without statx())
* add missing tests/expected/mount/special-missing-options
* make sure utab is created
* use udevadm settle to wait for systemd
Chris Webb [Thu, 23 Nov 2023 14:06:02 +0000 (14:06 +0000)]
unshare: Add --map-users=all and --map-groups=all
Accept the special value 'all' for --map-users and --map-groups,
configuring a pass-through mapping of every user or group ID available
in the parent user namespace.
These are invaluable for scripting tests, for example when you want to
remap users leaving groups unchanged, remap groups leaving users unchanged,
or create a pass-through user namespace which maps the same users and
groups as its parent but has no capabilities in that parent namespace.
In the root user namespace, 'all' is equivalent to '0:0:4294967295', but
in child namespaces it may represent a fragmented mapping corresponding
to multiple --map-users or --map-groups options.
Chris Webb [Thu, 23 Nov 2023 13:14:58 +0000 (13:14 +0000)]
unshare: Set uid and gid maps directly when run as root
The newuidmap and newgidmap setuid helpers provided by shadow don't allow
root to set up arbitrary mappings without explicit wildcard configuration
in /etc/subuid and /etc/subgid, and are an unnecessary dependency when
unshare is run privileged.
ID-mapped mount already knows how to create uid/gid maps directly for new
user namespaces, so teach unshare to do the same thing when run as root.
Continue to use the setuid helpers when we are not sufficiently privileged
to do the job ourselves.
Chris Webb [Thu, 23 Nov 2023 12:24:58 +0000 (12:24 +0000)]
unshare: Support multiple ID ranges for user and group maps
Accept multiple --map-users and --map-groups options to specify disjoint ID
ranges to map inside a user namespace. This was already supported by mount
--map-groups and --map-users, but paradoxically not by unshare itself.
Factor out the hole-punching logic which removes single-ID mappings set
with --map-user and --map-group from range mappings set with --map-users
and --map-groups. add_single_map_range() now performs this fixup for
every given range before prepending the single-ID mapping.
Karel Zak [Wed, 29 Nov 2023 11:37:52 +0000 (12:37 +0100)]
libmount: add missing utab options after helper call
libmount is able to add missing entry to /run/mount/utab after
external /sbin/mouht.<type> helper execution. This is not enough, it's
possible that the helper write proper entry to the utab, but there is
missing some options expected by libmount (usually because the options
are irrelevant fro the helper.
Reproducer:
Create a stupid mount.foo which writes x-foo=123 to utab:
Karel Zak [Tue, 28 Nov 2023 13:40:48 +0000 (14:40 +0100)]
libmount: accept '\' as escape for options separator
The libmount library can accept any characters as an option value when
the value is quoted (e.g., foo="b,a,r"). However, overlayfs users have
been using '\' as an escape character (e.g., lowerdir=foo\,bar).
Although this escaping mechanism was never officially supported by
libmount/mount, it worked for the old mount(2) API because it kept the
options string unparsed for the mount(2) syscall.
The introduction of the new mount API, which utilizes fsconfig(2) per
option, has brought attention to this issue.
This patch addresses the problem by introducing official support for
'\' as an escape character for options separator.
Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
References: https://lore.kernel.org/all/CAOQ4uxhgUSPkYAV8SJu-SFszkJcVO3-M4DXf46nJUtXODrPk2g@mail.gmail.com/T/#ma8e6cfc1ce7229abc089e03eed99b23b90d701e5 Signed-off-by: Karel Zak <kzak@redhat.com>
Junxiao Bi [Tue, 7 Nov 2023 18:48:06 +0000 (10:48 -0800)]
losetup: report lost loop devices for finding free loop
commit a6ca0456cc6d("loopdev: report lost loop devices") forgot to
report lost loop device for finding free loop case. With this path,
it will show the following if next free loop device is lost.
# ./losetup -f
/dev/loop1 (lost)
# ./losetup -f /tmp/test.img
lt-losetup: /tmp/test.img: failed to set up loop device: No such file or directory
lt-losetup: device node /dev/loop1 (7:1) is lost. You may use mknod(1) to recover it.
Karel Zak [Fri, 24 Nov 2023 09:21:58 +0000 (10:21 +0100)]
Merge branch 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux
* 'minor-changes-about-new-filter' of https://github.com/masatake/util-linux:
lsfd: (man) document --list-columns as the way to list columns
lsfd: (man) refer to scols-filter(5)
libsmartcols: (man) fix typos
Karel Zak [Fri, 24 Nov 2023 09:21:36 +0000 (10:21 +0100)]
Merge branch 'lslocks--co-holders' of https://github.com/masatake/util-linux
* 'lslocks--co-holders' of https://github.com/masatake/util-linux:
tests: (lslocks) add cases testing HOLDERS column
tests: (cosmetic,lslocks) trim whitespaces at the end of line
tests: (test_mkfds::make-regular-file) add a new parameter, "dupfd"
lslocks: add HOLDERS column
lslocks: store list_add_tail when storing information extracted from /proc/$pid/fdinfo/$fd
tests: (test_mkfds) initialize a proper union member
xalloc.h: add new functions: xstrappend, xstrputc, xstrvfappend, and xstrfappend
lsfd: (refactor) make the code comparing struct lock objects reusable
lslocks: add a missing "break;" in a switch/case statement
lslocks: (preparation) add a fd number to the lock struct when loading lock info from /proc/$pid/fdinfo/$fd
lslocks: (refactor) use a tree for storing lock information extracted from /proc/$pid/fdinfo/$fd
lslocks: (refactor) make the data structure for storing lock information replacable
Karel Zak [Mon, 20 Nov 2023 13:58:08 +0000 (14:58 +0100)]
tests: use scols_column_set_properties() in 'fromfile' sample
The library already can read column properties from a column separated
string. Let's use it in 'fromfile' sample to avoid duplicate code and
to test this function too.
Karel Zak [Mon, 20 Nov 2023 11:53:56 +0000 (12:53 +0100)]
libsmartcols: (samples) remove filter.c
It seems better to use fromfile.c sample where we do not have
hardcoded table data, but it's possible to use data from files (see
tests/ts/libsmartcols/files) as already used in in our tests.
Karel Zak [Mon, 6 Nov 2023 20:45:10 +0000 (21:45 +0100)]
libsmartcols: build filter scanner and parser header files too
* if .c and .h generated in the same time then bison does not duplicate
declarations from .h in .c
* it seems better to generate everything and exclude header files from
git
* the patch excludes autotools YACC support, we need reentrant parser
with some cool features from bison; autotools assumes POSIX
compatibility for YACC (bison -y), we do not need it.
Karel Zak [Mon, 23 Oct 2023 20:34:18 +0000 (22:34 +0200)]
libsmartcols: (filter) normalize param strings
Let's ignore space at the beginning and end of the string. It's
possible that filling functions in applications use extra space to
align data in columns. We need to ignore it.