Commit graph

2780 commits

Author SHA1 Message Date
Lennart Poettering a7d9fccd0e locale-util: suppress non-UTF-8 locales when enumerating them
Let's hide non-UTF-8 locales by default. It's 2019 after all.

Let's add an undocumented env var to reenable listing them though.

This should substantially shorten the list of choices we offer users,
and only show realistic choices.

note that only firstboot and localectl make use of this information, and
both allow configuration of values outside of these lists, hence all
this change does is hide legacy options, but they are still available if
you know what you do, and that's how it should be.
2019-07-14 11:05:34 +02:00
Lennart Poettering 13f4580626 locale-util: normalize UTF-8 locale names
Let's generate out lists in the format people expect.
2019-07-14 11:05:34 +02:00
Yu Watanabe 94e016650d
Merge pull request #13043 from poettering/strip-tab-ansi-no-static-size
util-lib: [static] array argument sizes are apparently not OK for NUL…
2019-07-13 18:12:39 +09:00
Lennart Poettering b65011dad0 alloc-util: drop _alloc_ decorator from memdup_suffix0()
Fixes: https://github.com/systemd/systemd/pull/13034#issuecomment-510801671
2019-07-13 11:04:20 +02:00
Lennart Poettering 6fb0569065 util-lib: [static] array argument sizes are apparently not OK for NULL parameters
Let's drop the 'static' logic when a parameter can be NULL.

I think asan/ubsan are right here, judging by the C99 spec language:

"A declaration of a parameter as ‘‘array of type’’ shall be adjusted to
‘‘qualified pointer to type’’, where the type qualifiers (if any) are
those specified within the [ and ] of the array type derivation. If the
keyword static also appears within the [ and ] of the array type
derivation, then for each call to the function, the value of the
corresponding actual argument shall provide access to the first element
of an array with at least as many elements as specified by the size
expression."

If we specify NULL, then we certainly don't pvode access to any valid
array.

Fixes: #13039
2019-07-12 16:40:10 +02:00
Lennart Poettering 5978345750
Merge pull request #13034 from poettering/memdup-suffix0-multiply-fixo
memdup_suffix0_multiply fix
2019-07-12 14:11:31 +02:00
Lennart Poettering bf21be1050 util-lib: fix comment
As suggested by @ralt.

Fixes: #12896
2019-07-12 09:37:49 +02:00
Lennart Poettering 7d025debfa alloc-util: drop _alloc_(2, 3) decorator from memdup_suffix0_multiply()
This decorator tells compilers that the memory we return is shorter than
it actually is, thus triggering misleading bad memory access complaints.

Fixes: #13026
2019-07-12 09:11:40 +02:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Yu Watanabe 6fa0524133
Merge pull request #12971 from yuwata/network-reassign-static-routes
network: reassign static routes and process reply address messages
2019-07-12 09:36:16 +09:00
Lennart Poettering 66855de739 tree-wide: make use of errno_or_else() everywhere 2019-07-11 23:20:31 +02:00
Lennart Poettering fed813778f errno-util: add new errno_or_else() helper 2019-07-11 23:20:31 +02:00
Yu Watanabe 9a897e22d4 util: introduce in4_addr_equal() 2019-07-11 22:37:00 +09:00
Lennart Poettering 4c2f584230 core: hook up service unit type with the new clean operation
The implementation is pretty straight-foward: when we get a request to
clean some type of resources we fork off a process doing that, and while
it is running we are in the "cleaning" state.
2019-07-11 12:18:51 +02:00
Lennart Poettering 380dc8b0a2 core: add generic "clean" operation to units
This adds basic infrastructure to implement a "clean" operation for unit
types. This "clean" operation is supposed to remove on-disk resources of
units, and is supposed to be used in a later commit to clean our
RuntimeDirectory=, StateDirectory= and so on of service units.

Later commits will open this up to the bus, and hook up service units
with this.

This also adds a new generic ActiveState called UNIT_MAINTENANCE. It's
supposed to cover all kinds of "maintainance" state of units.
Specifically, this is supposed to cover the "cleaning" operations later
added for service units which might take a bit of time. This high-level,
generic, abstract state is called UNIT_MAINTENANCE instead of the
more specific "UNIT_CLEANING", since I think this should be kept open
for different operations possibly later on that could be nicely subsumed
under this (for example, maybe a recursive chown()ing operation could be
covered by this, and similar).
2019-07-11 12:18:51 +02:00
Lennart Poettering c0228b4fa3 rm-rf: introduce new flag REMOVE_MISSING_OK
This new flag suppresses error if the top-level path specified doesn't
exist. This is useful since suppressing this on the caller side isn't
easy, since ENOENT migh be propagate for some reason from further inside
and we can't distuingish that.

