]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
7 years agofdisk: minor fixes to make readline work
Vaclav Dolezal [Mon, 28 Aug 2017 10:31:10 +0000 (12:31 +0200)] 
fdisk: minor fixes to make readline work

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agohwclock: for debugging print startup system time
J William Piggott [Sun, 13 Aug 2017 17:38:18 +0000 (13:38 -0400)] 
hwclock: for debugging print startup system time

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: refactor set_system_clock()
J William Piggott [Sun, 13 Aug 2017 17:11:25 +0000 (13:11 -0400)] 
hwclock: refactor set_system_clock()

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: update set_system_clock comments
J William Piggott [Sun, 13 Aug 2017 00:13:22 +0000 (20:13 -0400)] 
hwclock: update set_system_clock comments

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: update set_system_clock debugging
J William Piggott [Wed, 9 Aug 2017 00:50:55 +0000 (20:50 -0400)] 
hwclock: update set_system_clock debugging

Update debug messages for a combined --systz and --hctosys in
the set_system_clock function.

New debug messages:

hwclock --test -D --systz --localtime
Calling settimeofday(NULL, 240) to warp System time.
Test mode: clock was not changed

hwclock --test -D --systz --utc
Calling settimeofday(NULL, 0) to lock the warp function.
Calling settimeofday(NULL, 240) to set the kernel timezone.
Test mode: clock was not changed

hwclock --test -D --hctosys --utc
Calling settimeofday(1502239269.733639, 240)
Test mode: clock was not changed

hwclock --test -D --hctosys --localtime
Calling settimeofday(NULL, 240) to set persistent_clock_is_local.
Calling settimeofday(1502253708.200200, 240)
Test mode: clock was not changed

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: remove set_system_clock_timezone()
J William Piggott [Sun, 6 Aug 2017 16:17:10 +0000 (12:17 -0400)] 
hwclock: remove set_system_clock_timezone()

Remove set_system_clock_timezone() because the previous patch
moved its functionality into set_system_clock().

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: move systz into hctosys
J William Piggott [Sun, 6 Aug 2017 15:39:33 +0000 (11:39 -0400)] 
hwclock: move systz into hctosys

The set_system_clock_timezone() function is nearly identical to
set_system_clock(). Three additional statements are required
to include systz in hctosys.

This patch is intentionally incomplete to make reviewing the
actual required changes easier. Other patches in this set will:

 * remove set_system_clock_timezone()
 * fix messages and debugging
 * fix comments
 * and finally refactor set_system_clock()

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agofdisk: add missing include
Karel Zak [Thu, 24 Aug 2017 17:59:20 +0000 (19:59 +0200)] 
fdisk: add missing include

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofdisk: fix readline interaction with signals
Karel Zak [Thu, 24 Aug 2017 13:37:16 +0000 (15:37 +0200)] 
fdisk: fix readline interaction with signals

The high-level readline API is crazy to use with signals. Fortunately
the library provides low-level rl_callback_* API. In this case we can
use poll() to wait for input and control all signals, etc.

This patch also a little changes fdisk behavior on CTRL+C and CTRL+D.
The signals does not kill fdisk, but forces fdisk to return to the
main menu, if already in the main menu then exit. If the disk layout
has been modified than ask "Do you really want to exit...".

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofdisk: handle SIGINT in dialogs as cancel
Vaclav Dolezal [Tue, 15 Aug 2017 13:25:32 +0000 (15:25 +0200)] 
fdisk: handle SIGINT in dialogs as cancel

[kzak@redhat.com: - use sig_atomic_t]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofdisk: add wrap_fgets() for getting user input
Vaclav Dolezal [Tue, 15 Aug 2017 11:08:49 +0000 (13:08 +0200)] 
fdisk: add wrap_fgets() for getting user input

make function wrapping rl_fgets() and fputs()&fgets() to remove
code duplication in get_user_reply().

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolibfdisk: fix fdisk_reset_partition() leaking *_chs strings.
Vaclav Dolezal [Tue, 15 Aug 2017 08:02:45 +0000 (10:02 +0200)] 
libfdisk: fix fdisk_reset_partition() leaking *_chs strings.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolibfdisk: fix two potential memory errors.
Vaclav Dolezal [Mon, 14 Aug 2017 10:57:52 +0000 (12:57 +0200)] 
libfdisk: fix two potential memory errors.

Fixes one leak and one unchecked allocation error.

[kzak@redhat.com: - don't call fdisk_ask_menu_get_result()
                    after failed fdisk_do_ask()]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: improve alignment debug mesagges
Karel Zak [Tue, 22 Aug 2017 13:12:36 +0000 (15:12 +0200)] 
libfdisk: improve alignment debug mesagges

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: add --grain to mkpart sample
Karel Zak [Tue, 22 Aug 2017 12:59:42 +0000 (14:59 +0200)] 
libfdisk: add --grain to mkpart sample

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: add fdisk_save_user_grain()
Karel Zak [Tue, 22 Aug 2017 12:55:51 +0000 (14:55 +0200)] 
libfdisk: add fdisk_save_user_grain()

