]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
3 years agocal: Add test, all are checked against ncal
Aurelien LAJOIE [Wed, 6 May 2020 20:53:29 +0000 (22:53 +0200)] 
cal: Add test, all are checked against ncal

ncal -M 09 2006
    September 2006
Mo     4 11 18 25
Tu     5 12 19 26
We     6 13 20 27
Th     7 14 21 28
Fr  1  8 15 22 29
Sa  2  9 16 23 30
Su  3 10 17 24

cal -mv 09 2006
    September 2006
Mo     4 11 18 25
Tu     5 12 19 26
We     6 13 20 27
Th     7 14 21 28
Fr  1  8 15 22 29
Sa  2  9 16 23 30
Su  3 10 17 24

For example `vertical-3sjv` `ncal -wjA2 08 2006`
The differences are 3 letters days when julian calendar with cal
Trailing spaces

3 years agocal: Update man page
Aurelien LAJOIE [Mon, 11 May 2020 15:41:33 +0000 (17:41 +0200)] 
cal: Update man page

3 years agocal: Add column mode
Aurelien LAJOIE [Mon, 13 Apr 2020 20:15:30 +0000 (22:15 +0200)] 
cal: Add column mode

Add`-v` `--vertical` option to get a vertical output
Add it into relative bash-completion

For example `cal -yv`

                             2020

    January            February           March
Su     5 12 19 26         2  9 16 23      1  8 15 22 29
Mo     6 13 20 27         3 10 17 24      2  9 16 23 30
Tu     7 14 21 28         4 11 18 25      3 10 17 24 31
We  1  8 15 22 29         5 12 19 26      4 11 18 25
Th  2  9 16 23 30         6 13 20 27      5 12 19 26
Fr  3 10 17 24 31         7 14 21 28      6 13 20 27
Sa  4 11 18 25         1  8 15 22 29      7 14 21 28

    April              May                June
Su     5 12 19 26         3 10 17 24 31      7 14 21 28
Mo     6 13 20 27         4 11 18 25      1  8 15 22 29
Tu     7 14 21 28         5 12 19 26      2  9 16 23 30
We  1  8 15 22 29         6 13 20 27      3 10 17 24
Th  2  9 16 23 30         7 14 21 28      4 11 18 25
Fr  3 10 17 24         1  8 15 22 29      5 12 19 26
Sa  4 11 18 25         2  9 16 23 30      6 13 20 27

    July               August             September
Su     5 12 19 26         2  9 16 23 30      6 13 20 27
Mo     6 13 20 27         3 10 17 24 31      7 14 21 28
Tu     7 14 21 28         4 11 18 25      1  8 15 22 29
We  1  8 15 22 29         5 12 19 26      2  9 16 23 30
Th  2  9 16 23 30         6 13 20 27      3 10 17 24
Fr  3 10 17 24 31         7 14 21 28      4 11 18 25
Sa  4 11 18 25         1  8 15 22 29      5 12 19 26

    October            November           December
Su     4 11 18 25      1  8 15 22 29         6 13 20 27
Mo     5 12 19 26      2  9 16 23 30         7 14 21 28
Tu     6 13 20 27      3 10 17 24         1  8 15 22 29
We     7 14 21 28      4 11 18 25         2  9 16 23 30
Th  1  8 15 22 29      5 12 19 26         3 10 17 24 31
Fr  2  9 16 23 30      6 13 20 27         4 11 18 25
Sa  3 10 17 24 31      7 14 21 28         5 12 19 26

3 years agocal: Add helper functions for left align
Aurelien LAJOIE [Mon, 13 Apr 2020 19:55:24 +0000 (21:55 +0200)] 
cal: Add helper functions for left align

3 years agocal: Add weekdays into cal_control
Aurelien LAJOIE [Mon, 13 Apr 2020 20:00:08 +0000 (22:00 +0200)] 
cal: Add weekdays into cal_control

