Commit Graph

14194 Commits

Author SHA1 Message Date
Karel Zak 7c16238c06 eject: fix compiler warning [-Wformat-overflow]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-22 10:32:49 +02:00
Karel Zak 9faba2114a include/nls: remove unnecessary declaration
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-22 10:27:12 +02:00
Karel Zak 69fe4f4ba6 Merge branch 'clang' of https://github.com/neheb/util-linux
* 'clang' of https://github.com/neheb/util-linux:
  [clang-tidy] fix misleading identation
  [clang-tidy] use ceil
  [clang-tidy] fix wrong *cmp usage
  [clang-tidy] do not use else after return
  [clang-tidy] do not return in void functions
  [clang-tidy] fix mismatching declarations
2020-04-22 10:07:51 +02:00
Karel Zak e2aedec8d1 pylibmount: cleanup and sync UL_RaiseExc
Addresses: https://github.com/karelzak/util-linux/issues/1013
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-22 09:44:47 +02:00
Rosen Penev ad52498014
[clang-tidy] fix misleading identation
Found with readability-misleading-indentation

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev ed23cbce64
[clang-tidy] use ceil
Found with bugprone-incorrect-roundings

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Rosen Penev bd89499e07
[clang-tidy] do not return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Rosen Penev 13ae035211
[clang-tidy] fix mismatching declarations
Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Karel Zak 75c7684724 Merge branch 'map-user' of https://github.com/mat8913/util-linux
* 'map-user' of https://github.com/mat8913/util-linux:
  unshare: Support names for map-user/group options
  lib/pwdutils: add xgetgrnam
  unshare: allow custom uid/gid mappings in userns
2020-04-17 11:02:29 +02:00
Karel Zak f12d5ad279 lib/strutils: fix uint64_t overflow
Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-17 10:25:17 +02:00
Karel Zak 316617e848 tests: update fdisk outputs due to sizes rounding change
References: b38c20e13a
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-16 12:19:16 +02:00
Karel Zak b38c20e13a ilib/strutils: fix rounding in size_to_human_string()
Thanks to bub75 for the idea.

The patch adds SIZE_DECIMAL_2DIGITS into regression tests.

Addresses: https://github.com/karelzak/util-linux/issues/998
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-15 15:06:37 +02:00
Matthew Harm Bekkema 987550cbe8 unshare: Support names for map-user/group options
The --map-user and --map-group options can now be specified by either
uid/gid or user/group name.

Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
2020-04-15 23:05:16 +10:00
Matthew Harm Bekkema dc96ca29d8 lib/pwdutils: add xgetgrnam
Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
2020-04-15 22:50:59 +10:00
Karel Zak a890611357 mount: support "-o move" on command line
Addresses: https://github.com/karelzak/util-linux/issues/997
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-15 13:39:48 +02:00
Lukas Czerner 7084db77e6 blkdiscard: (man) offset and length must be sector aligned
Update blkdiscard manual page. Length and offset values must be aligned
to the device sector size.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
2020-04-15 11:32:05 +02:00
Karel Zak f48c407c9a scriptlive, scriptreplay: cleanup --maxdelay man page description
Addresses: https://github.com/karelzak/util-linux/issues/1004
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-14 11:40:38 +02:00
Karel Zak d3c08f4409 Merge branch '2020wk13' of https://github.com/kerolasa/util-linux
* '2020wk13' of https://github.com/kerolasa/util-linux:
  include: add remove_entry() to env.h
  tests: add sanitize_env() check
  more: fix moving backwards so that it can reach begining of the file
  more: use getopt_long() to parse options
  more: remove underlining related code
  more: fix SIGSTOP and SIGCONT handling
  more: make execute() more robust and timely
  more: target all standard streams when calling fflush()
  more: remove kill_line() in favor of erase_prompt()
  more: avoid defining special characters locally
  more: use off_t and cc_t to clarify what variables attempt to represent
  more: do not reset parent process terminal in execute()
  more: use single exit path to ensure resource freeing is unified