Let's provide API for applications that don't want to use the default
1MiB grain. The new function allow to use "as minimal as possible" if
grain is set by fdisk_save_user_grain() to 512.

If the phy sector size (or minimal I/O size) is greater than specified
grain size than smallest possible setting is used.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (dos) use size-=1 when alignment not used later
Karel Zak [Tue, 22 Aug 2017 12:54:27 +0000 (14:54 +0200)] 
libfdisk: (dos) use size-=1 when alignment not used later

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: improve "add partition" debug message
Karel Zak [Tue, 22 Aug 2017 12:53:18 +0000 (14:53 +0200)] 
libfdisk: improve "add partition" debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (gpt) fix size-1 error
Karel Zak [Tue, 22 Aug 2017 12:48:14 +0000 (14:48 +0200)] 
libfdisk: (gpt) fix size-1 error

If partition does not require alignment, then don't call LBA align
function and don't use size-=1 (fdisk_align_lba_in_range() returns
unmodified size and we call size=-1 more than once for the same size).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodocs: add CAP_SYS_ADMIN to TODO
Karel Zak [Tue, 22 Aug 2017 09:22:26 +0000 (11:22 +0200)] 
docs: add CAP_SYS_ADMIN to TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 21 Aug 2017 09:33:17 +0000 (11:33 +0200)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Define magic constants

7 years agoisosize: usage() and coding style cleanup
Karel Zak [Mon, 21 Aug 2017 09:16:51 +0000 (11:16 +0200)] 
isosize: usage() and coding style cleanup

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoisosize: iterate over all arguments even when something fails
Karel Zak [Mon, 21 Aug 2017 09:11:11 +0000 (11:11 +0200)] 
isosize: iterate over all arguments even when something fails

Earlier the command exit too early if one of the arguments failed.  After
this change all arguments are examined, and command return value will have
information what happen during processing.

Based on patch from Sami Kerola <kerolasa@iki.fi>

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolook: use WORDLIST environment variable to find word list
Sami Kerola [Sat, 12 Aug 2017 08:31:11 +0000 (09:31 +0100)] 
look: use WORDLIST environment variable to find word list

The WORDLIST is the same hunspell(1) and ispell(1) uses to achieve the same.
Apparently aspell(1) does not work with files like traditional dict lists.

Reference: https://github.com/hunspell/hunspell/blob/master/man/hunspell.1#L388
Reference: http://www.skrenta.com/rt/man/ispell.1.html
Reference: http://aspell.net/man-html/Creating-an-Individual-Word-List.html#Creating-an-Individual-Word-List
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agolibblkid: udf: Define magic constants
Pali Rohár [Sun, 20 Aug 2017 12:50:02 +0000 (14:50 +0200)] 
libblkid: udf: Define magic constants

7 years agolslogins: be more explicit with -g in man page
Karel Zak [Fri, 18 Aug 2017 08:29:54 +0000 (10:29 +0200)] 
lslogins: be more explicit with -g in man page

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolslogins: ignore non-existing users
Karel Zak [Fri, 18 Aug 2017 08:23:38 +0000 (10:23 +0200)] 
lslogins: ignore non-existing users

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agomisc: fix some printf format strings
Ruediger Meier [Wed, 16 Aug 2017 12:50:57 +0000 (14:50 +0200)] 
misc: fix some printf format strings

Noticed on xcode/OSX.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
7 years agodmesg: fix delimiter calculation
Karel Zak [Wed, 16 Aug 2017 12:15:56 +0000 (14:15 +0200)] 
dmesg: fix delimiter calculation

Reported-by: Laszlo Varkonyi <vlsoftsystems@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: fix compiler warning [-Wformat-truncation=]
Karel Zak [Wed, 16 Aug 2017 09:55:57 +0000 (11:55 +0200)] 
libblkid: fix compiler warning [-Wformat-truncation=]

The MBR partition pseudo-UUID is generated from table ID and partition
partno. The final UUID size limit is 37 bytes. The table ID has to be
restricted to keep compiler happy (for MBR the table ID is 8 bytes
as string).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agocfdisk: add missing 0x7F key mapping
Karel Zak [Tue, 15 Aug 2017 12:03:43 +0000 (14:03 +0200)] 
cfdisk: add missing 0x7F key mapping

Addresses: https://github.com/karelzak/util-linux/issues/499
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodocs: add --enable-programs to TODO
Karel Zak [Mon, 14 Aug 2017 10:25:07 +0000 (12:25 +0200)] 
docs: add --enable-programs to TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodocs: add UUID v3 an v5 to TODO
Karel Zak [Mon, 14 Aug 2017 10:09:50 +0000 (12:09 +0200)] 
docs: add UUID v3 an v5 to TODO

