]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
5 years agolast: do not use non-standard __UT_NAMESIZE
Patrick Steinhardt [Fri, 1 Mar 2019 17:35:49 +0000 (18:35 +0100)] 
last: do not use non-standard __UT_NAMESIZE

In commit b22332dd4 (last: fix wtmp user name buffer overflow
[asan], 2019-01-13), we started to make sure that the `ut_user`
field of the `utmpx` struct is always NUL-terminated. The
implementation makes use of the `__UT_NAMESIZE` define to
determine the position of the last character in that array. The
problem is that this is a non-standard define that is not
necessarily available on non-glibc platforms.

As there is no standardized define, we should just use `sizeof`.
This fixes compilation on musl libc based systems.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
5 years agolibmount: Recognize more fuse filesystems as pseudofs and netfs
Stanislav Brabec [Thu, 28 Feb 2019 22:09:40 +0000 (23:09 +0100)] 
libmount: Recognize more fuse filesystems as pseudofs and netfs

Add some fuse filesystems to the list of pseudofs and netfs.

There are still tens of filesystems that should be evaluated and added.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5 years agoagetty: Switch to 8-bit processing in get_logname() for UTF-8 terminals
Stanislav Brabec [Wed, 27 Feb 2019 22:22:40 +0000 (23:22 +0100)] 
agetty: Switch to 8-bit processing in get_logname() for UTF-8 terminals

If the terminal is in the UTF-8 mode, get_logname() should use 8-bit
processing.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Tested-by: Lubomir Rintel <lkundrak@v3.sk>
5 years agoagetty: Fix input of non-ASCII characters in get_logname()
Stanislav Brabec [Wed, 27 Feb 2019 22:22:19 +0000 (23:22 +0100)] 
agetty: Fix input of non-ASCII characters in get_logname()

As login supports non-ASCII characters in the logname, agetty should be
consistent.

8b58ffdd re-activated old and ASCII-only get_logname(), which restricted
the input to ASCII only. As the code does not read whole characters,
isascii(ascval) and isprint(ascval) returns nonsenses after entering a
non-ASCII character.

As keyboard maps don't contain unprintable non-control characters, it
seems to be relatively safe to remove both checks.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Tested-by: Lubomir Rintel <lkundrak@v3.sk>
5 years agotests: make sure TS_HELPER_MBSENCODE compiled
Karel Zak [Fri, 1 Mar 2019 14:04:54 +0000 (15:04 +0100)] 
tests: make sure TS_HELPER_MBSENCODE compiled

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoblockdev: make –-getbsz less confusing for end-users
Karel Zak [Thu, 28 Feb 2019 13:08:23 +0000 (14:08 +0100)] 
blockdev: make –-getbsz less confusing for end-users

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1684078
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: use subtests in fdisk/mbr-nondos-mode
Karel Zak [Wed, 27 Feb 2019 11:22:33 +0000 (12:22 +0100)] 
tests: use subtests in fdisk/mbr-nondos-mode

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: add fdisk (dos) first sector dialog test
Karel Zak [Wed, 27 Feb 2019 11:03:28 +0000 (12:03 +0100)] 
tests: add fdisk (dos) first sector dialog test

The test verifies that the "First sector" dialog offers relevant range
in the begin of the device if the end of the device is already used.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'dana/column-x' of https://github.com/okdana/util-linux
Karel Zak [Tue, 26 Feb 2019 11:25:21 +0000 (12:25 +0100)] 
Merge branch 'dana/column-x' of https://github.com/okdana/util-linux

* 'dana/column-x' of https://github.com/okdana/util-linux:
  column: Address fill-order confusion in documentation

5 years agolibfdisk: (dos) Use strtoul to parse the label-id
Juerg Haefliger [Fri, 22 Feb 2019 16:04:12 +0000 (17:04 +0100)] 
libfdisk: (dos) Use strtoul to parse the label-id

Parsing of the label-id fails on 32-bit if the MSB is set. Fix that by
using strtoul instead of strtol.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
5 years agolibfdisk: (dos) rewrite fist/last free sector functions
Karel Zak [Mon, 25 Feb 2019 12:59:50 +0000 (13:59 +0100)] 
libfdisk: (dos) rewrite fist/last free sector functions

The current code uses first[] and last[] arrays to specify partition
ranges. This is unnecessary as we already have all in memory.

The current code offers in first and last sector dialogs ranges
without care about already used areas.

This commit makes things more readable, more user-friendly and
remove obscure first[] and last[].

