chiark / gitweb /
elogind.git
5 years agoUse const char* for timestamp strings which we don't plan to modify
Zbigniew Jędrzejewski-Szmek [Thu, 24 May 2018 07:36:56 +0000 (09:36 +0200)]
Use const char* for timestamp strings which we don't plan to modify

Makes the intent a bit clearer.

5 years agoAlways allow timestamps to be printed
Zbigniew Jędrzejewski-Szmek [Mon, 21 May 2018 18:39:09 +0000 (20:39 +0200)]
Always allow timestamps to be printed

If the timestamp is above 9999-12-30, (or 2038-something-something on 32 bit),
use XXXX-XX-XX XX:XX:XX as the replacement.

The problem with refusing to print timestamps is that our code accepts such
timestamps, so we can't really just refuse to process them afterwards. Also, it
makes journal files non-portable, because suddently we might completely refuse
to print entries which are totally OK on a different machine.

5 years agobasic/random-util: do not use getrandom() under msan
Evgeny Vereshchagin [Sun, 20 May 2018 13:07:07 +0000 (15:07 +0200)]
basic/random-util: do not use getrandom() under msan

`fuzz-journal-remote` seems to be failing under `msan` as soon as it starts:

$ sudo infra/helper.py run_fuzzer systemd fuzz-journal-remote
Running: docker run --rm -i --privileged -e FUZZING_ENGINE=libfuzzer -v /home/vagrant/oss-fuzz/build/out/systemd:/out -t gcr.io/oss-fuzz-base/base-runner run_fuzzer fuzz-journal-remote
Using seed corpus: fuzz-journal-remote_seed_corpus.zip
/out/fuzz-journal-remote -rss_limit_mb=2048 -timeout=25 /tmp/fuzz-journal-remote_corpus -max_len=65536 < /dev/null
INFO: Seed: 3380449479
INFO: Loaded 2 modules   (36336 inline 8-bit counters): 36139 [0x7ff36ea31d39, 0x7ff36ea3aa64), 197 [0x9998c8, 0x99998d),
INFO: Loaded 2 PC tables (36336 PCs): 36139 [0x7ff36ea3aa68,0x7ff36eac7d18), 197 [0x999990,0x99a5e0),
INFO:        2 files found in /tmp/fuzz-journal-remote_corpus
INFO: seed corpus: files: 2 min: 4657b max: 7790b total: 12447b rss: 97Mb
Uninitialized bytes in __interceptor_pwrite64 at offset 24 inside [0x7fffdd4d7230, 240)
==15==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7ff36e685e8a in journal_file_init_header /work/build/../../src/systemd/src/journal/journal-file.c:436:13
    #1 0x7ff36e683a9d in journal_file_open /work/build/../../src/systemd/src/journal/journal-file.c:3333:21
    #2 0x7ff36e68b8f6 in journal_file_open_reliably /work/build/../../src/systemd/src/journal/journal-file.c:3520:13
    #3 0x4a3f35 in open_output /work/build/../../src/systemd/src/journal-remote/journal-remote.c:70:13
    #4 0x4a34d0 in journal_remote_get_writer /work/build/../../src/systemd/src/journal-remote/journal-remote.c:136:21
    #5 0x4a550f in get_source_for_fd /work/build/../../src/systemd/src/journal-remote/journal-remote.c:183:13
    #6 0x4a46bd in journal_remote_add_source /work/build/../../src/systemd/src/journal-remote/journal-remote.c:235:13
    #7 0x4a271c in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-journal-remote.c:36:9
    #8 0x4f27cc in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:524:13
    #9 0x4efa0b in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:448:3
    #10 0x4f8e96 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:732:7
    #11 0x4f9f73 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:752:3
    #12 0x4bf329 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:756:6
    #13 0x4ac391 in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #14 0x7ff36d14982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #15 0x41f9d8 in _start (/out/fuzz-journal-remote+0x41f9d8)

  Uninitialized value was stored to memory at
    #0 0x7ff36e61cd41 in sd_id128_randomize /work/build/../../src/systemd/src/libsystemd/sd-id128/sd-id128.c:288:16
    #1 0x7ff36e685cec in journal_file_init_header /work/build/../../src/systemd/src/journal/journal-file.c:426:13
    #2 0x7ff36e683a9d in journal_file_open /work/build/../../src/systemd/src/journal/journal-file.c:3333:21
    #3 0x7ff36e68b8f6 in journal_file_open_reliably /work/build/../../src/systemd/src/journal/journal-file.c:3520:13
    #4 0x4a3f35 in open_output /work/build/../../src/systemd/src/journal-remote/journal-remote.c:70:13
    #5 0x4a34d0 in journal_remote_get_writer /work/build/../../src/systemd/src/journal-remote/journal-remote.c:136:21
    #6 0x4a550f in get_source_for_fd /work/build/../../src/systemd/src/journal-remote/journal-remote.c:183:13
    #7 0x4a46bd in journal_remote_add_source /work/build/../../src/systemd/src/journal-remote/journal-remote.c:235:13
    #8 0x4a271c in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-journal-remote.c:36:9
    #9 0x4f27cc in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:524:13
    #10 0x4efa0b in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:448:3
    #11 0x4f8e96 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:732:7
    #12 0x4f9f73 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:752:3
    #13 0x4bf329 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:756:6
    #14 0x4ac391 in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #15 0x7ff36d14982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

  Uninitialized value was created by an allocation of 't' in the stack frame of function 'sd_id128_randomize'
    #0 0x7ff36e61cb00 in sd_id128_randomize /work/build/../../src/systemd/src/libsystemd/sd-id128/sd-id128.c:274

