Commit Graph

29902 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 01b92946c5
Merge pull request #16532 from yuwata/network-sync-state-file
network: sync link state file on dbus call, and ndisc cleanups
2020-07-23 16:34:38 +02:00
Zbigniew Jędrzejewski-Szmek d4fa0493a7 test-ordered-set: add a case where we get 0 for duplicate entries
This API is a complete mess. We forgot to do a hashed comparison for duplicate
entries and we use a direct pointer comparison. For trivial_hash_ops the result
is the same. For all other case, it's not. Fixing this properly will require
auditing all the uses of set_put() and ordered_set_put(). For now, let's just
acknowledge the breakage.
2020-07-23 15:47:21 +02:00
Zbigniew Jędrzejewski-Szmek 66bb00590f basic/terminal-util: define all foreground colors
We would add and remove definitions based on which colors were used by other
code. Let's just define all of them to simplify tests and allow easy comparisons
which colors look good.
2020-07-23 15:04:15 +02:00
Yu Watanabe 2645d4bcc1 test: clarify that ordered_set_put() returns -EEXIST if entry is duplicated 2020-07-23 21:29:32 +09:00
Lennart Poettering 82ff544160
Merge pull request #16496 from DaanDeMeyer/firstboot-shell
firstboot: Add --root-shell option and tighten up passwd/shadow handling
2020-07-23 08:39:45 +02:00
Lennart Poettering 00b868e857
Merge pull request #16542 from keszybz/make-targets-fail-again
Make targets fail again
2020-07-23 08:37:47 +02:00
Lennart Poettering c3f8a065e9 execute: take ownership of more fields in ExecParameters
Let's simplify things a bit, and take ownership of more fields in
ExecParameters, so that they are automatically freed when the structure
is released.
2020-07-23 08:37:21 +02:00
Daan De Meyer 28900a1bfe firstboot: Add --root-shell option 2020-07-22 21:22:46 +01:00
Daan De Meyer c4a53ebf7a firstboot: Tighten up passwd/shadow handling
There are a lot of edge cases that the current implementation
doesn't handle, especially in cases where one of passwd/shadow
exists and the other doesn't exist. For example, if
--root-password is specified, we will write /etc/shadow but
won't add a root entry to /etc/passwd if there is none.

To fix some of these issues, we constrain systemd-firstboot to
only modify /etc/passwd and /etc/shadow if both do not exist
already (or --force) is specified. On top of that, we calculate
all necessary information for both passwd and shadow upfront so
we can take it all into account when writing the actual files.

If no root password options are given --force is specified or both
files do not exist, we lock the root account for security purposes.
2020-07-22 21:22:41 +01:00
Zbigniew Jędrzejewski-Szmek 94d1ddbd7c pid1: target units can fail through dependencies
Fixes #16401.

c80a9a33d0 introduced the .can_fail field,
but didn't set it on .targets. Targets can fail through dependencies.
This leaves .slice and .device units as the types that cannot fail.

$ systemctl cat bad.service bad.target bad-fallback.service
[Service]
Type=oneshot
ExecStart=false

[Unit]
OnFailure=bad-fallback.service

[Service]
Type=oneshot
ExecStart=echo Fixing everythign!

$ sudo systemctl start bad.target
systemd[1]: Starting bad.service...
systemd[1]: bad.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: bad.service: Failed with result 'exit-code'.
systemd[1]: Failed to start bad.service.
systemd[1]: Dependency failed for bad.target.
systemd[1]: bad.target: Job bad.target/start failed with result 'dependency'.
systemd[1]: bad.target: Triggering OnFailure= dependencies.
systemd[1]: Starting bad-fallback.service...
echo[46901]: Fixing everythign!
systemd[1]: bad-fallback.service: Succeeded.
systemd[1]: Finished bad-fallback.service.
2020-07-22 17:58:12 +02:00
Zbigniew Jędrzejewski-Szmek 771b52427a core/job: adjust whitespace and comment 2020-07-22 17:58:12 +02:00
Yu Watanabe 2c62149509 network: ndisc: ignore duplicated IPv6Token= 2020-07-22 20:26:11 +09:00
Yu Watanabe 92ee90af47 network: ndisc: do not store duplicated data in Set
The Address objects in the set generated by ndisc_router_generate_addresses()
have the equivalent prefixlen, flags, prefered lifetime.
This commit makes ndisc_router_generate_addresses() return Set of
in6_addr.
2020-07-22 20:26:05 +09:00
Zbigniew Jędrzejewski-Szmek 3bb4126262
Merge pull request #16536 from poettering/time-clock-map-fixes
time-util: clock mapping improvements
2020-07-22 13:05:13 +02:00
Yu Watanabe 3dbd8a15d5 util: use IN6_ARE_ADDR_EQUAL() macro 2020-07-22 19:55:15 +09:00
Yu Watanabe 1b14222124 network: make bus methods sync link state file 2020-07-22 19:55:15 +09:00
Yu Watanabe c2a6595014 network: introduce link_save_and_clean() 2020-07-22 19:55:14 +09:00
Yu Watanabe f281fc1e95 tree-wide: use siphash24_compress_string() where it is applicable 2020-07-22 19:55:14 +09:00
Yu Watanabe 1c568d65ac util: introduce siphash24_compress_string() 2020-07-22 19:55:14 +09:00
Yu Watanabe 6c04fccb1d util: make siphash24_compress_boolean() inline
This also changes the stored type from int to uint8_t in order to make
hash value endianness independent.
2020-07-22 19:55:14 +09:00
Zbigniew Jędrzejewski-Szmek e3643b00a8 test-path: decrease variable scope 2020-07-22 12:12:54 +02:00
Zbigniew Jędrzejewski-Szmek 8f8c7801e9 test: increase timeout for test-path
The CI occasionally fail in test-path with a timeout. test-path loads
units from the filesystem, and this conceivably might take more than
the default limit of 3 s. Increase the timeout substantially to see if
this helps.
2020-07-22 12:12:36 +02:00
Zbigniew Jędrzejewski-Szmek 2859bb932b
Merge pull request #16530 from yuwata/udev-fix-race-in-renaming-network-interface
udev: fix race in renaming network interface
2020-07-22 11:50:09 +02:00
Lennart Poettering 63fdaa36c5
Merge pull request #16407 from bluca/verity_reuse
verity: re-use already open devices if the hashes match
2020-07-22 11:36:49 +02:00
Zbigniew Jędrzejewski-Szmek f25e9eda52
Merge pull request #16514 from keszybz/zstd-decompress-fix
Fix coredumpctl operation with zstd-compressed journals
2020-07-22 10:40:19 +02:00
Luca Boccassi ac1f3ad05f verity: re-use already open devices if the hashes match
Opening a verity device is an expensive operation. The kernelspace operations
are mostly sequential with a global lock held regardless of which device
is being opened. In userspace jumps in and out of multiple libraries are
required. When signatures are used, there's the additional cryptographic
checks.

