]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
7 years agohwclock: remove sysexits.h
J William Piggott [Mon, 28 Aug 2017 00:26:41 +0000 (20:26 -0400)] 
hwclock: remove sysexits.h

sysexits.h was introduced in v2.11t prior to util-linux-ng, with the
HISTORY entry: * hwclock: minor polishing.

So there was no specific issue solved by adding it. Its use was never
documented so it should be safe to remove.

Also, fix return values being used for the exit status that were not
magic constants (portability issue).

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agotests: update sfdisk wipe test
Karel Zak [Fri, 1 Sep 2017 08:42:51 +0000 (10:42 +0200)] 
tests: update sfdisk wipe test

Now command wipefs returns results in the order how superblocks has
been detected on the device.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agorfkill: add NFC fallback for old headers
Karel Zak [Thu, 31 Aug 2017 18:40:37 +0000 (20:40 +0200)] 
rfkill: add NFC fallback for old headers

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agowipefs: cleanup offsets list usage, fix -t filter
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>
7 years agolib/match: make match_fstype() case insensitive
Karel Zak [Thu, 31 Aug 2017 12:15:23 +0000 (14:15 +0200)] 
lib/match: make match_fstype() case insensitive

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: add --disable-rfkill
Karel Zak [Thu, 31 Aug 2017 09:40:51 +0000 (11:40 +0200)] 
build-sys: add --disable-rfkill

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agorfkill: cleanup returns
Karel Zak [Thu, 31 Aug 2017 09:16:07 +0000 (11:16 +0200)] 
rfkill: cleanup returns

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: remove unused rfkill.py
Karel Zak [Thu, 31 Aug 2017 08:37:36 +0000 (10:37 +0200)] 
build-sys: remove unused rfkill.py

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agorfkill: add Sami to authors
Karel Zak [Thu, 31 Aug 2017 08:36:51 +0000 (10:36 +0200)] 
rfkill: add Sami to authors

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agorfkill: cleanup usage()
Karel Zak [Thu, 31 Aug 2017 08:31:21 +0000 (10:31 +0200)] 
rfkill: cleanup usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'rfkill' of git://github.com/kerolasa/lelux-utiliteetit into rfkill
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.
  ...

7 years agorfkill: add systemd-rfkill(8) see also segment
Sami Kerola [Thu, 6 Jul 2017 20:57:59 +0000 (21:57 +0100)] 
rfkill: add systemd-rfkill(8) see also segment

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: check id number refers to a device that exists
Sami Kerola [Tue, 4 Jul 2017 20:43:56 +0000 (21:43 +0100)] 
rfkill: check id number refers to a device that exists

Earlier all commands happily accepted without detecting failure when
none-existing id number was used.  For example:

$ rfkill block 2017; echo $?
0

The same input after this change looks following.

$ rfkill block 2017; echo $?
rfkill: invalid identifier: 2017
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: use back and forward compatible test
Sami Kerola [Sat, 1 Jul 2017 08:15:12 +0000 (09:15 +0100)] 
rfkill: use back and forward compatible test

The rfkill_event struct might grow in future, so ensure the read sizes are
at least the minimum, and allow it to be more.

Reference: https://github.com/torvalds/linux/blob/master/include/uapi/linux/rfkill.h#L90-L102
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: add bash-completion file
Sami Kerola [Sun, 25 Jun 2017 12:21:31 +0000 (13:21 +0100)] 
rfkill: add bash-completion file

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: inform in syslog when rfkill is invoked
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: use human readable timestamps in event output
Sami Kerola [Sun, 25 Jun 2017 10:33:57 +0000 (11:33 +0100)] 
rfkill: use human readable timestamps in event output

The event command appears to be something what primarily a developers will
to use when debugging.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: use libsmartcols output
Sami Kerola [Sun, 25 Jun 2017 08:42:06 +0000 (09:42 +0100)] 
rfkill: use libsmartcols output

This also makes the rfkill to output status when executed without arguments.
That is believed ot be more useful than usage() output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: do not ignore read error
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: clarify 'all devices' handling
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: update manual page
Sami Kerola [Sat, 24 Jun 2017 23:01:19 +0000 (00:01 +0100)] 
rfkill: update manual page

Make the manual page style to match with util-linux project.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: make programming style to match util-linux project
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: make command to build in util-linux project
Sami Kerola [Sat, 24 Jun 2017 19:19:26 +0000 (20:19 +0100)] 
rfkill: make command to build in util-linux project

After this commit the command merely builds, but does not confirm style used
in util-linux project.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: move files to appropriate locations
Sami Kerola [Sat, 24 Jun 2017 19:03:38 +0000 (20:03 +0100)] 
rfkill: move files to appropriate locations

Also remove unnecessary items.  Notice that the licence text from COPYING is
moved to top of the command in comment section.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorfkill: merge rfkill.8 project to util-linux
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>
7 years agodocs: remove TODO item for fdisk
Karel Zak [Wed, 30 Aug 2017 10:01:21 +0000 (12:01 +0200)] 
docs: remove TODO item for fdisk

We use libsmartcols so basic escape for terminal should be already
done by the library.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: define dependence between chsh and getusershell
Karel Zak [Wed, 30 Aug 2017 09:30:41 +0000 (11:30 +0200)] 
build-sys: define dependence between chsh and getusershell

7 years agochsh: remove local /etc/shells parsing in favour of getusershell(3)
Sami Kerola [Mon, 28 Aug 2017 20:38:13 +0000 (21:38 +0100)] 
chsh: remove local /etc/shells parsing in favour of getusershell(3)

Less code, less bugs.  And if there are bugs at least share them with all
other programs that use getusershell(3) from libc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agobash-completion: simplify pid listing
Sami Kerola [Sat, 26 Aug 2017 12:45:13 +0000 (13:45 +0100)] 
bash-completion: simplify pid listing

Changing directory in subshell does not effect parent process, so this is
better and possibly quicker way to list pids.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agohwclock: remove bool type definition
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agofdisk: use strutils to trim whitespace from input
Vaclav Dolezal [Tue, 29 Aug 2017 12:31:06 +0000 (14:31 +0200)] 
fdisk: use strutils to trim whitespace from input

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agofdisk: fix copy from readline and whitespace stripping
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.
---

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
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>
8 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>
8 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).

8 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.

8 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()

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

8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>