Compare commits

...
Sign in to create a new pull request.

155 commits

Author SHA1 Message Date
Karel Zak
12f5423fc2 build-sys: release++ (v2.37.4)
Some checks failed
Build test / build (map[COMPILER:clang COMPILER_VERSION:10 SANITIZE:no]) (push) Has been cancelled
Build test / build (map[COMPILER:clang COMPILER_VERSION:10 SANITIZE:yes]) (push) Has been cancelled
Build test / build (map[COMPILER:gcc COMPILER_VERSION:10 SANITIZE:no]) (push) Has been cancelled
Build test / build (map[COMPILER:gcc COMPILER_VERSION:10 SANITIZE:yes]) (push) Has been cancelled
Build test / distcheck (push) Has been cancelled
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 10:50:32 +01:00
Karel Zak
0eb9b50878 docs: update v2.37.4-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 10:48:24 +01:00
Karel Zak
c6fe19815a po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 10:32:32 +01:00
Karel Zak
39a81981ac chsh, chfn: remove readline support [CVE-2022-0563]
The readline library uses INPUTRC= environment variable to get a path
to the library config file. When the library cannot parse the
specified file, it prints an error message containing data from the
file.

Unfortunately, the library does not use secure_getenv() (or a similar
concept) to avoid vulnerabilities that could occur if set-user-ID or
set-group-ID programs.

Reported-by: Rory Mackie <rory.mackie@trailofbits.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 10:32:32 +01:00
Karel Zak
86f89da80e build-sys: generate all man pages for distribution tarball
Now "make dist" and "make distcheck" follows autoconf. It means that
disabled tools or tools that cannot compile are ignored, and man-pages
for these tools are not generated. This is a problem for people
without asciidoctor (adoc -> man generator).

Fixes: https://github.com/util-linux/util-linux/issues/1577
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 10:32:32 +01:00
Karel Zak
331a1e6e10 build-sys: release++ (v2.37.3)
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-24 10:11:40 +01:00
Karel Zak
d4178c526b docs: add v2.37.3-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-24 10:08:27 +01:00
Karel Zak
5ac78f94e6 po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-24 09:49:17 +01:00
Karel Zak
018a10907f libmount: fix (deleted) suffix issue [CVE-2021-3996]
This issue is related to parsing the /proc/self/mountinfo file allows an
unprivileged user to unmount other user's filesystems that are either
world-writable themselves or mounted in a world-writable directory.

The support for "(deleted)" is no more necessary as the Linux kernel does
not use it in /proc/self/mountinfo and /proc/self/mount files anymore.

Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-24 09:49:16 +01:00
Karel Zak
f3db9bd609 libmount: fix UID check for FUSE umount [CVE-2021-3995]
Improper UID check allows an unprivileged user to unmount FUSE
filesystems of users with similar UID.

Signed-off-by: Karel Zak <kzak@redhat.com>
2022-01-24 09:49:16 +01:00
Karel Zak
f59c8fd38d build-sys: release++ (v2.37.2)
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 15:23:50 +02:00
Karel Zak
9ffaa85be1 docs: update v2.37.2-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 15:22:37 +02:00
Karel Zak
a2ec89ca4b docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 15:16:38 +02:00
Karel Zak
c10d72868e po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 15:15:36 +02:00
Jose Riha
1a59c9fa15 po: add sk.po (from translationproject.org) 2021-08-16 15:06:14 +02:00
Jakub Bogusz
ede5254afa po: update pl.po (from translationproject.org) 2021-08-16 15:06:14 +02:00
Karel Zak
d0aeb4d2c0 mount.8: don't consider additional mounts as experimental
This is bug, we have "EXPERIMENTAL" flag in the man page since v2.23.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 13:00:18 +02:00
panchenbo
75882dea1a lscpu:Add Phytium FT-2000+ & S2500 support 2021-08-16 12:59:52 +02:00
panchenbo
6dde514b2a lscpu:Add Phytium aarch64 cpupart 2021-08-16 12:59:42 +02:00
Karel Zak
19238be16d docs: fix info about LIBSMARTCOLS_DEBUG_PADDING
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-16 12:59:31 +02:00
Karel Zak
a5c6ab54e6 lscpu: fix compilation against librtas
Fixes: https://github.com/karelzak/util-linux/issues/1406
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-09 11:54:38 +02:00
Karel Zak
f6dd7b20cd prlimit: fix compiler warning [-Wmaybe-uninitialized]
sys-utils/prlimit.c:467:16: warning: 'hard' may be used uninitialized in this function [-Wmaybe-uninitialized]
  lim->rlim_max = hard;
  ~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:15: note: 'hard' was declared here
  rlim_t soft, hard;
               ^~~~
sys-utils/prlimit.c:466:16: warning: 'soft' may be used uninitialized in this function [-Wmaybe-uninitialized]
  lim->rlim_cur = soft;
  ~~~~~~~~~~~~~~^~~~~~
sys-utils/prlimit.c:456:9: note: 'soft' was declared here
  rlim_t soft, hard;
         ^~~~

References: https://github.com/karelzak/util-linux/issues/1406
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-09 11:54:07 +02:00
Karel Zak
ebd4749115 lscpu: fix NULL dereference
Fixes: https://github.com/karelzak/util-linux/issues/1401
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-30 14:44:32 +02:00
Érico Nogueira
692167ff5e lib/pwdutils: use assert to check correct usage.
Since these functions are only used internally, we can make sure they
are being used correctly, and assert() helps in catching remaining
issues. Usage of each changed function has been reviewed:

For xgetpwnam:

- chsh(1) only calls it if a username has been set
- login(1) only calls it if username has been set and is not empty
- su(1) always initializes new_user to "root"
- unshare(1) calls get_user with optarg, so always set as well

For xgetgrnam:

- unshare(1) calls get_group with optarg

For xgetpwuid:

- chsh(1) passes a stack allocated struct for struct passwd

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
2021-07-29 21:40:33 +02:00
Érico Nogueira
8ab700b933 logger: use xgetlogin from pwdutils.
It defined its own xgetlogin, which queried geteuid() instead of getuid(),
with a fallback to "<someone>" when lookup fails. This has been the case
since the function was introduced in
019b97024f, so geteuid() has always been
used. Since using geteuid for identification isn't consistent with the
rest of util-linux, switching to xgetlogin(), which uses getuid(),
should be correct.

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
2021-07-29 21:40:33 +02:00
Érico Nogueira
5cc21d91fc wall: use xgetlogin.
getlogin(3) shouldn't be used for identification here. This also removes
the bug where a missing entry for getuid() in passwd database wouldn't
print a warning, because whom would be set to "???".

For consistency, switch to "<someone>" when pw look up fails.

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
2021-07-29 21:40:33 +02:00
Érico Nogueira
bca77acb03 lib/pwdutils: don't use getlogin(3).
Per the man page, it shouldn't be used for security purposes. This is an
issue especially on musl, where getlogin is implemented as
getenv("LOGNAME"). Since xgetlogin is being used as user identity in su(1), to
set PAM_RUSER, we simply switch to always using getpwuid(getuid()).

Signed-off-by: Érico Nogueira <erico.erc@gmail.com>
2021-07-29 21:40:05 +02:00
Karel Zak
3c466f7c35 sulogin: fix getpasswd()
Fixes: https://github.com/karelzak/util-linux/issues/1400
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 21:28:00 +02:00
Karel Zak
54cb0dd60c libmount: don't use setgroups at all()
It's probably good idea to call setgroups() to cleanup groups,
but it introduces a regression as some mount helpers depend on
supplementary groups like "network" etc.

Fixes: https://github.com/karelzak/util-linux/issues/1398
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 20:42:24 +02:00
Karel Zak
4763080701 libmount: fix setgroups() use
* keep process in single supplementary group, which is the real group ID for the process

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

Fixes: https://github.com/karelzak/util-linux/issues/1398
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 11:57:37 +02:00
Karel Zak
4f2406545c losetup: use LOOP_CONFIGURE in a more robust way
32-bit userspace returns ENOTTY:
 ioctl(4, LOOP_CONFIGURE, {fd=3, block_size=0, info={lo_offset=0, lo_number=0, lo_flags=LO_FLAGS_AUTOCLEAR, lo_file_name="/usr/install/iso/systemrescue-8.04-amd64.iso", ...}}) = -1 ENOTTY (Inappropriate ioctl for device)

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

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

