Commit Graph

13075 Commits

Author SHA1 Message Date
Karel Zak 14560b7f54 lsblk: add lsblk.h
* move core struct to the header file
* move debug stuff to the header file

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:36:59 +02:00
Karel Zak bc405d641e lsblk: add columns FSAVAIL,FSSIZE,FSUSED,FSUSE%
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-13 12:11:06 +02:00
Karel Zak e4386c8cc0 libfdisk: accept grain script header
The "grain" variable is used to calculate partitions alignment. The
default is 1MiB (or minimal I/O size). The libfdisk provides API to overwrite
this default, but this feature has been nowhere accessible for
end-user.

This patch support for "grain: <size>" in libfdisk scripts.

Addresses: https://github.com/karelzak/util-linux/issues/688
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-12 13:26:18 +02:00
Karel Zak aef79c1f8e sfdisk: document script GPT headers
Add first-lba, last-lba and table-length to the sfdisk man page.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-12 12:26:06 +02:00
Karel Zak 1a6f970363 Merge branch 'more' of https://github.com/kerolasa/util-linux
* 'more' of https://github.com/kerolasa/util-linux:
  more: rename functions
  more: rename variable names
  more: remove unnecessary ifdef preprosessor directives
  more: do not call fileno() for std{in,out,err} streams
  more: remove 'register' keywords
  more: remove pointless functions
  more: return is statement not a function
  more: remove dead code and useless comments
2018-09-11 13:42:52 +02:00
Karel Zak da6392177d unshare: remove -s from --help output
The code and man page do not assume -s to be short alias to
--setgroups.

This commit also a little bit change --help output formatting to make
it more readable and structured.

Addresses: https://github.com/karelzak/util-linux/pull/692
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-11 12:47:39 +02:00
Karel Zak 137599ebe1 lsblk: don't ask udev when --sysroot specified
We use --sysroot to get information about block devices from /proc and
/sys dumps. In this case does not make sense to read anything from
udev as udevd is about the current system devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-11 09:53:18 +02:00
Matti Niemenmaa f1a7cfcb1d fallocate: add missing semicolon
This broke compilation when HAVE_POSIX_FALLOCATE was undefined. The typo
dates to the original posix_fallocate support added in commit
833f9a7aae.

Signed-off-by: Matti Niemenmaa <matti.niemenmaa+git@iki.fi>
2018-09-10 15:25:16 +03:00
Karel Zak 4698ffdfa1 Merge branch 'motd' of https://github.com/lnussel/util-linux 2018-09-10 10:35:32 +02:00
Karel Zak 13cbc6f21c lsblk: prefer MODEL from udev DB
sysfs device model is truncated to 16 characters:

> cat /sys/block/sda/device/model
Crucial_CT128MX1
> udevadm info --query=property /dev/sda | grep MODEL=
ID_MODEL=Crucial_CT128MX100SSD1

sysfs uses INQUARY response which has the 16 characters limitation and
udev uses something else.

Addresses: https://github.com/karelzak/util-linux/issues/690
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-10 10:31:17 +02:00
Ludwig Nussel 4866b71786 Add built in fallbacks for motd file
Use several locations for built in default for motd to allow for
e.g. run time generated motd without having to modify config files.
login.c already splits by colon.

/usr/share/misc/motd
  - chould be shipped by distributions
/run/motd
  - potentially run time created file with dynamic information
/etc/motd
  - for the admin fill with local information

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
2018-09-07 09:47:25 +02:00
Karel Zak 27afe50168 script: be sensitive to another SIGCHLD ssi_codes
The current signalfd handler cares on CLD_EXITED only. It's pretty
insufficient as there is more situations (and codes) when child no
more running.

