Commit Graph

29580 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d02fd8b1c6 core/bpf-firewall: use the correct cleanup function
On error, we'd just free the object, and not close the fd.

While at it, let's use set_ensure_consume() to make sure we don't leak
the object if it was already in the set. I'm not sure if that condition
can be achieved.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek 648c339c49 logind: fix possible memleak of message if the message was already in the set
I'm not sure if it is actually possible to encounter this condition. But
let's make the handling correct regardless.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek d378ef708b portable: rework set handling in portable_detach()
_cleanup_set_free_ is enough for unit_files, because unit_files is
allocated in set_put_strdup(), which uses string_hash_ops_free.

This fixes a leak if marker was already present in the table.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek ab9dd0b997 resolved: fix memleak on duplicate host lines in /etc/hosts 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek ceb17827fa resolved: simplify allocation failure handling in dns_stub_process_query()
Old code was correct, but let's make things more explicit.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek b8b46b1ce5 basic/set,hashmap: pass through allocation info in more cases 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek fcc1d0315d basic/set: add set_ensure_consume()
This combines set_ensure_allocated() with set_consume(). The cool thing is that
because we know the hash ops, we can correctly free the item if appropriate.
Similarly to set_consume(), the goal is to simplify handling of the case where
the item needs to be freed on error and if already present in the set.
2020-06-24 10:38:15 +02:00
Jay Burger a1ba8c5b71 feature to honor first shutdown request to completion
Create unit tests per established norm at position 52

check in_set first before getting unit
2020-06-24 09:42:01 +02:00
Lennart Poettering 7bf6babfa2
Merge pull request #16112 from poettering/nss-systemd-block-fix
rework nss-systemd recursion lock
2020-06-24 08:39:44 +02:00
Lennart Poettering bc8d57f290
Merge pull request #16223 from cgzones/user_selinux
Initialize SELinux in user instances
2020-06-24 08:39:13 +02:00
Christian Göttsche 3d9fbea43e selinux: update mac_selinux_free()
* Drop mac_selinux_use() condition from mac_selinux_free(): if the
  passed pointer holds memory we want to free it even if SELinux is
  disabled

* Drop NULL-check cause man:freecon(3) states that freecon(NULL) is a
  well-defined NOP

* Assert that on non-SELinux builds the passed pointer is always NULL,
  to avoid memory leaks
2020-06-24 08:38:34 +02:00
Zbigniew Jędrzejewski-Szmek 0d0248c665
Merge pull request #16246 from benzea/benzea/xdg-autostart
Minor xdg-autostart changes
2020-06-23 21:13:07 +02:00
Zbigniew Jędrzejewski-Szmek 21856e3462
Merge pull request #16213 from yuwata/network-cleanup-link-state-file
network: cleanup link state file
2020-06-23 21:09:24 +02:00
Zbigniew Jędrzejewski-Szmek db3b8d5d41 fuzz-udev-rules: rewrite to not require root privileges
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20142.

It turns out we don't need to do all this preparatory work if we want to parse
just one file.
2020-06-23 20:53:19 +02:00
Christian Göttsche a9ba0e328f Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
Christian Göttsche a11bfc17dc Initialize SELinux in user instances
Call mac_selinux_init() to setup the label cache, so objects can be
created with default SELinux context.

Fixes: #8004
2020-06-23 19:10:03 +02:00
Zbigniew Jędrzejewski-Szmek c238a1f5f1 udev: split rules object creation and loading
The only functional change is to downgrade the log line to avoid double
logging.
2020-06-23 18:04:18 +02:00
Lennart Poettering 037b0a47b0 userdb: replace recursion lock
Previously we'd used the existance of a specific AF_UNIX socket in the
abstract namespace as lock for disabling lookup recursions. (for
breaking out of the loop: userdb synthesized from nss → nss synthesized
from userdb → userdb synthesized from nss → …)

I did it like that because it promised to work the same both in static
and in dynmically linked environments and is accessible easily from any
programming language.

However, it has a weakness regarding reuse attacks: the socket is
securely hashed (siphash) from the thread ID in combination with the
AT_RANDOM secret. Thus it should not be guessable from an attacker in
advance. That's only true if a thread takes the lock only once and
keeps it forever. However, if a thread takes and releases it multiple
times an attacker might monitor that and quickly take the lock
after the first iteration for follow-up iterations.

It's not a big issue given that userdb (as the primary user for this)
never released the lock and we never made the concept a public
interface, and it was only included in one release so far, but it's
something that deserves fixing. (moreover it's a local DoS only, only
permitting to disable native userdb lookups)

With this rework the libnss_systemd.so.2 module will now export two
additional symbols. These symbols are not used by glibc, but can be used
by arbitrary programs: one can be used to disable nss-systemd, the other
to check if it is currently disabled.

The lock is per-thread. It's slightly less pretty, since it requires
people to manually link against C code via dlopen()/dlsym(), but it
should work safely without the aforementioned weakness.
2020-06-23 17:24:24 +02:00
Lennart Poettering 6e78726e20 nss-systemd: skip /etc/gshadow look-ups when we just need the GID of a group 2020-06-23 17:24:24 +02:00
Lennart Poettering 88d775b734 util: add dlfcn-util.h
This just adds a _cleanup_ helper call encapsulating dlclose().

This also means libsystemd-shared is linked against libdl now. I don't
think this is much of an issue, since libdl is part of glibc anyway, and
anything from exotic. It's not an optional part of the OS (think: NSS
requires dynamic linking), hence this pulls in no deps and is almost
certainly loaded into all process' memory anyway.

[zj: use DEFINE_TRIVIAL_CLEANUP_FUNC().]
2020-06-23 17:23:27 +02:00
Zbigniew Jędrzejewski-Szmek 311a0e2ee6 Revert "cgroup: Allow empty assignments of Memory{Low,Min}="
This reverts commit 53aa85af24.
The reason is that that patch changes the dbus api to be different than
the types declared by introspection api.

Replaces #16122.
2020-06-23 16:54:23 +02:00
Luca Boccassi 73083ca238 portabled: implement container host os-release interface 2020-06-23 12:58:21 +01:00
Luca Boccassi e1bb4b0d1d nspawn: implement container host os-release interface 2020-06-23 12:58:21 +01:00
Luca Boccassi b3b1a08a56 nspawn: use mkdir_p_safe instead of homegrown version 2020-06-23 12:57:05 +01:00
Luca Boccassi 17b99e377b basic/mkdir: introduce safe recursive variants
Add mkdir_p_safe and mkdir_parents_safe. Will be used by nspawn.
2020-06-23 12:57:05 +01:00
Susant Sahani 3d0c8750c5 networkctl: display DHCPv4 server address 2020-06-23 19:13:06 +09:00
Yu Watanabe fd1f3b3eed dhcp: fix entry name in parsing lease file 2020-06-23 19:13:06 +09:00
Yu Watanabe 46986251d6 network: drop duplicated information from link state file
Those entries are already in DHCP4 lease file, and not used anymore.
2020-06-23 19:13:05 +09:00
Yu Watanabe 5202be27ee sd-network: drop unused functions 2020-06-23 19:13:05 +09:00
Yu Watanabe 862e710820 networkctl: use lease file to get DHCPv4 client ID 2020-06-23 19:13:05 +09:00
Yu Watanabe d41fa6ee91 networkctl: use lease file to get DHCPv4 address 2020-06-23 19:13:05 +09:00
Yu Watanabe 35cab5f99d networkctl: load DHCPv4 lease file and use timezone data from the lease file 2020-06-23 19:13:05 +09:00
Yu Watanabe ef0daa1129 libsystemd-network: move prototypes of dhcp_lese_save/load() to network-internal.h 2020-06-23 19:13:05 +09:00
Dave Reisner cc479760b4 Revert "job: Don't mark as redundant if deps are relevant"
This reverts commit 097537f07a.

At least Fedora and Debian have already reverted this at the distro
level because it causes more problems than it solves. Arch is debating
reverting it as well [0] but would strongly prefer that this happens
upstream first. Fixes #15188.

[0] https://bugs.archlinux.org/task/66458
2020-06-23 11:42:45 +02:00
Benjamin Berg 9d9a9500cd xdg-autostart: Ignore all files with GNOME autostart phase
If an autostart file for GNOME has a phase specified, then this implies
it is a session service that needs to be started at a specific time.