We know when two devices are identical: they have the same root hash.
If libcrypsetup returns EEXIST, double check that the hashes are really
the same, and that either both or none have a signature, and if everything
matches simply remount the already open device. The kernel will do
reference counting for us.

In order to quickly and reliably discover if a device is already open,
change the node naming scheme from '/dev/mapper/major:minor-verity' to
'/dev/mapper/$roothash-verity'.

Unfortunately libdevmapper is not 100% reliable, so in some case it
will say that the device already exists and it is active, but in
reality it is not usable. Fallback to an individually-activated
unique device name in those cases for robustness.
2020-07-21 23:42:03 +01:00
Luca Boccassi 536879480a dm-util: use CRYPT_DEACTIVATE_DEFERRED instead of ioctl 2020-07-21 23:26:41 +01:00
Lennart Poettering d81be4e752 coredump: port to use common add_acls_for_user()
It's line-by-line the same logic, hence use the common implementation.
2020-07-21 22:58:40 +02:00
Lennart Poettering 2ea6247e01 acl-util: fix error handling in add_acls_for_user() 2020-07-21 22:58:40 +02:00
Lennart Poettering 002674387c offline-passwd: use chase_symlinks()
In case the passwd/group file is symlinked, follow things correctly.

Follow-up for: #16512
Addresses: https://github.com/systemd/systemd/pull/16512#discussion_r458073677
2020-07-21 22:31:00 +02:00
Zbigniew Jędrzejewski-Szmek 7cbb7d62c6 homectl: fix warning about unused function
../src/home/homectl-pkcs11.c:19:13: warning: ‘pkcs11_callback_data_release’ defined but not used [-Wunused-function]
   19 | static void pkcs11_callback_data_release(struct pkcs11_callback_data *data) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-07-21 17:42:16 +02:00
Zbigniew Jędrzejewski-Szmek e4a321fc08 journal/compress: remove loop in decompress_startswith_zstd()
This should be more efficient with no downsides. Same considerations as in the
previous commit hold.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek a24153279e journal/compress: fix zstd decompression with capped output size
decompress_blob_zstd() would allocate ever bigger buffers in a loop trying to
get a buffer big enough to decompress the input data. This is wasteful, since
we can just query the size of the decompressed data from the compressed header.
Worse, it doesn't work when the output size is capped, i.e. when dst_max != 0.
If the decompressed blob happened to be bigger than dst_max, decompression
would fail with -ENOBUFS. We need to use "stream decompression" instead, and
only get min(uncompressed size, dst_max) bytes of output.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856037 in a second way.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek b4a11ca3f2 journal: use -EPROTONOSUPPORT for unknown compression
We might add more compression types in the future, and we should treat that
as unsupported, and not a format error.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek 76cbafcdd4 sd-journal: when enumerating, continue even after an inaccessible field
SD_JOURNAL_FOREACH_DATA() and SD_JOURNAL_FOREACH_UNIQUE() would immediately
terminate when a field couldn't be accessed. This can happen for example when a
field is compressed with an unavailable compression format. But it's likely
that this is the wrong thing to do: the caller for example might want to
iterate over the fields but isn't interested in all of them. coredumpctl is
like this: it uses SD_JOURNAL_FOREACH_DATA() but only uses a subset of the
fields.

Add two new functions sd_journal_enumerate_good_data() and
sd_journal_enumerate_good_unique() that retry sd_journal_enumerate_data() and
sd_journal_enumerate_unique() if the return value is something that applies to
a single field: ENOBUS, E2BIG, EOPNOTSUPP.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856037.

An alternative would be to make the macros themselves smarter instead of adding
new symbols, and do the looping internally in the macro. I don't like that
approach for two reasons. First, it would embed the logic in the macro, so
recompilation would be required if we decide to update the logic. With the
current version of the patch, recompilation is required to use the new symbols,
but after that, library upgrades are enough. So the current approach is safer
in case further updates are needed. Second, our headers use primitive C, and it
is hard to do the macros without using newer features.
2020-07-21 17:42:11 +02:00
Lennart Poettering 04dffc0add user-util: indentation fix 2020-07-21 17:41:57 +02:00
Lennart Poettering 58afc4f8e4 core: don't acquire dual timestamp needlessly if we don't need it in .timer handling
Follow-up for: 26698337f3
2020-07-21 17:33:47 +02:00
Lennart Poettering d3926f9a46 test: add basic test for clock mapping 2020-07-21 17:33:47 +02:00
Lennart Poettering 7c0eb30e32 time-util: rework clock conversion logic
Let's split this out into its own helper function we can reuse at
various places.

Also, let's avoid signed values where we can so that we can cover more
of the available time range.
2020-07-21 17:30:49 +02:00
Lennart Poettering 6456dafa12
Merge pull request #16504 from poettering/read-file-ipc
fileio: teach read_full_file() the ability to read data from AF_UNIX stream socket
2020-07-21 14:16:32 +02:00
Lennart Poettering c400d040ce import: always prefer GNU tar, to avoid cmdline incompatibilities
Fixes: #16506
2020-07-21 14:16:02 +02:00
Lennart Poettering 9200bb30d0 journalctl: make pcre2 a dlopen() dependency
Let's make use of the library if it is installed, but otherwise just
generate a nice error and provide all other functionality.
2020-07-21 10:37:54 +02:00
Lennart Poettering 046c91314a dlfcn-util: add dlsym_many_and_warn() helper
When we dlopen() some library we most likely will resolve more than a
few symbols, hence add a helper that makes it easy.
2020-07-21 10:36:38 +02:00
Lennart Poettering 3177b9270c fileio: add brief explanations for flags 2020-07-21 10:32:01 +02:00
Lennart Poettering 49f16281c9 tree-wide: use READ_FULL_FILE_CONNECT_SOCKET at various places
Let's use the new flag wherever we read key material/passphrases/hashes
off disk, so that people can plug in their own IPC service as backend if
they like, easily.