Reported-by: Krzysztof Olędzki <ole@ans.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 11:57:17 +02:00
Karel Zak
31bb588663 blockdev: use snprintf() rather than sprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-29 11:57:17 +02:00
Karel Zak
86d5de52d4 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>
2021-07-29 11:57:17 +02:00
Karel Zak
9d761e8325 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>
2021-07-29 11:57:17 +02:00
Karel Zak
6e8af4695e libfdisk: (dos) don't ignore MBR+FAT use-case
Since libblkid commit 751eca28fc 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>
2021-07-29 11:55:45 +02:00
Thomas Abraham
b5a4d57a5c 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)
2021-07-29 11:55:45 +02:00
Christian Finnberg
bb894a4493 Fix typo 2021-07-29 11:55:45 +02:00
Karel Zak
bb954f7658 build-sys: release++ (v2.37.1)
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 15:59:15 +02:00
Karel Zak
7169c01223 docs: update v2.37.1-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 15:56:53 +02:00
Karel Zak
6bf2c99b2e docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 15:55:04 +02:00
Karel Zak
debce7468d po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 15:52:06 +02:00
Мирослав Николић
2349d4c090 po: update sr.po (from translationproject.org) 2021-07-22 15:46:26 +02:00
Rafael Fontenelle
e5694e94b5 po: update pt_BR.po (from translationproject.org) 2021-07-22 15:46:26 +02:00
Antonio Ceballos Roa
5ba2c4317c po: update es.po (from translationproject.org) 2021-07-22 15:46:26 +02:00
Karel Zak
4fcd20534f lslogins: fix memory leak [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 11:35:38 +02:00
Karel Zak
d1a5e99e8a lslogins: ask for supplementary groups only once [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-22 11:35:38 +02:00
Karel Zak
f626170062 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>
2021-07-22 11:35:22 +02:00
Karel Zak
a3d73c246f 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>
2021-07-20 11:59:53 +02:00
Karel Zak
650fca1a06 lslogins: consolidate and optimize utmp files use
* the original read_utmp() code is from GPLv3+, but lslogins is GPLv2+
  (see a6bf40ee77 (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>
2021-07-20 11:59:53 +02:00
Karel Zak
22a2bce042 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>
2021-07-20 11:59:53 +02:00
Karel Zak
937fe5d9c5 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>
2021-07-20 11:59:53 +02:00
Karel Zak
1bb08cfc01 tests: update sfdisk reorder test
References: commit f05a5bb2c2
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:59:05 +02:00
Karel Zak
4bea4821ab 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>
2021-07-20 11:58:48 +02:00
Pali Rohár
18492b47b7 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>
2021-07-20 11:58:13 +02:00
Luca Boccassi
db4d80fcef 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>
2021-07-20 11:57:58 +02:00
Pali Rohár
d501259161 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>
2021-07-20 11:57:13 +02:00
Pali Rohár
ee3d6b0d4a 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>
2021-07-20 11:56:34 +02:00
Pali Rohár
9c3b9269d9 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>
2021-07-20 11:56:34 +02:00
Luca Boccassi
6a7194ea23 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
2021-07-20 11:55:32 +02:00
Luca Boccassi
71b98c36d4 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.
2021-07-20 11:55:21 +02:00
Luca Boccassi
8da7e26cbc 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
2021-07-20 11:55:09 +02:00
Luca Boccassi
375afc17f4 build-sys: display cryptsetup status after ./configure
Signed-off-by: Luca Boccassi <bluca@debian.org>
2021-07-20 11:55:00 +02:00
Karel Zak
19dd7a1e30 lscpu: don't use DMI if executed with --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:54:48 +02:00
Ross Burton
be39647ac4 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>
2021-07-20 11:54:17 +02:00
Karel Zak
9ada40d3cc 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>
2021-07-20 11:54:03 +02:00
Karel Zak
5ca73c6eef 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>
2021-07-20 11:53:33 +02:00
Ross Burton
6269a5fc0d 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>
2021-07-20 11:53:10 +02:00
Ross Burton
89379c88db 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>
2021-07-20 11:53:10 +02:00
Ross Burton
0be381be44 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>
2021-07-20 11:52:16 +02:00
Karel Zak
54da548e02 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>
2021-07-20 11:51:44 +02:00
Karel Zak
2db4c7f0b3 hexdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:44 +02:00
Karel Zak
45f40a1ed8 pg: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:44 +02:00
Karel Zak
28941d202a misc: improve string to number conversions
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:51:02 +02:00
Karel Zak
97b7dcf32e include/strutils: consolidate string to number conversion
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:50:52 +02:00
Karel Zak
cd969e8908 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>
2021-07-20 11:50:52 +02:00
Karel Zak
c0617de5a4 agetty: do not use atol()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:50:52 +02:00
Karel Zak
cb75cf88b8 lscpu: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:50:52 +02:00
Karel Zak
9ee95fa26a utmpdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:49:57 +02:00
Karel Zak
878307e960 swapon: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:49:57 +02:00
Karel Zak
e4aad0a9c4 ipcs: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:49:57 +02:00
Karel Zak
0ea3e2f0ed 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>
2021-07-20 11:49:57 +02:00
Karel Zak
ee021a5f9e fsck: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:49:57 +02:00
Karel Zak
a9768580a4 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>
2021-07-20 11:34:53 +02:00
Karel Zak
cbfbbc44c4 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>
2021-07-20 11:34:53 +02:00
Karel Zak
22cecf786f 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>
2021-07-20 11:34:53 +02:00
Karel Zak
aeba558136 readprofile: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
9411b6ccf8 wipefs: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
c357816caa lslocks: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
7a50f117a4 kill: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
21ef212a58 lslogins: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
b2db509d13 fsck: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
8803c8d4ab lsmem: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Karel Zak
096487c616 lscpu: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
8335261c3d hwclock: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
b6cd420e03 ipcs: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
62aa386c4f libuuid: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
0729593862 libmount: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
736b6ab7fd libblkid: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Thiébaud Weksteen
864578ded7 mount.8.adoc: Remove context options exclusion
The exclusivity between the {fscontext, defcontext} and context options
was removed in kernel 2.6.25[1]. No specific verification on these
options is done in mount(8)[2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c9180a57a9ab2d5525faf8815a332364ee9e89b7
[2] https://github.com/karelzak/util-linux/blob/master/libmount/src/context_mount.c#L202
2021-07-20 11:33:27 +02:00
Karel Zak
b0f8d63e63 fsck.cramfs: use open+fstat rather than stat+open
Fixes: https://github.com/karelzak/util-linux/issues/1353
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:33:27 +02:00
Karel Zak
86328e78ea include/c: add drop_permissions(), consolidate UID/GID reset
Fixes: https://github.com/karelzak/util-linux/issues/1354
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:31:43 +02:00
Karel Zak
155b79d38e dmesg: remove condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:31:43 +02:00
Karel Zak
b342240e84 tools: report and use LDFLAGS in tools/config-gen
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:46 +02:00
Karel Zak
a000aad7a6 build-sys: use $LIBS rather than LDFLAGS
Fixes: https://github.com/karelzak/util-linux/pull/1349
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak
ab26415a03 lib/path: (test) fix ul_new_path() use 2021-07-20 11:30:00 +02:00
Karel Zak
42a9c18706 more: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak
59bb9ab136 wall: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak
703ec6fc66 script: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak
7b18166aa3 ldattach: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:30:00 +02:00
Karel Zak
b2bd06d9ca hwclock: fix ul_path_scanf() use
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:29:01 +02:00
Karel Zak
856ec50de5 eject: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
7bee16f27f logger: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
609468bc9b libfdisk: add and fix __format__ attributes
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
bda3f658e0 findmnt: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
292161888c libmount: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
b22ecdd840 include/strutils: fix __format__attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
2f40ad0608 include/path: add __format__attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:27:34 +02:00
Karel Zak
7e787030bf include/c: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:26:30 +02:00
Anatoly Pugachev
5fc0e55af1 tests: fix lsns test on kernels without USER namespaces
Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:26:30 +02:00
Karel Zak
ed03caf2c6 mount.8: fix overlayfs nfs_export= indention
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:26:30 +02:00
Karel Zak
421c6766ea include/strv: fix format attributes
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:25:50 +02:00
Christian Bartolomäus
b81a870767 Fix some brackets in synopses 2021-07-20 11:25:34 +02:00
Tj
c22bb73d3a mount: man-page; add all overlayfs options
The section in man (8) mount for overlay is missing nine options which
aren't documented elsewhere either and are useful features to be aware
of and use.

Fixes #1350.
2021-07-20 11:25:13 +02:00
Alex Xu
33eec71c1a build-sys: Update configure.ac
1. the test incorrectly used AC_COMPILE_IFELSE instead of
   AC_LINK_IFELSE, defeating the purpose of checking -lcrypt.
2. the test did not properly restore LIBS, causing later checks to all
   fail if libcrypt wasn't found.
3. HAVE_LIBCRYPT only controls whether to use -lcrypt, it is not
   needed or used in any source files.

[kzak@redhat.com: - improve commit message
                  - use UL_{SET,RESTORE}_FLAGS() rather than directly
		    modify $LIBS]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:25:00 +02:00
Karel Zak
cff7e7d84b lib/path: improve ul_path_readlink() to be more robust
According to POSIX, readlink() makes no effort to null-terminate buffer
with the result. It seems better to hide this disadvantage in the
ul_path_...() API rather than assume buf[sz] = '\0' everywhere.

Reported-by: Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:24:12 +02:00
Karel Zak
f113d46a50 mkfs.cramfs: add comment to explain readlink() use
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:24:12 +02:00
Karel Zak
9461ae9b90 rename: use readlink() in more robust way
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:24:12 +02:00
Karel Zak
aec0e37683 namei: simplify code
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:23:40 +02:00
Karel Zak
37bb1b07e0 more: fix setuid/setgid order
The rule is pretty simple, always use setgid() before setuid().

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:23:12 +02:00
Karel Zak
da0c591015 sulogin: add missing ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:22:23 +02:00
Karel Zak
ee0653123c sulogin: use explicit_bzero() for buffer with password
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:20:17 +02:00
Karel Zak
3aef5dcad5 login: remove obsolete and confusing comment
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:16:06 +02:00
Karel Zak
3871a969ed mkswap: fix holes detection (infinite loop and/or stack-buffer-underflow)
Reported-by: Brian Lane <bcl@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1971877
Fix: https://github.com/karelzak/util-linux/issues/1348
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:14:38 +02:00
Karel Zak
612913cda5 lib/loopdev: perform retry on EAGAIN
Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:14:17 +02:00
Topi Miettinen
b1e37433bb mount.8.adoc: document SELinux use of nosuid mount flag
Using mount flag `nosuid` also affects SELinux domain transitions but
this has not been documented well.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2021-07-20 11:13:25 +02:00
Platon Pronko
4b9d512c6f dmesg: fix indentation in man page
Double-semicolon at the end of the option line results in description
being indented extra tab to the right. Replacing them with double-colons
allows all options to be displayed at the same indent level.
2021-07-20 11:13:14 +02:00
Karel Zak
296f21699d lib/path: fix possible leak when use ul_path_read_string() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:13:02 +02:00
Karel Zak
a8deea07a7 hwclock: close adjtime on write error [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:13:02 +02:00
Karel Zak
994b3295c2 newgrp: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:13:02 +02:00
Karel Zak
bcb6ccf819 dmesg: fix possible memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:13:02 +02:00
Karel Zak
5f0cf2484f findmnt: (verify) fix memory leak [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:12:16 +02:00
Karel Zak
a7f7d3474a findmnt: (verify) fix cache related memory leaks on --nocanonicalize [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:11:49 +02:00
John Baublitz
d72c79d495 libblkid: Add hyphens to UUID string representation in Stratis superblock parsing
[kzak@redhat.com: - small code cleanup]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:09:58 +02:00
Samir Benmendil
a27ff267f0 hexdump: correctly display signed single byte integers
When using the format string '/1 "%d"', the byte did not display as a
signed integer as expected, it was interpreted as unsigned.
2021-07-20 11:09:26 +02:00
ratijas
d3363ef6d7 lsblk: fix formatting in -e option 2021-07-20 11:09:10 +02:00
Qais Yousef
4f42dc779e uclampset: Fix left over optind++
The code was changed to use ':' in getopt_long() but these were left
over by mistake causing weird random errors when using these options
depending on the order they were fed.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
2021-07-20 11:08:52 +02:00
Nicolai Dagestad
97660cb42a rfkill: Set scols table name to make the json output valid
[kzak@redhat.com: - s/rfkill/rfkilldevices/]

Fixes: https://github.com/karelzak/util-linux/issues/1339
Signed-off-by: Nicolai Dagestad <nicolai@dagestad.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:08:23 +02:00
Karel Zak
250fc0bc9b libsmartcols: fix bare array on JSON output
The bare array ({[...]}) for top level list of entries is invalid. It
seems better to print empty string than nothing. This is workaround
for broken utils, better is to define a table name.

Addresses: https://github.com/karelzak/util-linux/issues/1339
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:08:02 +02:00
Karel Zak
af5527f45e build-sys: make re-use of generated man-pages more robust
We need to ignore man-pages at all if not available (not generated
yet), but asciidoctor is not installed.

Fix: https://github.com/karelzak/util-linux/issues/1334
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:06:50 +02:00
Karel Zak
66099fe11c build-sys: add generated man-pages to distribution tarball
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:06:20 +02:00
Georgy Yakovlev
fb87dcc80e lscpu: fix build on powerpc
fails with error: label at end of compound statement
and fix typo as bonus.

Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
2021-07-20 10:57:22 +02:00
Karel Zak
9bf924165b lsblk: use ID_MODEL_ENC is possible
Fix: https://github.com/karelzak/util-linux/issues/1098
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 10:53:55 +02:00
Karel Zak
bef5ab005e include/strutils: fix heap-buffer-overflow in normalize_whitespace()
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-14 16:29:21 +02:00
Karel Zak
fce7b9501c build-sys: fix {release-version} man pages
* define {release-version} as $VERSION

* do not use {docdir} in adoc; it's built-in ascidoctor variable
  https://docs.asciidoctor.org/asciidoc/latest/attributes/document-attributes-reference/#intrinsic-attributes

Addresses: https://github.com/karelzak/util-linux/issues/1327
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 12:23:57 +02:00
Karel Zak
e0c46c2d4e build-sys: install hardlink bash-completion
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-02 12:23:57 +02:00
179 changed files with 72546 additions and 49609 deletions

16
AUTHORS
View file

@ -111,6 +111,7 @@ CONTRIBUTORS:
Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Alex Ivanov <yourbestfriend@openmailbox.org>
Alex Xu <351006+Hello71@users.noreply.github.com>
Allon Mureinik <amureini@redhat.com>
Alon Bar-Lev <alon.barlev@gmail.com>
Alvaro M. Echevarria
@ -198,6 +199,8 @@ CONTRIBUTORS:
Chris MacGregor <chrismacgregor@google.com>
Chris Metcalf <cmetcalf@mellanox.com>
Chris Morin <chris.morin2@gmail.com>
Christian Bartolomäus <use_v6@aglaz.de>
Christian Finnberg <christian@finnberg.net>
Christian Hesse <mail@eworm.de>
Christian von Roques <roques@juliet.ka.sub.org>
Christian Wiese <chris@opensde.org>
@ -272,6 +275,7 @@ CONTRIBUTORS:
Elliott Mitchell <ehem+util-linux@drgnwing.com>
Eric Biggers <ebiggers@google.com>
Eric Desrochers <eric.desrochers@canonical.com>
Érico Nogueira <erico.erc@gmail.com>
Érico Rolim <erico.erc@gmail.com>
Eric Rannaud <e@nanocritical.com>
Eric Rasmussen <ear@usfirst.org>
@ -323,6 +327,7 @@ CONTRIBUTORS:
Gaël PORTAY <gael.portay@collabora.com>
Gao Xiang <hsiangkao@redhat.com>
Georg Schiesser <georg.schiesser@opentech.at>
Georgy Yakovlev <gyakovlev@gentoo.org>
Gerald Schaefer <gerald.schaefer@de.ibm.com>
Gerhard Schneider <gs@ilfb.tuwien.ac.at>
Gero Treuner <gero@70t.de>
@ -440,6 +445,7 @@ CONTRIBUTORS:
Jörg Jenderek <joerg.jen.der.ek@gmx.net>
Joseph Parmelee <jparmele@wildbear.com>
Josep Puigdemont <josep.puigdemont@gmail.com>
Jose Riha <jose1711@gmail.com>
Josh Triplett <josh@joshtriplett.org>
Joshua Hudson <joshudson@gmail.com>
Joshua Watt <jpewhacker@gmail.com>
@ -488,6 +494,7 @@ CONTRIBUTORS:
Li Zefan <lizf@cn.fujitsu.com>
Lubomir Kundrak <lkundrak@redhat.com>
Lubomir Rintel <lkundrak@v3.sk>
Luca Boccassi <bluca@debian.org>
Luca Boccassi <luca.boccassi@microsoft.com>
Luca BRUNO <luca.bruno@coreos.com>
Luca Ceresoli <luca@lucaceresoli.net>
@ -584,6 +591,7 @@ CONTRIBUTORS:
nick black <dankamongmen@gmail.com>
nick black <nick.black@sprezzatech.com>
Nick Holloway <Nick.Holloway@pyrites.org.uk>
Nicolai Dagestad <nicolai@dagestad.fr>
Nicolai Langfeldt <janl@math.uio.no>
Nicolas Boichat <nicolas@boichat.ch>
Nicolas Provost <nprovost@quadriv.com>
@ -605,6 +613,7 @@ CONTRIBUTORS:
osexp2000 <osexp2000@gmail.com>
Pádraig Brady <P@draigBrady.com>
Pali Rohár <pali.rohar@gmail.com>
panchenbo <panchenbo@uniontech.com>
Pascal Terjan <pterjan@mandriva.com>
Patrice Dumas <pertusus@free.fr>
Patrick Plagwitz <patrick.plagwitz@fau.de>
@ -647,6 +656,7 @@ CONTRIBUTORS:
Pierre Labastie <pierre.labastie@neuf.fr>
Pietro Castelli
Pino Toscano <toscano.pino@tiscali.it>
Platon Pronko <platon7pronko@gmail.com>
Po-Yu Chuang <ratbert@faraday-tech.com>
Prarit Bhargava <prarit@redhat.com>
Qais Yousef <qais.yousef@arm.com>
@ -666,6 +676,7 @@ CONTRIBUTORS:
Randy Dunlap <randy.dunlap@oracle.com>
Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Rasmus Villemoes <rasmus.villemoes@prevas.dk>
ratijas <me@ratijas.tk>
Raul Gutierrez Segales <rgs@itevenworks.net>
Ray Wang <wanglei1123@gmail.com>
Rian Hunter <rian@alum.mit.edu>
@ -696,6 +707,7 @@ CONTRIBUTORS:
Ron Sommeling <sommel@sci.kun.nl>
Rosen Penev <rosenp@gmail.com>
Ross Biro <biro@yggdrasil.com>
Ross Burton <ross.burton@arm.com>
Rostislav Skudnov <rostislav@tuxera.com>
Roy Peled <the.roy.peled@gmail.com>
Ruediger Meier <ruediger.meier@ga-group.nl>
@ -706,6 +718,7 @@ CONTRIBUTORS:
Sami Kerola <kerolasa@iki.fi>
Sami Liedes <sami.liedes@iki.fi>
Sami Loone <sami@loone.fi>
Samir Benmendil <me@rmz.io>
Sam Morris <sam@robots.org.uk>
Samuel Dionne-Riel <samuel@dionne-riel.com>
Samuel Ortiz <sameo@linux.intel.com>
@ -777,6 +790,7 @@ CONTRIBUTORS:
Terry Burton <tez@terryburton.co.uk>
Thayne McCombs <thayne@lucidchart.com>
Theodore Ts'o <tytso@mit.edu>
Thiébaud Weksteen <tweek@google.com>
Thierry Reding <thierry.reding@avionic-design.de>
Thierry Vignaud <thierry.vignaud@gmail.com>
Thomas Abraham <tabraham@suse.com>
@ -794,6 +808,7 @@ CONTRIBUTORS:
Timo Juhani Lindfors <timo.lindfors@iki.fi>
Timo Warns <Warns@Pre-Sense.DE>
Tim Waugh <twaugh@redhat.com>
Tj <hacker@iam.tj>
Tobias Klauser <tklauser@distanz.ch>
Tobias Stoeckmann <tobias@stoeckmann.org>
Todd Lewis <utoddl@email.unc.edu>
@ -807,6 +822,7 @@ CONTRIBUTORS:
Tom Prince <tom.prince@ualberta.net>
Toni Uhlig <matzeton@googlemail.com>
Tony Asleson <tasleson@redhat.com>
Topi Miettinen <toiwoton@gmail.com>
Torsten Hilbrich <torsten.hilbrich@secunet.com>
Toshi Kani <toshi.kani@hp.com>
Trần Ngọc Quân <vnwildman@gmail.com>

View file

@ -0,0 +1,181 @@
util-linux 2.37.1 Release Notes
===============================
agetty:
- do not use atol() [Karel Zak]
blockdev:
- improve arguments parsing (remove atoi) [Karel Zak]
build-sys:
- Update configure.ac [Alex Xu]
- add generated man-pages to distribution tarball [Karel Zak]
- display cryptsetup status after ./configure [Luca Boccassi]
- fix {release-version} man pages [Karel Zak]
- install hardlink bash-completion [Karel Zak]
- make re-use of generated man-pages more robust [Karel Zak]
- use $LIBS rather than LDFLAGS [Karel Zak]
cfdisk:
- do not use atoi() [Karel Zak]
- optimize mountpoint detection for PARTUUID [Karel Zak]
dmesg:
- fix indentation in man page [Platon Pronko]
- fix possible memory leak [coverity scan] [Karel Zak]
- remove condition [lgtm scan] [Karel Zak]
docs:
- add uclampset to AUTHORS file [Karel Zak]
- fix typo in v2.37-ReleaseNotes [Karel Zak]
- update AUTHORS file [Karel Zak]
eject:
- add __format__ attribute [Karel Zak]
- do not use atoi() [Karel Zak]
fdisk:
- do not print error message when partition reordering is not needed [Pali Rohár]
- move reorder diag messages to fdisk_reorder_partitions() [Pali Rohár]
findmnt:
- (verify) fix cache related memory leaks on --nocanonicalize [coverity scan] [Karel Zak]
- (verify) fix memory leak [asan] [Karel Zak]
- add __format__ attribute [Karel Zak]
fsck:
- check errno after strto..() [Karel Zak]
- do not use atoi() [Karel Zak]
fsck.cramfs:
- use open+fstat rather than stat+open [Karel Zak]
fstrim:
- clean return code on --quiet-unsupported [Karel Zak]
hardlink:
- remove pcre2posix.h support [Karel Zak]
hexdump:
- correctly display signed single byte integers [Samir Benmendil]
- do not use atoi() [Karel Zak]
hwclock:
- check errno after strto..() [Karel Zak]
- close adjtime on write error [coverity scan] [Karel Zak]
- fix ul_path_scanf() use [Karel Zak]
include/c:
- add __format__ attribute [Karel Zak]
- add drop_permissions(), consolidate UID/GID reset [Karel Zak]
include/path:
- add __format__attribute [Karel Zak]
include/strutils:
- cleanup strto..() functions [Karel Zak]
- consolidate string to number conversion [Karel Zak]
- fix __format__attribute [Karel Zak]
- fix heap-buffer-overflow in normalize_whitespace() [Karel Zak]
include/strv:
- fix format attributes [Karel Zak]
ipcs:
- check errno after strto..() [Karel Zak]
- do not use atoi() [Karel Zak]
kill:
- check errno after strto..() [Karel Zak]
ldattach:
- add __format__ attribute [Karel Zak]
lib/loopdev:
- perform retry on EAGAIN [Karel Zak]
lib/path:
- (test) fix ul_new_path() use [Karel Zak]
- fix possible leak when use ul_path_read_string() [coverity scan] [Karel Zak]
- improve ul_path_readlink() to be more robust [Karel Zak]
libblkid:
- Add hyphens to UUID string representation in Stratis superblock parsing [John Baublitz]
- check errno after strto..() [Karel Zak]
- vfat Fix reading FAT16 boot label and serial id [Pali Rohár]
- vfat Fix reading FAT32 boot label [Pali Rohár]
libfdisk:
- add and fix __format__ attributes [Karel Zak]
libmount:
- add __format__ attribute [Karel Zak]
- check errno after strto..() [Karel Zak]
libsmartcols:
- fix bare array on JSON output [Karel Zak]
libuuid:
- check errno after strto..() [Karel Zak]
logger:
- add __format__ attribute [Karel Zak]
login:
- add callback for close_range() [Karel Zak]
- fix close_range() use [Karel Zak]
- remove obsolete and confusing comment [Karel Zak]
lsblk:
- fix formatting in -e option [ratijas]
- normalize space in SERIAL and MODEL [Karel Zak]
- use ID_MODEL_ENC is possible [Karel Zak]
lscpu:
- check errno after strto..() [Karel Zak]
- do not use atoi() [Karel Zak]
- don't use DMI if executed with --sysroot [Karel Zak]
- fix build on powerpc [Georgy Yakovlev]
lslocks:
- check errno after strto..() [Karel Zak]
lslogins:
- ask for supplementary groups only once [asan] [Karel Zak]
- check errno after strto..() [Karel Zak]
- consolidate and optimize utmp files use [Karel Zak]
- fix memory leak [asan] [Karel Zak]
- use sd_journal_get_data() in proper way [Karel Zak]
lsmem:
- check errno after strto..() [Karel Zak]
meson:
- fix crypt_activate_by_signed_key detection [Luca Boccassi]
- fix dlopen support for cryptsetup [Luca Boccassi]
misc:
- improve string to number conversions [Karel Zak]
mkfs.cramfs:
- add comment to explain readlink() use [Karel Zak]
mkswap:
- fix holes detection (infinite loop and/or stack-buffer-underflow) [Karel Zak]
more:
- add __format__ attribute [Karel Zak]
- fix null-pointer dereference [Karel Zak]
- fix setuid/setgid order [Karel Zak]
mount:
- fix roothash signature extension in manpage [Luca Boccassi]
- man-page; add all overlayfs options [Tj]
- mount.8 fix overlayfs nfs_export= indention [Karel Zak]
mount.8.adoc:
- Remove context options exclusion [Thiébaud Weksteen]
- document SELinux use of nosuid mount flag [Topi Miettinen]
namei:
- simplify code [Karel Zak]
newgrp:
- fix memory leak [coverity scan] [Karel Zak]
pg:
- do not use atoi() [Karel Zak]
po:
- merge changes [Karel Zak]
- update es.po (from translationproject.org) [Antonio Ceballos Roa]
- update pt_BR.po (from translationproject.org) [Rafael Fontenelle]
- update sr.po (from translationproject.org) [Мирослав Николић]
readprofile:
- check errno after strto..() [Karel Zak]
rename:
- use readlink() in more robust way [Karel Zak]
rfkill:
- Set scols table name to make the json output valid [Nicolai Dagestad]
script:
- add __format__ attribute [Karel Zak]
sulogin:
- add missing ifdefs [Karel Zak]
- use explicit_bzero() for buffer with password [Karel Zak]
swapon:
- do not use atoi() [Karel Zak]
test/eject:
- guard asan LD_PRELOAD with use-system-commands check [Ross Burton]
tests:
- check correct log file for errors in blkdiscard test [Ross Burton]
- don't hardcode /bin/kill in the kill tests [Ross Burton]
- fix lsns test on kernels without USER namespaces [Anatoly Pugachev]
- mark ul/ul as a known failure [Ross Burton]
- skip if scsi_debug model file is not accessible [Karel Zak]
- update sfdisk reorder test [Karel Zak]
tools:
- report and use LDFLAGS in tools/config-gen [Karel Zak]
uclampset:
- Fix left over optind++ [Qais Yousef]
utmpdump:
- do not use atoi() [Karel Zak]
verity:
- fix verity.roothashsig only working as last parameter [Luca Boccassi]
wall:
- add __format__ attribute [Karel Zak]
wipefs:
- check errno after strto..() [Karel Zak]

View file

@ -0,0 +1,41 @@
util-linux 2.37.2 Release Notes
===============================
blockdev:
- allow for larger values for start sector [Thomas Abraham]
- use snprintf() rather than sprintf() [Karel Zak]
docs:
- fix info about LIBSMARTCOLS_DEBUG_PADDING [Karel Zak]
- update AUTHORS file [Karel Zak]
lib/pwdutils:
- don't use getlogin(3). [Érico Nogueira]
- use assert to check correct usage. [Érico Nogueira]
libfdisk:
- (dos) don't ignore MBR+FAT use-case [Karel Zak]
- (dos) support partition and MBR overlap [Karel Zak]
libmount:
- don't use setgroups at all() [Karel Zak]
- fix setgroups() use [Karel Zak]
logger:
- use xgetlogin from pwdutils. [Érico Nogueira]
losetup:
- use LOOP_CONFIGURE in a more robust way [Karel Zak]
lscpu:
- Add Phytium FT-2000+ & S2500 support [panchenbo]
- Add Phytium aarch64 cpupart [panchenbo]
- fix NULL dereference [Karel Zak]
- fix compilation against librtas [Karel Zak]
mount:
- mount.8 don't consider additional mounts as experimental [Karel Zak]
po:
- add sk.po (from translationproject.org) [Jose Riha]
- merge changes [Karel Zak]
- update pl.po (from translationproject.org) [Jakub Bogusz]
prlimit:
- fix compiler warning [-Wmaybe-uninitialized] [Karel Zak]
sulogin:
- fix getpasswd() [Karel Zak]
sys-utils/ipcutils:
- be careful when call calloc() for uint64 nmembs [Karel Zak]
wall:
- use xgetlogin. [Érico Nogueira]

View file

@ -0,0 +1,13 @@
util-linux 2.37.3 Release Notes
===============================
This release fixes two security mount(8) and umount(8) issues:
CVE-2021-3996
Improper UID check in libmount allows an unprivileged user to unmount FUSE
filesystems of users with similar UID.
CVE-2021-3995
This issue is related to parsing the /proc/self/mountinfo file allows an
unprivileged user to unmount other user's filesystems that are either
world-writable themselves or mounted in a world-writable directory.

View file

@ -0,0 +1,15 @@
util-linux 2.37.4 Release Notes
===============================
This release fixes security issue in chsh(1) and chfn(8):
CVE-2022-0563
The readline library uses INPUTRC= environment variable to get a path
to the library config file. When the library cannot parse the
specified file, it prints an error message containing data from the
file.
Unfortunately, the library does not use secure_getenv() (or a similar
concept), or sanitize the config file path to avoid vulnerabilities that
could occur if set-user-ID or set-group-ID programs.

View file

@ -195,16 +195,16 @@ $(PATHFILES): Makefile
@ mv $@.tmp $@
CLEANFILES += $(MANPAGES) $(MANLINKS)
EXTRA_DIST += $(ADOCFILES_COMMON)
if ENABLE_ASCIIDOC
EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
man_MANS += $(MANPAGES) $(MANLINKS)
$(MANPAGES): $(ADOCFILES_COMMON) Makefile
$(MANPAGES): $(ADOCFILES_COMMON)
asciidoc_man_cmd = $(ASCIIDOCTOR) \
-b manpage \
-a 'release-version=$(VERSION)' \
-a 'package-docdir=$(docdir)' \
-a 'VERSION=$(VERSION)' \
-a 'ADJTIME_PATH=$(ADJTIME_PATH)'
@ -218,14 +218,33 @@ SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
$(MANLINKS): $(MANPAGES)
gen-man: $(man_MANS)
# Standard "make" follows BUILD_* macros from ./configure, and in this case, it
# ignores man pages for disabled tools, but for distribution tarball, we need
# to generate all man-pages (to avoid dependence on asciidoc). [kzak Jan-2022]
gen-man-dist:
@list=`find -name *.adoc -not -path "*/man-common/*" -not -path "*/po-man/*" | sed -e 's/\.adoc//g'`; \
missing=`for p in $$list; do test -f $$p || echo $$p; done`; \
if test -n "$$missing"; then \
$(MAKE) $(AM_MAKEFLAGS) $$missing; \
fi;
# !ENABLE_ASCIIDOC
else
if HAVE_MANPAGES
EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
man_MANS += $(MANPAGES) $(MANLINKS)
endif
gen-man:
gen-man-dist:
endif
# Arrange so that .tarball-version appears only in the distribution
# tarball, and never in a checked-out repository.
dist-hook:
dist-hook: gen-man-dist
echo $(VERSION) > $(distdir)/.tarball-version
# Set ChangeLog tag reference.
sed -i "s!log!log?h=v$(VERSION)!" $(distdir)/ChangeLog

16
NEWS
View file

@ -1,3 +1,19 @@
util-linux 2.37.4: Feb 14 2022
* see Documentation/releases/v2.37.4-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.4-ChangeLog
util-linux 2.37.3: Jan 25 2022
* see Documentation/releases/v2.37.3-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.3-ChangeLog
util-linux 2.37.2: Aug 16 2021
* see Documentation/releases/v2.37.2-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.2-ChangeLog
util-linux 2.37.1: Jul 22 2021
* see Documentation/releases/v2.37.1-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37.1-ChangeLog
util-linux 2.37: Jun 1 2021
* see Documentation/releases/v2.37-ReleaseNotes or the complete changelog at
https://www.kernel.org/pub/linux/utils/util-linux/v2.37/v2.37-ChangeLog

View file

@ -329,5 +329,8 @@ endif
if BUILD_UL
dist_bashcompletion_DATA += bash-completion/ul
endif
if BUILD_HARDLINK
dist_bashcompletion_DATA += bash-completion/hardlink
endif
endif # BUILD_BASH_COMPLETION

View file

@ -29,7 +29,7 @@ PACKAGE_VERSION_RELEASE=$(echo $PACKAGE_VERSION | awk -F. '{
dnl libblkid version
LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
LIBBLKID_DATE="01-Jun-2021"
LIBBLKID_DATE="14-Feb-2022"
LIBBLKID_LT_MAJOR=1
LIBBLKID_LT_MINOR=1
LIBBLKID_LT_MICRO=0
@ -742,6 +742,13 @@ UL_BUILD_INIT([asciidoc])
UL_REQUIRES_PROGRAM([asciidoc], [ASCIIDOCTOR], [asciidoctor], [man pages])
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$build_asciidoc" = xyes])
have_manpages=no
AS_IF([test -f "$srcdir/sys-utils/mount.8"], [
AC_MSG_NOTICE([re-use already generated man-pages.])
have_manpages=yes]
)
AM_CONDITIONAL([HAVE_MANPAGES], [test "x$have_manpages" = xyes])
AC_ARG_ENABLE([poman],
AS_HELP_STRING([--enable-poman], [generate translated man pages]),
@ -836,8 +843,8 @@ char *c = crypt("abc","pw");
have_libcrypt=no
have_crypt=yes
],[
LIBS="$LIBS -lcrypt"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
UL_SET_LIBS([-lcrypt])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#else
@ -847,12 +854,12 @@ char *c = crypt("abc","pw");
]], [[
char *c = crypt("abc","pw");
]])],[
AC_DEFINE([HAVE_LIBCRYPT], [1], [Do we need -lcrypt?])
have_libcrypt=yes
have_crypt=yes
],[
AC_MSG_WARN([crypt() is not available])
])
UL_RESTORE_LIBS
])
AM_CONDITIONAL([HAVE_LIBCRYPT], [test "x$have_libcrypt" = xyes])
@ -874,10 +881,10 @@ AS_IF([test "x$with_selinux" = xno], [
UL_PKG_STATIC([SELINUX_LIBS_STATIC], [libselinux])
AM_CONDITIONAL([HAVE_SELINUX], [true])
UL_SET_FLAGS([], [], [$SELINUX_LIBS])
UL_SET_LIBS([$SELINUX_LIBS])
# This function is missing in old libselinux 1.xx versions
AC_CHECK_FUNCS([security_get_initial_context])
UL_RESTORE_FLAGS
UL_RESTORE_LIBS
])
])
AC_SUBST([SELINUX_LIBS])
@ -1452,14 +1459,6 @@ UL_REQUIRES_HAVE([setpriv], [linux_capability_h], [linux/capability.h header fil
UL_REQUIRES_HAVE([setpriv], [cap_ng], [libcap-ng library])
AM_CONDITIONAL([BUILD_SETPRIV], [test "x$build_setpriv" = xyes])
PKG_CHECK_MODULES([PCRE2_POSIX], [libpcre2-posix],
[have_pcre2_posix=yes],
[have_pcre2_posix=no])
AS_IF([test "x$have_pcre2_posix" = xyes ], [
AC_DEFINE([HAVE_PCRE2_POSIX], [1], [Define if libpcre2-posix is available])
])
AM_CONDITIONAL([HAVE_PCRE2_POSIX], [test "x$have_pcre2_posix" = xyes])
AC_ARG_ENABLE([hardlink],
AS_HELP_STRING([--disable-hardlink], [do not build hardlink]),
[], [UL_DEFAULT_ENABLE([hardlink], [check])]
@ -2681,6 +2680,7 @@ AC_MSG_RESULT([
libeconf support: ${have_econf}
Btrfs support: ${have_btrfs}
Wide-char support: ${build_widechar}
libcryptsetup support: ${have_cryptsetup}
Manual pages: ${build_asciidoc}
Manual pages translated: ${build_poman}

View file

@ -16,6 +16,7 @@
#include "blkdev.h"
#include "pathnames.h"
#include "closestream.h"
#include "strutils.h"
#include "sysfs.h"
struct bdc {
@ -351,7 +352,7 @@ static void do_commands(int fd, char **argv, int d)
bdcms[j].name);
errtryhelp(EXIT_FAILURE);
}
iarg = atoi(argv[++i]);
iarg = strtos32_or_err(argv[++i], _("failed to parse command argument"));
} else
iarg = bdcms[j].argval;
@ -441,7 +442,7 @@ static void report_all_devices(void)
&ma, &mi, &sz, ptname) != 4)
continue;
sprintf(device, "/dev/%s", ptname);
snprintf(device, sizeof(device), "/dev/%s", ptname);
report_device(device, 1);
}
@ -455,7 +456,7 @@ static void report_device(char *device, int quiet)
long ra;
unsigned long long bytes;
uint64_t start = 0;
char start_str[11] = { "\0" };
char start_str[16] = { "\0" };
struct stat st;
fd = open(device, O_RDONLY | O_NONBLOCK);
@ -477,13 +478,13 @@ static void report_device(char *device, int quiet)
disk != st.st_rdev) {
if (ul_path_read_u64(pc, &start, "start") != 0)
/* TRANSLATORS: Start sector not available. Max. 10 letters. */
sprintf(start_str, "%10s", _("N/A"));
/* TRANSLATORS: Start sector not available. Max. 15 letters. */
snprintf(start_str, sizeof(start_str), "%15s", _("N/A"));
}
ul_unref_path(pc);
}
if (!*start_str)
sprintf(start_str, "%10ju", start);
snprintf(start_str, sizeof(start_str), "%15ju", start);
if (ioctl(fd, BLKROGET, &ro) == 0 &&
ioctl(fd, BLKRAGET, &ra) == 0 &&
@ -502,5 +503,5 @@ static void report_device(char *device, int quiet)
static void report_header(void)
{
printf(_("RO RA SSZ BSZ StartSec Size Device\n"));
printf(_("RO RA SSZ BSZ StartSec Size Device\n"));
}

View file

@ -141,9 +141,14 @@ static void menu_refresh_size(struct cfdisk *cf);
static int ui_end(void);
static int ui_refresh(struct cfdisk *cf);
static void ui_warnx(const char *fmt, ...);
static void ui_warn(const char *fmt, ...);
static void ui_info(const char *fmt, ...);
static void ui_warnx(const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2)));
static void ui_warn(const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2)));
static void ui_info(const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2)));
static void ui_draw_menu(struct cfdisk *cf);
static int ui_menu_move(struct cfdisk *cf, int key);
static void ui_menu_resize(struct cfdisk *cf);
@ -630,13 +635,13 @@ static int ask_callback(struct fdisk_context *cxt __attribute__((__unused__)),
switch(fdisk_ask_get_type(ask)) {
case FDISK_ASKTYPE_INFO:
ui_info(fdisk_ask_print_get_mesg(ask));
ui_info("%s", fdisk_ask_print_get_mesg(ask));
break;
case FDISK_ASKTYPE_WARNX:
ui_warnx(fdisk_ask_print_get_mesg(ask));
ui_warnx("%s", fdisk_ask_print_get_mesg(ask));
break;
case FDISK_ASKTYPE_WARN:
ui_warn(fdisk_ask_print_get_mesg(ask));
ui_warn("%s", fdisk_ask_print_get_mesg(ask));
break;
case FDISK_ASKTYPE_MENU:
ask_menu(ask, (struct cfdisk *) data);
@ -668,7 +673,8 @@ static int ui_end(void)
return 0;
}
static void ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap)
static void __attribute__((__format__ (__printf__, 3, 0)))
ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap)
{
size_t width;
char *buf = NULL;
@ -698,7 +704,8 @@ static void ui_vprint_center(size_t line, int attrs, const char *fmt, va_list ap
free(buf);
}
static void ui_center(size_t line, const char *fmt, ...)
static void __attribute__((__format__ (__printf__, 2, 3)))
ui_center(size_t line, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -706,7 +713,8 @@ static void ui_center(size_t line, const char *fmt, ...)
va_end(ap);
}
static void ui_warnx(const char *fmt, ...)
static void __attribute__((__format__ (__printf__, 1, 2)))
ui_warnx(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -721,7 +729,8 @@ static void ui_warnx(const char *fmt, ...)
va_end(ap);
}
static void ui_warn(const char *fmt, ...)
static void __attribute__((__format__ (__printf__, 1, 2)))
ui_warn(const char *fmt, ...)
{
char *fmt_m;
va_list ap;
@ -747,8 +756,10 @@ static void ui_clean_warn(void)
clrtoeol();
}
static int __attribute__((__noreturn__)) ui_err(int rc, const char *fmt, ...)
{
static int __attribute__((__noreturn__))
__attribute__((__format__ (__printf__, 2, 3)))
ui_err(int rc, const char *fmt, ...)
{
va_list ap;
ui_end();
@ -761,7 +772,9 @@ static int __attribute__((__noreturn__)) ui_err(int rc, const char *fmt, ...)
exit(rc);
}
static int __attribute__((__noreturn__)) ui_errx(int rc, const char *fmt, ...)
static int __attribute__((__noreturn__))
__attribute__((__format__ (__printf__, 2, 3)))
ui_errx(int rc, const char *fmt, ...)
{
va_list ap;
ui_end();
@ -775,7 +788,8 @@ static int __attribute__((__noreturn__)) ui_errx(int rc, const char *fmt, ...)
exit(rc);
}
static void ui_info(const char *fmt, ...)
static void __attribute__((__format__ (__printf__, 1, 2)))
ui_info(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -796,7 +810,8 @@ static void ui_clean_info(void)
clrtoeol();
}
static void ui_hint(const char *fmt, ...)
static void __attribute__((__format__ (__printf__, 1, 2)))
ui_hint(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@ -1130,7 +1145,7 @@ static void ui_draw_menuitem(struct cfdisk *cf,
if (cf->menu->idx == idx) {
standend();
if (d->desc)
ui_hint(_(d->desc));
ui_hint("%s", _(d->desc));
}
}
@ -1307,6 +1322,34 @@ static char *get_mountpoint(struct cfdisk *cf, const char *tagname, const char *
}
#endif /* HAVE_LIBMOUNT */
static inline int iszero(const char *str)
{
const char *p;
for (p = str; p && *p == '0'; p++);
return !p || *p == '\0';
}
static int has_uuid(struct fdisk_table *tb, const char *uuid)
{
struct fdisk_partition *pa;
struct fdisk_iter *itr;
int rc = 0;
if (!tb || !uuid || fdisk_table_is_empty(tb))
return 0;
itr = fdisk_new_iter(FDISK_ITER_FORWARD);
while (rc == 0 && fdisk_table_next_partition(tb, itr, &pa) == 0) {
const char *x = fdisk_partition_get_uuid(pa);
if (x)
rc = strcmp(x, uuid) == 0;
}
fdisk_free_iter(itr);
return rc;
}
static void extra_prepare_data(struct cfdisk *cf)
{
struct fdisk_partition *pa = get_current_partition(cf);
@ -1326,7 +1369,14 @@ static void extra_prepare_data(struct cfdisk *cf)
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_UUID, &data) && data) {
extra_insert_pair(l, _("Partition UUID:"), data);
if (!mountpoint)
/* Search for mountpoint by PARTUUID= means that we need to
* check fstab and convert PARTUUID to the device name. This is
* unnecessary and overkill for newly created partitions. Let's
* check if the UUID already exist in the old layout, otherwise
* ignore it.
*/
if (!mountpoint && has_uuid(cf->original_layout, data))
mountpoint = get_mountpoint(cf, "PARTUUID", data);
free(data);
}
@ -1350,19 +1400,19 @@ static void extra_prepare_data(struct cfdisk *cf)
/* for numeric data, only show non-zero rows */
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_BSIZE, &data) && data) {
if (atoi(data))
if (!iszero(data))
extra_insert_pair(l, "BSIZE:", data);
free(data);
}
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_CPG, &data) && data) {
if (atoi(data))
if (!iszero(data))
extra_insert_pair(l, "CPG:", data);
free(data);
}
if (!fdisk_partition_to_string(pa, cf->cxt, FDISK_FIELD_FSIZE, &data) && data) {
if (atoi(data))
if (!iszero(data))
extra_insert_pair(l, "FSIZE:", data);
free(data);
}
@ -1778,7 +1828,7 @@ static ssize_t ui_get_string(const char *prompt,
mbs_edit_goto(edit, MBS_EDIT_END);
if (hint)
ui_hint(hint);
ui_hint("%s", hint);
else
ui_clean_hint();

View file

@ -68,10 +68,10 @@ void list_disk_geometry(struct fdisk_context *cxt)
fdisk_info(cxt, _("Disk model: %s"), fdisk_get_devmodel(cxt));
if (lb && (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt)))
fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
fdisk_info(cxt, _("Geometry: %d heads, %ju sectors/track, %ju cylinders"),
fdisk_get_geom_heads(cxt),
fdisk_get_geom_sectors(cxt),
fdisk_get_geom_cylinders(cxt));
(uintmax_t) fdisk_get_geom_sectors(cxt),
(uintmax_t) fdisk_get_geom_cylinders(cxt));
fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"),
fdisk_get_unit(cxt, FDISK_PLURAL),
@ -182,7 +182,7 @@ void list_disklabel(struct fdisk_context *cxt)
/* print */
if (!scols_table_is_empty(out)) {
fdisk_info(cxt, ""); /* just line break */
fdisk_info(cxt, "%s", ""); /* just line break */
scols_print_table(out);
}
@ -193,14 +193,14 @@ void list_disklabel(struct fdisk_context *cxt)
continue;
if (!fdisk_lba_is_phy_aligned(cxt, fdisk_partition_get_start(pa))) {
if (!post)
fdisk_info(cxt, ""); /* line break */
fdisk_info(cxt, "%s", ""); /* line break */
fdisk_warnx(cxt, _("Partition %zu does not start on physical sector boundary."),
fdisk_partition_get_partno(pa) + 1);
post++;
}
if (fdisk_partition_has_wipe(cxt, pa)) {
if (!post)
fdisk_info(cxt, ""); /* line break */
fdisk_info(cxt, "%s", ""); /* line break */
fdisk_info(cxt, _("Filesystem/RAID signature on partition %zu will be wiped."),
fdisk_partition_get_partno(pa) + 1);
@ -210,7 +210,7 @@ void list_disklabel(struct fdisk_context *cxt)
if (fdisk_table_wrong_order(tb)) {
if (!post)
fdisk_info(cxt, ""); /* line break */
fdisk_info(cxt, "%s", ""); /* line break */
fdisk_info(cxt, _("Partition table entries are not in disk order."));
}
done:
@ -308,7 +308,7 @@ void list_freespace(struct fdisk_context *cxt)
/* print */
if (!scols_table_is_empty(out)) {
fdisk_info(cxt, ""); /* line break */
fdisk_info(cxt, "%s", ""); /* line break */
scols_print_table(out);
}
done:

View file

@ -636,10 +636,6 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
break;
case 'f':
rc = fdisk_reorder_partitions(cxt);
if (rc)
fdisk_warnx(cxt, _("Failed to fix partitions order."));
else
fdisk_info(cxt, _("Partitions order fixed."));
break;
case 'r':
rc = fdisk_enable_details(cxt, 0);

View file

@ -209,7 +209,7 @@ enables libblkid debug output.
enables libsmartcols debug output.
*LIBSMARTCOLS_DEBUG_PADDING*=on::
use visible padding characters. Requires enabled *LIBSMARTCOLS_DEBUG*.
use visible padding characters.
*LOCK_BLOCK_DEVICE*=<mode>::
use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details.

View file

@ -16,7 +16,7 @@ fsck - check and repair a Linux filesystem
== SYNOPSIS
*fsck* [*-lsAVRTMNP*] [*-r* [_fd_]] [*-C* [_fd_] [*-t* _fstype_] [_filesystem_...] [*--*] [_fs-specific-options_]
*fsck* [*-lsAVRTMNP*] [*-r* [_fd_]] [*-C* [_fd_]] [*-t* _fstype_] [_filesystem_...] [*--*] [_fs-specific-options_]
== DESCRIPTION

View file

@ -169,8 +169,9 @@ static int string_to_int(const char *s)
long l;
char *p;
errno = 0;
l = strtol(s, &p, 0);
if (*p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
if (errno || *p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
return -1;
return (int) l;
@ -1603,8 +1604,8 @@ static void parse_argv(int argc, char *argv[])
if (getenv("FSCK_FORCE_ALL_PARALLEL"))
force_all_parallel++;
if ((tmp = getenv("FSCK_MAX_INST")))
max_running = atoi(tmp);
if (ul_strtos32(getenv("FSCK_MAX_INST"), &max_running, 10) != 0)
max_running = 0;
}
int main(int argc, char *argv[])

View file

@ -152,14 +152,15 @@ static void test_super(int *start, size_t * length)
{
struct stat st;
/* find the physical size of the file or block device */
if (stat(filename, &st) < 0)
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
fd = open(filename, O_RDONLY);
if (fd < 0)
err(FSCK_EX_ERROR, _("cannot open %s"), filename);
/* find the physical size of the file or block device */
if (fstat(fd, &st) < 0)
err(FSCK_EX_ERROR, _("stat of %s failed"), filename);
if (S_ISBLK(st.st_mode)) {
unsigned long long bytes;
if (blkdev_get_size(fd, &bytes))

View file

@ -157,6 +157,8 @@ do_mmap(char *path, unsigned int size, unsigned int mode){
return NULL;
if (S_ISLNK(mode)) {
/* The link buffer is unnecessary to terminate by null as it's
* always used as buffer rather than a string */
start = xmalloc(size);
if (readlink(path, start, size) < 0) {
warn(_("readlink failed: %s"), path);

View file

@ -267,6 +267,8 @@ static void check_extents(struct mkswap_control *ctl)
return;
n = fiemap->fm_mapped_extents;
if (n == 0)
break;
for (i = 0; i < n; i++) {
struct fiemap_extent *e = &fiemap->fm_extents[i];

View file

@ -29,7 +29,7 @@ sfdisk - display or manipulate a disk partition table
*sfdisk* [options] _device_ [*-N* _partition-number_]
*sfdisk* [options] _command_]
*sfdisk* [options] _command_
== DESCRIPTION

View file

@ -468,7 +468,7 @@ static int move_partition_data(struct sfdisk *sf, size_t partno, struct fdisk_pa
typescript = mk_backup_filename_tpl(sf->move_typescript, devname, ".move");
if (!sf->quiet) {
fdisk_info(sf->cxt,"");
fdisk_info(sf->cxt, "%s", "");
color_scheme_enable("header", UL_COLOR_BOLD);
fdisk_info(sf->cxt, sf->noact ? _("Data move: (--no-act)") : _("Data move:"));
color_disable();
@ -1926,7 +1926,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
rc = fdisk_add_partition(sf->cxt, pa, &cur_partno);
if (rc) {
errno = -rc;
fdisk_warn(sf->cxt, _("Failed to add #%d partition"), next_partno + 1);
fdisk_warn(sf->cxt, _("Failed to add #%zu partition"), next_partno + 1);
}
}

View file

@ -16,6 +16,8 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <grp.h>
#include <assert.h>
@ -217,7 +219,7 @@ prog_inv_sh_nm_from_file(char *f, char stripext)
#ifndef HAVE_ERR_H
static inline void
static inline void __attribute__ ((__format__ (__printf__, 4, 5)))
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
{
fprintf(stderr, "%s: ", program_invocation_short_name);
@ -335,6 +337,24 @@ static inline size_t get_hostname_max(void)
return 64;
}
static inline int drop_permissions(void)
{
errno = 0;
/* drop GID */
if (setgid(getgid()) < 0)
goto fail;
/* drop UID */
if (setuid(getuid()) < 0)
goto fail;
return 0;
fail:
return errno ? -errno : -1;
}
/*
* The usleep function was marked obsolete in POSIX.1-2001 and was removed
* in POSIX.1-2008. It was replaced with nanosleep() that provides more

View file

@ -82,18 +82,16 @@ static inline struct dirent *xreaddir(DIR *dp)
# if defined(SYS_close_range)
# include <sys/types.h>
# ifndef HAVE_CLOSE_RANGE
static inline int close_range(unsigned int first, unsigned int last)
static inline int close_range(unsigned int first, unsigned int last, int flags)
{
return syscall(SYS_close_range, first, last);
return syscall(SYS_close_range, first, last, flags);
}
# endif
# define HAVE_CLOSE_RANGE 1
# endif /* SYS_close_range */
#endif /* __linux__ */
#ifndef HAVE_CLOSE_RANGE
extern void ul_close_all_fds(unsigned int first, unsigned int last);
#endif
#define UL_COPY_READ_ERROR (-1)
#define UL_COPY_WRITE_ERROR (-2)

View file

@ -23,7 +23,8 @@ struct path_cxt {
int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
};
struct path_cxt *ul_new_path(const char *dir, ...);
struct path_cxt *ul_new_path(const char *dir, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
void ul_unref_path(struct path_cxt *pc);
void ul_ref_path(struct path_cxt *pc);
@ -55,15 +56,18 @@ int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
int ul_path_open(struct path_cxt *pc, int flags, const char *path);
int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap);
int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap)
__attribute__ ((__format__ (__printf__, 3, 0)));
FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap);
FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap)
__attribute__ ((__format__ (__printf__, 3, 0)));
DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap);
DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap)
__attribute__ ((__format__ (__printf__, 2, 0)));
DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
@ -72,7 +76,8 @@ ssize_t ul_path_readlinkf(struct path_cxt *pc, char *buf, size_t bufsiz, const c
__attribute__ ((__format__ (__printf__, 4, 5)));
int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap);
int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap)
__attribute__ ((__format__ (__printf__, 4, 0)));
int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
@ -84,8 +89,10 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char
int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...);
int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...)
__attribute__ ((__format__ (__scanf__, 3, 4)));
int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 0)))
__attribute__ ((__format__ (__scanf__, 4, 5)));
int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);

