]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
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>
4 years agotests: add missing 'ts_check_prog xz'
Karel Zak [Thu, 10 Oct 2019 07:07:10 +0000 (09:07 +0200)] 
tests: add missing 'ts_check_prog xz'

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: fix compilation
Karel Zak [Thu, 10 Oct 2019 06:57:30 +0000 (08:57 +0200)] 
lib/pty-session: fix compilation

lib/test_pty-monotonic.o: In function `get_boot_time':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:29: undefined reference to `clock_gettime'
lib/test_pty-monotonic.o: In function `gettime_monotonic':
/home/travis/build/karelzak/util-linux/lib/monotonic.c:56: undefined reference to `clock_gettime'

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: remove device name from blkdiscard output
Karel Zak [Wed, 9 Oct 2019 14:57:24 +0000 (16:57 +0200)] 
tests: remove device name from blkdiscard output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: fix signalfd use
Karel Zak [Wed, 9 Oct 2019 14:43:50 +0000 (16:43 +0200)] 
script: fix signalfd use

It's necessary to create signal-fd before fork() to get SIGCHLD,
because child could be faster than our code.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: add debug messages around waitpid()
Karel Zak [Wed, 9 Oct 2019 13:07:49 +0000 (15:07 +0200)] 
script: add debug messages around waitpid()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: add --parsable, remove TS_OPT_parsable
Karel Zak [Wed, 9 Oct 2019 10:57:10 +0000 (12:57 +0200)] 
tests: add --parsable, remove TS_OPT_parsable

* don't enable parsable for non-parallel executions in travis
* add --parsable to run.sh
* use --parsable rather than TS_OPT_ in travis

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: cleanup prefixed used for tests
Karel Zak [Wed, 9 Oct 2019 10:31:28 +0000 (12:31 +0200)] 
build-sys: cleanup prefixed used for tests

It's ugly to use the same TS_ prefix in tests as well as in
build-system (e.g. make check), because then some env. variable can be
interpreted by our regression tests. For example TS_PARALLEL=.

It's seems better to use TS_ exclusively for tests and TESTS_ for
build-system.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: support 'none' for parallel tests
Karel Zak [Wed, 9 Oct 2019 10:01:57 +0000 (12:01 +0200)] 
build-sys: support 'none' for parallel tests

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotravis: force non-parallel for root
Karel Zak [Wed, 9 Oct 2019 09:36:52 +0000 (11:36 +0200)] 
travis: force non-parallel for root

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: fix typo
Karel Zak [Wed, 9 Oct 2019 08:02:10 +0000 (10:02 +0200)] 
build-sys: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotravis: don't call tests in parallel for root
Karel Zak [Wed, 9 Oct 2019 07:55:27 +0000 (09:55 +0200)] 
travis: don't call tests in parallel for root

Let's make it more readable in logs for root user.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: cleanup logs freeing
Karel Zak [Tue, 8 Oct 2019 12:20:39 +0000 (14:20 +0200)] 
script: cleanup logs freeing

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: remove unnecessary variables
Karel Zak [Mon, 7 Oct 2019 10:35:00 +0000 (12:35 +0200)] 
scriptlive: remove unnecessary variables

ul_pty code is able to do all necessary things for us, so don't waste
effort and keep the child variable in main() only.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: simplify example/test code
Karel Zak [Mon, 7 Oct 2019 10:30:16 +0000 (12:30 +0200)] 
lib/pty-session: simplify example/test code

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: make wait_child callback optional
Karel Zak [Mon, 7 Oct 2019 10:24:43 +0000 (12:24 +0200)] 
lib/pty-session: make wait_child callback optional

Now the code is duplicate on many places, but all we usually need is to
remember child status. It seems good enough to have very simple
callback child_die() to inform application about a change.

The patch also add PID to all signal related callbacks.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: use lib/pty-session
Karel Zak [Thu, 3 Oct 2019 12:33:25 +0000 (14:33 +0200)] 
script: use lib/pty-session

This patch consolidate pseudo-terminal stuff in util-linux. From now
there is only one implementation used in su(1) --pty, scriptlive(1)
and script(1).

The new stuff is based on the original script(1) -- it means poll()
and signalfd() based.

Note that script(1) code does not provide fallback for systems/libc
where is no openpty().

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: translate error messages too
Karel Zak [Thu, 3 Oct 2019 11:28:37 +0000 (13:28 +0200)] 
scriptlive: translate error messages too

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: add loggin callback to code, follow return codes
Karel Zak [Thu, 3 Oct 2019 11:23:41 +0000 (13:23 +0200)] 
lib/pty-session: add loggin callback to code, follow return codes

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: add log callbacks
Karel Zak [Wed, 2 Oct 2019 15:34:51 +0000 (17:34 +0200)] 
lib/pty-session: add log callbacks

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: add man page
Karel Zak [Wed, 2 Oct 2019 14:55:15 +0000 (16:55 +0200)] 
scriptlive: add man page

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: fix io data log use
Karel Zak [Wed, 2 Oct 2019 14:13:25 +0000 (16:13 +0200)] 
scriptreplay: fix io data log use

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: make data log file optional for --summary
Karel Zak [Wed, 2 Oct 2019 12:22:12 +0000 (14:22 +0200)] 
scriptreplay: make data log file optional for --summary

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: fix man page on --logging-format
Karel Zak [Wed, 2 Oct 2019 12:05:01 +0000 (14:05 +0200)] 
script: fix man page on --logging-format

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: improve debug messages
Karel Zak [Fri, 9 Aug 2019 08:22:27 +0000 (10:22 +0200)] 
lib/pty-session: improve debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: free resource at the and
Karel Zak [Thu, 8 Aug 2019 13:36:04 +0000 (15:36 +0200)] 
scriptlive: free resource at the and

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty: save sigmask, add API to free all resources
Karel Zak [Thu, 8 Aug 2019 13:34:00 +0000 (15:34 +0200)] 
lib/pty: save sigmask, add API to free all resources

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosu: (pty) remove unnecessary call
Karel Zak [Thu, 8 Aug 2019 13:32:13 +0000 (15:32 +0200)] 
su: (pty) remove unnecessary call