3 years ago(s)fdisk: avoid unneeded empty lines with '--list'
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>
3 years agodocs: Correct ChangeLog URL to history log.
Anatoly Pugachev [Thu, 7 May 2020 09:17:47 +0000 (12:17 +0300)] 
docs: Correct ChangeLog URL to history log.

Debian is using this to make URL with tagged release, and with the old
URL it does return an empty page.

$ apt info util-linux | grep -i version
Version: 2.35.1-2

$ zcat /usr/share/doc/util-linux/changelog.gz
See version control history.

http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=log;h=2.35.1

^^ empty page

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
3 years agolibblkid: add dax capability detection in topology probing
Anthony Iliopoulos [Tue, 5 May 2020 14:31:45 +0000 (16:31 +0200)] 
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>
3 years agowipefs: fix man page --no-headings short option
Karel Zak [Wed, 6 May 2020 13:18:52 +0000 (15:18 +0200)] 
wipefs: fix man page --no-headings short option

Addresses: https://github.com/karelzak/util-linux/issues/1029
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agofdisk: better wording for '-B' in the man page
Wolfram Sang [Wed, 6 May 2020 10:38:04 +0000 (12:38 +0200)] 
fdisk: better wording for '-B' in the man page

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814184 (second part)
Signed-off-by: Wolfram Sang <wsa@kernel.org>
3 years agofdisk: specify in '--help' that we can have multiple devices with '-l'
Wolfram Sang [Wed, 6 May 2020 10:37:50 +0000 (12:37 +0200)] 
fdisk: specify in '--help' that we can have multiple devices with '-l'

Matches it with the man-page.

Adresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=756187
Signed-off-by: Wolfram Sang <wsa@kernel.org>
3 years agotests: Fix for misc/fallocate test build failure.
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.

Signed-off-by: Mark Hindley <mark@hindley.org.uk>
3 years agolsblk: add dax (direct access) capability column
Anthony Iliopoulos [Tue, 5 May 2020 14:31:44 +0000 (16:31 +0200)] 
lsblk: add dax (direct access) capability column

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
3 years agoMerge branch 'scriptlive' of https://github.com/jwilk-forks/util-linux
Karel Zak [Wed, 6 May 2020 13:04:28 +0000 (15:04 +0200)] 
Merge branch 'scriptlive' of https://github.com/jwilk-forks/util-linux

* 'scriptlive' of https://github.com/jwilk-forks/util-linux:
  scriptlive: fix typo
  scriptlive: fix man page formatting

3 years agolibfdisk: fix partition calculation for BLKPG_* ioctls
Karel Zak [Wed, 6 May 2020 11:32:46 +0000 (13:32 +0200)] 
libfdisk: fix partition calculation for BLKPG_* ioctls

The include/partx.h interface we use in util-linux uses 512-byte
sectors, but libfdisk uses real sector sizes.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoscriptlive: fix typo
Jakub Wilk [Tue, 5 May 2020 12:17:55 +0000 (14:17 +0200)] 
scriptlive: fix typo

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
3 years agoscriptlive: fix man page formatting
Jakub Wilk [Tue, 5 May 2020 12:16:52 +0000 (14:16 +0200)] 
scriptlive: fix man page formatting

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
3 years agoagetty: save the original speed on --keep-baud
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>
3 years agodocs: add swap to 1st fstab field
Karel Zak [Mon, 4 May 2020 09:44:03 +0000 (11:44 +0200)] 
docs: add swap to 1st fstab field

Addresses: https://github.com/karelzak/util-linux/issues/1027
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolsblk: Fall back to ID_SERIAL
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()]

Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agounshare: Fix PID and TIME namespace persistence
michael-dev [Wed, 15 Apr 2020 21:16:53 +0000 (23:16 +0200)] 
unshare: Fix PID and TIME namespace persistence

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.

[kzak@redhat.com: - add ns/time_for_children
                  - remove C++ comments
                  - resolve commit conflicts]

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agobash-completion: umount explicitly needs gawk
Wolfram Sang [Tue, 28 Apr 2020 07:13:15 +0000 (09:13 +0200)] 
bash-completion: umount explicitly needs gawk