View file

@ -19,17 +19,25 @@ extern int parse_size(const char *str, uintmax_t *res, int *power);
extern int strtosize(const char *str, uintmax_t *res);
extern uintmax_t strtosize_or_err(const char *str, const char *errmesg);
extern int16_t strtos16_or_err(const char *str, const char *errmesg);
extern uint16_t strtou16_or_err(const char *str, const char *errmesg);
extern uint16_t strtox16_or_err(const char *str, const char *errmesg);
extern int ul_strtos64(const char *str, int64_t *num, int base);
extern int ul_strtou64(const char *str, uint64_t *num, int base);
extern int ul_strtos32(const char *str, int32_t *num, int base);
extern int ul_strtou32(const char *str, uint32_t *num, int base);
extern int32_t strtos32_or_err(const char *str, const char *errmesg);
extern uint32_t strtou32_or_err(const char *str, const char *errmesg);
extern uint32_t strtox32_or_err(const char *str, const char *errmesg);
extern int64_t str2num_or_err(const char *str, int base, const char *errmesg, int64_t low, int64_t up);
extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up);
extern int64_t strtos64_or_err(const char *str, const char *errmesg);
extern uint64_t strtou64_or_err(const char *str, const char *errmesg);
extern uint64_t strtox64_or_err(const char *str, const char *errmesg);
#define strtos64_or_err(_s, _e) str2num_or_err(_s, 10, _e, 0, 0)
#define strtou64_or_err(_s, _e) str2unum_or_err(_s, 10, _e, 0)
#define strtox64_or_err(_s, _e) str2unum_or_err(_s, 16, _e, 0)
#define strtos32_or_err(_s, _e) (int32_t) str2num_or_err(_s, 10, _e, INT32_MIN, INT32_MAX)
#define strtou32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 10, _e, UINT32_MAX)
#define strtox32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 16, _e, UINT32_MAX)
#define strtos16_or_err(_s, _e) (int16_t) str2num_or_err(_s, 10, _e, INT16_MIN, INT16_MAX)
#define strtou16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 10, _e, UINT16_MAX)
#define strtox16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 16, _e, UINT16_MAX)
extern double strtod_or_err(const char *str, const char *errmesg);
extern long double strtold_or_err(const char *str, const char *errmesg);
@ -98,8 +106,8 @@ static inline char *mem2strcpy(char *dest, const void *src, size_t n, size_t nma
if (n + 1 > nmax)
n = nmax - 1;
memset(dest, '\0', nmax);
memcpy(dest, src, n);
dest[nmax-1] = '\0';
return dest;
}
@ -334,7 +342,7 @@ static inline size_t normalize_whitespace(unsigned char *str)
else
str[x++] = str[i++];
}
if (nsp) /* tailing space */
if (nsp && x > 0) /* tailing space */
x--;
str[x] = '\0';
return x;
@ -362,7 +370,7 @@ static inline void strrem(char *s, int rem)
extern char *strnappend(const char *s, const char *suffix, size_t b);
extern char *strappend(const char *s, const char *suffix);
extern char *strfappend(const char *s, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 0)));
__attribute__ ((__format__ (__printf__, 2, 3)));
extern const char *split(const char **state, size_t *l, const char *separator, int quoted);
extern int skip_fline(FILE *fp);