The pty code has to save the original signal mask without application
assistance.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: fix build with pty
Karel Zak [Thu, 8 Aug 2019 13:08:14 +0000 (15:08 +0200)] 
build-sys: fix build  with pty

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty: reset mainloop timeout on signal
Karel Zak [Wed, 31 Jul 2019 09:57:26 +0000 (11:57 +0200)] 
lib/pty: reset mainloop timeout on signal

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: add -T, --log-timing
Karel Zak [Tue, 30 Jul 2019 12:59:34 +0000 (14:59 +0200)] 
scriptreplay: add -T, --log-timing

Add alias to -t,--timing to make it easy to copy and past script(1)
comnand line to scriptlive(1) and scriptreplay(1) command lines.
For example:

record:
  $ script --log-timing tm --log-in in

print:
  $ scriptreplay --log-timing tm --log-in in

re-run:
  $ scriptlive --log-timing tm --log-in in

And command line is still the same.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: run shell in PTY
Karel Zak [Tue, 30 Jul 2019 12:32:13 +0000 (14:32 +0200)] 
scriptlive: run shell in PTY

After this change shell executed by scriptlive(1) is going to behave
like shell in script(1). It means that the shell stdin is a
pseudo-terminal rather than pipe. This allows live replay of
interactive applications, ssh sessions, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty: allow use callback from mainloop
Karel Zak [Tue, 30 Jul 2019 12:29:20 +0000 (14:29 +0200)] 
lib/pty: allow use callback from mainloop

This allows to control mainloop behavior from PTY applications. For
example you can write to child (shell) process independently on the
current stdin.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: (utils) detect empty steps
Karel Zak [Tue, 30 Jul 2019 12:27:51 +0000 (14:27 +0200)] 
scriptreplay: (utils) detect empty steps

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: use struct timeval for delay
Karel Zak [Mon, 29 Jul 2019 10:50:17 +0000 (12:50 +0200)] 
scriptreplay: use struct timeval for delay

* use timeval rather than double for delay
* use sys/time.h macros for wirk with timeval
* add delay normalization to script-playutils.c API

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocript: always use decimal point numbers in logs
Karel Zak [Mon, 29 Jul 2019 10:43:06 +0000 (12:43 +0200)] 
cript: always use decimal point numbers in logs

The new header/info lines in log uses 0, but it's unexpected by
scriptreplay as there was always number formatted by %f.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: add missing exit()
Karel Zak [Mon, 29 Jul 2019 10:10:22 +0000 (12:10 +0200)] 
script: add missing exit()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosu: use lib/pty-session.c code for --pty
Karel Zak [Thu, 4 Jul 2019 09:59:23 +0000 (11:59 +0200)] 
su: use lib/pty-session.c code for --pty

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/pty-session: add generic PTY container code
Karel Zak [Thu, 4 Jul 2019 09:57:11 +0000 (11:57 +0200)] 
lib/pty-session: add generic PTY container code

The idea is to consolidate script(1), scriptlive(1) and su(1) --pty
and use the same code everywhere.

TODO: add callbacks for stdin/out logging (necessary for script(1)).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptlive: add new command to re-execute script(1) typescript
Karel Zak [Tue, 2 Jul 2019 15:03:53 +0000 (17:03 +0200)] 
scriptlive: add new command to re-execute script(1) typescript

The old good scriptreplay(1) just display your recorded session, the
scriptlive(1) uses stdin typescript (from new script(1)) to execute
your commands again.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: move all utils to script-playutils.{c,h}
Karel Zak [Mon, 1 Jul 2019 13:00:52 +0000 (15:00 +0200)] 
scriptreplay: move all utils to script-playutils.{c,h}

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: add --summary
Karel Zak [Fri, 28 Jun 2019 08:19:40 +0000 (10:19 +0200)] 
scriptreplay: add --summary

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: add more information to timing log
Karel Zak [Fri, 28 Jun 2019 08:01:29 +0000 (10:01 +0200)] 
script: add more information to timing log

Let's record also exit code, duration and start time.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: check for EOF
Karel Zak [Fri, 28 Jun 2019 08:00:53 +0000 (10:00 +0200)] 
scriptreplay: check for EOF

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: cleanup info logging
Karel Zak [Thu, 27 Jun 2019 12:02:47 +0000 (14:02 +0200)] 
script: cleanup info logging

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscriptreplay: print info and signals
Karel Zak [Wed, 26 Jun 2019 15:32:49 +0000 (17:32 +0200)] 
scriptreplay: print info and signals

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: log additional information
Karel Zak [Wed, 26 Jun 2019 15:32:18 +0000 (17:32 +0200)] 
script: log additional information

Signed-off-by: Karel Zak <kzak@redhat.com>