Commit Graph

13857 Commits

Author SHA1 Message Date
Karel Zak 7727be1af1 script: listen to SIGUSR1, flush logs on the signal
Based on pull request: https://github.com/karelzak/util-linux/pull/815

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 16:04:18 +01:00
Karel Zak ded3735ef4 kill: deallocate follow_ups [assan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 13:20:04 +01:00
Karel Zak 1395236acd kill: make man page more informative about --timeout
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 13:11:16 +01:00
Karel Zak 26c2ad6c38 kill: report features on -V, add lish_header initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 12:40:53 +01:00
Karel Zak b6c3de881c include/pidfd-utils: small cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 12:22:31 +01:00
Karel Zak e601521259 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()
2019-12-09 12:20:22 +01:00
Karel Zak 885fe4e57b Merge branch 'make-manpage-of-su-clearer' of https://github.com/your-diary/util-linux
* 'make-manpage-of-su-clearer' of https://github.com/your-diary/util-linux:
  Slight change in terms
  Make the manpage of su clearer
2019-12-09 12:18:38 +01:00
Karel Zak dde4b59369 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 0f23ee0c85).

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>
2019-12-09 11:30:55 +01:00
Manatsu Takahashi ebaf1d55b4 Slight change in terms 2019-12-08 22:26:26 +09:00
Manatsu Takahashi 1ffc4f7dcb Make the manpage of su clearer 2019-12-08 22:20:53 +09: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
Jouke Witteveen 1c788737d7 su: silence a useless warning
When the requested shell matches the restricted shell, there is no reason
to issue a warning, since we will be doing precisely as requested.