Addresses: https://github.com/karelzak/util-linux/issues/495
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoblockdev: document --setro more properly
Karel Zak [Mon, 14 Aug 2017 09:30:37 +0000 (11:30 +0200)] 
blockdev: document --setro more properly

Addresses: https://github.com/karelzak/util-linux/issues/498
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/randutils: reset lose counter
Karel Zak [Mon, 14 Aug 2017 08:56:08 +0000 (10:56 +0200)] 
lib/randutils: reset lose counter

It's probaly good idea to reset lose counter when we fallback from
getrandom() to /dev/urandom.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/randutils: improve getrandom() usage
Karel Zak [Mon, 14 Aug 2017 08:33:06 +0000 (10:33 +0200)] 
lib/randutils: improve getrandom() usage

The getrandom() does not have to return all requested bytes (missing
entropy or when interrupted by signal). The current implementation in
util-linux stupidly asks for all random data again, rather than only
for missing bytes.

The current code also does not care if we repeat our requests for
ever; that's bad.

This patch uses the same way as we already use for reading from
/dev/urandom. It means:

 * repeat getrandom() for only missing bytes
 * limit number of unsuccessful request (16 times)
 * fallback to /dev/urandom on ENOSYS (old kernel or so...)

Addresses: https://github.com/karelzak/util-linux/issues/496
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolosetup: add info about lazy detach to manpage
Karel Zak [Thu, 10 Aug 2017 10:37:34 +0000 (12:37 +0200)] 
losetup: add info about lazy detach to manpage

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'master' of https://github.com/RAOF/util-linux
Karel Zak [Thu, 10 Aug 2017 08:26:21 +0000 (10:26 +0200)] 
Merge branch 'master' of https://github.com/RAOF/util-linux

* 'master' of https://github.com/RAOF/util-linux:
  lib/randutils.c: More paranoia in getrandom() call.
  lib/randutils.c: Fall back gracefully when kernel doesn't support getrandom(2).

7 years agolib/randutils.c: More paranoia in getrandom() call.
Christopher James Halse Rogers [Mon, 7 Aug 2017 06:10:51 +0000 (16:10 +1000)] 
lib/randutils.c: More paranoia in getrandom() call.

If getrandom() is called with nbytes ≥ 256 then it can return with less than the requested
bytes filled.

In this case we *could* adjust the buffer by the number of bytes actually read, but it's
simpler to just redo the call.

7 years agolib/randutils.c: Fall back gracefully when kernel doesn't support getrandom(2).
Christopher James Halse Rogers [Mon, 7 Aug 2017 06:07:54 +0000 (16:07 +1000)] 
lib/randutils.c: Fall back gracefully when kernel doesn't support getrandom(2).

The 3.16 kernel is supported until 2020, and various distros have kernels of the same
vintage. It's entirely possible for code built against newer headers to be run against
these kernels, so fall-back to the old “read /dev/{u,}random” method if the kernel doesn'
support getrandom()

7 years agoMerge branch 'blkid-ubi'
Karel Zak [Mon, 7 Aug 2017 08:00:34 +0000 (10:00 +0200)] 
Merge branch 'blkid-ubi'

7 years agoMerge branch '170724' of github.com:jwpi/util-linux
Karel Zak [Mon, 7 Aug 2017 07:52:23 +0000 (09:52 +0200)] 
Merge branch '170724' of github.com:jwpi/util-linux

* '170724' of github.com:jwpi/util-linux:
  hwclock: fix hclock_valid test and error messages
  hwclock: remove busywait tristate return status
  hwclock: restore select() timeout warning
  hwclock: update man page
  hwclock: correlate hclocktime instead of set_time.
  hwclock: fix RTC read logic
  hwclock: move drift correction and --predict
  hwclock: move rtc permissions test
  hwclock: move systz above init clocks read

7 years agoagetty: keep returns in main()
Karel Zak [Mon, 7 Aug 2017 07:48:51 +0000 (09:48 +0200)] 
agetty: keep returns in main()

Don't use list_speeds() as non-return function, it seems better to
keep main() code consistent.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoagetty: fix invalid usage crash
Sami Kerola [Sun, 30 Jul 2017 13:59:24 +0000 (14:59 +0100)] 
agetty: fix invalid usage crash

$ agetty
agetty: not enough arguments: Success
Segmentation fault (core dumped)

Reference: 9325dbfd2018b2a3b510617f4aa13777fbbe23c3
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoagetty: add compile time features to --version output
Sami Kerola [Sat, 5 Aug 2017 15:46:55 +0000 (16:46 +0100)] 
agetty: add compile time features to --version output

