Karel Zak [Wed, 18 Jan 2017 12:17:21 +0000 (13:17 +0100)]
build-sys: use -lm for scriptreplay if necessary
Reported-by: Bert van Hall <bert.vanhall@avionic-design.de>
Addresses: https://github.com/karelzak/util-linux/pull/397 Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Mon, 16 Jan 2017 22:31:36 +0000 (22:31 +0000)]
last: use --time-format instruction when printing wtmp creation time
This makes --time-format=iso timestamp to look the same as login/logout
times. When --time-format=noformat is used the file creation time not
printed. There is no change to default format.
Stanislav Brabec [Thu, 12 Jan 2017 14:45:42 +0000 (15:45 +0100)]
libmount: Fix incorrect detach of reused loop device
If -oloop is used and the loop device is reused, the loop device is detached
after umount. It is incorrect as it could break the another task using the loop
device.
This is caused by mnt_context_enable_loopdel(,TRUE) that is called from
mnt_context_prepare_umount() whenever "loop" option is used, independently on
AUTOCLEAR flag.
Remove the "loop" option for reused devices to prevent detaching of reused loop
device.
Stanislav Brabec [Thu, 12 Jan 2017 14:45:27 +0000 (15:45 +0100)]
libmount: fix mount -oloop=/dev/loopX regression
If mount option "loop" is used with an argument, it should be respected. Commit 8efad715 introduced a regression. Even with an argument, overlaying loop device
is searched and argument is ignored. It could have unexpected side effects.
If argument is set, never allocate a new loop device.
How to reproduce:
mkdir -p cdrom
mkisofs -o cdrom.iso cdrom/ 2>/dev/null
losetup /dev/loop0 cdrom.iso
strace mount -t auto -o ro,loop=/dev/loop1 cdrom.iso /mnt 2>&1 | grep ^mount
cat /proc/self/mountinfo | grep /mnt
umount /mnt
losetup -d /dev/loop0
mount("/dev/loop0", "/mnt", "iso9660", MS_MGC_VAL|MS_RDONLY, NULL) = 0
327 60 7:0 / /mnt ro,relatime shared:241 - iso9660 /dev/loop0 ro
losetup: /dev/loop0: detach failed: No such device or address
Karel Zak [Fri, 13 Jan 2017 12:26:37 +0000 (13:26 +0100)]
libblkid: add blkid_probe_set_sectorsize()
The usual way is to use ioctl to ask block device for sector size, but
this is useless for disk images (regular files). And the default
(512-bytes) may be pretty wrong for disk images from 4K disks. Let's
support a way how to specify proper sector size.
Karel Zak [Fri, 13 Jan 2017 11:44:35 +0000 (12:44 +0100)]
libfdisk: change the way how apply user device properties
The current code calls fdisk_apply_user_device_properties() after
label probing, because we want to overwrite label geometry by user
settings (e.g. -C -H -S fdisk options).
Unfortunately, this way does not work if we need to use a different
sector size, because label probing depends on sector size... So, the
right way is to apply user setting to the fdisk context before we
start to read from device, and overwrite geometry again after label is
already read. Fortunately, this shit is necessary only rarely and for
SUN and SGI disk labels.
Addresses: https://github.com/karelzak/util-linux/issues/396 Signed-off-by: Karel Zak <kzak@redhat.com>
Stanislav Brabec [Tue, 10 Jan 2017 12:54:17 +0000 (13:54 +0100)]
If mtab support is disabled, disable ro/rw mtab checks
Commit f9906424 introduced a check that should prevent different information in
mtab and /proc/mounts. The check can require significant amount of time, and for
systems without mtab support it has no sense.
Execute this code only on systems with mtab.
When a systems with large number of nodes (thousands) mount the filesystems
simultaneously, the time required for serialization causes the utimensat() to
take a large amount of time (tens of minutes) when a large number of nodes are
simultaneously updating the timestamp.
Karel Zak [Mon, 9 Jan 2017 12:28:24 +0000 (13:28 +0100)]
libsmartcols: add scols_cell_get_alignment()
Just to hide that we use cell flags (bitwise operations) to define
cell content alignment. The patch also more explicitly specifies the
flags in the header file.
The alignment is evaluated in the order: right, center, left. The
default is left.
Note that SCOLS_CELL_FL_* are used for for table title only.
Karel Zak [Fri, 6 Jan 2017 10:09:01 +0000 (11:09 +0100)]
Merge branch 'betterMinixChecks' of https://github.com/n3world/util-linux
* 'betterMinixChecks' of https://github.com/n3world/util-linux:
libblkid/minix: Sanity check superblock s_state for v 1 and 2
libblkid/minix: Use same checks for version 3
libblkid/minix: Match minix superblock types
Nate Clark [Wed, 4 Jan 2017 20:21:17 +0000 (15:21 -0500)]
libblkid/minix: Sanity check superblock s_state for v 1 and 2
Swap devices with specific values in the uuid can look like minix
devices to blkid. Add an extra check to make sure the state of the
filesystem has valid state flags.
Nate Clark [Wed, 4 Jan 2017 20:24:32 +0000 (15:24 -0500)]
libblkid/minix: Use same checks for version 3
fsck.minix performs the same sanity checks on all versions of the
superblock. Update the probe to perform the same sanity checks so it is
less likely a different type of filesystem will be identified as minix.
Nate Clark [Wed, 4 Jan 2017 20:24:22 +0000 (15:24 -0500)]
libblkid/minix: Match minix superblock types
All of the types in the minix super block are unsigned but in
probe_minix they were being treated as signed. This would cause some of
the extra sanity checks to pass on a non minix device. The types were
updated to match the return types of the helper functions in
disk-utils/minix_programs.h
Nate Clark [Wed, 4 Jan 2017 17:31:37 +0000 (12:31 -0500)]
disk-utils/mkfs.minix: Set ninodes after checking max
ninodes in the superblock needs to be set after inodes is checked
against MINIX_MAX_INODES otherwise a value larger than MINIX_MAX_INODES
can be attempted to be stored in the superblock.
Without this change the command "mkfs.minix -2 -i 65530 <dev>" would
write a minix superblock with ninodes set to 0.
Karel Zak [Tue, 20 Dec 2016 14:31:33 +0000 (15:31 +0100)]
libmount: reimplement mnt_match_options()
Let's use optstr.c functions to parse pattern and options strings.
It's more robust that the old original mount(8) code and it supports
quotes in the options strings.
Karel Zak [Fri, 16 Dec 2016 11:46:45 +0000 (12:46 +0100)]
findmnt: error on --target /non-exist
The original --target implementation (< v2.27) has been based on
stat(), so it was usable for valid paths only.
The new implementation is based on search in the mountinfo file, so it
works for arbitrary crazy path. This is not backwardly compatible and
if the path does not exist then it still returns at least root
directory mount entry.
This patch forces mnt_table_find_mountpoint() to check if the path is
valid before we search in the mountinfo file.
Karel Zak [Thu, 15 Dec 2016 13:40:26 +0000 (14:40 +0100)]
more: avoid double free() on exit
On 'q' command more(1) calls end_it() function with _exit(). The
_exit() may suspend program execution due to pending I/O on very
loaded server. In this time SIGINT may be delivered due to impatient
user who will press ^C.
And then end_it() cleanup function may be executed by signal handler
too. The result is double free()...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403971 Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sun, 11 Dec 2016 11:43:37 +0000 (11:43 +0000)]
lib/randutils: use getrandom(2) when it is available
System call getrandom(2) is relatively new, available since kernel 3.17 but
not supported by glibc 2.24. That in mind autotools is made to check
availability of this function and keep old code as fallback. It is
reasonable assume it will take years before the syscall(2) and fallback are
unproblematic to remove.
One might ask why bother using getrandom(2). Main reason is to avoid
unnecessary system calls to achieve exactly same end result. That
demonstrated with 'strace -c ./mcookie' showing 36 calls before, and 32
after this change. Secondly the getrandom(2) function got to kernel with
promise it can be used to avoid file descriptor run down, and since uuidd
uses random_get_bytes() it should fulfill it's promise here.
Reference: http://man7.org/linux/man-pages/man2/getrandom.2.html
Reference: https://lwn.net/Articles/606141/ Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Karel Zak [Fri, 9 Dec 2016 14:11:31 +0000 (15:11 +0100)]
libmount: revert X-* and x-* meaning
Let's hope this is last change necessary to cleanup x-* usage:
x-* persistent option, stored in utab, available for umount, etc.
X-* fstab comment only
mount(8) supports x-mount.mkdir= as well as newly recommended X-mount.mkdir=
Advantages:
* less invasive
* does not require exception for x-systemd
* does not require rename x-initrd to X-initrd
The systemd and dracut users will get the new (=fixed) functionality without a
change in fstab configuration. This is the primary goal.
Disadvantages:
* not 100% compatible libmount behavior, x-* options have not been
previously stored in utab. The API is the same, options will be still
available, but on x-* libmount will write to /run/mount/utab. For now
it seems only systemd uses x-*, and they like this behavior, so...
Addresses: https://github.com/systemd/systemd/pull/4515 Signed-off-by: Karel Zak <kzak@redhat.com>
Ruediger Meier [Wed, 7 Dec 2016 19:39:02 +0000 (20:39 +0100)]
build-sys: don't clean *.img files
Don't know why this was added in d78df0ac but it can't be right that
libmount/python removes these files in the toplevel builddir. Moreover
I've never seen such *.img files appearing during build at all.
Karel Zak [Fri, 9 Dec 2016 12:48:34 +0000 (13:48 +0100)]
Merge branch doc_fixes
Rebase from
http://git.kernel.org/pub/scm/linux/kernel/git/mtk/util-linux.git doc_fixes
docs: renice(1): Add credentials(7) to SEE ALSO
docs: renice(1): Add SEE ALSO entry for sched(7)
docs: mount(8): Wording fix
docs: ionice(1): SEE ALSO: add ioprio_set(2)
docs: lsns(8): SEE ALSO: add namespaces(7)
docs: last(1): Eliminate oddball formatting
docs: last(1): SEE ALSO: add reference to wtmp(5)
docs: taskset(1): Wording fix
docs: namei(1): SEE ALSO: add symlink(7)
docs: kill(1): Wording fix
docs: various pages: Use 'UID" and "GID", not "uid" and "gid" in man pages
docs: various pages: Use "PID" not "pid" in man-pages
docs: various pages: Use "ID" not "id" in man pages
docs: various pages: Use consistent terminology (set-user-ID and set-group-ID)
docs: various pages: Format pathnames as italic (.I)
Michael Kerrisk [Mon, 5 Dec 2016 06:28:09 +0000 (07:28 +0100)]
docs: renice(1): Add SEE ALSO entry for sched(7)
The sched(7) page as of the most recent release contains detailed
information on the 'nice' value, including a discussion of
autogrouping, which has surprising interactions with the process
nice value.
Michael Kerrisk [Sun, 4 Dec 2016 19:34:54 +0000 (20:34 +0100)]
docs: various pages: Use consistent terminology (set-user-ID and set-group-ID)
Use consistent terminology for set-user-ID and set-group-ID bits.
There's much inconsistency in the pages. "suid",
"set-user-identifier", "setuid". Stick with one terminology,
"set-user-ID" and set-grout-ID, as suggested in man-pages(7).
Michael Kerrisk [Sat, 3 Dec 2016 20:13:59 +0000 (21:13 +0100)]
docs: various pages: Format pathnames as italic (.I)
In the majority of pages, pathnames are formatted as Italic,
which is the norm. However, there are several cases where they
are formatted as bold. This patch fixes a number of those
exceptions.
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
Michael Kerrisk [Fri, 9 Dec 2016 12:32:34 +0000 (13:32 +0100)]
docs: renice(1): Remove obsolete BUGS text
Already at least as far back as util-linux 2.2, renice uses
getpriority(2) to fetch the process's old nice value. Thus,
the "problem" discussed in this BUGS note disappeared long ago.
This is trivially demonstrable:
$ sleep 100 &
[1] 24322
$ renice -n 5 24322
24322 (process ID) old priority 0, new priority 5
$ renice -n 10 24322
24322 (process ID) old priority 5, new priority 10
Rather than trying to explain the ancient problem (20 years old?),
just kill this text.
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Michael Kerrisk [Fri, 9 Dec 2016 12:25:20 +0000 (13:25 +0100)]
docs: renice(1): Rework discussion of unprivileged users,
The BUGS section describing the limitations on what an unprivileged
user may do to the nice value is outdated, given the kernel changes
that added RLIMIT_NICE in Linux 2.6.12. So, remove that text.
The revised details for modern Linux were partially covered in NOTES,
but there were also inaccuracies there (and the use of the word
"monotonically" was unneeded). In particular, the point is that
unprivileged users can only increase the nice value. There is no
restriction particular to the range 0..+19. So, for example, the
following scenario is possible:
1. Superuser sets the nice value of an unprivileged user's
process to -20.
2. The unprivileged user can now renice that process to (say) -10.
Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 9 Dec 2016 08:47:33 +0000 (09:47 +0100)]
hwclock: don't check for permissions
The right place to verify user permissions is kernel. The current
situation is too strict (due to previous attempts to use hwclock as
suid that has never been supported).
Karel Zak [Thu, 8 Dec 2016 13:29:44 +0000 (14:29 +0100)]
libmount: use x-systemd options as X-*
The previous patch introduces X-* options namespace for options
that have to be maintained in user space.
Unfortunately, systemd users already use mount options that are
necessary by umount or another operations. The conclusion from
discussion with systemd guys is to store all the systemd options
in userspace.
It seems better to add one line exception to libmount than force all
fstab users to rename x-systemd to X-systemd.
Addresses: https://github.com/systemd/systemd/pull/3904 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 8 Dec 2016 13:55:02 +0000 (14:55 +0100)]
libmount: introduce X-* comments
x-* are fstab only and not stored in userspace (utab). In some cases
it's not optional solution because the option is also necessary for
umount or another operations. The X-* is exactly the same as x-*, but
stored to utab (or mtab on old systems).
It's usually bad idea to store mount options in userspace, but it's
better to provide any solution that force users to bypass mount(8)
(and friends) and implement 3rd-party incompatible solutions.
Karel Zak [Thu, 8 Dec 2016 13:24:41 +0000 (14:24 +0100)]
findmnt: add --tree to allow to enable tree output for --mtab
The --mtab output is merge from kernel and utab on all modern systems
(without classic /etc/mtab). It means we have all necessary information
to generate tree output.
For the backward compatibility --mtab is the list by default, the new
option --tree allows to override the default and enable tree always
when the table contains child-parent relations.