Commit Graph

2748 Commits

Author SHA1 Message Date
Lennart Poettering
a0ea1dee7b blockdev-util: let us know if block_get_whole_disk() did anything 2019-07-04 00:01:09 +02:00
Lennart Poettering
51f14fa111 blockdev: filter out invalid block devices early 2019-07-04 00:00:54 +02:00
Lennart Poettering
d18b300933 blockdev-util: propagate actual error 2019-07-04 00:00:44 +02:00
Yu Watanabe
539bcc831b Merge pull request #12903 from keszybz/condition-quoting
Condition quoting
2019-06-30 04:10:40 +09:00
Zbigniew Jędrzejewski-Szmek
f8bab19674 Merge pull request #12887 from fbuihuu/coredump-cleanup-part-1
Coredump cleanup part 1
2019-06-28 16:25:46 +02:00
Zbigniew Jędrzejewski-Szmek
4ec8514142 Rename EXTRACT_QUOTES to EXTRACT_UNQUOTE
Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to
leave the quotes in or to take them out. Let's say "unquote", like we
say "cunescape".
2019-06-28 11:35:05 +02:00
Franck Bui
ae41fdb66a io-util: introduce iovw_put_string_field() helper 2019-06-27 19:14:27 +02:00
Franck Bui
11e6d9714e journal-import: extract helpers for handling arrays of iovec and make them available for others 2019-06-27 19:14:23 +02:00
Franck Bui
30a0554ebd coredump: rename set_iovec_field_free() into set_iovec_string_field_free()
It's more in line with its counterpart set_iovec_string_field().

Also move the definition to io-util next to set_iovec_string_field().
2019-06-27 19:01:28 +02:00
Yu Watanabe
71d7a8218d util,test: rename variable non_iec -> si 2019-06-27 10:17:20 +09:00
Lennart Poettering
05b2ace147 Merge pull request #12870 from yuwata/tree-wide-further-path-join-cleanups
tree-wide: further path_join() and path_joina() cleanups
2019-06-25 09:27:01 +02:00
Yu Watanabe
2d9b74ba87 tree-wide: replace strjoin() with path_join() 2019-06-24 23:59:38 +09:00
Michal Sekletar
b070c7c0e1 core: introduce NUMAPolicy and NUMAMask options
Make possible to set NUMA allocation policy for manager. Manager's
policy is by default inherited to all forked off processes. However, it
is possible to override the policy on per-service basis. Currently we
support, these policies: default, prefer, bind, interleave, local.
See man 2 set_mempolicy for details on each policy.

Overall NUMA policy actually consists of two parts. Policy itself and
bitmask representing NUMA nodes where is policy effective. Node mask can
be specified using related option, NUMAMask. Default mask can be
overwritten on per-service level.
2019-06-24 16:58:54 +02:00
Yu Watanabe
95bbf19e2f path-util: fix an issue when the path argument of prefix_roota() is not absolute
When the first argument is '/' and the second argument is not absolute,
the return value was not prefixed with '/'. This fixes the issue.
2019-06-24 23:37:11 +09:00
Yu Watanabe
6abdec98f3 tree-wide: use _cleanup_ attribute and strv_consume() + TAKE_PTR() 2019-06-24 14:57:58 +09:00
Lennart Poettering
cee97d5768 Merge pull request #12836 from yuwata/tree-wide-replace-strjoin
tree-wide: replace strjoin() with path_join()
2019-06-22 20:02:46 +02:00
Topi Miettinen
e48fcfef06 cgroup-util: kill also threads
It's possible for a zombie process to have live threads. These are not listed
in /sys in "cgroup.procs" for cgroupsv2, but they show up in
"cgroup.threads" (cgroupv2) or "tasks" (cgroupv1) nodes. When killing a
cgroup (v2 only) with SIGKILL, let's also kill threads after killing processes,
so the live threads of a zombie get killed too.