This command has a lot of compile time #ifdef code.  It is time to add
feature listing to --version output so understanding command behavior is
easier.

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoagetty: add --list-speeds option
Sami Kerola [Sun, 30 Jul 2017 13:45:59 +0000 (14:45 +0100)] 
agetty: add --list-speeds option

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoagetty: remove dead DO_DEVFS_FIDDLING code segment
Sami Kerola [Sun, 30 Jul 2017 12:44:05 +0000 (13:44 +0100)] 
agetty: remove dead DO_DEVFS_FIDDLING code segment

There is no ./configure option to enable this, and it is unlikely any
distribution hot patching to enable fiddling when building package.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agobash-completion: look for look completions
Sami Kerola [Sat, 29 Jul 2017 21:27:46 +0000 (22:27 +0100)] 
bash-completion: look for look completions

The look(1) uses positional arguments, where first one is a word from
dictionary.  It is reasonable to assume most of the time people search from
system word lists so propose completions from there.  The second argument is
a dictionary file, that might invalidate the first input but that only
happens to users who have an idea what the want without bash-completion.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agolibuuid: use access(2) when checking /dev/random availability
Sami Kerola [Sun, 30 Jul 2017 11:33:12 +0000 (12:33 +0100)] 
libuuid: use access(2) when checking /dev/random availability

The access(2) is more lightwight than stat(2), and tells whether random
device(s) can be read or not, unlike the earlier stat() call.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agouuidparse: nil uuid have all bits set to zero
Sami Kerola [Sat, 29 Jul 2017 21:14:34 +0000 (22:14 +0100)] 
uuidparse: nil uuid have all bits set to zero

The nil UUID is special form of UUID that is specified to have all 128 bits
set to zero.

Reference: https://tools.ietf.org/html/rfc4122#section-4.1.7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agovipw: use explicit_bzero() to clear buffer after copy
Sami Kerola [Sat, 29 Jul 2017 16:19:47 +0000 (17:19 +0100)] 
vipw: use explicit_bzero() to clear buffer after copy

This should make leaking end of /etc/shadow file more unlikely.

Notice that there is now way to tell to editors they should ensure none it
does not leak any buffers, drop cores, and so on, when editing sensitive
data.  In short this change is addressing the issue only partially.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoinclude: move pamfail.h to auth.c
Sami Kerola [Sun, 30 Jul 2017 10:32:37 +0000 (11:32 +0100)] 
include: move pamfail.h to auth.c

This removes one small header file, and makes inline function to static to
only file it is used in.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agohwclock: fix hclock_valid test and error messages
J William Piggott [Wed, 2 Aug 2017 20:06:54 +0000 (16:06 -0400)] 
hwclock: fix hclock_valid test and error messages

Every hwclock operation that requires reading the RTC, tests
hclock_valid and prints a different warning. This redundancy
is unnecessary.

Move the warning to the RTC read block (the test was moved in
a previous patch in this set). This reduces function arguments
and is a significant code clean up. It will also benefit the
translators.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: remove busywait tristate return status
J William Piggott [Mon, 31 Jul 2017 15:57:01 +0000 (11:57 -0400)] 
hwclock: remove busywait tristate return status

The select() synchronization branch only returns success or
fail. There is no reason for the busywait branch to do more.
If synchronization fails for any reason then it must exit,
otherwise all drift correction operation will be invalid.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: restore select() timeout warning
J William Piggott [Mon, 31 Jul 2017 13:20:58 +0000 (09:20 -0400)] 
hwclock: restore select() timeout warning

hwclock now exits on select(2) timeout so restore the warning.

Reverts commit ab8f402952301106ad0bd5c5a51dc8646d1bff64
 and    commit efc4eaf4229f78f14430d8739ddef2c5101f05cc

Except use warnx(), because select() timeout does not set errno.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: update man page
J William Piggott [Mon, 31 Jul 2017 01:28:36 +0000 (21:28 -0400)] 
hwclock: update man page

Add information about setting the Hardware Clock if it has been
corrupted.

Add information about --update-drift and reduced system shutdown
times for --systohc.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: correlate hclocktime instead of set_time.
J William Piggott [Sun, 30 Jul 2017 20:22:49 +0000 (16:22 -0400)] 
hwclock: correlate hclocktime instead of set_time.

Correlate hclocktime with set_time instead of the other way around,
because set_time is used for timestamps in the adjtime file so it needs
to be unadulterated.

Also create var startup_hclocktime for correlated time.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: fix RTC read logic
J William Piggott [Sun, 30 Jul 2017 00:33:41 +0000 (20:33 -0400)] 
hwclock: fix RTC read logic

Over the past decade a few commits for a corner case problem
have left the RTC read branch in a bad place.

The problem was: when a corrupted RTC could not be read, then
it also could not be reset, because hwclock would error out
due to the RTC read failure.