We have no way of handling the ordering, and while it does make sense
to explicitly hide these services with X-systemd-skip, there is no point
in even trying to handle them.
2020-06-23 11:20:27 +02:00
Benjamin Berg 566cb7e23b xdg-autostart: Fix info message if Type= is not Application
The message was copy-pasted and not changed to correctly specify what
the problem was.
2020-06-23 11:04:44 +02:00
Luca Boccassi 0389f4fa81 core: add RootHash and RootVerity service parameters
Allow to explicitly pass root hash (explicitly or as a file) and verity
device/file as unit options. Take precedence over implicit checks.
2020-06-23 10:50:09 +02:00
Lennart Poettering 6fe01ced0e nspawn: mkdir selinux mount point once, but not twice
Since #15533 we didn't create the mount point for selinuxfs anymore.

Before it we created it twice because we mount selinuxfs twice: once the
superblock, and once we remount its bind mound read-only. The second
mkdir would mean we'd chown() the host version of selinuxfs (since
there's only one selinuxfs superblock kernel-wide).

The right time to create mount point point is once: before we mount the
selinuxfs. But not a second time for the remount.

Fixes: #16032
2020-06-23 10:17:36 +02:00
Lennart Poettering 65804d6aff selinux-util: tweak log_enforcing_errno() to return the errno passed in or 0 when in non-enforcing mode
Also, some other, minor modernizations.
2020-06-23 07:48:44 +02:00
Zbigniew Jędrzejewski-Szmek 2edc494216
Merge pull request #16237 from keszybz/revert-message-type-check
Revert "bus-message: immediately reject messages with invalid type"
2020-06-22 22:46:13 +02:00
Zbigniew Jędrzejewski-Szmek b98f393d88 bus-message: add macro for calculation of offset from the page 2020-06-22 17:18:35 +02:00
Zbigniew Jędrzejewski-Szmek b17af3e503 bus-message: avoid dereferencing a NULL pointer
We'd try to map a zero-byte buffer from a NULL pointer, which is undefined behaviour.

src/systemd/src/libsystemd/sd-bus/bus-message.c:3161:60: runtime error: applying zero offset to null pointer
    #0 0x7f6ff064e691 in find_part /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3161:60
    #1 0x7f6ff0640788 in message_peek_body /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3283:16
    #2 0x7f6ff064e8db in enter_struct_or_dict_entry /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3967:21
    #3 0x7f6ff06444ac in bus_message_enter_struct /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:4009:13
    #4 0x7f6ff0641dde in sd_bus_message_enter_container /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:4136:21
    #5 0x7f6ff0619874 in sd_bus_message_dump /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-dump.c:178:29
    #6 0x4293d9 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-bus-message.c:39:9
    #7 0x441986 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:558:15
    #8 0x44121e in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:470:3
    #9 0x443164 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:770:7
    #10 0x4434bc in fuzzer::Fuzzer::Loop(std::__1::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/libfuzzer/FuzzerLoop.cpp:799:3
    #11 0x42d2bc in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:846:6
    #12 0x42978a in main /src/libfuzzer/FuzzerMain.cpp:19:10
    #13 0x7f6fef13c82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #14 0x407808 in _start (out/fuzz-bus-message+0x407808)
2020-06-22 17:09:49 +02:00
Zbigniew Jędrzejewski-Szmek a9c9f79ece Revert "bus-message: immediately reject messages with invalid type"
This reverts commit a2dd991d0f.
Creation of such messages is evidently useful, and at least sdbus-c++ test
suite depends on that.

Fixes #16193.
2020-06-22 16:54:15 +02:00
Zbigniew Jędrzejewski-Szmek 6cd55d6f74 shared/bus-util: fix misleading error handling
set_put()/set_ensure_put() return 0, not -EEXIST, if the entry is already
found in the set. In this case this does not make any difference, but let's
not confuse the reader.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek e2ab8e09c8 udevadm-monitor: simplify creation of arg_tag_filter set
This version is more efficient, which doesn't matter, but it allows us
to remove a bunch of error handling, which is always nice.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 44e9342078 netdev/wireguard: do not invalidate peer on invalid syntax
We would say "ignoring", but invalidate the peer anyway.
Let's only do that if we modified the peer irreperably.

Also add comments explaining allocation handling.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek de7fef4b6e tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.

Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 0f9ccd9552 basic/set: add set_ensure_put()
It's such a common operation to allocate the set and put an item in it,
that it deserves a helper. set_ensure_put() has the same return values
as set_put().

Comes with tests!
2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek aaffd34933 sd-device: use set_put_strdup() in one more place 2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 29bd6012f1 resolved: introduce dns_transaction_gcp() 2020-06-22 16:32:37 +02:00
Zbigniew Jędrzejewski-Szmek 5fde0607a8
Merge pull request #16235 from yuwata/network-fix-warning-16224
network: fix compile error
2020-06-22 14:29:50 +02:00
Daan De Meyer bc694c06e6 log: Prefer logging to CLI unless JOURNAL_STREAM is set 2020-06-22 14:23:48 +02:00
Lennart Poettering 7830b5c103
Merge pull request #16059 from keszybz/resolve-single-label-names
Optionally resolve single label names
2020-06-22 14:00:31 +02:00
Lennart Poettering b7e8286b4a
Merge pull request #15926 from fbuihuu/rework-show-status
Rework show status
2020-06-22 13:55:06 +02:00
Yu Watanabe c4e585a36b network: add missing break
Follow-up for 2a71d57f4e.
2020-06-22 12:50:46 +02:00
Yu Watanabe 8d9982e30d network: drop unnecessary "&"
This confuses gcc-10 with -O3 -flto.

Closes #16224.
2020-06-22 12:13:24 +09:00
Zbigniew Jędrzejewski-Szmek 3b5bd7d6b8 resolved: optionally allow single-label A/AAAA queries 2020-06-18 21:26:20 +02:00
Zbigniew Jędrzejewski-Szmek c2f1e83e27 resolved: drop bit-field annotations for fields in Manager
Access to bit fields is less efficient, and since the Manager is a singleton,
a byte or two of space in the structure doesn't matter at all. (And in this
particular case, because of alignment issues, we wouldn't save anything
anyway.)
2020-06-18 21:26:20 +02:00
Zbigniew Jędrzejewski-Szmek 7877e5ca7c resolved: add dns_query_candidate_freep() 2020-06-18 21:26:20 +02:00
Yu Watanabe d474aa51bf network: tc: introduce Enhanced Transmission Selection (ETS)
Closes #15264.
2020-06-19 01:07:45 +09:00
Yu Watanabe 4dec921889 sd-netlink: add netlink properties of Enhanced Transmission Selection (ETS) 2020-06-19 00:47:55 +09:00
Paul Cercueil 3a712fda86 sd-boot: Add small comments after device-specific key macros
The key macros added in commit 6fe95d3020 look strange at first sight.
Add a comment with just the tablet name after each line, so that it's
obvious that these lines address device-specific issues of the EFI
firmware, and not broken/old code.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2020-06-18 15:57:11 +02:00
Lennart Poettering 034d0eb962
Merge pull request #16191 from poettering/repart-spec
repart: add specifier expansion to Label= + bump default mininum size to 10M
2020-06-18 15:53:31 +02:00
Lennart Poettering bc3b868b42
Merge pull request #16208 from yuwata/udev-fix-16207
udev: fixes error handling of sd_device_get_parent()
2020-06-18 15:52:07 +02:00
Yu Watanabe cc17c4c9a1 network: do not fail to configure non-nl80211 wifi interfaces
Also, make wifi_get_interface() and wifi_get_station() initialize
destination buffer when they return a non-negatinve value.

Closes #16160.
2020-06-18 15:50:56 +02:00
Yu Watanabe 845d784e54 network: drop casting in memcpy()ing IPv6 address
Follow-up for #16067.
2020-06-18 15:50:00 +02:00
Yu Watanabe 5eb6ef8b45 udev: udev_event_apply_format() always make buf NUL terminated
The return value of udev_event_apply_format() is always ignored.
So, the destination buffer must be always NUL terminated.
2020-06-18 13:53:08 +09:00
Yu Watanabe bc568a7a35 udev: fix error handling of sd_device_get_parent()
sd_device_get_parent() returns -EINVAL or -ENOENT on error, not -ENODEV.

