Karel Zak [Tue, 25 Feb 2020 14:31:23 +0000 (15:31 +0100)]
lsblk: fix -P regression from v2.34
Since v2.34 --list prints devices only once to make the output
user-readable. Unfortunately, it's regression for scripts/applications
where we need to parse lsblk output. So, let's make --pairs and --raw
backwardly compatible with versions before 2.34 and print all hierarchy.
Addresses: https://github.com/ibm-s390-tools/s390-tools/issues/80 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 25 Feb 2020 11:06:06 +0000 (12:06 +0100)]
libblkid: fix compiler warning [-Wsign-compare]
libblkid/src/superblocks/exfat.c: In function ‘probe_exfat’:
./include/c.h:133:17: warning: comparison of distinct pointer types lacks a cast
libblkid/src/superblocks/exfat.c:129:5: note: in expansion of macro ‘min’
./include/c.h:134:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
______________________________________________________
GNU C Library NEWS -- history of user-visible changes.
Version 2.31
Deprecated and removed features, and other changes affecting compatibility:
* The settimeofday function can still be used to set a system-wide time
zone when the operating system supports it. This is because the Linux
kernel reused the API, on some architectures, to describe a system-wide
time-zone-like offset between the software clock maintained by the kernel,
and the "RTC" clock that keeps time when the system is shut down.
However, to reduce the odds of this offset being set by accident,
settimeofday can no longer be used to set the time and the offset
simultaneously. If both of its two arguments are non-null, the call
will fail (setting errno to EINVAL).
Callers attempting to set this offset should also be prepared for the call
to fail and set errno to ENOSYS; this already happens on the Hurd and on
some Linux architectures. The Linux kernel maintainers are discussing a
more principled replacement for the reused API. After a replacement
becomes available, we will change settimeofday to fail with ENOSYS on all
platforms when its 'tzp' argument is not a null pointer.
settimeofday itself is obsolescent according to POSIX. Programs that set
the system time should use clock_settime and/or the adjtime family of
functions instead. We may cease to make settimeofday available to newly
linked binaries after there is a replacement for Linux's time-zone-like
offset API.
______________________________________________________
hwclock(8) had one settimeofday(2) call where both args were set for
--hctosys when the RTC was ticking UTC. This allowed setting the system
time, timezone, and locking the warp_clock function with a single call.
That operation now takes 3 calls of settimeofday(2).
Although this common operation now takes three calls, the overall logic
for the set_system_clock() function was simplified.
Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: J William Piggott <elseifthen@gmx.com>
Sami Kerola [Thu, 20 Feb 2020 20:08:00 +0000 (20:08 +0000)]
various: fix more lgtm scan warnings
The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions. The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero. And remove couple FIXME's that are
old and unlikely ever to get fixed.
Karel Zak [Tue, 18 Feb 2020 13:02:41 +0000 (14:02 +0100)]
Merge branch 'various-fixes' of https://github.com/kerolasa/util-linux
* 'various-fixes' of https://github.com/kerolasa/util-linux:
kill: include sys/types.h before checking SYS_pidfd_send_signal
libfdisk: fix pointer wraparound warning
hwclock: update yacc file
script: fix minor warning
getopt: use examples installation directory in man page
fstrim: randomize timer start time across 100 minutes
various: use threadsafe versions of time functions [lgtm scan]
write: fix potential string overflow
Karel Zak [Mon, 17 Feb 2020 12:13:11 +0000 (13:13 +0100)]
lscpu: fix SIGSEGV on archs without drawers & books
The drawers and books are optional and not supported on all
architectures and in this case drawers/books relevant arrays are not
allocated, so don't access it although user wants it
(e.g. "lscpu -p -y --output-all").
This patch also cleans up arrays allocation to make it more readable
and robust against edit mistakes.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1801760 Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sat, 15 Feb 2020 21:12:50 +0000 (21:12 +0000)]
kill: include sys/types.h before checking SYS_pidfd_send_signal
Including sys/types.h must happen before SYS_pidfd_send_signal is checked,
because that header defines variable in normal conditions. When sys/types.h
does not have SYS_pidfd_send_signal then fallback is defined in config.h
that is included by default, and has therefore worked fine before and after
this change.
Sami Kerola [Sun, 9 Feb 2020 22:14:56 +0000 (22:14 +0000)]
various: use threadsafe versions of time functions [lgtm scan]
Deprecating calls to not-thread safe asctime(), ctime(), and localtime()
calls is pretty close to pointless change. Lets do it to reduce lgtm scan
warnings with justification it's nicer to use static analysis tools when
they have very few positives.
Karel Zak [Mon, 10 Feb 2020 12:51:23 +0000 (13:51 +0100)]
Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
tests: Add UDF hdd image with emoji label created by mkudffs 2.2
libblkid: Fix UTF-16 support in function blkid_encode_to_utf8()
Pali Rohár [Sun, 9 Feb 2020 12:04:39 +0000 (13:04 +0100)]
tests: Add UDF hdd image with emoji label created by mkudffs 2.2
mkudffs 2.2 can create UDF filesystem which label contains Unicode code
points above U+FFFF which cannot be represented by UCS-2 encoding and
therefore UTF-16 needs to be used (via surrogate pairs). Unicode code
points above U+FFFF are encoded in UTF-8 by four bytes and some example is
emoji "😀".
This is test case to check that libblkid correctly supports UTF-16
decoding. It was created by mkudffs 2.2:
Pali Rohár [Sun, 9 Feb 2020 12:04:34 +0000 (13:04 +0100)]
libblkid: Fix UTF-16 support in function blkid_encode_to_utf8()
Function blkid_encode_to_utf8() says that is supports BLKID_ENC_UTF16LE and
BLKID_ENC_UTF16BE encodings, but it is not truth and supports only UCS-2
(and not full UTF-16).
As all places where BLKID_ENC_UTF16LE and BLKID_ENC_UTF16BE is used expects
UTF-16 and not UCS-2, this patch changes implementation of encodings
BLKID_ENC_UTF16LE and BLKID_ENC_UTF16BE to supports full UTF-16, including
surrogate pairs and not only UCS-2.
Karel Zak [Wed, 5 Feb 2020 13:37:41 +0000 (14:37 +0100)]
libfdisk: (gpt) add functionality to move backup header
- add fdisk_gpt_disable_relocation() to disable move backup header to standard location
- add fdisk_gpt_enable_minimize() to move backup header behind last partition
Note that fdisk_gpt_disable_relocation() has to be used before fdisk_assign_device(),
because automatic relocation is done when libfdisk reads the header from the device.
Karel Zak [Tue, 4 Feb 2020 15:17:42 +0000 (16:17 +0100)]
fstrim: do not use Protect setting in systemd service
The ProtectHome= and ProtectSystem= settings mounts all stuff for the service in read-only mode.
The fstrim ioctl operates on read-only mountpoint file descriptor, but
on some read-only filesystem the operation can fail, so since 2d22ac64e4 we check for read-only volumes and skip it.
References: Upstream: http://github.com/karelzak/util-linux/commit/2d22ac64e4d6e6732640f38b7232b5bcdc84a877
Addresses: https://github.com/karelzak/util-linux/issues/948 Signed-off-by: Karel Zak <kzak@redhat.com>
jonnyh64 [Wed, 29 Jan 2020 21:24:16 +0000 (22:24 +0100)]
chrt: Use sched_setscheduler system call directly
musl libc does not support the sched_setscheduler library function
because the underlying Linux system call does not confirm to Posix;
this patch makes chrt use the system call directly
[kzak@redhat.com:
- note that musl libc implements sched_setscheduler()
but returns -ENOSYS all time...
- add ifdefs to the patch
- make sure we include syscall.h]
References: http://git.musl-libc.org/cgit/musl/commit/src/sched/sched_setscheduler.c?id=1e21e78bf7a5c24c217446d8760be7b7188711c2
Addresses: https://github.com/karelzak/util-linux/issues/943 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 28 Jan 2020 09:45:07 +0000 (10:45 +0100)]
libmount: fix x- options use for non-root users
libmount returns EPERM for all X- and x- mount options for non-root
users when evaluate X-mount.mkdir. It's bug, we need to be sensitive
to only X-mount.mkdir and only if the target directory is missing.
Addresses: https://github.com/karelzak/util-linux/issues/941 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 27 Jan 2020 15:17:10 +0000 (16:17 +0100)]
build-sys: add --disable-hwclock-gplv3
The currently used date/time parser (for hwclock --set --date <date>)
is gnulib based code with GPLv3.
This patch allows to avoid this code and replace it with minimalistic
date/time parser.
Addresses: https://github.com/karelzak/util-linux/issues/891 Reported-by: Carlos Santos <unixmania@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 15 Jan 2020 11:58:29 +0000 (12:58 +0100)]
strutils: fix double free in strrealloc() [coverity scan]
* fix double free
* keep strrealloc() semantic compatible with classic realloc() (do not
free original pointer on failed memory allocation).
* remove unnecessary goto
Luca Boccassi [Wed, 4 Dec 2019 15:06:55 +0000 (15:06 +0000)]
libmount: add support for signed verity devices
A new API was added to libcryptsetup to make use of the kernel's new
CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG feature, which allows to sign
root hashes. Add a verity.roothashsig option to use it.
Device reuse will be allowed only if signatures are used by all, or
by none.
Karel Zak [Mon, 13 Jan 2020 09:39:52 +0000 (10:39 +0100)]
include: add some missing licence stuff to header files
It's mostly wrappers for compatibility and another trivial stuff etc.
Let's keep it as public domain to make it more portable to LGPL, GPL
and BSD code.
Signed-off-by: Karel Zak <kzak@redhat.com> CC: Sami Kerola <kerolasa@iki.fi> CC: Ruediger Meier <ruediger.meier@ga-group.nl>