While we are at it, also be a bit more careful witht the various
combinations of flags.

(Note that in some cases rm_rf() was already ignoring ENOENT from
unlink() or rmdir(), however that was pretty useless, since we always
open() the top-level path with O_DIRECTORY and if that hit ENOENT we
didn't ignore the failure).
2019-07-11 12:18:51 +02:00
Lennart Poettering 8e27167cc9
Merge pull request #13011 from keszybz/auto-erase
Remove string_erase and friends
2019-07-11 01:05:01 +02:00
Lennart Poettering 08945b59d1
Merge pull request #12926 from keszybz/urlify-logs
Urlify CONFIG_FILE and improve SYSTEMD_LOG_LOCATION
2019-07-11 00:00:34 +02:00
Lennart Poettering 6f209cb01d
Merge pull request #12965 from keszybz/auto-erase
_cleanup_(erase_and_freep)
2019-07-10 16:20:50 +02:00
Lennart Poettering ba40f0399e
Merge pull request #12939 from yuwata/lgtm-fixes
make LGTM quiet
2019-07-10 14:57:14 +02:00
Zbigniew Jędrzejewski-Szmek 309c6b19a7 Remove string_erase 2019-07-10 14:43:44 +02:00
Zbigniew Jędrzejewski-Szmek 9ae4ef49cd Remove string_free_erase 2019-07-10 13:48:55 +02:00
Zbigniew Jędrzejewski-Szmek 44c786f04a test: add _cleanup_(erase_and_freep)
Based on the macro and test case by Lennart Poettering and
Topi Miettinen suggestion.
2019-07-10 11:39:03 +02:00
Yu Watanabe 8164e30603 util: fix sign-compare warning 2019-07-09 09:54:13 +02:00
Ivan Shapovalov df2452c553 basic/log: fix SYSTEMD_LOG_* parsing error messages
(likely a copy-paste gone wrong)
2019-07-06 13:47:06 +03:00
Yu Watanabe 4bbccb02ea tree-wide: introduce strerror_safe() 2019-07-05 02:43:56 +09:00
Zbigniew Jędrzejewski-Szmek 1f65fd4926 basic/time-util: add helper function to check if timestamp is set
No functional change.
2019-07-04 19:12:47 +02:00
Zbigniew Jędrzejewski-Szmek bdc3426870 basic/log: omit ":0" from message when line number is not specified
And obviously CONFIG_LINE=0 is also not logged.

The way that log_syntax_internal now looks is becoming a bit crazy, but we
can't easily conditionalize on both unit and config_file, and we have different
types, so it's not easy to make this more compact.
2019-07-04 10:36:24 +02:00
Zbigniew Jędrzejewski-Szmek 62c6bbbc09 tree-wide: use PROJECT_FILE instead of __FILE__
This replaces the internal uses of __FILE__ with the new macro.
2019-07-04 10:36:00 +02:00
Zbigniew Jędrzejewski-Szmek a0b15b4177 basic/log: add a define for path relative to source root
When using build/ directory inside of the source directory:
__FILE__: ../src/test/test-log.c
RELATIVE_SOURCE_PATH: ..
PROJECT_FILE: src/test/test-log.c

When using a build directory outside of the source directory:
__FILE__: ../../../home/zbyszek/src/systemd-work/src/test/test-log.c
RELATIVE_SOURCE_PATH: ../../../home/zbyszek/src/systemd-work
PROJECT_FILE: src/test/test-log.c
2019-07-04 10:27:19 +02:00
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
Zbigniew Jędrzejewski-Szmek d35305fe83 basic/log: put location in a dark shade of yellow
It is different then the other colors we use. Tested on gnome-terminal,
urxvt, urxvt -rv, xterm, linux console.
2019-07-02 09:34:12 +02:00
Zbigniew Jędrzejewski-Szmek 1ad023e770 basic/log: drop parens from around file location information
There's really no risk of confusion, and shorter is better.
2019-07-01 14:32:45 +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