(My main goal was actually to support this for crypttab key files — i.e.
that you can specify AF_UNIX sockets as third column in crypttab — but
that's harder to implement, since the keys are read via libcryptsetup's
API, not ours.)
2020-07-21 10:32:01 +02:00
Lennart Poettering c668aa8b35 fileio: allow to read base64/hex data as strings
There's really no reason to prohibit this, hence don't.
2020-07-21 10:31:50 +02:00
Lennart Poettering b93d3f6b81 fileio: add support for read_full_file() on AF_UNIX stream sockets
Optionally, teach read_full_file() the ability to connect to an AF_UNIX
socket if the specified path points to one.
2020-07-21 10:23:44 +02:00
Lennart Poettering f294470262 fileio: add explicit flag for generating world executable warning when reading file 2020-07-21 09:56:44 +02:00
Zbigniew Jędrzejewski-Szmek 2e3e2750bb
Merge pull request #16519 from yuwata/networkctl-altnames
networkctl: tiny cleanups about alternative names
2020-07-21 09:10:00 +02:00
Zbigniew Jędrzejewski-Szmek 739b9a4354
Merge pull request #16353 from yuwata/network-dns-sni
resolve, network: more SNI and port number support
2020-07-21 08:06:17 +02:00
Yu Watanabe 28266c446a udev: drop unnecessary checks
Also, drop one unnecessary sd_device_unref(), as dev_db_clone will be
unref()ed in udev_event_free().
2020-07-21 11:55:28 +09:00
Yu Watanabe ae353ec2f6 udev: save ID_RENAMING= property to database before renaming network interface 2020-07-21 11:55:28 +09:00
Yu Watanabe 1cdea1a2f7 network: update one log message 2020-07-21 11:55:28 +09:00
Hans de Goede 3a978b30cd logind: Fix org.freedesktop.login1.set-reboot-to-boot-loader-menu saving to the wrong file in the non EFI case
According to the docs, and to the
org.freedesktop.login1.get-reboot-to-boot-loader-menu code, the
(oneshot) boot-loader-menu timeout should be stored in
/run/systemd/reboot-to-boot-loader-menu, but the set method was storing it
in /run/systemd/reboot-to-loader-menu.

This commit fixes this. Note that the fixed name also is a better match
for the dbus call names and matches the related
/run/systemd/reboot-to-boot-loader-entry structure, so fixing the set code,
rather then the get code + docs seems like the right thing to do here.
2020-07-21 10:02:34 +09:00
fangxiuning ddbab78f9a bus: use bus_log_connect_error to print error message 2020-07-21 10:02:01 +09:00
Yu Watanabe a574b7d152 resolvectl: use bus_message_read_in_addr_auto() 2020-07-21 04:12:11 +09:00
Yu Watanabe 7695e2cbbe network, resolve: use bus_message_read_ifindex() or friends 2020-07-21 04:08:22 +09:00
Yu Watanabe 3dd95ab6c5 util: introduce bus_message_read_ifindex() 2020-07-21 04:08:22 +09:00
Yu Watanabe 10d4620467 util: introduce bus_mesage_read_dns_servers() 2020-07-21 04:08:22 +09:00
Yu Watanabe 976009897b util: introduce helper functions to read in_addr from bus message 2020-07-21 04:08:22 +09:00
Yu Watanabe e293e755d5 util: drop duplicated inclusion of sd-bus.h 2020-07-21 04:08:22 +09:00
Yu Watanabe a747e71c56 resolvectl: show DNS servers with port and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe b1881e8320 resolvectl: make DNS servers can be specified with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 8e56ea4c88 resolve: add DBus properties which support DNS SNI and port number 2020-07-21 04:08:22 +09:00
Yu Watanabe 95ce1ba87b resolve: add DBus method to set DNS server with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 4e11ddfdd3 network: add DBus method to set DNS server with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 87d6489776 network: save DNS servers specified by DBus interface
Also, filter out DNS servers which do not match link ifindex.
2020-07-21 04:08:22 +09:00
Yu Watanabe 6458176514 network: do not save DNS= entries not match link ifindex 2020-07-21 04:08:22 +09:00
Yu Watanabe e77bd3fdff network: support port number and SNI in [Network] DNS= 2020-07-21 04:08:22 +09:00
Yu Watanabe 8aa5afd20f resolve: read/save port number and SNI from/into link state file 2020-07-21 04:08:16 +09:00
Yu Watanabe b6af282475 resolve: compare port and SNI in dns_server_hash_ops 2020-07-21 04:04:49 +09:00
Yu Watanabe 1b86009298 resolve: also compare port and SNI in dns_server_find() 2020-07-21 04:04:49 +09:00
Yu Watanabe da9de7385a resolve: support port specifier in DNS= setting 2020-07-21 04:04:42 +09:00
Yu Watanabe 395aa34023 resolve: ignore empty server name
Just for safety.
2020-07-21 03:55:34 +09:00
Yu Watanabe 408f8fbc0f util: introduce 'struct in_addr_full' and its helper functions 2020-07-21 03:55:34 +09:00
Yu Watanabe a723fb85da util: introduce in_addr_port_ifindex_name_from_string_auto() and in_addr_port_ifindex_name_to_string() 2020-07-21 03:55:34 +09:00
Yu Watanabe cbe194b39e resolve: propagate error in link_load_user()
Most error path in link_load_user() are ENOMEM. Hence, it is critical.
2020-07-21 03:55:34 +09:00
Yu Watanabe eced0d2a46
Merge pull request #16518 from yuwata/network-fix-failure-in-updating-mac-address
network: fix failures in updating MAC address
2020-07-21 02:13:24 +09:00
Zbigniew Jędrzejewski-Szmek 7e8279c0a6
Merge pull request #16501 from yuwata/udev-fix-renaming
udev: fix issues in renaming interface vs alternative names
2020-07-20 09:00:02 +02:00
Yu Watanabe 807667f7ac network: stop already running engines before updating MAC address
In NetworkdBridgeTests.test_bridge_configure_without_carrier of
systemd-networkd-tests.py