gensub() is a gawk extension, so use it explicitly. Otherwise users will
get an error if their 'awk' defaults to something else.

Fixes: 3ebfc8d37 ("bash-completion: umount support relative path and ~ as home shorthands")
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
3 years agolibfdisk: fix alignment logic for tiny partitions
Karel Zak [Wed, 29 Apr 2020 09:10:54 +0000 (11:10 +0200)] 
libfdisk: fix alignment logic for tiny partitions

Addresses: https://github.com/karelzak/util-linux/issues/1018 (second case)
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolibfdisk: make sure we check for maximal number of partitions
Karel Zak [Tue, 28 Apr 2020 10:58:42 +0000 (12:58 +0200)] 
libfdisk: make sure we check for maximal number of partitions

Addresses: https://github.com/karelzak/util-linux/issues/1018
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agolib/strutils: fix floating point exception
Karel Zak [Tue, 28 Apr 2020 10:28:59 +0000 (12:28 +0200)] 
lib/strutils: fix floating point exception

Addresses: https://github.com/karelzak/util-linux/issues/1017
Signed-off-by: Karel Zak <kzak@redhat.com>
3 years agoMerge branch 'ups/fstrim-condition-fstab' of https://github.com/lucab/util-linux
Karel Zak [Tue, 28 Apr 2020 10:13:58 +0000 (12:13 +0200)] 
Merge branch 'ups/fstrim-condition-fstab' of https://github.com/lucab/util-linux

* 'ups/fstrim-condition-fstab' of https://github.com/lucab/util-linux:
  fstrim: run service and timer only if /etc/fstab is present

4 years agolibmount: fix mount -a EBUSY for cifs
Roberto Bergantinos Corpas [Mon, 27 Apr 2020 13:46:02 +0000 (15:46 +0200)] 
libmount: fix mount -a EBUSY for cifs

fstab:

 //rhel73/myshare/sub/path  /mnt   cifs

after mount in mountinfo:

 #  grep cifs /proc/self/mountinfo
 47 39 0:40 /sub/path /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
            ^^^^^^^^^
or:

 # grep cifs /proc/self/mountinfo
 47 39 0:40 / /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
            ^

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]

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1826719
Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofstrim: run service and timer only if /etc/fstab is present
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.

Ref: https://github.com/karelzak/util-linux/issues/673#issuecomment-409246816
Ref: https://github.com/coreos/bugs/issues/2591
Ref: https://github.com/coreos/fedora-coreos-tracker/issues/468

Signed-off-by: Luca BRUNO <luca.bruno@coreos.com>
4 years agodocs: nsenter(1): fix further details in PID namespace section
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>
4 years agolibfdisk: (script) fix partno_from_devname()
Karel Zak [Mon, 27 Apr 2020 09:15:00 +0000 (11:15 +0200)] 
libfdisk: (script) fix partno_from_devname()

Addresses: https://github.com/karelzak/util-linux/issues/1015
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: only report I/O errors on --move-data
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>
4 years agolibmount: do not unnecessarily chmod utab.lock
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.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
4 years agolibsmartcols: don't calculate with encoding on scols_table_enable_noencoding()
Karel Zak [Wed, 22 Apr 2020 10:24:33 +0000 (12:24 +0200)] 
libsmartcols: don't calculate with encoding on scols_table_enable_noencoding()

Old:
$ echo -e "$(tput smul)A$(tput rmul) B\nC D" | column --table
A  B
C                 D

Fixed:
$ echo -e "$(tput smul)A$(tput rmul) B\nC D" | ./column --table
A  B
C  D