2.15-rc1 commit 3b96a7a Aug  9 2008
2.19-rc1 commit 5606df5 Dec 29 2010
2.23-rc1 commit ab8f402 Mar 21 2013

The first fix was to ignore a synchronization timeout only for
the busywait branch.

Two and a half years later a commit describing the same problem
took a little more heavy-handed approach by ignoring all
synchronization failures and the RTC read after it, for both of
the RTC set functions.

Because the previous fix also ignored the select() branch timeout
it caused a bogus warning. The chosen workaround for that was to
only print the select() timeout message in debug mode (this is
reverted by another patch).

The problem with these fixes is that we cannot just ignore the
synchronization timeout like that, because then the drift
correction operations will be invalid. The original logic was
correct; we must exit when synchronization fails.

Another problem is that now there are statements between the
timing-critical synchronize-read-timestamp trio (which were
also in the wrong order, but that part of the problem goes
back further in history).

The solution is to skip the RTC read block completely for the
RTC set functions when not also using the --update-drift
option. If we are updating the drift correction factor during
a set function then we must synchronize and read the RTC.
Otherwise reading the RTC is not needed. Anyone trying to set
a corrupt RTC should not be using --update-drift, because the
resulting drift correction factor would be invalid.

Using this approach has the added benefit of significantly
reducing system shutdown time when not using --update-drift:

time ./hwclock --test --systohc; time ./hwclock-master --test --systohc
Test mode: clock was not changed

real    0m0.072s
user    0m0.066s
sys     0m0.003s
Test mode: clock was not changed

real    0m1.000s
user    0m0.169s
sys     0m0.005s

I've see differences as high as 1.518 seconds.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: move drift correction and --predict
J William Piggott [Sat, 29 Jul 2017 13:21:19 +0000 (09:21 -0400)] 
hwclock: move drift correction and --predict

Move the predict branch above the RTC read branch.

Move drift correction into the RTC read branch, because it
requires an accurate RTC read, and it needs to be skipped for
operations that do not require an RTC read.

Simplify the RTC read branch test.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: move rtc permissions test
J William Piggott [Sat, 29 Jul 2017 00:51:31 +0000 (20:51 -0400)] 
hwclock: move rtc permissions test

Move the rtc permissions test below the systz call and
simplify it's 'if' test.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agohwclock: move systz above init clocks read
J William Piggott [Sat, 29 Jul 2017 00:48:01 +0000 (20:48 -0400)] 
hwclock: move systz above init clocks read

The systz option is all about speed, so move it to the
top and simplify the init clocks read test.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolibblkid: mark UBI as RAID
Karel Zak [Thu, 3 Aug 2017 13:09:06 +0000 (15:09 +0200)] 
libblkid: mark UBI as RAID

UBI is volume manager rather than filesystem. Note that libblkid has
optimized RAIDs probing (don't search for another filesystems is RAID
detected). We also don't search for RAIDs on very small devices, but
this optimization is ignored for UBI char devices (size=1byte).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: add support for UBI superblock
Rafał Miłecki [Wed, 2 Aug 2017 12:14:18 +0000 (14:14 +0200)] 
libblkid: add support for UBI superblock

UBI is a volume management system that can be used on a raw flash
partition for providing multiple logical volumes. Detecting UBI
superblock may be useful for tools wanting to simplify or automate
attaching UBI.

Please note it's not directly related to the ubifs support which is just
a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0)
while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

This patch adds simple code reading UBI version and unique number and
setting it in the blkid_probe.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
8 years agobuild-sys: support ncursesw without headers in ncursesw/ directory
Karel Zak [Tue, 1 Aug 2017 12:36:25 +0000 (14:36 +0200)] 
build-sys: support ncursesw without headers in ncursesw/ directory

Let's check always for alone ncurses.h and term.h if the preferred
variant with ncursesw/ subdirectory is not available.

The patch also minimize number of HAVE_...NCURSES_H macros in
config.h. We don't need to check for ncurses.h if ncurses/ncurses.h is
available.

Reported-by: Carlos Santos <casantos@datacom.ind.br>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add --nopartno to mkpart sample
Karel Zak [Tue, 1 Aug 2017 11:51:27 +0000 (13:51 +0200)] 
libfdisk: add --nopartno to mkpart sample

* disable dialogs for the mkpart sample
* add --nopartno use-case to force libfdisk to use default partno(s)
* add test for this feature

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosetpriv: document accepted formats for naming caps
Patrick Steinhardt [Thu, 20 Jul 2017 06:30:04 +0000 (08:30 +0200)] 
setpriv: document accepted formats for naming caps

