]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
2 years agomeson: install examples to correct directory
Thomas Weißschuh [Thu, 30 Dec 2021 15:33:33 +0000 (16:33 +0100)] 
meson: install examples to correct directory

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agomeson: headers: Install headers
Thomas Weißschuh [Thu, 30 Dec 2021 15:31:10 +0000 (16:31 +0100)] 
meson: headers: Install headers

Fixes #1365

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agomeson: headers: use util-linux version of version defines
Thomas Weißschuh [Thu, 30 Dec 2021 15:30:14 +0000 (16:30 +0100)] 
meson: headers: use util-linux version of version defines

This matches what autotools is doing.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agosu: Verify default SIGCHLD handling.
Tobias Stoeckmann [Sat, 23 Oct 2021 11:44:23 +0000 (13:44 +0200)] 
su: Verify default SIGCHLD handling.

The SIGCHLD handler could have been ignored by parent process.
Make sure that we have default handling activated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 years agofindmnt: (verify) add hint about systemctl daemon-reload
Karel Zak [Mon, 13 Dec 2021 12:34:42 +0000 (13:34 +0100)] 
findmnt: (verify) add hint about systemctl daemon-reload

Let's inform that systemd uses stuff older than fstab.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agomount: add hint about systemctl daemon-reload
Karel Zak [Mon, 13 Dec 2021 12:22:56 +0000 (13:22 +0100)] 
mount: add hint about systemctl daemon-reload

This commit implements an extra hint for systemd based distros to
inform users that units currently used by systemd are older than
fstab.  This situation is usually unwanted, and 'systemctl
daemon-reload' is recommended.

The message is printed only on terminal to avoid extra messages in
logs, etc.

Addresses: https://github.com/systemd/systemd/pull/20476
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoinclude/c: add cmp_timespec() and cmp_stat_mtime()
Karel Zak [Mon, 13 Dec 2021 12:19:18 +0000 (13:19 +0100)] 
include/c: add cmp_timespec() and cmp_stat_mtime()

It's like timercmp() in libc, but for timespec and for stat.st_mtim
(or stat.st_mtime for old struct stat versions).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agobuild-sys: add USE_SYSTEMD
Karel Zak [Mon, 13 Dec 2021 12:13:05 +0000 (13:13 +0100)] 
build-sys: add USE_SYSTEMD

Add info that systemd support is expected for tools where we do not
link with any systemd libs, but we want to support some systemd stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: check blkid_get_cache() return value [coverity scan]
Karel Zak [Fri, 10 Dec 2021 15:22:07 +0000 (16:22 +0100)] 
libblkid: check blkid_get_cache() return value [coverity scan]

CID 374488:  Error handling issues  (CHECKED_RETURN)
Calling "blkid_get_cache" without checking return value (as is done elsewhere 4 out of 5 times).

It's probably unnecessary as we check the cache pointer later, but let's
make it more robust for static analyzers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'lsfd-blkdev' of https://github.com/masatake/util-linux
Karel Zak [Fri, 10 Dec 2021 14:20:28 +0000 (15:20 +0100)] 
Merge branch 'lsfd-blkdev' of https://github.com/masatake/util-linux

* 'lsfd-blkdev' of https://github.com/masatake/util-linux:
  tests: (lsfd) call ts_skip_nonroot earlier
  lsfd: fix a typo in comment
  lsfd: declare local variables at the beginning of block
  tests: (lsfd) add a case for listing a fd opening a block device
  tests: (lsfd) add a factory for opening a block device to the helper command
  lsfd: use the list of block devices in /proc/devices for decoding SOURCE column
  lsfd: add a helper function for reading bdevs in /prode/devices
  lsfd: move the code for reading /proc/devices to lsfd.c

2 years agolibblkid/src/probe: check for ENOMEDIUM from ioctl(CDROM_LAST_WRITTEN)
Jeremi Piotrowski [Wed, 8 Dec 2021 17:09:53 +0000 (09:09 -0800)] 
libblkid/src/probe: check for ENOMEDIUM from ioctl(CDROM_LAST_WRITTEN)