```
bridge99: MAC address: 2e:3a:ec:4d:d3:62
Assertion 'sd_ipv4ll_is_running(ll) == 0' failed at src/libsystemd-network/sd-ipv4ll.c:110, function int sd_ipv4ll_set_mac(sd_ipv4ll *, const struct ether_addr *)(). Ignoring.
bridge99: Could not update MAC address in IPv4LL client: Device or resource busy
```
2020-07-20 15:29:55 +09:00
Yu Watanabe 96fe813c42 radv: introduce sd_radv_is_running() 2020-07-20 15:29:12 +09:00
Yu Watanabe 48c5398951 networkctl: do not ignore -EOPNOTSUPP when reading netlink message
If the kernel does not support alternative interface names, then
sd_netlink_message_read_strv() should just return -ENODATA.
2020-07-20 15:24:40 +09:00
Yu Watanabe ae5b779252 networkctl: sort alternative names 2020-07-20 15:24:40 +09:00
Franck Bui 0ef1adf512 vconsole-setup: downgrade log message when setting font fails on dummy console
Since commit 883eb9be98, vconsole-setup might be
called again to operate on dummy console where font operations are not
supported but where it's still important to have the correct keymap set [0][1].

vconsole-setup is mainly called by udev but can also be run via a dependency of
an early service. Both cases might end up calling vconsole-setup on the dummy
console.

The first case can happen during early boot even on systems that use (instead
of the dummy console) a "simple" video console driver supporting font
operations (such as vgacon) until a more specific driver (such as i915) takes
the console over. While this is happening vgacon is deactivated and temporarly
replaced by the dummy console [2].

There are also other cases where systemd-vconsole-setup might be called on
dummy console especially during (very) early boot. Indeed
systemd-vconsole-setup.service might be pulled in by early interactive services
such as 'dracut-cmdline-ask.service` which is run before udev.

If that happens on platforms with no grapical HWs (such as embedded ARM) or
with dummy console initially installed until a driver takes over (like Xen and
xen-fbfront) then setting font will fail.

Therefore this patch downgrades the log message emitted when setting font fails
to LOG_DEBUG and when font operations is not implemented like it's the case for
the dummy console.

Fixes: #16406.

[0] https://github.com/systemd/systemd/issues/10826
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1652473
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
2020-07-20 08:15:50 +02:00
Yu Watanabe 628f08b66d sd-netlink: make timeout message sealed
When sd_netlink_call_async() timed out, then we reply the synthetic
error message, but it was not sealed. So, reading the message causes
the following assertion:

```
Assertion 'm->sealed' failed at src/libsystemd/sd-netlink/netlink-message.c:652, function netlink_message_read_internal(). Ignoring.
```
2020-07-20 07:49:55 +02:00
Zbigniew Jędrzejewski-Szmek d735e4f2d6
Merge pull request #16505 from yuwata/network-manage-foreign-routes-cleanups
network: do not enumerate foreign routes when ManageForeignRoutes=no, and tiny cleanups
2020-07-20 07:48:57 +02:00
Luca Boccassi ed4512d009 nspawn: set container_host env vars before user arguments
Allows users on the command line to seamlessly override
$container_host_* just like they can override $container_id and
$container
2020-07-20 07:28:22 +02:00
YmrDtnJu a9c9b18a95 networkd: Use NLM_F_ACK on the netlink message to add a neighbor.
sd_netlink_message_set_flags is called without NLM_F_ACK which results in
a timeout while networkd is waiting for an ACK that the kernel will never send.
2020-07-20 11:30:35 +09:00
Yu Watanabe 4573592ddf
Merge pull request #16512 from keszybz/offline-passwd-altfiles
Support alternate passwd/group locations in tmpfiles
2020-07-19 06:46:05 +09:00
Zbigniew Jędrzejewski-Szmek 241947d1b4 shared/offline-passwd: look at /usr/lib/{passwd,group} too
This changes the code to allow looking at multiple files with different
prefixes, but uses "/etc" and "/usr/lib". rpm-ostree uses
/usr/lib/{passwd,group} with nss-altfiles. I see no harm in simply trying both
paths on all systems.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1857530.

A minor memory leak is fixed: hashmap_put() returns -EEXIST is the key is
present *and* and the value is different. It return 0 if the value is the
same. Thus, we would leak the user/group name if it was specified multiple
times with the same uid/gid. I opted to remove the warning message completely:
with multiple files it is reasonable to have the same name defined more than
once. But even with one file the warning is dubious: all tools that read those
files deal correctly with duplicate entries and we are not writing a linter.
2020-07-18 14:14:19 +02:00
Zbigniew Jędrzejewski-Szmek 3e5d2264b5 Move offline-password.[ch] to shared and add test-offline-passwd
The test binary has two modes: in the default argument-less mode, it
just checks that "root" can be resolved. When invoked manually, a root
prefix and user/group names can be specified.
2020-07-18 14:14:19 +02:00
Yu Watanabe 0119ab3d6c
Merge pull request #16476 from keszybz/qemu-autosuspend-rules
Add autosuspend rules for emulated QEMU devices
2020-07-18 09:10:20 +09:00
Yu Watanabe a8c10331b4 network: replace NDISC -> NDisc in log messages 2020-07-18 05:51:41 +09:00
Yu Watanabe 5eec0a0810 network: introduce address_exists() helper function 2020-07-18 05:51:41 +09:00
Yu Watanabe d15818f227 network: update debug log when foreign routes are received with ManageForeignRoutes=no 2020-07-18 05:51:41 +09:00
Yu Watanabe 5ff1ef31f2 network: do not enumerate routes if ManageForeignRoutes=no 2020-07-18 05:51:32 +09:00
Yu Watanabe 97fdae33df udev: do not try to reassign alternative names
Setting alternative names may fail if some of them are already assigned.
2020-07-17 21:36:11 +09:00
Yu Watanabe 434a348380 netlink: do not fail when new interface name is already used as an alternative name
When renaming a network interface, the new name may be used as an
alternative name. In that case, let's swap the current name and the
alternative name. That is, first drop the new name from the list of
alternative names, then rename the interface, finally set the old name
as an alternative name.
2020-07-17 21:31:47 +09:00
Yu Watanabe 1498252614 netlink: introduce rtnl_get/delete_link_alternative_names() 2020-07-17 21:29:13 +09:00
Yu Watanabe 7f16ef9fba
Merge pull request #16490 from yuwata/network-radv-ndisc-cleanups
network: cleanups for radv and ndisc
2020-07-17 15:12:53 +09:00
Zbigniew Jędrzejewski-Szmek dc9e9a18be
Merge pull request #16491 from keszybz/udev-logging
Improvements to udev logging and related code
2020-07-17 07:12:58 +02:00
Zbigniew Jędrzejewski-Szmek 9e79123884 tree-wide: use SYNTHETIC_ERRNO with log_device_* in more places 2020-07-16 22:08:12 +02:00
Zbigniew Jędrzejewski-Szmek 46d4149d0f sd-device: use LOG_PRI() in log_device_full()
We use LOG_PRI() in all log_*() functions, so let's do that here too for
consistency. Effectively this doesn't change anything since we only use
LOG_{INFO,DEBUG,...} as the argument.
2020-07-16 22:05:21 +02:00
Anita Zhang b5ef66101a analyze: CAP_RAWIO -> CAP_SYS_RAWIO
Fixes #16489
2020-07-16 21:14:59 +02:00
Yu Watanabe 94ec163ad2 timedatectl: do not show (null) if the address of NTP server is not resolved 2020-07-17 03:10:42 +09:00
Zbigniew Jędrzejewski-Szmek df7667323d udev: change the modalias string for usb devices to include the device name
When the kernel does not provide a modalias, we generate our own for usb devices.
For some reason, we generated the expected usb:vXXXXpYYYY string, suffixed by "*".
It was added that way already in 796b06c21b, but I
think that was a mistake, and Kay was thinking about the match pattern instead
of the matched string.

