Commit graph

18268 commits

Author SHA1 Message Date
Karel Zak
689c03b416 Merge branch 'enosys/locale' of https://github.com/t-8ch/util-linux
Some checks failed
CIFuzz / Fuzzing (i386, address) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, address) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, memory) (push) Has been cancelled
CIFuzz / Fuzzing (x86_64, undefined) (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
2023-07-03 12:52:38 +02:00
Karel Zak
6462dbe2ef Merge branch 'clock' of https://github.com/t-8ch/util-linux
* 'clock' of https://github.com/t-8ch/util-linux:
  lsclocks: new util to interact with system clocks
  lib/timeutils: implement timespec formatting
  lib/timeutils: implement nanosecond formatting
  lib/timeutils: constify some arguments
  utmpdump: validate subsecond granularity
2023-07-03 12:47:08 +02:00
Karel Zak
96de80b659 Merge branch 'lsfd--xmode' of https://github.com/masatake/util-linux
* 'lsfd--xmode' of https://github.com/masatake/util-linux:
  lsfd: add 'D' flag for representing deleted files to XMODE column
  lsfd: introduce XMODE column, extensible variant of MODE
  test: (lsfd) add a subcase for testing NAME column for a deleted file
  test: (lsfd) add a case for testing DELETED column
  test: (mkfds) add "make-regular-file" factory
2023-07-03 12:41:04 +02:00
Karel Zak
3e2e4c32e8 Merge branch 'lsfd--misc-tun' of https://github.com/masatake/util-linux
* 'lsfd--misc-tun' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case testing TUN.IFACE column
  tests: (mkfds) add a factor for opening tun device
  lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
  lsfd: (refactor) move miscdev specific code to cdev_misc_ops
  lsfd: (refactor) make the way to handle character devices extensible
  lsfd: (refactor) introduce a content data type for char devices
2023-07-03 12:38:48 +02:00
Karel Zak
c8e36ed4db Merge branch 'patch-1' of https://github.com/diizzyy/util-linux
* 'patch-1' of https://github.com/diizzyy/util-linux:
  include/bitops.h: Remove bswap* compatibility hack for FreeBSD
2023-07-03 12:36:07 +02:00
Karel Zak
452801e4f6 Merge branch 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux:
  libmount: fix typo
2023-07-03 12:32:42 +02:00
Karel Zak
5098291b2c Merge branch 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux
* 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux:
  libmount: update documentation for MNT_ERR_APPLYFLAGS
2023-07-03 12:30:43 +02:00
Karel Zak
85c9a0af07 Merge branch 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux
* 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux:
  unshare: allow negative time offsets
2023-07-03 12:28:54 +02:00
Thomas Weißschuh
95e853892f unshare: allow negative time offsets
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-30 22:36:06 +02:00
Thomas Weißschuh
e9ddea7912 lsclocks: new util to interact with system clocks
Usecases:
* Compare current monotonic time to timestamps reported by systemd
* Validate time namespace operations
* Inspect clock resolutions

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-30 14:12:48 +02:00
Jakub Wilk
a753fb6520 prlimit: reject trailing junk in limits without ":"
Before:

    $ prlimit --verbose --core=1x
    New CORE limit for pid 42: <1:1>

After:

    $ prlimit --verbose --core=1x
    prlimit: failed to parse CORE limit

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2023-06-29 20:13:01 +02:00
Debarshi Ray
5a17b1b626 libmount: update documentation for MNT_ERR_APPLYFLAGS
The implementation using the new FD based mount kernel API (ie.,
fsconfig/fsopen) uses MNT_ERR_APPLYFLAGS for failed mount_setattr(2)
calls, which involves more mount attributes (eg., MOUNT_ATTR_RDONLY,
MOUNT_ATTR_NOSUID, etc.) in addition to the MS_PROPAGATION flags (eg.,
MS_SHARED, MS_UNBINDABLE, etc.).

Note that mount_setattr(2) is part of the new FD based mount kernel API,
and is not used by the classic mount(2) based version.

Fallout from 987d844cdb

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2023-06-29 13:29:01 +02:00
Debarshi Ray
46fe78989d libmount: fix typo
Similar to e80f8e4612 and fallout from
6753e6f691

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2023-06-29 12:26:29 +02:00
Thomas Weißschuh
b9abaae312 lib/timeutils: implement timespec formatting
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:58:32 +02:00
Thomas Weißschuh
136f4874f4 lib/timeutils: implement nanosecond formatting
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:58:06 +02:00
Thomas Weißschuh
971244fdc7 lib/timeutils: constify some arguments
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:57:33 +02:00
Thomas Weißschuh
a8d0195462 utmpdump: validate subsecond granularity
tv_usec is only valid in the range [0, 999999].
If the file contains garbage data replace interpret it as "0" instead.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-28 14:50:49 +02:00
Karel Zak
2b48beb44e include/crc64: add missing license header
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-28 12:41:08 +02:00
Karel Zak
32c7870520 nsenter: avoid NULL pointer dereference [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-28 10:19:34 +02:00
Thomas Weißschuh
d191a7bef8 enosys: enable locale handling
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-27 12:45:37 +02:00
Karel Zak
65c4be5fc2 Merge branch 'cal' of https://github.com/jwilk-forks/util-linux
* 'cal' of https://github.com/jwilk-forks/util-linux:
  cal: fix long option name for -c
  cal: fix error message for bad -c argument
2023-06-27 10:29:59 +02:00
Masatake YAMATO
0cac072b64 tests: (lsfd) add a case testing TUN.IFACE column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 08:28:06 +09:00
Jakub Wilk
618dd71be4 cal: fix long option name for -c 2023-06-26 21:02:13 +02:00
Jakub Wilk
0fb52dabba cal: fix error message for bad -c argument 2023-06-26 21:00:26 +02:00
Jakub Wilk
b1fc5d61f0 lib/strutils: fix typo 2023-06-26 20:00:43 +02:00
Daniel Engberg
214e668c84
include/bitops.h: Remove bswap* compatibility hack for FreeBSD
This is no longer needed on supported versions of FreeBSD and causes build failures
2023-06-26 19:22:16 +02:00
Masatake YAMATO
369007a5b7 tests: (mkfds) add a factor for opening tun device
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
7cbec02a47 lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
An example output:

  # ./lsfd -Q '(SOURCE == "misc:tun")'  -o+TUN.IFACE
  COMMAND             PID       USER ASSOC MODE TYPE   SOURCE MNTID INODE NAME          TUN.IFACE
  qemu-system-x86 2846033       qemu    48  rw-  CHR misc:tun    23   306 iface=vnet89     vnet89
  qemu-system-x86 2865022       qemu    56  rw-  CHR misc:tun    23   306 iface=vnet103   vnet103
  openvpn         3113730 nm-openvpn     7  rw-  CHR misc:tun   588   306 iface=tun0         tun0
  qemu-system-x86 3608136       qemu    36  rw-  CHR misc:tun    23   306 iface=vnet104   vnet104
  qemu-system-x86 3608136       qemu    39  rw-  CHR misc:tun    23   306 iface=vnet105   vnet105
  qemu-system-x86 3608238       qemu    40  rw-  CHR misc:tun    23   306 iface=vnet106   vnet106
  qemu-system-x86 3608238       qemu    43  rw-  CHR misc:tun    23   306 iface=vnet107   vnet107
  qemu-system-x86 3608338       qemu    54  rw-  CHR misc:tun    23   306 iface=vnet108   vnet108
  qemu-system-x86 3608338       qemu    60  rw-  CHR misc:tun    23   306 iface=vnet109   vnet109

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
fb978312aa lsfd: (refactor) move miscdev specific code to cdev_misc_ops
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
8aa5b7c9d0 lsfd: (refactor) make the way to handle character devices extensible
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Masatake YAMATO
1225e6d0fb lsfd: (refactor) introduce a content data type for char devices
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-27 01:21:42 +09:00
Karel Zak
fb062800be Merge branch 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux
* 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux:
  Add `--user-parent` option to nsenter
2023-06-26 14:04:52 +02:00
Karel Zak
b0d4d09379 cfdisk: fix menu behavior after writing changes
Florian wrote:
  after a successful write, cfdisk remains on the "Write" cursor and
  furthermore when navigating to "Quit" will continue to  show
  "...without writing changes", despite there were writes. This patch
  addresses that.

Based on patch from Florian Zimmermann <florian.zimmermann@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 13:27:11 +02:00
Edward Chron
fa6ac102dc dmesg: -r LOG_MAKEPRI needs fac << 3
Submission to Project: util-linux
Open Incident: #2325 at github.com/util-linux/util-linux/issues/2325
Component: util-linux/sys-utils
File: dmesg.c
Code level patch applied against: 2.39 - latest code pulled from
           git.github.com:util-linux/util-linux.git

BUG: The facility field passed to macro from /usr/include/sys/syslog.h
     LOG_MAKEPRI(fac, pri) by dmesg -r needs to have fac argument
     shifted 3 bit to the left to return a valid raw valid. The lower
     3 bits for a raw value are used by the loglevel priority (pri)
     field, so the facility bits can only occupy the bits above the
     bits used to hold the pri field value.

The dmesg -r command produces the incorrect output for the raw value
for the or'ed combination of the facility | loglevel priority that gets
produced by the LOG_MAKEPRI macro. That macro is defined as:

    #define LOG_MAKEPRI(fac, pri) ((fac) | (pri))

which is defined in the current glibc code in /usr/include/sys/syslog.h
and is used only in the dmesg -r (raw output option) command to form the
raw value for facility or'ed with loglevel priority and displayed as:

    <#>[#######.######] ...

where the # in <#> contains the output from the LOG_MAKEPRI macro.

The lower 3 bits are reserved for the loglevel priority 0-7
and the bits above that are for the facility value, so the facility
index should be shifted to the left three bits and or'ed with the
loglevel priority.

In the glibc file: /usr/include/sys/syslog.h the macro LOG_MAKEPRI is
defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)

and returns the wrong facility and loglevel priority values, ideally it
should be defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac << 3) | (pri))

