]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
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()

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

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

4 years agolast: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:29:36 +0000 (13:29 +0200)] 
last: use snprintf() rather than sprintf()

4 years agolib: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:29:19 +0000 (13:29 +0200)] 
lib: use snprintf() rather than sprintf()

4 years agolibblkid: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:29:05 +0000 (13:29 +0200)] 
libblkid: use snprintf() rather than sprintf()

4 years agolibsmartcols: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 11:28:52 +0000 (13:28 +0200)] 
libsmartcols: use snprintf() rather than sprintf()

4 years agoblockdev: use snprintf() rather than sprintf()
Karel Zak [Tue, 27 Jul 2021 10:51:43 +0000 (12:51 +0200)] 
blockdev: use snprintf() rather than sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'master' of https://github.com/tabraham/util-linux
Karel Zak [Tue, 27 Jul 2021 10:49:59 +0000 (12:49 +0200)] 
Merge branch 'master' of https://github.com/tabraham/util-linux

4 years agosys-utils/ipcutils: be careful when call calloc() for uint64 nmembs
Karel Zak [Tue, 27 Jul 2021 09:58:31 +0000 (11:58 +0200)] 
sys-utils/ipcutils: be careful when call calloc() for uint64 nmembs

Fix: https://github.com/karelzak/util-linux/issues/1395
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (dos) support partition and MBR overlap
Karel Zak [Tue, 27 Jul 2021 09:40:32 +0000 (11:40 +0200)] 
libfdisk: (dos) support partition and MBR overlap

Let's support this crazy use-case in expert menu, because it's normal
for removable FAT disks, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (dos) don't ignore MBR+FAT use-case
Karel Zak [Tue, 27 Jul 2021 09:10:53 +0000 (11:10 +0200)] 
libfdisk: (dos) don't ignore MBR+FAT use-case

Since libblkid commit 751eca28fcfa1e325770904d7181b22e48c72b29 it does
not ignore FAT on whole-disks, so now libfdisk sees collision between
FAT and MBR. It's fine to report the collision to users, but we should
not ignore the MBR.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblockdev: allow for larger values for start sector
Thomas Abraham [Thu, 22 Jul 2021 19:43:13 +0000 (15:43 -0400)] 
blockdev: allow for larger values for start sector

commit 9147d2ad8a ("blockdev: Don't fail on missing start sector") limits
the size of the start sector to 10 digits.

Multi-terrabyte devices can have partitions with a start sector larger than
10 digits, which will cause an sprintf() to abort due to overflowing the buffer.

It causes:
  # blockdev --report /dev/sda4
  RO    RA   SSZ   BSZ   StartSec            Size   Device
  *** buffer overflow detected ***: terminated
  Aborted (core dumped)