For example, for a qemu device:
old: "usb:v0627p0001*"
new: "usb:v0627p0001:QEMU USB Tablet"

On the match side, all hwdb files in the wild seem to be using match patterns
with "*" at the end. So we can add more stuff to our generated modalias with
impunity.

This will allow more obvious and more certain matches on USB devices. In
principle the vendor+product id should be unique, but it's only 8 digits, and
there's a high chance of people getting this wrong. And matching the wrong
device would be quite problematic. By including the name in the match string we
make a mismatch much less likely.
2020-07-16 19:00:26 +02:00
Zbigniew Jędrzejewski-Szmek d6d4961b01 udev: don't complain when udev_watch_end() is called without udev_watch_init()
E.g. udevadm test prints "Invalid inotify descriptor." which is
meaningless without any context. I think it should be OK to call udev_watch_end()
from a cleanup path without any warning (even at debug level).
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 6b9f5f01cb basic/string-table: reduce variable scope 2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 5992f362bf udevadm: use STR_IN_SET(), add comment 2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek fe20121a4c sd-device: use strjoin instead of asprintf
strjoin should be faster for string concatenation.
Also drop "_"-prefix from function prototypes.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 22ba4525d3 udev: tweak debug logs for udev rules
We shouldn't say "ignoring" when running a program because the result is used for
the match/nomatch result of the rule.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek ba60127df7 udev: accept OPTIONS+= without any fuss
There is no reason to consider this wrong. In fact one could argue that +=
is more appropriate, because we always add to options, and not replace previous
assignments. If we output a debug message, we implicitly ask people to "fix" this,
and we shouldn't.

Also, all our rules use += right now.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek b6a80b83bc udev: accept IMPORT{}= without any fuss
Udev logs are full of messages about wrong operator type:
...
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:54 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:57 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:60 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:63 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:66 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:67 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:93 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:107 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:110 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:113 IMPORT key takes '==' or '!=' operator, assuming '=='.
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
/usr/lib/udev/rules.d/60-persistent-v4l.rules:7 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-v4l.rules:9 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-v4l.rules:16 IMPORT key takes '==' or '!=' operator, assuming '=='.
...

The warning was downgraded in f0beb6f816, but I
think it should be removed altogether. IMPORT{program}="asdf" seems like an
obvious way to write this, and people don't expect to have to write "==".
So let's just allow any operator.
2020-07-16 18:38:03 +02:00
Yu Watanabe 13e8a49a58 network: ndisc: any failures in processing event make the link in failed state
Also adjust log levels.
2020-07-17 01:18:44 +09:00
Yu Watanabe c97785168b network: radv: clean up conf parsers 2020-07-17 01:16:38 +09:00
Yu Watanabe d96edb2c6e network: downgrade log level in conf parsers 2020-07-17 00:40:09 +09:00
Lennart Poettering 4d939d2c84
Merge pull request #16485 from bluca/nspawn_os_release_mounts
Follow-up for comments on #15891
2020-07-16 15:09:35 +02:00
Yu Watanabe 9e54462cd5
Merge pull request #16482 from poettering/coverity-246
two coverity fixes
2020-07-16 20:23:23 +09:00
Luca Boccassi 14f1c47a0c nspawn: mount os-release in two steps to make it read-only
The kernel interface requires setting up read-only bind-mounts in
two steps, the bind first and then a read-only remount.
Fix nspawn-mount, and cover this case in the integration test.

Fixes #16484
2020-07-16 09:59:59 +01:00
Luca Boccassi eafc7d6056 nspawn: use access/F_OK instead of stat to check for file existence 2020-07-16 09:59:59 +01:00
Luca Boccassi 2094cd49c4 shared/os-util: fix comment style to follow guidelines 2020-07-16 09:59:59 +01:00
Luca Boccassi cc76bf01e3 basic/mkdir: use uid_is_valid instead of manual check 2020-07-16 09:59:59 +01:00
Zbigniew Jędrzejewski-Szmek 27806670ef
Merge pull request #16480 from yuwata/network-fix-dhcp4-races
network: fix two minor races in DHCP4 handling
2020-07-16 10:04:05 +02:00
Lennart Poettering 3cd4459003 Revert "selinux: cache enforced status and treat retrieve failure as enforced mode"
This reverts commit 257188f80c.
2020-07-16 08:49:35 +02:00
Lennart Poettering 8e32ad9557 machine: fix if check
Fixes: coverity 1430462
2020-07-16 08:35:26 +02:00
Lennart Poettering f63ef93703 execute: fix if check
Fixes: coverity 1430459
2020-07-16 08:35:18 +02:00
Yu Watanabe 0ded0e40ab dhcp4: only renewing lease when the client already has a lease
Follow-up for ceaec54a3c.