Reported-by: 冰柯 <ziming_cool@126.com
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agocolumn: Address fill-order confusion in documentation
dana [Fri, 22 Feb 2019 20:11:29 +0000 (14:11 -0600)] 
column: Address fill-order confusion in documentation

Historical versions of column have described the default fill order as
rows-then-columns and the -x order as columns-then-rows. This was
misleading at best, and the util-linux implementation was updated to
clarify the actual behaviour in 3e094e5fe2 (March 2017).

However, the other implementations (used by *BSD, macOS, Debian, &al.)
continue to use the previous wording, and a user comparing them could
easily get the false impression that util-linux column has exactly the
opposite fill behaviour from BSD column.

To address this, a note is added to the man page explaining the change
and clarifying that, despite what the BSD documentation says, the two
implementations behave identically in this regard.

Signed-off-by: dana <dana@dana.is>
5 years agolibmount: add mnt_table_{find,insert,move}_fs()
Karel Zak [Thu, 21 Feb 2019 12:49:39 +0000 (13:49 +0100)] 
libmount: add mnt_table_{find,insert,move}_fs()

Add functions to insert FS into table to specified position and to
move FS between two tables.

Co-Author: Tim Hildering <hilderingt@posteo.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: document --hex output regression (since v2.30)
Karel Zak [Wed, 20 Feb 2019 12:19:23 +0000 (13:19 +0100)] 
lscpu: document --hex output regression (since v2.30)

Addresses: https://github.com/karelzak/util-linux/issues/744
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsblk: allow to specify tree column
Karel Zak [Wed, 20 Feb 2019 11:49:24 +0000 (12:49 +0100)] 
lsblk: allow to specify tree column

* document --tree (was missing in the man page)
* add optional argument to --tree to specify tree

For example:

$ lsblk -o KNAME,SIZE,MOUNTPOINT --tree=KNAME /dev/dm-0
KNAME      SIZE MOUNTPOINT
dm-0     232.9G
└─dm-1   232.9G
  └─dm-2 232.9G

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibsmartcols: print tree also for empty cells
Karel Zak [Wed, 20 Feb 2019 11:47:24 +0000 (12:47 +0100)] 
libsmartcols: print tree also for empty cells

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: (dos) improve first unused sector for logical partitions
Karel Zak [Mon, 18 Feb 2019 15:38:11 +0000 (16:38 +0100)] 
libfdisk: (dos) improve first unused sector for logical partitions

Make sure we probe within extended partition.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: fix typos [codespell]
Sami Kerola [Mon, 14 Jan 2019 22:40:34 +0000 (22:40 +0000)] 
docs: fix typos [codespell]

Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoinclude/path.h: remove duplicate header inclusion
Sami Kerola [Fri, 25 Jan 2019 20:54:42 +0000 (20:54 +0000)] 
include/path.h: remove duplicate header inclusion

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoinclude: add no return function attribute
Sami Kerola [Fri, 8 Feb 2019 22:01:05 +0000 (22:01 +0000)] 
include: add no return function attribute

This warning is repeated 112 times when compiling with all warnings.

xalloc.h:23:1: warning: function '__err_oom' could be declared with
attribute 'noreturn' [-Wmissing-noreturn]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agohardlink, wall: fix variable shadowing
Sami Kerola [Sat, 9 Feb 2019 08:47:43 +0000 (08:47 +0000)] 
hardlink, wall: fix variable shadowing

misc-utils/hardlink.c:91:65: warning: declaration shadows a variable in the global scope [-Wshadow]
misc-utils/hardlink.c:73:5: note: previous declaration is here
int content_only = 0;

term-utils/wall.c:114:40: warning: declaration shadows a variable in the global scope [-Wshadow]
term-utils/wall.c:129:65: warning: declaration shadows a variable in the global scope [-Wshadow]
/usr/include/bits/getopt_core.h:36:14: note: previous declaration is here
extern char *optarg;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agovarious: fix 'uninitialized when used' warnings [clang]
Sami Kerola [Sat, 9 Feb 2019 09:34:52 +0000 (09:34 +0000)] 
various: fix 'uninitialized when used' warnings [clang]

This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agocal: fix Sexit and Senter
Karel Zak [Mon, 18 Feb 2019 12:10:58 +0000 (13:10 +0100)] 
cal: fix Sexit and Senter

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosfdisk: Avoid out of boundary read with readline
Tobias Stoeckmann [Sun, 17 Feb 2019 21:55:29 +0000 (22:55 +0100)] 
sfdisk: Avoid out of boundary read with readline