The CD device on Azure VMs returns CDS_DISC_OK from CDROM_DRIVE_STATUS even
when no disc is present. In that case an ENOMEDIUM from CDROM_LAST_WRITTEN
follows. Catch that and return error to prevent probing which results in
hundreds of "unaligned transfer" warnings in the kernel logbuffer.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2 years agotests: (lsfd) call ts_skip_nonroot earlier
Masatake YAMATO [Wed, 8 Dec 2021 15:33:49 +0000 (00:33 +0900)] 
tests: (lsfd) call ts_skip_nonroot earlier

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: fix a typo in comment
Masatake YAMATO [Wed, 8 Dec 2021 06:11:05 +0000 (15:11 +0900)] 
lsfd: fix a typo in comment

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: declare local variables at the beginning of block
Masatake YAMATO [Wed, 8 Dec 2021 05:55:06 +0000 (14:55 +0900)] 
lsfd: declare local variables at the beginning of block

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) add a case for listing a fd opening a block device
Masatake YAMATO [Wed, 8 Dec 2021 15:44:50 +0000 (00:44 +0900)] 
tests: (lsfd) add a case for listing a fd opening a block device

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) add a factory for opening a block device to the helper command
Masatake YAMATO [Wed, 8 Dec 2021 13:30:57 +0000 (22:30 +0900)] 
tests: (lsfd) add a factory for opening a block device to the helper command

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agofindmnt: add SOURCES column to print all devices with the same tag
Karel Zak [Thu, 9 Dec 2021 12:20:50 +0000 (13:20 +0100)] 
findmnt: add SOURCES column to print all devices with the same tag

It's the same like TARGETS for lsblk (the same device is possible to
mount on more mountpoints). Here in findmnt we support by a new column
SOURCES scenario when more devices (filesystems) use the same tag
(LABEL, UUID, e.g.).

For example:

$ findmnt --fstab -oTARGET,SOURCES --evaluate --json UUID=b45897ca-ffc4-4089-8404-5d6072f5aee1
{
   "filesystems": [
      {
         "target": "/mnt/test",
         "sources": [
             "/dev/sdb1", "/dev/sdc"
         ]
      }
   ]
}

Fixes: https://github.com/util-linux/util-linux/issues/1078
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agosfdisk add --backup-pt-sectors
Karel Zak [Thu, 9 Dec 2021 11:07:16 +0000 (12:07 +0100)] 
sfdisk add --backup-pt-sectors

The current option --backup is usable only when used with others sfdisk
commands. The new command --backup-pt-sectors create backup and exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoisfdisk: improve --backup documentation
Karel Zak [Thu, 9 Dec 2021 09:56:07 +0000 (10:56 +0100)] 
isfdisk: improve --backup documentation

* add reference to backup section
* add note that backup is done always after startup
* remove TODO item about --backup, it seems that back after open is
  only way how we can make it with current libfdisk, because
  fdisk_locate_disklabel() returns current in-memory rather than on-disk
  situation.

Addresses: https://github.com/util-linux/util-linux/issues/850
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolslocks: add INODE and MAJ:MIN columns
Karel Zak [Wed, 8 Dec 2021 15:55:03 +0000 (16:55 +0100)] 
lslocks: add INODE and MAJ:MIN columns

This is useful for use-cases (for example shell scripts) where
we cannot filter by PIDs.

Addresses: https://github.com/util-linux/util-linux/issues/1527
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: use the list of block devices in /proc/devices for decoding SOURCE column
Masatake YAMATO [Wed, 8 Dec 2021 14:41:52 +0000 (23:41 +0900)] 
lsfd: use the list of block devices in /proc/devices for decoding SOURCE column

For decoding the SOURCE column of a fd opening a block devices, the
origina code uses /proc/partitions only. However, this is not enough
for decoding /dev/nullb0. Though is is a block device node, the block
device behind the node is not listed in /proc/partitions.

This change uses the information min /proc/devices as the fallback of
/proc/partitions.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add a helper function for reading bdevs in /prode/devices
Masatake YAMATO [Wed, 8 Dec 2021 14:48:09 +0000 (23:48 +0900)] 
lsfd: add a helper function for reading bdevs in /prode/devices

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: move the code for reading /proc/devices to lsfd.c
Masatake YAMATO [Wed, 8 Dec 2021 14:02:45 +0000 (23:02 +0900)] 
lsfd: move the code for reading /proc/devices to lsfd.c

