]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agoscript: document SIGUSR1
Karel Zak [Mon, 9 Dec 2019 15:10:02 +0000 (16:10 +0100)] 
script: document SIGUSR1

Based on pull request: https://github.com/karelzak/util-linux/pull/815

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: listen to SIGUSR1, flush logs on the signal
Karel Zak [Mon, 9 Dec 2019 15:04:18 +0000 (16:04 +0100)] 
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>
4 years agokill: deallocate follow_ups [assan]
Karel Zak [Mon, 9 Dec 2019 12:20:04 +0000 (13:20 +0100)] 
kill: deallocate follow_ups [assan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agokill: make man page more informative about --timeout
Karel Zak [Mon, 9 Dec 2019 12:11:16 +0000 (13:11 +0100)] 
kill: make man page more informative about --timeout

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agokill: report features on -V, add lish_header initialization
Karel Zak [Mon, 9 Dec 2019 11:40:53 +0000 (12:40 +0100)] 
kill: report features on -V, add lish_header initialization

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/pidfd-utils: small cleanup
Karel Zak [Mon, 9 Dec 2019 11:22:31 +0000 (12:22 +0100)] 
include/pidfd-utils: small cleanup

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'kill-pidfd' of https://github.com/kerolasa/util-linux
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()

4 years agoMerge branch 'make-manpage-of-su-clearer' of https://github.com/your-diary/util-linux
Karel Zak [Mon, 9 Dec 2019 11:18:38 +0000 (12:18 +0100)] 
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

4 years agolib/randutils: re-licensing back to BSD
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>
4 years agoSlight change in terms
Manatsu Takahashi [Sun, 8 Dec 2019 13:26:26 +0000 (22:26 +0900)] 
Slight change in terms

4 years agoMake the manpage of su clearer
Manatsu Takahashi [Sun, 8 Dec 2019 13:20:53 +0000 (22:20 +0900)] 
Make the manpage of su clearer

4 years agodocs: Fix adjtime documentation
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>
4 years agosu: silence a useless warning
Jouke Witteveen [Fri, 6 Dec 2019 10:06:03 +0000 (11:06 +0100)] 
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>
4 years agomount: add verity example to man page
Karel Zak [Thu, 5 Dec 2019 14:32:23 +0000 (15:32 +0100)] 
mount: add verity example to man page

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: add --with-cryptsetup to config-gen.d/all.conf
Karel Zak [Thu, 5 Dec 2019 13:57:50 +0000 (14:57 +0100)] 
build-sys: add --with-cryptsetup to config-gen.d/all.conf

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: add verity to mount -V output
Karel Zak [Thu, 5 Dec 2019 13:57:29 +0000 (14:57 +0100)] 
libmount: add verity to mount -V output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomount: (dm-verity) update man page
Karel Zak [Thu, 5 Dec 2019 12:40:42 +0000 (13:40 +0100)] 
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>
4 years agoMerge branch 'dmverity' of https://github.com/bluca/util-linux
Karel Zak [Thu, 5 Dec 2019 12:23:46 +0000 (13:23 +0100)] 
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

4 years agolibmount: add support for verity devices via libcryptsetup
Luca Boccassi [Fri, 8 Nov 2019 17:02:09 +0000 (17:02 +0000)] 
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.

4 years agolsblk: add PARTTYPENAME column
Karel Zak [Wed, 4 Dec 2019 11:38:57 +0000 (12:38 +0100)] 
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>
4 years agolibfdisk: move GPT partition types to include/
Karel Zak [Wed, 4 Dec 2019 11:37:22 +0000 (12:37 +0100)] 
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>
4 years agoMerge branch 'mount-eperm'
Karel Zak [Tue, 3 Dec 2019 14:23:53 +0000 (15:23 +0100)] 
Merge branch 'mount-eperm'

* mount-eperm:
  mount: no exit on EPERM, continue without suid

4 years agounshare: cleanup capabilities code [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 14:15:22 +0000 (15:15 +0100)] 
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>
4 years agolibfdisk: improve Sun partitions calculation [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 14:07:58 +0000 (15:07 +0100)] 
libfdisk: improve Sun partitions calculation [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: improve MD I/O size calculation [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 13:51:31 +0000 (14:51 +0100)] 
libblkid: improve MD I/O size calculation [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: improve vfat entries calculation [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 13:49:16 +0000 (14:49 +0100)] 
libblkid: improve vfat entries calculation [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: make code more readable [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 13:35:43 +0000 (14:35 +0100)] 
lscpu: make code more readable [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix typo in mnt_context_prepare_helper() [lgtm scan]
Karel Zak [Tue, 3 Dec 2019 13:31:55 +0000 (14:31 +0100)] 
libmount: fix typo in mnt_context_prepare_helper() [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: mark scriptlive as KNOWN_FAILED
Karel Zak [Tue, 26 Nov 2019 08:56:24 +0000 (09:56 +0100)] 
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>
4 years agokill: use pidfd system calls to implement --timeout option
Sami Kerola [Mon, 25 Nov 2019 20:31:20 +0000 (20:31 +0000)] 
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>
4 years agobuild-sys: add missing NR underscore to UL_CHECK_SYSCALL()
Sami Kerola [Mon, 25 Nov 2019 20:33:05 +0000 (20:33 +0000)] 
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>
4 years agotests: another prompt fix
Karel Zak [Mon, 25 Nov 2019 13:09:38 +0000 (14:09 +0100)] 
tests: another prompt fix

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: fix out-of-tree build for hwclock
Karel Zak [Mon, 25 Nov 2019 12:55:18 +0000 (13:55 +0100)] 
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>
4 years agobash-completion: update for new script tools
Karel Zak [Mon, 25 Nov 2019 11:49:48 +0000 (12:49 +0100)] 
bash-completion: update for new script tools

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: fix typo
Karel Zak [Mon, 25 Nov 2019 11:49:41 +0000 (12:49 +0100)] 
scriptreplay: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: add --echo
Karel Zak [Mon, 25 Nov 2019 11:39:52 +0000 (12:39 +0100)] 
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>
4 years agotests: remove option --posix
Karel Zak [Mon, 25 Nov 2019 09:45:38 +0000 (10:45 +0100)] 
tests: remove option --posix

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: make scriptlive output more portable
Karel Zak [Fri, 22 Nov 2019 13:21:20 +0000 (14:21 +0100)] 
tests: make scriptlive output more portable

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: keep ECHO flag, improve welcome message
Karel Zak [Fri, 22 Nov 2019 13:04:21 +0000 (14:04 +0100)] 
scriptlive: keep ECHO flag, improve welcome message

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: upadet scriptlive output
Karel Zak [Fri, 22 Nov 2019 13:04:11 +0000 (14:04 +0100)] 
tests: upadet scriptlive output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: add script and scriptlive replay
Karel Zak [Fri, 22 Nov 2019 12:48:54 +0000 (13:48 +0100)] 
tests: add script and scriptlive replay

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: add --command, cleanup shell exec
Karel Zak [Fri, 22 Nov 2019 12:48:29 +0000 (13:48 +0100)] 
scriptlive: add --command, cleanup shell exec

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: terminate session at end of the log
Karel Zak [Fri, 22 Nov 2019 11:34:45 +0000 (12:34 +0100)] 
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>
4 years agolib/pty: make sure we not use closed FD
Karel Zak [Fri, 22 Nov 2019 10:56:04 +0000 (11:56 +0100)] 
lib/pty: make sure we not use closed FD

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: fix ECHO use, improve shell exec
Karel Zak [Thu, 21 Nov 2019 11:28:51 +0000 (12:28 +0100)] 
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>
4 years agolscpu: top-level DMI function refactoring
Karel Zak [Wed, 20 Nov 2019 10:25:32 +0000 (11:25 +0100)] 
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>
4 years agomount: no exit on EPERM, continue without suid
Karel Zak [Tue, 19 Nov 2019 13:58:20 +0000 (14:58 +0100)] 
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>
4 years agolibmount: don't access struct member, use API
Karel Zak [Mon, 18 Nov 2019 15:19:15 +0000 (16:19 +0100)] 
libmount: don't access struct member, use API

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agonologin: silently ignore well known shell command-line options
Sami Kerola [Sun, 17 Nov 2019 08:33:04 +0000 (08:33 +0000)] 
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>
4 years agolsblk: add FSVER to --fs
Karel Zak [Fri, 15 Nov 2019 10:23:44 +0000 (11:23 +0100)] 
lsblk: add FSVER to --fs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: Space before first partition may not be aligned
Evan Green [Tue, 12 Nov 2019 22:17:37 +0000 (14:17 -0800)] 
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>
4 years agolsblk: add FSVER (filesystem version) column
Karel Zak [Tue, 12 Nov 2019 12:55:55 +0000 (13:55 +0100)] 
lsblk: add FSVER (filesystem version) column

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoagetty: add --show-issue to review issue output
Karel Zak [Tue, 12 Nov 2019 10:15:38 +0000 (11:15 +0100)] 
agetty: add --show-issue to review issue output

Let's make life easier for admins and allow to review issue file
output on the current terminal without all full agetty execution. Use
case is pretty simple:

 # $EDITOR /etc/issue
 # agetty --show-issue

Addresses: https://github.com/karelzak/util-linux/issues/828
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoagetty: add support for /run/issue and /usr/lib/issue
Karel Zak [Tue, 12 Nov 2019 09:10:02 +0000 (10:10 +0100)] 
agetty: add support for /run/issue and /usr/lib/issue

Addresses: https://github.com/karelzak/util-linux/issues/828
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: introduce $sysconfstaticdir
Karel Zak [Mon, 11 Nov 2019 12:08:04 +0000 (13:08 +0100)] 
build-sys: introduce $sysconfstaticdir

The current situation is that distros differentiate between:

* host specific configuration -- usually /etc, maintained by admin

* distribution specific (static) configuration -- usually /usr/lib,
  maintained by ditro packages

Unfortunately autotools have clue about $sysconfdir (/etc) only. This
patch introduces $sysconfstaticdir (default $prefix/lib).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agorenice: fix arguments description in --help
Karel Zak [Fri, 8 Nov 2019 10:32:18 +0000 (11:32 +0100)] 
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>
4 years agorenice: fix --help text
Karel Zak [Fri, 8 Nov 2019 10:22:57 +0000 (11:22 +0100)] 
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>
4 years agofallocate.1: List gfs2 as supporting punch-hole
Andrew Price [Thu, 31 Oct 2019 16:51:44 +0000 (16:51 +0000)] 
fallocate.1: List gfs2 as supporting punch-hole

Signed-off-by: Andrew Price <anprice@redhat.com>
4 years agohwclock: add SPDX-License-Identifier(s)
Karel Zak [Fri, 8 Nov 2019 10:12:13 +0000 (11:12 +0100)] 
hwclock: add SPDX-License-Identifier(s)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodocs: add GPLv3 text
Karel Zak [Fri, 8 Nov 2019 10:10:54 +0000 (11:10 +0100)] 
docs: add GPLv3 text

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/timeutils: add %Y-%m-%dT%H:%M:%S to parse_timestamp()
Karel Zak [Fri, 8 Nov 2019 09:42:03 +0000 (10:42 +0100)] 
lib/timeutils: add %Y-%m-%dT%H:%M:%S to parse_timestamp()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib: add missing license headers
Karel Zak [Fri, 8 Nov 2019 09:40:42 +0000 (10:40 +0100)] 
lib: add missing license headers

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: .gitignore hwclock-parse-date.c
Karel Zak [Thu, 7 Nov 2019 09:43:46 +0000 (10:43 +0100)] 
build-sys: .gitignore hwclock-parse-date.c

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib: add missing license headers
Karel Zak [Thu, 7 Nov 2019 08:38:06 +0000 (09:38 +0100)] 
lib: add missing license headers

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: use parse-date() only for hwclock
Karel Zak [Thu, 7 Nov 2019 08:02:23 +0000 (09:02 +0100)] 
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>
4 years agolibblkid: open device in nonblock mode.
Michal Suchanek [Mon, 4 Nov 2019 20:23:15 +0000 (21:23 +0100)] 
libblkid: open device in nonblock mode.

When autoclose is set (kernel default but many distributions reverse the
setting) opening a CD-rom device causes the tray to close.

The function of blkid is to report the current state of the device and
not to change it. Hence it should use O_NONBLOCK when opening the
device to avoid closing a CD-rom tray.

blkid is used liberally in scripts so it can potentially interfere with
the user operating the CD-rom hardware.

[kzak@redhat.com: add O_NONBLOCK also to:
                  - wipefs
                  - blkid_new_probe_from_filename()
                  - blkid_evaluate_tag()]

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: commit add missing file
Karel Zak [Tue, 5 Nov 2019 14:42:19 +0000 (15:42 +0100)] 
tests: commit add missing file

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: add mount --all tests
Karel Zak [Tue, 5 Nov 2019 14:14:17 +0000 (15:14 +0100)] 
tests: add mount --all tests

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: make sure optsmode is initialized
Karel Zak [Thu, 31 Oct 2019 12:51:29 +0000 (13:51 +0100)] 
libmount: make sure optsmode is initialized

Since 34333e5244167a8f6385faa350938ed5cb6d5c0a we apply fstab options
manually by mnt_context_apply_fs() on --all. The function does not
work correctly when optsmode is zero.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomount: (man) document --target-prefix
Karel Zak [Thu, 31 Oct 2019 11:24:17 +0000 (12:24 +0100)] 
mount: (man) document --target-prefix

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: allow use -o together with --all
Karel Zak [Thu, 31 Oct 2019 11:10:03 +0000 (12:10 +0100)] 
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>
4 years agolibmount: move context fs merge to separate function
Karel Zak [Thu, 31 Oct 2019 10:52:17 +0000 (11:52 +0100)] 
libmount: move context fs merge to separate function

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix mnt_context_next_remount()
Karel Zak [Thu, 31 Oct 2019 09:34:12 +0000 (10:34 +0100)] 
libmount: fix mnt_context_next_remount()

The current implementation works, but the remount operation is done in
the cloned context and the original context (and calling application)
has no information about the final status/errors. This is mistake.

This new implementation works like mnt_context_next_mount(), it means
the same context (as used by application) is reused for all remounts.
The original setting is restored by mnt_context_apply_template().

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: save current FS setting as template
Karel Zak [Thu, 31 Oct 2019 09:31:53 +0000 (10:31 +0100)] 
libmount: save current FS setting as template

This commit adds new functions to save and reuse the current FS
setting (mount options from command line, etc) after context reset.
It's usable for example in "mount --all" when we use the same context
for more times for more mount operations.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: consolidate strdup() use
Karel Zak [Wed, 23 Oct 2019 11:00:40 +0000 (13:00 +0200)] 
libfdisk: consolidate strdup() use

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: use strdup_between_structs()
Karel Zak [Wed, 23 Oct 2019 10:30:19 +0000 (12:30 +0200)] 
libmount: use strdup_between_structs()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/strutils: add strdup_between_structs()
Karel Zak [Wed, 23 Oct 2019 10:28:09 +0000 (12:28 +0200)] 
include/strutils: add strdup_between_structs()

* improve strdup_to_offset() readability

* add strdup_between_offsets() and strdup_between_structs() to have
  better support for use-cases when we copy structs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: cleanup strdup() use in context, add reg.test
Karel Zak [Wed, 23 Oct 2019 10:02:33 +0000 (12:02 +0200)] 
libmount: cleanup strdup() use in context, add reg.test

* don't ignore strdup() result
* cleanup mnt_context_prepare_helper() to have only one return point
  (due to mnt_context_switch_ns())
* add mnt_context_prepare_helper() test program

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomount: add --target-prefix
Karel Zak [Tue, 22 Oct 2019 11:37:12 +0000 (13:37 +0200)] 
mount: add --target-prefix

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: add target prefix support
Karel Zak [Tue, 22 Oct 2019 11:35:05 +0000 (13:35 +0200)] 
libmount: add target prefix support

* add set/get functions to context
* use prefix to detect already mounted filesystems
* use prefix when prepare target path

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: never fallback to udev/blkid on --sysroot
Karel Zak [Tue, 29 Oct 2019 12:12:18 +0000 (13:12 +0100)] 
lsblk: never fallback to udev/blkid on --sysroot

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: don't use /proc/mounts fallback if filename specified
Karel Zak [Tue, 29 Oct 2019 11:59:08 +0000 (12:59 +0100)] 
libmount: don't use /proc/mounts fallback if filename specified

The current solution is to use /proc/mounts if previous attempt to
open /proc/self/mountinfo failed. The fallback should not be used when
mount table path is explicitly specified by application. The default
is NULL, only in this case libmount should be try to be smart.

Reported-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosu: fix error message
Karel Zak [Tue, 29 Oct 2019 09:04:29 +0000 (10:04 +0100)] 
su: fix error message

Reported-by: Pedro Albuquerque <palbuquerque73@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'blkid-sparc' of https://github.com/mator/util-linux
Karel Zak [Wed, 23 Oct 2019 11:14:45 +0000 (13:14 +0200)] 
Merge branch 'blkid-sparc' of https://github.com/mator/util-linux

* 'blkid-sparc' of https://github.com/mator/util-linux:
  tests: fixes blkid/md-raidX-whole on Sparc

4 years agotests: fixes blkid/md-raidX-whole on Sparc
Anatoly Pugachev [Wed, 23 Oct 2019 08:26:19 +0000 (11:26 +0300)] 
tests: fixes blkid/md-raidX-whole on Sparc

Since SPARC is using 'sun' partition table by default, make test not to
assume that disk has 'dos' partition table, so write 'dos' partition
table on disk, before proceeding any further.

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
4 years agolsblk: update man description of -f / --fs for current columns
Vladimir Slavik [Thu, 17 Oct 2019 11:45:48 +0000 (13:45 +0200)] 
lsblk: update man description of -f / --fs for current columns

see lsblk.c line 1930

4 years agolib/path: fix missing header for `struct stat`
Patrick Steinhardt [Thu, 17 Oct 2019 06:00:31 +0000 (08:00 +0200)] 
lib/path: fix missing header for `struct stat`

In commit b1418ed14 (lib/path: add ul_path_stat(), fix absolute paths,
2019-10-15), a new function `ul_path_stat()` was added to "path.h". This
new function prototype causes a compiler warning on musl libc based
systems due to one of the parameters having the unknown type `struct
stat` due to the <sys/stat.h> header not being included.

Fix the warning by including the header.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agoMerge branch 'master' of https://github.com/smvoss/util-linux
Karel Zak [Thu, 17 Oct 2019 09:03:16 +0000 (11:03 +0200)] 
Merge branch 'master' of https://github.com/smvoss/util-linux

* 'master' of https://github.com/smvoss/util-linux:
  wipefs: Allow explicitly enable/disablement

4 years agomount: (man) small typo fixes
Merlin Büge [Thu, 17 Oct 2019 04:45:22 +0000 (06:45 +0200)] 
mount: (man) small typo fixes

4 years agodocs: remove implemented TODO items
Karel Zak [Thu, 17 Oct 2019 08:54:15 +0000 (10:54 +0200)] 
docs: remove implemented TODO items

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agologin: reduce file-descriptors cleanup overhead
Karel Zak [Thu, 17 Oct 2019 08:41:39 +0000 (10:41 +0200)] 
login: reduce file-descriptors cleanup overhead

Addresses: https://github.com/karelzak/util-linux/issues/883
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/fileutils: add close_all_fds()
Karel Zak [Thu, 17 Oct 2019 08:36:27 +0000 (10:36 +0200)] 
lib/fileutils: add close_all_fds()

The classic way which is based on file-descriptors table size is
pretty expensive (due to table size) and forces code to do many
unnecessary close() calls. It seems better to use /proc/self/fds and
close used descriptors only.

Addresses: https://github.com/karelzak/util-linux/issues/883
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (lsblk) gather also udev attributes for new dumps
Karel Zak [Tue, 15 Oct 2019 11:29:13 +0000 (13:29 +0200)] 
tests: (lsblk) gather also udev attributes for new dumps

References: 7408a5d9c2e0bb20ac0660ead16b787825ef240e
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: read also GROUP,OWNER and MODE from dumps
Karel Zak [Tue, 15 Oct 2019 11:08:09 +0000 (13:08 +0200)] 
lsblk: read also GROUP,OWNER and MODE from dumps

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: on --sysroot read attributes from /dev/<devname> text file
Karel Zak [Tue, 15 Oct 2019 10:36:16 +0000 (12:36 +0200)] 
lsblk: on --sysroot read attributes from /dev/<devname> text file

The option --sysroot is used to read information from dumps rather
than from the current system. This patch allows to read also udev
attributes from text file in location /sysroot/dev/<devname>. The file
is text file in format NAME=value\n.

Suggested-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: add ul_path_stat(), fix absolute paths
Karel Zak [Tue, 15 Oct 2019 09:59:16 +0000 (11:59 +0200)] 
lib/path: add ul_path_stat(), fix absolute paths

* add ul_path_stat()

* make sure all paths for ul_path_..() functions are always
interpreted relatively to the context directory and prefix. This is
difference between ul_path_ API and standard libc "at" functions. We
do not use any exception for absolute paths. The reason is that we
need to read from prefixed paths although application assume absolute
path (/dev/sda1 means /prefix/dev/sda1 if a /prefix is defined).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agowipefs: Allow explicitly enable/disablement
Sam Voss [Tue, 15 Oct 2019 02:19:16 +0000 (21:19 -0500)] 
wipefs: Allow explicitly enable/disablement

Currently if `--disable-all-packages` is set, there is no configure
option for re-enabling `wipefs`.

As the current default for `wipefs` is "enabled", add `--disable-` flag
to maintain backward compatibility.

Signed-off-by: Sam Voss <sam.voss@gmail.com>
4 years agolibmount: Add libselinux dependency to pkgconfig file
Masami Hiramatsu [Fri, 11 Oct 2019 07:15:35 +0000 (16:15 +0900)] 
libmount: Add libselinux dependency to pkgconfig file

Add libselinux dependency to libmount if it is compiled
with selinux support.

Without this fix, 'pkg-config --libs --static mount' doesn't
show libselinux related options.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
4 years agolscpu: Add HiSilicon aarch64 tsv110 cpupart
John Garry [Tue, 8 Oct 2019 13:12:21 +0000 (21:12 +0800)] 
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>
4 years agonologin: Prevent error from su -c
Stanislav Brabec [Wed, 9 Oct 2019 23:08:25 +0000 (01:08 +0200)] 
nologin: Prevent error from su -c

"su -c" can pass "-c" to nologin. It causes ugly error:

su -c "echo OK" - man
-nologin: invalid option -- 'c'
Try '-nologin --help' for more information.

Accept -c to prevent this error.

Signed-off-by: Josef Cejka <jcejka@suse.com>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>