]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agouuidparse: use uuid type definitions from libuuid header
Sami Kerola [Sun, 22 Nov 2020 20:48:38 +0000 (20:48 +0000)] 
uuidparse: use uuid type definitions from libuuid header

While on it add missing UUID_TYPE_DCE_NIL to the header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidparse: use libuuid function to test nil uuid
Sami Kerola [Sun, 22 Nov 2020 20:46:40 +0000 (20:46 +0000)] 
uuidparse: use libuuid function to test nil uuid

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolib: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Thu, 17 Dec 2020 10:07:38 +0000 (11:07 +0100)] 
lib: fix compiler warnings [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Thu, 17 Dec 2020 10:07:25 +0000 (11:07 +0100)] 
libmount: fix compiler warnings [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: suggest "make check-programs"
Karel Zak [Thu, 17 Dec 2020 09:57:33 +0000 (10:57 +0100)] 
tests: suggest "make check-programs"

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: remove unnecessary prefix from static function
Karel Zak [Tue, 15 Dec 2020 10:31:57 +0000 (11:31 +0100)] 
lscpu: remove unnecessary prefix from static function

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Mon, 14 Dec 2020 14:56:55 +0000 (15:56 +0100)] 
scriptlive: fix compiler warnings [-Wmaybe-uninitialized]

term-utils/scriptlive.c: In function 'process_next_step':
term-utils/scriptlive.c:125:4: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/scriptlive.c:122:19: note: 'now.tv_usec' was declared here
term-utils/scriptlive.c:125:4: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/scriptlive.c:122:19: note: 'now.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Mon, 14 Dec 2020 14:56:55 +0000 (15:56 +0100)] 
script: fix compiler warnings [-Wmaybe-uninitialized]

term-utils/script.c: In function 'log_close.part.0.isra':
term-utils/script.c:306:3: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/script.c:303:18: note: 'now.tv_usec' was declared here
term-utils/script.c:306:3: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/script.c:303:18: note: 'now.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohwclock: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Mon, 14 Dec 2020 14:56:55 +0000 (15:56 +0100)] 
hwclock: fix compiler warnings [-Wmaybe-uninitialized]

sys-utils/hwclock-rtc.c: In function 'synchronize_to_clock_tick_rtc':
sys-utils/hwclock.c:169:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_sec' was declared here
sys-utils/hwclock.c:169:28: warning: 'begin.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'begin.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkdiscard: fix compiler warnings [-Wmaybe-uninitialized]
Karel Zak [Mon, 14 Dec 2020 14:56:55 +0000 (15:56 +0100)] 
blkdiscard: fix compiler warnings [-Wmaybe-uninitialized]

sys-utils/blkdiscard.c: In function 'main':
sys-utils/blkdiscard.c:304:33: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_usec' was declared here
sys-utils/blkdiscard.c:305:37: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_sec' was declared here
sys-utils/blkdiscard.c:304:33: warning: 'last.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_usec' was declared here
sys-utils/blkdiscard.c:305:65: warning: 'last.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: don't use deprecated security_context_t
Karel Zak [Mon, 14 Dec 2020 14:44:59 +0000 (15:44 +0100)] 
mkswap: don't use deprecated security_context_t

libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agologin-utils: don't use deprecated security_context_t
Karel Zak [Mon, 14 Dec 2020 14:44:59 +0000 (15:44 +0100)] 
login-utils: don't use deprecated security_context_t

libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: don't use deprecated security_context_t
Karel Zak [Mon, 14 Dec 2020 14:44:59 +0000 (15:44 +0100)] 
libmount: don't use deprecated security_context_t

libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: check for libselinux >= 3.1
Karel Zak [Mon, 14 Dec 2020 14:44:38 +0000 (15:44 +0100)] 
build-sys: check for libselinux >= 3.1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: update blkid output for iso/udf
Karel Zak [Mon, 14 Dec 2020 12:42:01 +0000 (13:42 +0100)] 
tests: update blkid output for iso/udf

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: read SCSI_IDENT_SERIAL also from udev
Karel Zak [Mon, 14 Dec 2020 10:38:04 +0000 (11:38 +0100)] 
lsblk: read SCSI_IDENT_SERIAL also from udev

Addresses: https://github.com/karelzak/util-linux/issues/1143
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkid: add another UDF identifiers
Karel Zak [Fri, 11 Dec 2020 09:02:22 +0000 (10:02 +0100)] 
blkid: add another UDF identifiers

Reported-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkid: encode all udf and iso IDs in udev output
Karel Zak [Thu, 10 Dec 2020 11:10:06 +0000 (12:10 +0100)] 
blkid: encode all udf and iso IDs in udev output

We encode to "safe" strings almost all variables for 'blkid -o udev'
and we need it also for SYSTEM_ID, PUBLISHER_ID, APPLICATION_ID,
BOOT_SYSTEM_ID and recently added VOLUME_SET_ID and DATA_PREPARER_ID.