Addresses: https://github.com/karelzak/util-linux/issues/1011
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/mbsalign: add function to calculate width
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoeject: fix compiler warning [-Wformat-overflow]
Karel Zak [Wed, 22 Apr 2020 08:32:49 +0000 (10:32 +0200)] 
eject: fix compiler warning [-Wformat-overflow]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/nls: remove unnecessary declaration
Karel Zak [Wed, 22 Apr 2020 08:27:12 +0000 (10:27 +0200)] 
include/nls: remove unnecessary declaration

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

4 years agopylibmount: cleanup and sync UL_RaiseExc
Karel Zak [Wed, 22 Apr 2020 07:44:47 +0000 (09:44 +0200)] 
pylibmount: cleanup and sync UL_RaiseExc

Addresses: https://github.com/karelzak/util-linux/issues/1013
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years ago[clang-tidy] fix misleading identation
Rosen Penev [Sun, 19 Apr 2020 05:24:27 +0000 (22:24 -0700)] 
[clang-tidy] fix misleading identation

Found with readability-misleading-indentation

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years ago[clang-tidy] use ceil
Rosen Penev [Sun, 19 Apr 2020 05:34:55 +0000 (22:34 -0700)] 
[clang-tidy] use ceil

Found with bugprone-incorrect-roundings

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years ago[clang-tidy] fix wrong *cmp usage
Rosen Penev [Sun, 19 Apr 2020 05:32:29 +0000 (22:32 -0700)] 
[clang-tidy] fix wrong *cmp usage

Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years ago[clang-tidy] do not use else after return
Rosen Penev [Sun, 19 Apr 2020 05:16:22 +0000 (22:16 -0700)] 
[clang-tidy] do not use else after return

Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years ago[clang-tidy] do not return in void functions
Rosen Penev [Sun, 19 Apr 2020 04:23:13 +0000 (21:23 -0700)] 
[clang-tidy] do not return in void functions

Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years ago[clang-tidy] fix mismatching declarations
Rosen Penev [Sun, 19 Apr 2020 04:14:25 +0000 (21:14 -0700)] 
[clang-tidy] fix mismatching declarations

Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
4 years agoMerge branch 'map-user' of https://github.com/mat8913/util-linux
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

4 years agolib/strutils: fix uint64_t overflow
Karel Zak [Fri, 17 Apr 2020 08:21:56 +0000 (10:21 +0200)] 
lib/strutils: fix uint64_t overflow

Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: update fdisk outputs due to sizes rounding change
Karel Zak [Thu, 16 Apr 2020 10:19:16 +0000 (12:19 +0200)] 
tests: update fdisk outputs due to sizes rounding change

References: b38c20e13a51acb7e3bb388e9cc17d5fc905e7d9
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoilib/strutils: fix rounding in size_to_human_string()
Karel Zak [Wed, 15 Apr 2020 13:01:12 +0000 (15:01 +0200)] 
ilib/strutils: fix rounding in size_to_human_string()

Thanks to bub75 for the idea.

The patch adds SIZE_DECIMAL_2DIGITS into regression tests.

Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agounshare: Support names for map-user/group options
Matthew Harm Bekkema [Wed, 15 Apr 2020 13:05:16 +0000 (23:05 +1000)] 
unshare: Support names for map-user/group options

The --map-user and --map-group options can now be specified by either
uid/gid or user/group name.

Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
4 years agolib/pwdutils: add xgetgrnam
Matthew Harm Bekkema [Wed, 15 Apr 2020 12:49:54 +0000 (22:49 +1000)] 
lib/pwdutils: add xgetgrnam

Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
4 years agomount: support "-o move" on command line
Karel Zak [Wed, 15 Apr 2020 11:24:23 +0000 (13:24 +0200)] 
mount: support "-o move" on command line

Addresses: https://github.com/karelzak/util-linux/issues/997
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkdiscard: (man) offset and length must be sector aligned
Lukas Czerner [Wed, 15 Apr 2020 07:08:12 +0000 (09:08 +0200)] 
blkdiscard: (man) offset and length must be sector aligned