2020-04-14 11:29:25 +02:00
Disconnect3d 7fa6e86789
Fix off by one when checking "/dev/mapper/" path
This PR fixes an off by one in `strncmp(dev->bid_name, "/dev/mapper/", 11)` check. The `"/dev/mapper/"` string literal has a length of 12 and without this fix paths like `"/dev/mapperSOMETHING"` would also be accepted.
2020-04-13 16:14:10 +02:00
Sami Kerola ed292a08dd
include: add remove_entry() to env.h
A function to remove an command-line option argument, or environment
variable.

Requested-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1003#discussion_r403988092
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Sami Kerola 3d6fa8da69
tests: add sanitize_env() check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Sami Kerola 837f49c6bf
more: fix moving backwards so that it can reach begining of the file
Moving backwards has worked fine until reaching start of file.  At that
point more printout had one line too much in output causing more seemingly
never to be able to reach the start.  That is now fixed, with clean ups to
skip_backwards() making it less confusing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Sami Kerola e3cb27f535
more: use getopt_long() to parse options
This commit also includes fix to how initial skip lines and search are
instructed in the code.  Earlier version was pretty close impossible to make
work with getopt_long() and had minor flaw - if both initial skip lines and
search were defined at the same time the skipping did not happen.  That is
now corrected.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Sami Kerola 94bece3c22
more: remove underlining related code
Linux terminal handles underlining just fine without more executable needing
to do anything extra.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:08 +01:00
Sami Kerola 6dcaaa9ef5
more: fix SIGSTOP and SIGCONT handling
When suspending only the more process.  Sending signal to process group
makes signal destination unnecessarily vague.  After the suspend is over
SIGCONT is expected, and it needs to ensure output terminal settings are
what more needs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola c366ebc7ef
more: make execute() more robust and timely
The wait() is now a little more robust by being more tolerate rogue SIGCHLDs
and unblocked signals.  The repeated fork() and sleep() is removed, if first
try does not success give up without delay to provide user timely feedback.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola f3c044eeed
more: target all standard streams when calling fflush()
If streams need to be flushed do not try to be clever, just flush all of
them.  That lead to finding unnecessary print out in run_shell() that is
removed in this commit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola 21d096239c
more: remove kill_line() in favor of erase_prompt()
These functions did similar things, so there is no need for both of them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola 508b2d79df
more: avoid defining special characters locally
The sys/ttydefaults.h can be used for CTRL() and rubout that is CERASE.  For
alarm it's best to keep things simple and call printf() alarm modifier.
QUIT was not in use, so it is just deleted.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola ba105bb5eb
more: use off_t and cc_t to clarify what variables attempt to represent
As a minor robustness improvement use ftello() to find out file position
rather than add and substract from old value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola 437cec386f
more: do not reset parent process terminal in execute()
Only the terminal of the child process, that is the command being executed,
needs the reset.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:14:07 +01:00
Sami Kerola 73ff5a9561
more: use single exit path to ensure resource freeing is unified
And be a little more complete all the allocations that can be released are,
but there is a small catch.  As mentioned in ncurses FAQ some leaks are
intentional, and that's the way they are.

Reference: https://invisible-island.net/ncurses/ncurses.faq.html#config_leaks
Reference: http://man7.org/linux/man-pages/man3/_nc_free_tinfo.3x.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-04-13 12:13:51 +01:00
Matthew Harm Bekkema 6e837b5a38 unshare: allow custom uid/gid mappings in userns
Two new options are added: `--map-user=<uid>` and `--map-group=<gid>`
for custom user and group mappings respectively. These are just
generalizations of the existing `--map-root-user` and
`--map-current-user` options.

As a side effect of this commit, specifying both `--map-root-user` and
`--map-current-user` no longer causes an error. Instead, the last
occurrence takes precedence.

Addresses: https://github.com/karelzak/util-linux/issues/885
Signed-off-by: Matthew Harm Bekkema <id@mbekkema.name>
2020-04-12 22:47:38 +10:00
Karel Zak ea4dcdc788 tests: add zonefs blkid test
Thanks to Damien Le Moal for the image.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-06 15:33:23 +02:00
Jann Horn d6cfb75428 docs: renice(1): Add chrt(1) to SEE ALSO
A user who wants to change the niceness of a process is likely to also be
interested in changing the scheduler class and/or RT priority.