This change makes blkid from util-linux more compatible with built-in
udevd blkid.

Addresses: https://github.com/karelzak/util-linux/pull/1215 (commit 5cbffdb74f6fec51b2cf260bea66375823fe65e7)
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: iso9660: add new test images
Pali Rohár [Thu, 10 Dec 2020 01:38:06 +0000 (02:38 +0100)] 
libblkid: iso9660: add new test images

Image iso-different-iso-joliet-label contains different identifiers in ISO
and Joliet locations. Identifiers are prefixed with "ISO" or "Joliet"
string to verify that UNICODE Joliet has preference over ASCII ISO.

Image iso-unicode-long-label contains very long identifiers in ISO location
which do not fit into the Joliet location. In ISO location is UNICODE
character 'ï' replaced by '_' and unrepresentable spaces also by '_'.
This test verifies that libblkid can use first half of identifiers from
Joliet (which contains UNICODE) and second half from ISO which is just
uppercase and only small subset of ASCII. This image was generated by Nero
Linux software and basically this truncate and '_' replacement is done by
default for any long or UNICODE label.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: add support for VOLUME_SET_ID and DATA_PREPARER_ID
Pali Rohár [Thu, 10 Dec 2020 00:52:18 +0000 (01:52 +0100)] 
libblkid: iso9660: add support for VOLUME_SET_ID and DATA_PREPARER_ID

udf superblock code already sets VOLUME_SET_ID to Volume Set Identifier
from UDF Primary Volume Descriptor.

In iso9660 similar meaning has Volume Set Identifier in ISO9660
Primary (or Supplementary Joliet) Volume Descriptor. Therefore exports it
as VOLUME_SET_ID label.

In ISO9660 Primary (and Supplementary Joliet) Volume Descriptor exists
another member Data Preparer Identifier which is currently not parsed by
iso9660 superblock code.

To have iso9660 superblock code feature complete export also Data Preparer
Identifier as DATA_PREPARER_ID label. UDF does not have equivalent of Data
Preparer Identifier.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: parse SYSTEM_ID, PUBLISHER_ID and APPLICATION_ID from Joliet
Pali Rohár [Thu, 10 Dec 2020 00:43:46 +0000 (01:43 +0100)] 
libblkid: iso9660: parse SYSTEM_ID, PUBLISHER_ID and APPLICATION_ID from Joliet

Joliet may contain UNICODE variant of these identifiers. So prefer UNICODE
variant from Joliet over ASCII variant if Joliet one is available.

Also use same technique as for Label for reconstructing original UNICODE
variants of these identifiers.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: improve label parsing
Pali Rohár [Wed, 9 Dec 2020 23:21:55 +0000 (00:21 +0100)] 
libblkid: iso9660: improve label parsing

Label in Joliet is UNICODE (UTF16BE) but can contain only 16 characters.
Label in PVD is subset of ASCII but can contain up to the 32 characters.
Non-representable characters are stored as replacement character '_'.

Label in Joliet is in most cases trimmed but UNICODE version of label in
PVD. Based on these facts try to reconstruct original label if label in
Joliet is prefix of the label in PVD (ignoring non-representable
characters).

It is possible that label in Joliet and PVD are totally different. In this
case label from Joliet as prior this change.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: fix parsing images which do not have Primary Volume Descriptor...
Pali Rohár [Wed, 9 Dec 2020 00:22:28 +0000 (01:22 +0100)] 
libblkid: iso9660: fix parsing images which do not have Primary Volume Descriptor as the first

ECMA 119 (ISO 9660) does not mandate that Primary Volume Descriptor needs
to be the first in Volume Descriptor Set sequence.

Move assignment of labels outside of the for-loop and correctly detects
Primary Volume Descriptor via its type (0x01) at any position in sequence.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: set block size also for High Sierra format
Pali Rohár [Wed, 9 Dec 2020 00:22:10 +0000 (01:22 +0100)] 
libblkid: iso9660: set block size also for High Sierra format

High Sierra format has also block size 2048.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: check that iso->publisher_id and iso->application_id are not file...
Pali Rohár [Tue, 8 Dec 2020 23:36:13 +0000 (00:36 +0100)] 
libblkid: iso9660: check that iso->publisher_id and iso->application_id are not file paths

ECMA 119 (ISO 9660) says that if the first byte is set to (5F), the
remaining bytes of this field shall specify an identifier for a file
containing the data. As libblkid does not support reading files from the
filesystem itself it cannot parse fields which starts with 0x5F '_' char.

So for now ignore iso->publisher_id and iso->application_id values which
starts with '_' character.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: iso9660: do not check is_str_empty() for iso->system_id and boot->boot_syst...
Pali Rohár [Tue, 8 Dec 2020 23:34:23 +0000 (00:34 +0100)] 
libblkid: iso9660: do not check is_str_empty() for iso->system_id and boot->boot_system_id