The original code is only for reading the names of character device
drivers. For making the code reusable in reading that of block device
drivers, rearrange the code an move it to the common area, lsfd.c.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agoprlimit: make syscall use more robust
Karel Zak [Wed, 8 Dec 2021 14:17:01 +0000 (15:17 +0100)] 
prlimit: make syscall use more robust

This is only cosmetic change to make code robust and compatible with
other spaces where we use syscall().

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'patch-1' of https://github.com/Delapouite/util-linux
Karel Zak [Wed, 8 Dec 2021 13:16:08 +0000 (14:16 +0100)] 
Merge branch 'patch-1' of https://github.com/Delapouite/util-linux

* 'patch-1' of https://github.com/Delapouite/util-linux:
  uuidgen.1.adoc: mention uuidparse in SEE ALSO

2 years agoMerge branch 'fix-overflow' of https://github.com/ChanthMiao/util-linux
Karel Zak [Wed, 8 Dec 2021 13:15:14 +0000 (14:15 +0100)] 
Merge branch 'fix-overflow' of https://github.com/ChanthMiao/util-linux

* 'fix-overflow' of https://github.com/ChanthMiao/util-linux:
  Fix integer overflow for alpha like linux

2 years agoMerge branch 'patch-2' of https://github.com/mariobl/util-linux
Karel Zak [Wed, 8 Dec 2021 13:13:36 +0000 (14:13 +0100)] 
Merge branch 'patch-2' of https://github.com/mariobl/util-linux

* 'patch-2' of https://github.com/mariobl/util-linux:
  lsfd.1.adoc: Improve punctuation and add translator comments
  lsfd.1.adoc: Fix yet another entry in the filter examples list
  lsfd.1.adoc: Fix wording and markup

2 years agouuidgen.1.adoc: mention uuidparse in SEE ALSO
Bruno Heridet [Tue, 7 Dec 2021 06:56:22 +0000 (07:56 +0100)] 
uuidgen.1.adoc: mention uuidparse in SEE ALSO

This indication mirrors the one found in uuidparse.1.adoc

2 years agolsfd.1.adoc: Improve punctuation and add translator comments
Mario Blättermann [Mon, 6 Dec 2021 19:11:17 +0000 (20:11 +0100)] 
lsfd.1.adoc: Improve punctuation and add translator comments