View file

@ -13,9 +13,12 @@ unsigned strv_length(char * const *l);
int strv_extend_strv(char ***a, char **b);
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int strv_extend(char ***l, const char *value);
int strv_extendv(char ***l, const char *format, va_list ap);
int strv_extendv(char ***l, const char *format, va_list ap)
__attribute__ ((__format__ (__printf__, 2, 0)));
int strv_extendf(char ***l, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 0)));
__attribute__ ((__format__ (__printf__, 2, 3)));
int strv_push(char ***l, char *value);
int strv_push_prepend(char ***l, char *value);
int strv_consume(char ***l, char *value);

View file

@ -170,8 +170,7 @@ char *canonicalize_path_restricted(const char *path)
pipes[0] = -1;
errno = 0;
/* drop permissions */
if (setgid(getgid()) < 0 || setuid(getuid()) < 0)
if (drop_permissions() != 0)
canonical = NULL; /* failed */
else {
char *dmname = NULL;

View file

@ -129,7 +129,6 @@ unsigned int get_fd_tabsize(void)
return m;
}
#ifndef HAVE_CLOSE_RANGE
void ul_close_all_fds(unsigned int first, unsigned int last)
{
struct dirent *d;
@ -166,7 +165,6 @@ void ul_close_all_fds(unsigned int first, unsigned int last)
}
}
}
#endif
#ifdef TEST_PROGRAM_FILEUTILS
int main(int argc, char *argv[])
@ -189,10 +187,10 @@ int main(int argc, char *argv[])
ignore_result( dup(STDIN_FILENO) );
# ifdef HAVE_CLOSE_RANGE
close_range(STDERR_FILENO + 1, ~0U);
# else
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
if (close_range(STDERR_FILENO + 1, ~0U, 0) < 0)
# endif
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
} else if (strcmp(argv[1], "--copy-file") == 0) {
int ret = ul_copy_file(STDIN_FILENO, STDOUT_FILENO);
if (ret == UL_COPY_READ_ERROR)

View file

@ -1360,7 +1360,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) {
rc = -errno;
errsv = errno;
if (errno != EINVAL) {
if (errno != EINVAL && errno != ENOTTY) {
DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE failed: %m"));
goto err;
}

View file

@ -542,22 +542,27 @@ DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
ssize_t ul_path_readlink(struct path_cxt *pc, char *buf, size_t bufsiz, const char *path)
{
int dirfd;
ssize_t ssz;
if (!path) {
const char *p = get_absdir(pc);
if (!p)
return -errno;
return readlink(p, buf, bufsiz);
ssz = readlink(p, buf, bufsiz - 1);
} else {
dirfd = ul_path_get_dirfd(pc);
if (dirfd < 0)
return dirfd;
if (*path == '/')
path++;
ssz = readlinkat(dirfd, path, buf, bufsiz - 1);
}
dirfd = ul_path_get_dirfd(pc);
if (dirfd < 0)
return dirfd;
if (*path == '/')
path++;
return readlinkat(dirfd, path, buf, bufsiz);
if (ssz >= 0)
buf[ssz] = '\0';
return ssz;
}
/*
@ -617,7 +622,7 @@ int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path,
* Returns newly allocated buffer with data from file. Maximal size is BUFSIZ
* (send patch if you need something bigger;-)
*
* Returns size of the string!
* Returns size of the string without \0, nothing is allocated if returns <= 0.
*/
int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
{
@ -635,6 +640,8 @@ int ul_path_read_string(struct path_cxt *pc, char **str, const char *path)
/* Remove tailing newline (usual in sysfs) */
if (rc > 0 && *(buf + rc - 1) == '\n')
--rc;
if (rc == 0)
return 0;
buf[rc] = '\0';
*str = strdup(buf);
@ -1099,7 +1106,7 @@ int main(int argc, char *argv[])
ul_path_init_debug();
pc = ul_new_path(dir);
pc = ul_new_path("%s", dir);
if (!pc)
err(EXIT_FAILURE, "failed to initialize path context");
if (prefix)
@ -1191,11 +1198,11 @@ int main(int argc, char *argv[])
errx(EXIT_FAILURE, "<file> not defined");
file = argv[optind++];
if (ul_path_read_string(pc, &res, file) < 0)
if (ul_path_read_string(pc, &res, file) <= 0)
err(EXIT_FAILURE, "read string failed");
printf("read: %s: %s\n", file, res);
if (ul_path_readf_string(pc, &res, "%s", file) < 0)
if (ul_path_readf_string(pc, &res, "%s", file) <= 0)
err(EXIT_FAILURE, "readf string failed");
printf("readf: %s: %s\n", file, res);

View file

@ -3,6 +3,7 @@
* it what you wish.
*/
#include <stdlib.h>
#include <assert.h>
#include "c.h"
#include "pwdutils.h"
@ -17,8 +18,8 @@ struct passwd *xgetpwnam(const char *username, char **pwdbuf)
struct passwd *pwd = NULL, *res = NULL;
int rc;
if (!pwdbuf || !username)
return NULL;
assert(pwdbuf);
assert(username);
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
pwd = xcalloc(1, sizeof(struct passwd));
@ -49,8 +50,8 @@ struct group *xgetgrnam(const char *groupname, char **grpbuf)
struct group *grp = NULL, *res = NULL;
int rc;
if (!grpbuf || !groupname)
return NULL;
assert(grpbuf);
assert(groupname);
*grpbuf = xmalloc(UL_GETPW_BUFSIZ);
grp = xcalloc(1, sizeof(struct group));
@ -77,8 +78,7 @@ struct passwd *xgetpwuid(uid_t uid, char **pwdbuf)
struct passwd *pwd = NULL, *res = NULL;
int rc;
if (!pwdbuf)
return NULL;
assert(pwdbuf);
*pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
pwd = xcalloc(1, sizeof(struct passwd));
@ -104,11 +104,6 @@ char *xgetlogin(void)
{
struct passwd *pw = NULL;
uid_t ruid;
char *user;
user = getlogin();
if (user)
return xstrdup(user);
/* GNU Hurd implementation has an extension where a process can exist in a
* non-conforming environment, and thus be outside the realms of POSIX
@ -117,6 +112,9 @@ char *xgetlogin(void)
* environment.
*
* http://austingroupbugs.net/view.php?id=511
*
* The same implementation is useful for other systems, since getlogin(3)
* shouldn't be used as actual identification.
*/
errno = 0;
ruid = getuid();

View file

@ -319,123 +319,114 @@ char *strndup(const char *s, size_t n)
}
#endif
static uint32_t _strtou32_or_err(const char *str, const char *errmesg, int base);
static uint64_t _strtou64_or_err(const char *str, const char *errmesg, int base);
int16_t strtos16_or_err(const char *str, const char *errmesg)
/*
* convert strings to numbers; returns <0 on error, and 0 on success
*/
int ul_strtos64(const char *str, int64_t *num, int base)
{
int32_t num = strtos32_or_err(str, errmesg);
if (num < INT16_MIN || num > INT16_MAX) {
errno = ERANGE;
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
}
static uint16_t _strtou16_or_err(const char *str, const char *errmesg, int base)
{
uint32_t num = _strtou32_or_err(str, errmesg, base);
if (num > UINT16_MAX) {
errno = ERANGE;
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
}
uint16_t strtou16_or_err(const char *str, const char *errmesg)
{
return _strtou16_or_err(str, errmesg, 10);
}
uint16_t strtox16_or_err(const char *str, const char *errmesg)
{
return _strtou16_or_err(str, errmesg, 16);
}
int32_t strtos32_or_err(const char *str, const char *errmesg)
{
int64_t num = strtos64_or_err(str, errmesg);
if (num < INT32_MIN || num > INT32_MAX) {
errno = ERANGE;
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
}
static uint32_t _strtou32_or_err(const char *str, const char *errmesg, int base)
{
uint64_t num = _strtou64_or_err(str, errmesg, base);
if (num > UINT32_MAX) {
errno = ERANGE;
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
}
uint32_t strtou32_or_err(const char *str, const char *errmesg)
{
return _strtou32_or_err(str, errmesg, 10);
}
uint32_t strtox32_or_err(const char *str, const char *errmesg)
{
return _strtou32_or_err(str, errmesg, 16);
}
int64_t strtos64_or_err(const char *str, const char *errmesg)
{
int64_t num;
char *end = NULL;
errno = 0;
if (str == NULL || *str == '\0')
goto err;
num = strtoimax(str, &end, 10);
return -EINVAL;
*num = (int64_t) strtoimax(str, &end, base);
if (errno || str == end || (end && *end))
goto err;
return num;
err:
if (errno == ERANGE)
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
return -EINVAL;
return 0;
}
static uint64_t _strtou64_or_err(const char *str, const char *errmesg, int base)
int ul_strtou64(const char *str, uint64_t *num, int base)
{
uintmax_t num;
char *end = NULL;
int64_t tmp;
errno = 0;
if (str == NULL || *str == '\0')
goto err;
num = strtoumax(str, &end, base);
return -EINVAL;
/* we need to ignore negative numbers, note that for invalid negative
* number strtoimax() returns negative number too, so we do not
* need to check errno here */
tmp = (int64_t) strtoimax(str, &end, base);
if (tmp < 0)
errno = ERANGE;
else {
errno = 0;
*num = strtoumax(str, &end, base);
}
if (errno || str == end || (end && *end))
goto err;
return -EINVAL;
return 0;
}
int ul_strtos32(const char *str, int32_t *num, int base)
{
int64_t tmp;
int rc;
rc = ul_strtos64(str, &tmp, base);
if (rc == 0 && (tmp < INT32_MIN || tmp > INT32_MAX))
rc = -(errno = ERANGE);
if (rc == 0)
*num = (int32_t) tmp;
return rc;
}
int ul_strtou32(const char *str, uint32_t *num, int base)
{
uint64_t tmp;
int rc;
rc = ul_strtou64(str, &tmp, base);
if (rc == 0 && tmp > UINT32_MAX)
rc = -(errno = ERANGE);
if (rc == 0)
*num = (uint32_t) tmp;
return rc;
}
/*
* Covert strings to numbers in defined range and print message on error.
*
* These functions are used when we read input from users (getopt() etc.). It's
* better to consolidate the code and keep it all based on 64-bit numbers then
* implement it for 32 and 16-bit numbers too.
*/
int64_t str2num_or_err(const char *str, int base, const char *errmesg,
int64_t low, int64_t up)
{
int64_t num = 0;
int rc;
rc = ul_strtos64(str, &num, base);
if (rc == 0 && ((low && num < low) || (up && num > up)))
rc = -(errno = ERANGE);
if (rc) {
if (errno == ERANGE)
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
err:
if (errno == ERANGE)
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
uint64_t strtou64_or_err(const char *str, const char *errmesg)
uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up)
{
return _strtou64_or_err(str, errmesg, 10);
}
uint64_t num = 0;
int rc;
uint64_t strtox64_or_err(const char *str, const char *errmesg)
{
return _strtou64_or_err(str, errmesg, 16);
rc = ul_strtou64(str, &num, base);
if (rc == 0 && (up && num > up))
rc = -(errno = ERANGE);
if (rc) {
if (errno == ERANGE)
err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str);
}
return num;
}
double strtod_or_err(const char *str, const char *errmesg)
@ -1192,29 +1183,49 @@ static int test_strutils_normalize(int argc, char *argv[])
int main(int argc, char *argv[])
{
if (argc == 3 && strcmp(argv[1], "--size") == 0)
if (argc == 3 && strcmp(argv[1], "--size") == 0) {
return test_strutils_sizes(argc - 1, argv + 1);
if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0)
} else if (argc == 4 && strcmp(argv[1], "--cmp-paths") == 0) {
return test_strutils_cmp_paths(argc - 1, argv + 1);
if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0)
} else if (argc == 4 && strcmp(argv[1], "--strdup-member") == 0) {
return test_strdup_to_member(argc - 1, argv + 1);
if (argc == 4 && strcmp(argv[1], "--stralnumcmp") == 0) {
} else if (argc == 4 && strcmp(argv[1], "--stralnumcmp") == 0) {
printf("%s\n", ul_stralnumcmp(argv[2], argv[3]) == 0 ?
"match" : "dismatch");
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--normalize") == 0)
} else if (argc == 3 && strcmp(argv[1], "--normalize") == 0) {
return test_strutils_normalize(argc - 1, argv + 1);
else {
} else if (argc == 3 && strcmp(argv[1], "--strtos64") == 0) {
printf("'%s'-->%jd\n", argv[2], strtos64_or_err(argv[2], "strtos64 failed"));
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--strtou64") == 0) {
printf("'%s'-->%ju\n", argv[2], strtou64_or_err(argv[2], "strtou64 failed"));
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--strtos32") == 0) {
printf("'%s'-->%d\n", argv[2], strtos32_or_err(argv[2], "strtos32 failed"));
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--strtou32") == 0) {
printf("'%s'-->%u\n", argv[2], strtou32_or_err(argv[2], "strtou32 failed"));
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--strtos16") == 0) {
printf("'%s'-->%hd\n", argv[2], strtos16_or_err(argv[2], "strtos16 failed"));
return EXIT_SUCCESS;
} else if (argc == 3 && strcmp(argv[1], "--strtou16") == 0) {
printf("'%s'-->%hu\n", argv[2], strtou16_or_err(argv[2], "strtou16 failed"));
return EXIT_SUCCESS;
} else {
fprintf(stderr, "usage: %1$s --size <number>[suffix]\n"
" %1$s --cmp-paths <path> <path>\n"
" %1$s --strdup-member <str> <str>\n"
" %1$s --stralnumcmp <str> <str>\n"
" %1$s --normalize <str>\n",
" %1$s --normalize <str>\n"
" %1$s --strto{s,u}{16,32,64} <str>\n",
argv[0]);
exit(EXIT_FAILURE);
}

View file

@ -182,10 +182,9 @@ char *sysfs_blkdev_get_name(struct path_cxt *pc, char *buf, size_t bufsiz)
ssize_t sz;
/* read /sys/dev/block/<maj:min> link */
sz = ul_path_readlink(pc, link, sizeof(link) - 1, NULL);
sz = ul_path_readlink(pc, link, sizeof(link), NULL);
if (sz < 0)
return NULL;
link[sz] = '\0';
name = strrchr(link, '/');
if (!name)
@ -393,7 +392,7 @@ char *sysfs_blkdev_get_devchain(struct path_cxt *pc, char *buf, size_t bufsz)
if (sz <= 0 || sz + sizeof(_PATH_SYS_DEVBLOCK "/") > bufsz)
return NULL;
buf[sz++] = '\0';
sz++;
prefix = ul_path_get_prefix(pc);
if (prefix)
psz = strlen(prefix);
@ -567,10 +566,9 @@ int sysfs_blkdev_get_wholedisk( struct path_cxt *pc,
char *name;
ssize_t linklen;
linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath) - 1, NULL);
linklen = ul_path_readlink(pc, linkpath, sizeof(linkpath), NULL);
if (linklen < 0)
goto err;
linkpath[linklen] = '\0';
stripoff_last_component(linkpath); /* dirname */
name = stripoff_last_component(linkpath); /* basename */
@ -678,11 +676,10 @@ int sysfs_blkdev_scsi_get_hctl(struct path_cxt *pc, int *h, int *c, int *t, int
goto done;
blk->hctl_error = 1;
len = ul_path_readlink(pc, buf, sizeof(buf) - 1, "device");
len = ul_path_readlink(pc, buf, sizeof(buf), "device");
if (len < 0)
return len;
buf[len] = '\0';
hctl = strrchr(buf, '/');
if (!hctl)
return -1;

View file

@ -1040,8 +1040,9 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
if (prefix && strncasecmp(prefix, "part", 4) == 0) {
char *end = NULL;
errno = 0;
partno = strtol(prefix + 4, &end, 10);
if (prefix == end || (end && *end))
if (errno || prefix == end || (end && *end))
partno = 0;
else
rc = 0; /* success */

View file

@ -1272,7 +1272,11 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
if (rc || len == 0 || off == NULL)
return 0;
errno = 0;
magoff = strtoumax(off, NULL, 10);
if (errno)
return 0;
offset = magoff + pr->off;
fd = blkid_probe_get_fd(pr);
if (fd < 0)

View file

@ -297,16 +297,25 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
DBG(READ, ul_debug("tag: %s=\"%s\"", name, value));
errno = 0;
/* Some tags are stored directly in the device struct */
if (!strcmp(name, "DEVNO"))
if (!strcmp(name, "DEVNO")) {
dev->bid_devno = strtoull(value, NULL, 0);
else if (!strcmp(name, "PRI"))
if (errno)
return -errno;
} else if (!strcmp(name, "PRI")) {
dev->bid_pri = strtol(value, NULL, 0);
else if (!strcmp(name, "TIME")) {
if (errno)
return -errno;
} else if (!strcmp(name, "TIME")) {
char *end = NULL;
dev->bid_time = strtoull(value, &end, 0);
if (end && *end == '.')
if (errno == 0 && end && *end == '.')
dev->bid_utime = strtoull(end + 1, NULL, 0);
if (errno)
return -errno;
} else
ret = blkid_set_tag(dev, name, value, strlen(value));

View file

@ -19,13 +19,18 @@
#include "superblocks.h"
#include "crc32c.h"
/* Macro to avoid error in struct declaration. */
#define STRATIS_UUID_LEN 32
/* Contains 4 hyphens and trailing null byte. */
const int STRATIS_UUID_STR_LEN = 37;
struct stratis_sb {
uint32_t crc32;
uint8_t magic[16];
uint64_t sectors;
uint8_t reserved[4];
uint8_t pool_uuid[32];
uint8_t dev_uuid[32];
uint8_t pool_uuid[STRATIS_UUID_LEN];
uint8_t dev_uuid[STRATIS_UUID_LEN];
uint64_t mda_size;
uint64_t reserved_size;
uint64_t flags;
@ -57,11 +62,29 @@ static int stratis_valid_sb(uint8_t *p)
return crc == le32_to_cpu(stratis->crc32);
}
/*
* Format UUID string representation to include hyphens given that Stratis stores
* UUIDs without hyphens in the superblock to keep the UUID length a power of 2.
*/
static void stratis_format_uuid(const unsigned char *src_uuid,
unsigned char *dst_uuid)
{
int i;
for (i = 0; i < STRATIS_UUID_LEN; i++) {
*dst_uuid++ = *src_uuid++;
if (i == 7 || i == 11 || i == 15 || i == 19)
*dst_uuid ++ = '-';
}
*dst_uuid = '\0';
}
static int probe_stratis(blkid_probe pr,
const struct blkid_idmag *mag __attribute__((__unused__)))
{
const struct stratis_sb *stratis = NULL;
uint8_t *buf = blkid_probe_get_buffer(pr, 0, SB_AREA_SIZE);
unsigned char uuid[STRATIS_UUID_STR_LEN];
if (!buf)
return errno ? -errno : 1;
@ -76,17 +99,16 @@ static int probe_stratis(blkid_probe pr,
(buf + SECOND_COPY_OFFSET);
}
blkid_probe_strncpy_uuid(pr, stratis->dev_uuid,
sizeof(stratis->dev_uuid));
blkid_probe_set_value(pr, "POOL_UUID",
stratis->pool_uuid,
sizeof(stratis->pool_uuid));
stratis_format_uuid(stratis->dev_uuid, uuid);
blkid_probe_strncpy_uuid(pr, uuid, sizeof(uuid));
stratis_format_uuid(stratis->pool_uuid, uuid);
blkid_probe_set_value(pr, "POOL_UUID", uuid, sizeof(uuid));
blkid_probe_sprintf_value(pr, "BLOCKDEV_SECTORS", "%" PRIu64,
le64_to_cpu(stratis->sectors));
blkid_probe_sprintf_value(pr, "BLOCKDEV_INITTIME", "%" PRIu64,
le64_to_cpu(stratis->initialization_time));
return 0;
}

View file

@ -43,7 +43,9 @@ struct vfat_super_block {
/* 30*/ uint16_t vs_fsinfo_sector;
/* 32*/ uint16_t vs_backup_boot;
/* 34*/ uint16_t vs_reserved2[6];
/* 40*/ unsigned char vs_unknown[3];
/* 40*/ unsigned char vs_drive_number;
/* 41*/ unsigned char vs_boot_flags;
/* 42*/ unsigned char vs_ext_boot_sign; /* 0x28 - without vs_label/vs_magic; 0x29 - with */
/* 43*/ unsigned char vs_serno[4];
/* 47*/ unsigned char vs_label[11];
/* 52*/ unsigned char vs_magic[8];
@ -53,6 +55,7 @@ struct vfat_super_block {
/* Yucky misaligned values */
struct msdos_super_block {
/* DOS 2.0 BPB */
/* 00*/ unsigned char ms_ignored[3];
/* 03*/ unsigned char ms_sysid[8];
/* 0b*/ unsigned char ms_sector_size[2];
@ -63,16 +66,21 @@ struct msdos_super_block {
/* 13*/ unsigned char ms_sectors[2]; /* =0 iff V3 or later */
/* 15*/ unsigned char ms_media;
/* 16*/ uint16_t ms_fat_length; /* Sectors per FAT */
/* DOS 3.0 BPB */
/* 18*/ uint16_t ms_secs_track;
/* 1a*/ uint16_t ms_heads;
/* 1c*/ uint32_t ms_hidden;
/* V3 BPB */
/* DOS 3.31 BPB */
/* 20*/ uint32_t ms_total_sect; /* iff ms_sectors == 0 */
/* V4 BPB */
/* 24*/ unsigned char ms_unknown[3]; /* Phys drive no., resvd, V4 sig (0x29) */
/* DOS 3.4 EBPB */
/* 24*/ unsigned char ms_drive_number;
/* 25*/ unsigned char ms_boot_flags;
/* 26*/ unsigned char ms_ext_boot_sign; /* 0x28 - DOS 3.4 EBPB; 0x29 - DOS 4.0 EBPB */
/* 27*/ unsigned char ms_serno[4];
/* DOS 4.0 EBPB */
/* 2b*/ unsigned char ms_label[11];
/* 36*/ unsigned char ms_magic[8];
/* padding */
/* 3e*/ unsigned char ms_dummy2[0x1fe - 0x3e];
/*1fe*/ unsigned char ms_pmagic[2];
} __attribute__((packed));
@ -324,8 +332,11 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
vol_label = vol_label_buf;
}
boot_label = ms->ms_label;
vol_serno = ms->ms_serno;
if (ms->ms_ext_boot_sign == 0x29)
boot_label = ms->ms_label;
if (ms->ms_ext_boot_sign == 0x28 || ms->ms_ext_boot_sign == 0x29)
vol_serno = ms->ms_serno;
blkid_probe_set_value(pr, "SEC_TYPE", (unsigned char *) "msdos",
sizeof("msdos"));
@ -378,7 +389,9 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
version = "FAT32";
boot_label = vs->vs_label;
if (vs->vs_ext_boot_sign == 0x29)
boot_label = vs->vs_label;
vol_serno = vs->vs_serno;
/*

View file

@ -73,10 +73,7 @@ static int probe_dm_tp(blkid_probe pr,
if (dmpipe[1] != STDOUT_FILENO)
dup2(dmpipe[1], STDOUT_FILENO);
/* The libblkid library could linked with setuid programs */
if (setgid(getgid()) < 0)
exit(1);
if (setuid(getuid()) < 0)
if (drop_permissions() != 0)
exit(1);
snprintf(maj, sizeof(maj), "%d", major(devno));

View file

@ -82,10 +82,7 @@ static int probe_lvm_tp(blkid_probe pr,
if (lvpipe[1] != STDOUT_FILENO)
dup2(lvpipe[1], STDOUT_FILENO);
/* The libblkid library could linked with setuid programs */
if (setgid(getgid()) < 0)
exit(1);
if (setuid(getuid()) < 0)
if (drop_permissions() != 0)
exit(1);
lvargv[0] = cmd;

View file

@ -834,12 +834,6 @@ static int dos_probe_label(struct fdisk_context *cxt)
if (!mbr_is_valid_magic(cxt->firstsector))
return 0;
/* ignore disks with FAT */
if (cxt->collision &&
(strcmp(cxt->collision, "vfat") == 0 ||
strcmp(cxt->collision, "ntfs") == 0))
return 0;
dos_init(cxt);
get_partition_table_geometry(cxt, &h, &s);
@ -1257,7 +1251,8 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
if (start >= temp + fdisk_get_units_per_sector(cxt)
&& read) {
if (!pa || !pa->start_follow_default)
fdisk_info(cxt, _("Sector %llu is already allocated."), temp);
fdisk_info(cxt, _("Sector %ju is already allocated."),
(uintmax_t) temp);
temp = start;
read = 0;
if (pa && fdisk_partition_has_start(pa))
@ -1513,12 +1508,13 @@ static void check(struct fdisk_context *cxt, size_t n,
"maximum %d"), n, h + 1, cxt->geom.heads);
if (real_s >= cxt->geom.sectors)
fdisk_warnx(cxt, _("Partition %zu: sector %d greater than "
"maximum %llu"), n, s, cxt->geom.sectors);
"maximum %ju"), n, s,
(uintmax_t) cxt->geom.sectors);
if (real_c >= cxt->geom.cylinders)
fdisk_warnx(cxt, _("Partition %zu: cylinder %d greater than "
"maximum %llu"),
"maximum %ju"),
n, real_c + 1,
cxt->geom.cylinders);
(uintmax_t) cxt->geom.cylinders);
if (cxt->geom.cylinders <= 1024 && start != total)
fdisk_warnx(cxt, _("Partition %zu: previous sectors %u "
@ -1704,11 +1700,11 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
if (!nerrors) {
fdisk_info(cxt, _("No errors detected."));
if (total > n_sectors)
fdisk_info(cxt, _("Total allocated sectors %llu greater "
"than the maximum %llu."), total, n_sectors);
fdisk_info(cxt, _("Total allocated sectors %ju greater "
"than the maximum %ju."), (uintmax_t) total, (uintmax_t) n_sectors);
else if (total < n_sectors)
fdisk_info(cxt, _("Remaining %lld unallocated %ld-byte "
"sectors."), n_sectors - total, cxt->sector_size);
fdisk_info(cxt, _("Remaining %ju unallocated %ld-byte "
"sectors."), (uintmax_t) n_sectors - total, cxt->sector_size);
} else
fdisk_warnx(cxt,
P_("%d error detected.", "%d errors detected.", nerrors),
@ -1873,10 +1869,10 @@ static int dos_add_partition(struct fdisk_context *cxt,
msg = _("All space for primary partitions is in use.");
if (pa && fdisk_partition_has_start(pa)) {
fdisk_warnx(cxt, msg);
fdisk_warnx(cxt, "%s", msg);
return -EINVAL;
}
fdisk_info(cxt, msg);
fdisk_info(cxt, "%s", msg);
}
DBG(LABEL, ul_debug("DOS: trying logical"));
rc = add_logical(cxt, pa, &res);
@ -2440,10 +2436,8 @@ static int dos_reorder(struct fdisk_context *cxt)
struct pte *pei, *pek;
size_t i,k;
if (!wrong_p_order(cxt, NULL)) {
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
if (!wrong_p_order(cxt, NULL))
return 1;
}
while ((i = wrong_p_order(cxt, &k)) != 0 && i < 4) {
/* partition i should have come earlier, move it */
@ -2500,10 +2494,11 @@ int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i)
return 0;
}
/* the default start is at the second sector of the disk or at the
* second sector of the extended partition
/* The safe start is at the second sector, but some use-cases require
* to have MBR within the first partition , so default to the first
* sector of the disk or at the second sector of the extended partition
*/
free_start = pe->offset ? pe->offset + 1 : 1;
free_start = pe->offset ? pe->offset + 1 : 0;
curr_start = get_abs_partition_start(pe);
@ -2543,6 +2538,11 @@ int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i)
dos_partition_set_start(p, new);
partition_set_changed(cxt, i, 1);
if (new == 0)
fdisk_info(cxt, _("The new beginning of the partition overlaps the disk "
"label area. Be very careful when using the partition. "
"You can lose all your partitions on the disk."));
}
return rc;

View file

@ -10,6 +10,7 @@
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/types.h>
@ -50,7 +51,7 @@
#define EFI_PMBR_OSTYPE 0xEE
#define MSDOS_MBR_SIGNATURE 0xAA55
#define GPT_PART_NAME_LEN (72 / sizeof(uint16_t))
#define GPT_NPARTITIONS FDISK_GPT_NPARTITIONS_DEFAULT
#define GPT_NPARTITIONS ((size_t) FDISK_GPT_NPARTITIONS_DEFAULT)
/* Globally unique identifier */
struct gpt_guid {
@ -951,7 +952,7 @@ static int valid_pmbr(struct fdisk_context *cxt)
fdisk_warnx(cxt, _("GPT PMBR size mismatch (%"PRIu64" != %"PRIu64") "
"will be corrected by write."),
sz_lba, cxt->total_sectors - 1ULL);
sz_lba, cxt->total_sectors - (uint64_t) 1);
/* Note that gpt_write_pmbr() overwrites PMBR, but we want to keep it valid already
* in memory too to disable warnings when valid_pmbr() called next time */
@ -2677,7 +2678,7 @@ static int gpt_create_disklabel(struct fdisk_context *cxt)
fdisk_info(cxt, _("Created a new GPT disklabel (GUID: %s)."), str);
if (gpt_get_nentries(gpt) < GPT_NPARTITIONS)
fdisk_info(cxt, _("The maximal number of partitions is %d (default is %d)."),
fdisk_info(cxt, _("The maximal number of partitions is %zu (default is %zu)."),
gpt_get_nentries(gpt), GPT_NPARTITIONS);
done:
return rc;
@ -2758,7 +2759,7 @@ static int gpt_check_table_overlap(struct fdisk_context *cxt,
}
if (gpt_partition_end(e) > last_usable) {
fdisk_warnx(cxt, _("Partition #%zu out of range (maximal end is %"PRIu64" sectors)"),
i + 1, last_usable - 1ULL);
i + 1, last_usable - (uint64_t) 1);
rc = -EINVAL;
}
}
@ -2806,7 +2807,7 @@ int fdisk_gpt_set_npartitions(struct fdisk_context *cxt, uint32_t nents)
fdisk_warnx(cxt, _("The partition entry size is zero."));
else
fdisk_warnx(cxt, _("The number of the partition has to be smaller than %zu."),
UINT32_MAX / entry_size);
(size_t) UINT32_MAX / entry_size);
return rc;
}
@ -2858,7 +2859,7 @@ int fdisk_gpt_set_npartitions(struct fdisk_context *cxt, uint32_t nents)
/* update library info */
cxt->label->nparts_max = gpt_get_nentries(gpt);
fdisk_info(cxt, _("Partition table length changed from %"PRIu32" to %"PRIu64"."),
fdisk_info(cxt, _("Partition table length changed from %"PRIu32" to %"PRIu32"."),
old_nents, nents);
fdisk_label_set_changed(cxt->label, 1);
@ -3096,10 +3097,8 @@ static int gpt_reorder(struct fdisk_context *cxt)
(const void *) gpt_get_entry(gpt, i),
(const void *) gpt_get_entry(gpt, i + 1)) > 0;
if (!mess) {
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
if (!mess)
return 1;
}
qsort(gpt->ents, nparts, sizeof(struct gpt_entry),
gpt_entry_cmp_start);

View file

@ -583,12 +583,28 @@ int fdisk_toggle_partition_flag(struct fdisk_context *cxt,
*/
int fdisk_reorder_partitions(struct fdisk_context *cxt)
{
int rc;
if (!cxt || !cxt->label)
return -EINVAL;
if (!cxt->label->op->reorder)
return -ENOSYS;
return cxt->label->op->reorder(cxt);
rc = cxt->label->op->reorder(cxt);
switch (rc) {
case 0:
fdisk_info(cxt, _("Partitions order fixed."));
break;
case 1:
fdisk_info(cxt, _("Nothing to do. Ordering is correct already."));
break;
default:
fdisk_warnx(cxt, _("Failed to fix partitions order."));
break;
}
return rc;
}
/*

View file

@ -875,9 +875,12 @@ size_t fdisk_ask_menu_get_nitems(struct fdisk_ask *ask);
int fdisk_ask_print_get_errno(struct fdisk_ask *ask);
const char *fdisk_ask_print_get_mesg(struct fdisk_ask *ask);
int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...);
int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...);
int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...);
int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
/* utils.h */
extern char *fdisk_partname(const char *dev, size_t partno);

View file

@ -987,9 +987,10 @@ static int sgi_create_disklabel(struct fdisk_context *cxt)
/* otherwise print error and use truncated version */
fdisk_warnx(cxt,
_("BLKGETSIZE ioctl failed on %s. "
"Using geometry cylinder value of %llu. "
"Using geometry cylinder value of %ju. "
"This value may be truncated for devices "
"> 33.8 GB."), cxt->dev_path, cxt->geom.cylinders);
"> 33.8 GB."), cxt->dev_path,
(uintmax_t) cxt->geom.cylinders);
}
}

View file

@ -83,10 +83,10 @@ static void set_partition(struct fdisk_context *cxt, size_t i,
fdisk_label_get_parttype_from_code(cxt->label, sysid);
if (start / (cxt->geom.heads * cxt->geom.sectors) > UINT32_MAX)
fdisk_warnx(cxt, _("%#zu: start cylinder overflows Sun label limits"), i+1);
fdisk_warnx(cxt, _("#%zu: start cylinder overflows Sun label limits"), i+1);
if (stop - start > UINT32_MAX)
fdisk_warnx(cxt, _("%#zu: number of sectors overflow Sun label limits"), i+1);
fdisk_warnx(cxt, _("#%zu: number of sectors overflow Sun label limits"), i+1);
sunlabel->vtoc.infos[i].id = cpu_to_be16(sysid);
sunlabel->vtoc.infos[i].flags = cpu_to_be16(0);
@ -246,10 +246,10 @@ static int sun_create_disklabel(struct fdisk_context *cxt)
} else {
fdisk_warnx(cxt,
_("BLKGETSIZE ioctl failed on %s. "
"Using geometry cylinder value of %llu. "
"Using geometry cylinder value of %ju. "
"This value may be truncated for devices "
"> 33.8 GB."),
cxt->dev_path, cxt->geom.cylinders);
cxt->dev_path, (uintmax_t) cxt->geom.cylinders);
}
} else
ask_geom(cxt);

View file

@ -81,7 +81,7 @@ lib_mount = library(
link_with : [lib_common,
lib_blkid],
dependencies : [lib_selinux,
lib_cryptsetup,
get_option('cryptsetup-dlopen').enabled() ? lib_dl : lib_cryptsetup,
realtime_libs],
install : build_libmount)

View file

@ -220,9 +220,12 @@ PyMODINIT_FUNC initpylibmount(void)
if (!(pylibmount_debug_mask & PYMNT_DEBUG_INIT)) {
char *str = getenv("PYLIBMOUNT_DEBUG");
errno = 0;
pylibmount_debug_mask = 0;
if (str)
pylibmount_debug_mask = strtoul(str, NULL, 0);
if (errno)
pylibmount_debug_mask = 0;
pylibmount_debug_mask |= PYMNT_DEBUG_INIT;
}

View file

@ -2702,7 +2702,7 @@ int mnt_context_strerror(struct libmnt_context *cxt __attribute__((__unused__)),
}
int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, char *fmt, ...)
int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, const char *fmt, ...)
{
va_list va;

View file

@ -645,10 +645,7 @@ static int exec_helper(struct libmnt_context *cxt)
const char *args[14], *type;
int i = 0;
if (setgid(getgid()) < 0)
_exit(EXIT_FAILURE);
if (setuid(getuid()) < 0)
if (drop_permissions() != 0)
_exit(EXIT_FAILURE);
if (!mnt_context_switch_origin_ns(cxt))

View file

@ -453,10 +453,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
struct libmnt_ns *ns_old;
const char *type = mnt_fs_get_fstype(cxt->fs);
const char *optstr;
char *user_id = NULL;
size_t sz;
uid_t uid;
char uidstr[sizeof(stringify_value(ULONG_MAX))];
uid_t uid, entry_uid;
*errsv = 0;
@ -473,11 +470,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
optstr = mnt_fs_get_fs_options(cxt->fs);
if (!optstr)
return 0;
if (mnt_optstr_get_option(optstr, "user_id", &user_id, &sz) != 0)
return 0;
if (sz == 0 || user_id == NULL)
if (mnt_optstr_get_uid(optstr, "user_id", &entry_uid) != 0)
return 0;
/* get current user */
@ -494,8 +487,7 @@ static int is_fuse_usermount(struct libmnt_context *cxt, int *errsv)
return 0;
}
snprintf(uidstr, sizeof(uidstr), "%lu", (unsigned long) uid);
return strncmp(user_id, uidstr, sz) == 0;
return uid == entry_uid;
}
/*
@ -696,10 +688,7 @@ static int exec_helper(struct libmnt_context *cxt)
const char *args[12], *type;
int i = 0;
if (setgid(getgid()) < 0)
_exit(EXIT_FAILURE);
if (setuid(getuid()) < 0)
if (drop_permissions() != 0)
_exit(EXIT_FAILURE);
if (!mnt_context_switch_origin_ns(cxt))

View file

@ -61,8 +61,9 @@ static size_t crypt_hex_to_bytes(const char *hex, char **result)
for (i = 0; i < len; i++) {
memcpy(buf, &hex[i * 2], 2);
errno = 0;
bytes[i] = strtoul(buf, &endp, 16);
if (endp != &buf[2]) {
if (errno || endp != &buf[2]) {
free(bytes);
return -EINVAL;
}
@ -77,7 +78,8 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
const char *backing_file, *optstr;
char *val = NULL, *key = NULL, *root_hash_binary = NULL, *mapper_device = NULL,
*mapper_device_full = NULL, *backing_file_basename = NULL, *root_hash = NULL,
*hash_device = NULL, *root_hash_file = NULL, *fec_device = NULL, *hash_sig = NULL;
*hash_device = NULL, *root_hash_file = NULL, *fec_device = NULL, *hash_sig = NULL,
*root_hash_sig_file = NULL;
size_t len, hash_size, hash_sig_size = 0, keysize = 0;
struct crypt_params_verity crypt_params = {};
struct crypt_device *crypt_dev = NULL;
@ -217,7 +219,10 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
*/
if (rc == 0 && (cxt->user_mountflags & MNT_MS_ROOT_HASH_SIG) &&
mnt_optstr_get_option(optstr, "verity.roothashsig", &val, &len) == 0 && val) {
rc = ul_path_stat(NULL, &hash_sig_st, val);
root_hash_sig_file = strndup(val, len);
rc = root_hash_sig_file ? 0 : -ENOMEM;
if (rc == 0)
rc = ul_path_stat(NULL, &hash_sig_st, root_hash_sig_file);
if (rc == 0)
rc = !S_ISREG(hash_sig_st.st_mode) || !hash_sig_st.st_size ? -EINVAL : 0;
if (rc == 0) {
@ -226,7 +231,7 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
rc = hash_sig ? 0 : -ENOMEM;
}
if (rc == 0) {
rc = ul_path_read(NULL, hash_sig, hash_sig_size, val);
rc = ul_path_read(NULL, hash_sig, hash_sig_size, root_hash_sig_file);
rc = rc < (int)hash_sig_size ? -1 : 0;
}
}
@ -410,6 +415,7 @@ done:
free(hash_device);
free(root_hash);
free(root_hash_file);
free(root_hash_sig_file);
free(fec_device);
free(hash_sig);
free(key);