to return the correct raw value.

We checked with glibc developement and the LOG_MAKEPRI macro is correct
as is and can't be changed as it used by *BSD as is so the solution for
dmesg -r is to shift the facility index left by 3 bits as input to the
LOG_MAKEPRI macro. That is what glibc development recommended.
(For reference, see glibc bugzilla Bug 30563)

We can front end the LOG_MAKEPRI macro with a macro that shifts the
facility by the needed 3 bits which we've added to dmesg.c:

    #define LOG_RAW_FAC_PRI(fac, pri) LOG_MAKEPRI((fac << 3), (pri))

This has been tested and works correctly to produce the correct raw
mode value for Facility or'ed together with Loglevel priority.

You can verify that this fix works correctly.

We can test by adding several records to /dev/kmsg like this:

    echo "<14> Test Message Facility 8 Loglevel 6" >> /dev/kmsg
    echo "<15> Test Message Facility 8 Loglevel 7" >> /dev/kmsg
    echo "<30> Test Message Facility 24 Loglevel 6" >> /dev/kmsg
    echo "<31> Test Message Facility 24 Loglevel 7" >> /dev/kmsg

these commands add 4 records to the dmesg buffer. Then when we print the
records by cat'ing /dev/kmsg or using the dmesg command several ways:

    -bash-4.2# cat /dev/kmsg | grep "Test Message Facility"
    14,1114,495317239,-; Test Message Facility 8 Loglevel 6
    15,1115,503340779,-; Test Message Facility 8 Loglevel 7
    30,1116,643374764,-; Test Message Facility 24 Loglevel 6
    31,1117,657165117,-; Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -S -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

   -bash-4.2# dmesg -S -r | grep "Test Message Facility"
   <14>[  495.317239]  Test Message Facility 8 Loglevel 6
   <15>[  503.340779]  Test Message Facility 8 Loglevel 7
   <30>[  643.374764]  Test Message Facility 24 Loglevel 6
   <31>[  657.165117]  Test Message Facility 24 Loglevel 7