2 years agohardlink: make reflink detection more robust [coverity scan]
Karel Zak [Mon, 6 Dec 2021 09:39:00 +0000 (10:39 +0100)] 
hardlink: make reflink detection more robust [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoFix integer overflow for alpha like linux
chanthmiao [Sun, 5 Dec 2021 08:58:17 +0000 (16:58 +0800)] 
Fix integer overflow for alpha like linux

2 years agolsfd.1.adoc: Fix yet another entry in the filter examples list
Mario Blättermann [Thu, 2 Dec 2021 19:59:02 +0000 (20:59 +0100)] 
lsfd.1.adoc: Fix yet another entry in the filter examples list

2 years agolsfd.1.adoc: Fix wording and markup
Mario Blättermann [Thu, 2 Dec 2021 19:41:14 +0000 (20:41 +0100)] 
lsfd.1.adoc: Fix wording and markup

2 years agohardlink: use open(O_CREAT) with mode
Karel Zak [Thu, 2 Dec 2021 14:00:44 +0000 (15:00 +0100)] 
hardlink: use open(O_CREAT) with mode

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: update hardlink output
Karel Zak [Thu, 2 Dec 2021 13:25:59 +0000 (14:25 +0100)] 
tests: update hardlink output

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: add reflinks support (add --reflinks and --skip-reflinks)
Karel Zak [Thu, 2 Dec 2021 13:15:49 +0000 (14:15 +0100)] 
hardlink: add reflinks support (add --reflinks and --skip-reflinks)

Let's make XFS and BTRFS users more happy. The option --skip-reflinks
forces hardlink to detect files with shared extends and --reflinks
forces hardlink to create clones (FICLONE ioctl) rather than
hardlinks.

Addresses: https://github.com/util-linux/util-linux/issues/1447
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: fix memory leak [coverity scan]
Karel Zak [Thu, 2 Dec 2021 09:24:56 +0000 (10:24 +0100)] 
unshare: fix memory leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: call size_to_human_string() only when necessary
Karel Zak [Wed, 1 Dec 2021 14:42:52 +0000 (15:42 +0100)] 
hardlink: call size_to_human_string() only when necessary

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: simplify file_link()
Karel Zak [Wed, 1 Dec 2021 14:38:50 +0000 (15:38 +0100)] 
hardlink: simplify file_link()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: Document --map-{groups,users,auto}
Sean Anderson [Wed, 24 Nov 2021 18:26:18 +0000 (13:26 -0500)] 
unshare: Document --map-{groups,users,auto}

This documents the new options added in the previous few commits.
I have added another example to better demonstrate the these
options. The actual use is fairly straightforward, but the descriptions
are on the pithier side.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add option to automatically create user and group maps
Sean Anderson [Wed, 24 Nov 2021 18:26:17 +0000 (13:26 -0500)] 
unshare: Add option to automatically create user and group maps

This option is designed to handle the "garden path" user/group ID
mapping:

- The user has one big map in /etc/sub[u,g]id
- The user wants to map as many user and group IDs as they can,
  especially the first 1000 users and groups.

The "auto" map is designed to handle this. We find the first map
matching the current user, and then map the whole thing to the ID range
starting at ID 0.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add options to map blocks of user/group IDs
Sean Anderson [Wed, 24 Nov 2021 18:26:16 +0000 (13:26 -0500)] 
unshare: Add options to map blocks of user/group IDs

This adds the ability to map multiple user/group IDs when creating a new
user namespace. Regular processes cannot map any user other than the
effective user, so we need to use the setuid helpers newuidmap and
newgidmap, provided by shadow. Typically, users will be assigned blocks
of user/group IDs in /etc/sub{u,g}id, although it is also possible to
use NSS. There is a second advantage in using these helpers: because we
never write to /proc/self/gid_map, we don't have to disable setgroups.

Because the process of mapping IDs is almost identical, whether we are
mapping user IDs or group IDs, we put both in a common "map_range"
structure. These are read in by (ab)using string_to_idarray. In addition
to any map created with --map-users, we still need to handle a map of
size one created with --map-user. This makes constructing the helpers'
command line the trickiest part of the whole process. newuidmap/
newgidmap check to see if any ranges overlap before creating a mapping.
To avoid failing, we carve out a hole in the mapping for the singular
map. In the worst case, we may have three separate maps.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add some helpers for forking and synchronizing
Sean Anderson [Wed, 24 Nov 2021 18:26:15 +0000 (13:26 -0500)] 
unshare: Add some helpers for forking and synchronizing

There is (or rather, will be) a common pattern in unshare like

/* parent */ /* child */
fork()
do_some_work()
sync() wait();
do_more_work();
wait() exit();

where the parent has to do some tasks (unshare(), fork() again, etc)
before the child can do its work. At the moment this is implemented
explicitly with a pipe().

Add some helper functions to abstract this process away. In addition,
switch to eventfd() instead of pipe(). As the man page for eventfd(2)
notes,

> Applications can use an eventfd file descriptor instead of a pipe (see
> pipe(2)) in all cases where a pipe is used simply to signal events. The
> kernel overhead of an eventfd file descriptor is much lower than that of
> a pipe, and only one file descriptor is required (versus the two required
> for a pipe).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add waitchild helper
Sean Anderson [Wed, 24 Nov 2021 18:26:14 +0000 (13:26 -0500)] 
unshare: Add waitchild helper

This refactors out the waitpid() logic into a function which will be
reused for the upcoming patches.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agoinclude/c: Add abs_diff macro
Sean Anderson [Wed, 24 Nov 2021 18:26:13 +0000 (13:26 -0500)] 
include/c: Add abs_diff macro

This macro calculates abs(a - b). It is especially useful for unsigned
numbers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agolibmount: disable mtab only on statfs() success only
Karel Zak [Wed, 1 Dec 2021 11:35:42 +0000 (12:35 +0100)] 
libmount: disable mtab only on statfs() success only

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsns: fix compilation on old systems without linux/nsfs.h
Karel Zak [Tue, 30 Nov 2021 14:02:10 +0000 (15:02 +0100)] 
lsns: fix compilation on old systems without linux/nsfs.h

Addresses: https://github.com/util-linux/util-linux/pull/1521
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolscpu: (arm) remove extra whitespace
Karel Zak [Tue, 30 Nov 2021 13:24:40 +0000 (14:24 +0100)] 
lscpu: (arm) remove extra whitespace

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'mantypo' of https://github.com/vice/util-linux
Karel Zak [Tue, 30 Nov 2021 13:21:38 +0000 (14:21 +0100)] 
Merge branch 'mantypo' of https://github.com/vice/util-linux

* 'mantypo' of https://github.com/vice/util-linux:
  script.1.adoc: correct socond as second

2 years agoscript.1.adoc: correct socond as second
Vicente Jimenez Aguilar [Tue, 30 Nov 2021 11:07:54 +0000 (12:07 +0100)] 
script.1.adoc: correct socond as second

2 years agoAdd Earlier Phytium cores
panchenbo [Tue, 30 Nov 2021 06:25:57 +0000 (14:25 +0800)] 
Add Earlier Phytium cores

2 years agoMerge branch 'lsfd-test-normalize-protoname' of https://github.com/masatake/util...
Karel Zak [Mon, 29 Nov 2021 15:06:30 +0000 (16:06 +0100)] 
Merge branch 'lsfd-test-normalize-protoname' of https://github.com/masatake/util-linux

* 'lsfd-test-normalize-protoname' of https://github.com/masatake/util-linux:
  tests: (lsfd) normalize protoname before comparing

2 years agoMerge branch 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux
Karel Zak [Mon, 29 Nov 2021 15:04:53 +0000 (16:04 +0100)] 
Merge branch 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux

* 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux:
  tests: (lsfd) fix file descriptor leaks reported by coverity

2 years agoMerge branch 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux
Karel Zak [Mon, 29 Nov 2021 15:03:40 +0000 (16:03 +0100)] 
Merge branch 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux

* 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux:
  tests: (lsfd) give missing test descriptions
  tests: (lsfd) don't compare inodes

2 years agoirqtop: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:32:27 +0000 (15:32 +0100)] 
irqtop: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohwclock: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:30:10 +0000 (15:30 +0100)] 
hwclock: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoutmpdump: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:26:49 +0000 (15:26 +0100)] 
utmpdump: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: ignore scanf() result when read number of stripes [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:21:55 +0000 (15:21 +0100)] 
libblkid: ignore scanf() result when read number of stripes [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: (lsfd) fix file descriptor leaks reported by coverity
Masatake YAMATO [Mon, 29 Nov 2021 14:04:04 +0000 (23:04 +0900)] 
tests: (lsfd) fix file descriptor leaks reported by coverity

The oldfd argument of dup2 is not closed automatically.
It must be closed explicitly.

Close #1517.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) give missing test descriptions
Masatake YAMATO [Mon, 29 Nov 2021 14:12:23 +0000 (23:12 +0900)] 
tests: (lsfd) give missing test descriptions

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) don't compare inodes
Masatake YAMATO [Mon, 29 Nov 2021 14:01:04 +0000 (23:01 +0900)] 
tests: (lsfd) don't compare inodes