Addresses: https://github.com/karelzak/util-linux/issues/686
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-05 11:55:21 +02:00
Karel Zak 350f5c8df2 lscpu: use the first VM from /proc/sysinfo
Addresses: https://github.com/karelzak/util-linux/issues/685
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-04 14:30:37 +02:00
Karel Zak d0b75b03bc lscpu: make xasprintf call more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-04 13:12:34 +02:00
Karel Zak f40e316f5e build-sys: default to /lib64 for ${exec_prefix}/lib64
We already default to /lib for the default $exec_prefix, but the current
configure does not care about /lib64 although the use-case is exactly
same as for /lib.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-04 11:42:19 +02:00
Karel Zak 66620e411b docs: remove obsolete entry from TODO
Already implemented by commit cf654e1c3e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-03 15:53:41 +02:00
Sami Kerola 275d47c9b7
more: rename functions
This clarifies what various function calls are doing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:30:12 +01:00
Sami Kerola d910f31110
more: rename variable names
Try to make variable names to tell what they do.  Earlier names have been in
more(1) since the command was first wrote, and it looks like coding
practices has changed since late 70's.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:09 +01:00
Sami Kerola 1e2cd595eb
more: remove unnecessary ifdef preprosessor directives
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:09 +01:00
Sami Kerola d2b540022b
more: do not call fileno() for std{in,out,err} streams
These file descriptor numbers are well known, use them from unistd.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola 0b735ea49e
more: remove 'register' keywords
One can only assume someone tried to make more(1) to run quicker.  More up
to date assumption is that compilers are fully capable optimizing binaries
without these sort of hints.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola 70824899b0
more: remove pointless functions
The curs_terminfo(3X) defines putp() as tputs(str, 1, putchar), so all of
these five functions can be replaced with putp().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola f728d8baae
more: return is statement not a function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Sami Kerola c8b1fa6046
more: remove dead code and useless comments
Removal of STOP requires explanation.  Looking unix-history-repo getline()
function in first BSD-3 version could return STOP.  By next tag BSD-4 the
return STOP had disappeared.  If I read this correctly that was a partial
removal, and second part has waited to be completed since 1980-11-16 when
BSD-4 was released.

Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-09-02 18:28:08 +01:00
Karel Zak 7edaf221d6 test: update UUID v5 tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-31 12:48:46 +02:00
Karel Zak d6ddf07d31 libuuid: fix name-based UUIDs
The current version is not fully compatible with RFC4122. It
incorrectly encodes UUID variant

	xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

where M is UUID version and N is UUID variant.

 $ python -c "import uuid ; print(uuid.uuid5(uuid.UUID(int=0), 'foo'))"
 aa752cea-8222-5bc8-acd9-555b090c0ccb
                    ^^

Old version:

 $ uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1
 aa752cea-8222-5bc8-8cd9-555b090c0ccb
                    ^^

Fixed version:
 ./uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1;
 aa752cea-8222-5bc8-acd9-555b090c0ccb
                    ^^

The patch uses uuid_unpack and uuid_pack. It makes code more readable
and allow to access proper octens. The same way we already use for
time and random based UUIDs.

Addresses: https://github.com/karelzak/util-linux/issues/683
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-31 12:43:17 +02:00
Karel Zak 9a312758ee libuuid: add note about RFC4122 UUID layout
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-31 10:08:46 +02:00
Karel Zak 1e3bc261d0 tests: update fdisk output
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-30 15:24:41 +02:00
Karel Zak 6ec4760967 fdisk: add "Disk model:" to the print output
Addresses: https://github.com/karelzak/util-linux/issues/682
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-30 14:01:54 +02:00
Karel Zak 745801e44a libfdisk: add fdisk_get_devmodel() and fdisk_get_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-30 14:01:46 +02:00
Karel Zak cf96b08efa docs: add note about lsblk usage/free cols
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-24 12:04:24 +02:00
Karel Zak 6d0df9ceb4 docs: cleanup TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-24 11:28:43 +02:00
Karel Zak 82bbc77bfc bash-completion: update column
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-23 14:14:29 +02:00
Karel Zak 11159cca21 tests: add column --table-empty-lines test
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-23 13:41:05 +02:00
Karel Zak 2698f9ba88 column: add --table-empty-lines
The option allows to add empty line to the table. The default behavior
is to ignore empty lines at all.

echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table
A
AA
AAA
AAAA

$ echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table --table-empty-lines
A
AA
AAA

AAAA

Addresses: https://github.com/karelzak/util-linux/issues/593
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-23 13:34:43 +02:00
Karel Zak 369be41bcd libsmartcols: don't mark as extreme where average is zero
The columns with NOEXTREME flag are internally marked as extreme
(=contains extreme width) if maximal with is greater than 2 *
average_width. This detection has to sure that the average is non-zero
otherwise the column is always "extreme".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-23 10:13:17 +02:00
Karel Zak c434b2782c libsmartcols: allow to add line to table without columns
The table allows to add columns on the fly when lines already exist.
So, it does not make sense to reject request to add line to table
without columns.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-23 10:02:49 +02:00
Karel Zak 89f9542574 setpriv: add --reset-env
Clear environment in way like su(1), but PATH is set to hard-coded
defaults and /etc/login.defs is not used at all (I guess we want to
keep setpriv(1) simple).

If you need anything more advanced than use env(1).

Addresses: https://github.com/karelzak/util-linux/issues/325
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-22 11:43:32 +02:00
Karel Zak 64d11d6bb0 su: add note about merged /usr
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-22 11:39:13 +02:00
Karel Zak 99179a0a08 setpriv: add user/group names to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-22 10:35:51 +02:00
Karel Zak 85c15c1f61 setpriv: allow to use group name for --groups
Addresses: https://github.com/karelzak/util-linux/issues/325
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-22 10:29:09 +02:00
Karel Zak a8224e8e7e sulogin: restore signals after failed exec() only
* removes unnecessary variable

* the current code restores signals always when shell has not been
  executed -- this is correct as function sushell() modify signal
  mask, but in all another cases we do not need touch the mask.
  Especially when we ask for the  password in endless while() loop...

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 16:16:40 +02:00
Karel Zak f9915d6db3 sulogin: do not use plain 0 as NULL
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 15:58:20 +02:00
Karel Zak 2c37ca7c4b libmount: cleanup licenses sections in the files
* add SPDX-License-Identifier (see https://spdx.org/licenses/)
* add "This file part of libmount from util-linux project."
* use proper text for LGPL-2.1-or-later
* use the same texts everywhere

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 15:43:53 +02:00
Karel Zak 4189907e6c docs: use SPDX license names
Let's use standardized names for licenses. The names used by SPDX
makes things more obvious at first glance. For complete list see:
https://spdx.org/licenses/

Note, this commit does not change any license or so...

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 14:47:21 +02:00
Karel Zak 26b6525a51 fstrim: use -n shortcut for --dry-run
It seems 'n' is more common than 'd'. The patch also cleanup
getopt_long() options string.

Addresses: fda0e2cf04 (commitcomment-30097920)
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-16 14:00:45 +02:00
Karel Zak 1b0a420281 Merge branch 'spelling' of https://github.com/jwilk-forks/util-linux
* 'spelling' of https://github.com/jwilk-forks/util-linux:
  Fix man page typos
2018-08-16 13:47:51 +02:00
Jakub Wilk b9c3b903fe Fix man page typos
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 11:09:15 +02:00
Jakub Wilk 456bda924f fincore.1: add missing space
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 10:37:10 +02:00
Karel Zak 75efef98d4 su: add --whitelist-environment
* usable with --login to whitelist specified environment variables

* the list is ignored for the core variables like HOME, SHELL, USER,
  LOGNAME and PATH (su --login always resets these variables)

Note that su(1) requires password and after successful authentication
user has full control over the session, so he can set arbitrary
environment variables. The whitelist makes things more user friendly
only.

The patch removes unnecessary optimization when allocate environ[]. It
seems better to keep all in glibc hands and just reset the environment
array only.

Addresses: https://github.com/karelzak/util-linux/issues/221
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-15 13:03:21 +02:00