Since commit fbd15c4d4 (setpriv: support setting unnamed capabilities,
2017-07-17), it is possible to name capabilities not only by name, but
also by their index. While using the human-readable name is usually
recommended, using the index may be required in case new capabilities
have been introduced to the kernel for which we have no name yet. The
newly introduce format format is not documented inside of setpriv(1),
though, which is being fixed in this commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
8 years agohwclock: remove custom errno string
J William Piggott [Mon, 24 Jul 2017 18:59:07 +0000 (14:59 -0400)] 
hwclock: remove custom errno string

Custom errno messages are unnecessary and problematic for translators.

hwclock --directisa
hwclock: iopl() port access failed: Operation not permitted
hwclock: root privileges may be required

The custom errno message is misleading. We do not know what
the system permissions are set to. The default errno string is
correct, and enough.

Patched:
hwclock --directisa
hwclock: iopl() port access failed: Operation not permitted

root@:~# hwclock --directisa -D
Using direct ISA access to the clock
2017-07-24 14:49:17.782716-0400

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove custom errno string
J William Piggott [Mon, 24 Jul 2017 16:11:28 +0000 (12:11 -0400)] 
hwclock: remove custom errno string

Custom errno messages are unnecessary and problematic for translators.

The current messages are also too long, > 90 columns:
/dev/rtc0 does not have interrupt functions. Waiting in loop for time from \
/dev/rtc0 to change

Fixed:
ioctl(3, RTC_UIE_ON, 0): Inappropriate ioctl for device
Waiting in loop for time from /dev/rtc0 to change

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: fix unimplemented ioctl test
J William Piggott [Mon, 24 Jul 2017 00:16:03 +0000 (20:16 -0400)] 
hwclock: fix unimplemented ioctl test

The rtc driver has not returned EINVAL for unimplemented ioctls since
v2.5.8 in 2002. However, it does return it for other errors; making the
current test potentially problematic. Since 9f3d0fc util-linux assumes
kernel >= 2.6.0 so remove EINVAL as an ioctl test.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: squash custom errno strings
J William Piggott [Sun, 23 Jul 2017 18:25:55 +0000 (14:25 -0400)] 
hwclock: squash custom errno strings

warn() appends ENOENT as: No such file or directory

The custom string is unnecessary and problematic for translators.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: squash custom errno strings
J William Piggott [Sun, 23 Jul 2017 17:21:32 +0000 (13:21 -0400)] 
hwclock: squash custom errno strings

hwclock previously used printf for custom errno messages.
Later they were converted to use warn(), but were not
squashed. One of the reasons for warn and errno is to avoid
making translators deal with a multitude custom strings.

Also the custom strings are incorrect:

hwclock --hctosys
hwclock: Must be superuser to set system clock.
Unable to set system clock.

We do not know what the system permissions are set to.  The
correct response is to simply say permission was denied; as
the default errno string does. The second line is redundant
and just adds noise the code and to logs.

Patched:

hwclock --hctosys
hwclock: settimeofday() failed: Operation not permitted

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agobuild: use --runstatedir instead of --localstatedir
Andreas Henriksson [Thu, 27 Jul 2017 14:00:42 +0000 (16:00 +0200)] 
build: use --runstatedir instead of --localstatedir

The util-linux code was previously aligned to use @localstatedir@ and
the util-linux build system was set to override the default to use /run.

Current GNU Coding Standards introduced the @runstatedir@ variable
for this purpose. Lets use that instead.

The GNU default for @runstatedir@ is ${localstatedir}/run so util-linux
still override the default to be /run to preserve the status quo from
before. The only difference is that you'll now pass --runstatedir to
override the location on the command line instead of --localstatedir.

(FWIW, Debhelper in compat 11 will automatically start passing
--runstatedir=/run to all autotools configured builds. It already
passes --localstatedir=/var (to avoid it ending up with the GNU default
/usr/local/var) which breaks the util-linux build system code that
tries to default it to /run. This change will thus allow util-linux
and debhelper to work better together and avoid the need for a
package-specific override.)

Relevant historic commits:
 * commit 07a16b9d1e5a48550a0d19abb9a900853433ffa2
   "build-sys: change --localstatedir to /run"
 * commit 80c51185d50f00a2701f9379f10fc48a0f885dfc
   "uuidd: use run configured state directory"
 * commit 01c5b787947aeaffc7e56000827e3edefa357c59
   "agetty: use configured run state directory"

[kzak@redhat.com: - add $runstatedir fallback for autoconf < 2.70
                  - check for unmodified $localstatedir]

CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agowhereis: include native multiarch path in lib search paths
Andreas Henriksson [Sun, 30 Jul 2017 17:52:17 +0000 (19:52 +0200)] 
whereis: include native multiarch path in lib search paths

This includes atleast the native multiarch path in the paths to search.
(Maybe also other multiarch paths should also be searched? But atleast
this is a first step.)

Before this change (on Debian):
$ whereis libc
libc: /usr/share/man/man7/libc.7.gz

After this change:
$ whereis libc
libc: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.a /usr/share/man/man7/libc.7.gz

