Some parts of the Debian build infrastructure uses unshare to run the
package build, and that appears to cause a "nested" unshare in the
lsns/ioctl_ns test to fail. Unfortunately the tests then hang at this
point.
Try running unshare before the actual test, and skip the test if unshare
already fails.
[kzak@redhat.com: - add --fork to the test
- don't write to stdout/err]
Signed-off-by: Chris Hofstaedtler <zeha@debian.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 31 Aug 2021 09:57:30 +0000 (11:57 +0200)]
tests: use sub-tests for dm-verity
* write error to the test log file rather than on stdout
* use sub-tests to get more info on output
* don't use ts_die in sub-tests to make sure we call final dmsetup remove
Naohiro Aota [Mon, 30 Aug 2021 05:52:56 +0000 (14:52 +0900)]
lsblk: add columns of zoned parameters
Several parameters for zoned devices are missing from lsblk's columns. This
commit introduces them as following.
ZONE-SZ zone size
ZONE-WGRAN zone write granularity
ZONE-APP zone append max bytes
ZONE-NR number of zones
ZONE-OMAX maximum number of open zones
ZONE-AMAX maximum number of active zones
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Hans de Goede [Fri, 30 Jul 2021 11:22:54 +0000 (13:22 +0200)]
wdctl: Workaround reported boot-status bits not being present in wd->ident.options
Some watchdog drivers are capable of reporting WDIOF_CARDRESET in their
bootstatus, but they do not advertise this in the options field
returned by the WDIOC_GETSUPPORT ioctl.
This causes wdctl to not print the CARDRESET flag on these devices,
even when the reset was caused by the watchdog and this is being
reported in the WDIOC_GETBOOTSTATUS return.
Add a workaround by or-ing any bits which are set in the status and
bstatus returns into wd->ident.options so that reported flags will
get printend independent of them being advertised as supported in
wd->ident.options.
This will make wdctl print a CARDRESET line when the system was
actually reset by the watchdog while omitting it when it was not
reset by the watchdog. At least on drivers which have the
CARDRESET is missing from info.options problem. On other drivers
the CARDRESET line will always be printend, but the actual reported
value will change.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Jan Samek [Mon, 16 Aug 2021 19:22:15 +0000 (21:22 +0200)]
zramctl: add zstd compression algorithm option
Add information about the possible value 'zstd' for the 'zramctl --algorithm'
option to 'zramctl --help' and zramctl (8) manpage. The kernel supports zram
with zstd compression starting with 4.15 (see
https://lore.kernel.org/lkml/20170912050005.3247-1-sergey.senozhatsky@gmail.com/#r).
Karel Zak [Thu, 12 Aug 2021 10:12:39 +0000 (12:12 +0200)]
libmount: change propagation of /run for X-mount.subdir
We do not need to create a new mount node from /run/mount/tmptgt
(where we mount filesystem root), because /run is already mount
node in all mainstream distros, and we can use MS_PRIVATE for
this top-level directory. There is still fallback if /run is
on root filesystem.
This solution reduces number of mount operations, with the patch the
subdir implementation is:
* open current namespace from /proc/self/ns/mnt
* mkdir /run/mount/tmptg (if it does not exist)
* make /run private by mount(MS_PRIVATE)
* mount filesystem to /run/mount/tmptg
* bind mount /run/mount/tmptg/<subdir> to <target>
* umount /run/mount/tmptg
* setns() to the original namespace
Karel Zak [Thu, 12 Aug 2021 08:58:18 +0000 (10:58 +0200)]
libmount: use /run/mount/tmptgt rather than /tmp/mount/mount.<pid>
The unshared namespace is per-process, so we can use the same
directory in all mount(8) instances. It's unnecessary to create
and remove process specific directory.
* open current namespace from /proc/self/ns/mnt
* mkdir /tmp/mount/mount.<pid>
* unshare mount namespace
* create mount node from /tmp/mount/mount.<pid> by mount(MS_BIND)
* mark /tmp/mount/mount.<pid> private by mount(MS_PRIVATE|MS_REC)
* bind mount /tmp/mount/mount.<pid>/subdir to <target>
* umount /tmp/mount/mount.<pid>
* rmdir /tmp/mount/mount.<pid>
* setns() to the original namespace
Note that /tmp/mount/mount.<pid> conversion to mount node and call for
MS_PRIVATE are visible (propagated to the system) if /tmp is a shared
filesystem, the rest (all operations with the desired filesystem) is
atomic for a parental namespace.
Maybe one day it will be possible to reimplement it in more
elegant way with new mount kernel APIs (open_tree(), etc.).
Fixes: https://github.com/karelzak/util-linux/issues/1103 Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/prlimit.c:467:16: warning: 'hard' may be used uninitialized in this function [-Wmaybe-uninitialized]
lim->rlim_max = hard;
~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:15: note: 'hard' was declared here
rlim_t soft, hard;
^~~~
sys-utils/prlimit.c:466:16: warning: 'soft' may be used uninitialized in this function [-Wmaybe-uninitialized]
lim->rlim_cur = soft;
~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:9: note: 'soft' was declared here
rlim_t soft, hard;
^~~~
References: https://github.com/karelzak/util-linux/issues/1406 Signed-off-by: Karel Zak <kzak@redhat.com>
Smitty [Sun, 8 Aug 2021 22:04:30 +0000 (18:04 -0400)]
whereis: use commands for Bash completions
Currently, the Bash completions for `whereis <TAB>` gives
`whereis file` ("file" is not a placeholder here, it literally expands
to that). This fixes that by passing the `-c` flag to `compgen` to
request completions for command names.
Karel Zak [Mon, 2 Aug 2021 08:40:10 +0000 (10:40 +0200)]
Merge branch 'chs' of https://github.com/pali/util-linux
* 'chs' of https://github.com/pali/util-linux:
fdisk: Add support for fixing MBR partitions CHS values
libfdisk: (dos) Add function fdisk_dos_fix_chs() for fixing CHS values for all partitions
libfdisk: (dos) Add function dos_partition_sync_chs() for updating CHS values
fdisk: Add support for fixing MBR partitions CHS values
Add a new extended option 'F' to fdisk which recalculates and fixes CHS
values for each partition in MBR table according to current fdisk settings
for number of heads and sectors per track.
This allows in interactive mode to repair existing partitions to be
compatible with CHS addressing after changing extended option 'h' (number
of heads) or 's' (sectors per track) as these options do not modify content
of existing partitions.
libfdisk: (dos) Add function fdisk_dos_fix_chs() for fixing CHS values for all partitions
This function fixes beginning and ending CHS values for every partition
according to LBA relative offset, relative beginning and size and fdisk
idea of disk geometry (sectors per track and number of heads). This
function may be used for repairing existing partitions to be compatible
with CHS addressing.
Karel Zak [Fri, 30 Jul 2021 09:50:46 +0000 (11:50 +0200)]
agetty: use CTRL+C to erase username
aggety(8) from the beginning ignores ^C (the small exception was
between 2.32 and 2.34 when this char has been misinterpreted).
This patch forces agetty to interpret ^C like ^U, it means to
erase the user's input and wait for a completely new username.
The small difference is that for ^C it does not set 'kill character'.
This change does not affect serial lines where ^C is still ignored like
in previous decades. I'd like to avoid any regression as I have
no clue if any serial lines do not send this control char in some
context ...
Fixes: https://github.com/karelzak/util-linux/issues/1399
References: https://github.com/karelzak/util-linux/issues/1046 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 29 Jul 2021 19:34:20 +0000 (21:34 +0200)]
Merge branch 'xget' of https://github.com/ericonr/util-linux
* 'xget' of https://github.com/ericonr/util-linux:
lib/pwdutils: use assert to check correct usage.
logger: use xgetlogin from pwdutils.
wall: use xgetlogin.
lib/pwdutils: don't use getlogin(3).
Karel Zak [Thu, 29 Jul 2021 18:37:32 +0000 (20:37 +0200)]
libmount: don't use setgroups at all()
It's probably good idea to call setgroups() to cleanup groups,
but it introduces a regression as some mount helpers depend on
supplementary groups like "network" etc.
Fixes: https://github.com/karelzak/util-linux/issues/1398 Signed-off-by: Karel Zak <kzak@redhat.com>
Since these functions are only used internally, we can make sure they
are being used correctly, and assert() helps in catching remaining
issues. Usage of each changed function has been reviewed:
For xgetpwnam:
- chsh(1) only calls it if a username has been set
- login(1) only calls it if username has been set and is not empty
- su(1) always initializes new_user to "root"
- unshare(1) calls get_user with optarg, so always set as well
For xgetgrnam:
- unshare(1) calls get_group with optarg
For xgetpwuid:
- chsh(1) passes a stack allocated struct for struct passwd
It defined its own xgetlogin, which queried geteuid() instead of getuid(),
with a fallback to "<someone>" when lookup fails. This has been the case
since the function was introduced in 019b97024fde3f07eaf541eef990762483369a11, so geteuid() has always been
used. Since using geteuid for identification isn't consistent with the
rest of util-linux, switching to xgetlogin(), which uses getuid(),
should be correct.
getlogin(3) shouldn't be used for identification here. This also removes
the bug where a missing entry for getuid() in passwd database wouldn't
print a warning, because whom would be set to "???".
For consistency, switch to "<someone>" when pw look up fails.
Per the man page, it shouldn't be used for security purposes. This is an
issue especially on musl, where getlogin is implemented as
getenv("LOGNAME"). Since xgetlogin is being used as user identity in su(1), to
set PAM_RUSER, we simply switch to always using getpwuid(getuid()).