The numbers for the inodes (cwd and rtd) are different in platforms
(or file systems).

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) normalize protoname before comparing
Masatake YAMATO [Mon, 29 Nov 2021 13:26:03 +0000 (22:26 +0900)] 
tests: (lsfd) normalize protoname before comparing

This is a follow-up commit to a60ac11fe0087584f37329b4733edfade3452c64.

>    In the commit, the protoname of (AF_UNIX, SOCK_DGRAM) sockets was also
>    changed to "UNIX-DGRAM". However, it was renamed back to "UNIX" in
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0edf0824e0dc359ed76bf96af986e6570ca2c0b9

To make this test case more portable, this change makes the test case
accept "UINX-DGRAM" in addition to "UINX", too.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: check ul_strtou*() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 13:00:42 +0000 (14:00 +0100)] 
lsfd: check ul_strtou*() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: fix copy & past error [coverity scan]
Karel Zak [Mon, 29 Nov 2021 12:46:17 +0000 (13:46 +0100)] 
lsfd: fix copy & past error [coverity scan]

1235            if (right->type != NODE_NUM) {
1236                    snprintf(parser->errmsg, ERRMSG_LEN,
1237                             _("error: unexpected right operand type %s for: %s"),
>>>     CID 374358:  Incorrect expression  (COPY_PASTE_ERROR)
>>>     "left" in "left->type" looks like a copy-paste error.
1238                             NODE_CLASS(left)->name,
1239                             op2_class->name);
1240                    return false;
1241            }

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: fix use-after-free and resource leak [coverity scan]
Karel Zak [Mon, 29 Nov 2021 12:41:36 +0000 (13:41 +0100)] 
lsfd: fix use-after-free and resource leak [coverity scan]

