Karel Zak [Tue, 23 Jan 2024 13:54:17 +0000 (14:54 +0100)]
Merge branch 'lastlog2' of https://github.com/schubi2/util-linux
* 'lastlog2' of https://github.com/schubi2/util-linux:
lastlog2 - Y2038 safe version of lastlog pam_lastlog2 - PAM module which logs user login with lastlog2
Edward Chron [Thu, 4 Jan 2024 20:43:46 +0000 (12:43 -0800)]
dmesg: add caller_id support
Submission to Project: util-linux
Open Incident: #2609 at github.com/util-linux/util-linux/issues/2609
Component: util-linux/sys-utils
File: dmesg.c
Code level patch applied against: 2.39.3 - latest code pulled from
git.github.com:util-linux/util-linux.git
Revision: #1 on 2023/12/08 per Review from Karel Zak
Revision: #2 on 2023/12/12 Adjust line offsets for master update and
Add caller_id_size init to dmesg -K
Revision: #3 on 2023/12/12 Use of sizeof for cidbuf and limit search
for caller_id to dmesg prefix to msg text
Revision: #4 on 2023/12/15 Ensure SYSLOG and kmsg inputs have
caller_id_size set appropriately
Revision: #5 on 2023/12/24 Make caller_id width consistent with
makedumpfile
Revision: #6 on 2023/12/30 Use updated test naming convention
Revision: #7 on 2024/01/04 Normalize kmsg caller_id spacing for test
platforms by removing caller_id padding
in test generated output.
Add support to standard dmesg command for the optional Linux Kernel
debug CONFIG option PRINTK_CALLER which adds an optional dmesg field
that contains the Thread Id or CPU Id that is issuing the printk to
add the message to the kernel ring buffer. This makes debugging simpler
as dmesg entries for a specific thread or CPU can be recognized.
The dmesg -S using the old syslog interface supports printing the
PRINTK_CALLER field but currently standard dmesg does not support
printing the field if present. There are utilities that use dmesg and
so it would be optimal if dmesg supported PRINTK_CALLER as well.
The additional field provided by PRINTK_CALLER is only present
if it was configured for the Linux kernel where the dmesg command
is run. It is a debug option and not configured by default so the
dmesg output will only change for those kernels where the option was
configured when the kernel was built. For users who went to the
trouble to configure PRINTK_CALLER and have the extra field available
for debugging, having dmesg print the field is very helpful.
Size of the PRINTK_CALLER field is determined by the maximum number
tasks that can be run on the system which is limited by the value of
/proc/sys/kernel/pid_max as pid values are from 0 to value - 1.
This value determines the number of id digits needed by the caller id.
The PRINTK_CALLER field is printed as T<id> for a Task Id or C<id>
for a CPU Id for a printk in CPU context. The values are left space
padded and enclosed in parentheses such as: [ T123] or [ C16]
For consistency with dmesg -S which supports the PRINTK_CALLER field
the field is printed followed by a space. For JSON format output the
PRINTK_CALLER field is identified as caller as that is consistent with
it's naming in /dev/kmsg. No space padding is used to reduce space
consumed by the JSON output. So the output from the command on a system
with PRINTK_CALLER field enabled in the Linux .config file the dmesg
output appears as:
> dmesg
...
[ 520.897104] [ T3919] usb 3-3: Product: USB 2.0 Hub
and
> dmesg -x
...
kern :info : [ 520.897104] [ T3919] usb 3-3: Product: USB 2.0 Hub
> dmesg -S
...
[ 520.897104] [ T3919] usb 3-3: Product: USB 2.0 Hub
and
> dmesg -S -x
...
kern :info : [ 520.897104] [ T3919] usb 3-3: Product: USB 2.0 Hub
Note: When dmesg uses the old syslog interface the reserved space for
the PRINTK_CALLER field is capped at 5 digits because 32-bit
kernels are capped at 32768 as the max number of PIDs. However,
64-bit systems are currently capped at 2^22 PIDs (0 - 4194303).
The PID cap is set by PID_MAX_LIMIT but the system limit can be
less so we use /proc/sys/kernel/pid_max to determine the size
needed to hold the maximum PID value size for the current system.
Many 64-bit systems support 2^22 PIDs (0 - 4194303) and you see:
This is the only difference seen with PRINTK_CALLER configured and
printing between the dmesg /dev/kmsg interface and the dmesg -S syslog
interface.
Tests naming has been revised based on naming convention Thomas used to
introduce dmest json tests. The naming of test and input files that
reside in tests/ts/dmeg include:
<name> are existing dmesg syslog interface tests and input files.
cid-<name> are dmesg syslog interface caller_id tests and input files.
json-<name> are dmesg kmsg interface tests and input files.
cid-json-<name> are dmesg kmsg interface caller_id tests and input files.
Resulting expected files match the test names.
Signed-off-by: Ivan Delalande <colona@arista.com> Signed-off-by: Edward Chron <echron@arista.com> Signed-off-by: Karel Zak <kzak@redhat.com>
As none of the cputype_patterns match any of the fields in that file,
`cpu->type` is never set, which causes `get_cell_data` to always
return nullptr. The output of `lscpu -b --extended=CPU` and `lscpu
-p` is then empty.
Resolve that.
[kzak@redhat.com: - fix DEF_PAT_CPUTYPE()s order
- refresh lscpu/lscpu-rv64-linux test]
Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 23 Jan 2024 10:07:58 +0000 (11:07 +0100)]
Merge branch 'lsfd--fix-2691' of https://github.com/masatake/util-linux
* 'lsfd--fix-2691' of https://github.com/masatake/util-linux:
tests: (lsfd::column-xmode) skip some subtests if OFD locks are not available
tests: (lsfd) skip mkfds-netns if SIOCGSKNS is not defined
tests: (lsfd) add lsfd_check_mkfds_factory as a help function
tests: (test_mkfds) add --is-available option
lsfd: build lsfd even if kcmp.h is not available
tests: (refactor (test_mkfds, lsfd)) use TS_EXIT_NOTSUPP instead of EXIT_ENOSYS
Karel Zak [Tue, 23 Jan 2024 10:06:51 +0000 (11:06 +0100)]
Merge branch 'findmnt-inode' of https://github.com/masatake/util-linux
* 'findmnt-inode' of https://github.com/masatake/util-linux:
findmnt: add -I, --dfi options for imitating the output of df -i
findmnt: add inode-related columns for implementing "df -i" like output
Masatake YAMATO [Fri, 19 Jan 2024 20:06:58 +0000 (05:06 +0900)]
lsfd: build lsfd even if kcmp.h is not available
As reported in #2691 by @rrrossi, lsfd was not built on the platform
where kcmp.h was not available. However, lsfd just uses kcmp(2) only
for optimization; it can work without kcmp.
Karel Zak [Mon, 22 Jan 2024 12:04:44 +0000 (13:04 +0100)]
libmount: ignore unwanted kernel events in monitor
If the mount operation requires multiple steps, it's optimal for the
libmount monitor to ignore the steps until we get a complete mount
(reported by the utab.event file).
This commit adds a new API function, mnt_monitor_veil_kernel(), to
ignore unwanted kernel mount events.
Note that this only makes sense when the application monitors kernel
and userspace events simultaneously.
Karel Zak [Mon, 22 Jan 2024 11:56:24 +0000 (12:56 +0100)]
libmount: add utab.act file
The file exists when libmount works with utab, and more steps are
expected during a single mount operation (more kernel events, more
updates to utab, etc.).
It is possible to monitor the file through the mnt_monitor_...() API
by a simple access() after any event. No locks are expected in
monitor, making it usable for non-root users without any security
impact. The monitor can ignore events if the file exist.
Thomas Weißschuh [Fri, 19 Jan 2024 02:12:21 +0000 (03:12 +0100)]
login: ignore return of audit_log_acct_message
The function is marked with `warn_unused_result` so handle the return
value. Failures of `audit_open()` are also silently ignored so do the
same for `audit_log_acct_message()` itself.
Karel Zak [Wed, 17 Jan 2024 11:37:08 +0000 (12:37 +0100)]
wall: fix calloc cal [-Werror=calloc-transposed-args]
term-utils/wall.c:143:37: error: xcalloc sizes specified with sizeof in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
143 | buf->groups = xcalloc(sizeof(*buf->groups), buf->ngroups);
| ^
term-utils/wall.c:143:37: note: earlier argument should specify number of elements, later size of each element
sulogin: relabel terminal according to SELinux policy
The common SELinux practice is to have a distinct label for terminals in
use by logged in users. This allows to differentiate access on the
associated terminal (e.g. user_tty_device_t) vs foreign ones (e.g.
tty_device_t or sysadm_tty_device_t). Therefore the application
performing the user login and setting up the associated terminal should
label that terminal according to the loaded SELinux policy. Commonly
this is done by pam_selinux(7). Since sulogin(8) does not use pam(7)
perform the necessary steps manually.
Fixes: https://github.com/util-linux/util-linux/issues/1578 Reviewed-by: James Carter <jwcart2@gmail.com> Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 16 Jan 2024 10:17:55 +0000 (11:17 +0100)]
Merge branch 'time64' of https://github.com/t-8ch/util-linux
* 'time64' of https://github.com/t-8ch/util-linux:
build-sys: (tests) validate that time_t is 64bit
meson: try to always use 64bit time support on glibc
build-sys: try to always use 64bit time support on glibc
build-sys: backport autoconf year2038 macros
tests: add sysinfo to show sizeof(time_t)
tests: constify a sysinfo helpers struct
Karel Zak [Mon, 15 Jan 2024 09:38:45 +0000 (10:38 +0100)]
Merge branch 'PR/uuidd-cont-clock-persistence' of github.com:karelzak/util-linux-work
* 'PR/uuidd-cont-clock-persistence' of github.com:karelzak/util-linux-work:
libuuid: fix uint64_t printf and scanf format
uuidd: add cont_clock persistence
Karel Zak [Fri, 12 Jan 2024 09:31:38 +0000 (10:31 +0100)]
Merge branch 'libblkid/const' of https://github.com/t-8ch/util-linux
* 'libblkid/const' of https://github.com/t-8ch/util-linux:
libblkid: constify return values of blkid_probe_get_sb
include/c.h: handle members of const struct
Michael Trapp [Wed, 10 Jan 2024 16:29:38 +0000 (17:29 +0100)]
uuidd: add cont_clock persistence
cont_clock requires a correct time setup and therefore it
must be possible to detect a step back between uuidd starts.
Reserving the next 10 seconds is sufficient and should not
have a noticeable performance impact. It will also provide
the possibility to start with the clock_reg from the previous
session when the system was rebooted.
Whith that, the early cont_clock initialization in uuidd
should be removed because writing the cont_clock persitence
when -C was not set is useless and might be confusing.
Thomas Weißschuh [Fri, 12 Jan 2024 07:47:50 +0000 (08:47 +0100)]
libblkid: avoid aligning out of probing area
When reading from the end of the device the IO size alignment could
enlarge the read buffer outside of the probing area.
This would then trigger a read failure.
Thomas Weißschuh [Fri, 12 Jan 2024 06:51:39 +0000 (07:51 +0100)]
include/c.h: handle members of const struct
Trying to copy into a local const struct will lead to a compiler error.
By adding a "+ 0" to the argument of __typeof__() the type of the
resulting express will loose its constness.
Karel Zak [Thu, 11 Jan 2024 14:43:50 +0000 (15:43 +0100)]
Merge branch 'login' of https://github.com/stoeckmann/util-linux
* 'login' of https://github.com/stoeckmann/util-linux:
login: document blank treatment in shell field
login: unify pw_shell script test
login: simplify name creation
Karel Zak [Thu, 11 Jan 2024 14:25:43 +0000 (15:25 +0100)]
Merge branch 'include/parttypes' of https://github.com/t-8ch/util-linux
* 'include/parttypes' of https://github.com/t-8ch/util-linux:
include: add U-Boot environment partition type
include: add some more ChromeOS partition types
Karel Zak [Mon, 8 Jan 2024 09:37:09 +0000 (10:37 +0100)]
Merge branch 'tests--lsfd--mkfds-inotify-on-btrfs' of https://github.com/masatake/util-linux
* 'tests--lsfd--mkfds-inotify-on-btrfs' of https://github.com/masatake/util-linux:
tests: (lsfd) add a case testing INOTIFY.INODES.RAW column on btrfs
tests: (test_mkfds::inotify) add "dir" and "file" parameters
tests: (lsfd::mkfds-inotify) use findmnt(1) instead of stat(1) to get bdev numbers
Masatake YAMATO [Fri, 5 Jan 2024 08:54:36 +0000 (17:54 +0900)]
tests: (lsfd::mkfds-inotify) use findmnt(1) instead of stat(1) to get bdev numbers
Close #2349
stat(2) on some filesystems including btrfs reports a block device
number (bdev number) with a offset. On the other hand, "inotify wd"
field of /proc/$pid/fdinfo/$fd for an inotify file reports bdev
numbers without offsets.
The offset caused the failure of lsfd::mkfds-inotify test case on
btrfs. Unlike stat(2), findmnt can report bdev numbers without
offsets.