SUMMARY: MemorySanitizer: use-of-uninitialized-value /work/build/../../src/systemd/src/journal/journal-file.c:436:13 in journal_file_init_header
Exiting
MS: 0 ; base unit: 0000000000000000000000000000000000000000
artifact_prefix='./'; Test unit written to ./crash-847911777b3096783f4ee70a69ab6d28380c810b
[vagrant@localhost oss-fuzz]$ sudo infra/helper.py check_build --sanitizer=memory systemd
Running: docker run --rm -i --privileged -e FUZZING_ENGINE=libfuzzer -e SANITIZER=memory -v /home/vagrant/oss-fuzz/build/out/systemd:/out -t gcr.io/oss-fuzz-base/base-runner test_all
INFO: performing bad build checks for /out/fuzz-dhcp-server.
INFO: performing bad build checks for /out/fuzz-journal-remote.
INFO: performing bad build checks for /out/fuzz-unit-file.
INFO: performing bad build checks for /out/fuzz-dns-packet.
4 fuzzers total, 0 seem to be broken (0%).
Check build passed.

It's a false positive which is most likely caused by
https://github.com/google/sanitizers/issues/852. I think it could be got around
by avoiding `getrandom` when the code is compiled with `msan`

5 years agobasic/journal-importer: escape & ellipsize bad data in log entries
Zbigniew Jędrzejewski-Szmek [Thu, 17 May 2018 09:09:07 +0000 (11:09 +0200)]
basic/journal-importer: escape & ellipsize bad data in log entries