Hopefully fixes #16299.
2020-07-16 14:58:54 +09:00
Lennart Poettering 330f899079 load-fragment: downgrade log messages we ignore to LOG_WARNING
We typically don't log above LOG_WARNING about issues we then go on to
ignore. Do so here, too
2020-07-16 14:58:05 +09:00
Lennart Poettering 89a5385fb7 mountpoint-util: fix error handling 2020-07-16 14:56:40 +09:00
Yu Watanabe f766d9af38 network: dhcp4: add two warnings 2020-07-16 10:54:16 +09:00
Yu Watanabe 153cf04139 network: dhcp4: fix another race with SendDecline=yes
If the SD_IPV4ACD_EVENT_BIND event happens before all routes are
assigned, then the link stuck in configuring state.
2020-07-16 10:54:08 +09:00
Yu Watanabe 75be72d139 network: dhcp4: also release old lease in dhcp_lease_lost()
The lease lost may happen during renewing address. If it happens,
assertion hits in dhcp4_release_old_lease().
2020-07-16 10:51:46 +09:00
Lennart Poettering 8d5bb13d78 core: fix invalid assertion
We miscounted here, and would hit an assert once too early.
2020-07-16 09:13:04 +09:00
Christian Göttsche aeba8dd523 network: fix typo 2020-07-16 08:45:42 +09:00
Zbigniew Jędrzejewski-Szmek 95b29f3267
Merge pull request #16396 from yuwata/network-configured-flag
network: about xxx_configured flags
2020-07-15 15:45:38 +02:00
Zbigniew Jędrzejewski-Szmek b8ff0663e8
Merge pull request #16468 from keszybz/two-unrelated-patches
Two unrelated patches
2020-07-15 13:40:22 +02:00
Yu Watanabe 43bf28741f network: drop doubled white space 2020-07-15 17:15:25 +09:00
Yu Watanabe 93b0b88c3a network: free address when it is removed 2020-07-15 17:15:25 +09:00
Yu Watanabe 6906794dd1 network: dhcp4: do not assign new address before old one is not removed
If DHCP4 client lost a lease, and then soon acquire new lease, then
the removal of the old address may not be completed. If that happens,
and the new and old addresses are the same, then the new address will be
considered as a foreign address. Such a situation can occur when the
DHCP4 server is restarted.

This makes networkd wait for the removal of the old address when a new
lease is acquired.

This also makes the link in configuring state when renewing address.
2020-07-15 17:15:25 +09:00
Yu Watanabe 5d976f5f64 network: do not call link_check_ready() in link_request_set_routing_policy_rule()
It will be called in link_request_set_nexthop() or serveral handlers().
2020-07-15 17:15:25 +09:00
Yu Watanabe 0c816fcc7b network: make link_request_set_nexthop() called from link_request_set_routes() or route_handler()
Then we can drop static_routes_ready() flag.
2020-07-15 17:15:25 +09:00
Yu Watanabe 659ad3a0af network: do not make link in configured state when no address is assigned
When DHCP6 and RA are enabled, and RA does not provide any addresses,
then link may become configured state even if no address is assigned,
due to the time-lag between RA completion and DHCP reply.
This makes if DHCP is explicitly enabled, then link must have at least
one valid address to be in the configured state.
2020-07-15 17:15:25 +09:00
Yu Watanabe d98c546dac network: ndisc: split ndisc_configured flag into for addresses and routes 2020-07-15 17:15:25 +09:00
Yu Watanabe 01c344bdd4 network: ndisc: do not ignore remaining addresses
Follow-up for c24c83dc67.
2020-07-15 17:15:25 +09:00
Yu Watanabe 39373cb984 network: add debugging log why link is not in configured state yet 2020-07-15 17:15:16 +09:00
Yu Watanabe eb01a2dfb1 network: make link_request_set_nexthop() static 2020-07-15 17:14:30 +09:00
Yu Watanabe a4623f84ed network: add a debugging log 2020-07-15 17:14:30 +09:00
Yu Watanabe feb596b5c3 network: include error code in the log message 2020-07-15 17:14:30 +09:00
Yu Watanabe 2a877f4560 network: set dhcp6_xxx_configured flag after routes/addresses are assigned 2020-07-15 17:14:30 +09:00
Lennart Poettering ee5c1311ee logs: when embedding catalog info in log output use a dash of color and unicode
let's separate things out a bit, to make it easier to discern log output
and catalog data.

catalog data is now colored green (which is a color we don't use for log
data currently), and prefixed with a block shade.
2020-07-15 09:32:03 +02:00
Zbigniew Jędrzejewski-Szmek a996ead6a2
Merge pull request #16398 from poettering/machined-varlink
machined: move UID/GID resolution logic to userdb, i.e. from nss-mymachines to nss-systemd
2020-07-15 09:24:49 +02:00
Filipe Brandenburger 26698337f3 timer: Adjust calendar timers based on monotonic timer instead of realtime
When the RTC time at boot is off in the future by a few days, OnCalendar=
timers will be scheduled based on the time at boot. But if the time has been
adjusted since boot, the timers will end up scheduled way in the future, which
may cause them not to fire as shortly or often as expected.

Update the logic so that the time will be adjusted based on monotonic time.
We do that by calculating the adjusted manager startup realtime from the
monotonic time stored at that time, by comparing that time with the realtime
and monotonic time of the current time.

Added a test case to validate this works as expected. The test case creates a
QEMU virtual machine with the clock 3 days in the future. Then we adjust the
clock back 3 days, and test creating a timer with an OnCalendar= for every 15
minutes. We also check the manager startup timestamp from both `systemd-analyze
dump` and from D-Bus.

Test output without the corresponding code changes that fix the issue:

  Timer elapse outside of the expected 20 minute window.
    next_elapsed=1594686119
    now=1594426921
    time_delta=259198

With the code changes in, the test passes as expected.
2020-07-15 09:23:09 +02:00
Zbigniew Jędrzejewski-Szmek 76830e2500
Merge pull request #16462 from keszybz/rpm-macro-warnings
Emit better errors for rpm macro misuse
2020-07-15 08:56:28 +02:00
Zbigniew Jędrzejewski-Szmek b56a877ef8 test-fs-util: use log_info instead of printf
The test is failing in koji, and the line from printf() does not end up
in the logs for some reason. log_info() works fine, so let's just use
that here too.
2020-07-14 22:18:38 +02:00
Zbigniew Jędrzejewski-Szmek 6cdc429454
Merge pull request #16340 from keszybz/var-tmp-readonly
Create ro private /var/tmp dir when /var/tmp is read-only
2020-07-14 19:59:48 +02:00
Zbigniew Jędrzejewski-Szmek 56a13a495c pid1: create ro private tmp dirs when /tmp or /var/tmp is read-only
Read-only /var/tmp is more likely, because it's backed by a real device. /tmp
is (by default) backed by tmpfs, but it doesn't have to be. In both cases the
same consideration applies.