All the above methods agree in their output as expected.
However, running dmesg -r does not agree.

dmesg -r erronously produces:
----------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <7>[  495.317239]  Test Message Facility 8 Loglevel 6
    <7>[  503.340779]  Test Message Facility 8 Loglevel 7
    <7>[  643.374764]  Test Message Facility 24 Loglevel 6
    <7>[  657.165117]  Test Message Facility 24 Loglevel 7

However, if we run the dmesg -r command using the new front end macro
LOG_RAW_FAC_PRI(fac, pri) we do get the correct output:

Here is the corrected dmesg -r output:
-------------------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <14>[  495.317239]  Test Message Facility 8 Loglevel 6
    <15>[  503.340779]  Test Message Facility 8 Loglevel 7
    <30>[  643.374764]  Test Message Facility 24 Loglevel 6
    <31>[  657.165117]  Test Message Facility 24 Loglevel 7

shifting the facility index value by 3 bits in the LOG_RAW_FAC_PRI macro
provides the correct ouput as shown. All the other commands produce the
same output so now they are all in agreement.

Signed-off-by: Ivan Delalande <colona@arista.com>
Signed-off-by: Edward Chron <echron@arista.com>
2023-06-26 13:27:02 +02:00
Karel Zak
08b35072b9 build-sys: don't call pkg-config --static if unnecessary
Addresses: https://github.com/util-linux/util-linux/issues/2327
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 12:48:30 +02:00
Karel Zak
3a4d70419c logger: initialize socket credentials contol union
Addresses: https://github.com/util-linux/util-linux/issues/2336
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-06-26 11:56:23 +02:00
Karel Zak
0904cff4a5 Merge branch 'unshare/time-msg' of https://github.com/t-8ch/util-linux
* 'unshare/time-msg' of https://github.com/t-8ch/util-linux:
  unshare: fix error message for unexpected time offsets