Closes #12262.
2019-06-22 18:35:48 +02:00
Lennart Poettering
c6134d3e2f path-util: get rid of prefix_root()
prefix_root() is equivalent to path_join() in almost all ways, hence
let's remove it.

There are subtle differences though: prefix_root() will try shorten
multiple "/" before and after the prefix. path_join() doesn't do that.
This means prefix_root() might return a string shorter than both its
inputs combined, while path_join() never does that. I like the
path_join() semantics better, hence I think dropping prefix_root() is
totally OK. In the end the strings generated by both functon should
always be identical in terms of path_equal() if not streq().

This leaves prefix_roota() in place. Ideally we'd have path_joina(), but
I don't think we can reasonably implement that as a macro. or maybe we
can? (if so, sounds like something for a later PR)

Also add in a few missing OOM checks
2019-06-21 08:42:55 +09:00
Anita Zhang
f66ad46066 nspawn: don't hard fail when setting capabilities
The OCI changes in #9762 broke a use case in which we use nspawn from
inside a container that has dropped capabilities from the bounding set
that nspawn expected to retain. In an attempt to keep OCI compliance
and support our use case, I made hard failing on setting capabilities
not in the bounding set optional (hard fail if using OCI and log only
if using nspawn cmdline).

Fixes #12539
2019-06-20 21:46:36 +02:00
Yu Watanabe
657ee2d82b tree-wide: replace strjoin() with path_join() 2019-06-21 03:26:16 +09:00
Lennart Poettering
4a33a02e99 capability: fix loops for cap_last_cap()
cap_last_cap() returns the last valid cap (instead of the number of
valid caps). to iterate through all known caps we hence need to use a <=
check, and not a < check like for all other cases. We got this right
usually, but in three cases we did not.
2019-06-20 14:55:24 +02:00
Lennart Poettering
64ef83139c Merge pull request #12837 from yuwata/tree-wide-lgtm-fixes
tree-wide: fix issues found by lgtm
2019-06-20 12:35:34 +02:00
Yu Watanabe
b19eab1f74 Merge pull request #12806 from yuwata/networkctl-ethtool-12657
networkctl: show speed, duplex, auto negotiation, and port
2019-06-20 06:56:37 +09:00
Yu Watanabe
31a9be2372 util: use extract_first_word() instead of strsep() 2019-06-20 06:51:34 +09:00
Yu Watanabe
b7de125bba util: make format_bytes() support e.g. 3.0E 2019-06-19 23:15:19 +09:00
Yu Watanabe
aa89266900 util: introduce format_bytes_full()
And move it into format-util.c.
2019-06-19 23:15:19 +09:00
Yu Watanabe
f3f0d873e2 util: introduce siphash24_compress_boolean() 2019-06-19 21:03:16 +09:00
Frantisek Sumsal
31c9d74d50 hashmap: avoid using TLS in a destructor
Using C11 thread-local storage in destructors causes uninitialized
read. Let's avoid that using a direct comparison instead of using
the cached values. As this code path is taken only when compiled
with -DVALGRIND=1, the performance cost shouldn't matter too much.

Fixes #12814
2019-06-18 13:59:12 +02:00
Franck Bui
ae1d13db05 terminal-util: introduce openpt_allocate()
Allocating a pty is done in a couple of places so let's introduce a new helper
which does the job.

Also the new function, as well as openpt_in_namespace(), returns both pty
master and slave so the callers don't need to know about the pty slave
allocation details.

For the same reasons machine_openpt() prototype has also been changed to return
both pty master and slave so callers don't need to allocate a pty slave which
might be in a different namespace.

Finally openpt_in_namespace() has been renamed into
openpt_allocate_in_namespace().
2019-06-18 09:26:31 +02:00
Franck Bui
04c84cd173 namespace-util: make use of TAKE_FD()
No functional changes.
2019-06-18 07:54:51 +02:00
Franck Bui
71ec74d193 fs-util: no need for fchmod_and_chown() to access /proc/self/fd directly
fstat(2) is fine with O_PATH fds.

For changing owership of a file opened with O_PATH, there's fchownat(2).