If we boot with read-only /var/tmp, any unit with PrivateTmp=yes would fail
because we cannot create the subdir under /var/tmp to mount the private directory.
But many services actually don't require /var/tmp (either because they only use
it occasionally, or because they only use /tmp, or even because they don't use the
temporary directories at all, and PrivateTmp=yes is used to isolate them from
the rest of the system).

To handle both cases let's create a read-only directory under /run/systemd and
mount it as the private /tmp or /var/tmp. (Read-only to not fool the service into
dumping too much data in /run.)

$ sudo systemd-run -t -p PrivateTmp=yes bash
Running as unit: run-u14.service
Press ^] three times within 1s to disconnect TTY.
[root@workstation /]# ls -l /tmp/
total 0
[root@workstation /]# ls -l /var/tmp/
total 0
[root@workstation /]# touch /tmp/f
[root@workstation /]# touch /var/tmp/f
touch: cannot touch '/var/tmp/f': Read-only file system

This commit has more changes than I like to put in one commit, but it's touching all
the same paths so it's hard to split.
exec_runtime_make() was using the wrong cleanup function, so the directory would be
left behind on error.
2020-07-14 19:47:15 +02:00
Zbigniew Jędrzejewski-Szmek 1061fc1c17 rpm: include macro name in errors for two args macros too 2020-07-14 19:22:42 +02:00
Zbigniew Jędrzejewski-Szmek 281014b73e rpm: adjust various macros to print macro name in the error message
Based on initial patch by Jan Engelhardt <jengelh@inai.de>.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856122.
2020-07-14 19:21:12 +02:00
Zbigniew Jędrzejewski-Szmek 8800df5f71
Merge pull request #16430 from mikhailnov/fix-rpm-create-package-macros
Fix RPM *_create_package macros
2020-07-14 19:02:09 +02:00
Lennart Poettering 38ccb55731 nss-mymachines: drop support for UID/GID resolving
Now that we make the user/group name resolving available via userdb and
thus nss-systemd, we do not need the UID/GID resolving support in
nss-mymachines anymore. Let's drop it hence.

We keep the module around, since besides UID/GID resolving it also does
hostname resolving, which we care about. (One of those days we should
replace that by some Varlink logic between
nss-resolve/systemd-resolved.service too)

The hooks are kept in the NSS module, but they do not resolve anything
anymore, in order to keep compat at a maximum.
2020-07-14 17:08:12 +02:00
Lennart Poettering 4751364e76 machined: implement user/group lookup varlink API in machined too
Let's natively support our own API in machined too.

This allows us to remove half of nss-mymachines in a later commit.
2020-07-14 17:06:23 +02:00
Lennart Poettering 74d1b7d2ad machined: refactor UID/GID machine translation
Let's move the heavy lifting out of the bus call implemntations, and
into generic code.

This allows us to expose them easily via Varlink too in a later commit.
2020-07-14 17:06:23 +02:00
Lennart Poettering a07f18cd30 process-util: make sure procfs_file_alloca() works for non-literal field names too 2020-07-14 17:06:23 +02:00
Lennart Poettering 56870d324b docs: permit user/group services that do not support enumeration
sssd people don't like enumeration and for some other cases it's not
nice to support either, in particular when synthesizing records for
container/userns UID/GID ranges.

Hence, let's make enumeration optional.
2020-07-14 16:44:52 +02:00
Lennart Poettering 08ef688656 analyze: make testing ConditionPathExistsGlob= work
Fixes: #16439
Alternative-To: #16440
2020-07-14 14:59:18 +02:00
Lennart Poettering 77ee1783eb udevadm: beef up deprecation log warning
Let's add a catalog entry explaining further details.

Most importantly though: talk to PID 1 directly, via the private D-Bus
socket, so that this actually works correctly during early boot, where
D-Bus is not around.
2020-07-14 14:57:19 +02:00
Zbigniew Jędrzejewski-Szmek 46072ae35a repart: include more relevant information in the warning message, fix test
The test would always fail with a long uname. In F33 this is right
now "5.8.0-0.rc2.20200622git625d3449788f.1.fc33.x86_64" which caused the
test to always fail.
2020-07-13 03:43:26 +09:00
Yu Watanabe 5553041a62
Merge pull request #16435 from gaoyi1988/master
fix multi matches when use "||"
2020-07-12 21:46:22 +09:00
Zbigniew Jędrzejewski-Szmek ddcdcac519
Merge pull request #16432 from cgzones/selinux_err_fix
SELlinux followup error/logging fixes
2020-07-12 11:55:44 +02:00
gaoyi 1e67a9c2cd udev: specify the end of value
NULSTR_FOREACH may read the illegal match

Signed-off-by: gaoyi <ymuemc@163.com>
2020-07-12 03:24:42 -04:00
fangxiuning d67b1d18fc bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
Christian Göttsche f2df56bfea namespace: unify logging in mount_tmpfs
Fixes: abad72be4d
Follow up: #16426
2020-07-11 21:25:39 +02:00
Christian Göttsche db06c162e8 shared: fix error handling in make_inaccessible_nodes
_label wrappers return -errno on failure instead of returning -1 and
setting global errno.

Fixes: 8d9cbd809d
Follow up: #16426
2020-07-11 21:25:39 +02:00
Mikhail Novosyolov 3e6e0856cd rpm: avoid hiding errors and output in *_create_package macros
Commit b0ca726585 "rpm: avoid hiding errors from systemd commands" remove hiding errors and output
for other macros, but did not do that for %sysusers_create_package and %tmpfiles_create_package.

This change syncs their behaviour with %sysusers_create and %tmpfiles_create

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2020-07-11 17:20:23 +03:00
Mikhail Novosyolov 93406fd379 rpm: avoid odd symbols in EOF indicator
The last line in this macros was actually "SYSTEMD_INLINE_EOF " with a space at the end,
but the shell was instructed to look for a line without space.

Macros %sysusers_create_inline and %tmpfiles_create_inline did not have this mistake.

An example:
[root@rosa-2019 bind-server]# cat /etc/passwd | grep named
[root@rosa-2019 bind-server]# cat /tmp/bs
systemd-sysusers --replace=/usr/lib/sysusers.d/named.conf - <<SYSTEMD_INLINE_EOF >/dev/null 2>&1 || :
u named - "BIND DNS Server" /var/lib/named
g named - -
m named named
SYSTEMD_INLINE_EOF
[root@rosa-2019 bind-server]# sh /tmp/bs
/tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF')
[root@rosa-2019 bind-server]# bash /tmp/bs
/tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF')
[root@rosa-2019 bind-server]# bash --version
GNU bash, version 5.0.17(1)-release (x86_64-openmandriva-linux-gnu)

