Commit Graph

2357 Commits

Author SHA1 Message Date
Luca Boccassi 9835a4b6a1 verity: add support for Forward Error Correction options
Requires kernel built with CONFIG_DM_VERITY_FEC.
2019-12-10 12:52:39 +00:00
Luca Boccassi 141bb954e7 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.
2019-12-10 12:52:39 +00:00
Pierre Labastie 90084a2608 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>
2019-12-06 12:50:46 +01:00
Karel Zak 62dc77f3a2 mount: add verity example to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 15:32:23 +01:00
Karel Zak c9300c7d6e mount: (dm-verity) update man page
* move to separate section (like we use for LOOP DEVICE support)
* explain what dm-verity + mount(8) does

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 13:47:53 +01:00
Karel Zak 9309ca1b93 Merge branch 'dmverity' of https://github.com/bluca/util-linux
* 'dmverity' of https://github.com/bluca/util-linux:
  libmount: add support for verity devices via libcryptsetup
2019-12-05 13:23:46 +01:00
Luca Boccassi e6a498877c libmount: add support for verity devices via libcryptsetup
The following new options are added:

verity.hashdevice
verity.roothash
verity.hashoffset

The source path will be used as a dm-verity object, and will be
opened using libcryptsetup APIs.

A new --with-cryptsetup build-time option is added, which adds a
dependency on libcryptsetup. To ease bootstrapping, given libcryptsetup
build-depends on util-linux for libuuid, if --with-cryptsetup=yes but
libcryptsetup is not installed only a warning will be printed at
configure time rather than an error. This way stage0/first stage/ring0
builds can use the same configure options but avoid installing
cryptsetup to get a working base set, and then rebuild util-linux in
the next step of the boostrapping process.

If verity options are selected but cannot be fullfilled due to lack of
dependencies, mounting a volume will fail even if using a loop device
would work as a fallback, to avoid silently skipping integrity checks.
2019-12-05 10:39:21 +00:00
Karel Zak 3861c371f6 Merge branch 'mount-eperm'
* mount-eperm:
  mount: no exit on EPERM, continue without suid