We shouldn't just log arbitrary stuff, in particular newlines and control chars
Now:
Unknown dunder line __CURSORFACILITY=6\nSYSLOG_IDENTIFIER=/USR/SBIN/CRON\nMES…, ignoring.
Unknown dunder line __REALTIME_TIME[TAMP=1404101101501874\n__MONOTONIC_TIMEST…, ignoring.

5 years agobasic/string-util: add a convenience function to cescape mostly-ascii fields
Zbigniew Jędrzejewski-Szmek [Thu, 17 May 2018 08:55:21 +0000 (10:55 +0200)]
basic/string-util: add a convenience function to cescape mostly-ascii fields

It's not supposed to be the most efficient, but instead fast and simple to use.

I kept the logic in ellipsize_mem() to use unicode ellipsis even in non-unicode
locales. I'm not quite convinced things should be this way, especially that with
this patch it'd actually be simpler to always use "…" in unicode locale and "..."
otherwise, but Lennart wanted it this way for some reason.

5 years agobasic/journal-importer: do not write non-unicode char to log
Zbigniew Jędrzejewski-Szmek [Thu, 17 May 2018 08:04:24 +0000 (10:04 +0200)]
basic/journal-importer: do not write non-unicode char to log

The type of cescape_char() is changed to int to make it easier to use
in "%.*s". We know the value is between 1 and 4, so size_t is overkill.

5 years agofuzz-journal-remote: a fuzzer for journal-remote over-the-wire input
Zbigniew Jędrzejewski-Szmek [Wed, 16 May 2018 10:05:07 +0000 (12:05 +0200)]
fuzz-journal-remote: a fuzzer for journal-remote over-the-wire input

5 years agosd-id128: return -ENOMEDIUM on null id
Zbigniew Jędrzejewski-Szmek [Wed, 16 May 2018 11:55:12 +0000 (13:55 +0200)]
sd-id128: return -ENOMEDIUM on null id

We currently return -ENOMEDIUM when /etc/machine-id is empty, and -EINVAL when
it is all zeros. But -EINVAL is also used for invalid args. The distinction
between empty and all-zero is not very important, let's use the same return
code.

Also document -ENOENT and -ENOMEDIUM since they can be a bit surprising.

5 years agojournal-remote: split out µhttpd support and main() into a separate file
Zbigniew Jędrzejewski-Szmek [Wed, 16 May 2018 08:21:58 +0000 (10:21 +0200)]
journal-remote: split out µhttpd support and main() into a separate file

This is in preparation to reusing the RemoteServer in other concepts.
I tried to keep changes to minimum:
- arg_* global variables are now passed as state in RemoteServer
- exported functions get the "journal_remote_" prefix
- some variables are renamed

In particular, there is an ugly global RemoveServer* variable. It was originally
added because µhttpd did not allow state to be passed to the callbacks. I'm not
sure if this has been remediated in µhttpd, but either way, this is not changed
here, the global variable is only renamed for clarity.

5 years agodoc: update TODO
Yu Watanabe [Thu, 31 May 2018 08:39:13 +0000 (17:39 +0900)]
doc: update TODO

5 years agotree-wide: make use of memory_startswith() at various places
Lennart Poettering [Wed, 30 May 2018 11:09:03 +0000 (13:09 +0200)]
tree-wide: make use of memory_startswith() at various places

5 years agostring-util: add new memory_startswith() helper
Lennart Poettering [Wed, 30 May 2018 11:07:37 +0000 (13:07 +0200)]
string-util: add new memory_startswith() helper

We have code like this at various placer, let's make things shorter and
more readable with a helper for it.

5 years agosocket-util: rename parse_socket_address_bind_ipv6_only_or_bool() to socket_address_b...
Yu Watanabe [Tue, 29 May 2018 03:40:28 +0000 (12:40 +0900)]
socket-util: rename parse_socket_address_bind_ipv6_only_or_bool() to socket_address_bind_ipv6_only_or_bool_from_string()

Hence, we can define config_parse_socket_bind() by using
DEFINE_CONFIG_PARSE_ENUM() macro.

5 years agoconf-parser: introduce DEFINE_CONFIG_PARSE*() macros
Yu Watanabe [Sat, 26 May 2018 16:39:12 +0000 (01:39 +0900)]
conf-parser: introduce DEFINE_CONFIG_PARSE*() macros

This introduces several macros for defining config parsers.
Also this fixes errno in DEFINE_CONFIG_PARSE_ENUM() and _ENUMV()
and makes the log level lower when a duplicated item is
specified to the settings parsed by the function defined by
DEFINE_CONFIG_PARSE_ENUMV().

5 years agosmack: make mac_smack_fix() deal somewhat sensible with non-absolute paths
Lennart Poettering [Wed, 30 May 2018 16:21:58 +0000 (18:21 +0200)]
smack: make mac_smack_fix() deal somewhat sensible with non-absolute paths

This tries to improve the mac_smack_fix() logic a bit, by properly
handling non-absolute paths.

It's still pretty broken though, which is sad for security technology:
non-normalized paths (for example "/usr/../dev/sda") will still not be
treated correctly. I am not sure how to fix that properly though, and I
don't understand SMACK well enough to do so. This fix hence just fixes
to most obvious glaring issue.

5 years agosd-bus: make add match method callback slot "floating"
Lennart Poettering [Wed, 30 May 2018 14:35:36 +0000 (16:35 +0200)]
sd-bus: make add match method callback slot "floating"

When we allocate an asynchronous match object we will allocate an
asynchronous bus call object to install the match server side.
Previously the call slot would be created as regular slot, i.e.
non-floating which meant installing the match even if it was itself
floating would result in a non-floating slot to be created internally,
which ultimately would mean the sd_bus object would be referenced by it,
and thus never be freed.

Let's fix that by making the match method callback floating in any case
as we have no interest in leaving the bus allocated beyond the match
slot.

Fixes: #8551
5 years agobus-slot: for bus slot objects with no explicit description use the match string...
Lennart Poettering [Wed, 30 May 2018 14:34:06 +0000 (16:34 +0200)]
bus-slot: for bus slot objects with no explicit description use the match string as description

Let's make debugging a but easier with implicit descriptions for some
match objects.

5 years agoman: document the new sd_bus_slot_set_floating() call
Lennart Poettering [Wed, 30 May 2018 14:33:12 +0000 (16:33 +0200)]
man: document the new sd_bus_slot_set_floating() call

Also extend the memory management description of sd-bus highlighting the
effect of "floating" slot objects a bit.

5 years agosd-bus: add new sd_bus_slot_set_floating() call
Lennart Poettering [Wed, 30 May 2018 14:29:33 +0000 (16:29 +0200)]
sd-bus: add new sd_bus_slot_set_floating() call

This new call allows explicit control of the "floating" state of a bus
slot object. This is useful for creating a bus slot object first,
retaining a reference to it, using it for making changes to the slot
object (for example, set a description) and then handing it over to
sd-bus for lifecycle management.

It's also useful to fix #8551.

5 years agoman: fix minor typo
Lennart Poettering [Wed, 30 May 2018 14:28:28 +0000 (16:28 +0200)]
man: fix minor typo

5 years agotree-wide: fix typo in comments and NEWS
Yu Watanabe [Tue, 29 May 2018 16:07:37 +0000 (01:07 +0900)]
tree-wide: fix typo in comments and NEWS

5 years agoconf-parser: add a bit more whitespace
Lennart Poettering [Mon, 28 May 2018 19:47:43 +0000 (21:47 +0200)]
conf-parser: add a bit more whitespace

We usually seperate case statements within a switch from each other by
empty lines. We also often add an empty line after multi-line function
prototypes, let's do so here too

Also, no trailing ; after }...

5 years agoupdate TODO
Lennart Poettering [Tue, 29 May 2018 09:40:49 +0000 (11:40 +0200)]
update TODO

5 years agodoc: mention RestrictNamespaces= merges multiple assignment now
Yu Watanabe [Tue, 29 May 2018 06:11:35 +0000 (15:11 +0900)]
doc: mention RestrictNamespaces= merges multiple assignment now

Follow-up for #8817.

5 years agomeson: use a convenience static library for nspawn core
Zbigniew Jędrzejewski-Szmek [Mon, 28 May 2018 08:37:11 +0000 (10:37 +0200)]
meson: use a convenience static library for nspawn core

This makes it easier to link the nspawn implementation to the tests.
Right now this just means that nspawn-patch-uid.c is not compiled
twice, which is nice, but results in test-patch-uid being slightly bigger,
which is not nice. But in general, we should use convenience libs to
compile everything just once, as far as possible. Otherwise, once we
start compiling a few files here twice, and a few file there thrice, we
soon end up in a state where we are doing hundreds of extra compilations.
So let's do the "right" thing, even if is might not be more efficient.

