Commit Graph

14972 Commits

Author SHA1 Message Date
Anatoly Pugachev 67c9744c10 tests: add checksum for cramfs/mkfs for LE:16384 (ia64)
Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2020-12-19 21:36:00 +03:00
Karel Zak 7ed579523b lib: fix compiler warnings [-Wmaybe-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-17 11:07:38 +01:00
Karel Zak 22a64b02b9 libmount: fix compiler warnings [-Wmaybe-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-17 11:07:25 +01:00
Karel Zak 60bad224a8 tests: suggest "make check-programs"
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-17 10:57:33 +01:00
Karel Zak 5ebff0918d lscpu: remove unnecessary prefix from static function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-15 11:31:57 +01:00
Karel Zak cf918bd3ac 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>
2020-12-14 16:03:03 +01:00
Karel Zak 117cbf9180 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>
2020-12-14 16:01:55 +01:00
Karel Zak cf8c191738 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>
2020-12-14 15:59:45 +01:00
Karel Zak 5d58258d62 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>
2020-12-14 15:56:55 +01:00
Karel Zak ca6fcc1a89 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>
2020-12-14 15:54:08 +01:00
Karel Zak e522815027 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>
2020-12-14 15:54:08 +01:00
Karel Zak eba9ef598f 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>
2020-12-14 15:54:08 +01:00
Karel Zak 1468eda63f build-sys: check for libselinux >= 3.1
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 15:49:30 +01:00
Karel Zak 61c49a6ed5 tests: update blkid output for iso/udf
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 13:42:01 +01:00
Karel Zak 1492fb4ef2 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>
2020-12-14 11:38:04 +01:00
Karel Zak 72ab706502 blkid: add another UDF identifiers
Reported-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-11 10:02:22 +01:00
Karel Zak 150394604d 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 5cbffdb74f)
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-10 12:10:06 +01:00
Pali Rohár eb6a4cc2e1 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>
2020-12-10 02:38:06 +01:00
Pali Rohár 5cbffdb74f 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>
2020-12-10 01:52:18 +01:00
Pali Rohár 18565da827 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>
2020-12-10 01:43:46 +01:00
Pali Rohár dab6d75cfc 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>
2020-12-10 00:21:55 +01:00
Pali Rohár 4bfcb1fc4a 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>
2020-12-09 01:22:28 +01:00
Pali Rohár db66eddf7f 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>
2020-12-09 01:22:10 +01:00
Pali Rohár 5ff184b5b5 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>
2020-12-09 00:36:13 +01:00
Pali Rohár 8d027a2135 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>
2020-12-09 00:34:23 +01:00
Karel Zak 2a2b7da131 tests: (fileutils) remove unused code
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-08 13:09:10 +01:00
Karel Zak 5bc0378bfa tests: (blkid) add erofs image
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-08 10:52:20 +01:00
Gao Xiang 7b2a874e2e 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>
2020-12-08 10:34:47 +01:00
Karel Zak 5594c690e5 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
2020-12-07 13:44:25 +01:00
Karel Zak cc72e0d2cf 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
2020-12-07 13:37:41 +01:00
Karel Zak 96c8282584 login: fix compiler warning [-Werror=strict-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-07 13:26:33 +01:00
Manuel Bentele cd3f22e6e0
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>
2020-12-05 23:51:27 +01:00
Pali Rohár b6168ae9cf libblkid: udf: update test output for APPLICATION_ID and PUBLISHER_ID
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2020-12-05 21:10:23 +01:00
Pali Rohár 67c4bf1f24 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>
2020-12-05 20:45:25 +01:00
Pali Rohár f09ceed2b6 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>
2020-12-05 20:43:22 +01:00
Pali Rohár d8056b5489 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>
2020-12-05 20:39:35 +01:00
Sami Kerola 07b12154dc
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>
2020-12-03 20:09:15 +00:00
Sami Kerola a75700d86e
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>
2020-12-03 20:09:14 +00:00
Sami Kerola f0649c0d83
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>
2020-12-03 20:09:14 +00:00
Sami Kerola 931e60982e
login: move message printing out from main()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:09:14 +00:00
Sami Kerola b04f183578
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>
2020-12-03 20:07:30 +00:00
Sami Kerola 7679a2c5ca
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>
2020-12-03 20:07:30 +00:00
Sami Kerola d515381901
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>
2020-12-03 20:07:29 +00:00
Sami Kerola 5941a0db06
login: use calloc() when memory needs to be cleared
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:07:29 +00:00
Sami Kerola 0da0a5ed3b
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>
2020-12-03 20:07:29 +00:00
Sami Kerola 5dd0896aa8
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>
2020-12-03 20:07:28 +00:00
Sami Kerola 79a8afeb8f
login: replace function like definitions with inline functions
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:06:51 +00:00
Sami Kerola fb038d27a1
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>
2020-12-03 20:06:51 +00:00
Sami Kerola 0b4d75fae5
login: move timeout from global to local scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-03 20:06:47 +00:00
Sami Kerola bfcba3f586
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>
2020-12-03 19:54:29 +00:00