Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)
Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.
Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Karel Zak [Tue, 19 May 2020 08:55:20 +0000 (10:55 +0200)]
agetty: extend --issue-file to support multiple paths
The current default behavior is to print the first issue file/dir and
all alternative locations are used as a backup solution only. If something
is found than the rest is ignored. The --issue-file allow to overwrite
this default behavior, but currently it supports only one file/dir.
This patch extend --issue-file to support ':' separated list of paths
and *all* the files (if exist and no empty) in the list are printed.
Karel Zak [Mon, 18 May 2020 12:13:33 +0000 (14:13 +0200)]
libfdisk: (dos) be more robust about max number of partitions
It seems the previous MAXIMUM_PARTS bug fix has not been generic
enough. Let's use the check for all dos_add_partition().
This patch also remove libfdisk attempt to be smart and search for
unused primary partition. If you need more than 60 partition in MBR
than you have a different problem that cannot be solved by libfdisk
...
References: http://github.com/karelzak/util-linux/commit/b80fb30a5b79ce2cc8c7486e1435ec061aa79e2f
Addresses: https://github.com/karelzak/util-linux/issues/1022 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 18 May 2020 09:21:22 +0000 (11:21 +0200)]
Merge branch 'cal_column' of https://github.com/utix/util-linux
* 'cal_column' of https://github.com/utix/util-linux:
cal: Remove todo
cal: Add test, all are checked against ncal
cal: Update man page
cal: Add column mode
cal: Add helper functions for left align
cal: Add weekdays into cal_control
Michael Kerrisk [Sat, 16 May 2020 07:45:11 +0000 (09:45 +0200)]
ipcs.1: ipcs no longer needs read permission on IPC resources
With changes starting around util-linux commit 058e81540fbb0d2b78
that switched from using IPC_STAT to parsing /proc/sysvipc/*,
ipcs now shows all IPC objects rather than just the objects for
which the user has read permission. Update the page to reflect this
fact, and also add a NOTES section describing the historical and
fallback behavior where /proc is not available.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
an-old.tmac: <./sys-utils/mount.8>:2427 (.RE): warning: extra .RE or .RS is missing before it; "an-RS-open" is 0.
Input file is ././sys-utils/unshare.1
<./sys-utils/unshare.1>:176 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:181 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:240 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:246 (macro BR): only 1 argument, but more are expected
Input file is ././term-utils/agetty.8
troff: backtrace: file '<./term-utils/agetty.8>':130
troff: <./term-utils/agetty.8>:130: warning: trailing space
Input file is ././text-utils/more.1
troff: backtrace: file '<./text-utils/more.1>':91
troff: <./text-utils/more.1>:91: warning: macro 'b' not defined
The output from nroff and troff is unchanged, except for the word
"number" in text-utils/more.1, that was missing.
If a user submits a zone management ioctl from user-space, like a zone
reset and a file-system (like zonefs or f2fs) is mounted on the zoned
block device, the zone will get reset and the file-system's cached value
of the zone's write-pointer becomes invalid.
Subsequent writes to this zone from the file-system will result in
unaligned writes and the drive will error out.
Open the block device file in exclusive mode for submitting these ioctls.
If a file-system is mounted the kernel will return -EBUSY and we can't
continue issuing the ioctl.
Reported-by: Coly Li <colyli@suse.de> Cc: Damien Le Moal <Damien.LeMoal@wdc.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Lsblk throws the following error for nvmeNcXnY devices.
lsblk: nvme1c1n1: unknown device name
This is because nvmeNcXnY devices are hidden and do not have
the file /sys/block/<nvmeNcXnY>/dev.
Following patch was added
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=d51f05bfecb299a830897106460bf395be440c0a
Which made lsblk read from /sys/block/<nvmeNcXnY>/device/dev
which do exist for nvmeNcXnY devices.
After the above patch, the unknown error goes away.
However, another error is encountered in the very next step.
nvme1c1n1: failed to initialize sysfs handler
This is because lsblk looks for /sys/dev/block/242:1
(nvmeNcXnY major:minor) pathname which usually exists for other
block devices but not for the nvmeNcXnY devices as they are hidden.
Below patch does not even print this error for hidden devices
and exits silently.
[kzak@redhat.com: - add prefix to make sysfs_devname_is_hidden()
usable for /sys dumps
- use the function in initialize_device() more early]
Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com> Signed-off-by: Karel Zak <kzak@redhat.com>
It seems that directories like /etc/motd.d are already used by PAM or
by another stuff. Let's keep it in admin/distro hands and do not
change the current default.
Karel Zak [Tue, 12 May 2020 12:20:54 +0000 (14:20 +0200)]
login: add support for directories in MOTD_FILE=
The current standard is to use directories to make it easy for
distributions to share resources. This patch also add /etc/motd.d
and /run/motd.d to the default MOTD_FILE=.
Addresses: https://github.com/karelzak/util-linux/issues/10341 Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Wed, 6 May 2020 19:19:23 +0000 (20:19 +0100)]
more: make page and arrow up/down to update view
Aim was to introduce page and arrow up/down keys to more(1), but that
also required merging colon_command() and more_key_command() functions.
The more_key_commands enum is pointless from computers point of view.
The command identification performed in read_command() inline with
more_key_command() execution -- but that would be hard for humans, and
source code ought to serve both parties.
Reference: https://github.com/karelzak/util-linux/pull/1003 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Wed, 6 May 2020 19:19:22 +0000 (20:19 +0100)]
more: use libmagic to identify binary files
As the old commend said: 'This code would best be shared with the file(1)
program or, perhaps, more should not try to be so smart'. Now at configure
time one can choose whether more(1) is sharing code with file(1), or not.
Addresses: http://bugs.debian.org/139205 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Wolfram Sang [Mon, 11 May 2020 16:10:48 +0000 (18:10 +0200)]
sfdisk: avoid unneeded empty lines with '--list-free'
Similar to commit 4a52959d1 ("(s)fdisk: avoid unneeded empty lines with
'--list'"), there were also two superfluous empty lines when /dev/sr0
didn't contain a medium. Refactor the '--list-free' code the same way as
in the mentioned commit.
Wolfram Sang [Wed, 6 May 2020 10:39:21 +0000 (12:39 +0200)]
(s)fdisk: avoid unneeded empty lines with '--list'
On my system, I got two superfluous empty lines because /dev/sr0 didn't
contain a medium. Refactor the code to handle the seperator within
print_device_pt() and print it only when assigning the device worked.
This unifies handling between print_all_devices_pt and (s)fdisk because
the latter did not consider the return code for the seperator while the
former did. Also, it saves some lines of code.
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814184 (first part) Signed-off-by: Wolfram Sang <wsa@kernel.org>
libblkid: add dax capability detection in topology probing
The dax (direct access) blockdev capability is exposed via sysfs, add it
to the list of topology values to be obtained while probing.
Expose blkid_topology_get_dax() symbol that programs can link against
for querying the capability.
Reorder the idinfos array to give precedence to the sysfs over ioctl so
that the dax probe has a chance to be executed, as there is no ioctl
interface for it.
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Mark Hindley [Tue, 5 May 2020 19:28:55 +0000 (21:28 +0200)]
tests: Fix for misc/fallocate test build failure.
This was already a known possible failure case. However, in the migration to a
clearer separation of stdout and stderr in the testsuite, the logfile used to
detect the failure was not updated.
Karel Zak [Mon, 4 May 2020 10:27:42 +0000 (12:27 +0200)]
agetty: save the original speed on --keep-baud
agetty cycling through the baud rates specified on command line
(triggered by BREAK). Unfortunately, the original baud rate (probably
the best one) is tried only first time on --keep-baud.
Addresses: https://github.com/karelzak/util-linux/issues/1025 Signed-off-by: Karel Zak <kzak@redhat.com>
Sven Wiltink [Fri, 1 May 2020 14:35:40 +0000 (16:35 +0200)]
lsblk: Fall back to ID_SERIAL
In some cases ID_SERIAL_SHORT isn't provided by libudev, but ID_SERIAL
is. An example of this are virtio devices. See the output of udevadm
info:
P: /devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
N: vdb
S: disk/by-id/virtio-08491434ee711d3420e9
S: disk/by-path/pci-0000:00:06.0
S: disk/by-path/virtio-pci-0000:00:06.0
E: DEVLINKS=/dev/disk/by-id/virtio-08491434ee711d3420e9 /dev/disk/by-path/pci-0000:00:06.0 /dev/disk/by-path/virtio-pci-0000:00:06.0
E: DEVNAME=/dev/vdb
E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
E: DEVTYPE=disk
E: ID_PATH=pci-0000:00:06.0
E: ID_PATH_TAG=pci-0000_00_06_0
E: ID_SERIAL=08491434ee711d3420e9
E: MAJOR=252
E: MINOR=16
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=1403804
[kzak@redhat.com: - add ID_SERIAL also to get_properties_by_file()]
After unshare(...) is called, /proc/self/ns/pid does not change.
Instead, only /proc/self/ns/pid_for_children is affected. So bind-mounting
/proc/self/ns/pid results in the original namespace getting bind-mounted.
Fix this by instead bind-mounting ns/pid_for_children.
That is so since on kernel cifs code, cifs_get_root (which returns the
entry associated with mnt_root) return s_root if
CIFS_MOUNT_USE_PREFIX_PATH is set, no questions asked.
This situation can occurr often on CIFS mounts, as CIFS servers limit
frequently scope of access to the root path.
[kzak@redhat.com: - add more info to the commit message,
- clean up variable names]
Luca BRUNO [Mon, 27 Apr 2020 10:06:07 +0000 (10:06 +0000)]
fstrim: run service and timer only if /etc/fstab is present
The timer and service units run `fstrim --fstab`, which strictly
depends on `/etc/fstab` being present in the OS. This adds relevant
condition statements to the units, in order to skip them and avoid
runtime failures.
Stephen Kitt [Thu, 23 Apr 2020 08:37:02 +0000 (10:37 +0200)]
docs: nsenter(1): fix further details in PID namespace section
The "Further details" sentence in the PID namespace section got merged
with the surrounding text; this patch moves it to the end, to match
the other namespace sections, and adds the missing clone(2) reference.
Fixes: 894efece9eb89 ("Provide better cross references for namespace concepts") Signed-off-by: Stephen Kitt <steve@sk2.org>
Karel Zak [Wed, 22 Apr 2020 12:57:33 +0000 (14:57 +0200)]
sfdisk: only report I/O errors on --move-data
Now sfdisk stops everything on I/O error when moving data. It seems
better to report the error to user and continue as it's better to have
one bad sector in the partition than inconsistent all partition.
Addresses: https://github.com/karelzak/util-linux/issues/984 Signed-off-by: Karel Zak <kzak@redhat.com>
Tycho Andersen [Thu, 9 Jan 2020 23:52:41 +0000 (16:52 -0700)]
libmount: do not unnecessarily chmod utab.lock
Before ecfeae90a294 ("libmount: Ensure utab.lock mode 644"), you could do
something like:
irc:/tmp umount --version
umount from util-linux 2.27.1 (libmount 2.27.0: selinux, assert, debug)
irc:/tmp mkdir foo bar
irc:/tmp unshare -Urm
irc:/tmp mount --bind foo bar
irc:/tmp umount bar
irc:/tmp echo $?
0
However, afterwards, you get:
/tmp unshare -Urm
/tmp mount --bind foo bar
/tmp umount bar
umount: /tmp/bar: filesystem was unmounted, but failed to update userspace mount table.
Because of the chmod failing:
fchmod(3, 0644) = -1 EPERM (Operation not permitted)
Let's figure out whether the chmod is necessary before doing it, and only
do it if it is necessary. This won't fix cases where the system is already
broken, but at least on healthy systems umount will behave as before.
Karel Zak [Wed, 22 Apr 2020 10:22:29 +0000 (12:22 +0200)]
lib/mbsalign: add function to calculate width
We already have mbs_safe_nwidth() but it assumes that all "bad" chars
will be encoded by \x<hex>. Now we need also function that do not care
about encoding.
Karel Zak [Wed, 22 Apr 2020 08:07:51 +0000 (10:07 +0200)]
Merge branch 'clang' of https://github.com/neheb/util-linux
* 'clang' of https://github.com/neheb/util-linux:
[clang-tidy] fix misleading identation
[clang-tidy] use ceil
[clang-tidy] fix wrong *cmp usage
[clang-tidy] do not use else after return
[clang-tidy] do not return in void functions
[clang-tidy] fix mismatching declarations
Karel Zak [Fri, 17 Apr 2020 09:02:29 +0000 (11:02 +0200)]
Merge branch 'map-user' of https://github.com/mat8913/util-linux
* 'map-user' of https://github.com/mat8913/util-linux:
unshare: Support names for map-user/group options
lib/pwdutils: add xgetgrnam
unshare: allow custom uid/gid mappings in userns
Karel Zak [Tue, 14 Apr 2020 09:29:25 +0000 (11:29 +0200)]
Merge branch '2020wk13' of https://github.com/kerolasa/util-linux
* '2020wk13' of https://github.com/kerolasa/util-linux:
include: add remove_entry() to env.h
tests: add sanitize_env() check
more: fix moving backwards so that it can reach begining of the file
more: use getopt_long() to parse options
more: remove underlining related code
more: fix SIGSTOP and SIGCONT handling
more: make execute() more robust and timely
more: target all standard streams when calling fflush()
more: remove kill_line() in favor of erase_prompt()
more: avoid defining special characters locally
more: use off_t and cc_t to clarify what variables attempt to represent
more: do not reset parent process terminal in execute()
more: use single exit path to ensure resource freeing is unified
This PR fixes an off by one in `strncmp(dev->bid_name, "/dev/mapper/", 11)` check. The `"/dev/mapper/"` string literal has a length of 12 and without this fix paths like `"/dev/mapperSOMETHING"` would also be accepted.
Sami Kerola [Sun, 12 Apr 2020 07:53:32 +0000 (08:53 +0100)]
include: add remove_entry() to env.h
A function to remove an command-line option argument, or environment
variable.
Requested-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1003#discussion_r403988092 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sun, 29 Mar 2020 13:52:19 +0000 (14:52 +0100)]
more: fix moving backwards so that it can reach begining of the file
Moving backwards has worked fine until reaching start of file. At that
point more printout had one line too much in output causing more seemingly
never to be able to reach the start. That is now fixed, with clean ups to
skip_backwards() making it less confusing.
Sami Kerola [Sat, 28 Mar 2020 15:09:00 +0000 (15:09 +0000)]
more: use getopt_long() to parse options
This commit also includes fix to how initial skip lines and search are
instructed in the code. Earlier version was pretty close impossible to make
work with getopt_long() and had minor flaw - if both initial skip lines and
search were defined at the same time the skipping did not happen. That is
now corrected.
Sami Kerola [Sat, 28 Mar 2020 10:17:46 +0000 (10:17 +0000)]
more: fix SIGSTOP and SIGCONT handling
When suspending only the more process. Sending signal to process group
makes signal destination unnecessarily vague. After the suspend is over
SIGCONT is expected, and it needs to ensure output terminal settings are
what more needs.
Sami Kerola [Sat, 28 Mar 2020 10:00:08 +0000 (10:00 +0000)]
more: make execute() more robust and timely
The wait() is now a little more robust by being more tolerate rogue SIGCHLDs
and unblocked signals. The repeated fork() and sleep() is removed, if first
try does not success give up without delay to provide user timely feedback.
Sami Kerola [Sat, 21 Mar 2020 17:45:47 +0000 (17:45 +0000)]
more: target all standard streams when calling fflush()
If streams need to be flushed do not try to be clever, just flush all of
them. That lead to finding unnecessary print out in run_shell() that is
removed in this commit.
Sami Kerola [Sat, 21 Mar 2020 15:59:04 +0000 (15:59 +0000)]
more: avoid defining special characters locally
The sys/ttydefaults.h can be used for CTRL() and rubout that is CERASE. For
alarm it's best to keep things simple and call printf() alarm modifier.
QUIT was not in use, so it is just deleted.
Sami Kerola [Sat, 21 Mar 2020 09:30:57 +0000 (09:30 +0000)]
more: use single exit path to ensure resource freeing is unified
And be a little more complete all the allocations that can be released are,
but there is a small catch. As mentioned in ncurses FAQ some leaks are
intentional, and that's the way they are.
Reference: https://invisible-island.net/ncurses/ncurses.faq.html#config_leaks
Reference: http://man7.org/linux/man-pages/man3/_nc_free_tinfo.3x.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Two new options are added: `--map-user=<uid>` and `--map-group=<gid>`
for custom user and group mappings respectively. These are just
generalizations of the existing `--map-root-user` and
`--map-current-user` options.
As a side effect of this commit, specifying both `--map-root-user` and
`--map-current-user` no longer causes an error. Instead, the last
occurrence takes precedence.
Addresses: https://github.com/karelzak/util-linux/issues/885 Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
libmount: Avoid triggering autofs in lookup_umount_fs_by_statfs
Currently, umount /foo results in a statfs("/foo") call, which triggers
autofs. This can create another mountpoint on /foo, which is then unmounted
later instead of the actual /foo at the time umount was called.
This is especially an issue for umount -R /bar, which just fails with
-EBUSY as the accidental mountpoint is never accounted for and so it tries
to umount /bar before /bar/someautofs.
Replace the direct statfs call with open(path, O_PATH) + fstatfs, which sees
the autofs mount directly, without triggering it.
Aurelien LAJOIE [Sat, 28 Mar 2020 22:33:41 +0000 (23:33 +0100)]
cal: correctly set the week width
There is seven values but only 6 spaces between them, that why the -1
The value is always used with a minus one, just set it correctly instead
of always fix when used
Aurelien LAJOIE [Thu, 26 Mar 2020 14:38:27 +0000 (15:38 +0100)]
libuuid: improve uuid_unparse() performance
There is 2 improvements:
* remove useless uuid_unpack,
* directly print the hexa format from memory without using printf
we can do this as the bytes order is the network byte order
https://tools.ietf.org/html/rfc4122#section-4.1.2
even the spatially unique node identifier(the last 6 bytes)
The improvement is important, some results for 1000000 uuid_unparse calls:
Little Endian Ubuntu:
before took 382623 us
after took 36740 us
Big Endian OpenBSD:
before took 3138172 us
after took 180116 us
Karel Zak [Tue, 31 Mar 2020 11:17:20 +0000 (13:17 +0200)]
Merge branch 'more' of https://github.com/kerolasa/util-linux
* 'more' of https://github.com/kerolasa/util-linux:
more: refactor and clarify code
more: add display_file() to show files and stdin
more: simplify initterm()
more: move currently open file to control structure
more: move code blocks from more_key_command() to functions
more: move runtime usage output to a function
more: restructure print_buf() if-else with continue
more: tell in run time help what the 'v' will execute as editor
more: drop setuid permissions before executing anything
more: do not allocate shell command buffer from stack
more: replace siglongjmp() and signal() calls with signalfd()