>>>     CID 374363:  Memory - illegal accesses  (USE_AFTER_FREE)
>>>     Dereferencing freed pointer "t".
764                             snprintf(parser->errmsg, ERRMSG_LEN,
765                                      _("error: unsupported column data type: %d, column: %s"),
766                                      jtype, t->val.str);

856             default:
857                     warnx("unexpected token type: %d", t->type);
>>>     CID 374360:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "t" going out of scope leaks the storage it points to.
858                     return NULL;

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: make sure we do not use uninitialized struct stat [coverity scan]
Karel Zak [Mon, 29 Nov 2021 12:35:35 +0000 (13:35 +0100)] 
lsfd: make sure we do not use uninitialized struct stat [coverity scan]

540             if (is_association(f, NS_MNT))
>>>     CID 374364:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "sb.st_ino".
541                     proc->ns_mnt = sb.st_ino;

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolib/path: make path use more robust [coverity scan]
Karel Zak [Mon, 29 Nov 2021 12:25:16 +0000 (13:25 +0100)] 
lib/path: make path use more robust [coverity scan]

*** CID 374365:  Null pointer dereferences  (FORWARD_NULL)
/lib/path.c: 364 in ul_path_stat()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolslocks: check scanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 12:11:13 +0000 (13:11 +0100)] 
lslocks: check scanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux
Karel Zak [Mon, 29 Nov 2021 10:13:00 +0000 (11:13 +0100)] 
Merge branch 'patch-1' of https://github.com/ThomasKaiser/util-linux

* 'patch-1' of https://github.com/ThomasKaiser/util-linux:
  Add Apple cores, fix Phytium core names

2 years agoMerge branch 'master' of https://github.com/AndrewGMorgan/util-linux
Karel Zak [Mon, 29 Nov 2021 10:08:05 +0000 (11:08 +0100)] 
Merge branch 'master' of https://github.com/AndrewGMorgan/util-linux

2 years agoMerge branch 'lsfd-testcase-for-socketpair' of https://github.com/masatake/util-linux
Karel Zak [Mon, 29 Nov 2021 10:06:58 +0000 (11:06 +0100)] 
Merge branch 'lsfd-testcase-for-socketpair' of https://github.com/masatake/util-linux

2 years agoMerge branch 'lsfd' of https://github.com/mator/util-linux
Karel Zak [Mon, 29 Nov 2021 10:05:12 +0000 (11:05 +0100)] 
Merge branch 'lsfd' of https://github.com/mator/util-linux

* 'lsfd' of https://github.com/mator/util-linux:
  build-sys: add configure option to disable lsfd
  don't build lsfd, if linux header kcmp.h is missing

2 years agoAdd Apple cores, fix Phytium core names
ThomasKaiser [Sun, 28 Nov 2021 15:39:47 +0000 (16:39 +0100)] 
Add Apple cores, fix Phytium core names

See https://www.spinics.net/lists/arm-kernel/msg879381.html and https://en.wikipedia.org/wiki/FeiTeng_(processor)#Future_processors (S2500 and D2000 are SoCs and contain 4 or 8 FTC663 cores).

2 years agoComplete Linux-PAM compliance for forked child in su and login.
Andrew G. Morgan [Sun, 28 Nov 2021 05:00:22 +0000 (21:00 -0800)] 
Complete Linux-PAM compliance for forked child in su and login.

As documented here:

http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end

The child that is about to exec*() the user shell is supposed to pam_end()
with PAM_DATA_SILENT. This gives the modules a last chance to do a minor
cleanup of the module state before the user's shell is launched.

Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2 years agosfdisk man: Escape ((…)) to avoid AsciiDoc interpreting and stripping from manpage
Paul Sarena [Sat, 27 Nov 2021 02:14:25 +0000 (18:14 -0800)] 
sfdisk man: Escape ((…)) to avoid AsciiDoc interpreting and stripping from manpage

2 years agotests: (lsfd) make DGRAM socketpair to mitigate the change of protoname
Masatake YAMATO [Sat, 27 Nov 2021 00:39:42 +0000 (09:39 +0900)] 
tests: (lsfd) make DGRAM socketpair to mitigate the change of protoname