4 years agolslogins: fix memory leak [asan]
Karel Zak [Thu, 22 Jul 2021 09:34:11 +0000 (11:34 +0200)] 
lslogins: fix memory leak [asan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslogins: ask for supplementary groups only once [asan]
Karel Zak [Thu, 22 Jul 2021 09:30:22 +0000 (11:30 +0200)] 
lslogins: ask for supplementary groups only once [asan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslogins: use sd_journal_get_data() in proper way
Karel Zak [Thu, 22 Jul 2021 09:03:54 +0000 (11:03 +0200)] 
lslogins: use sd_journal_get_data() in proper way

man sd_journal_get_data:
    The returned data is in a read-only memory map and is only valid until the next invocation
    of sd_journal_get_data().

It means that use data after 3x sd_journal_get_data() is really bad
idea. It also seems better to not assume the fields are zero
terminated as journal API works with void* and size_t to address the
data.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1984704
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'chs' of https://github.com/pali/util-linux
Karel Zak [Mon, 19 Jul 2021 11:34:24 +0000 (13:34 +0200)] 
Merge branch 'chs' of https://github.com/pali/util-linux

* 'chs' of https://github.com/pali/util-linux:
  tests: fdisk: Update CHS values in MBR partitions
  libfdisk: (dos) Fix determining number of heads and sectors per track from MBR
  libfdisk: (dos) Fix upper bound cylinder check in check_consistency()
  libfdisk: (dos) Fix upper bound cylinder check in check()
  libfdisk: (dos) Fix setting CHS values when creating new partition
  libfdisk: (dos) Use helper macros cylinder() and sector() in check_consistency()
  libfdisk: (dos) Put number of CHS check_consistency errors into summart message
  libfdisk: (dos) Add check both begin and end CHS partition parameters
  libfdisk: (dos) Fix check error message when CHS calculated sector does not match LBA
  libfdisk: (dos) Fix printing number of CHS sectors in check error message
  libfdisk: (dos) Recalculate number of cylinders after changing number of heads and sectors

4 years agotests: fdisk: Update CHS values in MBR partitions
Pali Rohár [Fri, 16 Jul 2021 20:26:38 +0000 (22:26 +0200)] 
tests: fdisk: Update CHS values in MBR partitions

It looks like that old CHS values prior this change in test data are
incorrect. Possible explanation why CHS values are incorrect is in commit
message 9cade4fbf8c4 ("libfdisk: (dos) Fix determining number of heads and
sectors per track from MBR").

This change updates test data to pass test suite after applying mentioned
commit.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agoMerge branch 'verity_exp' of https://github.com/bluca/util-linux
Karel Zak [Fri, 16 Jul 2021 12:17:19 +0000 (14:17 +0200)] 
Merge branch 'verity_exp' of https://github.com/bluca/util-linux

* 'verity_exp' of https://github.com/bluca/util-linux:
  verity: remove experimental tag from mount manpage

4 years agoverity: remove experimental tag from mount manpage
Luca Boccassi [Fri, 16 Jul 2021 10:52:44 +0000 (11:52 +0100)] 
verity: remove experimental tag from mount manpage

It has been around for a year and a half, and 3 releases.

4 years agolibfdisk: (dos) Fix determining number of heads and sectors per track from MBR
Pali Rohár [Tue, 6 Jul 2021 17:43:56 +0000 (19:43 +0200)] 
libfdisk: (dos) Fix determining number of heads and sectors per track from MBR

Current algorithm implemented in get_partition_table_geometry() function
is wrong. It take head bits from CHS position from the end of the last
partition and proclaim that this value is number of heads on disk. Same
does for sectors bits from CHS and proclaim that this value is number of
sectors per tracks. As number of disk heads and head bits in CHS position
are different things this just results in bogus detected disk geometry.

Implement a new algorithm to determinate number of heads and sectors per
track from partition sector offsets. In MBR table for every partition is
stored every sector offset in two formats: one as CHS and one as LBA.

Conversion from CHS to LBA is defined by formula:

   LBA = (c * N_heads + h) * N_sectors + (s - 1)

So if we have two different offsets in both CHS and LBA formats, written as
(LBA1, c1, h1, s1) and (LBA2, c2, h2, s2) then we can calculate number of
heads and sectors per tracks by solving linear equations as:

   N_heads = (o1 * h2 - o2 * h1) / (o2 * c1 - o1 * c2)
   N_sectors = (o2 * c1 - o1 * c2) / (c1 * h2 - c2 * h1)

where

   o = LBA - (s - 1)

Integer division also verifies that offsets were calculated from same
number of heads and sectors per track as division must be always positive
with no reminder.

There is a special case when either numerator or denominator is zero. This
indicates that comparing partition offsets have also same CHS offset
divisor which leads to fact that calculation of number of heads and sector
per tracks is not possible.

In MBR table are stored up to 8 offset numbers, so it means there are up
to the 28 of candidates which can expose number of disk heads and number of
disk sectors per track. Start with offsets which belongs to same partition
and start from the first partition. As the first partition in most cases
was used by BIOS for booting.

It is required to skip CHS values 1023/254/63 and 1023/255/63 as these
indicates that values are invalid or overflowed.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Fix upper bound cylinder check in check_consistency()
Pali Rohár [Tue, 6 Jul 2021 16:29:10 +0000 (18:29 +0200)] 
libfdisk: (dos) Fix upper bound cylinder check in check_consistency()

To determinate if CHS values are valid for consistency check and not
overflowed, it is needed to check current CHS cylinder value and not total
disk cylinder values. It is possible that also on "big" disk there is first
small partition which can be represented by CHS tuple.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Fix upper bound cylinder check in check()
Pali Rohár [Tue, 6 Jul 2021 16:26:52 +0000 (18:26 +0200)] 
libfdisk: (dos) Fix upper bound cylinder check in check()

To check if LBA sector can be represented in CHS without overflow it is
required to check for cylinder value which belongs to the LBA sector. And
not the total number of disk cylinders. Note that maximal representable
total number of disk cylinders is 1024 and therefore the last cylinder
which which can be stored in CHS tuple is 1023. Hence strict inequality is
used.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Fix setting CHS values when creating new partition
Pali Rohár [Tue, 6 Jul 2021 15:12:13 +0000 (17:12 +0200)] 
libfdisk: (dos) Fix setting CHS values when creating new partition

It does not matter if dos compatibility flag is turned on or off. CHS
values in partition entry can overflow also when dos compatibility flag is
turned off. In this case maximal representable CHS values should be used.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Use helper macros cylinder() and sector() in check_consistency()
Pali Rohár [Tue, 6 Jul 2021 13:03:21 +0000 (15:03 +0200)] 
libfdisk: (dos) Use helper macros cylinder() and sector() in check_consistency()

Helper macros are already used there and make code more readable.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Put number of CHS check_consistency errors into summart message
Pali Rohár [Tue, 6 Jul 2021 12:57:13 +0000 (14:57 +0200)] 
libfdisk: (dos) Put number of CHS check_consistency errors into summart message

Function check_consistency() prints errors to console output but does not
calculate correct error numbers in summary error message. Fix it, so fdisk
prints correct number in summary message "N errors detected.".

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Add check both begin and end CHS partition parameters
Pali Rohár [Tue, 6 Jul 2021 12:54:40 +0000 (14:54 +0200)] 
libfdisk: (dos) Add check both begin and end CHS partition parameters

There is no reason to check only end CHS partition parameters. Check also
begin values and correctly count errors in nerrors variable. fdisk then
print correctly summary message "N errors detected.".

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Fix check error message when CHS calculated sector does not match LBA
Pali Rohár [Tue, 6 Jul 2021 12:08:42 +0000 (14:08 +0200)] 
libfdisk: (dos) Fix check error message when CHS calculated sector does not match LBA

Function check() checks that LBA addresses sector number matches CHS sector
number. But error message contains information about "previous sectors" and
"total sectors" which is misleading so change it.

Also rename variables 'start' and 'total' to make it clear what value is
stored in them. Note that in 'start' variable is currently stored last LBA
partition sector and in 'total' is stored last CHS partition sector. So
neither sector where partition starts nor total sectors of partition.

Code and check logic looks to be correct, just error message and variable
names are misleading. Therefore no functional changes in this patch.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Fix printing number of CHS sectors in check error message
Pali Rohár [Tue, 6 Jul 2021 11:51:22 +0000 (13:51 +0200)] 
libfdisk: (dos) Fix printing number of CHS sectors in check error message

Number of CHS sectors (indexed from zero) is stored in variable 'real_s'.
In variable 's' is stored in high 2 bits number of CHS cylinders.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibfdisk: (dos) Recalculate number of cylinders after changing number of heads and...
Pali Rohár [Mon, 5 Jul 2021 20:13:11 +0000 (22:13 +0200)] 
libfdisk: (dos) Recalculate number of cylinders after changing number of heads and sectors

After geometry is changes it is required to recalculate total number of
cylinders. Otherwise total disk capacity is either reduced or extended.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agologin: add callback for close_range()
Karel Zak [Thu, 15 Jul 2021 10:51:39 +0000 (12:51 +0200)] 
login: add callback for close_range()

Let's make it more robust for old kernels where is no close_range() or
in cases when it's unsuccessful.

Reported-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslogins: consolidate and optimize utmp files use
Karel Zak [Thu, 15 Jul 2021 10:24:07 +0000 (12:24 +0200)] 
lslogins: consolidate and optimize utmp files use

* the original read_utmp() code is from GPLv3+, but lslogins is GPLv2+
  (see https://github.com/karelzak/util-linux/commit/a6bf40ee77a85f5108208dc764b5d023a07998f5#commitcomment-53407151)

* remove redundant parse_btmp() and parse_wtmp() as it does not
  provide anything

* reduce realloc() calls, allocate all in one step

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fdisk-tests-more-details' of https://github.com/pali/util-linux
Karel Zak [Thu, 15 Jul 2021 08:20:09 +0000 (10:20 +0200)] 
Merge branch 'fdisk-tests-more-details' of https://github.com/pali/util-linux

* 'fdisk-tests-more-details' of https://github.com/pali/util-linux:
  tests: fdisk: Layout with more details

4 years agohardlink: remove pcre2posix.h support
Karel Zak [Wed, 14 Jul 2021 15:51:07 +0000 (17:51 +0200)] 
hardlink: remove pcre2posix.h support

It's deprecated for years. Let's rely on old good libc regex.h for now.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agologin: fix close_range() use
Karel Zak [Wed, 14 Jul 2021 15:25:57 +0000 (17:25 +0200)] 
login: fix close_range() use

This new syscall comes with three arguments (see kernel commit
278a5fbaed89dacd04e9d052f4594ffd0e0585de). Not sure why util-linux
assume only two.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1981729
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: update sfdisk reorder test
Karel Zak [Wed, 14 Jul 2021 14:18:20 +0000 (16:18 +0200)] 
tests: update sfdisk reorder test

References: commit f05a5bb2c2e62d3753f8c9262b9f6cbf469e5b0
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: skip if scsi_debug model file is not accessible
Karel Zak [Wed, 14 Jul 2021 14:13:21 +0000 (16:13 +0200)] 
tests: skip if scsi_debug model file is not accessible

* do not print grep(1) info message

* use ts_skip rather than ts_die when scsi_debug is useless

Fixes: https://github.com/karelzak/util-linux/issues/1376
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotools/git-version-gen: use NEWS as a fallback
Karel Zak [Wed, 14 Jul 2021 13:57:00 +0000 (15:57 +0200)] 
tools/git-version-gen: use NEWS as a fallback

* define ".tarball-version" as the default if not specified by $1

* try read the version string from NEWS file as a fallback if the
  git-repository or .tarball-version is not available

Fixes: https://github.com/karelzak/util-linux/issues/1381
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fat' of https://github.com/pali/util-linux
Karel Zak [Wed, 14 Jul 2021 10:23:52 +0000 (12:23 +0200)] 
Merge branch 'fat' of https://github.com/pali/util-linux

* 'fat' of https://github.com/pali/util-linux:
  libblkid: vfat: Fix reading FAT32 boot label
  libblkid: vfat: Fix reading FAT16 boot label and serial id

4 years agoMerge branch 'reorder' of https://github.com/pali/util-linux
Karel Zak [Wed, 14 Jul 2021 10:21:54 +0000 (12:21 +0200)] 
Merge branch 'reorder' of https://github.com/pali/util-linux

* 'reorder' of https://github.com/pali/util-linux:
  fdisk: move reorder diag messages to fdisk_reorder_partitions()
  fdisk: do not print error message when partition reordering is not needed

4 years agoMerge branch 'verity_sig_extension' of https://github.com/bluca/util-linux
Karel Zak [Wed, 14 Jul 2021 10:20:30 +0000 (12:20 +0200)] 
Merge branch 'verity_sig_extension' of https://github.com/bluca/util-linux

* 'verity_sig_extension' of https://github.com/bluca/util-linux:
  mount: fix roothash signature extension in manpage

4 years agoMerge branch 'meson_verity' of https://github.com/bluca/util-linux
Karel Zak [Wed, 14 Jul 2021 10:19:49 +0000 (12:19 +0200)] 
Merge branch 'meson_verity' of https://github.com/bluca/util-linux

* 'meson_verity' of https://github.com/bluca/util-linux:
  meson: fix dlopen support for cryptsetup
  meson: fix crypt_activate_by_signed_key detection

4 years agoMerge branch 'verity_corruption' of https://github.com/bluca/util-linux
Karel Zak [Wed, 14 Jul 2021 10:18:08 +0000 (12:18 +0200)] 
Merge branch 'verity_corruption' of https://github.com/bluca/util-linux

* 'verity_corruption' of https://github.com/bluca/util-linux:
  verity: fix verity.roothashsig only working as last parameter
  verity: add support for corruption action flag
  build-sys: display cryptsetup status after ./configure

4 years agotests/eject: check for root perms at beginning
Karel Zak [Wed, 14 Jul 2021 08:25:33 +0000 (10:25 +0200)] 
tests/eject: check for root perms at beginning

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'test' of https://github.com/rossburton/util-linux
Karel Zak [Wed, 14 Jul 2021 08:21:20 +0000 (10:21 +0200)] 
Merge branch 'test' of https://github.com/rossburton/util-linux

* 'test' of https://github.com/rossburton/util-linux:
  test/eject: guard asan LD_PRELOAD with use-system-commands check

4 years agofdisk: move reorder diag messages to fdisk_reorder_partitions()
Pali Rohár [Mon, 12 Jul 2021 22:40:00 +0000 (00:40 +0200)] 
fdisk: move reorder diag messages to fdisk_reorder_partitions()

The function fdisk_reorder_partitions() is also used in sfdisk and cfdisk
and these commands assume info/warn messages from the library. So move all
messages from fdisk to fdisk_reorder_partitions().

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agoverity: fix verity.roothashsig only working as last parameter
Luca Boccassi [Sun, 11 Jul 2021 17:14:40 +0000 (18:14 +0100)] 
verity: fix verity.roothashsig only working as last parameter

Parsing of verity.roothashsig did not take into consideration that other options
might follow, and used the whole string as a file path. But mnt_optstr_get_option
just returns a pointer in the mount option string, it doesn't extract it, so it
would have other subsequent options too. The length parameter has to be used.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
4 years agoverity: add support for corruption action flag
Luca Boccassi [Fri, 2 Jul 2021 17:51:41 +0000 (18:51 +0100)] 
verity: add support for corruption action flag

Add verity.oncorruption= to let users override the default kernel
behaviour, using libcrypsetup's relevant flags.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
4 years agotests: fdisk: Layout with more details
Pali Rohár [Tue, 6 Jul 2021 22:56:21 +0000 (00:56 +0200)] 
tests: fdisk: Layout with more details

Use fdisk -x instead of fdisk -l for printing layout in fdisk tests. This
can help debugging why some fdisk tests fail.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agofdisk: do not print error message when partition reordering is not needed
Pali Rohár [Tue, 6 Jul 2021 13:35:25 +0000 (15:35 +0200)] 
fdisk: do not print error message when partition reordering is not needed

Option 'f' currently prints following RED error message:

    Nothing to do. Ordering is correct already.
    Failed to fix partitions order.

This change removes RED error message when ordering is already correct.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: vfat: Fix reading FAT32 boot label
Pali Rohár [Mon, 5 Jul 2021 13:10:51 +0000 (15:10 +0200)] 
libblkid: vfat: Fix reading FAT32 boot label

FAT32 can be formatted with boot sign 0x28 to indicate that only serial id
is present or with boot sign 0x29 which indicates that both boot label and
serial id is present.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: vfat: Fix reading FAT16 boot label and serial id
Pali Rohár [Mon, 5 Jul 2021 13:09:12 +0000 (15:09 +0200)] 
libblkid: vfat: Fix reading FAT16 boot label and serial id

Older FAT16 variants do not have to contain boot label or serial id. Boot
sign 0x28 indicates that only serial id is present and boot sign 0x29
indicates that both boot label and serial id is present. Other boot sign
values (e.g. zero) indicates older FAT16 variant without boot label and
boot sign.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agomount: fix roothash signature extension in manpage
Luca Boccassi [Sat, 3 Jul 2021 11:15:53 +0000 (12:15 +0100)] 
mount: fix roothash signature extension in manpage

The PKCS7 RFC recommends to use .p7s for detached signatures file extensions,
so use that in the example.

https://datatracker.ietf.org/doc/html/rfc5751#section-3.2.1

4 years agomeson: fix dlopen support for cryptsetup
Luca Boccassi [Fri, 2 Jul 2021 18:44:59 +0000 (19:44 +0100)] 
meson: fix dlopen support for cryptsetup

dlopen is treated as a dependency, but that's not quite right, it
should be an alternative way to link to libcryptsetup.
Search for it only if cryptsetup is not disabled, and if the cryptsetup-dlopen
is explicitly set to enabled. If it is, do not link to libcryptsetup.

Add cryptsetup support status to the meson summary.

4 years agomeson: fix crypt_activate_by_signed_key detection
Luca Boccassi [Fri, 2 Jul 2021 18:11:58 +0000 (19:11 +0100)] 
meson: fix crypt_activate_by_signed_key detection

It should set HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY, rather than HAVE_CRYPTSETUP
which enables the verity features, as it needs to detect the availability of
the crypt_activate_by_signed_key API

4 years agobuild-sys: display cryptsetup status after ./configure
Luca Boccassi [Fri, 2 Jul 2021 17:09:03 +0000 (18:09 +0100)] 
build-sys: display cryptsetup status after ./configure

Signed-off-by: Luca Boccassi <bluca@debian.org>
4 years agolscpu: don't use DMI if executed with --sysroot
Karel Zak [Fri, 2 Jul 2021 11:12:13 +0000 (13:12 +0200)] 
lscpu: don't use DMI if executed with --sysroot

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotest/eject: guard asan LD_PRELOAD with use-system-commands check
Ross Burton [Thu, 1 Jul 2021 19:44:31 +0000 (20:44 +0100)] 
test/eject: guard asan LD_PRELOAD with use-system-commands check

This test tries to add asan to LD_PRELOAD because the just-built eject
will call the host /bin/umount, and apparently asan doesn't like this.

However, if ldd isn't present, this fails as the path to asan is the
error message saying that ldd isn't present.

As the asan workaround is only needed when executing the binaries that
have just been built and not the system binaries, only use it if the
test is on the built binaries.

Closes #1373.

Signed-off-by: Ross Burton <ross.burton@arm.com>
4 years agofstrim: clean return code on --quiet-unsupported
Karel Zak [Thu, 1 Jul 2021 15:06:34 +0000 (17:06 +0200)] 
fstrim: clean return code on --quiet-unsupported

This feature is already supported for -a and -A. Let's support it also
when FS specified on command line.

Addresses: https://github.com/systemd/mkosi/pull/721
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'tests' of https://github.com/rossburton/util-linux
Karel Zak [Wed, 30 Jun 2021 10:39:13 +0000 (12:39 +0200)] 
Merge branch 'tests' of https://github.com/rossburton/util-linux

4 years agolsblk: normalize space in SERIAL and MODEL
Karel Zak [Wed, 30 Jun 2021 10:25:18 +0000 (12:25 +0200)] 
lsblk: normalize space in SERIAL and MODEL

These strings come from HW and udev does not modify it. It seems good
idea to clean up it before we print it.

Fixes: https://github.com/karelzak/util-linux/issues/1368
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: mark ul/ul as a known failure
Ross Burton [Wed, 30 Jun 2021 10:25:01 +0000 (11:25 +0100)] 
tests: mark ul/ul as a known failure

As with ul/basic, this test produces different output when ran under
different terminals, which isn't very useful.

Set TS_KNOWN_FAIL so that these problems don't cause the test to fail.

Signed-off-by: Ross Burton <ross.burton@arm.com>
4 years agoMerge branch 'kill' of https://github.com/rossburton/util-linux
Karel Zak [Wed, 30 Jun 2021 10:07:50 +0000 (12:07 +0200)] 
Merge branch 'kill' of https://github.com/rossburton/util-linux

* 'kill' of https://github.com/rossburton/util-linux:
  tests: check correct log file for errors in blkdiscard test
  tests: don't hardcode /bin/kill in the kill tests

4 years agolibblkid: remove EVMS support
Karel Zak [Wed, 30 Jun 2021 09:35:45 +0000 (11:35 +0200)] 
libblkid: remove EVMS support

"When you discover you're riding a dead horse, the best strategy is to dismount."

EVMS is dead since 2006, LVM is the winner.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: remove the old code
Huang Shijie [Thu, 17 Jun 2021 12:41:16 +0000 (12:41 +0000)] 
lscpu: remove the old code

The file "/sys/firmware/dmi/tables/DMI" always exists.

The dmi_decode_cputype() can provide more information then arm_smbios_decode().
So remove it to tidy the code.

Before this patch, we can get the output from Centos 7.9 who has
"/sys/firmware/dmi/entries/4-0/raw" and "/sys/firmware/dmi/tables/DMI":
  ----------------------------------------------------
  BIOS Vendor ID:                  Ampere(TM)
  Model name:                     Neoverse-N1
    BIOS Model name:               Ampere(TM) Altra(TM) Processor
  ----------------------------------------------------

 After this patch which uses "/sys/firmware/dmi/tables/DMI", in Centos 7.9, we get:
  ----------------------------------------------------
  BIOS Vendor ID:                  Ampere(TM)
  Model name:                     Neoverse-N1
    BIOS Model name:               Ampere(TM) Altra(TM) Processor Q00-00 CPU @ 2.8GHz
    BIOS CPU family:               257
  ----------------------------------------------------

Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
4 years agotests: check correct log file for errors in blkdiscard test
Ross Burton [Tue, 29 Jun 2021 17:10:40 +0000 (18:10 +0100)] 
tests: check correct log file for errors in blkdiscard test

When checking if the discard ioctl is supported, look in stderr not stdout as
that is where the error appears.

Signed-off-by: Ross Burton <ross.burton@arm.com>
4 years agotests: don't hardcode /bin/kill in the kill tests
Ross Burton [Tue, 29 Jun 2021 15:34:20 +0000 (16:34 +0100)] 
tests: don't hardcode /bin/kill in the kill tests

If the 'kill' test is executed with --use-system-commands, it calls
/bin/kill to avoid the shell's own kill command being invoked.

However, this doesn't work if the kill we want to test isn't in fact in
/bin.  Instead, use $(which kill) to find a kill on the PATH and call
that directly.

Signed-off-by: Ross Burton <ross.burton@arm.com>
4 years agocfdisk: optimize mountpoint detection for PARTUUID
Karel Zak [Fri, 25 Jun 2021 10:58:51 +0000 (12:58 +0200)] 
cfdisk: optimize mountpoint detection for PARTUUID

Don't check fstab (and udev symplinks) for new UUIDs.

Fixes: https://github.com/karelzak/util-linux/issues/1331
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fix_mount_fscontext' of https://github.com/tweksteen/util-linux
Karel Zak [Fri, 25 Jun 2021 09:47:06 +0000 (11:47 +0200)] 
Merge branch 'fix_mount_fscontext' of https://github.com/tweksteen/util-linux

* 'fix_mount_fscontext' of https://github.com/tweksteen/util-linux:
  mount.8.adoc: Remove context options exclusion

4 years agohexdump: do not use atoi()
Karel Zak [Fri, 25 Jun 2021 09:05:21 +0000 (11:05 +0200)] 
hexdump: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agopg: do not use atoi()
Karel Zak [Fri, 25 Jun 2021 08:24:35 +0000 (10:24 +0200)] 
pg: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomisc: improve string to number conversions
Karel Zak [Thu, 24 Jun 2021 14:42:53 +0000 (16:42 +0200)] 
misc: improve string to number conversions

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/strutils: consolidate string to number conversion
Karel Zak [Thu, 24 Jun 2021 14:36:58 +0000 (16:36 +0200)] 
include/strutils: consolidate string to number conversion

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomore: fix null-pointer dereference
Karel Zak [Wed, 23 Jun 2021 09:37:31 +0000 (11:37 +0200)] 
more: fix null-pointer dereference

The command allows executing arbitrary shell commands while viewing a file by
entering '!' followed by the command. Entering a command that contains a '%',
'!', or '\' causes a segmentation violation.

The same more(1) function has a problem when not file is specified (cat
/etc/passwd | more) on command line.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1975153
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoagetty: do not use atol()
Karel Zak [Tue, 22 Jun 2021 15:26:11 +0000 (17:26 +0200)] 
agetty: do not use atol()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 15:06:46 +0000 (17:06 +0200)] 
lscpu: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoutmpdump: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 14:50:46 +0000 (16:50 +0200)] 
utmpdump: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoswapon: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 14:16:38 +0000 (16:16 +0200)] 
swapon: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoipcs: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 13:19:22 +0000 (15:19 +0200)] 
ipcs: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoeject: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 13:15:46 +0000 (15:15 +0200)] 
eject: do not use atoi()