5 years agomeson: test out headers with more standard versions
Zbigniew Jędrzejewski-Szmek [Mon, 28 May 2018 07:07:36 +0000 (09:07 +0200)]
meson: test out headers with more standard versions

They all pass fine, but let's keep testing regularly.

5 years agobash-completion: add completion for portablectl
Yu Watanabe [Mon, 28 May 2018 06:38:19 +0000 (15:38 +0900)]
bash-completion: add completion for portablectl

5 years agocore: add --dump-bus-properties option to systemd
Yu Watanabe [Mon, 28 May 2018 09:13:19 +0000 (18:13 +0900)]
core: add --dump-bus-properties option to systemd

If systemd is invoked with this option, this dumps all bus properties.
This may be useful for shell completion for `systemctl --property`.

5 years agosd-bus: use _cleanup_ more
Zbigniew Jędrzejewski-Szmek [Sat, 26 May 2018 14:56:01 +0000 (16:56 +0200)]
sd-bus: use _cleanup_ more

5 years agojournalctl: add with-unit mode
Luca Boccassi [Tue, 22 May 2018 11:22:00 +0000 (12:22 +0100)]
journalctl: add with-unit mode

When dealing with a large number of template instances, for example
when launching daemons per VRF, it is hard for operators to correlate
log lines to arguments.
Add a new with-unit mode which, if available, prefixes unit and user
unit names when displaying its log messages instead of the syslog
identifier. It will also use the full timestamp with timezones, like
the short-full mode.

5 years agotree-wide: drop unused variables
Yu Watanabe [Fri, 25 May 2018 09:09:01 +0000 (18:09 +0900)]
tree-wide: drop unused variables

Follow-ups for #8620.

5 years agoupdate TODO
Lennart Poettering [Mon, 16 Apr 2018 10:37:25 +0000 (12:37 +0200)]
update TODO

5 years agoman: add man pages for the portable service stuff
Lennart Poettering [Tue, 17 Apr 2018 15:40:34 +0000 (17:40 +0200)]
man: add man pages for the portable service stuff

5 years agoadd new portable service framework
Lennart Poettering [Mon, 16 Apr 2018 19:41:40 +0000 (21:41 +0200)]
add new portable service framework

This adds a small service "systemd-portabled" and a matching client
"portablectl", which implement the "portable service" concept.

The daemon implements the actual operations, is PolicyKit-enabled and is
activated on demand with exit-on-idle.

Both the daemon and the client are an optional build artifact, enabled
by default rhough.

5 years agomachined: move bus_reply_pair_array() into generic utilities
Lennart Poettering [Mon, 9 Apr 2018 17:44:21 +0000 (19:44 +0200)]
machined: move bus_reply_pair_array() into generic utilities

This way, we can reuse it in portabled.

5 years agoconf-files: beef up conf-files.[ch] a bit
Lennart Poettering [Mon, 16 Apr 2018 19:24:13 +0000 (21:24 +0200)]
conf-files: beef up conf-files.[ch] a bit

This adds fozr new flags:

- If CONF_FILES_DIRECTORY is specified conf_file_list() and friends
  will look for directories only.

- Similar CONF_FILES_REGULAR means we'll look only for regular files.

- If CONF_FILES_BASENAME is specified the resulting list will contain
  only the basenames of all discovered files or directories, not the
  full paths.

- If CONF_FILES_FILTER_MASKED is specified the resulting list will have
  masked entries removed (i.e. those symlinked to /dev/null and
  suchlike)

These four flags are useful for discovering portable service profile
information.

While we are at it, also improve a couple of other things:

- More debug logging

- use path_hash_ops instead of string_hash_ops when putting together the
  path lists

5 years agofileio: make sure read_full_stream() works on memory-backed streams
Lennart Poettering [Tue, 17 Apr 2018 09:07:56 +0000 (11:07 +0200)]
fileio: make sure read_full_stream() works on memory-backed streams

5 years agoos-util: add helpers for finding /etc/os-release
Lennart Poettering [Mon, 26 Mar 2018 14:32:40 +0000 (16:32 +0200)]
os-util: add helpers for finding /etc/os-release

Place this new helpers in a new source file os-util.[ch], and move the
existing and related call path_is_os_tree() to it as well.

5 years agofileio: add parse_env_filev() that is like parse_env_file() but takes a va_list
Lennart Poettering [Mon, 26 Mar 2018 17:20:47 +0000 (19:20 +0200)]
fileio: add parse_env_filev() that is like parse_env_file() but takes a va_list

5 years agofileio: accept FILE* in addition to path in parse_env_file()
Lennart Poettering [Fri, 23 Mar 2018 20:31:14 +0000 (21:31 +0100)]
fileio: accept FILE* in addition to path in parse_env_file()

Most our other parsing functions do this, let's do this here too,
internally we accept that anyway. Also, the closely related
load_env_file() and load_env_file_pairs() also do this, so let's be
systematic.

5 years agoprocess-util: add a new FORK_MOUNTNS_SLAVE flag for safe_fork()
Lennart Poettering [Fri, 23 Mar 2018 19:52:46 +0000 (20:52 +0100)]
process-util: add a new FORK_MOUNTNS_SLAVE flag for safe_fork()