Addresses: https://bugs.debian.org/856968
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
8 years agotunelp: use linux header
Sami Kerola [Sat, 29 Jul 2017 15:35:30 +0000 (16:35 +0100)] 
tunelp: use linux header

Remove use of LPTRUSTIRQ in same go.  The LPTRUSTIRQ provided --trust-irq
option, but it has not worked in nearly 20 years.

Reference: http://repo.or.cz/davej-history.git/blobdiff/1f58336fe0515bc929e4de227eb44b12a4a18998..ac5579c68db87bc21630676c167ee8224267f32c:/include/linux/lp.h
Reference: http://repo.or.cz/davej-history.git/blobdiff/1f58336fe0515bc929e4de227eb44b12a4a18998..ac5579c68db87bc21630676c167ee8224267f32c:/drivers/char/lp.c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agofstab(5): mention how tabs are escaped
Andreas Henriksson [Thu, 27 Jul 2017 21:00:15 +0000 (23:00 +0200)] 
fstab(5): mention how tabs are escaped

Someone requested explicitly mentioning how tabs are escaped,
in addition to the already existing spaces example.

Addresses: https://bugs.debian.org/580047
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
8 years agohwclock: remove m68k and alpha cmos from manual
J William Piggott [Mon, 24 Jul 2017 23:54:15 +0000 (19:54 -0400)] 
hwclock: remove m68k and alpha cmos from manual

  m68k removed in commit 846c7d3
  alpha cmos removed in commit c47a618

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agowdctl: do not call fsync(2) when closing watchdog device
Sami Kerola [Sun, 23 Jul 2017 21:20:37 +0000 (22:20 +0100)] 
wdctl: do not call fsync(2) when closing watchdog device

This removes bogus write failed warning.

$ wdctl
wdctl: write failed: Invalid argument
Device:        /dev/watchdog
[...]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoDocs: update howto-usage-function.txt
J William Piggott [Sun, 23 Jul 2017 14:03:18 +0000 (10:03 -0400)] 
Docs: update howto-usage-function.txt

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agolibsmartcols: fix comment (to make gtk-docs happy)
Karel Zak [Mon, 31 Jul 2017 11:33:11 +0000 (13:33 +0200)] 
libsmartcols: fix comment (to make gtk-docs happy)

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocolumn: (-t) disable encoding for non-printable chars
Karel Zak [Mon, 31 Jul 2017 09:48:38 +0000 (11:48 +0200)] 
column: (-t) disable encoding for non-printable chars

$ echo -e '\033[34mBLUE{1\n\033[31mRED{2\n' | ./column -s '{' -t
BLUE  1
RED   2

Addresses: https://github.com/karelzak/util-linux/issues/490
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: add scols_table_enable_noencoding()
Karel Zak [Mon, 31 Jul 2017 09:45:23 +0000 (11:45 +0200)] 
libsmartcols: add scols_table_enable_noencoding()

Now the library encode all output. It seems too strict and difficult
to use the library for some use-cases -- for example if you want to
use the library for already colorized output (by esc.sequences).

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoagetty: fix --login-pause logic
Karel Zak [Mon, 31 Jul 2017 08:27:20 +0000 (10:27 +0200)] 
agetty: fix --login-pause logic

Let's "eat" ENTER key when pressed after login pause prompt.

Addresses: https://github.com/karelzak/util-linux/issues/491
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: add HPE extended-XFS to known filesystems
Mark Tinguely [Fri, 30 Jun 2017 14:30:39 +0000 (09:30 -0500)] 
libblkid: add HPE extended-XFS to known filesystems

The HPE (formerly SGI) enhanced XFS has changed its magic
version number to allow the use of EXFS and community XFS
filesystems at the same time.

This patch adds HPE EXFS support to libblkid.

[kzak@redhat.com: - removed EXFS log prober, it uses the same magic
                    string as XFS log]

Signed-off-by: Mark Tinguely <mark.tinguely@hpe.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agohwclock: fix regression from c3ae785
J William Piggott [Tue, 18 Jul 2017 19:42:55 +0000 (15:42 -0400)] 
hwclock: fix regression from c3ae785

hwclock --get foo
hwclock: 3 too many arguments given

Fixed:

hwclock --get foo
hwclock: 1 too many arguments given

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove unused epoch_option
J William Piggott [Tue, 18 Jul 2017 18:37:30 +0000 (14:37 -0400)] 
hwclock: remove unused epoch_option

Also one whitespace fix.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agotests: check sfdisk resize on unsorted offsets
Karel Zak [Wed, 19 Jul 2017 13:34:35 +0000 (15:34 +0200)] 
tests: check sfdisk resize on unsorted offsets

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: allow to resize in unsorted partition table
Karel Zak [Wed, 19 Jul 2017 13:09:36 +0000 (15:09 +0200)] 
libfdisk: allow to resize in unsorted partition table