View file

@ -399,6 +399,7 @@ extern const struct libmnt_optmap *mnt_optmap_get_entry(
const struct libmnt_optmap **mapent);
/* optstr.c */
extern int mnt_optstr_get_uid(const char *optstr, const char *name, uid_t *uid);
extern int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end);
extern int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next);
extern int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next);
@ -454,7 +455,8 @@ extern int mnt_context_set_tabfilter(struct libmnt_context *cxt,
int (*fltr)(struct libmnt_fs *, void *),
void *data);
extern int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, char *fmt, ...);
extern int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
extern int mnt_context_get_mount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);
extern int mnt_context_get_umount_excode(struct libmnt_context *cxt, int mntrc, char *buf, size_t bufsz);

View file

@ -1076,6 +1076,48 @@ int mnt_optstr_fix_user(char **optstr)
return rc;
}
/*
* Converts value from @optstr addressed by @name to uid.
*
* Returns: 0 on success, 1 if not found, <0 on error
*/
int mnt_optstr_get_uid(const char *optstr, const char *name, uid_t *uid)
{
char *value = NULL;
size_t valsz = 0;
char buf[sizeof(stringify_value(UINT64_MAX))];
int rc;
uint64_t num;
assert(optstr);
assert(name);
assert(uid);
rc = mnt_optstr_get_option(optstr, name, &value, &valsz);
if (rc != 0)
goto fail;
if (valsz > sizeof(buf) - 1) {
rc = -ERANGE;
goto fail;
}
mem2strcpy(buf, value, valsz, sizeof(buf));
rc = ul_strtou64(buf, &num, 10);
if (rc != 0)
goto fail;
if (num > ULONG_MAX || (uid_t) num != num) {
rc = -ERANGE;
goto fail;
}
*uid = (uid_t) num;
return 0;
fail:
DBG(UTILS, ul_debug("failed to convert '%s'= to number [rc=%d]", name, rc));
return rc;
}
/**
* mnt_match_options:
* @optstr: options string

View file

@ -50,11 +50,12 @@ static const char *next_s32(const char *s, int *num, int *rc)
if (!s || !*s)
return s;
errno = 0;
*rc = -EINVAL;
*num = strtol(s, &end, 10);
if (end == NULL || s == end)
return s;
if (*end == ' ' || *end == '\t' || *end == '\0')
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
*rc = 0;
return end;
}
@ -66,11 +67,12 @@ static const char *next_u64(const char *s, uint64_t *num, int *rc)
if (!s || !*s)
return s;
errno = 0;
*rc = -EINVAL;
*num = (uint64_t) strtoumax(s, &end, 10);
if (end == NULL || s == end)
return s;
if (*end == ' ' || *end == '\t' || *end == '\0')
if (errno == 0 && (*end == ' ' || *end == '\t' || *end == '\0'))
*rc = 0;
return end;
}
@ -225,11 +227,6 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, const char *s)
goto fail;
}
/* remove "\040(deleted)" suffix */
p = (char *) endswith(fs->target, PATH_DELETED_SUFFIX);
if (p && *p)
*p = '\0';
s = skip_separator(s);
/* (6) vfs options (fs-independent) */