It is not guaranteed that the returned string of readline() actually
contains as many bytes as buf can contain.

If bufsz is larger than the allocated memory by readline, an out of
boundary read occurs and leads to undefined behaviour. Most likely
that will be a crash.

This can be reproduced when readline-support is compiled in and when
you directly enter "quit" and "n" (to not write changes back to disk)
when sfdisk was called with any given device.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 years agolibfdisk: sanity check, to prevent overlapping partitions from being partly reported...
Fabian.Kirsch@dlr.de [Wed, 13 Feb 2019 14:49:10 +0000 (14:49 +0000)] 
libfdisk: sanity check, to prevent overlapping partitions from being partly reported as free

i noticed wrongly reported free space when looking with cfdisk on
an USB drive prepared with the latest alpine *.iso[1].

Feel free to apply below patch, which fixed the issue for me.

Greetings
  Fabian

[1]: http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86/alpine-extended-3.9.0-x86.iso

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: (tabdiff) use list_add_tail() in more robust way
Karel Zak [Mon, 18 Feb 2019 11:35:09 +0000 (12:35 +0100)] 
libmount: (tabdiff) use list_add_tail() in more robust way

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: use list_add_tail() in more robust way
Karel Zak [Mon, 18 Feb 2019 11:34:11 +0000 (12:34 +0100)] 
libfdisk: use list_add_tail() in more robust way

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibsmartcols: use list_add_tail() in more robust way
Karel Zak [Mon, 18 Feb 2019 11:33:12 +0000 (12:33 +0100)] 
libsmartcols: use list_add_tail() in more robust way

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: tiny code simplification
Karel Zak [Mon, 18 Feb 2019 11:31:37 +0000 (12:31 +0100)] 
libblkid: tiny code simplification

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: check table membership before adding entry
Tim Hildering [Sun, 17 Feb 2019 23:01:18 +0000 (00:01 +0100)] 
libmount: check table membership before adding entry

Added validation to function 'mnt_table_add_fs()' to check that added @fs
is not already a member of another table.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agowall: remove unnecessary warning
Karel Zak [Thu, 14 Feb 2019 09:41:59 +0000 (10:41 +0100)] 
wall: remove unnecessary warning

wall(1) may be used in scripts or in pipe. In this case report failed
ttyname() does not make sense, especially if the code does not depend
on on this function.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1608176
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: update fdisk outputs
Karel Zak [Tue, 12 Feb 2019 13:22:49 +0000 (14:22 +0100)] 
tests: update fdisk outputs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofdisk: use 2 decimal places for size in disk summary
Karel Zak [Tue, 12 Feb 2019 13:21:54 +0000 (14:21 +0100)] 
fdisk: use 2 decimal places for size in disk summary

 In the disk summary it seems nice, but I'm not sure about lists (SIZE
 columns). It seems more readable to keep the lists with one decimal
 place only. New output:

  # sfdisk --list /dev/sda

 Old output:
  Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors

 New output:
  Disk /dev/sda: 223.58 GiB, 240057409536 bytes, 468862128 sectors

 The rest is unchanged:
  ...
  Device         Start       End   Sectors   Size Type
  /dev/sda1       2048    411647    409600   200M EFI System
  /dev/sda2     411648    821247    409600   200M Linux filesystem
  /dev/sda3     821248 274087935 273266688 130.3G Linux filesystem
  /dev/sda4  274087936 378945535 104857600    50G Linux filesystem
  /dev/sda5  378945536 468862094  89916559  42.9G Linux filesystem

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1673452
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/strutils: support two decimal places in size_to_human_string() output
Karel Zak [Tue, 12 Feb 2019 12:27:56 +0000 (13:27 +0100)] 
lib/strutils: support two decimal places in size_to_human_string() output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: (hardlink) update noregex
Karel Zak [Mon, 11 Feb 2019 13:53:51 +0000 (14:53 +0100)] 
tests: (hardlink) update noregex

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: add long options
Karel Zak [Mon, 11 Feb 2019 13:01:55 +0000 (14:01 +0100)] 
hardlink: add long options

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: rename function
Karel Zak [Mon, 11 Feb 2019 12:30:46 +0000 (13:30 +0100)] 
hardlink: rename function

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: make code more readable
Karel Zak [Mon, 11 Feb 2019 12:25:04 +0000 (13:25 +0100)] 
hardlink: make code more readable

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup global variables
Karel Zak [Mon, 11 Feb 2019 12:18:35 +0000 (13:18 +0100)] 
hardlink: cleanup global variables