The protoname for a socket can be get from its xattr slot of
/proc/$PID/fd/$FD.

The protoname for (AF_UNIX, SOCK_STREAM) sockets was changed
from "UNIX" to "UNIX-STREAM" in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=94531cfcbe79c3598acf96806627b2137ca32eb9

As the result, the test case, mkfds-socketpair doesn't work well on a
newer kernel.

To mitigate the impact of the change in the kernel, use (AF_UNIX, SOCK_DGRAM)
for making a socket pair.

In the commit, the protoname of (AF_UNIX, SOCK_DGRAM) sockets was also
changed to "UNIX-DGRAM". However, it was renamed back to "UNIX" in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0edf0824e0dc359ed76bf96af986e6570ca2c0b9

Partially close #1511.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agobuild-sys: add configure option to disable lsfd
Anatoly Pugachev [Fri, 26 Nov 2021 23:48:28 +0000 (02:48 +0300)] 
build-sys: add configure option to disable lsfd

2 years agodon't build lsfd, if linux header kcmp.h is missing
Anatoly Pugachev [Fri, 26 Nov 2021 17:28:00 +0000 (20:28 +0300)] 
don't build lsfd, if linux header kcmp.h is missing

2 years agoEscape ((…)) in AsciiDoc to fix broken example
Paul Sarena [Fri, 26 Nov 2021 23:34:02 +0000 (15:34 -0800)] 
Escape ((…)) in AsciiDoc to fix broken example

In AsciiDoc, double parentheses are used to mark flow index terms, but in this document, their use is intended to be interpreted by the shell's arithmetic expansion.  By escaping them with a backslash in the AsciiDoc, they pass through as-is to the manpage and other targets.

So, instead of a rendered result of `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=$0x00000438 bs=1 conv=notrunc`, we get `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=$((0x00000438)) bs=1 conv=notrunc`.

Seperately, when interpreted by a shell's arithmetic expansion, the 0x00000438 hex is converted to decimal 1080 `dd if=~/wipefs-sdb-0x00000438.bak of=/dev/sdb seek=1080 bs=1 conv=notrunc`

2 years agohardlink: fix compiler warning [-Wformat=]
Karel Zak [Fri, 26 Nov 2021 18:45:29 +0000 (19:45 +0100)] 
hardlink: fix compiler warning [-Wformat=]

misc-utils/hardlink.c:726:48: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘__nlink_t’

Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'topic/lsfd'
Karel Zak [Fri, 26 Nov 2021 11:12:54 +0000 (12:12 +0100)] 
Merge branch 'topic/lsfd'

2 years agoMerge branch 'patch-3' of https://github.com/Hello71/util-linux
Karel Zak [Thu, 25 Nov 2021 11:35:24 +0000 (12:35 +0100)] 
Merge branch 'patch-3' of https://github.com/Hello71/util-linux

* 'patch-3' of https://github.com/Hello71/util-linux:
  loopdev: accept ENOSYS for LOOP_CONFIGURE

2 years agoblkid: check device type and name before probe
Karel Zak [Thu, 25 Nov 2021 10:54:26 +0000 (11:54 +0100)] 
blkid: check device type and name before probe

For calls "blkid /dev/*", it seems better to check the
device type and name before we open the device in libblkid.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2026511
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: check UBI char device name
Karel Zak [Thu, 25 Nov 2021 10:54:11 +0000 (11:54 +0100)] 
libblkid: check UBI char device name

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolib/sys: add sysfs_chrdev_devno_to_devname()
Karel Zak [Thu, 25 Nov 2021 10:52:46 +0000 (11:52 +0100)] 
lib/sys: add sysfs_chrdev_devno_to_devname()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoloopdev: accept ENOSYS for LOOP_CONFIGURE
Alex Xu [Wed, 24 Nov 2021 20:34:10 +0000 (20:34 +0000)] 
loopdev: accept ENOSYS for LOOP_CONFIGURE

qemu returns this if it doesn't understand the ioctl. according to ioctl(2) it should actually return EINVAL, but considering that it's been doing this for at least 20 years already, I doubt there's much appetite for change, considering that it has a slightly better error message if propagated back to the user and changing it to EINVAL may break other programs.