Update blkdiscard manual page. Length and offset values must be aligned
to the device sector size.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
4 years agoscriptlive, scriptreplay: cleanup --maxdelay man page description
Karel Zak [Tue, 14 Apr 2020 09:40:38 +0000 (11:40 +0200)] 
scriptlive, scriptreplay: cleanup --maxdelay man page description

Addresses: https://github.com/karelzak/util-linux/issues/1004
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch '2020wk13' of https://github.com/kerolasa/util-linux
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

4 years agoFix off by one when checking "/dev/mapper/" path
Disconnect3d [Mon, 13 Apr 2020 14:14:10 +0000 (16:14 +0200)] 
Fix off by one when checking "/dev/mapper/" path

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.

4 years agoinclude: add remove_entry() to env.h
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>
4 years agotests: add sanitize_env() check
Sami Kerola [Sun, 12 Apr 2020 18:45:53 +0000 (19:45 +0100)] 
tests: add sanitize_env() check

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: fix moving backwards so that it can reach begining of the file
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: use getopt_long() to parse options
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: remove underlining related code
Sami Kerola [Sat, 28 Mar 2020 11:08:13 +0000 (11:08 +0000)] 
more: remove underlining related code

Linux terminal handles underlining just fine without more executable needing
to do anything extra.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: fix SIGSTOP and SIGCONT handling
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: make execute() more robust and timely
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: target all standard streams when calling fflush()
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: remove kill_line() in favor of erase_prompt()
Sami Kerola [Sat, 21 Mar 2020 16:53:15 +0000 (16:53 +0000)] 
more: remove kill_line() in favor of erase_prompt()

These functions did similar things, so there is no need for both of them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: avoid defining special characters locally
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: use off_t and cc_t to clarify what variables attempt to represent
Sami Kerola [Sat, 21 Mar 2020 13:15:19 +0000 (13:15 +0000)] 
more: use off_t and cc_t to clarify what variables attempt to represent

As a minor robustness improvement use ftello() to find out file position
rather than add and substract from old value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: do not reset parent process terminal in execute()
Sami Kerola [Sat, 21 Mar 2020 12:34:15 +0000 (12:34 +0000)] 
more: do not reset parent process terminal in execute()

Only the terminal of the child process, that is the command being executed,
needs the reset.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: use single exit path to ensure resource freeing is unified
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>
4 years agounshare: allow custom uid/gid mappings in userns
Matthew Harm Bekkema [Fri, 3 Jan 2020 22:11:30 +0000 (09:11 +1100)] 
unshare: allow custom uid/gid mappings in userns

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>
4 years agotests: add zonefs blkid test
Karel Zak [Mon, 6 Apr 2020 13:33:23 +0000 (15:33 +0200)] 
tests: add zonefs blkid test

Thanks to Damien Le Moal for the image.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodocs: renice(1): Add chrt(1) to SEE ALSO
Jann Horn [Sun, 5 Apr 2020 05:55:14 +0000 (07:55 +0200)] 
docs: renice(1): Add chrt(1) to SEE ALSO

A user who wants to change the niceness of a process is likely to also be
interested in changing the scheduler class and/or RT priority.

Signed-off-by: Jann Horn <jannh@google.com>
4 years agolibmount: use mnt_stat_mountpoint() on more places
Karel Zak [Mon, 6 Apr 2020 09:58:29 +0000 (11:58 +0200)] 
libmount: use mnt_stat_mountpoint() on more places

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: Avoid triggering autofs in lookup_umount_fs_by_statfs
Fabian Vogt [Wed, 1 Apr 2020 11:15:13 +0000 (13:15 +0200)] 
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.

4 years agolibuuid: remove function alias
Karel Zak [Wed, 1 Apr 2020 08:21:58 +0000 (10:21 +0200)] 
libuuid: remove function alias

It seems the 'alias' attribute is not portable enough.