We already have a flag for creating a new mount namespace for the child.
Let's add an extension to that: a new FORK_MOUNTNFS_SLAVE flag. When
used in combination will mark all mounts in the child namespace as
MS_SLAVE so that the child can freely mount or unmount stuff but it
won't leak into the parent.

5 years agofd-util: add new helper call fd_duplicate_data_fd()
Lennart Poettering [Fri, 9 Mar 2018 21:45:08 +0000 (22:45 +0100)]
fd-util: add new helper call fd_duplicate_data_fd()

This call creates an fd from another fd containing the same data.
Specifically, repeated read() on the returned fd should return the same
data as the original fd. This call is useful when we want to copy data
out of disk images and suchlike, and want to be pass fds with the data
around without having to keep the disk image continously mounted.

The implementation tries to be somewhat smart and tries to prefer
memfds/pipes over files in /tmp or /var/tmp based on the size of the
data, but has appropropriate fallbacks in place.

5 years agobasic: fix raw_clone() on 32-bit sparc
Mike Gilbert [Thu, 24 May 2018 14:48:55 +0000 (10:48 -0400)]
basic: fix raw_clone() on 32-bit sparc

The clone syscall uses the same semantics as on 64-bit. The trap number
for syscall entry is different.

Bug: https://bugs.gentoo.org/656368

5 years agoload-fragment: allow to specify RestrictNamespaces= multiple times
Yu Watanabe [Tue, 1 May 2018 01:36:39 +0000 (10:36 +0900)]
load-fragment: allow to specify RestrictNamespaces= multiple times

If multiple RestrictNamespaces= settings are set, then merge the settings.
This also drops supporting "~yes" and "~no".

5 years agonsflsgs: drop namespace_flag_{from,to}_string()
Yu Watanabe [Tue, 1 May 2018 01:48:21 +0000 (10:48 +0900)]
nsflsgs: drop namespace_flag_{from,to}_string()

This also drops namespace_flag_to_string_many_with_check(), and
renames namespace_flag_{from,to}_string_many() to
namespace_flags_{from,to}_string().

5 years agonsflags: drop namespace_flag_to_string_many_with_check()
Yu Watanabe [Tue, 1 May 2018 01:44:19 +0000 (10:44 +0900)]
nsflags: drop namespace_flag_to_string_many_with_check()

We always ignore the unused bits. So, it is not necessary to check
them.

5 years agologind: let's change the type of the runtime directory size to uint64_t
Lennart Poettering [Thu, 17 May 2018 02:33:13 +0000 (22:33 -0400)]
logind: let's change the type of the runtime directory size to uint64_t

Externally it's an uint64_t anyway, and internally we most just
initialize it to physical_memory() which returns uint64_t, hence there's
exactly zero value in using it as size_t internally. Hence, let's fix
that, and use uint64_t everywhere.

5 years agoutil: add debug logging to system_tasks_max()
Lennart Poettering [Thu, 17 May 2018 02:32:15 +0000 (22:32 -0400)]
util: add debug logging to system_tasks_max()

We should always do debug logging when we eat up error conditions. Let's
do so here too.

5 years agoutil: fix physical_memory() to work correctly on cgroupsv2
Lennart Poettering [Thu, 17 May 2018 02:27:58 +0000 (22:27 -0400)]
util: fix physical_memory() to work correctly on cgroupsv2

Let's look into the right cgroupsv2 attribute.

Also, while we are at it, add debug logging for all error conditions we
eat up silently otherwise.

5 years agoupdate TODO
Lennart Poettering [Mon, 7 May 2018 15:50:31 +0000 (17:50 +0200)]
update TODO

5 years agonspawn: make sure our container PID 1 keeps logging to the original stderr as long...
Lennart Poettering [Tue, 22 May 2018 14:52:50 +0000 (16:52 +0200)]
nspawn: make sure our container PID 1 keeps logging to the original stderr as long as possible

If we log to the pty that is configured as stdin/stdout/stderr of the
container too early we risk filling it up in full before we start
processing the pty from the parent process, resulting in deadlocks.
Let's hence keep a copy of the original tty we were started on before
setting up stdin/stdout/stderr, so that we can log to it, and keep using
it as long as we can.

Since the kernel's pty internal buffer is pretty small this actually
triggered deadlocks when we debug logged at lot from nspawn's child
processes, see: https://github.com/systemd/systemd/pull/9024#issuecomment-390403674

With this change we won't use the pty at all, only the actual payload we
start will, and hence we won't deadlock on it, ever.

5 years agodoc: mention in NEWS that AF_INET{,6} are dropped from logind
Yu Watanabe [Thu, 24 May 2018 04:18:28 +0000 (13:18 +0900)]
doc: mention in NEWS that AF_INET{,6} are dropped from logind

Closes #9072.

5 years agotimesync,shared: move logic requesting bus name to shared
Yu Watanabe [Sat, 19 May 2018 16:55:39 +0000 (01:55 +0900)]
timesync,shared: move logic requesting bus name to shared

Preparation for setting DynamicUser= to other services which
request bus names.

5 years agocore: support unit specifiers in IODeviceWeight= and friends
Yu Watanabe [Sat, 19 May 2018 14:59:02 +0000 (23:59 +0900)]
core: support unit specifiers in IODeviceWeight= and friends