Fixes #16207.
2020-06-18 13:52:38 +09:00
Lennart Poettering 2a71d57f4e network: clean-up DHCP lease server data configuration
This is an attempt to clean up the POP3/SMTP/LPR/… DHCP lease server
data logic in networkd. This reduces code duplication and fixes a number
of bugs.

This removes any support for collecting POP3/SMPT/LPR servers acquired
via local DHCP client releases since noone uses that, and given how old
these protocols are I doubt this will change. It keeps support for
configuring them for the dhcp server however.

The differences between the DNS/NTP/SIP/POP3/SMTP/LPR configuration
logics are minimized.

This removes the relevant symbols from sd-network.h (which is an
internal API only at this point after all).

This is unfortunately not well test, given the old code for this had
barely any tests. But the new code should not perform worse at least,
and allow us to release, since it corrects some interfaces visible in
the .network configuration format.

Fixes: #15943
2020-06-18 13:08:18 +09:00
Zbigniew Jędrzejewski-Szmek d5da3ada8e
Merge pull request #16061 from filbranden/standalone1
meson: add a new -Dstandalone-binaries=true option
2020-06-18 00:09:42 +02:00
Yu Watanabe d9eacc1cdd network: tc: add more settings for HTB
Closes #15213.
2020-06-17 16:49:46 +09:00
Susant Sahani 120b5c0bbe network: DHCPv6 - Add support to set token on the LAN interface
This patch adds support to set a token on the LAN interface for
the acquired delegated prefixes for the DHCPv6 to generate address.
2020-06-17 14:20:48 +09:00
Luca Boccassi 8d2d64166e efi: use stub for cache_efi_options_variable if !ENABLE_EFI
../src/core/main.c: In function 'main':
../src/core/main.c:2637:32: error: implicit declaration of function 'cache_efi_options_variable'; did you mean 'systemd_efi_options_variable'? [-Werror=implicit-function-declaration]
                         (void) cache_efi_options_variable();
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
                                systemd_efi_options_variable
2020-06-16 21:47:30 +02:00
Lennart Poettering fb08381c14 repart: if now minimal size is specified, default to 10M
Prompted by this discussion:

https://lists.freedesktop.org/archives/systemd-devel/2020-June/044669.html
2020-06-16 15:48:58 +02:00
Lennart Poettering e031166e15 repart: add simple specifier expansion in Label=
Strictly speaking this is a compat breakage, but given the tool was
added only in the last release, let's try to sail under the radar, and
fix this early before anyone notices it wasn't supported always.
2020-06-16 15:48:10 +02:00
Paul Cercueil 6fe95d3020 sd-boot: Work around malformed CR key code
When a key is pressed, the EFI firmware gives us a 64-bit word that
contains the modifier key code in the upper 32 bits, the scan code in
the middle 16 bits, and a unicode character in the low 16 bits.

Some bogus EFI firmwares will put the unicode character in the scan code
area, for instance on the EZpad mini 4s tablet.

Others will even put the unicode character in both the scan code and
unicode areas. This is the case for instance on the Teclast X98+ II
tablet.

Add workarounds for these corner cases, only for the carriage return key
right now. Some more workarounds may be needed, e.g. for volume keys,
but I cannot test it.

Partially fixes #8466.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2020-06-15 08:05:57 +02:00
Filipe Brandenburger 7283fbfd0c efi: Skip parsing SystemdOptions if there's an error getting it.
The original logic was logging an "ignored" debug message, but it was still
going ahead and calling proc_cmdline_parse_given() on the NULL line. Fix that
to skip that explicitly when the EFI variable wasn't really read.
2020-06-14 10:51:01 +02:00
Daan De Meyer 25c86e4c39 networkd: Add missing match_wlan_iftype check to network_verify 2020-06-14 10:47:37 +02:00
Zbigniew Jędrzejewski-Szmek 550c14fedd
Merge pull request #16163 from DaanDeMeyer/resolved-edns-info
resolved: Don't complain too much when downgrading from EDNS
2020-06-14 10:45:02 +02:00
Tomáš Pospíšek 6df8a6c753
Improve message for scheduled shutdown or reboot
Depending on if the system has been scheduled for shutdown or for reboot pring the corresponding message (and not only "Shutdown"). Prtinting the "wrong" message when rebooting will mislead and panic people. I get these messages via cron from remote servers and it would be bad if those systems actually *did* shut down, as the email from cron is telling me. Those messages cause an adrenalin spike in our team, which wouldn't happen, if the message was "correct"

Fixes #16129.
2020-06-14 10:43:06 +02:00
Daan De Meyer 4f571b4061 resolved: Log the feature level we're downgrading from as well 2020-06-13 14:48:40 +02:00
Filipe Brandenburger 209b2592ed efi: Cache contents of EFI variable SystemdOptions
Cache it early in startup of the system manager, right after `/run/systemd` is
created, so that further access to it can be done without accessing the EFI
filesystem at all.
2020-06-13 14:46:57 +02:00
Daan De Meyer e034886b80 resolved: Don't complain too much when downgrading from EDNS 2020-06-12 20:17:15 +02:00
Jan Palus ac4e03d45b login: filenames in /run/systemd/users are uids
Fixes: #16146
2020-06-12 19:37:52 +02:00
Lennart Poettering ed6727d40a
Merge pull request #16137 from poettering/sleep-fixlets
some log fixes in the sleep code
2020-06-11 14:12:48 +02:00
Evgeny Vereshchagin 119111645b
Merge pull request #16136 from mrc0mmand/travis-cleanup
Move the gcc/clang build check to GitHub Actions
2020-06-11 14:16:44 +03:00
Lennart Poettering 241616d57d
Merge pull request #16124 from ssahani/dhcpv6-duid
network: Display DHCPv6 DUID
2020-06-11 12:03:07 +02:00
Franck Bui 43bba15ac8 pid1: rename manager_set_{show_status,watchdog}_overridden() into manager_override_(show_status,watchdog}
No functional change.
2020-06-11 12:00:32 +02:00
Franck Bui 0bb007f7a2 pid1: add a new SetShowStatus() bus call to override/restore show status mode
The only way to control "ShowStatus" property programmatically was to use the
signal API and wait until the property "ShowStatus" switched to the new value.

This interface is rather cumbersome to use and doesn't allow to temporarily
override the current setting and later restore the overridden value in
race-free manner.

The new method also accepts the empty string as argument which allows to
restore the initial value of ShowStatus, ie the value before it was overridden
by this method.

Fixes: #11447.
2020-06-11 12:00:32 +02:00
Franck Bui 3ceb347130 pid1: introduce an helper to handle the show-status marker
No functional change.
2020-06-11 12:00:16 +02:00
Lennart Poettering 2c4702057b sleep: pass error we see to log function 2020-06-11 10:35:04 +02:00
Lennart Poettering 1326de0158 sleep-config: modernize destructors
All other destructors in the same .c file return NULL, let's make sure
the one where this so far wasn't done does it too.
2020-06-11 10:33:57 +02:00
Lennart Poettering c732e87979 sleep-config: downgrade log level in can_s2h()
As in the previous commit: can_sleep() is more a library-style function,
hence log at debug level only.
2020-06-11 10:33:56 +02:00
Lennart Poettering c02540dc9e sleep: clean up debug/error logging
half of find_hibernation_location() logged at debug level, the other
half logged at error level, and the third half didn't log at all.

Let's clean this up somewhat. Since can_sleep() is probably more
a library-style function let's downgrade everything to LOG_DEBUG and
then make sure sleep.c logs at error level, as the main program.
2020-06-11 10:33:56 +02:00
Lennart Poettering 6f9120ad61 sleep-config: return correct error code 2020-06-11 10:33:56 +02:00
Lennart Poettering c0d8fbfa34 sleep-config: add more debug logging 2020-06-11 10:33:56 +02:00
Frantisek Sumsal 2b918da5a1 journal: drop the assert-only variable completely
Followup to dfa64b64a7.
2020-06-11 10:22:09 +02:00
Lennart Poettering 0f2d351f79 tree-wide: port to fd_wait_for_event()
Prompted by the discussion on #16110, let's migrate more code to
fd_wait_for_event().

