]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
3 years agoFix misspellings
Rafael Fontenelle [Sat, 4 Sep 2021 14:11:04 +0000 (11:11 -0300)] 
Fix misspellings

3 years agotests: Skip lsns/ioctl_ns test if unshare fails
Chris Hofstaedtler [Fri, 20 Aug 2021 10:30:50 +0000 (10:30 +0000)] 
tests: Skip lsns/ioctl_ns test if unshare fails

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>
3 years agosu: (bash-completion) offer usernames rather than files
Karel Zak [Tue, 31 Aug 2021 10:51:40 +0000 (12:51 +0200)] 
su: (bash-completion) offer usernames rather than files

Fixes: https://github.com/karelzak/util-linux/issues/1424
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agocolumn: segmentation fault on invalid unicode input passed to -s option
Karel Zak [Tue, 31 Aug 2021 10:31:15 +0000 (12:31 +0200)] 
column: segmentation fault on invalid unicode input passed to -s option

The function mbs_to_wcs() returns NULL on invalid UTF.

Fixes: https://github.com/karelzak/util-linux/issues/1425
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'bug/1416' of https://github.com/V-Smeets/util-linux
Karel Zak [Tue, 31 Aug 2021 10:26:00 +0000 (12:26 +0200)] 
Merge branch 'bug/1416' of https://github.com/V-Smeets/util-linux

* 'bug/1416' of https://github.com/V-Smeets/util-linux:
  Erase line before writing the filename

3 years agoMerge branch 'patch-2' of https://github.com/rffontenelle/util-linux
Karel Zak [Tue, 31 Aug 2021 10:08:38 +0000 (12:08 +0200)] 
Merge branch 'patch-2' of https://github.com/rffontenelle/util-linux

* 'patch-2' of https://github.com/rffontenelle/util-linux:
  asciidoc: unconstrained formatting pair in fdisk

3 years agoMerge branch 'patch-1' of https://github.com/rffontenelle/util-linux
Karel Zak [Tue, 31 Aug 2021 10:07:34 +0000 (12:07 +0200)] 
Merge branch 'patch-1' of https://github.com/rffontenelle/util-linux

* 'patch-1' of https://github.com/rffontenelle/util-linux:
  asciidoc: fix quoted message in fsck.minix

3 years agotests: use sub-tests for dm-verity
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

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: check for dm-verity support
Karel Zak [Tue, 31 Aug 2021 09:40:45 +0000 (11:40 +0200)] 
tests: check for dm-verity support

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: add tests for dm-verity support in mount
Vojtěch Eichler [Fri, 27 Aug 2021 08:48:27 +0000 (10:48 +0200)] 
tests: add tests for dm-verity support in mount

3 years agodocs: add hint about TP
Karel Zak [Tue, 31 Aug 2021 09:02:26 +0000 (11:02 +0200)] 
docs: add hint about TP

Addresses: https://github.com/karelzak/util-linux/issues/1421
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolsblk: add zoned columns to "lsblk -z"
Naohiro Aota [Mon, 30 Aug 2021 05:52:57 +0000 (14:52 +0900)] 
lsblk: add zoned columns to "lsblk -z"

Add zoned columns to the "-z" option as follow.

