Sami Loone [Tue, 9 Feb 2021 09:46:36 +0000 (10:46 +0100)]
agetty: tty eol defaults to REPRINT
Adapting tty eol settings from defaults misbehaves as CTRL('r') aka
REPRINT is confused with CR. Consequently --skip-login does not set
tty CR<->NL translations and thus acts against advertised CR as eol
default.
[kzak@redhat.com:
It seems this issue has been introduced by commit f566447 where we
merged sulogin and agetty terminal initialization together to the file
include/ttyutils.h.
The original agetty has really used .eol=13 (aka CR) for the default.
The problem is invisible for sulogin(1) because it always asks for a
password and .eol= is set to NL/CR, the same agetty when it asks for
username.]
Addresses: https://github.com/karelzak/util-linux/pull/1247 Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/blkdiscard.c: In function 'main':
sys-utils/blkdiscard.c:304:33: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_usec' was declared here
sys-utils/blkdiscard.c:305:37: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_sec' was declared here
sys-utils/blkdiscard.c:304:33: warning: 'last.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_usec' was declared here
sys-utils/blkdiscard.c:305:65: warning: 'last.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_sec' was declared here
sys-utils/hwclock-rtc.c: In function 'synchronize_to_clock_tick_rtc':
sys-utils/hwclock.c:169:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_sec' was declared here
sys-utils/hwclock.c:169:28: warning: 'begin.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'begin.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_sec' was declared here
term-utils/scriptlive.c: In function 'process_next_step':
term-utils/scriptlive.c:125:4: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/scriptlive.c:122:19: note: 'now.tv_usec' was declared here
term-utils/scriptlive.c:125:4: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/scriptlive.c:122:19: note: 'now.tv_sec' was declared here
term-utils/script.c: In function 'log_close.part.0.isra':
term-utils/script.c:306:3: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/script.c:303:18: note: 'now.tv_usec' was declared here
term-utils/script.c:306:3: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
term-utils/script.c:303:18: note: 'now.tv_sec' was declared here
Karel Zak [Wed, 3 Feb 2021 13:45:15 +0000 (14:45 +0100)]
login: use full tty path for PAM_TTY
pam_set_item() man page:
PAM_TTY
The terminal name: prefixed by /dev/ if it is a device file;
for graphical, X-based, applications the value for this item
should be the $DISPLAY variable.
It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...
Fixes: https://github.com/karelzak/util-linux/issues/1242 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 3 Feb 2021 13:45:15 +0000 (14:45 +0100)]
su: use full tty path for PAM_TTY
pam_set_item() man page:
PAM_TTY
The terminal name: prefixed by /dev/ if it is a device file;
for graphical, X-based, applications the value for this item
should be the $DISPLAY variable.
It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...
Fixes: https://github.com/karelzak/util-linux/issues/1242 Signed-off-by: Karel Zak <kzak@redhat.com>
ToddRK [Thu, 28 Jan 2021 11:44:41 +0000 (12:44 +0100)]
fsck.cramfs: fix fsck.cramfs crashes on blocksizes > 4K
fsck.cramfs crashes when extracting a cramfs image with a 16KB blocksize.
The read_buffer is hardcoded for a 4KB blocksize. When using a blocksize
larger than 4KB, the program's code uses indexes that go past the end of the
allocated space for the read_buffer and this causes the crash.
The following changes fix the problem for me in the latest 2.36.1 release of
fsck.cramfs.c. However there are hardcoded values of 4096 in the code that
might cause problems under other circumstances and I have not attempted to
fix those.
[kzak@redhat.com: - some coding style changes to code]
Fixes: https://github.com/karelzak/util-linux/issues/1232 Signed-off-by: ToddRK <ToddRK@example.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 12 Jan 2021 10:43:31 +0000 (11:43 +0100)]
lib/loopdev: make is_loopdev() more robust
It seems the current kernel can create a loop devices with a different
major number. For example
# losetup /dev/loop12345678 file.img
# lsblk /dev/loop12345678
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop12345678 15:811342 0 5M 0 loop
We need a way how to verify the device is loopdev also when the device is
not associated with any backing file -- in this case there is no "loop"
directory in /sys/dev/block/<maj:min>/, but we can cannonicalize this sysfs
symlink as it points to /sys/devices/virtual/block/loop<n> (see "loop" in
the path).
Note that without this change losetup is not able to list and delete
the loop device.
Addresses: https://github.com/karelzak/util-linux/issues/1202 Signed-off-by: Karel Zak <kzak@redhat.com>
A 33553920 byte optimal I/O size arises from badly-implemented USB SATA
adapters reporting 0xffff 512 byte sectors (32 MiB - 512). Commit acb7651f8897ae73d0f45dd75bc87630001c61b9 indirectly addresses this by
ignoring the optimal I/O size if it's not a multiple of the physical
sector size. That works if the physical sector size is 4096, but 33553920 optimal is allowed for 512 physical.
This commit explicitly ignores 33553920, as there is no legitimate
situation where this number would be the real optimal I/O size.
Signed-off-by: Ryan Finnie <ryan@finnie.org> Closes: https://github.com/karelzak/util-linux/issues/1221
Manuel Bentele [Sat, 5 Dec 2020 22:51:27 +0000 (23:51 +0100)]
losetup: fix wrong printf() format specifier for ino_t data type
Since the range of the ino_t data type is platform-specific (depending on
the wordsize), a usage of the fixed format specifier %PRIu64 is not correct
for ino_t on some 32-bit architectures, eg. ARM (Raspberry Pi 1). This issue
may lead to undefinied output and is not reported by gcc (in version 10.2.0
and 8.3.0-6+rpi1) even though -Wformat is enabled by -Wall. Therefore it is
most likely that it seems to be a false negative error in gcc's format
specifier check, so that this issue was never detected before.
This change fixes the issue by the use of a cast, since there is no
platform-independent format specifier for ino_t available. The wrong format
specifier %PRIu64 is replaced by %ju, where its corresponding variable of
type ino_t is casted to uintmax_t. The type uintmax_t represents the largest
platform-specific unsigned integer, so that all integer values are preserved
for a platform-independent printing.
Fixes: https://github.com/karelzak/util-linux/issues/1211 Signed-off-by: Manuel Bentele <development@manuel-bentele.de>
Érico Rolim [Fri, 20 Nov 2020 15:33:23 +0000 (12:33 -0300)]
setpriv: small clean-up.
- Add _() calls for some strings which were missing it.
- In print_caps(), use the same error checking done in
list_known_caps(); it is expected that libcap-ng will always return a
string, even if it's only "cap_%d".
Karel Zak [Thu, 19 Nov 2020 11:04:08 +0000 (12:04 +0100)]
lib/signames: change license to public domain
The file is simple list of signal names and trivial function to search
in the list. We do not need any extra license here and as public
domain it will be more portable to other tools (GPL and BSD) in the
util-linux.
All previous contributors (Sami, Niklas and me) agree with this change.
Karel Zak [Thu, 19 Nov 2020 10:12:06 +0000 (11:12 +0100)]
umount: ignore --no-canonicalize,-c for non-root users
It seems better to ignore this option than drop-permissions and later
exit with EPERMs. This change makes umount(8) more compatible with
fuser user umounts by systemd where -c is used to reduce overhead etc.
Addresses: https://github.com/karelzak/util-linux/issues/1192 Signed-off-by: Karel Zak <kzak@redhat.com>
Érico Rolim [Wed, 18 Nov 2020 14:35:26 +0000 (11:35 -0300)]
setpriv: allow using [-+]all for capabilities.
The initial change to lib/caputils that allowed this was commit 5d95818757941bc609e5aeec5e2218f7d35a6e19, which made it possible to
trust the value returned by cap_last_cap().
The error message was also somewhat misleading, since cap_last_cap()
being smaller than CAP_LAST_CAP happens when setpriv itself is built
with kernel headers older than the currently running kernel, not due to
libcap-ng.
Érico Rolim [Sun, 15 Nov 2020 04:34:41 +0000 (01:34 -0300)]
lib/caputils: add fall back for last cap using prctl.
This allows the rest of the programs using cap_last_cap to trust the
value returned by it, since it will either be obtained from procfs
(straight from kernel) or with prctl.
Also checked if the file under /proc is actually mounted in a procfs.
Samanta Navarro [Sun, 8 Nov 2020 11:45:18 +0000 (11:45 +0000)]
libblkid: allow a lot of mac partitions
If the map count is set to INT_MAX then the for loop does not stop
because its check is never false.
I have not found a correct upper limit. The other partition logics have
a maximum amount (exception is atari.c).
The loop itself wouldn't be endless. If the iteration reaches block 0
then the signature will be wrong. This means that map count = INT_MAX
case would fail even if such a setup would be correct on disk.
`--json` implies `--dump`, thus `--json --dump` must be
allowed. `--list-free` is incompatible with `--dump`, and thus also
with `--json`. Currently `--json --dump` is prohibited, even though
`--list-free` is not specified at all.
Egor Chelak [Thu, 29 Oct 2020 17:06:13 +0000 (19:06 +0200)]
vipw: fix short write handling in copyfile
Since `off` and `nr` approach each other, the for-loop ends prematurely
when at least half of the buffer was written. I think under certain
conditions this could cause the copy to be incomplete.
There's a couple of places which use varients on "0x%u" in format strings;
that's almost always wrong - you either want 0x%x or just %u. In libmount's
case it's flags, so I'm assuming the intention really is hex. In the ja.po
case it's %u in the original msgid.
Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
Dusty Mabe [Tue, 13 Oct 2020 15:26:16 +0000 (11:26 -0400)]
fstrim: remove fstab condition from fstrim.timer
In 9995da0 we added support to fstrim to be able to fall back to
`/proc/self/mountinfo` if `/etc/fstab` didn't exist, but we forgot
to remove the `/etc/fstab` condition from the timer. Let's remove
that condition from the timer so we can go back to periodically
running `fstrim.service`.
Karel Zak [Tue, 13 Oct 2020 08:31:42 +0000 (10:31 +0200)]
losetup: avoid infinite busy loop
issue report:
if i run the heavy duty test from #16859 a couple of times I can get
the loopback layer in the kernel into a state where there's a loopback
block device allocated, that you can open, but where both LOOP_CLR_FD
and _SET_FD fail with EBUSY. and /dev/loop-control still returns it as
the next free one... weird state util-linux losetup when called to
allocate a new device then freezes
This commit:
* restrict number of attempts to 16
* use 200000ms sleep between attempts
* add note about non-atomic loop device setup to the man page
Reported-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 6 Oct 2020 11:26:36 +0000 (13:26 +0200)]
build-sys: exclude GPL from libcommon
The library is not distributed and almost all code in this ar(1)
archive is Public Domain or LGPL ... but let's avoid any doubts and do
not mix non-GPL and GPL code there.
Addresses: https://github.com/karelzak/util-linux/issues/1157 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 6 Oct 2020 11:15:29 +0000 (13:15 +0200)]
lib/procutils: use Public Domain for this file
It's was originally GPL, but all the current code in the file is from
me and I don't think it makes sense to use GPL here anymore. We need
to use lib/ files in LGPL as well as in GPL binaries, etc. Let's makes
things (build-system) less complicated.
Karel Zak [Wed, 30 Sep 2020 09:44:03 +0000 (11:44 +0200)]
libfdisk: (gpt) make sure device is large enough
The current code creates GPT header and partitions arrays (with 128
entries ...) although there is no space for all the stuff. This patch
forces fdisk_create_disklabel() to return -ENOSPC if the last and first
usable LBA calculation is out of device size.
Addresses: https://github.com/karelzak/util-linux/issues/1147 Signed-off-by: Karel Zak <kzak@redhat.com>
Gero Treuner [Thu, 10 Sep 2020 19:43:03 +0000 (21:43 +0200)]
fallocate: fix --dig-holes at end of files
I discovered that making a file sparse with "fallocate -d filename"
fails on the last block of a file, because - usually being partial -
the system call only zeroes that part instead of deallocating the
block. See man fallocate(2) - section "Deallocating file space".
The expected call is punching the whole block beyond eof, which
doesn't change the file length because of flag FALLOC_FL_KEEP_SIZE.