* remove NAMELEN, use PATH_MAX
* mark global variables as static
* move all global variables to the begin of the code

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: remove typedefs
Karel Zak [Mon, 11 Feb 2019 12:00:18 +0000 (13:00 +0100)] 
hardlink: remove typedefs

- remove typedefs
- use long names for structs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: (hardlink) update summary output
Karel Zak [Mon, 11 Feb 2019 09:37:09 +0000 (10:37 +0100)] 
tests: (hardlink) update summary output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsblk: use ID_SCSI_SERIAL when available
Sven Wiltink [Fri, 8 Feb 2019 09:53:21 +0000 (10:53 +0100)] 
lsblk: use ID_SCSI_SERIAL when available

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup error messages, use xalloc.h
Karel Zak [Wed, 6 Feb 2019 16:21:36 +0000 (17:21 +0100)] 
hardlink: cleanup error messages, use xalloc.h

- do not use magical doexit(), just use err()
- print summary on exit

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup verbose and warning messages
Karel Zak [Wed, 6 Feb 2019 16:13:08 +0000 (17:13 +0100)] 
hardlink: cleanup verbose and warning messages

- use warn()
- use stdout rather than stderr

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: (man) add AVAILABILITY
Karel Zak [Wed, 6 Feb 2019 13:37:34 +0000 (14:37 +0100)] 
hardlink: (man) add AVAILABILITY

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
Karel Zak [Wed, 6 Feb 2019 12:55:20 +0000 (13:55 +0100)] 
Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink

