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
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.
Daniel Drake [Mon, 16 Dec 2019 06:16:48 +0000 (14:16 +0800)]
libblkid: improve identification of ISO9660 partition
Recent changes to the iso9660 handler attempt to better handle the case
where the media has both an ordinary ISO9660 filesystem, and a partition
table with a partition entry pointing at the ISO9660 filesystem.
Rather than assuming the presence of a partition table means that there
is an ISO9660 partition, check that such a partition exists before
deciding upon which device the metadata should be presented. One real
world example of this is the grub-mkrescue image format; add a unit test
to cover that.
Secondly, even if we find an appropriate entry in the partition table,
verify that we actually have a device that corresponds to the partition
where we would then proceed to expose this metadata. In the case of a
CD/DVD (i.e. /dev/sr0) we would not normally expect to see devices
corresponding to the partitions, in that case the ISO metadata should be
presented on the whole disk (/dev/sr0).
Pali Rohár [Sun, 15 Dec 2019 11:55:41 +0000 (12:55 +0100)]
libblkid: udf: Fix reporting UDF 2.60 revision for Mac OS X disks
Apple's newfs_udf, when creating UDF 2.60 disks, sets value 2.50 into
both Minimum UDF Read Revision and Minimum UDF Write Revision fields in
LVIDIU. And sets 2.60 value into UDF revision field in LVD descriptor.
So to correctly parse and set blkid ID_FS_VERSION field, use maximum value
from Minimum UDF Read Revision in LVIDIU, Minimum UDF Write Revision in
LVDIU and UDF revision in LVD descriptor.
This commit also adds a testing UDF 2.60 disk image with 4K sectors created
by Apple's newfs_udf to verify that ID_FS_VERSION is set correctly to 2.60.
agetty: return proper value if compiled without ISSUEDIR support
If agetty is compiled without support for ISSUEDIR, then it implements
a stub for `issuedir_read` that simply does nothing. In fact it does
too little, as it doesn't have a proper return statement even though the
function returns an integer.
Fix the issue by always returning `1` from `issuedir_read`. This
is the same error code that the real implementation of that function
returns in case it cannot open the directory and is thus a sensible
default to pretend that the directory doesn't exist.
Karel Zak [Tue, 10 Dec 2019 13:46:13 +0000 (14:46 +0100)]
Merge branch 'dmverity_options' of https://github.com/bluca/util-linux
* 'dmverity_options' of https://github.com/bluca/util-linux:
verity: add support for Forward Error Correction options
verity: ensure that hash_device and root_hash[_file] are passed together or not at all
verity: add new verity.roothashfile option
Luca Boccassi [Tue, 10 Dec 2019 11:18:09 +0000 (11:18 +0000)]
verity: add new verity.roothashfile option
Allow users to point mount to a file to read the roothash, in addition
to passing it inline.
Allows a volume managed by a systemd mount unit to be updated without
changing the mount unit content itself, for easier and more user friendly
servicing.
Karel Zak [Mon, 9 Dec 2019 11:20:22 +0000 (12:20 +0100)]
Merge branch 'kill-pidfd' of https://github.com/kerolasa/util-linux
* 'kill-pidfd' of https://github.com/kerolasa/util-linux:
kill: use pidfd system calls to implement --timeout option
build-sys: add missing NR underscore to UL_CHECK_SYSCALL()
Karel Zak [Mon, 9 Dec 2019 10:30:55 +0000 (11:30 +0100)]
lib/randutils: re-licensing back to BSD
The file is originally from libuuid, this library is under BSD
licence. Unfortunately, I have added LGPL header by accident to the
file (commit 0f23ee0c855d686b0c315af2c96b8835134cd9e3).
The file under LGPL was modified (in relevant way) by Sami,
Christopher and me. We all agree with re-licensing back to BSD.
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Christopher James Halse Rogers <chris@cooperteam.net> Signed-off-by: Karel Zak <kzak@redhat.com>
Pierre Labastie [Fri, 6 Dec 2019 11:50:46 +0000 (12:50 +0100)]
docs: Fix adjtime documentation
The first line of the adjtime file is made of three numbers (see=20
hwclock.c):
- a drift factor as a decimal float
- the time of last adjust as a decimal integer
- a zero (for compatibility) as a decimal float.
but both man pages (hwclock.8 and adj_time.5) tell that the third
number is a decimal integer.
Of course this is harmless if somebody edits the adjtime file with
"0"=20 as the third number: it will be correctly read by hwclock
anyway. But if for some reason, a program reads the adjtime file and
expects an integer, it will fail, because hwclock writes O.OOOO0O as
the third=20 number.
Signed-off-by:: Pierre Labastie <pierre.labastie@neuf.fr> Signed-off-by: Karel Zak <kzak@redhat.com>