The current code assumes that partition offsets (starts) are sorted.
This is usual situation, but unsorted partition table is also valid...

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: improve table print debugs
Karel Zak [Wed, 19 Jul 2017 13:09:12 +0000 (15:09 +0200)] 
libfdisk: improve table print debugs

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocfdisk: add resize function
Karel Zak [Wed, 19 Jul 2017 11:27:50 +0000 (13:27 +0200)] 
cfdisk: add resize function

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: support default partno in mkpart-fullspec sample
Karel Zak [Wed, 19 Jul 2017 09:42:50 +0000 (11:42 +0200)] 
libfdisk: support default partno in mkpart-fullspec sample

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add fdisk_disable_dialogs()
Karel Zak [Wed, 19 Jul 2017 09:30:57 +0000 (11:30 +0200)] 
libfdisk: add fdisk_disable_dialogs()

The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().

Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.

This function simplify semantic of the library for non-interactive
programs.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) return EINVAL when delete unused partition
Karel Zak [Wed, 19 Jul 2017 08:34:03 +0000 (10:34 +0200)] 
libfdisk: (dos) return EINVAL when delete unused partition

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoblkid: Add dm-integrity superblock signature
Milan Broz [Tue, 18 Jul 2017 11:08:23 +0000 (13:08 +0200)] 
blkid: Add dm-integrity superblock signature

Since the kernel version 4.12 there is a new dm-integrity module
that provides an emulated per-sector metadata format for storing data integrity.

This patch adds dm-integrity magic signature to blkid to recognize such
a block device.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
8 years agoscript: fix ambiguity about the optional argument of the -t option
Antonio Ospite [Tue, 18 Jul 2017 12:29:07 +0000 (14:29 +0200)] 
script: fix ambiguity about the optional argument of the -t option

[kzak@redhat.com: - merge two patches from Antonio to the one,
                  - update the patch]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Antonio Ospite <ao2@ao2.it>
8 years agosetpriv: support setting unnamed capabilities
Patrick Steinhardt [Mon, 17 Jul 2017 21:14:09 +0000 (23:14 +0200)] 
setpriv: support setting unnamed capabilities

When setting capabilities, we accept human readable names like for
example `sys_rawio` or `net_admin`. To do so the translation between the
capability name and its in-kernel index, we rely on the function
`capng_name_to_capability`. When the function does not know the named
capability, it will return an error value and we abort setting the
capability.

This relies upon the ability of libcap to know all capabilities inside
of the kernel. But actually, it is possible that new capabilities are
introduced inside of the Linux kernel which are not recognized yet by
the library. When dumping these unknown capabilities, libcap will simply
return a string like "cap_38", that is it will append the capability's
in-kernel index to the prefix "cap_". This may lead a user to also think
that "cap_38" may be passed to the switches "--inh-caps" or
"--ambient-caps", which is unfortunately not the case.

We can do better here by instead accepting strings in the form of
"cap_N". To do so, we can simply rely on the fact that capability
indices are steadily increasing and that the highest index known to the
kernel is stored inside of the kernel's procfs, made readily available
by our function `real_cap_last_cap()`. So in case libcap does not know a
capability name, we can simply parse the string and, if it is in the
correct format, check whether the detected index is between 0 and the
highest capability index. If so, we can treat it as a valid capability
string and apply it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
8 years agolibfdisk: fix warning -Wunused-function
Ruediger Meier [Tue, 18 Jul 2017 09:07:49 +0000 (11:07 +0200)] 
libfdisk: fix warning -Wunused-function

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agobuild-sys: don't use non-existing UUID_LIBS
Ruediger Meier [Thu, 27 Apr 2017 07:12:28 +0000 (09:12 +0200)] 
build-sys: don't use non-existing UUID_LIBS

We've added UUID_LIBS in f77a4d1087 but I don't see what it
was good for.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibfdisk: use fdisk_sector_t consistently and fix printf format strings
Ruediger Meier [Thu, 13 Jul 2017 18:00:03 +0000 (20:00 +0200)] 
libfdisk: use fdisk_sector_t consistently and fix printf format strings

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoparse-date: fix printf format
Ruediger Meier [Wed, 12 Jul 2017 19:41:50 +0000 (21:41 +0200)] 
parse-date: fix printf format

warning on 32bit systems:
../lib/parse-date.y: In function 'parse_date':
../lib/parse-date.y:1509:7: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'intmax_t' [-Wformat=]
       abs_time_zone_min);
       ^

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: remove UUIDs with time overflow from uuidparse
Karel Zak [Tue, 18 Jul 2017 08:01:22 +0000 (10:01 +0200)] 
tests: remove UUIDs with time overflow from uuidparse

The time_t used by timeval is "long", it means too small on 32-bits
archs to hold large numbers.

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>