libuuid/src/unparse.c:72:17: error: only weak aliases are supported on darwin
        __attribute__((alias("uuid_unparse_lower")));

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocal: correctly set the week width
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

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
4 years agocal: Correctly center the year
Aurelien LAJOIE [Sat, 28 Mar 2020 22:33:40 +0000 (23:33 +0100)] 
cal: Correctly center the year

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
4 years agocal: use a const char*
Aurelien LAJOIE [Sat, 28 Mar 2020 22:33:39 +0000 (23:33 +0100)] 
cal: use a const char*

A put string function should not modify the char*

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
4 years agolibuuid: improve uuid_unparse() performance
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

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
4 years agoMerge branch 'more' of https://github.com/kerolasa/util-linux
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()

4 years agolslogins: remove unnecessary brackets
Karel Zak [Tue, 31 Mar 2020 11:12:11 +0000 (13:12 +0200)] 
lslogins: remove unnecessary brackets

Just to be consistent with the rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch '2020wk12' of https://github.com/kerolasa/util-linux
Karel Zak [Tue, 31 Mar 2020 11:05:53 +0000 (13:05 +0200)] 
Merge branch '2020wk12' of https://github.com/kerolasa/util-linux

* '2020wk12' of https://github.com/kerolasa/util-linux:
  lslogins: use lastlog as wtmp fallback
  login: avoid lseek() with pread() and pwrite()
  libuuid: ensure variable is initialized [cppcheck]
  ctrlaltdel: display error message indicated by errno

4 years agoMerge branch 'mips' of https://github.com/FlyGoat/util-linux
Karel Zak [Tue, 31 Mar 2020 10:54:58 +0000 (12:54 +0200)] 
Merge branch 'mips' of https://github.com/FlyGoat/util-linux

* 'mips' of https://github.com/FlyGoat/util-linux:
  lscpu: Adapt MIPS cpuinfo

4 years agofstrim: rename --quite to --quite-unsupported
Karel Zak [Tue, 31 Mar 2020 10:26:54 +0000 (12:26 +0200)] 
fstrim: rename --quite to --quite-unsupported

We use --verbose together with --quite in service files. It seems
confusing, let's make the option more descriptive.

Addresses: https://github.com/karelzak/util-linux/issues/1001
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolslogins: use lastlog as wtmp fallback
Sami Kerola [Sun, 29 Mar 2020 19:40:48 +0000 (20:40 +0100)] 
lslogins: use lastlog as wtmp fallback

The wtmp file tends to rotate higher rate than lastlog, so use the later as
fallback in when wtmp tells nothing in LAST-LOGIN column.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agologin: avoid lseek() with pread() and pwrite()
Sami Kerola [Sun, 22 Mar 2020 20:54:00 +0000 (20:54 +0000)] 
login: avoid lseek() with pread() and pwrite()

This makes code a little less complicated by avoiding couple system calls.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibuuid: ensure variable is initialized [cppcheck]
Sami Kerola [Sat, 29 Feb 2020 08:51:53 +0000 (08:51 +0000)] 
libuuid: ensure variable is initialized [cppcheck]

This fix has a little bit of a feel of making a static analyzer to be happy
instead of real progress.  If I read the preprocessor directives correctly
it should be impossible hit uninitialized variable.  Then again if a bug
creeps into these ifdef's in that case it is nice to have robust code that
doesn't immediately go wrong.

    libuuid/src/gen_uuid.c:200:20: error: Uninitialized variable: a [uninitvar]
       memcpy(node_id, a, 6);
                       ^
    libuuid/src/gen_uuid.c:197:8: error: Uninitialized variable: a [uninitvar]
      if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
           ^

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoctrlaltdel: display error message indicated by errno
Sami Kerola [Tue, 25 Feb 2020 21:30:19 +0000 (21:30 +0000)] 
ctrlaltdel: display error message indicated by errno

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: refactor and clarify code
Sami Kerola [Wed, 18 Mar 2020 20:13:16 +0000 (20:13 +0000)] 
more: refactor and clarify code

Use the backspace provided dy terminfo, and if that is not possible use
fallback.