This only leaves 7 places where we call into poll()/poll() directly in
our entire codebase. (one of which is fd_wait_for_event() itself)
2020-06-10 20:06:10 +02:00
Filipe Brandenburger db64ba81c6 meson: build standalone version of systemd-tmpfiles
Use -Dstandalone-binaries=yes to enable building and installing this standalone
version of the binary without a dependency on the systemd-shared solib.

Also move the list of sources for systemd-tmpfiles to its own meson.build file.
2020-06-10 10:54:29 -07:00
Susant Sahani 639118854f networkctl: Display DHCP6 DUID 2020-06-10 19:21:24 +02:00
Susant Sahani a9deab2eec sd-network: Introduce APIs to get DHCP6 DUID 2020-06-10 19:21:21 +02:00
Susant Sahani 7e738e7b70 network: DHCP6 - save DUID to state file 2020-06-10 19:21:11 +02:00
Susant Sahani 6b7d5b6eaf network: DHCP6 - introduce DHCP6 DUID to string 2020-06-10 19:17:28 +02:00
Lennart Poettering 24bd74ae03
Merge pull request #15940 from keszybz/names-set-optimization
Try to optimize away Unit.names set
2020-06-10 18:52:08 +02:00
Anita Zhang bb9244781c core: don't consider SERVICE_SKIP_CONDITION for abnormal or failure restarts
Fixes: #16115
2020-06-10 17:12:55 +02:00
Lennart Poettering 97033ba455 pager: set PR_DEATHSIG for pager to SIGINT rather than SIGTERM
"less" doesn't properly reset its terminal on SIGTERM, it does so only
on SIGINT. Let's thus configure SIGINT instead of SIGTERM.

I think this is something less should fix too, and clean up things
correctly on SIGTERM, too. However, given that we explicitly enable
SIGINT behaviour by passing "K" to $LESS I figure it makes sense if we
also send SIGINT instead of SIGTERM to match it.

Fixes: #16084
2020-06-10 10:31:22 +02:00
Zbigniew Jędrzejewski-Szmek 51b367b86d
Merge pull request #16111 from poettering/bitlck-fix
bitlocker cryptsetup fix
2020-06-10 10:25:36 +02:00
Zbigniew Jędrzejewski-Szmek 9664be199a
Merge pull request #16118 from poettering/inaccessible-fixlets
move $XDG_RUNTIME_DIR/inaccessible/ to $XDG_RUNTIME_DIR/systemd/inaccessible
2020-06-10 10:23:13 +02:00
Zbigniew Jędrzejewski-Szmek 2befe404d4
Merge pull request #16120 from poettering/udevd-fixlets
minor udev fixlets
2020-06-10 10:18:36 +02:00
Zbigniew Jędrzejewski-Szmek e2ea005681 core: do not touch instance from unit_choose_id()
unit_choose_id() is about marking one of the aliases of the unit as the main
name. With the preparatory work in previous patches, all aliases of the unit
must have the same instance, so the operation to update the instance is a noop.
2020-06-10 09:45:58 +02:00
Zbigniew Jędrzejewski-Szmek 934ef6a522 core: create socket service instances with the correct name from the start
Upon an incoming connection for an accepting socket, we'd create a unit like
foo@0.service, then figure out that the instance name should be e.g. "0-41-0",
and then add the name foo@0-41-0.service to the unit. This obviously violates
the rule that any service needs to have a constance instance part.

So let's reverse the order: we first determine the instance name and then
create the unit with the correct name from the start.

There are two cases where we don't know the instance name:
- analyze-verify: we just do a quick check that the instance unit can be
  created. So let's use a bogus instance string.
- selinux: the code wants to load the service unit to extract the ExecStart path
  and query it for the selinux label. Do the same as above.

Note that in both cases it is possible that the real unit that is loaded could
be different than the one with the bogus instance value, for example if there
is a dropin for a specific instance name. We can't do much about this, since we
can't figure out the instance name in advance. The old code had the same
shortcoming.
2020-06-10 09:45:55 +02:00
Zbigniew Jędrzejewski-Szmek ada4b34ec7 core: rework error messages in unit_add_name()
They were added recently in acd1987a18. We can
make them more informative by using unit_type_to_string() and not repeating
unit names as much. Also, %m should not be used together with SYNTHETIC_ERRNO().
2020-06-10 09:42:20 +02:00
Zbigniew Jędrzejewski-Szmek d383acad25 core: when adding names to unit, require matching instance strings
We would check that the instance is present in both units (or missing in both).
But when it is defined, it should be the same in both. The comment in the code
was explicitly saying that differing instance strings are allowed, but this
mostly seems to be a left-over from old times. The man page is pretty clear:

> the instance (if any) is always uniquely defined for a given unit and all its
> aliases.
2020-06-10 09:42:20 +02:00
Zbigniew Jędrzejewski-Szmek 4562c35527 core: store unit aliases in a separate set
We allocated the names set for each unit, but in the majority of cases, we'd
put only one name in the set:

$ systemctl show --value -p Names '*'|grep .|grep -v ' '|wc -l
564
$ systemctl show --value -p Names '*'|grep .|grep ' '|wc -l
16

So let's add a separate .id field, and only store aliases in the set, and only
create the set if there's at least one alias. This requires a bit of gymnastics
in the code, but I think this optimization is worth the trouble, because we
save one object for many loaded units.

In particular set_complete_move() wasn't very useful because the target
unit would always have at least one name defined, i.e. the optimization to
move the whole set over would never fire.
2020-06-10 09:36:58 +02:00
Zbigniew Jędrzejewski-Szmek 02939ee001
Merge pull request #16087 from mrc0mmand/travis-build-check
travis: check build with various compiler options
2020-06-10 09:06:14 +02:00
Lennart Poettering dad28bffd6 tree-wide: check POLLNVAL everywhere
poll() sets POLLNVAL inside of the poll structures if an invalid fd is
passed. So far we generally didn't check for that, thus not taking
notice of the error. Given that this specific kind of error is generally
indication of a programming error, and given that our code is embedded
into our projects via NSS or because people link against our library,
let's explicitly check for this and convert it to EBADF.

(I ran into a busy loop because of this missing check when some of my
test code accidentally closed an fd it shouldn't close, so this is a
real thing)
2020-06-10 08:57:31 +02:00
Frantisek Sumsal dfa64b64a7 tree-wide: mark assert()-only variables as unused
to make a compilation with -Db_ndebug=true and --werror pass once again.
2020-06-09 21:31:10 +02:00
Daan De Meyer 45204921be
Merge pull request #16104 from ssahani/dhcpv6-iaid
networkctl: Display DHCPv6 IAID
2020-06-09 21:18:28 +02:00
YmrDtnJu 2ffadd3cee AppArmor: Support for loading a set of pre-compiled profiles at startup time
Let systemd load a set of pre-compiled AppArmor profile files from a policy
cache at /etc/apparmor/earlypolicy. Maintenance of that policy cache must be
done outside of systemd.

After successfully loading the profiles systemd will attempt to change to a
profile named systemd.

If systemd is already confined in a profile, it will not load any profile files
and will not attempt to change it's profile.

If anything goes wrong, systemd will only log failures. It will not fail to
start.
2020-06-09 20:27:47 +02:00
Lennart Poettering d689f0f20a
Merge pull request #16058 from Werkov/fix-memory-protection-default
Fix memory protection default setting
2020-06-09 20:02:53 +02:00
Lennart Poettering 4f4f37b20d
Merge pull request #16046 from bluca/dissect_squashfs_verity
dissect: single-filesystem verity images with external hashdevice
2020-06-09 19:52:21 +02:00
Lennart Poettering 48b747fa03 inaccessible: move inaccessible file nodes to /systemd/ subdir in runtime dir always
Let's make sure $XDG_RUNTIME_DIR for the user instance and /run for the
system instance is always organized the same way: the "inaccessible"
device nodes should be placed in a subdir of either called "systemd" and
a subdir of that called "inaccessible".

This way we can emphasize the common behaviour, and only differ where
really necessary.

