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.
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.
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.
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;
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.
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>
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:
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 274087935273266688 130.3G Linux filesystem
/dev/sda4 274087936378945535104857600 50G Linux filesystem
/dev/sda5 37894553646886209489916559 42.9G Linux filesystem
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1673452 Signed-off-by: Karel Zak <kzak@redhat.com>
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
...
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 ...
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>
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).
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>
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>
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>
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>
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>
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:
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.
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>
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