View file

@ -119,7 +119,7 @@ static int do_print_table(struct libscols_table *tb, int *is_empty)
if (scols_table_is_json(tb)) {
ul_jsonwrt_init(&tb->json, tb->out, 0);
ul_jsonwrt_root_open(&tb->json);
ul_jsonwrt_array_open(&tb->json, tb->name);
ul_jsonwrt_array_open(&tb->json, tb->name ? tb->name : "");
ul_jsonwrt_array_close(&tb->json);
ul_jsonwrt_root_close(&tb->json);
} else if (is_empty)
@ -134,7 +134,7 @@ static int do_print_table(struct libscols_table *tb, int *is_empty)
if (scols_table_is_json(tb)) {
ul_jsonwrt_root_open(&tb->json);
ul_jsonwrt_array_open(&tb->json, tb->name);
ul_jsonwrt_array_open(&tb->json, tb->name ? tb->name : "");
}
if (tb->format == SCOLS_FMT_HUMAN)

View file

@ -50,7 +50,7 @@ static void check_padding_debug(struct libscols_table *tb)
{
const char *str;
assert(libsmartcols_debug_mask); /* debug has to be enabled! */
assert(libsmartcols_debug_mask); /* debug has to be already initialized! */
str = getenv("LIBSMARTCOLS_DEBUG_PADDING");
if (!str || (strcmp(str, "on") != 0 && strcmp(str, "1") != 0))

View file

@ -37,6 +37,7 @@
#include <ctype.h>
#include <string.h>
#include "c.h"
#include "uuidP.h"
int uuid_parse(const char *in, uuid_t uu)
@ -70,16 +71,28 @@ int uuid_parse_range(const char *in_start, const char *in_end, uuid_t uu)
if (!isxdigit(*cp))
return -1;
}
errno = 0;
uuid.time_low = strtoul(in_start, NULL, 16);
uuid.time_mid = strtoul(in_start+9, NULL, 16);
uuid.time_hi_and_version = strtoul(in_start+14, NULL, 16);
uuid.clock_seq = strtoul(in_start+19, NULL, 16);
if (!errno)
uuid.time_mid = strtoul(in_start+9, NULL, 16);
if (!errno)
uuid.time_hi_and_version = strtoul(in_start+14, NULL, 16);
if (!errno)
uuid.clock_seq = strtoul(in_start+19, NULL, 16);
if (errno)
return -1;
cp = in_start+24;
buf[2] = 0;
for (i=0; i < 6; i++) {
buf[0] = *cp++;
buf[1] = *cp++;
errno = 0;
uuid.node[i] = strtoul(buf, NULL, 16);
if (errno)
return -1;
}
uuid_pack(&uuid, uu);