Follow-up for #13823
2020-06-09 16:23:56 +02:00
Lennart Poettering b8c9074534 login: use ERRNO_IS_PRIVILEGE() where appropriate 2020-06-09 16:13:51 +02:00
Lennart Poettering d582afe144 mkdir: use log_full_errno() where appropriate 2020-06-09 16:13:16 +02:00
Lennart Poettering 6b2229c6c6 udev: set fewer process properties
On systemd systems we generally don't need to chdir() to root, we don't
need to setup /dev/ ourselves (as PID 1 does that during earliest boot),
and we don't need to set the OOM adjustment values, as that's done via
unit files.

Hence, drop this. if people want to use udev from other init systems
they should do this on their own, I am very sure it's a good thing to do
it from outside of udevd, so that fewer privileges are required by udevd. In
particular the dev_setup() stuff is something that people who build
their own non-systemd distros want to set up themselves anyway, in
particular as they already have to mount devtmpfs themselves anyway.

Note that this only drops stuff that isn't really necessary for testing
stuff, i.e. process properties and settings that don't matter if you
quickly want to invoke udev from a terminal session to test something.
2020-06-09 15:40:20 +02:00
Lennart Poettering fe56acd8e0 udevd: use cpus_in_affinity_mask()
Let's make use of our own helpers. This has the benefit that we can deal
with arbitrarily sized affinity masks.
2020-06-09 15:39:53 +02:00
Lennart Poettering 57b611a5bf
Merge pull request #16074 from msekletar/freezer-test-flakes
Freezer test flakes
2020-06-09 14:38:40 +02:00
Lennart Poettering 6930d069a3 cryptsetup: pass selected mode to crypt_load() when doing LUKS
This doesn't fix anything IRL, but is a bit cleaner, since it makes sure
that arg_type is properly passed to crypt_load() in all cases.

We actually never set arg_type to CRYPT_LUKS2, which is why this wasn't
noticed before, but theoretically this might change one day, and
existing comments suggest it as possible value for arg_type, hence let's
process it properly.
2020-06-09 14:24:21 +02:00
Lennart Poettering 5af39ac850 cryptsetup: try to load bitlocker superblock only if requested
let's do automatic discovery only for our native LUKS/LUKS2 headers,
since they are Linux stuff, and let's require that BitLocker to be
requested explicitly.

This makes sure cryptsetup without either "luks" nor "bitlk" in the
option string will work. Right now it would fail because we'd load the
superblock once with luks and once with bitlk and one of them would
necessarily fail.

Follow-up for #15979
2020-06-09 14:24:15 +02:00
Adam Nielsen f01994380e login: allow individual USB ports to be assigned to seats
Assigning seats to specific USB ports lets the devices plugged into them
inherit the port's seat assignment.
2020-06-09 13:30:59 +02:00
Luca Boccassi e7cbe5cb9e dissect: support single-filesystem verity images with external verity hash
dm-verity support in dissect-image at the moment is restricted to GPT
volumes.
If the image a single-filesystem type without a partition table (eg: squashfs)
and a roothash/verity file are passed, set the verity flag and mark as
read-only.
2020-06-09 12:19:21 +01:00
Susant Sahani 331ee15f18 networkctl: DHCPv6 - display IAID 2020-06-09 19:58:36 +09:00
Susant Sahani 01dd138031 sd-network: Introduce API to get DHCPv6 IAID 2020-06-09 19:58:36 +09:00
Susant Sahani 18d8a2cf30 network: DHCPv6 - export IAID to state file 2020-06-09 19:58:31 +09:00
Susant Sahani d69d4038ec dhcp6: Provide method to access IAID 2020-06-09 19:57:38 +09:00
Lennart Poettering ed66590d15
Merge pull request #16080 from YmrDtnJu/9p
9p is a network filesystem
2020-06-09 10:51:20 +02:00
Jan Klötzke bf76080180 core: let user define start-/stop-timeout behaviour
The usual behaviour when a timeout expires is to terminate/kill the
service. This is what user usually want in production systems. To debug
services that fail to start/stop (especially sporadic failures) it
might be necessary to trigger the watchdog machinery and write core
dumps, though. Likewise, it is usually just a waste of time to
gracefully stop a stuck service. Instead it might save time to go
directly into kill mode.

This commit adds two new options to services: TimeoutStartFailureMode=
and TimeoutStopFailureMode=. Both take the same values and tweak the
behavior of systemd when a start/stop timeout expires:

 * 'terminate': is the default behaviour as it has always been,
 * 'abort': triggers the watchdog machinery and will send SIGABRT
   (unless WatchdogSignal was changed) and
 * 'kill' will directly send SIGKILL.

To handle the stop failure mode in stop-post state too a new
final-watchdog state needs to be introduced.
2020-06-09 10:04:57 +02:00
Lennart Poettering 8b5616fa91
Merge pull request #16073 from keszybz/shell-completion
Bash completion for homectl and help improvement for kernel-install
2020-06-09 09:33:41 +02:00
Lennart Poettering d3d0b763b4
Merge pull request #15953 from keszybz/gdb-script
Update gdb script to match current sources and other hashmap improvements
2020-06-09 09:31:49 +02:00
Franck Bui 44a419540e pid1: rework handling of m->show_status
The fact that m->show_status was serialized/deserialized made impossible any
further customisation of this setting via system.conf. IOW the value was
basically always locked unless it was changed via signals.

This patch reworks the handling of m->show_status but also makes sure that if a
new value was changed via the signal API then this value is kept and preserved
accross PID1 reexecuting or reloading.

Note: this effectively means that once the value is set via the signal
interface, it can be changed again only through the signal API.
2020-06-09 09:16:54 +02:00
Franck Bui 0d6d3cf055 pid1: rename manager_get_show_status() to manager_should_show_status()
The name 'manager_get_show_status()' suggests that the function simply reads
the property 'show_status' of the manager and hence returns a 'StatusType'
value.

However it was doing more than that since it contained the logic (based on
'show_status' but also on the state of the manager) to figure out if status
message could be emitted to the console.

Hence this patch renames the function to 'manager_should_show_status()'. The
previous name will be reused in a later patch to effectively return the value
of 'show_status' property.

No functional change.
2020-06-09 09:16:54 +02:00
Franck Bui b309078ab9 pid1: make more use of show_status_on()
No functional change.
2020-06-09 09:16:54 +02:00
Lennart Poettering 5a36324962
Merge pull request #16047 from poettering/udev-ro-block
udev: optionally mark all block devices popping up read-only by default
2020-06-09 09:09:32 +02:00
Yu Watanabe a4d1bef73f
Merge pull request #16085 from ssahani/network-client-id
networkctl: add support to display DHCPv4 client ID
2020-06-09 15:30:23 +09:00
Maxim Fomin 6cc27c29ad Add 'bitlk' option to mount Bitlocker drives with cryptsetup. 2020-06-09 08:12:55 +02:00
YmrDtnJu c15ab81ed9
mount-tool: Replace fstype_is_{network,api_vfs} with fstype_is_blockdev_backed
Not every filesystem that is not a network filesystem and also not an API VFS
filesystem has a corresponding block device.
2020-06-08 19:36:42 +02:00
YmrDtnJu ac2474e4ff
basic: New function fstype_is_blockdev_backed for fstypes that need a blockdev
The function returns true if the specified filesystem requires a block device.
2020-06-08 19:36:42 +02:00
Lennart Poettering 95ac523030 udev: optionally mark all block devices read-only as they pop up 2020-06-08 16:53:37 +02:00
Luca Boccassi b1806441bb dissect-image: wait for udev for single filesystem images too
Single filesystem images are mounted from the /dev/block/X:Y symlink
rather than /dev/loopZ, so we need to wait for udev to create it or
mounting will be racy and occasionally fail.
2020-06-08 13:06:53 +01:00
Susant Sahani 2153bbc81a networkctl: Display DHCP4 client ID 2020-06-08 07:09:32 +02:00
Susant Sahani daec96821d sd-network: Introduce API to access DHCP4 client ID 2020-06-08 07:09:24 +02:00
Susant Sahani 5dfaf89b5b network: DHCP4 client ID save in state file 2020-06-08 07:08:04 +02:00
Yu Watanabe 94d76d071e network: introduce IPv4AcceptLocal= setting
Closes #16090.
2020-06-08 13:48:17 +09:00
layderv a07e962549 homed help --uid short option 2020-06-07 12:38:46 +02:00
Daan De Meyer 6495ceddf3
Merge pull request #16033 from poettering/parse-int-fixlets
various fixes and tweaks for integer parsing
2020-06-06 10:45:35 +02:00
YmrDtnJu a742f9828e resolve: enable RES_TRUSTAD towards the 127.0.0.53 stub resolver
glibc 2.31 strips the AD flag, unless either the application specifies
RES_TRUSTAD or the options in resolv.conf contain trust-ad.