5 years agotree-wide: remove some double newlines in headers, too
Lennart Poettering [Tue, 22 May 2018 14:08:26 +0000 (16:08 +0200)]
tree-wide: remove some double newlines in headers, too

5 years agofind-double-newline: look in headers too
Lennart Poettering [Tue, 22 May 2018 14:07:18 +0000 (16:07 +0200)]
find-double-newline: look in headers too

5 years agoconf-parser: make use of free_and_replace() at one more place
Lennart Poettering [Tue, 22 May 2018 11:12:48 +0000 (13:12 +0200)]
conf-parser: make use of free_and_replace() at one more place

5 years agotree-wide: port over all code to the new CONFIG_PARSER_PROTOTYPE() macro
Lennart Poettering [Tue, 22 May 2018 11:10:17 +0000 (13:10 +0200)]
tree-wide: port over all code to the new CONFIG_PARSER_PROTOTYPE() macro

This makes most header files easier to look at. Also Emacs gets really
slow when browsing through large sections of overly long prototypes,
which is much improved by this macro.

We should probably not do something similar with too many other cases,
as macros like this might help readability for some, but make it worse
for others. But I think given the complexity of this specific prototype
and how often we use it, it's worth doing.

5 years agoconfig-parser: introduce new CONFIG_PARSER_PROTOTYPE() macro
Lennart Poettering [Tue, 22 May 2018 11:03:19 +0000 (13:03 +0200)]
config-parser: introduce new CONFIG_PARSER_PROTOTYPE() macro

This builds on the previous GENERIC_PARSER_ARGS macro work. I think in
general it is a better idea to declare macros that generate full C
statements instead of just parts of them, hence, let's introduce
CONFIG_PARSER_PROTOTYPE() which defines a full C function prototype,
instead of the pre-existing way of defining the C function prototype
manually, but then using GENERIC_PARSER_ARGS to define its arguments.

This doesn't drop GENERIC_PARSER_ARGS though, but renames it to
CONFIG_PARSER_ARGUMENTS, and changes the ConfigParserCallback function
type to use it. The new name follows more closely how the other symbols
in the header are named.

5 years agobasic/rm-rf: include the path in error messages
Zbigniew Jędrzejewski-Szmek [Tue, 22 May 2018 09:33:01 +0000 (11:33 +0200)]
basic/rm-rf: include the path in error messages

Attempted to remove disk file system under "/tmp/systemd-temporary-aWPkbQ", and we can't allow that.

5 years agotree-wide: port various bits of the tree over to the new DUMP_STRING_TABLE() macro
Lennart Poettering [Tue, 22 May 2018 10:10:56 +0000 (12:10 +0200)]
tree-wide: port various bits of the tree over to the new DUMP_STRING_TABLE() macro

5 years agostring-table: add new DUMP_STRING_TABLE() macro
Lennart Poettering [Tue, 22 May 2018 10:06:54 +0000 (12:06 +0200)]
string-table: add new DUMP_STRING_TABLE() macro

The macro is inspired by the other string table macros, and takes the
same arguments in the same order and dumps a string table to stdout.
Since it's typesafe it's nice to implement this as macro rather than
regular function.

This new macro is useful for implementing commands such as "systemctl -t
help" and similar, i.e. wherever we want to dump all values of an enum
to stdout.

5 years agotest-sizeof: show that a small 64 field is not enough to force the enum to be 64...
Zbigniew Jędrzejewski-Szmek [Tue, 22 May 2018 07:07:35 +0000 (09:07 +0200)]
test-sizeof: show that a small 64 field is not enough to force the enum to be 64 bits

On both 32 and 64 bits, the result is:
enum Enum → 32 bits, unsigned
enum BigEnum → 32 bits, unsigned
enum BigEnum2 → 64 bits, unsigned
big_enum2_pos → 4
big_enum2_neg → 8

The last two lines show that even if the enum is 64 bit, and the field of an
enum is defined with UINT64_C(), the field can still be smaller.

5 years agorpm: add macros for common configuration dirs
Zbigniew Jędrzejewski-Szmek [Sat, 19 May 2018 15:02:37 +0000 (17:02 +0200)]
rpm: add macros for common configuration dirs

%_environmnentdir /usr/lib/environment.d
%_modulesloaddir /usr/lib/modules-load.d
%_modprobedir /usr/lib/modprobe.d

This makes installing files there more convenient because people don't need to
construct the path from %_prefix/lib/… .

See https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/GBF5WJLTQVSXMHGYGBF3723ZYCWFBR7C/.

5 years agorpm: add macros for common configuration dirs
Zbigniew Jędrzejewski-Szmek [Sat, 19 May 2018 15:02:37 +0000 (17:02 +0200)]
rpm: add macros for common configuration dirs

%_environmnentdir /usr/lib/environment.d
%_modulesloaddir /usr/lib/modules-load.d
%_modprobedir /usr/lib/modprobe.d

This makes installing files there more convenient because people don't need to
construct the path from %_prefix/lib/… .

See https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/GBF5WJLTQVSXMHGYGBF3723ZYCWFBR7C/.

5 years agofs-util: don't alter errno in unlink_tempfilep()
Lennart Poettering [Fri, 18 May 2018 18:14:54 +0000 (20:14 +0200)]
fs-util: don't alter errno in unlink_tempfilep()

Functions whose only purpose is to be used with _cleanup_() should not
touch errno, so that failing removals do not alter errno at unexpected
places.