The user and group named were NOT created!

Now I remove the trailing space after "SYSTEMD_INLINE_EOF" and rerun:
[root@rosa-2019 bind-server]# sh /tmp/bs
[root@rosa-2019 bind-server]# tail -n 1 /etc/group
named485:named
[root@rosa-2019 bind-server]#

The user and group have been created correctly.

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2020-07-11 17:20:16 +03:00
Zbigniew Jędrzejewski-Szmek b159831b61
Merge pull request #16424 from keszybz/cap-bpf-compat
Handle new capabilities gracefully
2020-07-11 13:35:34 +02:00
Christian Göttsche abad72be4d namespace: fix MAC labels of TemporaryFileSystem=
Reproducible with:
  systemd-run -p TemporaryFileSystem=/root -t /bin/bash
    ls -dZ /root

Prior:
  root:object_r:tmpfs_t:s0 /root
Past:
  root:object_r:user_home_dir_t:s0 /root
2020-07-11 00:09:05 +02:00
Christian Göttsche 8d9cbd809d selinux: create standard user-runtime nodes with default context
Currently systemd-user-runtime-dir does not create the files in
/run/user/$UID/systemd/inaccessible with the default SELinux label.
The user and role part of these labels should be based on the user
related to $UID and not based on the process context of
systemd-user-runtime-dir.

Since v246-rc1 (9664be199a) /run/user/$UID/systemd is also created by
systemd-user-runtime-dir and should also be created with the default
SELinux context.
2020-07-10 21:55:13 +02:00
Christian Göttsche 7a3e4dc38b basic: add helper function mknod_label() 2020-07-10 21:55:13 +02:00
Zbigniew Jędrzejewski-Szmek 5700780389 basic/cap-list: reduce scope of variables 2020-07-10 16:55:24 +02:00
Zbigniew Jędrzejewski-Szmek 864a25d99b basic/capability-util: let cap_last_cap() return unsigned integer
We never return anything higher than 63, so using "long unsigned"
as the type only confused the reader. (We can still use "long unsigned"
and safe_atolu() to parse the kernel file.)
2020-07-10 16:55:24 +02:00
Zbigniew Jędrzejewski-Szmek 417770f303 basic/cap-list: parse/print numerical capabilities
We would refuse to print capabilities which were didn't have a name
for. The kernel adds new capabilities from time to time, most recently
cap_bpf. 'systmectl show -p CapabilityBoundingSet ...' would fail with
"Failed to parse bus message: Invalid argument" because
capability_set_to_string_alloc() would fail with -EINVAL. So let's
print such capabilities in hexadecimal:

CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search
  cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap
  cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin
  cap_net_raw cap_ipc_lock cap_ipc_owner 0x10 0x11 0x12 0x13 0x14 0x15 0x16
  0x17 0x18 0x19 0x1a ...

For symmetry, also allow capabilities that we don't know to be specified.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1853736.
2020-07-10 16:55:24 +02:00
fangxiuning 76fb53c94a install: fix wrong data type 2020-07-10 10:05:39 +02:00
Zbigniew Jędrzejewski-Szmek a127c6208f userdb: fix dlopen call
The call would always fail with:
systemd-userwork[780]: Failed to dlopen(libnss_systemd.so.2), ignoring: /usr/lib64libnss_systemd.so.2: cannot open shared object file: No such file or directory
2020-07-09 07:55:56 +02:00
Zbigniew Jędrzejewski-Szmek 55aacd502b
Merge pull request #15891 from bluca/host_os_release
Container Interface: expose the host's os-release metadata to nspawn and portable guests
2020-07-08 23:52:13 +02:00
Zbigniew Jędrzejewski-Szmek 48c190822b Merge pull request #16405 from sipraga/master 2020-07-08 22:32:04 +02:00
Zbigniew Jędrzejewski-Szmek 02b0109af5
Merge pull request #15955 from anitazha/nullorempty
core: check null_or_empty_path for masked units instead of /dev/null
2020-07-08 22:18:17 +02:00
Alvin Šipraga 0d0de133f0 network: add support for MACVLAN source mode
Add support for creating a MACVLAN interface in "source" mode by
specifying Mode=source in the [MACVLAN] section of a .netdev file.

A list of allowed MAC addresses for the corresponding MACVLAN can also
be specified with the SourceMACAddress= option of the [MACVLAN] section.

An example .netdev file:

    [NetDev]
    Name=macvlan0
    Kind=macvlan
    MACAddress=02:DE:AD:BE:EF:00

    [MACVLAN]
    Mode=source
    SourceMACAddress=02:AB:AB:AB:AB:01 02:CD:CD:CD:CD:01
    SourceMACAddress=02:EF:EF:EF:EF:01

The same keys can also be specified in [MACVTAP] for MACVTAP kinds of
interfaces, with the same semantics.
2020-07-08 18:01:52 +02:00
Zbigniew Jędrzejewski-Szmek cbc056c819 core: wrap some long lines and other formatting changes 2020-07-08 16:37:23 +02:00
Lennart Poettering 24e2494407
Merge pull request #16385 from JackFangXN/master
table add table_log_xx_error()
2020-07-08 12:12:29 +02:00
Yu Watanabe 43b24a0716 sd-device: use log_device_debug_errno() 2020-07-08 12:11:19 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
Yu Watanabe c253a95bca
Merge pull request #16379 from yuwata/network-dhcp6-delegated-prefix-address-handler
network: fix assertion in assigning dhcp6 delegated prefix
2020-07-08 10:22:08 +09:00
Zbigniew Jędrzejewski-Szmek 2e2f6a01a0
Merge pull request #16143 from fbuihuu/fstab-generator-fix
fstab-generator: make sure explicit deps configured via mount options apply to .mount, not .automount unit
2020-07-07 20:06:18 +02:00
Alan Perry 5dc60faae5 add error message when bind mount src missing 2020-07-07 20:04:19 +02:00
Yu Watanabe 3650173fec network: make address_handler() static 2020-07-07 19:48:38 +02:00
Yu Watanabe a211ff4b84 network: introduce own address handler for dhcp6 delegated prefix
Fixes #16365.
2020-07-07 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek 2b0bf3ccf8
Merge pull request #16301 from poettering/firstboot-image
Add --image= switch to firstboot, similar to --root= but with support for operating on disk image
2020-07-07 19:44:12 +02:00