See https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=NEWS;hb=HEAD
2020-06-06 10:40:45 +02:00
Thomas Haller 9141594cae lldp: fix assertion checking argument for sd_lldp_set_neighbors_max()
Fixes: 34437b4f9c ('sd-lldp: rework sd-lldp API')
2020-06-06 10:38:50 +02:00
Zbigniew Jędrzejewski-Szmek 3ac33bc966 kernel-install: extend --help 2020-06-05 16:34:05 +02:00
Zbigniew Jędrzejewski-Szmek ea9f36ac83
Merge pull request #15378 from msekletar/udev-kill-signal
udev:  make signal that we use to kill workers on timeout configurable
2020-06-05 16:33:14 +02:00
Michal Sekletár 2884836e3c core: fix the return value in order to make sure we don't dipatch method return too early
Actually, it is the same kind of problem as in d910f4c . Basically, we
need to return 1 on success code path in slice_freezer_action().
Otherwise we dispatch DBus return message too soon.

Fixes: #16050
2020-06-05 16:10:40 +02:00
Lennart Poettering 42e57a4eb2 test: add test for parse_uid_range() 2020-06-05 15:56:32 +02:00
Lennart Poettering 53c6db99fa tests: beef up integer parsing tests 2020-06-05 15:56:32 +02:00
Lennart Poettering fc80cabcf5 parse-util: also parse integers prefixed with 0b and 0o
Let's adopt Python 3 style 0b and 0x syntaxes, because it makes a ton of
sense, in particular in bitmask settings.
2020-06-05 15:56:32 +02:00
Lennart Poettering 60eb1f0728 parse-util: rewrite parse_uid_range() on top of parse_uid()
parse_uid() does so many safety checks we want, hence rewrite
parse_uid_range() on top of parse_uid() instead of parse_range().
2020-06-05 15:56:32 +02:00
Lennart Poettering f5979b63cc user-util: be stricter in parse_uid()
Let's refuse "+" and "-" prefixed UIDs. Let's refuse whitespace-prefixed
UIDS, Let's refuse zero-prefixed UIDs. Let's be safe than sorry.
2020-06-05 15:56:31 +02:00
Lennart Poettering c44702a8bd parse-util: rewrite parse_mode() on top of safe_atou_full()
Parsing is hard, hence let's use our own careful wrappers wherever
possible.
2020-06-05 15:56:31 +02:00
Lennart Poettering aa85e4d3ce parse-util: make return parameter optional in safe_atou16_full()
All other safe_atoXYZ_full() functions have the parameter optional,
let's make it optoinal here, too.
2020-06-05 15:56:31 +02:00
Lennart Poettering c78eefc135 parse-util: allow '-0' as alternative to '0' and '+0'
Let's allow "-0" as alternative to "+0" and "0" when parsing integers,
unless the new SAFE_ATO_REFUSE_PLUS_MINUS flag is specified.

In cases where allowing the +/- syntax shall not be allowed
SAFE_ATO_REFUSE_PLUS_MINUS is the right flag to use, but this also means
that -0 as only negative integer that fits into an unsigned value should
be acceptable if the flag is not specified.
2020-06-05 15:56:31 +02:00
Lennart Poettering 707e93aff8 parse-util: allow tweaking how to parse integers
This allows disabling a few alternative ways to decode integers
formatted as strings, for safety reasons.

See: #15991
2020-06-05 15:56:31 +02:00
Michal Sekletár e209926778 udev: make signal that we use to kill workers on timeout configurable 2020-06-05 11:09:17 +02:00
Zbigniew Jędrzejewski-Szmek 0ce8092109
Merge pull request #15466 from elmarco/dhcp-leases
networkctl: print DHCP leases
2020-06-05 08:47:35 +02:00
Marc-André Lureau d9ce1c2493 networkctl: print DHCP leases 2020-06-04 11:16:15 +02:00
Marc-André Lureau 090c923b4d networkctl: factor out link_get_property()
The next patch is going to reuse it.
2020-06-04 11:16:15 +02:00
Marc-André Lureau 7be3261222 sd-dhcp-client: add sd_dhcp_client_id_to_string()
Add a human-friendly pretty-printer for client ID.
2020-06-04 11:16:15 +02:00
Marc-André Lureau aaec2d7b9b macro.h: add sizeof_field() helper
Similar to kernel FIELD_SIZE()
2020-06-04 11:16:15 +02:00
Marc-André Lureau 00ebe01156 sd-dhcp-client: make struct sd_dhcp_client_id reusable 2020-06-04 11:16:15 +02:00
Marc-André Lureau cf72a78660 networkd: expose DHCPServer interface on links 2020-06-04 11:16:15 +02:00
Marc-André Lureau 38ee31a6e4 networkd: start a DBus interface for the DHCP server
Add a "org.freedesktop.network1.DHCPServer" DBus interface that will be
added on a link path where a DHCP server is provided.

Currently, it only exposes a "Leases" property, although there are plans
to expand it further. The property is updated thanks to the
dhcp_server_callback().
2020-06-04 11:16:15 +02:00
Marc-André Lureau 36d35f2259 sd-dhcp-server: notify callback on lease changed 2020-06-04 11:16:15 +02:00
Marc-André Lureau 5b03043a75 sd-dhcp-server: add sd_dhcp_server_set_callback() 2020-06-04 11:04:06 +02:00
Yu Watanabe 3cd5924c85 network: make link become configured state when at least one dynamic protocol provide an address
Before this, to speed up the system boot with IPv4 only network,
we need to specify `IPv6AcceptRA=no`, as it is enabled by default.

Closes #15469.
2020-06-04 10:49:26 +02:00
Yu Watanabe 161bc1b627
Merge pull request #16057 from keszybz/resolvectl-sorted-no-nta
Drop NTA lists from resolvectl status and sort output by link number
2020-06-04 11:30:14 +09:00
Yu Watanabe bb9a9e33c9
Merge pull request #15171 from ssahani/tc-qfq
network: TC- Introduce Quick Fair Queueing (QFQ)
2020-06-04 11:17:42 +09:00
Lennart Poettering ecc04067f9 seccomp: filter openat2() entirely in seccomp_restrict_sxid() 2020-06-03 18:26:34 +02:00
Lennart Poettering 7ade8982ca core: remove support for ".include" stanza
Six years ago we declared it obsolete and removed it from the docs
(c073a0c4a5) and added a note about it in
NEWS. Two years ago we add warning messages about it, indicating the
feature will be removed (41b283d0f1) and
mentioned it in NEWS again.

Let's now kill it for good.
2020-06-03 18:26:12 +02:00
Yu Watanabe c643bda5ec network: read driver name from ethtool
To make Driver= in [Match] section work in containers.

Note that ID_NET_DRIVER= property in udev database is set with the
result of the ethtool. So, this should not change anything for
non-container cases.

Closes #15678.
2020-06-03 18:25:37 +02:00
Zbigniew Jędrzejewski-Szmek 33bece166c basic/sort-util: adorn qsort_safe with a prefix underscore
It should not be used directly since we have typesafe_qsort(), so
let's mark it appropriately.
2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek bacafb0990 pstore: use typesafe_qsort
Also move "allocated" above "n", since, conceptually, it is modified
earlier (and that is the definition order we normally use).
2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek eb10767565 resolvect: sort status output by link number
This makes the output more predictable. Also, interesting interfaces
are often the low-numbered ones (actual hardware links, not virtual
devices stacked on top), and this makes them more visible.
2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek c9d243cdef resolvectl,systemctl: reduce scope of variables 2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek 6cf3011c6c Introduce strcasecmp_ptr() and use it in a few places 2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek 6773049a4c resolvectl: do not show NTA lists in status
Those lists are very long and use up a significant chunk of screen real estate.
But the contents are mostly static (usually they just reflect built-in
configuration). Let's just not show them in 'status' output. They can still
be viewed with 'nta' verb.
2020-06-03 15:31:28 +02:00
Yu Watanabe 4d7ddaf97b network: tc: introduce [QuickFairQueueingClass] section 2020-06-03 17:25:44 +09:00
Susant Sahani b12aaee5ab network: tc: introduce Quick Fair Queueing (QFQ) 2020-06-03 14:17:51 +09:00
Susant Sahani c33f1e5a3f sd-netlink: add netlink properties of Quick Fair Queueing (QFQ) 2020-06-03 13:41:44 +09:00
Yu Watanabe 6161b35d5e
Merge pull request #16048 from poettering/conf-parser-mtime
conf-parser: automatically pick up newest mtime when parsing configuration files
2020-06-03 08:25:28 +09:00
Zbigniew Jędrzejewski-Szmek c9e0695675 core: set source_mtime after load dropins
Dropins may specify SourcePath= too, but we would do the stat only
after loading the main fragment, before loading of the drop-ins.