This is already done in unlink_and_freep(), rmdir_and_freep(),
rm_rf_physical_and_freep(), hence do so for unlink_tempfilep(), too.

Follow-up for #9013

5 years agomeson: use run_target for generating tags with ctags
Evegeny Vereshchagin [Fri, 18 May 2018 10:52:17 +0000 (10:52 +0000)]
meson: use run_target for generating tags with ctags

In https://github.com/systemd/systemd/pull/6561, `run_target`
was changed to `custom_target`, which inadvertently caused
relative paths to be passed to ctags due to
https://github.com/mesonbuild/meson/issues/3589.
The switch to `run_target` causes absolute paths to be
passed again and makes it easier to jump from file to
file, hopefully delaying the need to exit Vim :-)

5 years agoUse STRLEN in two places
Zbigniew Jędrzejewski-Szmek [Fri, 11 May 2018 09:09:37 +0000 (11:09 +0200)]
Use STRLEN in two places

5 years agotest-copy: remove unnecessary initialization
Zbigniew Jędrzejewski-Szmek [Mon, 14 May 2018 07:20:17 +0000 (09:20 +0200)]
test-copy: remove unnecessary initialization

Initializing just some of the values doesn't make sense. We should handle them
all in the same way. In those tests there are no jumps, all steps are covered
with assert_se(), so we know everything will be set if we get to the end of the
function. And _not_ initializing those variables has the advantage that it
allows valgrind to catch potential initalization errors in the function being
tested.

5 years agotree-wide: do not wrap assert_se in extra parentheses
Zbigniew Jędrzejewski-Szmek [Mon, 14 May 2018 07:12:12 +0000 (09:12 +0200)]
tree-wide: do not wrap assert_se in extra parentheses

We were inconsitently using them in some cases, but in majority not.
Using assignment in assert_se is very common, not an exception like in
'if', so let's drop the extra parens everywhere.

5 years agocore/mount-setup: remove part of check which is always true
Zbigniew Jędrzejewski-Szmek [Mon, 14 May 2018 06:50:00 +0000 (08:50 +0200)]
core/mount-setup: remove part of check which is always true

f1470e424b2b5337e3c383d68dc5a26af1ff4ce6 removed one check, but missed a similar
one a few lines down.

CID #1390949.

5 years agologin: use BUS_DEFINE_PROPERTY_GET* macros
Yu Watanabe [Mon, 14 May 2018 01:02:55 +0000 (10:02 +0900)]
login: use BUS_DEFINE_PROPERTY_GET* macros

5 years agobus-util: add more macros for defining functions of getting dbus properties
Yu Watanabe [Mon, 14 May 2018 01:02:17 +0000 (10:02 +0900)]
bus-util: add more macros for defining functions of getting dbus properties

5 years agofs-util,test: add helper to remove tempfiles
Zbigniew Jędrzejewski-Szmek [Wed, 16 May 2018 09:35:41 +0000 (11:35 +0200)]
fs-util,test: add helper to remove tempfiles

This simplifies the use of tempfiles in tests and fixes "leaked"
temporary files in test-fileio, test-catalog, test-conf-parser.

Not the whole tree is converted.

5 years agopath-util: one more empty_or_root() change
Lennart Poettering [Wed, 25 Apr 2018 09:23:01 +0000 (11:23 +0200)]
path-util: one more empty_or_root() change

5 years agoprocess-util: add new helper call for adjusting the OOM score
Lennart Poettering [Mon, 7 May 2018 18:44:41 +0000 (20:44 +0200)]
process-util: add new helper call for adjusting the OOM score

And let's make use of it in execute.c

5 years agobasic: split parsing of the OOM score adjust value into its own function in parse...
Lennart Poettering [Mon, 7 May 2018 18:26:38 +0000 (20:26 +0200)]
basic: split parsing of the OOM score adjust value into its own function in parse-util.c

And port config_parse_exec_oom_score_adjust() over to use it.

While we are at it, let's also fix config_parse_exec_oom_score_adjust()
to accept an empty string for turning off OOM score adjustments set
earlier.

5 years agoconf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null()
Lennart Poettering [Mon, 7 May 2018 16:18:11 +0000 (18:18 +0200)]
conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null()

5 years agobasic: be more careful when closing fds based on RLIMIT_NOFILE
Lennart Poettering [Mon, 7 May 2018 15:54:59 +0000 (17:54 +0200)]
basic: be more careful when closing fds based on RLIMIT_NOFILE

Let's make sure we properly handle cases where RLIMIT_NOFILE is set to
infinity, zero or values outside of the "int" range.

5 years agocore: move config_parse_limit() to the generic conf-parser.[ch]
Lennart Poettering [Thu, 3 May 2018 17:01:21 +0000 (19:01 +0200)]
core: move config_parse_limit() to the generic conf-parser.[ch]

That way we can use it in nspawn.

Also, while we are at it, let's rename the call config_parse_rlimit(),
i.e. insert the "r", to clarify what kind of limit this is about.

5 years agorlimit-util: rework rlimit_{from|to}_string() to work without "Limit" prefix
Lennart Poettering [Thu, 3 May 2018 16:45:39 +0000 (18:45 +0200)]
rlimit-util: rework rlimit_{from|to}_string() to work without "Limit" prefix