Simplify entering and exiting standard mode.  Now when these std_enter and
std_exit variables are initialized correctly they do not need to be checked
quite as complex way as earlier.

Do not call prepare_line_buffer() unnecessarily.  The line buffer needs only
to be prepared only at times of more(1) initialization and when terminal
size changes.

Add a function to print various separators, that is better than static
strings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: add display_file() to show files and stdin
Sami Kerola [Sat, 28 Mar 2020 07:50:43 +0000 (07:50 +0000)] 
more: add display_file() to show files and stdin

Earlier main() inline code implemented input files and stdin displaying
separately.  With small restructuring this code can be shared.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: simplify initterm()
Sami Kerola [Wed, 18 Mar 2020 20:13:10 +0000 (20:13 +0000)] 
more: simplify initterm()

Return rather than use long 'else' statement.  Also unwind some overly
compact variable set and test code, that can be best observed how
underlining settings are now handled.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: move currently open file to control structure
Sami Kerola [Wed, 18 Mar 2020 20:13:08 +0000 (20:13 +0000)] 
more: move currently open file to control structure

Currently open file is needed a bit here and there.  Move it to control
structure to avoid passing it around.  This also makes fixing memory leak at
more_exit() very easy.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: move code blocks from more_key_command() to functions
Sami Kerola [Wed, 18 Mar 2020 20:13:06 +0000 (20:13 +0000)] 
more: move code blocks from more_key_command() to functions

The more_key_command() was overly long.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: move runtime usage output to a function
Sami Kerola [Wed, 18 Mar 2020 20:13:02 +0000 (20:13 +0000)] 
more: move runtime usage output to a function

This change also removes a ghost prompt that was left in place when printing
help.  When looking old commits the output fluke has been around at least
since util-linux v2.2.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: restructure print_buf() if-else with continue
Sami Kerola [Wed, 18 Mar 2020 20:13:00 +0000 (20:13 +0000)] 
more: restructure print_buf() if-else with continue

Replacing long 'else' with 'continue' allows dropping one level of
indentation.  Main aim is to improve code readability by reducing
complexity one needs to keep track while looking the code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: tell in run time help what the 'v' will execute as editor
Sami Kerola [Wed, 18 Mar 2020 20:12:59 +0000 (20:12 +0000)] 
more: tell in run time help what the 'v' will execute as editor

In same go use well known paths from system include file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: drop setuid permissions before executing anything
Sami Kerola [Wed, 18 Mar 2020 20:12:57 +0000 (20:12 +0000)] 
more: drop setuid permissions before executing anything

Pagers are not expected to have setuid or setgid bits, but assuming such
mistake has taken place try to avoid privilege escalation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: Adapt MIPS cpuinfo
Jiaxun Yang [Sat, 28 Mar 2020 04:19:42 +0000 (12:19 +0800)] 
lscpu: Adapt MIPS cpuinfo

MIPS have slightly different layout of cpuinfo.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
4 years agomore: do not allocate shell command buffer from stack
Sami Kerola [Wed, 18 Mar 2020 20:12:54 +0000 (20:12 +0000)] 
more: do not allocate shell command buffer from stack

This change has three possitive effects:  Avoid expansion code when it is
not needed.  Stop wasting memory from stack for something rarely needed.
When command buffer is needed stop limiting it's size artificially.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomore: replace siglongjmp() and signal() calls with signalfd()
Sami Kerola [Wed, 18 Mar 2020 20:12:51 +0000 (20:12 +0000)] 
more: replace siglongjmp() and signal() calls with signalfd()

From man siglongjmp(3) 'longjmp() and siglongjmp() make programs hard to
understand and maintain.  If possible, an alternative should be used.'  That
manual page remark summarizes quite well why more(1) needs to move away from
jumping around.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibmount: make mnt_context_find_umount_fs() more extendable
Karel Zak [Fri, 27 Mar 2020 10:34:12 +0000 (11:34 +0100)] 
libmount: make mnt_context_find_umount_fs() more extendable

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