ECMA 119 (ISO 9660) does not say anything if all bytes are of these fields
are FILLER then fields are not set. It says it for iso->publisher_id and
iso->application_id.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agotests: (fileutils) remove unused code
Karel Zak [Tue, 8 Dec 2020 12:09:10 +0000 (13:09 +0100)] 
tests: (fileutils) remove unused code

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (blkid) add erofs image
Karel Zak [Tue, 8 Dec 2020 09:52:20 +0000 (10:52 +0100)] 
tests: (blkid) add erofs image

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: add erofs filesystem support
Gao Xiang [Sat, 5 Dec 2020 07:44:10 +0000 (15:44 +0800)] 
libblkid: add erofs filesystem support

Enhanced Read-Only File System (EROFS) has been included in Linux
kernel, many Linux distributions, buildroot and Android AOSP for
a while. Plus, nowadays, it's known that EROFS has been commercially
used by several Android vendors for their system partitions.
util-linux in busybox can also detect it recently.

This patch adds support for detecting EROFS filesystem to libblkid.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
4 years agoMerge branch 'master' of https://github.com/pali/util-linux into master
Karel Zak [Mon, 7 Dec 2020 12:44:25 +0000 (13:44 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux into master

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: update test output for APPLICATION_ID and PUBLISHER_ID
  libblkid: udf: add support for PUBLISHER_ID
  libblkid: udf: add support for APPLICATION_ID
  libblkid: udf: check that dstrings are encoded in OSTA Compressed Unicode

4 years agoMerge branch 'fix/losetup-printf' of https://github.com/bahnwaerter/util-linux into...
Karel Zak [Mon, 7 Dec 2020 12:37:41 +0000 (13:37 +0100)] 
Merge branch 'fix/losetup-printf' of https://github.com/bahnwaerter/util-linux into master

* 'fix/losetup-printf' of https://github.com/bahnwaerter/util-linux:
  losetup: fix wrong printf() format specifier for ino_t data type

4 years agologin: fix compiler warning [-Werror=strict-prototypes]
Karel Zak [Mon, 7 Dec 2020 12:26:33 +0000 (13:26 +0100)] 
login: fix compiler warning [-Werror=strict-prototypes]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolosetup: fix wrong printf() format specifier for ino_t data type
Manuel Bentele [Sat, 5 Dec 2020 22:51:27 +0000 (23:51 +0100)] 
losetup: fix wrong printf() format specifier for ino_t data type

Since the range of the ino_t data type is platform-specific (depending on
the wordsize), a usage of the fixed format specifier %PRIu64 is not correct
for ino_t on some 32-bit architectures, eg. ARM (Raspberry Pi 1). This issue
may lead to undefinied output and is not reported by gcc (in version 10.2.0
and 8.3.0-6+rpi1) even though -Wformat is enabled by -Wall. Therefore it is
most likely that it seems to be a false negative error in gcc's format
specifier check, so that this issue was never detected before.

This change fixes the issue by the use of a cast, since there is no
platform-independent format specifier for ino_t available. The wrong format
specifier %PRIu64 is replaced by %ju, where its corresponding variable of
type ino_t is casted to uintmax_t. The type uintmax_t represents the largest
platform-specific unsigned integer, so that all integer values are preserved
for a platform-independent printing.

Fixes: https://github.com/karelzak/util-linux/issues/1211
Signed-off-by: Manuel Bentele <development@manuel-bentele.de>
4 years agolibblkid: udf: update test output for APPLICATION_ID and PUBLISHER_ID
Pali Rohár [Sat, 5 Dec 2020 20:10:23 +0000 (21:10 +0100)] 
libblkid: udf: update test output for APPLICATION_ID and PUBLISHER_ID

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: udf: add support for PUBLISHER_ID
Pali Rohár [Sat, 5 Dec 2020 19:45:25 +0000 (20:45 +0100)] 
libblkid: udf: add support for PUBLISHER_ID

iso9660 superblock code already sets PUBLISHER_ID to Publisher Identifier
from ISO9660 Supplementary Volume Descriptor.

In udf field LVInfo1 from Implementation Use Volume Descriptor could
contain information such as Owner Name. More UDF generating tools
(e.g. Solaris's labelit or Linux udftools 2.3+) set this field to person
who creating the filesystem therefore its meaning is similar to ISO9660
Publisher Identifier. So for compatibility with iso9660 superblock code
export this field via PUBLISHER_ID label.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: udf: add support for APPLICATION_ID
Pali Rohár [Sat, 5 Dec 2020 19:43:22 +0000 (20:43 +0100)] 
libblkid: udf: add support for APPLICATION_ID

iso9660 superblock code already sets APPLICATION_ID to Application
Identifier from ISO9660 Supplementary Volume Descriptor.

In udf similar meaning has Application Identifier from UDF Primary Volume
Descriptor. Therefore exports it as APPLICATION_ID label.

More tools for generating hybrid ISO+UDF images (e.g. genisoimage, mkisofs
or nero) set Application Identifier in UDF Primary Volume Descriptor to
just empty string. But they set Implementation Identifier in UDF Primary
Volume Descriptor to their tool name.

So if Application Identifier is empty then exports Implementation
Identifier as APPLICATION_ID label.

Please note that Application Identifier and Implementation Identifier are
stored in UDF only in ASCII, not UNICODE.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agolibblkid: udf: check that dstrings are encoded in OSTA Compressed Unicode
Pali Rohár [Sat, 5 Dec 2020 19:39:35 +0000 (20:39 +0100)] 
libblkid: udf: check that dstrings are encoded in OSTA Compressed Unicode

dstring structures are in UL_ENCODE_LATIN1/UL_ENCODE_UTF16BE encodings only
when corresponding desc_charset structures are set to the OSTA Compressed
Unicode. So add missing checks.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agologin: tidy up manual page
Sami Kerola [Mon, 16 Nov 2020 21:37:29 +0000 (21:37 +0000)] 
login: tidy up manual page

Add defaults to couple logindefs, and generally clean up  manual page a
little bit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolib/fileutils: make close_all_fds() to be similar with close_range()
Sami Kerola [Wed, 2 Dec 2020 22:56:16 +0000 (22:56 +0000)] 
lib/fileutils: make close_all_fds() to be similar with close_range()

The util-linux close_all_fds() serves the same purpose as close_range()
that will over time obsolete local implementation completely.  For
upcoming few years it is best to have a fallback that uses same input
arguments as the new system call.  That allows surrounding code and
variables not to be affected by version of mass file descriptor closing
function.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1205#discussion_r534080128
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use close_range() system call when possible
Sami Kerola [Sat, 14 Nov 2020 12:55:10 +0000 (12:55 +0000)] 
login: use close_range() system call when possible

This system call was added while back, but does not have glibc support yet.
Lets try to use the new facility early on.  The promise in reference link is
that the new call is faster, and works when /proc is not mounted.

Reference: https://lwn.net/Articles/789000/
Reference: https://lwn.net/Articles/789023/
Reference: https://kernelnewbies.org/LinuxChanges#Linux_5.9.New_close_range.28.29_system_call_for_easier_closing_of_file_descriptors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: move message printing out from main()
Sami Kerola [Sat, 14 Nov 2020 11:32:54 +0000 (11:32 +0000)] 
login: move message printing out from main()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use xalloc memory allocation helpers everywhere
Sami Kerola [Fri, 13 Nov 2020 23:04:43 +0000 (23:04 +0000)] 
login: use xalloc memory allocation helpers everywhere

Apart two function calls login(1) already used xalloc functions.  If there
was a time when login tried to gracefully handle allocation errors that has
not been true for long time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: fix coding style issues
Sami Kerola [Fri, 13 Nov 2020 22:11:01 +0000 (22:11 +0000)] 
login: fix coding style issues

Couple function had spaces instead of tabs in indent.  This change uses tabs
everywhere, and does handful of other spacing additions and removals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use system definitions to determine maxium login name length
Sami Kerola [Fri, 13 Nov 2020 21:25:02 +0000 (21:25 +0000)] 
login: use system definitions to determine maxium login name length

Allocating stack for about 10x more than longest possible user name is
wasteful, even if it happens for reletively short period of time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use calloc() when memory needs to be cleared
Sami Kerola [Fri, 13 Nov 2020 22:58:17 +0000 (22:58 +0000)] 
login: use calloc() when memory needs to be cleared

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use explicit_bzero() to get rid of confidental memory
Sami Kerola [Fri, 13 Nov 2020 20:55:19 +0000 (20:55 +0000)] 
login: use explicit_bzero() to get rid of confidental memory

Earlier code was most probably correct, but it is best to be safe than sorry
when dealing with confidental data removals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: add initialize() function to have less stack allocated in main()
Sami Kerola [Fri, 13 Nov 2020 00:17:18 +0000 (00:17 +0000)] 
login: add initialize() function to have less stack allocated in main()

And move couple variables to the narrow scope they are used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: replace function like definitions with inline functions
Sami Kerola [Thu, 12 Nov 2020 23:53:44 +0000 (23:53 +0000)] 
login: replace function like definitions with inline functions

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: move getlogindefs_num() after localization init
Sami Kerola [Thu, 12 Nov 2020 23:44:55 +0000 (23:44 +0000)] 
login: move getlogindefs_num() after localization init

There are translations in getlogindefs_num() and they will not take effect
unless the function call is after the setlocale(), bindtextdomain(), and
textdomain().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: move timeout from global to local scope
Sami Kerola [Thu, 12 Nov 2020 23:58:59 +0000 (23:58 +0000)] 
login: move timeout from global to local scope

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: stop keeping timeout message in memory forever
Sami Kerola [Thu, 12 Nov 2020 23:40:30 +0000 (23:40 +0000)] 
login: stop keeping timeout message in memory forever

When the timeout is cancelled the message can be removed from memory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: use sig_atomic_t type for variable accessed from signal handler
Sami Kerola [Thu, 12 Nov 2020 23:34:16 +0000 (23:34 +0000)] 
login: use sig_atomic_t type for variable accessed from signal handler

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'col-bug1198' of https://github.com/kerolasa/util-linux
Karel Zak [Thu, 3 Dec 2020 14:09:19 +0000 (15:09 +0100)] 
Merge branch 'col-bug1198' of https://github.com/kerolasa/util-linux

* 'col-bug1198' of https://github.com/kerolasa/util-linux:
  col: make input to tolerate invalid wide characters

4 years agolibsmartcols: sanitize variable names on export output
Karel Zak [Thu, 3 Dec 2020 11:14:10 +0000 (12:14 +0100)] 
libsmartcols: sanitize variable names on export output

The shells are very restrictive about variable names, only [:alnum:]
chars are allowed (and alphabetic chars as the first char).  The
library will replace "bad" chars with "_". The char '%' at the end is
replaced by _PCT.

Addresses: https://github.com/karelzak/util-linux/issues/1201
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocol: make input to tolerate invalid wide characters
Sami Kerola [Thu, 26 Nov 2020 22:01:39 +0000 (22:01 +0000)] 
col: make input to tolerate invalid wide characters

The getwchar(3) will choke and exit if invalid character is encountered.
This change will make col(1) to print broken multibyte characters as
\x{hex} string.

Reported-by: Vitaly Lipatov <lav@etersoft.ru>
Addresses: https://github.com/karelzak/util-linux/issues/1198
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'dankamongmen/libblkid-manual-fix' of https://github.com/dankamongmen...
Karel Zak [Wed, 2 Dec 2020 11:06:25 +0000 (12:06 +0100)] 
Merge branch 'dankamongmen/libblkid-manual-fix' of https://github.com/dankamongmen/util-linux

4 years agotravis: disable OSX for now
Karel Zak [Tue, 1 Dec 2020 10:44:09 +0000 (11:44 +0100)] 
travis: disable OSX for now

For weeks we have a problem with timeout on OSX on travis, not sure
how to fix it ... volunteer wanted :-)

 ==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.19.1 --no-system-libs --paral
 ==> make

 No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
 Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

 The build has been terminated

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofuzzers: make tests setup more robust
Karel Zak [Tue, 1 Dec 2020 10:35:02 +0000 (11:35 +0100)] 
fuzzers: make tests setup more robust

- use robust functions like write_all()
- don't use assert() to check write/open/etc return values, because oss-fuzz.com
  report foreign (system, libc, ...) issues as our fails

Addresses: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28009
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (blkid) add support for multisession images
Karel Zak [Mon, 30 Nov 2020 09:33:20 +0000 (10:33 +0100)] 
tests: (blkid) add support for multisession images

This commit adds support for multisession filesystem images to
standard low-probe blkid tests. The expected image name is

 <name>-multi-<offset>[-<offset> ...][-<something>].img

For example:
  iso-multi-0-174-348-genisoimage.img.xz

triggers three sub-tests:
  : iso-multi-genisoimage-0     ... OK
  : iso-multi-genisoimage-174   ... OK
  : iso-multi-genisoimage-348   ... OK

Addresses: https://github.com/karelzak/util-linux/issues/1161
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: fix some typos in function comments
nick black [Fri, 27 Nov 2020 03:52:20 +0000 (22:52 -0500)] 
libblkid: fix some typos in function comments

4 years agolibblkid: initialize magic strings in robust way
Karel Zak [Wed, 25 Nov 2020 14:45:23 +0000 (15:45 +0100)] 
libblkid: initialize magic strings in robust way

It is the worst habit to depend on the order of the members of the
structure ...

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge remote-tracking branch 'pali/multisesssion'
Karel Zak [Wed, 25 Nov 2020 13:48:30 +0000 (14:48 +0100)] 
Merge remote-tracking branch 'pali/multisesssion'

* pali/multisesssion:
  libblkid: udf: add support for unclosed sequential Write-Once media
  libblkid: udf: add support for multisession via session_offset hint
  libblkid: iso9660: add support for multisession via session_offset hint
  libblkid: fix blkid_probe_get_sb() to use hint offset calculation
  libblkid: allow to specify offset defined by hint for blkid_probe_get_idmag()
  libblkid: detect session_offset hint for optical discs
  libblkid: do size correction of optical discs also by last written sector
  libblkid: detect CD/DVD discs in packet writing mode
  libblkid: overwrite existing hint
  libblkid: export blkid_probe_reset_hints()
  blkid: add --hint <name>=value
  libblkid: add blkid_probe_{set,get}_hint()

4 years agolslogins: call close() for usable FD [coverity scan]
Karel Zak [Wed, 25 Nov 2020 13:02:11 +0000 (14:02 +0100)] 
lslogins: call close() for usable FD [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge remote-tracking branch 'sami/uuidd-work'
Karel Zak [Tue, 24 Nov 2020 12:12:22 +0000 (13:12 +0100)] 
Merge remote-tracking branch 'sami/uuidd-work'

* sami/uuidd-work:
  uuidd: fix misleading indentation
  uuidd: make timeout to take effect when debug is not defined
  uuidd: remove unnecessary bulk request size limit
  uuidd: add uuidd specific data types that are used in protocol
  uuidd: reorder bulk time and random generation code
  uuidd: document uuidd protocol
  uuidd: override operation type when performing bulk request
  uuidd: move option parsing to separate function
  uuidd: add command-line option values struct
  uuidd: use pid_t type when referring to process id

4 years agobuild-sys: do not use extra subdir for getopt examples
Karel Zak [Tue, 24 Nov 2020 11:46:03 +0000 (12:46 +0100)] 
build-sys: do not use extra subdir for getopt examples

This is unnecessary, we have ${docsdir}/util-linux which is good
enough for these two getopt examples. I guess the "getopt"
subdirectory is legacy from time getopt has been merged into
util-linux.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotravis: try update to xcode10.1
Karel Zak [Tue, 24 Nov 2020 10:31:45 +0000 (11:31 +0100)] 
travis: try update to xcode10.1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: add dependence between CD/DVD block and packet devices
Karel Zak [Mon, 23 Nov 2020 14:16:39 +0000 (15:16 +0100)] 
lsblk: add dependence between CD/DVD block and packet devices

This dependence is defined by

  $ cat /sys/class/pktcdvd/device_map
  pktcdvd0 252:0 11:0

Unfortunately, there is not any direct sysfs way how to refer this
relationship in /sys/{block,dev/block}. So, we have to read the
device_map file and then compare device numbers with the list.

$ lsblk /dev/sr0
NAME       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0         11:0    1 1024M  0 rom
└─pktcdvd0 252:0    1    0B  0 disk

Addresses: https://github.com/karelzak/util-linux/issues/1185
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agouuidd: fix misleading indentation
Sami Kerola [Sat, 21 Nov 2020 22:16:48 +0000 (22:16 +0000)] 
uuidd: fix misleading indentation

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: make timeout to take effect when debug is not defined
Sami Kerola [Sat, 21 Nov 2020 22:12:36 +0000 (22:12 +0000)] 
uuidd: make timeout to take effect when debug is not defined

The trailing comma made code to compile without issues, but meant all_done()
was called only when --debug was in defined in command-line.

Fixes: 3d6250e96b0041a3cbe2f8dd3e746cca5d6ac121
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: remove unnecessary bulk request size limit
Sami Kerola [Sat, 21 Nov 2020 21:24:10 +0000 (21:24 +0000)] 
uuidd: remove unnecessary bulk request size limit

Limiting random query to 1000 uuid's was pointless when the next line will
further restrict upper limit to 63 entries.  The 63 entries is what fits to
the uuidd communication buffer with the header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: add uuidd specific data types that are used in protocol
Sami Kerola [Sat, 21 Nov 2020 16:57:43 +0000 (16:57 +0000)] 
uuidd: add uuidd specific data types that are used in protocol

Use a typedef for types that are sensitive what comes to uuidd protocol
field widths, read write sizes, and related checks.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1196#discussion_r528595794
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: reorder bulk time and random generation code
Sami Kerola [Sat, 21 Nov 2020 18:13:45 +0000 (18:13 +0000)] 
uuidd: reorder bulk time and random generation code

Write the data and response length values in same close to order they appear
in protocol.  This should make code a little easier to read.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: document uuidd protocol
Sami Kerola [Sat, 21 Nov 2020 16:38:58 +0000 (16:38 +0000)] 
uuidd: document uuidd protocol

Seeing what can be expected should make it easier to understand what the
code does.

Notice that simply writing down the resposes one can start wondering deeper
questions, such as, why does the time bulk response reply only one uuid
followed by number how many were requested?  Was that a some type of TODO
note?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: override operation type when performing bulk request
Sami Kerola [Sat, 21 Nov 2020 10:14:17 +0000 (10:14 +0000)] 
uuidd: override operation type when performing bulk request

Relying to single vs bulk requests to be exactly two steps away from each
other was an unnecessary dirty trick.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: move option parsing to separate function
Sami Kerola [Fri, 20 Nov 2020 22:27:34 +0000 (22:27 +0000)] 
uuidd: move option parsing to separate function

Moving the option parsing to a separate function will allow moving some
variables from main() heap to be in scope that free them later.  That should
make the uuidd to have a little bit smaller runtime memory allocation.

The static long options is changed to be local variable.  That should make
it to be part of heap for a bit, until removed.  Earlier the variable was in
data segment and permanently in runtime memory.  Whether this makes any
impact either way is not entirely clear, but hope is the runtime memory
allocation is tiny bit smaller.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: add command-line option values struct
Sami Kerola [Fri, 20 Nov 2020 22:17:22 +0000 (22:17 +0000)] 
uuidd: add command-line option values struct

The struct will help seeing where the variable values are coming from.  This
will also help upcoming refactoring.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agouuidd: use pid_t type when referring to process id
Sami Kerola [Fri, 20 Nov 2020 22:05:46 +0000 (22:05 +0000)] 
uuidd: use pid_t type when referring to process id

Earlier use of a variable that holds switch enabling boolean to hold process
id was a little bit strange, and not exactly correct.  An int should be good
enough to hold any pid, but it is better to be precise and use the type that
is meant for the job.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 23 Nov 2020 09:21:17 +0000 (10:21 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label

4 years agoMerge branch 'privfix' of https://github.com/ericonr/util-linux
Karel Zak [Mon, 23 Nov 2020 09:19:01 +0000 (10:19 +0100)] 
Merge branch 'privfix' of https://github.com/ericonr/util-linux

4 years agolibblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label
Pali Rohár [Sun, 22 Nov 2020 18:44:09 +0000 (19:44 +0100)] 
libblkid: drbdmanage: use blkid_probe_strncpy_uuid instead of blkid_probe_set_id_label

Function blkid_probe_strncpy_uuid() is better suitable for setting UUID
than function blkid_probe_set_id_label().

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
4 years agosetpriv: allow using [-+]all for capabilities.
Érico Rolim [Wed, 18 Nov 2020 14:35:26 +0000 (11:35 -0300)] 
setpriv: allow using [-+]all for capabilities.

The initial change to lib/caputils that allowed this was commit
5d95818757941bc609e5aeec5e2218f7d35a6e19, which made it possible to
trust the value returned by cap_last_cap().

The error message was also somewhat misleading, since cap_last_cap()
being smaller than CAP_LAST_CAP happens when setpriv itself is built
with kernel headers older than the currently running kernel, not due to
libcap-ng.

4 years agosetpriv: small clean-up.
Érico Rolim [Fri, 20 Nov 2020 15:33:23 +0000 (12:33 -0300)] 
setpriv: small clean-up.

- Add _() calls for some strings which were missing it.
- In print_caps(), use the same error checking done in
  list_known_caps(); it is expected that libcap-ng will always return a
  string, even if it's only "cap_%d".

4 years agoMerge branch 'w45'
Karel Zak [Fri, 20 Nov 2020 11:01:22 +0000 (12:01 +0100)] 
Merge branch 'w45'

* w45:
  fdformat: remove command from default build
  more: improve error messaging when input file is directory
  ul: make set_column() zero check more obvious
  colrm: fix argument parsing
  rfkill: stop execution when rfkill device cannot be opened
  cifuzz: reindent yaml file
  man: make tilde and caret characters to render correctly

4 years agolib/caputils: split to multiple functions, add test
Karel Zak [Fri, 20 Nov 2020 10:21:41 +0000 (11:21 +0100)] 
lib/caputils: split to multiple functions, add test

Let's split the code to make it possible to test separately bsearch as
well as procfs based cap_last_cap().

 $ ./test_caputils --last-by-bsearch
 last cap: 39
 $ ./test_caputils --last-by-procfs
 last cap: 39
 $ ./test_caputils --last
 last cap: 39

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/procutils: improve proc_is_procfs(), add test
Karel Zak [Fri, 20 Nov 2020 09:38:01 +0000 (10:38 +0100)] 
lib/procutils: improve proc_is_procfs(), add test

* add delay between attempts
* zeroize errno and check for EAGAIN (like in other code)
* add small test program
   ./test_procutils --is-procfs [<dir>]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'caps' of https://github.com/ericonr/util-linux
Karel Zak [Fri, 20 Nov 2020 09:21:19 +0000 (10:21 +0100)] 
Merge branch 'caps' of https://github.com/ericonr/util-linux

* 'caps' of https://github.com/ericonr/util-linux:
  lib/caputils: add fall back for last cap using prctl.
  lib/procutils: add proc_is_procfs helper.

4 years agolscpu: show the number of physical socket on aarch64 machine without ACPI PPTT
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:09 +0000 (00:06 -0500)] 
lscpu: show the number of physical socket on aarch64 machine without ACPI PPTT

Show the number of the number of physical socket even if the sysfs doesn't
have the physical socket information.

Note, lscpu shows the number of physical socket as 'Socket(s):' only if
root user runs it because accessing the DMI table requires root
privilege.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu: add helper to get physical sockets
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:08 +0000 (00:06 -0500)] 
lscpu: add helper to get physical sockets

Add a helper function, get_number_of_physical_sockets_from_dmi(),
to get physical sockets from DMI table in case of the sysfs for
cpu topology doesn't have the physical socket information.

get_number_of_physical_sockets_from_dmi() parse the DMI table
and counts the number of SMBIOS Processor Information (Type04)
structure.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu-dmi: Move some functions related to DMI to lscpu-dmi
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:07 +0000 (00:06 -0500)] 
lscpu-dmi: Move some functions related to DMI to lscpu-dmi

Move some functions related to DMI to lscpu-dmi.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu-virt: split hypervisor_from_dmi_table()
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:06 +0000 (00:06 -0500)] 
lscpu-virt: split hypervisor_from_dmi_table()