Signed-off-by: Jouke Witteveen <j.witteveen@gmail.com>
2019-12-06 12:40:55 +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 fadb5ebf9c build-sys: add --with-cryptsetup to config-gen.d/all.conf
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 14:57:50 +01:00
Karel Zak cbc390da3a libmount: add verity to mount -V output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-05 14:57:29 +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 107e955946 lsblk: add PARTTYPENAME column
Print also partition type in human-readable way.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1777261
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-04 12:38:57 +01:00
Karel Zak 96c2b09fcb libfdisk: move GPT partition types to include/
We need the array use in another tools too. Let's follow the way we
use for MBR and keep it in include/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-04 12:37:22 +01: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 b4251e5151 libfdisk: improve Sun partitions calculation [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 15:07:58 +01:00
Karel Zak 5fbb920ed4 libblkid: improve MD I/O size calculation [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:51:31 +01:00
Karel Zak 2d1e803b08 libblkid: improve vfat entries calculation [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:49:16 +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 6f7c67a5ff libmount: fix typo in mnt_context_prepare_helper() [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:31:55 +01:00
Karel Zak 21c97651f4 tests: mark scriptlive as KNOWN_FAILED
Not sure why, but on travis-ci the shell output is little bit
different, probably depends on shell version, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-26 09:56:24 +01:00
Sami Kerola 6e6b9a1d24
kill: use pidfd system calls to implement --timeout option
At times there is need in scripts to send multiple signals to a process.
Often these cases require some amount of waiting before follow-up signal
should be sent.

One common case is process termination, where first script tries to kill
process gracefully but if that does not work SIGKILL is sent.  Functionality
like that is commonly done by periodically checking if signalled pid exist
or not, and if it does another signal is sent possibly to an unrelated
process that reused pid number.  That means polling a pid is prone to a data
race.  Also if the first signal immediately kills the process one polling
interval is lost in sleep.

Another example when multiple signal need to be sent is various daemon
process control situations, such as Upgrading Executable on the Fly (see
reference).  This happens to be the case that inspired change author to make
sequential signaling a little bit easier.

Reference: http://nginx.org/en/docs/control.html#upgrade
Pull-request: https://github.com/karelzak/util-linux/pull/902
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-25 21:25:50 +00:00
Sami Kerola ca27517aae
build-sys: add missing NR underscore to UL_CHECK_SYSCALL()
The unistd.h defines system call numbers with two leading underscores.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-25 20:33:05 +00:00
Karel Zak 52722cda11 tests: another prompt fix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 14:09:38 +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 0faa7eda04 bash-completion: update for new script tools
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 12:49:48 +01:00
Karel Zak eb78192211 scriptreplay: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 12:49:41 +01:00
Karel Zak 1eee1acb24 script: add --echo
It some cases it makes sense to disable ECHO flag also when script
used in pipe. This new option allows to keep full control in user's
hands.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 12:39:52 +01:00
Karel Zak a06b278bd3 tests: remove option --posix
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-25 10:45:38 +01:00
Karel Zak 53ea212dca tests: make scriptlive output more portable
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 14:21:20 +01:00
Karel Zak 4a2d27a242 scriptlive: keep ECHO flag, improve welcome message
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 14:04:21 +01:00
Karel Zak 45b819c124 tests: upadet scriptlive output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 14:04:11 +01:00
Karel Zak 85ecd3719b tests: add script and scriptlive replay
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 13:48:54 +01:00
Karel Zak 1ec363cfff scriptlive: add --command, cleanup shell exec
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 13:48:29 +01:00
Karel Zak 95d255a819 scriptlive: terminate session at end of the log
We need a proper way how to inform child (shell) that the game is
over. It seems the best is to send EOF to child rather than
immediately break PTY mainloop where we have poll(), because shell can
still produce data etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 13:03:35 +01:00
Karel Zak f896aef36b lib/pty: make sure we not use closed FD
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-22 11:59:52 +01:00
Karel Zak 4169bcb766 script: fix ECHO use, improve shell exec
For tools like su(1) is ECHO flag unexpected for use-case like

	echo 'date' | su - user

but script(1) need the echo to keep input recorded.

The patch also return execlp() use to script(1) code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-21 12:28:51 +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 916a3f8d29 libmount: don't access struct member, use API
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-18 16:19:15 +01:00
Sami Kerola beb61b07c2
nologin: silently ignore well known shell command-line options
nologin is typically used in /etc/passwd as a shell replacement.  Hence it
is reasonable to ignore well known command-line options silently to avoid
unwanted ugly error messages.

Addresses: https://github.com/karelzak/util-linux/issues/895
Requested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-17 08:33:04 +00:00
Karel Zak 4631edaee2 lsblk: add FSVER to --fs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-15 11:23:44 +01:00
Evan Green ae1e82e0b5 libfdisk: Space before first partition may not be aligned
libfdisk chooses a grain of 1MB fairly arbitrarily, and this granule
may not be honored by other utilities. GPT disks formatted elsewhere
may have space before the first partition, AND a partition that exists
solely below 1MB. If this occurs, cfdisk ends up adding a free space
region where end < start, resulting in a 16 Exabyte free region.

That's too many exabytes.

This happens because the start gets rounded up to the granule size in
new_freespace() but the end is left alone. The logs show it best:

23274: libfdisk:      CXT: [0x572d878]: initialized:  last=34, grain=2048
23274: libfdisk:      CXT: [0x572d878]: partno=10, start=64
23274: libfdisk:      CXT: [0x572d878]: freespace analyze: partno=10, start=64, end=64
23274: libfdisk:      CXT: [0x572d878]: LBA           34 aligned-up           2048 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: LBA           63 aligned-down            0 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: LBA           34 aligned-near            0 [grain=2048s]
23274: libfdisk:      CXT: [0x572d878]: 0 in range <2048..0> aligned to 2048
23274: libfdisk:     PART: [0x574bb98]: alloc
23274: libfdisk:      TAB: [0x5749d58]: adding freespace
23274: libfdisk:      TAB: [0x5749d58]: insert entry 0x574bb98 pre=0x574a820 [start=2048, end=63, size=18446744073709549632, freespace  ]

Avoid this by aligning the last value like new_freespace() does.

Signed-off-by: Evan Green <evangreen86@gmail.com>
2019-11-12 14:38:26 -08:00