Commit Graph

12002 Commits

Author SHA1 Message Date
Karel Zak 42be9bda5b su: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:48:56 +02:00
Karel Zak 832f5cd524 su: add control struct
* setup logindefs loader by function rather than by global pointer

* move basic booleans to the su_context struct

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:48:56 +02:00
Karel Zak b1195aa07d su: cosmetic changes after indent
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:48:56 +02:00
Karel Zak 983652abc1 su: fix indention
Yes, I know... this patch is horrible. We all hate this in git
history, but the original indention from coreutils has been so
crazy...

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:48:56 +02:00
Karel Zak cf92105e50 docs: add ASAN to TODO list
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:44:57 +02:00
Sami Kerola 37a6cc7a14 bash-completion: update uuidgen, wipefs, tunelp, setpriv, and hwclock
uuidgen: Add hash-based UUIDs to bash-completion.  These were added in
commit c6f1ec68a8.

wipefs: Command started to use libsmartcols, and it got some new options.
Commit d9921b2a12.

rename: New option was added in commit fabb90676a.

tunelp: The --trust-irq was removed it being years broken.  Commit
d52eb4bd90.

setpriv: Add --ambient-caps option from commit 0c92194eee.
In same go fix 'bash set -u' issue, that is the same as mentioned commit
abbcec4fc9.

hwclock: For some reason --get has always been missing from this file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-18 11:04:52 +02:00
Sami Kerola 6627bc79e4 docs: remove repeated word from mount(8) man page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-09-18 11:04:52 +02:00
Karel Zak 7928a926a0 libsmartcols: fix scols_line_move_cells() n+1 error [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 10:41:20 +02:00
Karel Zak 774178f727 Merge branch 'patch-1' of https://github.com/aner-perez/util-linux 2017-09-15 14:45:36 +02:00
Karel Zak d369dc42cb libmount: export locking errors as MNT_EX_FILEIO
The mount man page assumes locking errors mapped to MNT_EX_FILEIO (16)
return code. Unfortunately, this is internally not exported as a
special error code, so it's returned as a generic (errno based)
stuff. This patch fixes this issue.

Note that we still use locking for example for utab or when enabled
/etc/mtab (disabled by default).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 14:30:06 +02:00
Karel Zak 1ed968c526 libsmartcols: fix heap-buffer-overflow when move columns
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:43:54 +02:00
Karel Zak ae1c9d6008 uuidparse:fix stack-buffer-overflow [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:45 +02:00
Karel Zak 3da94b1114 swaplabel: fix --disable-libuuid compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:40 +02:00
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
Aner Perez ed21c47aa1 Example for renaming foo? does not work as described
Command for renaming foo? should add 2 zeros to make all the file names have 3 digits as described in the example results.
2017-09-14 11:30:53 -04: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