Commit Graph

11988 Commits

Author SHA1 Message Date
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Karel Zak 8b318eb25e logger: make stdin parsing more friendly to static analyzers
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 12:54:54 +02:00
Karel Zak e8f6060f27 rfkill: fix coding style and error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 12:28:44 +02:00
Sami Kerola b120966812 rfkill: do not fsync(3) /dev/rfkill file descriptor
Attempt to fsync() this device returns EINVAL, causing the rfkill always to
return EXIT_FAILURE when either block or unblock is requested.  Simply
closing the file descriptor will fix the issue.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-15 12:24:31 +02:00
Sami Kerola 4f892d77d5 rfkill: allow use of multiple arguments
There is no reason why multiple arguments could not be supported.

Most common use case is to do multiple control commands in one go without us
of 'all' argument that can cause unnecessary connection breakage.  For
example someone might want to add to a system initialization following
commands.

    rfkill block bluetooth uwb wimax wwan gps fm nfc

That will ensure everything but wifi is turned off with as few commands as
possible, without killing wifi at any point.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-15 12:24:31 +02:00
Karel Zak 2e7a922701 script: support sig{stop/cont}
* call wait() only when child exited
* suspend all session (including script master process) when child get
  SIGSTOP and send SIGCONT to child when master process resume

This allows to suspend all session and later use "fg" shell command to
resume.

$ ps af
14722 pts/1    Ss     0:00 bash
 4870 pts/1    S+     0:00  \_ ./script
 4871 pts/6    Ss+    0:00      \_ bash -i

$ kill -SIGSTOP 4871

and script session on another terminal:

$ script
Script started, file is typescript
$ 
[1]+  Stopped                 ./script

$ fg 1
./script

... session again usable ...
^D
Script done, file is typescript

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-08 09:48:29 +02:00
Karel Zak e12364cdfb lsblk: small man page change in return codes description
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-07 10:03:18 +02:00
Sami Kerola 40191b5f95 hwclock: add -a that is short of --adjust to manual page and usage
In same go use -V as return value of --version from getopts_long().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-05 14:34:53 +02:00
J William Piggott 08e3c9e662 hwclock: update usage()
Improve usage strings for debug and version.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-09-05 12:33:19 +02:00
Karel Zak ec56858bbb Merge branch '170825' of github.com:jwpi/util-linux
* '170825' of github.com:jwpi/util-linux:
  hwclock: close hwaudit_fd unconditionally
  hwclock: don't always use hwclock_exit
  hwclock: remove sysexits.h
2017-09-05 12:24:40 +02:00
Karel Zak 3184afa529 uuidgen: add more details to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 12:17:26 +02:00
Philip Prindeville c6f1ec68a8 uuidgen: add support for hash-based UUIDs
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:56:24 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Philip Prindeville 0047626887 libuuid: add support for hash-based UUIDs
Adding V3 and V5 UUIDs per RFC-4122.

[kzak@redhat.com: - fix symbols file]

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 11:26:39 +02:00
J William Piggott 5b8e46f7e7 hwclock: close hwaudit_fd unconditionally
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-09-03 12:34:03 -04:00
J William Piggott 652dcf5131 hwclock: don't always use hwclock_exit
Special exit handling is not wanted for usage() or bad
command syntax. For example we do not want to audit:
hwclock --set --date foo

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-09-03 12:23:44 -04:00
J William Piggott c47a8f2a87 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>
2017-09-03 12:03:10 -04:00
Karel Zak 58d57ae2d8 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>
2017-09-01 10:42:51 +02:00
Karel Zak ea05c23ab7 rfkill: add NFC fallback for old headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 20:40:37 +02:00
Karel Zak 0e45b256ac 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>
2017-08-31 14:47:14 +02:00
Karel Zak 0158e68fbd lib/match: make match_fstype() case insensitive
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 14:15:23 +02:00
Karel Zak 3d47ab0549 build-sys: add --disable-rfkill
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 11:40:51 +02:00
Karel Zak 3c5022c645 rfkill: cleanup returns
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 11:16:07 +02:00
Karel Zak 24f9dde539 build-sys: remove unused rfkill.py
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 10:37:36 +02:00
Karel Zak f4949fcc3b rfkill: add Sami to authors
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 10:36:51 +02:00
Karel Zak fcc3efb40e rfkill: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 10:31:21 +02:00
Karel Zak f1f874bf48 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.
  ...
2017-08-31 09:56:18 +02:00
Sami Kerola 11dc93b78a
rfkill: add systemd-rfkill(8) see also segment
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-30 20:32:49 +01:00
Sami Kerola f806a238f7
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>
2017-08-30 20:32:49 +01:00
Sami Kerola 1bee8ec6f8
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>
2017-08-30 20:32:49 +01:00
Sami Kerola 9bf5e08fd3
rfkill: add bash-completion file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-30 20:32:49 +01:00
Sami Kerola fd3d4ec710
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>
2017-08-30 20:32:49 +01:00
Sami Kerola 7d0b3acbb4
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>
2017-08-30 20:32:48 +01:00
Sami Kerola b3849c66d3
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>
2017-08-30 20:32:48 +01:00
Sami Kerola 6955a1d66c
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>
2017-08-30 20:32:48 +01:00
Sami Kerola b03378e793
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>
2017-08-30 20:32:48 +01:00
Sami Kerola a60cbb52e3
rfkill: update manual page
Make the manual page style to match with util-linux project.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-30 20:32:48 +01:00
Sami Kerola 367f40806e
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>
2017-08-30 20:32:48 +01:00
Sami Kerola c0d78c90be
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>
2017-08-30 20:32:48 +01:00
Sami Kerola e69263c03b
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>
2017-08-30 20:32:48 +01:00
Sami Kerola d17fb726b5
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>
2017-08-30 20:29:31 +01:00
Karel Zak 9001a06ebe 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>
2017-08-30 12:01:21 +02:00
Karel Zak 49a3d609ed build-sys: define dependence between chsh and getusershell 2017-08-30 11:30:41 +02:00
Sami Kerola a1f5bb9d1f 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>
2017-08-30 11:21:59 +02:00
Sami Kerola 75c5f4a516 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>
2017-08-30 11:21:57 +02:00
Sami Kerola 473ec35974 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>
2017-08-30 11:21:56 +02:00
Vaclav Dolezal 6c183c283b fdisk: use strutils to trim whitespace from input
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-29 15:26:39 +02:00
Vaclav Dolezal 1d775aa260 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>
2017-08-28 14:06:15 +02:00
Vaclav Dolezal 3063670425 fdisk: minor fixes to make readline work
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-28 14:03:30 +02:00
J William Piggott e406be01b4 hwclock: for debugging print startup system time
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-08-24 18:49:11 -04:00