Karel Zak [Thu, 31 Aug 2017 12:47:14 +0000 (14:47 +0200)]
wipefs: cleanup offsets list usage, fix -t filter
* move list with offsets specified by -o to the wipe_control struct
* don't clone the list of offsets, just keep it simple and stupid
* apply all filters (-o and -t) in get_desc_for_probe()
* always return offset and len by get_desc_for_probe() and apply
always use libblkid hide & step-back
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1486777 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 31 Aug 2017 07:56:18 +0000 (09:56 +0200)]
Merge branch 'rfkill' of git://github.com/kerolasa/lelux-utiliteetit into rfkill
* 'rfkill' of git://github.com/kerolasa/lelux-utiliteetit: (57 commits)
rfkill: add systemd-rfkill(8) see also segment
rfkill: check id number refers to a device that exists
rfkill: use back and forward compatible test
rfkill: add bash-completion file
rfkill: inform in syslog when rfkill is invoked
rfkill: use human readable timestamps in event output
rfkill: use libsmartcols output
rfkill: do not ignore read error
rfkill: clarify 'all devices' handling
rfkill: update manual page
rfkill: make programming style to match util-linux project
rfkill: make command to build in util-linux project
rfkill: move files to appropriate locations
add python module
use uapi rfkill.h
version 0.5
fix compiler warning
Add NFC support
version 0.4
Add rfkill type "fm" to the man page.
...
Sami Kerola [Sun, 25 Jun 2017 11:12:40 +0000 (12:12 +0100)]
rfkill: inform in syslog when rfkill is invoked
This should help when trying to explain what or who is flicking wireles on
or off. Notice that the change is not perfect - if rfkill command is
setting a state that is already set the syslog entry is sent eventhough
there was no effective change.
Sami Kerola [Sun, 25 Jun 2017 00:35:28 +0000 (01:35 +0100)]
rfkill: do not ignore read error
Read error should be impossible, but when one does happen user certainly
wants to know about that rather than see even more strange issue caused
random data in name variable.
Sami Kerola [Sun, 25 Jun 2017 00:04:41 +0000 (01:04 +0100)]
rfkill: clarify 'all devices' handling
Stop using RFKILL_IS_INVALID a marker when rfkill is iterating over all
devices. Addition of RFKIL_IS_ALL should make this a lot easier to digest,
especially if reading code in hurry.
Sami Kerola [Sat, 24 Jun 2017 19:42:58 +0000 (20:42 +0100)]
rfkill: make programming style to match util-linux project
Use the usual facilities, add translation strings, move global variables at
the beginning of the file, make usage() look as expected, add standard
command-line option parsing.
Sami Kerola [Wed, 30 Aug 2017 19:29:31 +0000 (20:29 +0100)]
rfkill: merge rfkill.8 project to util-linux
Projet merge discussion in maillists:
http://www.spinics.net/lists/util-linux-ng/msg14289.html
http://marc.info/?l=linux-wireless&m=149880885914076&w=2
Old-Remote: http://git.sipsolutions.net/rfkill.git/
Old-Remote: git://git.kernel.org/pub/scm/linux/kernel/git/jberg/rfkill.git Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sat, 26 Aug 2017 12:38:07 +0000 (13:38 +0100)]
hwclock: remove bool type definition
Use plain int instead of type defining it to a boolean, and use numbers to
signify true or false as we do everywhere else in this source tree. And in
hwclock-cmos.c file booleans weren't even needed, to the related code is
removed.
Vaclav Dolezal [Mon, 28 Aug 2017 11:20:34 +0000 (13:20 +0200)]
fdisk: fix copy from readline and whitespace stripping
Bug fixed:
---
678: fdisk: ASK: asking for number ['Partition number', <1,4>, default=1, range: 1-4]
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 12345
678: fdisk: ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1): 1
678: fdisk: ASK: user's reply: >>>12345<<<
Value out of range.
678: fdisk: ASK: asking for user replay [interactive]
Partition number (1-4, default 1):
678: fdisk: ASK: user's reply: >>>22345<<<
Value out of range.
---
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>
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>
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...".
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.
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).
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.
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>
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).
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>
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).
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()
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.
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.
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>
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>
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>
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>
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>
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).
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.
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.