let's make the call more generic, so that we can also easily use it for
parsing "RLIMIT_xyz" style constants.

5 years agoinhibit: use pager for systemd-inhibit --list
David Tardon [Thu, 17 May 2018 13:45:37 +0000 (15:45 +0200)]
inhibit: use pager for systemd-inhibit --list

5 years agoTurn VALGRIND variable into a meson configuration switch
Zbigniew Jędrzejewski-Szmek [Sun, 13 May 2018 20:28:24 +0000 (22:28 +0200)]
Turn VALGRIND variable into a meson configuration switch

Configuration through environment variable is inconvenient with meson, because
they cannot be convieniently changed and/or are not preserved during
reconfiguration (https://github.com/mesonbuild/meson/issues/1503).
This adds -Dvalgrind=true/false, which has the advantage that it can be set
at any time with meson configure -Dvalgrind=... and ninja will rebuild targets
as necessary. Additional minor advantages are better consistency with the
options for hashmap debugging, and typo avoidance with '#if' instead of '#ifdef'.

5 years agocore: Break circular dependency between unit.h and cgroup.h
Felipe Sateler [Tue, 15 May 2018 18:12:22 +0000 (14:12 -0400)]
core: Break circular dependency between unit.h and cgroup.h

5 years agomeson: use array type option
Yu Watanabe [Wed, 2 May 2018 04:56:28 +0000 (13:56 +0900)]
meson: use array type option

Array type option is supported since 0.44.0.

5 years agomeson: use warning() method
Yu Watanabe [Thu, 10 May 2018 05:50:52 +0000 (14:50 +0900)]
meson: use warning() method

This bumps the required minimum version of meson to 0.44, as
`warning()` method is supported since 0.44.

5 years agomeson: use get_supported_arguments()
Yu Watanabe [Thu, 10 May 2018 06:30:42 +0000 (15:30 +0900)]
meson: use get_supported_arguments()

This bumps the required minimum version of meson to 0.43, as
`get_supported_arguments()` is supported since meson-0.43.

5 years agotest: use _cleanup_hashmap_free_ instread of _cleanup_(hashmap_freep)
Yu Watanabe [Mon, 14 May 2018 05:14:17 +0000 (14:14 +0900)]
test: use _cleanup_hashmap_free_ instread of _cleanup_(hashmap_freep)

5 years agosd-bus: use free_and_strdup()
Yu Watanabe [Mon, 14 May 2018 05:09:03 +0000 (14:09 +0900)]
sd-bus: use free_and_strdup()

5 years agobus-util: add several macros for defining functions of getting dbus properties
Yu Watanabe [Sun, 13 May 2018 03:20:51 +0000 (12:20 +0900)]
bus-util: add several macros for defining functions of getting dbus properties

5 years agobasic: add log_level argument to timezone_is_valid
Mike Gilbert [Sat, 12 May 2018 19:20:13 +0000 (15:20 -0400)]
basic: add log_level argument to timezone_is_valid

5 years agobasic: timezone_is_valid: check for magic bytes "TZif"
Mike Gilbert [Thu, 10 May 2018 19:10:48 +0000 (15:10 -0400)]
basic: timezone_is_valid: check for magic bytes "TZif"

Fixes: https://github.com/systemd/systemd/issues/8905
5 years agotest: do not call alloca() inside the list of arguments
Yu Watanabe [Fri, 11 May 2018 06:01:35 +0000 (15:01 +0900)]
test: do not call alloca() inside the list of arguments

5 years agohexdecoct: drop an unnecessary check
Yu Watanabe [Fri, 11 May 2018 04:56:28 +0000 (13:56 +0900)]
hexdecoct: drop an unnecessary check

5 years agobasic: fix comment style
Yu Watanabe [Fri, 11 May 2018 04:55:28 +0000 (13:55 +0900)]
basic: fix comment style

5 years agohexdecoct: ignore whitespace within the input hexadecimal text of unhexmem()
Yu Watanabe [Fri, 11 May 2018 05:36:22 +0000 (14:36 +0900)]
hexdecoct: ignore whitespace within the input hexadecimal text of unhexmem()

5 years agoterminal-util: add a function that shows a pretty separator line
Lennart Poettering [Thu, 10 May 2018 18:28:33 +0000 (11:28 -0700)]
terminal-util: add a function that shows a pretty separator line

Follow-up for #8824

5 years agostring-util: rename strdash_if_empty() to empty_to_dash()
Yu Watanabe [Thu, 10 May 2018 16:55:46 +0000 (01:55 +0900)]
string-util: rename strdash_if_empty() to empty_to_dash()

5 years agopath-util: introduce empty_to_root() and use it many places
Yu Watanabe [Thu, 10 May 2018 16:47:33 +0000 (01:47 +0900)]
path-util: introduce empty_to_root() and use it many places

5 years agobasic/terminal-util: fix output of files without a final newline
Zbigniew Jędrzejewski-Szmek [Fri, 27 Apr 2018 07:39:53 +0000 (09:39 +0200)]
basic/terminal-util: fix output of files without a final newline

If the main config file or one of the drop-ins did not have the final newline,
there would be no seperating empty line (or if this was the last file
displayed, our own output would end without the final newline, possibly running
into the subsequent prompt or such). copy_bytes() does not know anything about
lines, so let's just use a normal loop with read_line() and puts().