summaryrefslogtreecommitdiffstats
path: root/sys-utils
Commit message (Collapse)AuthorAgeFilesLines
* hwclock: move systz above init clocks readJ William Piggott2017-08-041-3/+4
| | | | | | | 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>
* setpriv: document accepted formats for naming capsPatrick Steinhardt2017-08-011-1/+6
| | | | | | | | | | | | 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>
* hwclock: remove custom errno stringJ William Piggott2017-07-312-6/+1Star
| | | | | | | | | | | | | | | | | | | | | | 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>
* hwclock: remove custom errno stringJ William Piggott2017-07-311-14/+12Star
| | | | | | | | | | | | | | 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>
* hwclock: fix unimplemented ioctl testJ William Piggott2017-07-311-2/+2
| | | | | | | | | 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>
* hwclock: squash custom errno stringsJ William Piggott2017-07-311-8/+2Star
| | | | | | | | 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>
* hwclock: squash custom errno stringsJ William Piggott2017-07-311-26/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tunelp: use linux headerSami Kerola2017-07-314-120/+3Star
| | | | | | | | | 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>
* fstab(5): mention how tabs are escapedAndreas Henriksson2017-07-311-1/+2
| | | | | | | | 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>
* hwclock: remove m68k and alpha cmos from manualJ William Piggott2017-07-311-9/+0Star
| | | | | | | m68k removed in commit 846c7d3 alpha cmos removed in commit c47a618 Signed-off-by: J William Piggott <elseifthen@gmx.com>
* wdctl: do not call fsync(2) when closing watchdog deviceSami Kerola2017-07-311-2/+2
| | | | | | | | | | | This removes bogus write failed warning. $ wdctl wdctl: write failed: Invalid argument Device: /dev/watchdog [...] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: fix regression from c3ae785J William Piggott2017-07-201-3/+3
| | | | | | | | | | | | 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>
* hwclock: remove unused epoch_optionJ William Piggott2017-07-202-2/+1Star
| | | | | | Also one whitespace fix. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* setpriv: support setting unnamed capabilitiesPatrick Steinhardt2017-07-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch '170711' of github.com:jwpi/util-linuxKarel Zak2017-07-174-53/+32Star
|\ | | | | | | | | | | | | | | * '170711' of github.com:jwpi/util-linux: hwclock: improve RTC epoch messages hwclock: improve RTC epoch messages hwclock: remove dead ioctl check hwclock: --epoch presence test fails
| * hwclock: improve RTC epoch messagesJ William Piggott2017-07-161-11/+5Star
| | | | | | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
| * hwclock: improve RTC epoch messagesJ William Piggott2017-07-161-19/+14Star
| | | | | | | | | | | | | | Make consistent and improve messages in get_epoch_rtc() and set_epoch_rtc(). Signed-off-by: J William Piggott <elseifthen@gmx.com>
| * hwclock: remove dead ioctl checkJ William Piggott2017-07-161-7/+1Star
| | | | | | | | | | | | | | | | | | | | The epoch ioctls test hasn't been valid for 20 years (v2.1.88). RTC has returned ENOTTY for unimplemented ioctls for 15 years. The check is made for RTC_EPOCH_SET, but not for RTC_EPOCH_READ. They were both implemented at the same time. Signed-off-by: J William Piggott <elseifthen@gmx.com>
| * hwclock: --epoch presence test failsJ William Piggott2017-07-164-19/+15Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | hwclock --setepoch --epoch 0 Will warn that the epoch option is required. The --epoch presence test is made on its argument after it is converted to an integer. This means any value it can be tested for, can also be given as an input. So make the conversion after the presence test, like the --date option does. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* | ldattach: simplify debugging function when vwarnx(3) is availableSami Kerola2017-07-151-3/+7
|/ | | | | | | The vwarnx(3) is probably not available in all libc implementations, in such cases use the earlier printout as a fallback. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* hwclock: sync one-liner descriptionsJ William Piggott2017-07-102-3/+3
| | | | | | | | | | | Make whatisdb/manpage and usage() one-line descriptions match. Also update the description; hwclock has evolved into much more than reading and setting the Hardware Clock. It also sets the System Clock, warps the System Clock, sets the kernel time configurations, and more. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: final usage() strings sliceJ William Piggott2017-07-101-1/+2
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: usage() use program_invocation_short_nameJ William Piggott2017-07-101-3/+3
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: remove from usage() FILE *out = stdoutJ William Piggott2017-07-101-32/+31Star
| | | | Signed-off-by: J William Piggott <elseifthen@gmx.com>
* mount: remove extN from mount.8 man pageKarel Zak2017-07-101-348/+2Star
| | | | | | | | | | The e2fsprogs package contains ext4(5) man page with all necessary information. We do not have to duplicate effort and maintain copy of the extN mount options in our mount.8. (We already do the same for XFS.) Signed-off-by: Karel Zak <kzak@redhat.com>
* setpriv: silence compiler warningRuediger Meier2017-07-041-1/+1
| | | | | | | | | | | | This got lost in 30129e2f sys-utils/setpriv.c:182:32: warning: implicit conversion from enumeration type 'enum cap_type' to different enumeration type 'capng_type_t' [-Wenum-conversion] return capng_have_capability(which, i); ~~~~~~~~~~~~~~~~~~~~~ ^~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-2940-76/+76
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'path-fixes' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-294-35/+35
|\ | | | | | | | | | | | | | | | | | | | | | | * 'path-fixes' of https://github.com/rudimeier/util-linux: hwclock: don't ifdef printf arguments setpriv: align --help tools: add segfault detection for checkusage.sh misc: avoid some dead initialization warnings lscpu: make clang analyzer happy lsmem: fix, using freed memory lib/path: add error handling to path_vcreate() lib/path: fix crash, pathbuf overflow
| * hwclock: don't ifdef printf argumentsRuediger Meier2017-06-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This may fails if printf() is macro, introduced in cc7cb070. clang compiler warnings: CC sys-utils/hwclock.o ../sys-utils/hwclock.c:1228:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive] #ifdef __linux__ ^ ../sys-utils/hwclock.c:1230:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive] #endif ^ 2 warnings generated. CC: J William Piggott <elseifthen@gmx.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * setpriv: align --helpRuediger Meier2017-06-291-1/+1
| | | | | | | | | | | | | | This was forgotton during my last cleanup because the build was auto-disabled on my system. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: avoid some dead initialization warningsRuediger Meier2017-06-291-4/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang analyzer warnings: Dead store, Dead initialization: lib/mbsedit.c:154:8: warning: Value stored to 'in' during its initialization is never read char *in = (char *) &c; ^~ ~~~~~~~~~~~ misc-utils/findmnt-verify.c:129:14: warning: Value stored to 'cn' during its initialization is never read const char *cn = tgt; ^~ ~~~ Dead store, Dead increment: sys-utils/hwclock.c:1461:2: warning: Value stored to 'argv' is never read argv += optind; ^ ~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * lscpu: make clang analyzer happyRuediger Meier2017-06-291-14/+13Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let read_nodes() work on uninitialized structs to silence these two warnings: CC sys-utils/lscpu-lscpu.o warning: Path diagnostic report is not generated. Current output format does not support diagnostics that cross file boundaries. Refer to --analyzer-output for valid output formats In file included from sys-utils/lscpu.c:63: ./include/xalloc.h:32:21: warning: Call to 'malloc' has an allocation size of 0 bytes void *ret = malloc(size); ^~~~~~~~~~~~ sys-utils/lscpu.c:1468:23: warning: Function call argument is an uninitialized value desc->nodemaps[i] = path_read_cpuset(maxcpus, ^~~~~~~~~~~~~~~~~~~~~~~~~ 2 warnings generated. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * lsmem: fix, using freed memoryRuediger Meier2017-06-292-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Simply avoiding strdup(). Error handling improved. This was the Clang Analyzer warning: Memory Error, Use-after-free sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed err(EXIT_FAILURE, _("Failed to open %s"), path); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * lib/path: fix crash, pathbuf overflowRuediger Meier2017-06-272-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" Segmentation fault (core dumped) After: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" lscpu: invalid argument to --sysroot: File name too long Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | docs: remove some old history from manpagesRuediger Meier2017-06-295-82/+25Star
|/ | | | | | | | We assume that users will have a kernel >= 2.6.0 and removel references to earlier kernels. There are still a few ones left. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* setpriv: add --ambient-caps to usage()Karel Zak2017-06-271-17/+18
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* setpriv: support modifying the set of ambient capabilitiesPatrick Steinhardt2017-06-272-3/+33
| | | | | | | | | | | | | | | | | | | Right now, we do not support modifying the set of ambient capabilities, which has been introduced quite recently with Linux 4.3. As libcap-ng does not yet provide any ability to modify this set, we do have to roll our own support via `prctl`, which is now easy to do due to the indirections introduced in the preceding commits. We add a new command line argument "--ambient-caps", which uses the same syntax as both "--inh-caps" and "--bounding-set" to specify either adding or dropping capabilities. This commit also adjusts documentation to mention the newly introduced ability to modify the ambient capability set. Based on a patch by Andy Lutomirski. Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Patrick Steinhardt <ps@pks.im>
* setpriv: support dumping ambient capabilitiesPatrick Steinhardt2017-06-271-1/+18
| | | | | | | | | | | | Our code dumping owned capabilities does not yet handle ambient capabilities, which were only recently introduced with Linux 4.3. This commit implements printing ambient capabilities if they're supported by the system. Based on a patch by Andy Lutomirski. Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Patrick Steinhardt <ps@pks.im>
* setpriv: proxy function to update capabilitiesPatrick Steinhardt2017-06-271-2/+17
| | | | | | | | | | | | | libcap-ng provides a function to update capabilities with `capng_update`. As libcap-ng has not yet been updated to enable modification of ambient capabilities, we cannot use it to update this set, though. In order to allow easily extending the logic to also handle ambient capability sets, we create a new function `cap_update`. Right now, it simply calls out to `capng_update` for all supported capability types. Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Patrick Steinhardt <ps@pks.im>
* setpriv: proxy function checking whether a capability is setPatrick Steinhardt2017-06-271-1/+20
| | | | | | | | | | | | | | | | The loop in `print_caps` iterates over every capability, checks whether it is set and, if so, prints out its name. Currently, the checking and printing is rather intertwined, making it harder to extend the check whether we own a capability. Prepare code for the introduction of ambient capabilities by disentangling the code checking for a capability and printing code. A new function `has_cap` is introduced and `print_caps` will now simply call out to it and only handle printing itself. This easily allows to extend the capability check based on which capability set is queried. Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Patrick Steinhardt <ps@pks.im>
* setpriv: introduce indirection for `capng_type` enumPatrick Steinhardt2017-06-271-11/+19
| | | | | | | | | | | | | | | | | | The capng_type is used to distinguish the different types of capability sets, that is the effective, inheratibale, permitted capabilities as well as the capability bounding set. In Linux 4.3, a new set of capabilities was introduced with ambient capabilities. Unfortunately, libcap-ng does not provide any support for these kind of capabilities and as such, we will have to roll our own support. As a first step, we introduce an indirection for the `capng_type` enum, allowing us to add the ambient capability type later on. Right now, no functional change is expected from this change and in fact, each of the newly introduce enums should have the same value as respective enum of libcap-ng. Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Patrick Steinhardt <ps@pks.im>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-273-13/+15
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-2738-76/+38Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-2612-41/+52
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cosmetics, remove argument from usage(int)Ruediger Meier2017-06-262-8/+8
| | | | | | | This patch is trivial and changes nothing, because we were always using usage(0). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(stderr)Ruediger Meier2017-06-2620-112/+169
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(ERROR)Ruediger Meier2017-06-261-8/+10
| | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-263-21/+25
| | | | | | | | | | | | | | | | Fixed checkusage.sh warnings: rtcwake: --unknownopt, non-empty stdout rtcwake: --unknownopt, stderr too long: 21 blockdev: --unknownopt, stderr too long: 28 lsipc: --unknownopt, stderr too long: 77 pg: --unknownopt, stderr too long: 23 renice: --unknownopt, stderr too long: 18 sulogin: --unknownopt, stderr too long: 17 write: --unknownopt, stderr too long: 12 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* flock, getopt: write --help to stdout and return 0Ruediger Meier2017-06-261-25/+27
| | | | | | | | | | ... and use errtryhelp() instead of usage(). Note in past "getopt --help" returned 2. But it is otherwise documented and was just a mistake IMO. See the unreachable exit(0) which was removed here: d1d03b54 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-265-7/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>