$ lsblk -z -i
NAME        ZONED        ZONE-SZ ZONE-NR ZONE-AMAX ZONE-OMAX ZONE-APP ZONE-WGRAN
sda         host-managed    256M   55880         0       128     672K         4K
sdb         host-managed    256M   55880         0       128     672K         4K
zram0       none              0B       0         0         0       0B         0B
nvme2n1     none              0B       0         0         0       0B         0B
|-nvme2n1p1 none              0B       0         0         0       0B         0B
|-nvme2n1p2 none              0B       0         0         0       0B         0B
`-nvme2n1p3 none              0B       0         0         0       0B         0B
nvme0n1     none              0B       0         0         0       0B         0B
nvme1n1     none              0B       0         0         0       0B         0B
nvme0n2     host-managed      2G    1844        14        14       4M         4K
nvme1n2     host-managed      2G    1844        14        14       4M         4K

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
3 years agolsblk: add columns of zoned parameters
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>
3 years agolsblk: factor out function to read sysfs param as bytes
Naohiro Aota [Mon, 30 Aug 2021 05:52:55 +0000 (14:52 +0900)] 
lsblk: factor out function to read sysfs param as bytes

Factor out a new function device_read_bytes() to read a sysfs path as bytes
for a preparation for the next commit and to reduce the code duplication.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
3 years agoasciidoc: unconstrained formatting pair in fdisk
Rafael Fontenelle [Mon, 30 Aug 2021 10:19:06 +0000 (07:19 -0300)] 
asciidoc: unconstrained formatting pair in fdisk

Not using unconstrained witl result in showing asterisk instead, which is unwanted.

3 years agoasciidoc: fix quoted message in fsck.minix
Rafael Fontenelle [Sun, 29 Aug 2021 20:10:05 +0000 (17:10 -0300)] 
asciidoc: fix quoted message in fsck.minix

3 years agoAdd partition type GUID for Haiku.
Hill Ma [Tue, 24 Aug 2021 21:21:27 +0000 (14:21 -0700)] 
Add partition type GUID for Haiku.

3 years agotests: make eject umount tests more robust
Karel Zak [Tue, 24 Aug 2021 08:49:32 +0000 (10:49 +0200)] 
tests: make eject umount tests more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: make mount/fstab-all more robust
Karel Zak [Mon, 23 Aug 2021 14:28:52 +0000 (16:28 +0200)] 
tests: make mount/fstab-all more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agotests: make ./run.sh more robust
Karel Zak [Mon, 23 Aug 2021 13:15:38 +0000 (15:15 +0200)] 
tests: make ./run.sh more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoErase line before writing the filename
Vincent Smeets [Fri, 20 Aug 2021 09:00:33 +0000 (11:00 +0200)] 
Erase line before writing the filename

3 years agosfdisk: write empty label also when only ignored partition specified
Karel Zak [Thu, 19 Aug 2021 10:10:02 +0000 (12:10 +0200)] 
sfdisk: write empty label also when only ignored partition specified

sfdisk writes empty disk label only when "label:" header specified.
Unfortunately, this feature is ignored when all specified partitions
are ignored

  echo -e "label: dos\n0,0,0\n" | sfdisk /dev/sdc

Fixes: https://github.com/karelzak/util-linux/issues/1413
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'rfkill-event-abort' of https://github.com/lightmare/util-linux
Karel Zak [Thu, 19 Aug 2021 09:12:31 +0000 (11:12 +0200)] 
Merge branch 'rfkill-event-abort' of https://github.com/lightmare/util-linux

* 'rfkill-event-abort' of https://github.com/lightmare/util-linux:
  rfkill: quit when read end of stdout is closed

3 years agogithub: add linux-modules-extra package to CI tests
Karel Zak [Thu, 19 Aug 2021 09:01:19 +0000 (11:01 +0200)] 
github: add linux-modules-extra package to CI tests

It should be enough to get scsi_debug kernel module.

Suggested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agorfkill: quit when read end of stdout is closed
Mickey Rose [Tue, 17 Aug 2021 14:36:06 +0000 (16:36 +0200)] 
rfkill: quit when read end of stdout is closed

3 years agowdctl: Workaround reported boot-status bits not being present in wd->ident.options
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>
3 years agolibfdisk: check calloc() return [gcc-analyzer]
Karel Zak [Wed, 18 Aug 2021 09:35:07 +0000 (11:35 +0200)] 
libfdisk: check calloc() return [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: make self_partition() use more robust [gcc-analyzer]
Karel Zak [Wed, 18 Aug 2021 09:28:43 +0000 (11:28 +0200)] 
libfdisk: make self_partition() use more robust [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: dereference of possibly-NULL [gcc-analyzer]
Karel Zak [Wed, 18 Aug 2021 09:15:55 +0000 (11:15 +0200)] 
libfdisk: dereference of possibly-NULL [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: make mnt_table_get_fs_root() more robust [gcc-analyzer]
Karel Zak [Wed, 18 Aug 2021 09:02:45 +0000 (11:02 +0200)] 
libmount: make mnt_table_get_fs_root() more robust [gcc-analyzer]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoipcmk: fix strtoul use, remove deadcode [coverity scan]
Karel Zak [Wed, 18 Aug 2021 08:38:52 +0000 (10:38 +0200)] 
ipcmk: fix strtoul use, remove deadcode [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agohardlink: Calling posix_fadvise without checking return value [coverity scan]
Karel Zak [Wed, 18 Aug 2021 08:26:48 +0000 (10:26 +0200)] 
hardlink: Calling posix_fadvise without checking return value [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomore: Calling open without checking return value [coverity scan]
Karel Zak [Wed, 18 Aug 2021 08:25:14 +0000 (10:25 +0200)] 
more: Calling open without checking return value [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolscpu: fix cppcheck warning [Uninitialized variable]
Karel Zak [Wed, 18 Aug 2021 08:19:23 +0000 (10:19 +0200)] 
lscpu: fix cppcheck warning [Uninitialized variable]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomount: (adoc) ext_N_ → ext__N__ [manpage-l10n]
Karel Zak [Tue, 17 Aug 2021 13:28:28 +0000 (15:28 +0200)] 
mount: (adoc) ext_N_ → ext__N__ [manpage-l10n]

Reported-by: Helge Kreutzmann <debian@helgefjell.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomount: (adoc) mount → mount(2), of → or [manpage-l10n]
Karel Zak [Tue, 17 Aug 2021 13:22:09 +0000 (15:22 +0200)] 
mount: (adoc) mount → mount(2),  of → or [manpage-l10n]

Reported-by: Helge Kreutzmann <debian@helgefjell.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agomount: (adoc) fix missing period [manpage-l10n]
Karel Zak [Tue, 17 Aug 2021 13:07:59 +0000 (15:07 +0200)] 
mount: (adoc) fix missing period [manpage-l10n]

Reported-by: Helge Kreutzmann <debian@helgefjell.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'master' of https://github.com/panchenbo/util-linux
Karel Zak [Tue, 17 Aug 2021 11:55:02 +0000 (13:55 +0200)] 
Merge branch 'master' of https://github.com/panchenbo/util-linux

3 years agoagetty: (adoc) double hyphen replaced by dash in man pages
Karel Zak [Tue, 17 Aug 2021 11:50:52 +0000 (13:50 +0200)] 
agetty: (adoc) double hyphen replaced by dash in man pages

Fixes: https://github.com/karelzak/util-linux/issues/1411
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agozramctl: improve usage() output
Karel Zak [Tue, 17 Aug 2021 11:32:10 +0000 (13:32 +0200)] 
zramctl: improve usage() output

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agofix error ft_part 0x662
panchenbo [Tue, 17 Aug 2021 03:29:12 +0000 (11:29 +0800)] 
fix error ft_part 0x662

3 years agozramctl: add zstd compression algorithm option
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).

Signed-off-by: Jan Samek <samekh@email.cz>
3 years agomount: add -m,--mkdir as shortcut for X-mount.mkdir
Karel Zak [Thu, 12 Aug 2021 11:51:57 +0000 (13:51 +0200)] 
mount: add -m,--mkdir as shortcut for X-mount.mkdir

Suggested-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: support quotes in X-mount options
Karel Zak [Thu, 12 Aug 2021 11:44:19 +0000 (13:44 +0200)] 
libmount: support quotes in X-mount options

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: show options string on parse error
Karel Zak [Thu, 12 Aug 2021 11:41:56 +0000 (13:41 +0200)] 
libmount: show options string on parse error

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: allow X-* options more than once
Karel Zak [Thu, 12 Aug 2021 11:39:39 +0000 (13:39 +0200)] 
libmount: allow X-* options more than once

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: change propagation of /run for X-mount.subdir
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

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: use /run/mount/tmptgt rather than /tmp/mount/mount.<pid>
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: remove support for obsolete /dev/.mount/utab
Karel Zak [Thu, 12 Aug 2021 08:44:03 +0000 (10:44 +0200)] 
libmount: remove support for obsolete /dev/.mount/utab

The default is /run/mount/utab for years.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'master' of https://github.com/panchenbo/util-linux
Karel Zak [Wed, 11 Aug 2021 14:22:39 +0000 (16:22 +0200)] 
Merge branch 'master' of https://github.com/panchenbo/util-linux

* 'master' of https://github.com/panchenbo/util-linux:
  lscpu:Add Phytium FT-2000+ & S2500 support

3 years agomount.8: don't consider additional mounts as experimental
Karel Zak [Wed, 11 Aug 2021 14:18:29 +0000 (16:18 +0200)] 
mount.8: don't consider additional mounts as experimental

This is bug, we have "EXPERIMENTAL" flag in the man page since v2.23.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: add X-mount.subdir=
Karel Zak [Wed, 11 Aug 2021 13:57:37 +0000 (15:57 +0200)] 
libmount: add X-mount.subdir=

Like btrfs subvol=, but more generic and for all filesystems. This
feature is marked as EXPERIMENTAL (may be removed).

 # mount /dev/sdc /mnt/test -o X-mount.subdir=AAA

 # findmnt /dev/sdc
 TARGET    SOURCE         FSTYPE OPTIONS
 /mnt/test /dev/sdc[/AAA] ext4   rw,relatime,stripe=512

Implemented as:

 * 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>
3 years agolscpu:Add Phytium FT-2000+ & S2500 support
panchenbo [Wed, 11 Aug 2021 11:33:31 +0000 (19:33 +0800)] 
lscpu:Add Phytium FT-2000+ & S2500 support

3 years agoMerge branch 'master' of https://github.com/panchenbo/util-linux
Karel Zak [Wed, 11 Aug 2021 08:04:35 +0000 (10:04 +0200)] 
Merge branch 'master' of https://github.com/panchenbo/util-linux

* 'master' of https://github.com/panchenbo/util-linux:
  lscpu:Add Phytium aarch64 cpupart

3 years agolscpu:Add Phytium aarch64 cpupart
panchenbo [Wed, 11 Aug 2021 05:00:08 +0000 (13:00 +0800)] 
lscpu:Add Phytium aarch64 cpupart

3 years agodocs: fix info about LIBSMARTCOLS_DEBUG_PADDING
Karel Zak [Tue, 10 Aug 2021 08:12:26 +0000 (10:12 +0200)] 
docs: fix info about LIBSMARTCOLS_DEBUG_PADDING

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'whereis-bash-complete' of https://github.com/Smittyvb/util-linux
Karel Zak [Mon, 9 Aug 2021 09:58:42 +0000 (11:58 +0200)] 
Merge branch 'whereis-bash-complete' of https://github.com/Smittyvb/util-linux

* 'whereis-bash-complete' of https://github.com/Smittyvb/util-linux:
  whereis: use commands for Bash completions

3 years agolib/buffer: fix buffer reset
Karel Zak [Mon, 9 Aug 2021 09:07:17 +0000 (11:07 +0200)] 
lib/buffer: fix buffer reset

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolscpu: fix compilation against librtas
Karel Zak [Mon, 9 Aug 2021 07:52:46 +0000 (09:52 +0200)] 
lscpu: fix compilation against librtas

Fixes: https://github.com/karelzak/util-linux/issues/1406
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoprlimit: fix compiler warning [-Wmaybe-uninitialized]
Karel Zak [Mon, 9 Aug 2021 07:45:21 +0000 (09:45 +0200)] 
prlimit: fix compiler warning [-Wmaybe-uninitialized]

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>
3 years agowhereis: use commands for Bash completions
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.

Signed-off-by: Smitty van Bodegom <me@smitop.com>
3 years agolibsmartcols: use lib/buffer, remove local implementation
Karel Zak [Fri, 6 Aug 2021 10:04:05 +0000 (12:04 +0200)] 
libsmartcols: use lib/buffer, remove local implementation

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/buffer: add support for "safe" encoding
Karel Zak [Fri, 6 Aug 2021 10:02:39 +0000 (12:02 +0200)] 
lib/buffer: add support for "safe" encoding

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/buffer: add possibility to save position in the buffer
Karel Zak [Thu, 5 Aug 2021 14:45:07 +0000 (16:45 +0200)] 
lib/buffer: add possibility to save position in the buffer

This is necessary to use lib/buffer.c in libsmart cols.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/buffer: retun size of the buffer and data
Karel Zak [Thu, 5 Aug 2021 14:05:58 +0000 (16:05 +0200)] 
lib/buffer: retun size of the buffer and data

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/strutils: add strappend()
Karel Zak [Thu, 5 Aug 2021 13:42:15 +0000 (15:42 +0200)] 
lib/strutils: add strappend()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/strutils: rename strappend() to strconcat()
Karel Zak [Thu, 5 Aug 2021 09:25:54 +0000 (11:25 +0200)] 
lib/strutils: rename strappend() to strconcat()

It concatenates two strings to a new string. It's something else than
"append".

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibuuid: include c.h to cover restrict keyword
Karel Zak [Thu, 5 Aug 2021 07:46:21 +0000 (09:46 +0200)] 
libuuid: include c.h to cover restrict keyword

References: https://github.com/karelzak/util-linux/issues/1405
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibblkid: (btrfs) add debug messages to zoned support
Karel Zak [Tue, 3 Aug 2021 11:29:16 +0000 (13:29 +0200)] 
libblkid: (btrfs) add debug messages to zoned support

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: (dos) index partition from zero for DBG()
Karel Zak [Mon, 2 Aug 2021 13:49:10 +0000 (15:49 +0200)] 
libfdisk: (dos) index partition from zero for DBG()

References: https://github.com/karelzak/util-linux/pull/1394
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: add new Linux GPT partition types
WANG Xuerui [Mon, 2 Aug 2021 09:55:19 +0000 (17:55 +0800)] 
libfdisk: add new Linux GPT partition types

Add new partition type UUIDs introduced in the following systemd PRs:

- https://github.com/systemd/systemd/pull/17700
- https://github.com/systemd/systemd/pull/20087

[kzak@redhat.com: - add missing commas]

Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibmount: assert() is enough [lgtm scan]
Karel Zak [Mon, 2 Aug 2021 08:58:56 +0000 (10:58 +0200)] 
libmount: assert() is enough [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'chs' of https://github.com/pali/util-linux
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

4 years agoForward value of sector_size instead of its address in blkdev_get_physector_size
Nicolas Melot [Sun, 1 Aug 2021 17:20:58 +0000 (19:20 +0200)] 
Forward value of sector_size instead of its address in blkdev_get_physector_size

4 years agotests: add rv64 lscpu test
Karel Zak [Fri, 30 Jul 2021 13:32:24 +0000 (15:32 +0200)] 
tests: add rv64 lscpu test

References: https://github.com/karelzak/util-linux/issues/1401
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix NULL dereference
Karel Zak [Fri, 30 Jul 2021 12:35:25 +0000 (14:35 +0200)] 
lscpu: fix NULL dereference

Fixes: https://github.com/karelzak/util-linux/issues/1401
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoRevert "sulogin: fix getpasswd()"
Karel Zak [Fri, 30 Jul 2021 12:16:03 +0000 (14:16 +0200)] 
Revert "sulogin: fix getpasswd()"

This patch is unnecessary in the master branch.

This reverts commit 2d8a9fcee2e3d63deb6bcba650894ff14d8e2d3b.

References: https://github.com/karelzak/util-linux/issues/1400

4 years agofdisk: Add support for fixing MBR partitions CHS values
Pali Rohár [Fri, 30 Jul 2021 09:19:20 +0000 (11:19 +0200)] 
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.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Add function fdisk_dos_fix_chs() for fixing CHS values for all partitions
Pali Rohár [Fri, 30 Jul 2021 09:15:15 +0000 (11:15 +0200)] 
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.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agoagetty: use CTRL+C to erase username
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>
4 years agolibfdisk: (dos) Add function dos_partition_sync_chs() for updating CHS values
Pali Rohár [Fri, 30 Jul 2021 09:01:36 +0000 (11:01 +0200)] 
libfdisk: (dos) Add function dos_partition_sync_chs() for updating CHS values

Call this function everytime after changing either relative LBA partition
offset or LBA partition size to ensure that CHS values are in sync with
LBA.

This should fix partition CHS values after moving or deleting partition.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agoMerge branch 'xget' of https://github.com/ericonr/util-linux
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).

4 years agosulogin: fix getpasswd()
Karel Zak [Thu, 29 Jul 2021 19:28:00 +0000 (21:28 +0200)] 
sulogin: fix getpasswd()

Fixes: https://github.com/karelzak/util-linux/issues/1400
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: don't use setgroups at all()
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>
4 years agolib/pwdutils: use assert to check correct usage.
Érico Nogueira [Wed, 28 Jul 2021 02:58:26 +0000 (23:58 -0300)] 
lib/pwdutils: use assert to check correct usage.

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

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
4 years agologger: use xgetlogin from pwdutils.
Érico Nogueira [Wed, 28 Jul 2021 02:54:42 +0000 (23:54 -0300)] 
logger: use xgetlogin from pwdutils.

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.

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
4 years agowall: use xgetlogin.
Érico Nogueira [Wed, 28 Jul 2021 02:51:34 +0000 (23:51 -0300)] 
wall: use xgetlogin.

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.

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
4 years agolib/pwdutils: don't use getlogin(3).
Érico Nogueira [Wed, 28 Jul 2021 02:41:30 +0000 (23:41 -0300)] 
lib/pwdutils: don't use getlogin(3).

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()).

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
4 years agolibmount: fix setgroups() use
Karel Zak [Thu, 29 Jul 2021 09:50:48 +0000 (11:50 +0200)] 
libmount: fix setgroups() use

* keep process in single supplementary group, which is the real group ID for the process

* make sure we have rights to call setgroups(), requires group permissions

Fixes: https://github.com/karelzak/util-linux/issues/1398
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'procmnt-fix' of https://github.com/benaryorg/util-linux
Karel Zak [Wed, 28 Jul 2021 09:17:59 +0000 (11:17 +0200)] 
Merge branch 'procmnt-fix' of https://github.com/benaryorg/util-linux

* 'procmnt-fix' of https://github.com/benaryorg/util-linux:
  fix #648 by ignoring EINVAL on-remount of proc

4 years agolosetup: use LOOP_CONFIGURE in a more robust way
Karel Zak [Wed, 28 Jul 2021 09:05:36 +0000 (11:05 +0200)] 
losetup: use LOOP_CONFIGURE in a more robust way

32-bit userspace returns ENOTTY:
 ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/usr/install/iso/systemrescue-8.04-amd64.iso", ...}}) = -1 ENOTTY (Inappropriate ioctl for device)

64-bit userspace returns EINVAL:
 ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/usr/src/PACKAGES/systemrescue-8.04-amd64.iso", ...}}) = -1 EINVAL (Invalid argument)

The correct return value for an unknown ioctl is ENOTTY, but we need
to support already released kernels, so let's support both errnos.

Reported-by: Krzysztof Olędzki <ole@ans.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: fix fdisk/bsd on big endian systems (tested on sparc64 and ppc64)
Anatoly Pugachev [Tue, 27 Jul 2021 16:33:03 +0000 (19:33 +0300)] 
tests: fix fdisk/bsd on big endian systems (tested on sparc64 and ppc64)

Fixes: 5d0f0ca56
Closes #1392

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
4 years agoMerge branch 'rename-all' of https://github.com/utoddl/util-linux
Karel Zak [Tue, 27 Jul 2021 12:14:51 +0000 (14:14 +0200)] 
Merge branch 'rename-all' of https://github.com/utoddl/util-linux

* 'rename-all' of https://github.com/utoddl/util-linux:
  rename: size_t, mutually exclusive parameters
  rename: stop after count changes
  rename: add --all and --last parameters

4 years agoMerge branch 'patch-1' of https://github.com/cfinnberg/util-linux
Karel Zak [Tue, 27 Jul 2021 11:34:16 +0000 (13:34 +0200)] 
Merge branch 'patch-1' of https://github.com/cfinnberg/util-linux

4 years agoreadprofile: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:31:57 +0000 (13:31 +0200)] 
readprofile: use snprintf() rather than sprintf()

4 years agoipcs: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:31:47 +0000 (13:31 +0200)] 
ipcs: use snprintf() rather than sprintf()

4 years agowrite: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:31:30 +0000 (13:31 +0200)] 
write: use snprintf() rather than sprintf()

4 years agomore: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:31:18 +0000 (13:31 +0200)] 
more: use snprintf() rather than sprintf()

4 years agolslocks: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:30:56 +0000 (13:30 +0200)] 
lslocks: use snprintf() rather than sprintf()

4 years agouuidd: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:30:42 +0000 (13:30 +0200)] 
uuidd: use snprintf() rather than sprintf()