2023-06-26 11:50:02 +02:00
Karel Zak
ceb13fa9e8 Merge branch 'test/builddir-pwd' of https://github.com/t-8ch/util-linux
* 'test/builddir-pwd' of https://github.com/t-8ch/util-linux:
  tests: (run.sh) detect builddir from working directory
2023-06-26 11:49:43 +02:00
Karel Zak
55b0cc7106 Merge branch 'losetup-errormsg' of https://github.com/t-8ch/util-linux
* 'losetup-errormsg' of https://github.com/t-8ch/util-linux:
  losetup: deduplicate find_unused() logic
  lib/loopdev: consistently return error values from loopcxt_find_unused()
  lib/loopdev: document function return values
2023-06-26 11:49:20 +02:00
Karel Zak
69e7e599c0 Merge branch 'hardlink' of https://github.com/jwilk-forks/util-linux
* 'hardlink' of https://github.com/jwilk-forks/util-linux:
  hardlink: (man) add missing comma
2023-06-26 11:48:43 +02:00
Karel Zak
c0ac6d590a Merge branch 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux
* 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux:
  lsfd: fix specifying wrong JSON typs when building the help message
  tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
2023-06-26 11:48:24 +02:00
Karel Zak
c985e0742e Merge branch 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work
* 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work:
  libmount: add sample to test fs and context relation
  libmount: fix sync options between context and fs structs
2023-06-26 11:45:50 +02:00
Thomas Weißschuh
2da0200327 unshare: fix error message for unexpected time offsets
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 13:28:19 +02:00
Thomas Weißschuh
af9fc22d03 losetup: deduplicate find_unused() logic
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:06:21 +02:00
Thomas Weißschuh
3c5402640d lib/loopdev: consistently return error values from loopcxt_find_unused()
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:06:21 +02:00
Thomas Weißschuh
af5efcd810 lib/loopdev: document function return values
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 10:04:39 +02:00
Thomas Weißschuh
dc1d0f8dd1 tests: (run.sh) detect builddir from working directory
This makes it easier to run test.sh from the build directory as
everything will work without any parameters irrespective of the build
directories name.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-25 09:06:47 +02:00
Jakub Wilk
4bcc2ed30d hardlink: (man) add missing comma 2023-06-24 09:24:29 +02:00
igo95862
01a6d803b5
Add --user-parent option to nsenter
When this option is used nsenter will fetch the parent user
namespace from any namespace file descriptors available.

It can be combined with existing `--user` option in which case
the parent user namespace will be fetched from the user namespace
and replace it.

The usecase of this option is when a user namespace that owns
the other type namespaces we want to switch to is not actually
bound to any process. Without using ioctl it is impossible to
acquire namespace file descriptor. For example, bubblewrap
`bwrap` command creates unbinded user namespace when `--dev`
option is used.
2023-06-23 00:26:13 +06:00
Masatake YAMATO
253c991da1 lsfd: fix specifying wrong JSON typs when building the help message
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2023-06-23 01:10:04 +09:00