2019-12-03 15:23:53 +01:00
Karel Zak ac0391cc4f unshare: cleanup capabilities code [lgtm scan]
- remove C++isms
- remove unnecessary { }
- remove if-if
- remove unnecessary condition

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 15:15:22 +01:00
Karel Zak 48f80ab3b0 lscpu: make code more readable [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:35:43 +01:00
Karel Zak 897166a86d build-sys: fix out-of-tree build for hwclock
The file sys-utils/hwclock-parse-date.c is generated from .y and
stored in the build directory and "#include hwclock.h" is interpreted
relatively to the build tree rather than to source tree. We need
explicit -I compiler option to point to $srcdir for hwclock.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 13:55:18 +01:00
Karel Zak 241f3f014e lscpu: top-level DMI function refactoring
Let's keep /dev/mem code together and do not mix it with /sys firmware
stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-20 11:33:59 +01:00
Karel Zak 6497f2d99e mount: no exit on EPERM, continue without suid
The current libmount assumes that mount(8) and umount(8) are suid
binaries. For this reason it implements internal rules which
restrict what is allowed for non-root users. Unfortunately, it's
out of reality for some use-cases where root permissions are no
required. Nice example are fuse filesystems.

So, the current situation is to call exit() always when mount, umount or
libmount are unsure with non-root user rights. This patch removes the
exit() call and replaces it with suid permissions drop, after that it
continues as usually. It means after suid-drop all depend on kernel
and no another security rule is used by libmount (simply because any
rule is no more necessary).

Example:

old version:
   $ mount -t fuse.sshfs kzak@192.168.111.1:/home/kzak /home/kzak/mnt
   mount: only root can use "--types" option

new version:
   $ mount -t fuse.sshfs kzak@192.168.111.1:/home/kzak /home/kzak/mnt
   kzak@192.168.111.1's password:

   $ findmnt /home/kzak/mnt
   TARGET         SOURCE                        FSTYPE     OPTIONS
   /home/kzak/mnt kzak@192.168.111.1:/home/kzak fuse.sshfs rw,nosuid,nodev,relatime,user_id=1000,group_id=1000

   $ umount /home/kzak/mnt
   $ echo $?
   0

Note that fuse user umount is supported since v2.34 due to user_id= in
kernel mount table.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-19 14:58:20 +01:00
Karel Zak 390ba85c78 renice: fix arguments description in --help
The --{pid,pgrp,user} options does not have arguments.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:32:18 +01:00
Karel Zak cb99f4ea79 renice: fix --help text
The option [-n] in the code has no any meaning and the value is used
as priority, not incrementally.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:22:57 +01:00
Andrew Price 48bb8522fe fallocate.1: List gfs2 as supporting punch-hole
Signed-off-by: Andrew Price <anprice@redhat.com>
2019-11-08 11:18:17 +01:00
Karel Zak 68a2ade7ed hwclock: add SPDX-License-Identifier(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:12:13 +01:00
Karel Zak 4d1b9e02fc build-sys: .gitignore hwclock-parse-date.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 10:43:46 +01:00
Karel Zak 8e1b131e0a build-sys: use parse-date() only for hwclock
The parse-date.y is used only for hwclock, let's keep it together.
Note that the file (originally from gnulib) has GPLv3 license, so it's
better to make it obvious that we use it really only for hwclock (also
GPL).

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-07 09:02:23 +01:00
Karel Zak f2cb9359c1 mount: (man) document --target-prefix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak 34333e5244 libmount: allow use -o together with --all
For example:
	# mount --verbose --all -t xfs -o ro

will mount all all XFS filesystems from fstab, but read-only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Karel Zak b231e0f71c mount: add --target-prefix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-31 12:25:08 +01:00
Merlin Büge b2de475c67 mount: (man) small typo fixes 2019-10-17 11:01:13 +02:00
Karel Zak 43db339b9a docs: remove implemented TODO items
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-17 10:54:15 +02:00
John Garry 6f00af5b3c lscpu: Add HiSilicon aarch64 tsv110 cpupart
Add an entry for the HiSilicon aarch64 part tsv110.

Another known alias for this part is TaishanV110, and it can be
found in the Kunpeng920/Hi1620 SoC.

Signed-off-by: John Garry <john.garry@huawei.com>
2019-10-11 10:11:27 +02:00
Karel Zak b3fc2a3c33 hwclock: report rtc open() errors on --verbose
Let's be more verbose and provide real open() error to make
debugging easier on --verbose.

For example:

$ hwclock --verbose
hwclock from util-linux 2.34.193-6bebea-dirty
System Time: 1570445823.701266
Trying to open: /dev/rtc0
hwclock: cannot open /dev/rtc0: Permission denied          <---
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

Addresses: https://github.com/karelzak/util-linux/issues/879
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-07 12:57:43 +02:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak 8e76d28dbd fsfreeze: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:57:31 +02:00
Sami Kerola 218b1dd6f9
misc: fix typos [codespell]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:41:46 +01:00
Karel Zak 8434a362c9 Merge branch 'unshare/keep-caps' of https://github.com/jpeach/util-linux
* 'unshare/keep-caps' of https://github.com/jpeach/util-linux:
  unshare: add --keep-caps option
2019-09-12 12:29:28 +02:00
Karel Zak fd7b0b4e54 dmesg: do not stop on \0
... but I have doubts this change fixes the issue. It seems (on my
system) that \0 is already filtered out by kernel/syslog.

Addresses: https://github.com/karelzak/util-linux/issues/862
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-10 10:34:01 +02:00
James Peach cef4decf04 unshare: add --keep-caps option
Add the --keep-caps option to unshare to preserve capabilities that
are granted when creating a new user namespace. This allows the child
process to retain privilege within the new user namespace without also
being UID 0.
2019-09-09 20:23:08 -07:00
Karel Zak 646bba41fd dmesg: add --noescape
We have no way how to print the kernel message buffer in really raw
way. The new option --noescape disables all \x<hex> translations.

Addresses: https://github.com/karelzak/util-linux/issues/858
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-09 12:56:53 +02:00
James Peach 4175f29e62 unshare: add --map-current-user option
Add the --map-current-user option to unshare. This option maps the
current effective UID and GID in the new user namespace so that the
inner and outer credentials match.

Signed-off-by: James Peach <jpeach@apache.org>
2019-09-08 15:00:00 -07:00
Karel Zak f227757c77 fstrim: ignore non-directory mountpoints
It seems better to silently ignore mount binds on file (= mountpoint
is not a directory).

This patch also fixes use-after-free bug from commit 402006fa6e.

Addresses: https://github.com/karelzak/util-linux/issues/857
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 16:32:10 +02:00
Karel Zak f7f25faae0 Merge branch '2019wk33' of https://github.com/kerolasa/util-linux
* '2019wk33' of https://github.com/kerolasa/util-linux:
  docs: try to find broken man references and fix them
  docs: correct su.1 runuser reference from section 8 to 1
  po: remove possibility to translate static option arguments
2019-08-27 10:11:02 +02:00
Bjarni Ingi Gislason 85efb65621 sys-utils/manuals: Make the number of the paired macros ".RS" and ".RE" equal
Adjust the number of the macros ".RS" and ".RE" to be equal.

  There is no change in the formatted output.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-08-27 09:31:10 +02:00
Sami Kerola dbeb1d733e
docs: try to find broken man references and fix them
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-26 19:43:40 +01:00
Sami Kerola a7466bdcbe
po: remove possibility to translate static option arguments
These strings are expected to be wrote exactly as they are parsed, so make
translating them impossible.  Since mkfs.cramfs -N option arguments need
this treatment use opportunity to slice usage() output to multiple lines.

Addresses: https://bugs.debian.org/907568
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-24 09:29:52 +01:00
Karel Zak 8c863d0eac eject: use O_EXCL on default
* by default we assume all is umounted; so O_EXCL is no problem,
  otherwise there is bug or race (someone else remounted the device)...

* --force and --no-umount disable O_EXCL

Addresses: https://github.com/karelzak/util-linux/issues/423
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-22 13:05:06 +02:00
Karel Zak 23b98f775f Merge branch 'container' of https://github.com/slashdd/util-linux
* 'container' of https://github.com/slashdd/util-linux:
  fstrim shouldn't run inside a container
2019-08-21 14:37:26 +02:00
Patrick Steinhardt cdd2d60e56 wdctl: remove duplicate include of <unistd.h>
The <unistd.h> header is included twice in "wdctl.c". Remove one
of these includes to keep "make checkincludes" happy.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-19 15:00:35 +02:00
Eric Desrochers 0280d31a2b fstrim shouldn't run inside a container
Container type implies the following products:
openvz	OpenVZ/Virtuozzo
lxc	Linux container implementation by LXC
lxc-libvirt	Linux container implementation by libvirt
systemd-nspawn	systemd's minimal container implementation, see systemd-nspawn(1)
docker	Docker container manager
podman	Podman container manager
rkt	rkt app container runtime
wsl	Windows Subsystem for Linux

References:
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
https://www.freedesktop.org/software/systemd/man/systemd-detect-virt.html#

Fix: #840

Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com>
2019-08-14 13:31:25 -04:00
Karel Zak cd38987bf4 Merge branch 'issue832' of https://github.com/kerolasa/util-linux
* 'issue832' of https://github.com/kerolasa/util-linux:
  mountpoint: add --nofollow option
2019-08-07 11:20:21 +02:00
Chistyj Arkadij 0797511930 removed double space 2019-08-04 21:21:55 +03:00
Chistyj Arkadij e9d2e0c819 fixed mount man page typo, "bythe" -> "by the" 2019-08-04 17:06:38 +03:00
Sami Kerola 6d56251220
mountpoint: add --nofollow option
The no follow option will allow user to distinct mount points from symbolic
links pointing to them.  Arguably this is pretty pedantic option, mounting a
device or bind mount to a directory via symlink does not have or cause any
issues.

Addresses: https://github.com/karelzak/util-linux/issues/832
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-02 19:39:05 +01:00
Karel Zak 3661aab4cf dmesg: fix output hex encoding
The current code ignores single-byte non-printable characters.

Reported-by: Marc Deslauriers <marc.deslauriers@canonical.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-01 11:43:58 +02:00
Karel Zak 0c493067dd choom: improve docs
It's not obvious from the current docs that you have to explicitly
split command line options and wanted commands.

Addresses: https://github.com/karelzak/util-linux/issues/833
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-01 11:06:06 +02:00
Sami Kerola b5f376d11d
lscpu: prefer memcpy() to manual pointer arithmetic
With pointer arithmetic clang address sanitizer gives following error this
change addresses.  Notice the following happens only when running as root.

sys-utils/lscpu-dmi.c:83:14: runtime error: load of misaligned address
0x55a1d62f3d1d for type 'const uint16_t' (aka 'const unsigned short'), which
requires 2 byte alignment

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-27 19:00:34 +01:00