Commit Graph

2332 Commits

Author SHA1 Message Date
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
Karel Zak 8bad603ae0 lscpu: (man) add note about cache sizes
Addresses: https://github.com/karelzak/util-linux/issues/827
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-25 12:23:59 +02:00
Karel Zak c64d452b3e fstrim: fix systemd service protection
ProtectHome=yes makes /home inaccessible, but we need to open the
directories (mountpoints) read-only.

Addresses: https://github.com/karelzak/util-linux/issues/824
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-22 11:10:30 +02:00
Carlos Santos 88bc304ba8 hwclock: use CMOS clock only if available
- Add --disable-hwclock-cmos configuration argument
- Add USE_HWCLOCK_CMOS (enabled by default for i386/x86_64)
- Add define(USE_HWCLOCK_CMOS)
- Compile hwclock-cmos.c only if USE_HWCLOCK_CMOS is true
- Remove all unnecessary #ifdefs from hwclock-cmos.c
- Add #ifdef USE_HWCLOCK_CMOS around the determine_clock_access_method()
  call in hwclock.c

Signed-off-by: Carlos Santos <unixmania@gmail.com>
2019-07-15 13:56:13 +02:00
Stanislav Brabec ec06412c90 losetup: Typo fix
Fix a typo in usage introduced in a1a41597bf.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-21 14:38:32 +02:00
Karel Zak bddcf5b816 Merge branch 'topic/wdctl' 2019-06-17 15:48:28 +02:00
Karel Zak b3dd29d1b8 wdctl; read from /sys if necessary
The device can be inaccessible for non-root user or busy (already used
by another process). In this case it seems better to read information
from /sys.

Note that /sys does not provide struct watchdog_info.options, so we
cannot print list of supported watchdog features.

Addresses: https://github.com/karelzak/util-linux/issues/804
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 8c8df42146 wdctl: default to /dev/watchdog0
Let's use miscdev /dev/watchdog as fallback only. We need (if possible)
cdev /dev/watchdog0 as this device has entry in /sys/class/watchdog.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 5d628f37b7 wdctl: remove printing from main()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak a599d1375e wdctl: add control struct
* remove global variables
* keep all together

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak e4d511d40c wdctl: rename watch dog info struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:47:39 +02:00
Karel Zak 25b7045e5d misc: replaces atexit(close_stdout) with new close_stdout_atexit()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:46:10 +02:00
Karel Zak cf3b6b71eb lscpu: add a new columns to --cache
References: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-system-cpu
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:46:10 +02:00
Karel Zak 6466959d9a fstrim: update man page, reuse libmnt_iter
* add info about read-only to the man page
* don't be systemd specific, people aso use crond
* reuse libmnt_iter

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-11 11:05:12 +02:00
Stanislav Brabec 402006fa6e fstrim: properly de-duplicate fstrim -A
fstab can contain tag based mounts. De-duplication by source has to be
done after resolving the full source path.

Perform the table iteration twice. First time, prepare for
de-duplication, second time perform the TRIM itself.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-11 10:26:55 +02:00
Stanislav Brabec 2d22ac64e4 fstrim -a/-A: Skip read-only volumes
Calling TRIM on some read-only volumes can fail with:
fstrim: /win: FITRIM ioctl failed: Bad file descriptor

Skipping all read-only mounts seems to be safe and logical strategy.

Fixes opensuse#1106214.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-11 10:23:45 +02:00
Stanislav Brabec 4080be3d7d fstrim: Fix fstrim_all() comment
"convert LABEL=" does not happens in mnt_fs_get_source(), but later in
mnt_resolve_spec(). To make this more clean, move the comment before this
chunk of code.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2019-06-11 10:23:45 +02:00
Karel Zak bf0a0e3e2a umount: be more strict about --all
If you by accident execute

	umount ls -al /mnt/

then umount --all is executed and another arguments silently ignored.
It seems better to be more strict in this case.

Reported-by: Harald Dunkel <harald.dunkel@aixigo.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-06 14:56:48 +02:00
Karel Zak da14a74df9 setpriv: fix memory leak in local scope [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 13:11:14 +02:00
Karel Zak cf5debba06 setarch: avoid NULL dereference [coverity check]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 13:08:21 +02:00
Karel Zak d3149a8556 rtcwake: terminate mode and excl[]
* terminate string read from /proc
* terminate array for exclusive options

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 12:53:58 +02:00
Karel Zak 9f74aa07d4 renice: make code more readable for static analyzer [coverity scan]
It seems coverity and clag have no clue about relation between argv[]
and argc. Let's make code more readable for them...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 12:19:23 +02:00
Karel Zak 517debc389 readprofile: be more explicit with used types [cppcheck]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 12:17:26 +02:00
Karel Zak a066140713 lscpu: check scols_line_set_data() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 12:05:03 +02:00
Karel Zak fe2e38f3b1 lscpu: make lookup() use more consistent [coverity scan]
We usually check lookup() return value. Let's do it in this case too.
It seems static analyzers will be happy with consistent code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 11:58:51 +02:00
Karel Zak e4c6816cc3 ipcs: check return value when read from /proc [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 15:32:59 +02:00