View file

@ -109,7 +109,7 @@ chfn_chsh_sources = \
login-utils/ch-common.c
chfn_chsh_cflags = $(SUID_CFLAGS) $(AM_CFLAGS)
chfn_chsh_ldflags = $(SUID_LDFLAGS) $(AM_LDFLAGS)
chfn_chsh_ldadd = libcommon.la $(READLINE_LIBS)
chfn_chsh_ldadd = libcommon.la
if CHFN_CHSH_PASSWORD
chfn_chsh_ldadd += -lpam

View file

@ -56,11 +56,6 @@
# include "auth.h"
#endif
#ifdef HAVE_LIBREADLINE
# define _FUNCTION_DEF
# include <readline/readline.h>
#endif
struct finfo {
char *full_name;
char *office;
@ -228,23 +223,18 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question,
{
int len;
char *buf;
#ifndef HAVE_LIBREADLINE
size_t dummy = 0;
#endif
if (!def_val)
def_val = "";
while (true) {
printf("%s [%s]:", question, def_val);
__fpurge(stdin);
#ifdef HAVE_LIBREADLINE
rl_bind_key('\t', rl_insert);
if ((buf = readline(" ")) == NULL)
#else
putchar(' ');
if (getline(&buf, &dummy, stdin) < 0)
#endif
errx(EXIT_FAILURE, _("Aborted."));
/* remove white spaces from string end */
ltrim_whitespace((unsigned char *) buf);
len = rtrim_whitespace((unsigned char *) buf);

View file

@ -58,11 +58,6 @@
# include "auth.h"
#endif
#ifdef HAVE_LIBREADLINE
# define _FUNCTION_DEF
# include <readline/readline.h>
#endif
struct sinfo {
char *username;
char *shell;
@ -121,33 +116,6 @@ static void print_shells(void)
endusershell();
}
#ifdef HAVE_LIBREADLINE
static char *shell_name_generator(const char *text, int state)
{
static size_t len;
char *s;
if (!state) {
setusershell();
len = strlen(text);
}
while ((s = getusershell())) {
if (strncmp(s, text, len) == 0)
return xstrdup(s);
}
return NULL;
}
static char **shell_name_completion(const char *text,
int start __attribute__((__unused__)),
int end __attribute__((__unused__)))
{
rl_attempted_completion_over = 1;
return rl_completion_matches(text, shell_name_generator);
}
#endif
/*
* parse_argv () --
* parse the command line arguments, and fill in "pinfo" with any
@ -198,21 +166,16 @@ static char *ask_new_shell(char *question, char *oldshell)
{
int len;
char *ans = NULL;
#ifdef HAVE_LIBREADLINE
rl_attempted_completion_function = shell_name_completion;
#else
size_t dummy = 0;
#endif
if (!oldshell)
oldshell = "";
printf("%s [%s]:", question, oldshell);
#ifdef HAVE_LIBREADLINE
if ((ans = readline(" ")) == NULL)
#else
putchar(' ');
if (getline(&ans, &dummy, stdin) < 0)
#endif
return NULL;
/* remove the newline at the end of ans. */
ltrim_whitespace((unsigned char *) ans);
len = rtrim_whitespace((unsigned char *) ans);

View file

@ -1012,7 +1012,6 @@ static void loginpam_acct(struct login_context *cxt)
loginpam_err(pamh, rc);
/*
* Grab the user information out of the password file for future use.
* First get the username that we are actually using, though.
*/
rc = loginpam_get_username(pamh, &cxt->username);
@ -1358,10 +1357,9 @@ static void initialize(int argc, char **argv, struct login_context *cxt)
#endif
}
#ifdef HAVE_CLOSE_RANGE
close_range(STDERR_FILENO + 1, ~0U);
#else
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
if (close_range(STDERR_FILENO + 1, ~0U, 0) < 0)
#endif
ul_close_all_fds(STDERR_FILENO + 1, ~0U);
}
int main(int argc, char **argv)

View file

@ -474,55 +474,52 @@ static struct utmpx *get_last_btmp(struct lslogins_control *ctl, const char *use
}
static int read_utmp(char const *file, size_t *nents, struct utmpx **res)
static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **records)
{
size_t n_read = 0, n_alloc = 0;
struct utmpx *utmp = NULL, *u;
size_t i, imax = 0;
struct utmpx *ary = NULL;
struct stat st;
if (utmpxname(file) < 0)
*nrecords = 0;
*records = NULL;
if (utmpxname(path) < 0)
return -errno;
setutxent();
errno = 0;
/* optimize allocation according to file size, the realloc() below is
* just fallback only */
if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) {
imax = st.st_size / sizeof(struct utmpx);
ary = xmalloc(imax * sizeof(struct utmpx));
}
while ((u = getutxent()) != NULL) {
if (n_read == n_alloc) {
n_alloc += 32;
utmp = xrealloc(utmp, n_alloc * sizeof (struct utmpx));
for (i = 0; ; i++) {
struct utmpx *u;
errno = 0;
u = getutxent();
if (!u) {
if (errno)
goto fail;
break;
}
utmp[n_read++] = *u;
if (i == imax)
ary = xrealloc(ary, (imax *= 2) * sizeof(struct utmpx));
ary[i] = *u;
}
if (!u && errno) {
free(utmp);
*nrecords = i;
*records = ary;
endutxent();
return 0;
fail:
endutxent();
free(ary);
if (errno) {
if (errno != EACCES)
err(EXIT_FAILURE, "%s", path);
return -errno;
}
endutxent();
*nents = n_read;
*res = utmp;
return 0;
}
static int parse_wtmp(struct lslogins_control *ctl, char *path)
{
int rc = 0;
rc = read_utmp(path, &ctl->wtmp_size, &ctl->wtmp);
if (rc < 0 && errno != EACCES)
err(EXIT_FAILURE, "%s", path);
return rc;
}
static int parse_btmp(struct lslogins_control *ctl, char *path)
{
int rc = 0;
rc = read_utmp(path, &ctl->btmp_size, &ctl->btmp);
if (rc < 0 && errno != EACCES)
err(EXIT_FAILURE, "%s", path);
return rc;
return -EINVAL;
}
static void get_lastlog(struct lslogins_control *ctl, uid_t uid, void *dst, int what)
@ -565,6 +562,9 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
*list = xcalloc(1, ngroups * sizeof(gid_t));
fprintf(stderr, "KZAK>>> alloc '%p' for %s\n", *list, pwd->pw_name);
/* now for the actual list of GIDs */
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
return -1;
@ -757,7 +757,8 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
break;
case COL_SGROUPS:
case COL_SGIDS:
if (get_sgroups(&user->sgroups, &user->nsgroups, pwd))
if (!user->nsgroups &&
get_sgroups(&user->sgroups, &user->nsgroups, pwd) < 0)
err(EXIT_FAILURE, _("failed to get supplementary groups"));
break;
case COL_HOME:
@ -908,11 +909,14 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
static int str_to_uint(char *s, unsigned int *ul)
{
char *end;
char *end = NULL;
if (!s || !*s)
return -1;
errno = 0;
*ul = strtoul(s, &end, 0);
if (!*end)
if (errno == 0 && end && !*end)
return 0;
return 1;
}
@ -1048,7 +1052,6 @@ static int create_usertree(struct lslogins_control *ctl)
}
if (rc || !user)
continue;
tsearch(user, &ctl->usertree, cmp_uid);
}
} else {
@ -1231,14 +1234,28 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
}
}
#ifdef HAVE_LIBSYSTEMD
static char *get_journal_data(sd_journal *j, const char *name)
{
const char *data = NULL, *p;
size_t len = 0;
if (sd_journal_get_data(j, name, (const void **) &data, &len) < 0
|| !data || !len)
return NULL;
/* Get rid of journal entry field identifiers */
p = strnchr(data, len, '=');
if (!p || !*(p + 1))
return NULL;
p++;
return xstrndup(p, len - (p - data));
}
static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode)
{
sd_journal *j;
char *match, *timestamp;
uint64_t x;
time_t t;
const char *identifier, *pid, *message;
size_t identifier_len, pid_len, message_len;
char *match;
if (journal_path)
sd_journal_open_directory(&j, journal_path, 0);
@ -1252,30 +1269,27 @@ static void print_journal_tail(const char *journal_path, uid_t uid, size_t len,
sd_journal_previous_skip(j, len);
do {
if (0 > sd_journal_get_data(j, "SYSLOG_IDENTIFIER",
(const void **) &identifier, &identifier_len))
goto done;
if (0 > sd_journal_get_data(j, "_PID",
(const void **) &pid, &pid_len))
goto done;
if (0 > sd_journal_get_data(j, "MESSAGE",
(const void **) &message, &message_len))
goto done;
char *id, *pid, *msg, *ts;
uint64_t x;
time_t t;
sd_journal_get_realtime_usec(j, &x);
t = x / 1000000;
timestamp = make_time(time_mode, t);
/* Get rid of journal entry field identifiers */
identifier = strchr(identifier, '=') + 1;
pid = strchr(pid, '=') + 1;
message = strchr(message, '=') + 1;
ts = make_time(time_mode, t);
fprintf(stdout, "%s %s[%s]: %s\n", timestamp, identifier, pid,
message);
free(timestamp);
id = get_journal_data(j, "SYSLOG_IDENTIFIER");
pid = get_journal_data(j, "_PID");
msg = get_journal_data(j, "MESSAGE");
if (ts && id && pid && msg)
fprintf(stdout, "%s %s[%s]: %s\n", ts, id, pid, msg);
free(ts);
free(id);
free(pid);
free(msg);
} while (sd_journal_next(j));
done:
free(match);
sd_journal_flush_matches(j);
sd_journal_close(j);
@ -1333,6 +1347,7 @@ static void free_user(void *f)
struct lslogins_user *u = f;
free(u->login);
free(u->group);
free(u->nprocs);
free(u->gecos);
free(u->sgroups);
free(u->pwd_ctime);
@ -1644,11 +1659,11 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
if (require_wtmp()) {
parse_wtmp(ctl, path_wtmp);
parse_utmpx(path_wtmp, &ctl->wtmp_size, &ctl->wtmp);
ctl->lastlogin_fd = open(path_lastlog, O_RDONLY, 0);
}
if (require_btmp())
parse_btmp(ctl, path_btmp);
parse_utmpx(path_btmp, &ctl->btmp_size, &ctl->btmp);
if (logins || groups)
get_ulist(ctl, logins, groups);

View file

@ -123,7 +123,7 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
{
char **look;
int notfound = 1;
char *pwd, *xpwd;
char *pwd, *xpwd, *spwd;
if (getuid() == 0)
/* root may do anything */
@ -144,8 +144,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
* as in /etc/passwd */
/* check /etc/gshadow */
if (!(pwd = get_gshadow_pwd(ge->gr_name)))
pwd = ge->gr_passwd;
spwd = get_gshadow_pwd(ge->gr_name);
pwd = spwd ? spwd : ge->gr_passwd;
if (pwd && *pwd && (xpwd = xgetpass(stdin, _("Password: ")))) {
char *cbuf = crypt(xpwd, pwd);
@ -162,6 +162,8 @@ static int allow_setgid(const struct passwd *pe, const struct group *ge)
return TRUE;
}
free(spwd);
/* default to denial */
return FALSE;
}

View file

@ -80,6 +80,8 @@ static struct sigaction saved_sigchld;
static volatile sig_atomic_t alarm_rised;
static volatile sig_atomic_t sigchild;
#define SULOGIN_PASSWORD_BUFSIZ 128
#ifndef IUCLC
# define IUCLC 0
#endif
@ -602,13 +604,13 @@ static void setup(struct console *con)
* Ask for the password. Note that there is no default timeout as we normally
* skip this during boot.
*/
static const char *getpasswd(struct console *con)
static char *getpasswd(struct console *con)
{
struct sigaction sa;
struct termios tty;
static char pass[128], *ptr;
static char pass[SULOGIN_PASSWORD_BUFSIZ], *ptr;
struct chardata *cp;
const char *ret = pass;
char *ret = NULL;
unsigned char tc;
char c, ascval;
int eightbit;
@ -619,6 +621,7 @@ static const char *getpasswd(struct console *con)
cp = &con->cp;
tty = con->tio;
ret = pass;
tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ISIG);
tc = (tcsetattr(fd, TCSAFLUSH, &tty) == 0);
@ -711,6 +714,10 @@ quit:
tcfinal(con);
printf("\r\n");
out:
#ifdef HAVE_EXPLICIT_BZERO
if (ret == NULL)
explicit_bzero(pass, sizeof(pass));
#endif
return ret;
}
@ -977,7 +984,7 @@ int main(int argc, char **argv)
setup(con);
while (1) {
const char *passwd = pwd->pw_passwd;
const char *answer;
char *answer;
int doshell = 0;
int deny = !opt_e && locked_account_password(pwd->pw_passwd);
@ -985,8 +992,12 @@ int main(int argc, char **argv)
if ((answer = getpasswd(con)) == NULL)
break;
if (deny)
if (deny) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(answer, SULOGIN_PASSWORD_BUFSIZ);
#endif
exit(EXIT_FAILURE);
}
/* no password or locked account */
if (!passwd[0] || locked_account_password(passwd))
@ -999,7 +1010,9 @@ int main(int argc, char **argv)
else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
doshell++;
}
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(answer, SULOGIN_PASSWORD_BUFSIZ);
#endif
if (doshell) {
/* sushell() unmask signals */
sushell(pwd);

View file

@ -74,8 +74,16 @@ static time_t strtotime(const char *s_time)
static suseconds_t strtousec(const char *s_time)
{
const char *s = strchr(s_time, ',');
if (s)
return (suseconds_t) atoi(s + 1);
if (s && *++s) {
suseconds_t us;
char *end = NULL;
errno = 0;
us = strtol(s, &end, 10);
if (errno == 0 && end && end > s)
return us;
}
return 0;
}
@ -266,7 +274,7 @@ static int gettok(char *line, char *dest, int size, int eatspace)
static void undump(FILE *in, FILE *out)
{
struct utmpx ut;
char s_addr[INET6_ADDRSTRLEN + 1], s_time[29], *linestart, *line;
char s_addr[INET6_ADDRSTRLEN + 1], s_time[29] = {}, *linestart, *line;
linestart = xmalloc(1024 * sizeof(*linestart));
s_time[28] = 0;

View file

@ -67,28 +67,21 @@ AC_DEFUN([UL_SET_ARCH], [
])
dnl UL_SET_FLAGS(CFLAGS, CPPFLAGS, LDFLAGS)
dnl UL_SET_LIBS(LIBS)
dnl
dnl Sets new global CFLAGS, CPPFLAGS and LDFLAG, the original
dnl setting could be restored by UL_RESTORE_FLAGS()
dnl Sets new global LIBS, the original setting could be restored by UL_RESTORE_LIBS()
dnl
AC_DEFUN([UL_SET_FLAGS], [
old_CFLAGS="$CFLAGS"
old_CPPFLAGS="$CPPFLAGS"
old_LDFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS $1"
CPPFLAGS="$CPPFLAGS $2"
LDFLAGS="$LDFLAGS $3"
AC_DEFUN([UL_SET_LIBS], [
old_LIBS="$LIBS"
LIBS="$LIBS $1"
])
dnl UL_RESTORE_FLAGS()
dnl UL_RESTORE_LIBS()
dnl
dnl Restores CFLAGS, CPPFLAGS and LDFLAG previously saved by UL_SET_FLAGS()
dnl Restores LIBS previously saved by UL_SET_LIBS()
dnl
AC_DEFUN([UL_RESTORE_FLAGS], [
CFLAGS="$old_CFLAGS"
CPPFLAGS="$old_CPPFLAGS"
LDFLAGS="$old_LDFLAGS"
AC_DEFUN([UL_RESTORE_LIBS], [
LIBS="$old_LIBS"
])

View file

@ -264,11 +264,6 @@ lib_readline_static = dependency(
static : true,
required : need_static_libs ? get_option('readline') : disabler())
lib_pcre = dependency(
'libpcre2-posix',
required : get_option('libpcre2-posix'))
conf.set('HAVE_PCRE2_POSIX', lib_pcre.found() ? 1 : false)
lib_user = dependency(
'libuser',
version : '>= 0.58',
@ -312,15 +307,24 @@ lib_cryptsetup = dependency(
required : get_option('cryptsetup'))
conf.set('HAVE_CRYPTSETUP', lib_cryptsetup.found() ? 1 : false)
lib_cryptsetup_dl = dependency(
'dl',
required : get_option('cryptsetup-dlopen'))
conf.set('CRYPTSETUP_VIA_DLOPEN', lib_cryptsetup_dl.found() ? 1 : false)
if not get_option('cryptsetup').disabled() and get_option('cryptsetup-dlopen').enabled()
lib_dl = cc.find_library(
'libdl',
required : true)
conf.set('CRYPTSETUP_VIA_DLOPEN', 1)
summary('cryptsetup support (dlopen)',
'enabled',
section : 'components')
else
summary('cryptsetup support',
lib_cryptsetup.found() ? 'enabled' : 'disabled',
section : 'components')
endif
have = cc.has_function(
'crypt_activate_by_signed_key',
dependencies : lib_cryptsetup)
conf.set('HAVE_CRYPTSETUP', have ? 1 : false)
conf.set('HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY', have ? 1 : false)
lib_cap_ng = dependency(
'libcap-ng')
@ -2532,7 +2536,6 @@ exe = executable(
hardlink_sources,
include_directories : includes,
link_with : [lib_common],
dependencies : [lib_pcre],
install_dir : usrbin_exec_dir,
install : true)
if not is_disabler(exe)

View file

@ -28,7 +28,7 @@ usrbin_exec_PROGRAMS += logger
MANPAGES += misc-utils/logger.1
dist_noinst_DATA += misc-utils/logger.1.adoc
logger_SOURCES = misc-utils/logger.c lib/strutils.c lib/strv.c
logger_LDADD = $(LDADD)
logger_LDADD = $(LDADD) libcommon.la
logger_CFLAGS = $(AM_CFLAGS)
if HAVE_SYSTEMD
logger_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS) $(SYSTEMD_JOURNAL_LIBS)
@ -244,8 +244,4 @@ dist_noinst_DATA += misc-utils/hardlink.1.adoc
hardlink_SOURCES = misc-utils/hardlink.c lib/monotonic.c
hardlink_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS)
hardlink_CFLAGS = $(AM_CFLAGS)
if HAVE_PCRE2_POSIX
hardlink_LDADD += $(PCRE2_POSIX_LIBS)
hardlink_CFLAGS += $(PCRE2_POSIX_CFLAGS)
endif
endif

View file

@ -17,7 +17,7 @@ blkid - locate/print block device attributes
*blkid* *--label* _label_ | *--uuid* _uuid_
*blkid* [*--no-encoding* *--garbage-collect* *--list-one* *--cache-file* _file_] [*--output* _format_][*--match-tag* _tag_] [*--match-token* _NAME=value_] [_device_...]
*blkid* [*--no-encoding* *--garbage-collect* *--list-one* *--cache-file* _file_] [*--output* _format_] [*--match-tag* _tag_] [*--match-token* _NAME=value_] [_device_...]
*blkid* *--probe* [*--offset* _offset_] [*--output* _format_] [*--size* _size_] [*--match-tag* _tag_] [*--match-types* _list_] [*--usages* _list_] [*--no-part-details*] _device_...

View file

@ -32,7 +32,8 @@ struct verify_context {
no_fsck : 1;
};
static void verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap)
static void __attribute__ ((__format__ (__printf__, 3, 0)))
verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap)
{
if (!vfy->target_printed) {
fprintf(stdout, "%s\n", mnt_fs_get_target(vfy->fs));
@ -44,7 +45,8 @@ static void verify_mesg(struct verify_context *vfy, char type, const char *fmt,
fputc('\n', stdout);
}
static int verify_warn(struct verify_context *vfy, const char *fmt, ...)
static int __attribute__ ((__format__ (__printf__, 2, 3)))
verify_warn(struct verify_context *vfy, const char *fmt, ...)
{
va_list ap;
vfy->nwarnings++;
@ -54,7 +56,8 @@ static int verify_warn(struct verify_context *vfy, const char *fmt, ...)
return 0;
}
static int verify_err(struct verify_context *vfy, const char *fmt, ...)
static int __attribute__ ((__format__ (__printf__, 2, 3)))
verify_err(struct verify_context *vfy, const char *fmt, ...)
{
va_list ap;
vfy->nerrors++;
@ -64,7 +67,8 @@ static int verify_err(struct verify_context *vfy, const char *fmt, ...)
return 0;
}
static int verify_ok(struct verify_context *vfy __attribute__((unused)),
static int __attribute__ ((__format__ (__printf__, 2, 3)))
verify_ok(struct verify_context *vfy __attribute__((unused)),
const char *fmt, ...)
{
va_list ap;
@ -160,7 +164,10 @@ static int verify_target(struct verify_context *vfy)
static char *verify_tag(struct verify_context *vfy, const char *name,
const char *value)
{
char *src = mnt_resolve_tag(name, value, cache);
char *src = NULL;
if (!(flags & FL_NOCACHE))
src = mnt_resolve_tag(name, value, cache);
if (!src) {
if (mnt_fs_get_option(vfy->fs, "noauto", NULL, NULL) == 1)
@ -336,6 +343,18 @@ static int read_proc_filesystems(struct verify_context *vfy)
return rc;
}
static void free_proc_filesystems(struct verify_context *vfy)
{
size_t n;
if (!vfy->fs_ary)
return;
for (n = 0; n < vfy->fs_num; n++ )
free(vfy->fs_ary[n]);
free(vfy->fs_ary);
}
static int read_kernel_filesystems(struct verify_context *vfy)
{
int rc = 0;
@ -388,14 +407,18 @@ static int read_kernel_filesystems(struct verify_context *vfy)
static int verify_fstype(struct verify_context *vfy)
{
const char *src = mnt_resolve_spec(mnt_fs_get_source(vfy->fs), cache);
const char *type, *realtype;
char *src = mnt_resolve_spec(mnt_fs_get_source(vfy->fs), cache);
char *realtype = NULL;
const char *type;
int ambi = 0, isauto = 0, isswap = 0;
if (!src)
return 0;
if (mnt_fs_is_pseudofs(vfy->fs) || mnt_fs_is_netfs(vfy->fs))
return verify_ok(vfy, _("do not check %s FS type (pseudo/net)"), src);
if (mnt_fs_is_pseudofs(vfy->fs) || mnt_fs_is_netfs(vfy->fs)) {
verify_ok(vfy, _("do not check %s FS type (pseudo/net)"), src);
goto done;
}
type = mnt_fs_get_fstype(vfy->fs);
@ -404,8 +427,10 @@ static int verify_fstype(struct verify_context *vfy)
if (none
&& mnt_fs_get_option(vfy->fs, "bind", NULL, NULL) == 1
&& mnt_fs_get_option(vfy->fs, "move", NULL, NULL) == 1)
return verify_warn(vfy, _("\"none\" FS type is recommended for bind or move oprations only"));
&& mnt_fs_get_option(vfy->fs, "move", NULL, NULL) == 1) {
verify_warn(vfy, _("\"none\" FS type is recommended for bind or move oprations only"));
goto done;
}
if (strcmp(type, "auto") == 0)
isauto = 1;
@ -421,23 +446,33 @@ static int verify_fstype(struct verify_context *vfy)
if (!realtype) {
if (isauto)
return verify_err(vfy, _("cannot detect on-disk filesystem type"));
return verify_warn(vfy, _("cannot detect on-disk filesystem type"));
verify_err(vfy, _("cannot detect on-disk filesystem type"));
else
verify_warn(vfy, _("cannot detect on-disk filesystem type"));
goto done;
}
if (realtype) {
isswap = strcmp(realtype, "swap") == 0;
vfy->no_fsck = strcmp(realtype, "xfs") == 0;
if (type && !isauto && strcmp(type, realtype) != 0)
return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
if (!isswap && !is_supported_filesystem(vfy, realtype))
return verify_err(vfy, _("on-disk %s seems unsupported by the current kernel"), realtype);
if (type && !isauto && strcmp(type, realtype) != 0) {
verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
goto done;
}
if (!isswap && !is_supported_filesystem(vfy, realtype)) {
verify_err(vfy, _("on-disk %s seems unsupported by the current kernel"), realtype);
goto done;
}
verify_ok(vfy, _("FS type is %s"), realtype);
}
done:
if (!cache) {
free(src);
free(realtype);
}
return 0;
}
@ -523,5 +558,8 @@ done:
} else
fprintf(stdout, _("Success, no errors or warnings detected\n"));
free_proc_filesystems(&vfy);
return rc != 0 ? rc : vfy.nerrors + parse_nerrors;
}

View file

@ -187,7 +187,7 @@ LIBSMARTCOLS_DEBUG=all::
enables libsmartcols debug output
LIBSMARTCOLS_DEBUG_PADDING=on::
use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
use visible padding characters.
== EXAMPLES

View file

@ -129,8 +129,8 @@ In compatibility mode, leading '*-*' and '*{plus}*' characters in the short opti
== EXAMPLES
// TRANSLATORS: Don't translate _{docdir}_.
Example scripts for (ba)sh and (t)csh are provided with the *getopt*(1) distribution, and are installed in _{docdir}_ directory.
// TRANSLATORS: Don't translate _{package-docdir}_.
Example scripts for (ba)sh and (t)csh are provided with the *getopt*(1) distribution, and are installed in _{package-docdir}_ directory.
== ENVIRONMENT

View file

@ -44,14 +44,7 @@
#include "monotonic.h"
#include "optutils.h"
/* Use libpcre2posix if it's available */
#ifdef HAVE_PCRE2_POSIX
# include <pcre2posix.h>
# undef REG_NOSUB
# define REG_NOSUB 0 /* we do want backreferences in PCRE mode */
#else
# include <regex.h> /* regcomp(), regsearch() */
#endif
#include <regex.h> /* regcomp(), regsearch() */
#ifdef HAVE_SYS_XATTR_H
# include <sys/xattr.h> /* listxattr, getxattr */

View file

@ -176,10 +176,11 @@ static int arg_to_signum(char *arg, int maskbit)
char *ep;
if (isdigit(*arg)) {
errno = 0;
numsig = strtol(arg, &ep, 10);
if (NSIG <= numsig && maskbit && (numsig & 128) != 0)
numsig -= 128;
if (*ep != 0 || numsig < 0 || NSIG <= numsig)
if (errno || *ep != 0 || numsig < 0 || NSIG <= numsig)
return -1;
return numsig;
}

View file

@ -63,6 +63,7 @@
#include "xalloc.h"
#include "strv.h"
#include "list.h"
#include "pwdutils.h"
#define SYSLOG_NAMES
#include <syslog.h>
@ -393,16 +394,6 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
}
#endif
static char const *xgetlogin(void)
{
char const *cp;
struct passwd *pw;
if (!(cp = getlogin()) || !*cp)
cp = (pw = getpwuid(geteuid()))? pw->pw_name : "<someone>";
return cp;
}
/* this creates a timestamp based on current time according to the
* fine rules of RFC3164, most importantly it ensures in a portable
* way that the month day is correctly written (with a SP instead
@ -619,7 +610,8 @@ static void add_structured_data_param(struct list_head *ls, const char *param)
err_oom();
}
static void add_structured_data_paramf(struct list_head *ls, const char *fmt, ...)
static void __attribute__ ((__format__ (__printf__, 2, 3)))
add_structured_data_paramf(struct list_head *ls, const char *fmt, ...)
{
struct structured_data *sd;
va_list ap;
@ -926,6 +918,8 @@ static void logger_open(struct logger_ctl *ctl)
syslog_local_header;
if (!ctl->tag)
ctl->tag = xgetlogin();
if (!ctl->tag)
ctl->tag = "<someone>";
generate_syslog_header(ctl);
}

View file

@ -10,6 +10,7 @@
#include "mangle.h"
#include "path.h"
#include "nls.h"
#include "strutils.h"
#include "lsblk.h"
@ -111,11 +112,19 @@ static struct lsblk_devprop *get_properties_by_udev(struct lsblk_device *ld)
data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT");
if(!data)
data = udev_device_get_property_value(dev, "ID_SERIAL");
if (data)
if (data) {
prop->serial = xstrdup(data);
normalize_whitespace((unsigned char *) prop->serial);
}
if ((data = udev_device_get_property_value(dev, "ID_MODEL")))
if ((data = udev_device_get_property_value(dev, "ID_MODEL_ENC"))) {
prop->model = xstrdup(data);
unhexmangle_string(prop->model);
normalize_whitespace((unsigned char *) prop->model);
} else if ((data = udev_device_get_property_value(dev, "ID_MODEL"))) {
prop->model = xstrdup(data);
normalize_whitespace((unsigned char *) prop->model);
}
udev_device_unref(dev);
DBG(DEV, ul_debugobj(ld, "%s: found udev properties", ld->name));

View file

@ -45,7 +45,7 @@ Use _column_ as a de-duplication key to de-duplicate output tree. If the key is
+
The usual use case is to de-duplicate output on system multi-path devices, for example by *-E WWN*.
-e*, *--exclude* _list_::
*-e*, *--exclude* _list_::
Exclude the devices specified by the comma-separated _list_ of major device numbers. Note that RAM disks (major=1) are excluded by default if *--all* is not specified. The filter is applied to the top-level devices only. This may be confusing for *--list* output format where hierarchy of the devices is not obvious.
*-f*, *--fs*::
@ -150,7 +150,7 @@ LIBSMARTCOLS_DEBUG=all::
enables *libsmartcols* debug output.
LIBSMARTCOLS_DEBUG_PADDING=on::
use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
use visible padding characters.
== NOTES

View file

@ -192,8 +192,10 @@ static char *get_filename_sz(ino_t inode, pid_t lock_pid, size_t *size)
!strcmp(dp->d_name, ".."))
continue;
errno = 0;
/* care only for numerical descriptors */
if (!strtol(dp->d_name, (char **) NULL, 10))
if (!strtol(dp->d_name, (char **) NULL, 10) || errno)
continue;
if (!fstatat(fd, dp->d_name, &sb, 0)

View file

@ -99,7 +99,7 @@ readlink_to_namei(struct namei *nm, const char *path)
}
nm->abslink = xmalloc(sz + 1);
if (*sym != '/' && isrel) {
if (isrel) {
/* create the absolute path from the relative symlink */
memcpy(nm->abslink, path, nm->relstart);
*(nm->abslink + nm->relstart) = '/';

View file

@ -105,6 +105,7 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
{
char *newname = NULL, *target = NULL;
int ret = 1;
ssize_t ssz;
struct stat sb;
if ( faccessat(AT_FDCWD, s, F_OK, AT_SYMLINK_NOFOLLOW) != 0 &&
@ -125,12 +126,15 @@ static int do_symlink(char *from, char *to, char *s, int verbose, int noact,
return 2;
}
target = xmalloc(sb.st_size + 1);
if (readlink(s, target, sb.st_size + 1) < 0) {
ssz = readlink(s, target, sb.st_size + 1);
if (ssz < 0) {
warn(_("%s: readlink failed"), s);
free(target);
return 2;
}
target[sb.st_size] = '\0';
target[ssz] = '\0';
if (string_replace(from, to, target, target, &newname) != 0)
ret = 0;

View file

@ -334,7 +334,10 @@ static struct wipe_desc *get_desc_for_probe(struct wipe_control *ctl,
} else
return NULL;
errno = 0;
*offset = strtoll(off, NULL, 10);
if (errno)
return NULL;
/* Filter out by -t <type> */
if (ctl->type_pattern && !match_fstype(type, ctl->type_pattern))

3261
po/ca.po

File diff suppressed because it is too large Load diff

3231
po/cs.po

File diff suppressed because it is too large Load diff

3221
po/da.po

File diff suppressed because it is too large Load diff

3231
po/de.po

File diff suppressed because it is too large Load diff

3945
po/es.po

File diff suppressed because it is too large Load diff

3267
po/et.po

File diff suppressed because it is too large Load diff

3260
po/eu.po

File diff suppressed because it is too large Load diff

3310
po/fi.po

File diff suppressed because it is too large Load diff

3231
po/fr.po

File diff suppressed because it is too large Load diff

3272
po/gl.po

File diff suppressed because it is too large Load diff

3231
po/hr.po

File diff suppressed because it is too large Load diff

3264
po/hu.po

File diff suppressed because it is too large Load diff

3329
po/id.po

File diff suppressed because it is too large Load diff

3318
po/it.po

File diff suppressed because it is too large Load diff

3245
po/ja.po

File diff suppressed because it is too large Load diff

3236
po/nl.po

File diff suppressed because it is too large Load diff

3233
po/pl.po

File diff suppressed because it is too large Load diff

3231
po/pt.po

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more