Fixes #13634.
2020-06-02 22:53:55 +02:00
Lennart Poettering 4f9ff96a55 conf-parser: return mtime in config_parse() and friends
This is a follow-up for 9f83091e3c.

Instead of reading the mtime off the configuration files after reading,
let's do so before reading, but with the fd we read the data from. This
is not only cleaner (as it allows us to save one stat()), but also has
the benefit that we'll detect changes that happen while we read the
files.

This also reworks unit file drop-ins to use the common code for
determining drop-in mtime, instead of reading system clock for that.
2020-06-02 19:32:20 +02:00
Lennart Poettering 5aca2e6733 conf-parse: fix pretty bad typo 2020-06-02 19:32:06 +02:00
Lennart Poettering 22ed4a6d9a fs-util: add stat_warn_permissions() that operates on struct stat instead of fd 2020-06-02 19:31:36 +02:00
Lennart Poettering 7183b22f12
Merge pull request #15996 from yuwata/network-dhcp6-route-metric-15295
network: add RouteMetric= in [DHCPv6] section
2020-06-02 19:29:47 +02:00
Michal Koutný 53aa85af24 cgroup: Allow empty assignments of Memory{Low,Min}=
Currently, an empty assignment of Memory{Low,Min}= directives would be
interpretted as setting it to global default, i.e. zero. However, if we
set a runtime protection value on a unit that inherits parent's
DefaultMemory{Low,Min}=, it is not possible to revert it back to the
state where the DefaultMemory{Low,Min}= is propagated from parent
slice(s).

This patch changes the semantics of the empty assignments to explicitly
nullify any value set by the user previously. Since DBus API uses
uint64_t where 0 is a valid configuration, the patch modifies DBus API
by exploiting the variant type of property value to pass the NULL value.
2020-06-02 18:59:47 +02:00
Michal Koutný db2b8d2e28 cgroup: Make empty assignments reset to default
When MemoryLow= or MemoryMin= is set, it is interpretted as setting the
values to infinity. This is inconsistent with the default initialization
to 0.
It'd be nice to interpret the empty assignment as fallback to
DefaultMemory* of parent slice, however, current DBus API cannot convey
such a NULL value, so stick to simply interpretting that as hard-wired
default.
2020-06-02 18:59:47 +02:00
Michal Koutný 21c8397694 tests: Fix description of test units
Corrected reference to non-existent unit.
2020-06-02 18:59:47 +02:00
Zbigniew Jędrzejewski-Szmek eee9b30af4 basic/efivars: try re-reading efivars without delay first
Quoting https://github.com/systemd/systemd/issues/14828#issuecomment-635212615:

> [kernel uses] msleep_interruptible() and that means when the process receives
> any kind of signal masked or not this will abort with EINTR.  systemd-logind
> gets signals from the TTY layer all the time though.

> Here's what might be happening: while logind reads the EFI stuff it gets a
> series of signals from the TTY layer, which causes the read() to be aborted
> with EINTR, which means logind will wait 50ms and retry. Which will be
> aborted again, and so on, until quite some time passed. If we'd not wait for
> the 50ms otoh we wouldn't wait so long, as then on each signal we'd
> immediately retry again.
2020-06-02 17:32:29 +02:00
Lennart Poettering 75f6d5d87e fd-util: be more careful with fclose() errnos
This might fix #15859, a bug which I find very puzzling.
2020-06-02 17:32:02 +02:00
Yu Watanabe 8dd91cb55b network: drop an unused function 2020-06-02 17:06:01 +09:00
Yu Watanabe c24dd73952 network: move DHCPv6 related conf parsers to networkd-dhcp6.c 2020-06-02 17:06:00 +09:00
Yu Watanabe bdad94d0d6 network: set both dhcp_route_metric and dhcp6_route_metric by DHCP.RouteMetric= for backward compatibility
But [DHCPv4] or [DHCPv6] section take precedence.
This also update so for UseDNS= and UseNTP=.
2020-06-02 17:05:49 +09:00
Yu Watanabe 1bf1bfd958 network: add DHCPv6.RouteMetric=
Hopefully fixes #15295.
2020-06-02 15:16:51 +09:00
Yu Watanabe 132be2b868 network: use uint32_t instead of unsigned for route priority 2020-06-02 15:16:51 +09:00
Zbigniew Jędrzejewski-Szmek d06661ab66
Merge pull request #16030 from yuwata/network-read-mtime-of-dropin-configs-15521
network: also read mtime of drop-in configs
2020-06-01 15:14:13 +02:00
Yu Watanabe 397288e3eb
Merge pull request #15991 from keszybz/uids-gids-only-decimal
Only use base 10 for numeric uids/gids
2020-06-01 17:04:57 +09:00
Yu Watanabe 9f83091e3c network: also read mtime of drop-in configs
Fixes #15521.
2020-06-01 17:03:40 +09:00
Yu Watanabe c4473dec34 network: do not propagte error on stat() 2020-06-01 17:03:40 +09:00
Norbert Lange 63e2d1714e udev: single binary replacing udevd and udevadm
Since the separate binaries contain mostly the same code,
this almost halves the size of the installation.

before:
398K /bin/udevadm
391K /lib/systemd/systemd-udevd

after:
431K /bin/udevadm
0    /lib/systemd/systemd-udevd -> ../../bin/udevadm

Fixes: #14200
2020-06-01 09:41:21 +02:00
Yu Watanabe 0e77fc66bc network: fix double free in macsec_receive_channel_free()
Fixes #15941.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22547
2020-06-01 09:39:46 +02:00
Zbigniew Jędrzejewski-Szmek b9d19abd38
Merge pull request #16029 from yuwata/network-wireguard-without-peers-15786
network: configure wireguard without no peers
2020-06-01 09:34:04 +02:00
Yu Watanabe 50254f5500 network: wireguard: set ListenPort= when no peers are configured
Closes #15786.
2020-06-01 14:22:08 +09:00
Yu Watanabe dc851c00c3
Merge pull request #15982 from keszybz/shell-completion-and-help
Shell completion and udevd help update
2020-06-01 13:50:50 +09:00
Yu Watanabe f3e4b1e07c
Merge pull request #15884 from ssahani/dhcpv6-vendor
DHCPv6: Introduce vendor specific
2020-06-01 12:25:54 +09:00
Zbigniew Jędrzejewski-Szmek 156a5fd297 basic/user-util: always use base 10 for user/group numbers
We would parse numbers with base prefixes as user identifiers. For example,
"0x2b3bfa0" would be interpreted as UID==45334432 and "01750" would be
interpreted as UID==1000. This parsing was used also in cases where either a
user/group name or number may be specified. This means that names like
0x2b3bfa0 would be ambiguous: they are a valid user name according to our
documented relaxed rules, but they would also be parsed as numeric uids.

This behaviour is definitely not expected by users, since tools generally only
accept decimal numbers (e.g. id, getent passwd), while other tools only accept
user names and thus will interpret such strings as user names without even
attempting to convert them to numbers (su, ssh). So let's follow suit and only
accept numbers in decimal notation. Effectively this means that we will reject
such strings as a username/uid/groupname/gid where strict mode is used, and try
to look up a user/group with such a name in relaxed mode.

Since the function changed is fairly low-level and fairly widely used, this
affects multiple tools: loginctl show-user/enable-linger/disable-linger foo',
the third argument in sysusers.d, fourth and fifth arguments in tmpfiles.d,
etc.