* 'hardlink' of https://github.com/rudimeier/util-linux: (25 commits)
  hardlink: add first simple tests
  hardlink: util-linux usage
  hardlink: fix compiler warnings
  hardlink: style indentations and license header
  hardlink: enable build with and without pcre2
  fixes for the fixes
  temporal fix before re-patch (updates from Fedora repo)
  Update hardlink.1
  Fixed version number, added changelog about Todd Lewis' patch
  exclude files via pcre
  Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989)
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file
  Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file
  Mention -f option in the man page
  do not allow to hardlink files across filesystems by default (#786719) (use -f option to override)
  fix possible buffer overflows, integer overflows, update man page
  fix URL and remove mmap() (#676962, #672917)
  - update docs to describe highest verbosity -vv option (#210816) - use dist Resolves: 210816
  mostly spec cleanup
  ...

5 years agomount: Do not call mnt_pretty_path() on net file systems.
Stanislav Brabec [Tue, 5 Feb 2019 23:07:54 +0000 (00:07 +0100)] 
mount: Do not call mnt_pretty_path() on net file systems.

Calling mnt_pretty_path() on network file systems can cause mangling of
the output:
root# mount | grep nfs
nfs.example.com:/home on /home type nfs4 ...
root# mkdir -p nfs.example.com:/home
root# mount | grep nfs
/root/nfs.example.com:/home on /home type nfs4 ...

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5 years agocol: improve error message, update regression test
Karel Zak [Tue, 5 Feb 2019 17:07:26 +0000 (18:07 +0100)] 
col: improve error message, update regression test

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: add col(1) to TODO
Karel Zak [Tue, 5 Feb 2019 11:13:46 +0000 (12:13 +0100)] 
docs: add col(1) to TODO

Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agocol: make flush_line() a little bit robust
Karel Zak [Tue, 5 Feb 2019 11:06:00 +0000 (12:06 +0100)] 
col: make flush_line() a little bit robust

The code is horrible. The core of the problem are signed integers
and no check for the limits.

This patch fixes c->c_column = cur_col; where c_column is "short"
and "cur_col" is int. Let's use "int" for all the variables. It's
really not perfect as for bigger lines it can segfault again...

The patch also removes some unnecessary static variables.

Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'patch-1' of https://github.com/edupont/util-linux
Karel Zak [Tue, 5 Feb 2019 10:09:02 +0000 (11:09 +0100)] 
Merge branch 'patch-1' of https://github.com/edupont/util-linux

* 'patch-1' of https://github.com/edupont/util-linux:
  Typo in configuration help

5 years agoMerge branch 'mount-nosuid' of https://github.com/Lekensteyn/util-linux
Karel Zak [Tue, 5 Feb 2019 10:07:32 +0000 (11:07 +0100)] 
Merge branch 'mount-nosuid' of https://github.com/Lekensteyn/util-linux

* 'mount-nosuid' of https://github.com/Lekensteyn/util-linux:
  mount.8: clarify (no)suid behavior on file capabilities

5 years agolibfdisk: (gpt) add HiFive Unleashed bootloader partition UUIDs
Icenowy Zheng [Thu, 24 Jan 2019 10:33:34 +0000 (18:33 +0800)] 
libfdisk: (gpt) add HiFive Unleashed bootloader partition UUIDs

The HiFive Unleashed SBC's bootloader seeks for GPT partitions with
specific UUID for loading the next stage bootloader (ZSBL loads FSBL,
and FSBL loads BBL).

Add these partition type UUIDs.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
5 years agocal: use standout mode on monochrome terminals
Karel Zak [Mon, 4 Feb 2019 13:16:11 +0000 (14:16 +0100)] 
cal: use standout mode on monochrome terminals

The function colors_init() checks for colors, it means it fails
on monochrome terminals, but cal(1) in this case still need to
highlight the current day.

Reported-by: Nuno Silva <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/colors: force to "never" mode on non-terminal output
Karel Zak [Mon, 4 Feb 2019 13:14:37 +0000 (14:14 +0100)] 
lib/colors: force to "never" mode on non-terminal output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoTypo in configuration help
edupont [Fri, 1 Feb 2019 21:57:34 +0000 (22:57 +0100)] 
Typo in configuration help

5 years agomount.8: clarify (no)suid behavior on file capabilities
Peter Wu [Fri, 1 Feb 2019 14:40:53 +0000 (15:40 +0100)] 
mount.8: clarify (no)suid behavior on file capabilities

Clarify that the nosuid option also affects file capabilities and that
it only limits execution of programs. (setgid on directories still
inherit the group regardless of the nosuid option.) The new text is
taken from the mount(2) manual page from the man-pages project.

Addresses: https://github.com/karelzak/util-linux/issues/482
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
5 years agosfdisk: fix logical partition resize when start specified
Karel Zak [Thu, 31 Jan 2019 13:16:42 +0000 (14:16 +0100)] 
sfdisk: fix logical partition resize when start specified

Addresses: https://github.com/karelzak/util-linux/issues/745
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agologger: (man) add info about rewrite and authors
Karel Zak [Tue, 29 Jan 2019 14:59:41 +0000 (15:59 +0100)] 
logger: (man) add info about rewrite and authors

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agologger: (man) make more obvious that --server/socket is required
Karel Zak [Tue, 29 Jan 2019 14:44:13 +0000 (15:44 +0100)] 
logger: (man) make more obvious that --server/socket is required

The options --tcp/udp specify only how, but no where.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agobuild-sys: fix crypt() detection without -lcrypt
Johannes Nixdorf [Tue, 22 Jan 2019 18:17:55 +0000 (19:17 +0100)] 
build-sys: fix crypt() detection without -lcrypt

The check tested whether code using crypt() links without -lcrypt, but
didn't set have_crypt to yes if it succeeded.

This fixes the check erroneously failing when compiling against musl
libc.

Signed-off-by: Johannes Nixdorf <mixi@shadowice.org>
5 years agologger: concatenate multiple lines of MESSAGE into a single field.
Karel Zak [Wed, 23 Jan 2019 10:41:43 +0000 (11:41 +0100)] 
logger: concatenate multiple lines of MESSAGE into a single field.

this is deemed a useful special case since journalctl will only show
either the first or last element of the message array if the field
appears multiple times.

Based on patch from: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
https://github.com/karelzak/util-linux/pull/743

Addresses: https://github.com/karelzak/util-linux/issues/742
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: remove dependence on libuuid
Karel Zak [Tue, 22 Jan 2019 11:33:19 +0000 (12:33 +0100)] 
libblkid: remove dependence on libuuid

Currently we use libuuid to print UUID only. This code is possible to replace
by one snprintf(). It seems better to duplicate this one snprintf than force
all distros to keep libuuid together with libblkid.

Note, this scenario has been already supported on --disable-libuuid.

Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosetarch: don't return address of automatic variable
Andreas Schwab [Sat, 19 Jan 2019 22:18:16 +0000 (23:18 +0100)] 
setarch: don't return address of automatic variable

On architectures without special personalities setarch uses the contents
of a local variable with automatic storage duration after return from
the function, causing it to report a spurious error.

$ setarch m68k
setarch: Kernel cannot set architecture to m68k

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
5 years agolosetup: update an error message
Jeffrey Ferreira [Tue, 22 Jan 2019 10:56:16 +0000 (11:56 +0100)] 
losetup: update an error message

Update an error message to add --partscan to the list of options
only allowed during loop device setup.

Signed-off-by: Jeffrey Ferreira <jeffpferreira@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolosetup: properly use --sector-size when create a new device
Karel Zak [Tue, 22 Jan 2019 10:50:20 +0000 (11:50 +0100)] 
losetup: properly use --sector-size when create a new device

The --partscan functionality depends on sector size. Make sure
sector size is set before we force kernel to scan the device for
partitions. For example:

 losetup -f loopfile --sector-size 4KiB --partscan --show

where 'loopfile' contains GPT with 4096 sectors.

Reported-by: Jeffrey Ferreira <jeffpferreira@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/loopdev: set blocksize when create a new device
Karel Zak [Tue, 22 Jan 2019 10:37:35 +0000 (11:37 +0100)] 
lib/loopdev: set blocksize when create a new device

The partition scanner in kernel depends on blocksize. We need to set
the blocksize before we call LOOP_SET_STATUS64 (this ioctl triggers
the scanner).

This patch extends the internal API to save blocksize into loopdev
context to be usable later for loopcxt_setup_device().

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/loopdev: differentiate between setter()s and ioctl calls
Karel Zak [Tue, 22 Jan 2019 10:12:42 +0000 (11:12 +0100)] 
lib/loopdev: differentiate between setter()s and ioctl calls

Now the internal API uses loopcxt_set_...() to set context variables
as well as to call ioctls. This patch introduces loopcxt_ioctl_...()
to makes things more obvious to readers.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: be more explicit about BTRFS
Karel Zak [Tue, 22 Jan 2019 09:13:54 +0000 (10:13 +0100)] 
swapon: be more explicit about BTRFS

It seems nocow and nodatasum attributes are required.
See btrfs_swap_activate() in  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: rewrite section about swapfiles
Karel Zak [Tue, 22 Jan 2019 09:02:17 +0000 (10:02 +0100)] 
swapon: rewrite section about swapfiles

* don't duplicate info on two places -- let's keep only small note
  in mkswap(8) man page, suggest to read swapon(8) man page

* add info about kernel versions for XFS and Btrfs swapfiles support

* use subsection in the NOTES

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: (man) iomap for swapfile is already supported by kernel
Karel Zak [Mon, 21 Jan 2019 16:01:25 +0000 (17:01 +0100)] 
swapon: (man) iomap for swapfile is already supported by kernel

... since commit 67482129cdabf7cede1301d2415ef4f0156d35cd (Linus'
tree).

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: (man) cleanup note about holes
Karel Zak [Mon, 21 Jan 2019 11:44:49 +0000 (12:44 +0100)] 
swapon: (man) cleanup note about holes

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agomount: (man) add note about --all to remount desc
Karel Zak [Mon, 21 Jan 2019 10:56:27 +0000 (11:56 +0100)] 
mount: (man) add note about --all to remount desc

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolosetup: use offset in warn_size() calculation
Karel Zak [Fri, 18 Jan 2019 11:13:12 +0000 (12:13 +0100)] 
losetup: use offset in warn_size() calculation

 # dd if=/dev/urandom of=dummy bs=513 count=1 2>/dev/null

 # losetup -f --show --offset 1 dummy
 /dev/loop0
 losetup: dummy: Warning: file does not fit into a 512-byte sector; the end of the file will be ignore

The warning is bogus as with offset the size of the file fits into
512-byte sector. Simple test that all is right:

 # dd if=dummy bs=1 skip=1 2>/dev/null | sha256sum - /dev/loop0
 da2ed0ade6ea518a802cd8a7a3c01c408ad8699ef6856b0b01f92b867d4ba9b5  -
 da2ed0ade6ea518a802cd8a7a3c01c408ad8699ef6856b0b01f92b867d4ba9b5  /dev/loop0

Addresses: https://github.com/karelzak/util-linux/issues/722
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: add comment to fdisk_set_first_lba()
Karel Zak [Fri, 18 Jan 2019 10:38:57 +0000 (11:38 +0100)] 
libfdisk: add comment to fdisk_set_first_lba()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: update TODO
Karel Zak [Fri, 18 Jan 2019 10:14:38 +0000 (11:14 +0100)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agowhereis: search in /(s)bin before /usr/lib
Karel Zak [Thu, 17 Jan 2019 10:19:27 +0000 (11:19 +0100)] 
whereis: search in /(s)bin before /usr/lib

Addresses: https://github.com/karelzak/util-linux/issues/741
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: add support for MS_REMOUNT on --all
Karel Zak [Wed, 16 Jan 2019 14:00:07 +0000 (15:00 +0100)] 
libmount: add support for MS_REMOUNT on --all

This patch add to support for remount-all operation to
libmount and mount(8).

For example:
mount --all -o remount,ro -t vfat

to remount read-only all VFAT filesystems.

Addresses: https://github.com/karelzak/util-linux/issues/589
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofsck.cramfs: fix utimes() usage
Karel Zak [Tue, 15 Jan 2019 10:44:25 +0000 (11:44 +0100)] 
fsck.cramfs: fix utimes() usage

The bug has been introduced by untested commit ad7ac3d598e2d541d9eba70975e68dff7e52c7d9 ;-(

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agobuild-sys: use REALTIME_LIBS for hwclock due to monotonic.c
Karel Zak [Mon, 14 Jan 2019 11:18:35 +0000 (12:18 +0100)] 
build-sys: use REALTIME_LIBS for hwclock due to monotonic.c

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'time-fixes' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 14 Jan 2019 11:04:04 +0000 (12:04 +0100)] 
Merge branch 'time-fixes' of https://github.com/kerolasa/util-linux

* 'time-fixes' of https://github.com/kerolasa/util-linux:
  fsck.cramfs: use utimes() instead of utime() that is obsolete
  hwclock: use monotonic time to measure how long setting time takes
  include: add indirect monotonic clock id specifier
  timeutils: match today day and this year correctly

5 years agoMerge branch 'asan-fixes' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 14 Jan 2019 10:58:06 +0000 (11:58 +0100)] 
Merge branch 'asan-fixes' of https://github.com/kerolasa/util-linux

5 years agoreadprofile: check input file is not empty [asan]
Sami Kerola [Sun, 13 Jan 2019 19:59:40 +0000 (19:59 +0000)] 
readprofile: check input file is not empty [asan]

Addresses: https://github.com/karelzak/util-linux/issues/717
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agolast: fix wtmp user name buffer overflow [asan]
Sami Kerola [Sun, 13 Jan 2019 19:48:59 +0000 (19:48 +0000)] 
last: fix wtmp user name buffer overflow [asan]

Ensure utmp user name field is null terminated.  Without that getpwnam() can
buffer overflow, when wtmp file is malformed.

Addresses: https://github.com/karelzak/util-linux/issues/715
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agobash-completion: umount support relative path and ~ as home shorthands
Sami Kerola [Sat, 12 Jan 2019 11:14:15 +0000 (11:14 +0000)] 
bash-completion: umount support relative path and ~ as home shorthands

Addresses: https://github.com/karelzak/util-linux/issues/703
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agofsck.cramfs: use utimes() instead of utime() that is obsolete
Sami Kerola [Mon, 7 Jan 2019 22:23:04 +0000 (22:23 +0000)] 
fsck.cramfs: use utimes() instead of utime() that is obsolete

Reference: http://man7.org/linux/man-pages/man3/utime.3p.html#APPLICATION_USAGE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agohwclock: use monotonic time to measure how long setting time takes
Sami Kerola [Mon, 7 Jan 2019 21:34:11 +0000 (21:34 +0000)] 
hwclock: use monotonic time to measure how long setting time takes

Earlier gettimeofday() was affected by discontinuous jumps.  Measuring how
long time it takes to set time using function that effected by the very
thing being measured makes head spin.  Lets make this less confusing with
monotonic clock that ticks on without jumps.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoinclude: add indirect monotonic clock id specifier
Sami Kerola [Mon, 7 Jan 2019 21:31:34 +0000 (21:31 +0000)] 
include: add indirect monotonic clock id specifier

Avoid repeated ifdef checks in code by adding a project specific
preprocessor definition.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agotimeutils: match today day and this year correctly
Sami Kerola [Sat, 5 Jan 2019 21:32:23 +0000 (21:32 +0000)] 
timeutils: match today day and this year correctly

Assumption all years since 1970 have been exactly 365 days long has it's
problems when leap years happen.  Lets use struct tm fields that are
provided by localtime_r(), making year and day to be correctly compared even
when it's late new years eve somewhere else than UTC-0.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agologin: add support for login.defs(5) LASTLOG_UID_MAX
Karel Zak [Fri, 11 Jan 2019 11:16:00 +0000 (12:16 +0100)] 
login: add support for login.defs(5) LASTLOG_UID_MAX

This new variable allows to keep lastlog file small and filter out
things like huge nfsnobody UIDs.

The variable is also supported by shadow-utils (adduser, etc.).

Addresses: https://github.com/shadow-maint/shadow/pull/142/
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agologin-utils/logindefs: clenaup API
Karel Zak [Fri, 11 Jan 2019 11:15:00 +0000 (12:15 +0100)] 
login-utils/logindefs: clenaup API

The default value should be unsigned if the result is also unsigned...

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofstrim: check for read-only devices on -a/-A
Karel Zak [Fri, 11 Jan 2019 09:44:14 +0000 (10:44 +0100)] 
fstrim: check for read-only devices on -a/-A

 to avoid "FITRIM ioctl failed: Remote I/O error"

Addresses: https://github.com/karelzak/util-linux/issues/738
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosu-common.c: prefer ENV_SUPATH over ENV_ROOTPATH
Stanislav Brabec [Thu, 10 Jan 2019 00:28:54 +0000 (01:28 +0100)] 
su-common.c: prefer ENV_SUPATH over ENV_ROOTPATH

ENV_SUPATH and ENV_ROOTPATH are equivalent and ENV_ROOTPATH takes
precedence in both login and su. It makes no sense. More logical would be
precedence of ENV_SUPATH in su and ENV_ROOTPATH in login.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5 years agosu-common.c: prefer /etc/default/su over login.defs
Stanislav Brabec [Thu, 10 Jan 2019 00:28:53 +0000 (01:28 +0100)] 
su-common.c: prefer /etc/default/su over login.defs

su(1) documentation says:
       /etc/default/su  command specific logindef config file
       /etc/login.defs  global logindef config file

It indirectly indicates that /etc/default/su should take precedence
over /etc/login.defs.

But the reverse is true. It is not possible to define ENV_PATH in
/etc/login.defs and then make su specific customization in
/etc/default/su. We need to change read order to match the documented
behavior.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5 years agofdisk: make partition types uses more robust
Karel Zak [Thu, 10 Jan 2019 11:17:19 +0000 (12:17 +0100)] 
fdisk: make partition types uses more robust

* report failed partition type parsing
* make sure partition types code (from user reply) for MBR is hex

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofdisk: support CTRL+C on change-partition-type dialog
Karel Zak [Thu, 10 Jan 2019 10:26:05 +0000 (11:26 +0100)] 
fdisk: support CTRL+C on change-partition-type dialog

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoutmpdump: fix word swapping in manual page
Carlos Santos [Mon, 7 Jan 2019 19:32:34 +0000 (17:32 -0200)] 
utmpdump: fix word swapping in manual page

From
    The only binary version of the utmp(5) is standardised.
To
    Only the binary version of the utmp(5) is standardised.

Change-Id: I0033f6cf055d569c7dfca5e05e918f735ea72582
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
5 years agolibblkid: improve whole-disk detection when read /proc/partitions
Karel Zak [Tue, 8 Jan 2019 11:07:18 +0000 (12:07 +0100)] 
libblkid: improve whole-disk detection when read /proc/partitions

blkid(8) in high-level mode checks partitions and unpartitioned
whole-disk devices from the file /proc/partitions.

The current heuristic assumes that partition name ends with a digit.
Unfortunately, this is not correct -- for example md0 or nvme0n1 are
whole-disk devices.

This commit uses sysfs_devno_is_wholedisk() to make sure the device is
a partition (according to kernel or DM). It's probably more expensive,
because this way requires more syscalls (to read stuff from /sys etc.).

The patch also adds more information to the blkid(8) man page.

Addresses: https://github.com/karelzak/util-linux/issues/728
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoldattach: Check for value of _HAVE_STRUCT_TERMIOS_C_ISPEED
Khem Raj [Sat, 5 Jan 2019 06:38:25 +0000 (22:38 -0800)] 
ldattach: Check for value of _HAVE_STRUCT_TERMIOS_C_ISPEED

in glibc 2.29+ checking for just existence of _HAVE_STRUCT_TERMIOS_C_ISPEED
won't be enough, the value has to be checked

see
https://sourceware.org/git/?p=glibc.git;a=commit;h=e5a50db36eaa6e8c6427b3a971563240b633ca85

Signed-off-by: Khem Raj <raj.khem@gmail.com>
5 years agolibblkid: (ntfs) fix compiler warning [-Wpedantic]
Karel Zak [Wed, 2 Jan 2019 13:44:59 +0000 (14:44 +0100)] 
libblkid: (ntfs) fix compiler warning [-Wpedantic]

libblkid/src/superblocks/ntfs.c:80:2: warning: ISO C restricts enumerator
values to range of 'int' (4294967295 is too large) [-Wpedantic]

Addressed: https://github.com/karelzak/util-linux/pull/732
Signed-off-by: Karel Zak <kzak@redhat.com>