Only changing permissions is problematic but we introduced fchmod_opath() for
that purpose.
2019-06-18 07:54:51 +02:00
Zbigniew Jędrzejewski-Szmek
2bb24885de Merge pull request #12700 from yuwata/udev-propagate-critical-errors
udev: modernize code and propagate critical errors
2019-06-03 15:29:40 +02:00
Zbigniew Jędrzejewski-Szmek
3135369cff basic/memory-util: do not "return" anything from memzero() macro
The macro is not used in expressions, so we don't need the ternary statement.
2019-05-30 22:55:32 +02:00
Yu Watanabe
7e4831d296 util: introduce strnpcpy() and strnscpy() 2019-05-30 21:08:51 +09:00
Yu Watanabe
961189af2a util: introduce PTR_TO_MODE and MODE_TO_PTR macros 2019-05-30 21:08:51 +09:00
Michal Sekletar
3f09629c22 Merge pull request #12628 from keszybz/dbus-execute
Rework cpu affinity parsing
2019-05-30 12:32:53 +02:00
Zbigniew Jędrzejewski-Szmek
f44b3035d4 Move cpus_in_affinity_mask() to cpu-set-util.[ch]
It just seems to fit better there and it's always better to have things
in shared/ rather than basic/.
2019-05-29 10:26:00 +02:00
Yu Watanabe
518a66ec08 tree-wide: replace if_indextoname() with format_ifname() 2019-05-29 14:21:19 +09:00
Yu Watanabe
7f686722f7 util: introduce format_ifname() 2019-05-29 14:21:19 +09:00
Yu Watanabe
f5072281ba util: add assertions 2019-05-29 13:21:51 +09:00
Yu Watanabe
88465a4ee7 util: introduce parse_ifindex_or_ifname() 2019-05-29 13:21:18 +09:00
Zbigniew Jędrzejewski-Szmek
6bf901a9b5 Merge pull request #12437 from poettering/chmod-and-chown-rewrite
chmod_and_chown() rewrite
2019-05-28 15:12:20 +02:00
Zbigniew Jędrzejewski-Szmek
127c167cdb Merge pull request #12390 from poettering/string-file-mkdir
fileio: add a WRITE_STRING_FILE_MKDIR_0755 flag to write_string_file() that creates parent directories if needed
2019-05-28 14:42:55 +02:00
Zbigniew Jędrzejewski-Szmek
365939fc9f Merge pull request #12392 from poettering/firstboot-salt
generalize crypt_r() salt generation code
2019-05-28 14:36:54 +02:00
Lennart Poettering
1c99d2e0c5 Merge pull request #12597 from keszybz/analyze-timestamp
Analyze timestamps
2019-05-28 14:34:53 +02:00
Lennart Poettering
7345109e61 capability-util: be more careful with types 2019-05-28 14:23:20 +02:00
Lennart Poettering
1802d5f2cf terminal-util: reset access mode in vt_restore(), too
Only changing ownership back to root is not enough we also need to
change the access mode, otherwise the user might have set 666 first, and
thus allow everyone access before and after the chown().
2019-05-24 15:07:55 +02:00
Lennart Poettering
4b3b5bc71b tree-wide: port various places over to use chmod_and_chown()
Doing this properly is hard, hence let's unify the code.
2019-05-24 15:07:55 +02:00
Lennart Poettering
f8a8579e84 tmpfile-util: simplify umask reset declaration 2019-05-24 15:07:55 +02:00
Lennart Poettering
2dbb7e94af fs-util: rewrite chmod_and_chown()
Inspired by #12431 let's also rework chmod_and_chown() and make sure we
never add more rights to a file not owned by the right user.

Also, let's make chmod_and_chown() just a wrapper arond
fchmod_and_chown().

let's also change strategy: instead of chown()ing first and stating
after on failure and supressing errors, let's avoid the chown in the
firts place, in the interest on keeping things minimal.
2019-05-24 15:07:55 +02:00