Signed-off-by: Jann Horn <jannh@google.com>
2020-04-06 11:59:43 +02:00
Karel Zak 3168ba091f libmount: use mnt_stat_mountpoint() on more places
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-06 11:58:29 +02:00
Fabian Vogt 7065cc0e53 libmount: Avoid triggering autofs in lookup_umount_fs_by_statfs
Currently, umount /foo results in a statfs("/foo") call, which triggers
autofs. This can create another mountpoint on /foo, which is then unmounted
later instead of the actual /foo at the time umount was called.

This is especially an issue for umount -R /bar, which just fails with
-EBUSY as the accidental mountpoint is never accounted for and so it tries
to umount /bar before /bar/someautofs.

Replace the direct statfs call with open(path, O_PATH) + fstatfs, which sees
the autofs mount directly, without triggering it.
2020-04-01 13:34:43 +02:00
Karel Zak bee4640067 libuuid: remove function alias
It seems the 'alias' attribute is not portable enough.

libuuid/src/unparse.c:72:17: error: only weak aliases are supported on darwin
        __attribute__((alias("uuid_unparse_lower")));

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-04-01 10:21:58 +02:00
Aurelien LAJOIE a5e322f4f4 cal: correctly set the week width
There is seven values but only 6 spaces between them, that why the -1
The value is always used with a minus one, just set it correctly instead
of always fix when used

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:32:01 +02:00
Aurelien LAJOIE b908299188 cal: Correctly center the year
Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:31:54 +02:00
Aurelien LAJOIE c1f1439316 cal: use a const char*
A put string function should not modify the char*

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:31:52 +02:00
Aurelien LAJOIE 2f81213e26 libuuid: improve uuid_unparse() performance
There is 2 improvements:

 * remove useless uuid_unpack,
 * directly print the hexa format from memory without using printf
   we can do this as the bytes order is the network byte order
   https://tools.ietf.org/html/rfc4122#section-4.1.2
   even the spatially unique node identifier(the last 6 bytes)

The improvement is important, some results for 1000000 uuid_unparse calls:

Little Endian Ubuntu:
before took 382623 us
after  took  36740 us

Big Endian OpenBSD:
before took 3138172 us
after  took  180116 us

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:29:39 +02:00
Karel Zak be0044b812 Merge branch 'more' of https://github.com/kerolasa/util-linux
* 'more' of https://github.com/kerolasa/util-linux:
  more: refactor and clarify code
  more: add display_file() to show files and stdin
  more: simplify initterm()
  more: move currently open file to control structure
  more: move code blocks from more_key_command() to functions
  more: move runtime usage output to a function
  more: restructure print_buf() if-else with continue
  more: tell in run time help what the 'v' will execute as editor
  more: drop setuid permissions before executing anything
  more: do not allocate shell command buffer from stack
  more: replace siglongjmp() and signal() calls with signalfd()
2020-03-31 13:17:20 +02:00
Karel Zak cd52e392ac lslogins: remove unnecessary brackets
Just to be consistent with the rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-31 13:12:11 +02:00
Karel Zak 737b972fbc Merge branch '2020wk12' of https://github.com/kerolasa/util-linux
* '2020wk12' of https://github.com/kerolasa/util-linux:
  lslogins: use lastlog as wtmp fallback
  login: avoid lseek() with pread() and pwrite()
  libuuid: ensure variable is initialized [cppcheck]
  ctrlaltdel: display error message indicated by errno
2020-03-31 13:05:53 +02:00
Karel Zak 16debd23e8 Merge branch 'mips' of https://github.com/FlyGoat/util-linux
* 'mips' of https://github.com/FlyGoat/util-linux:
  lscpu: Adapt MIPS cpuinfo
2020-03-31 12:54:58 +02:00
Karel Zak ef89802e83 fstrim: rename --quite to --quite-unsupported
We use --verbose together with --quite in service files. It seems
confusing, let's make the option more descriptive.

Addresses: https://github.com/karelzak/util-linux/issues/1001
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-31 12:26:54 +02:00
Sami Kerola 3434ac9720
lslogins: use lastlog as wtmp fallback
The wtmp file tends to rotate higher rate than lastlog, so use the later as
fallback in when wtmp tells nothing in LAST-LOGIN column.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-29 21:18:48 +01:00