Split hypervisor_from_dmi_table() to parsing dmi table and checking the
hypervisor vendor.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT
Masayoshi Mizuma [Fri, 20 Nov 2020 05:06:05 +0000 (00:06 -0500)] 
lscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT

lscpu may show the wrong number of sockets if the machine is aarch64 and
doesn't have ACPI PPTT.

That's because lscpu shows the number of sockets by using a sysfs entry
(cpu/cpuX/topology/core_siblings). The sysfs entry is set by MPIDR_EL1
register if the machine doesn't have ACPI PPTT. MPIDR_EL1 doesn't show
the physical socket information directly. It shows the affinity level.

According to linux/arch/arm64/kernel/topology.c:store_cpu_topology(),
the top level of affinity is called as 'Cluster'.

Use Cluster instead of Socket on the machine which doesn't have ACPI PPTT.

This patch is useful for aarch64 machine which is based on ARM
SBBR v1.0 and v1.1, the specs don't require ACPI PPTT. ARM SBBR v1.2
requires ACPI PPTT.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
4 years agolib/signames: change license to public domain
Karel Zak [Thu, 19 Nov 2020 11:04:08 +0000 (12:04 +0100)] 
lib/signames: change license to public domain

The file is simple list of signal names and trivial function to search
in the list. We do not need any extra license here and as public
domain it will be more portable to other tools (GPL and BSD) in the
util-linux.

