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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Since 34333e5244 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>
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>
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>
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>
* 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>
* 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>
* 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>
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>
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>
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>
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>