2 years agolsfd: cleanup --summary semantic
Karel Zak [Wed, 24 Nov 2021 14:00:45 +0000 (15:00 +0100)] 
lsfd: cleanup --summary semantic

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agofindmnt: add support to print deleted targets
Karel Zak [Wed, 24 Nov 2021 11:22:27 +0000 (12:22 +0100)] 
findmnt: add support to print deleted targets

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: add mnt_fs_is_deleted()
Karel Zak [Wed, 24 Nov 2021 11:20:15 +0000 (12:20 +0100)] 
libmount: add mnt_fs_is_deleted()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agonsenter: add --wdns to change working directory
Karel Zak [Mon, 22 Nov 2021 12:18:54 +0000 (13:18 +0100)] 
nsenter: add --wdns to change working directory

The current --wd=<dir> changes CWD to the path which is opened
*before* nsenter calls setns(). It may be useful if you want to use in
namespace something from your current namespace.  In this case, the
option --wd works like a "tunnel" between namespaces.

For some other use-cases, this is useless and you want to be sure that
CWD always points to the target namespace. For this purpose this patch
implements --wdns <dir>.

Example:

 Setup the namespaces:

  # unshare --mount
  # mount /dev/sdc /mnt/A
  # touch /mnt/A/fooooo
  # echo $$
  2425872

 Enter the namespace from another session:

  # nsenter --all --target 2425872 --wd=/mnt/A ls -a
  .  ..

  # nsenter --all --target 2425872 --wdns=/mnt/A ls -a
  .  ..  fooooo  lost+found

Fixes: https://github.com/util-linux/util-linux/issues/1500
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agologin: (adoc) add hint about PAM and env.variables
Karel Zak [Mon, 22 Nov 2021 09:34:14 +0000 (10:34 +0100)] 
login: (adoc) add hint about PAM and env.variables

Fixes: https://github.com/util-linux/util-linux/issues/1507
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoflock: (adoc) fix example
Karel Zak [Mon, 22 Nov 2021 09:23:52 +0000 (10:23 +0100)] 
flock: (adoc) fix example

Fixes: https://github.com/util-linux/util-linux/issues/1506
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoscript: (adoc) improve man page readability
Karel Zak [Mon, 22 Nov 2021 09:22:09 +0000 (10:22 +0100)] 
script: (adoc) improve man page readability

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: don't mark cache as "probed" if /sys not available
Karel Zak [Fri, 19 Nov 2021 13:19:03 +0000 (14:19 +0100)] 
libblkid: don't mark cache as "probed" if /sys not available

For "mount --all" we need to read the cache more than once in a short
time. The library checks the delay between probes, and if the delay is
too short, it does not read devices. This is a problem on boot when there
are no /sys, and the cache is empty. In this case, we need to check
for /sys until it's available constantly.

https://github.com/util-linux/util-linux/issues/1492
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolslogins: remove unwanted debug message
Karel Zak [Fri, 19 Nov 2021 11:55:54 +0000 (12:55 +0100)] 
lslogins: remove unwanted debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: add --dump-counters option
Masatake YAMATO [Thu, 18 Nov 2021 15:14:50 +0000 (00:14 +0900)] 
lsfd: add --dump-counters option

User may wonder how the built-in counters are defined.
Describing their definitions in lsfd(1) is one of choice.
However, the definitions may drastically change in the future
development.

--dump-counters option is for making lsfd self descriptive.
Users who understand the filter expressions can understand
directly the meaning of the counters.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd.1.doc: write anout --summary and --counter options
Masatake YAMATO [Thu, 18 Nov 2021 15:11:13 +0000 (00:11 +0900)] 
lsfd.1.doc: write anout --summary and --counter options

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: implement --summary and --counter options
Masatake YAMATO [Sun, 31 Oct 2021 19:52:48 +0000 (04:52 +0900)] 
lsfd: implement --summary and --counter options

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add a helper function for building filter
Masatake YAMATO [Fri, 29 Oct 2021 21:53:30 +0000 (06:53 +0900)] 
lsfd: add a helper function for building filter

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (filter) make some data structures its source file local
Masatake YAMATO [Sat, 13 Nov 2021 10:48:16 +0000 (19:48 +0900)] 
lsfd: (filter) make some data structures its source file local

Unintentionally they were extern'ed.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>