Karel Zak [Wed, 3 Jan 2024 13:13:28 +0000 (14:13 +0100)]
libmount: introduce /run/mount/utab.event
The mnt_monitor_...() API uses /run/mount/utab.lock to monitor utab
changes. The same file is used to control access to the utab file.
The utab can be updated more than once during one mount(8) call, for
example, one update is done in /sbin/mount.nfs and next in mount(8).
This situation triggers two (e.g. inotify) events when monitoring is
based on the lock file.
It seems better to introduce separate file to trigger the event and do
not trigger this event in /sbin/mount.<type> helpers.
Karel Zak [Tue, 2 Jan 2024 10:15:57 +0000 (11:15 +0100)]
Merge branch 'fixes' of https://github.com/t-8ch/util-linux
* 'fixes' of https://github.com/t-8ch/util-linux:
libmount: (context) avoid dead store
libmount: (utils) avoid dead store
pipesz: avoid dead store
fileeq: optimize size of ul_fileeq_method
sha1: properly wipe variables
libfdisk: (sgi): use strncpy over strcpy
libfdisk: (sun) properly initialize partition data
libmount: (tests) fix --filesystems crash on invalid argument
libmount: (tests) fix --filesystems test argument parsing
libmount: (veritydev) use asprintf to build string
libsmartcols: (samples/fromfile) properly handle return value from getline()
libuuid: (test_uuid) make reading UUIDs from file more robust
libblkid: (dev) use strdup to duplicate string
pg: use snprintf to build string
hexdump: use xasprintf to build string
readprofile: use xasprintf to build string
cal: avoid out of bound write
logger: use strncpy instead of strcpy
exec_shell: use xasprintf
strv: make strv_new_api static
Karel Zak [Sun, 31 Dec 2023 10:23:39 +0000 (11:23 +0100)]
Merge branch 'patch-12' of https://github.com/mariobl/util-linux
* 'patch-12' of https://github.com/mariobl/util-linux:
Update po4a.cfg to assign exch.1 correctly to misc-utils
exch: Add man page to po4a.cfg to make it translatable
Karel Zak [Thu, 14 Dec 2023 08:43:54 +0000 (09:43 +0100)]
Merge branch 'PR/libsmartcols-cell-data' of github.com:karelzak/util-linux-work
* 'PR/libsmartcols-cell-data' of github.com:karelzak/util-linux-work:
libsmartcols: fix memory leak on filter parser error
libsmartcols: free after error in filter sample
libsmartcols: make cell data printing more robust
Karel Zak [Tue, 12 Dec 2023 09:21:19 +0000 (10:21 +0100)]
Merge branch 'dmesg/tests' of https://github.com/t-8ch/util-linux
* 'dmesg/tests' of https://github.com/t-8ch/util-linux:
dmesg: use symbolic defines for second conversions
dmesg: add support for reserved and local facilities
dmesg: (tests) validate json output
dmesg: only write one message to json
jsonwrt: add ul_jsonwrt_value_s_sized
dmesg: open-code LOG_MAKEPRI
dmesg: correctly print all supported facility names
dmesg: error out instead of silently ignoring force_prefix
Karel Zak [Mon, 11 Dec 2023 09:52:11 +0000 (10:52 +0100)]
Merge branch 'fix-bash-completion-rules' of https://github.com/masatake/util-linux
* 'fix-bash-completion-rules' of https://github.com/masatake/util-linux:
bash-completion: (lslocks): add --bytes option to the rules
bash-completion: (fadvise): fix a typo
more: exit if POLLERR and POLLHUP on stdin is received
more command continues to run in case stdin have closed the file and it
takes 100% of CPU. This is because revents on stdin send
POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even
though it is not requested in events. This is common Linux behaviour to
never mask out POLLHUP or POLLERR. The loop in more_key_command() runs
infinitely because more_poll() returns 0 and read_command() reads 0
bytes.
Check for POLLERR and POLLHUP, and exit more in case of an error.
Steps to reproduce:
1. Setup /etc/systemd/logind.conf with KillUserProcesses=no
2. Add config "Defaults use_pty" in /etc/sudoers
3. Start an ssh session to the machine
4. # sudo su -
5. # more <big enough file>
6. kill the parent ssh process, say close the tab
At this time "more" runs with 100% CPU utilization.
Eli Schwartz [Thu, 7 Dec 2023 00:40:44 +0000 (19:40 -0500)]
bash-completion: make sure that "lastb" actually completes
Building util-linux logs a warning on Gentoo:
```
* Problems with installed bash completions were found:
*
* lastb: incorrect name, no completions for 'lastb' command defined.
*
* For more details on installing bash-completions, please see:
* https://wiki.gentoo.org/wiki/Bash/Installing_completion_files
```
A bash-completion file is usually composed of two parts:
- a function that knows how to produce completions
- a specification of which command should be completed
In cases where multiple commands have the same options, e.g. commands
that are symlinked to each other, it is common to symlink the completion
files as well. This shares the first part. But the second part cannot be
shared, it must be implemented twice by specifying two different
commands to be completed.
"lastb" had a symlinked completion, but when the completion system
processes /usr/share/bash-completion/completions/lastb, it would only
define a completion for "last".
Define both completions in one file, so that sourcing it works
regardless of command used.
more: exit if POLLHUP or POLLERR on stdin is received
more command continues to run in case stdin have closed the file and it
takes 100% of CPU. This is because revents on stdin send
POLLIN | POLLHUP | POLLERR once stdin is closed. more receives it even
though it is not requested in events. This is common Linux behaviour to
never mask out POLLHUP or POLLERR. The loop in more_key_command() runs
infinitely because more_poll() returns 0 and read_command() reads 0
bytes.
Steps to reproduce:
1. Setup /etc/systemd/logind.conf with KillUserProcesses=no
2. Add config "Defaults use_pty" in /etc/sudoers
3. Start an ssh session to the machine
4. # sudo su -
5. # more <big enough file>
6. kill the parent ssh process, say close the tab
At this time "more" runs with 100% CPU utilization.
Masatake YAMATO [Thu, 7 Dec 2023 19:35:29 +0000 (04:35 +0900)]
tests: (lslcoks) insert a sleep between taking a lock and running lslocks
Close #2624.
It appears that there is a time lag between locking and its visibility
in /proc/locks. See the unstbale results of errors I observed in
https://github.com/util-linux/util-linux/pull/2629.
Karel Zak [Thu, 7 Dec 2023 12:54:26 +0000 (13:54 +0100)]
unshare: make sure map_range.next is initialized [coverity scan]
* initialize during declaration (if possible), unspecified fields
defaults to zero in this case.
* fix coverity warnings:
CID 410290: Uninitialized variables (UNINIT)
Using uninitialized value "mid". Field "mid.next" is uninitialized when calling "insert_map_range".
CID 410289: Uninitialized variables (UNINIT)
Using uninitialized value "hi". Field "hi.next" is uninitialized when calling "insert_map_range".
CID 410288: Uninitialized variables (UNINIT)
Using uninitialized value "lo". Field "lo.next" is uninitialized when calling "insert_map_range".
Karel Zak [Thu, 7 Dec 2023 10:30:26 +0000 (11:30 +0100)]
Merge branch 'master' of https://github.com/mystuffs/util-linux
* 'master' of https://github.com/mystuffs/util-linux:
lscpu-cputype.c: assign value to multiple variables (ar->bit32 and ar->bit64) clang with -Wcomma will emit an warning of "misuse of comma operator". Since the value that will be assigned, is the same for both (bit32 and bit64), just assigning directly to both variables seems reasonable.