All previous contributors (Sami, Niklas and me) agree with this change.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix resource leak [coverity scan]
Karel Zak [Thu, 19 Nov 2020 11:00:58 +0000 (12:00 +0100)] 
lscpu: fix resource leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix possible null dereferences [coverity scan]
Karel Zak [Thu, 19 Nov 2020 10:57:19 +0000 (11:57 +0100)] 
lscpu: fix possible null dereferences [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoumount: ignore --no-canonicalize,-c for non-root users
Karel Zak [Thu, 19 Nov 2020 10:12:06 +0000 (11:12 +0100)] 
umount: ignore --no-canonicalize,-c for non-root users

It seems better to ignore this option than drop-permissions and later
exit with EPERMs. This change makes umount(8) more compatible with
fuser user umounts by systemd where -c is used to reduce overhead etc.

Addresses: https://github.com/karelzak/util-linux/issues/1192
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: don't use "symfollow" for helpers on user mounts
Karel Zak [Thu, 19 Nov 2020 08:49:16 +0000 (09:49 +0100)] 
libmount: don't use "symfollow" for helpers on user mounts

Addresses: https://github.com/karelzak/util-linux/issues/1193
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/caputils: add fall back for last cap using prctl.
Érico Rolim [Sun, 15 Nov 2020 04:34:41 +0000 (01:34 -0300)] 
lib/caputils: add fall back for last cap using prctl.

This allows the rest of the programs using cap_last_cap to trust the
value returned by it, since it will either be obtained from procfs
(straight from kernel) or with prctl.

Also checked if the file under /proc is actually mounted in a procfs.

4 years agolib/procutils: add proc_is_procfs helper.
Érico Rolim [Wed, 18 Nov 2020 17:07:10 +0000 (14:07 -0300)] 
lib/procutils: add proc_is_procfs helper.

Also add missing include in procutils.h for the definition of pid_t.

4 years agoMerge branch 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux
Karel Zak [Wed, 18 Nov 2020 09:32:39 +0000 (10:32 +0100)] 
Merge branch 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux

* 'hwclock-syscall-nr' of https://github.com/pinotree/util-linux:
  hwclock: do not assume __NR_settimeofday_time32

4 years agohwclock: do not assume __NR_settimeofday_time32
Pino Toscano [Tue, 17 Nov 2020 10:32:45 +0000 (11:32 +0100)] 
hwclock: do not assume __NR_settimeofday_time32

Check that __NR_settimeofday_time32 exists before trying to use it as
syscall number.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>