* remove unnecessary strtok() use
* remove atoi use()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofsck: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 12:42:56 +0000 (14:42 +0200)] 
fsck: do not use atoi()

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/strutils: cleanup strto..() functions
Karel Zak [Tue, 22 Jun 2021 12:20:42 +0000 (14:20 +0200)] 
include/strutils: cleanup strto..() functions

* add ul_strtos64() and ul_strtou64()
* add simple test

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblockdev: improve arguments parsing (remove atoi)
Karel Zak [Tue, 22 Jun 2021 10:32:58 +0000 (12:32 +0200)] 
blockdev: improve arguments parsing (remove atoi)

old version:
 # blockdev --setfra 4x096 /dev/sdc

new version:
 # blockdev --setfra 4x096 /dev/sdc
 blockdev: failed to parse command argument: '4x096'

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocfdisk: do not use atoi()
Karel Zak [Tue, 22 Jun 2021 09:50:06 +0000 (11:50 +0200)] 
cfdisk: do not use atoi()

It's unnecessary to use atoi in this case.

Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoreadprofile: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:37:48 +0000 (15:37 +0200)] 
readprofile: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agowipefs: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:34:06 +0000 (15:34 +0200)] 
wipefs: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslocks: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:33:36 +0000 (15:33 +0200)] 
lslocks: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agokill: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:32:51 +0000 (15:32 +0200)] 
kill: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslogins: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:31:43 +0000 (15:31 +0200)] 
lslogins: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofsck: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:29:43 +0000 (15:29 +0200)] 
fsck: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsmem: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:29:33 +0000 (15:29 +0200)] 
lsmem: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
lscpu: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohwclock: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
hwclock: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoipcs: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
ipcs: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibuuid: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
libuuid: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
libmount: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: check errno after strto..()
Karel Zak [Mon, 21 Jun 2021 13:00:40 +0000 (15:00 +0200)] 
libblkid: check errno after strto..()

Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>