* '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
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>
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>
* '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
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
* '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()
* '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
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>
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>
This fix has a little bit of a feel of making a static analyzer to be happy
instead of real progress. If I read the preprocessor directives correctly
it should be impossible hit uninitialized variable. Then again if a bug
creeps into these ifdef's in that case it is nice to have robust code that
doesn't immediately go wrong.
libuuid/src/gen_uuid.c:200:20: error: Uninitialized variable: a [uninitvar]
memcpy(node_id, a, 6);
^
libuuid/src/gen_uuid.c:197:8: error: Uninitialized variable: a [uninitvar]
if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
^
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use the backspace provided dy terminfo, and if that is not possible use
fallback.
Simplify entering and exiting standard mode. Now when these std_enter and
std_exit variables are initialized correctly they do not need to be checked
quite as complex way as earlier.
Do not call prepare_line_buffer() unnecessarily. The line buffer needs only
to be prepared only at times of more(1) initialization and when terminal
size changes.
Add a function to print various separators, that is better than static
strings.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier main() inline code implemented input files and stdin displaying
separately. With small restructuring this code can be shared.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Return rather than use long 'else' statement. Also unwind some overly
compact variable set and test code, that can be best observed how
underlining settings are now handled.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Currently open file is needed a bit here and there. Move it to control
structure to avoid passing it around. This also makes fixing memory leak at
more_exit() very easy.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This change also removes a ghost prompt that was left in place when printing
help. When looking old commits the output fluke has been around at least
since util-linux v2.2.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Replacing long 'else' with 'continue' allows dropping one level of
indentation. Main aim is to improve code readability by reducing
complexity one needs to keep track while looking the code.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>