Fixes #15985.
2020-05-31 18:38:16 +02:00
Zbigniew Jędrzejewski-Szmek f7091f458e loginctl: define loop iterators in the loop header 2020-05-31 18:38:16 +02:00
Zbigniew Jędrzejewski-Szmek d1109e12c0 udevd: update snippet string
Repeating the unit name in the description is not useful, and "manages devices"
is too cryptic.
2020-05-30 17:15:20 +02:00
Luca Boccassi d904afc730 core: reload cache if it's dirty when starting a UNIT_NOT_FOUND unit
The time-based cache allows starting a new unit without an expensive
daemon-reload, unless there was already a reference to it because of
a dependency or ordering from another unit.
If the cache is out of date, check again if we can load the
fragment.
2020-05-30 16:50:05 +02:00
Zbigniew Jędrzejewski-Szmek 956508cb5d
Merge pull request #15935 from poettering/cache-more-efi-vars
logind + efi-loader: cache more efi vars
2020-05-30 15:44:26 +02:00
Zbigniew Jędrzejewski-Szmek 3a02643a40
Merge pull request #15915 from poettering/journal-external-link
journal: show external links in log output
2020-05-30 15:04:40 +02:00
Lennart Poettering ddb82ec2a2 sd-dhcp: clean-up of DHCP lease server code
This is an attempt to clean-up the DHCP lease server type code a bit. We
now strictly use the same enum everywhere, and store server info in an
array. Moreover, we use the same nomenclature everywhere.

This only makes the changes in the sd-dhcp code. The networkd code is
untouched so far (but should be fixed up like this too. But it's more
complicated since this would then touch actual settings in .network
files).

Note that this also changes some field names in serialized lease files.
But given that these field names have not been part of a released
version of systemd yet, such a change should be ok.

This is pure renaming/refactoring, shouldn't actually change any
behaviour.
2020-05-30 14:18:43 +02:00
Susant Sahani a1422af564 network: L2TP fix crash
```
=220358== Invalid read of size 8
==220358==    at 0x452F05: l2tp_session_free (l2tp-tunnel.c:46)
==220358==    by 0x456926: l2tp_tunnel_done (l2tp-tunnel.c:725)
==220358==    by 0x43CF4D: netdev_free (netdev.c:205)
==220358==    by 0x43D045: netdev_unref (netdev.c:210)
==220358==    by 0x4198B7: manager_free (networkd-manager.c:1877)
==220358==    by 0x40D0B3: manager_freep (networkd-manager.h:105)
==220358==    by 0x40DE1C: run (networkd.c:21)
==220358==    by 0x40DE75: main (networkd.c:130)
==220358==  Address 0x5c035d0 is 0 bytes inside a block of size 40 free'd
==220358==    at 0x483A9F5: free (vg_replace_malloc.c:538)
==220358==    by 0x452F87: l2tp_session_free (l2tp-tunnel.c:57)
==220358==    by 0x456857: netdev_l2tp_tunnel_verify (l2tp-tunnel.c:710)
==220358==    by 0x440947: netdev_load_one (netdev.c:738)
==220358==    by 0x441222: netdev_load (netdev.c:851)
==220358==    by 0x419C50: manager_load_config (networkd-manager.c:1934)
==220358==    by 0x40D7BE: run (networkd.c:87)
==220358==    by 0x40DE75: main (networkd.c:130)
==220358==  Block was alloc'd at
==220358==    at 0x4839809: malloc (vg_replace_malloc.c:307)
==220358==    by 0x452A76: malloc_multiply (alloc-util.h:96)
==220358==    by 0x4531E6: l2tp_session_new_static (l2tp-tunnel.c:82)
==220358==    by 0x455C01: config_parse_l2tp_session_id (l2tp-tunnel.c:535)
==220358==    by 0x48E6D72: next_assignment (conf-parser.c:133)
==220358==    by 0x48E77A3: parse_line (conf-parser.c:271)
==220358==    by 0x48E7E4F: config_parse (conf-parser.c:396)
==220358==    by 0x48E80E5: config_parse_many_files (conf-parser.c:453)
==220358==    by 0x48E8490: config_parse_many (conf-parser.c:512)
==220358==    by 0x44089C: netdev_load_one (netdev.c:729)
==220358==    by 0x441222: netdev_load (netdev.c:851)
==220358==    by 0x419C50: manager_load_config (networkd-manager.c:1934)

```
2020-05-30 11:59:27 +02:00
Zbigniew Jędrzejewski-Szmek 856e51957a strv: propagate location info from the call site too 2020-05-30 11:40:53 +02:00
Zbigniew Jędrzejewski-Szmek 138f49e452 basic/hashmap,set: change "internal_" to "_" as the prefix
"internal" is a lot of characters. Let's take a leaf out of the Python's book
and simply use _ to mean private. Much less verbose, but the meaning is just as
clear, or even more.
2020-05-30 11:40:53 +02:00
Zbigniew Jędrzejewski-Szmek 55825de59b basic/hashmap: drop unneeded macro 2020-05-30 11:40:53 +02:00
Zbigniew Jędrzejewski-Szmek 43874aa7bb hashmap: don't allow hashmap_type_info table to be optimized away
This makes debugging hashmaps harder, because we can't query the size.  Make
sure that table is always present.
2020-05-30 11:40:37 +02:00
Zbigniew Jędrzejewski-Szmek 06134457d2 basic/hashmap: update comment 2020-05-30 11:24:57 +02:00
Daan De Meyer 269412ef44
Merge pull request #15958 from layderv/master
#15773 add --reboot-arg to systemctl reboot
2020-05-30 11:04:14 +02:00
laydervus dae710bef1 #15773 add --reboot-argument to systemctl reboot 2020-05-29 21:22:29 +01:00
Lennart Poettering 29da419305 stat-util: trivial empty_or_null() tweaks
To small tweaks: /dev/null is definitely a char device. And if we have
the path, to a string base comparison first.
2020-05-29 21:23:43 +02:00
sterlinghughes 8acb11a6a3 Check ambient set against bounding set prior to applying ambient set
Fixes #15020
2020-05-29 21:23:26 +02:00
Lennart Poettering 5fc20ede0f
Merge pull request #15954 from keszybz/unit-file-leak
Fix leak in unit path cache and another small optimization
2020-05-29 16:02:53 +02:00
Lennart Poettering 84190644ff efi: add more logging for all EFI variable reads 2020-05-29 15:42:09 +02:00
Lennart Poettering 002914e688 bootctl: add simple, low-level reboot-to-firmware verb for controlling the flag 2020-05-29 15:41:50 +02:00
Lennart Poettering 8a96369e0b bootctl: show reboot-to-firmware info, too 2020-05-29 15:41:46 +02:00
Lennart Poettering c37070c85a efi: cache OsIndications too 2020-05-29 15:41:43 +02:00
Lennart Poettering d197c403b2 efi: explicitly update mtime of EFI variables when changing them 2020-05-29 15:41:31 +02:00
Lennart Poettering c75e7da0b5 efi: as extra paranoia NUL terminate UTF-16 strings with three NUL bytes
This is a safey net anyway, let's make it fully safe: if the data ends
on an uneven byte, then we need to complete the UTF-16 codepoint first,
before adding the final NUL byte pair. Hence let's suffix with three
NULs, instead of just two.
2020-05-29 15:41:18 +02:00
Lennart Poettering 9e5230aad9 efi: cache OsIndicationsSupported
As suggested by:

https://github.com/systemd/systemd/issues/14828#issuecomment-634202054
2020-05-29 15:41:06 +02:00
Lennart Poettering 5c25f42322 efi: avoid weirdly double }} by indenting differently 2020-05-29 15:41:03 +02:00
Lennart Poettering d4bd786d69 efi: cache LoaderEntries EFI variable
Based-on:

https://github.com/systemd/systemd/issues/14828#issuecomment-634202054
2020-05-29 15:40:01 +02:00
Evgeny Vereshchagin ceae629564 README: add a Fossies codespell badge
I keep forgetting where the report is. Hopefully the badge will
make it easier to find it. I also fixed several typos codespell
found along the way.
2020-05-29 15:06:16 +02:00
Yu Watanabe 433e14fda7 network: fix memleaks
Fixes #15951.
2020-05-29 14:49:40 +02:00