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>
libblkid: (xfs) external log: check for regular xfs on more sectors
The xfs external log probe only checks for regular xfs on sector zero,
but then checks for valid log record headers on all first 512 sectors.
This can incorrectly detect an xfs external log if a regular xfs (i.e.
with internal log) is shifted by up to 512 sectors; it may happen with
bcache and LVM1 for example, as the regular xfs is found later in disk.
This results in ambivalent filesystem detection, thus no UUID for udev.
Fix this problem by checking for regular xfs on all sectors considered
by the xfs external log probe.
Karel Zak [Tue, 7 Jan 2020 15:48:34 +0000 (16:48 +0100)]
libblkid: check for medium on CDMROMs probing
The commit 39f5af25982d8b0244000e92a9d0e0e6557d0e17 introduces
O_NONBLOCK to avoid the tray close on open(). The side effect is that
open() is successful when there is no medium.
This is usually no problem for standard tools because the next read()
will fail. Unfortunately, libblkid ignores I/O errors for (and only
for) CDROMs to support some crazy hybrid data+audio disks. The final
result is many I/O errors in system log when O_NONBLOCK is enabled.
This patch add CDROM_DRIVE_STATUS to stop probing when there is no
disk or when the tray is open.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1787973 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 7 Jan 2020 10:40:17 +0000 (11:40 +0100)]
tests: mark mdadm tests as TS_KNOWN_FAIL
It seems recent changes in mdadm make things a little bit unstable for
some users. Let's mark the tests temporary as TS_KNOWN_FAIL until we
get more information.
Addresses: https://github.com/karelzak/util-linux/issues/906 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 3 Jan 2020 09:48:09 +0000 (10:48 +0100)]
libmount: improve X-mount.mkdir for non-root users
Since v2.35 mount(8) drops suid on -EPERM and repeat necessary actions
before mount(2) syscall. This patch also improves this behavior for
X-mount.mkdir too.
mount(8):
* return -EPERM on sanitize_paths() rather than call err()
* call suid_drop() on failed sanitize_paths()
* update man page
libmount:
* mnt_context_prepare_target() refactoring
* return -EPERM when in restricted mode for X-mount.mkdir
Karel Zak [Fri, 20 Dec 2019 11:55:49 +0000 (12:55 +0100)]
Merge branch 'master' of https://github.com/dsd/util-linux
* 'master' of https://github.com/dsd/util-linux:
libblkid: improve identification of ISO9660 partition
isosize: move ISO size functions into a shared header
doc: howto-man-page.txt: Use font macros instead of font escapes
Use font macros instead of font escapes (\f[BIPR]).
The escape '\c' ("connect to next input text")
is used to join the output of two macros without a space character.
This is similar to the '\' escape at the end of a line.
Font escapes make the text more difficult to read.
###
Changes based on:
Use a macro to change to the italic font,
instead of \fI [1], if possible.
The macros have the italic corrections,
but "\c" removes the "\/" part.
Or
add the italic corrections.
[1] man-pages(7) [Debian package "manpages"]
###
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of a
1) name for an option
2) negative number to be printed.
###
Wrong distance between sentences or protect the indicator.
a) Separate the sentences and subordinate clauses;
each begins on a new line.
See man-pages(7) [package "manpages"] and "info groff".
Or
b) Adjust space between sentences (two spaces),
c) or protect the indicator by adding "\&" after it.
The "indicator" is an "end-of-sentence character" (.!?).
The amount of space between sentences in the output can then be
controlled with the ".ss" request.
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).
Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.
This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.