1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00
Commit Graph

48986 Commits

Author SHA1 Message Date
Yu Watanabe
5acb3cabd1 meson: make the second and third elements of tests or fuzzers optional
Then, we can shorten many test definitions.
2021-01-19 07:04:19 +09:00
Yu Watanabe
9aeec01e77 test: move test-umount.c to src/shutdown
Then, we can drop src/shutdown from include directories later.
2021-01-19 07:04:19 +09:00
Yu Watanabe
bac11cd667 core: move several source files to src/shared
As, the files are used by many executables, fstab-generator, remount-fs,
machine-id-setup, and etc.
With this change, the total size of the relevant executables and
libshared slightly decreases.

Before:
```
$ ll systemd-fstab-generator systemd-remount-fs systemd-machine-id-setup systemd-shutdown systemd-nspawn systemd src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 7577800 Jan  5 13:35 src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 4608360 Jan  5 13:35 systemd
-rwxrwxr-x 1 watanabe watanabe  117240 Jan  5 13:35 systemd-fstab-generator
-rwxrwxr-x 1 watanabe watanabe   61576 Jan  5 13:35 systemd-machine-id-setup
-rwxrwxr-x 1 watanabe watanabe  853080 Jan  5 13:35 systemd-nspawn
-rwxrwxr-x 1 watanabe watanabe   70600 Jan  5 13:35 systemd-remount-fs
-rwxrwxr-x 1 watanabe watanabe  172624 Jan  5 13:35 systemd-shutdown
```
Total: 13461280

After:
```
$ ll systemd-fstab-generator systemd-remount-fs systemd-machine-id-setup systemd-shutdown systemd-nspawn systemd src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 7658336 Jan  5 13:32 src/shared/libsystemd-shared-247.so
-rwxrwxr-x 1 watanabe watanabe 4523560 Jan  5 13:32 systemd
-rwxrwxr-x 1 watanabe watanabe   78288 Jan  5 13:32 systemd-fstab-generator
-rwxrwxr-x 1 watanabe watanabe   30984 Jan  5 13:32 systemd-machine-id-setup
-rwxrwxr-x 1 watanabe watanabe  840384 Jan  5 13:32 systemd-nspawn
-rwxrwxr-x 1 watanabe watanabe   39104 Jan  5 13:32 systemd-remount-fs
-rwxrwxr-x 1 watanabe watanabe  117160 Jan  5 13:32 systemd-shutdown
```
Total: 13287816
2021-01-19 07:04:19 +09:00
Yu Watanabe
772e0a76f3 test: rewrite test-sd-device-thread.c to depend only on libsystemd
Similarly, this makes test-udev-device-thread.c depend only on libudev.
2021-01-19 07:04:19 +09:00
Yu Watanabe
261fc53b99 test: move tests for libudev into src/libudev 2021-01-19 07:04:19 +09:00
Yu Watanabe
cf2423503b time-wait-sync: move time-wait-sync.c -> src/timesync/wait-sync.c
As wait-online is located under src/network.
2021-01-19 07:04:19 +09:00
Yu Watanabe
e2e7888191 xdg: move tests for xdg-autostart-generator
Then, we can drop src/xdg-autostart-generator from include directories
later.
2021-01-19 07:04:19 +09:00
Yu Watanabe
a79e17234d meson.build: drop unused variable 2021-01-19 07:04:19 +09:00
Yu Watanabe
0703d2f6c4 test: move test-systemd-tmpfiles.py from src/test to test
As the other test scripts, e.g. test-sysusers.sh, are located under
test rather than src/test.
2021-01-19 07:04:19 +09:00
Yu Watanabe
0f46548deb login: move src/login/logind-acl.[ch] -> src/shared/devnode-acl.[ch]
The files are used by logind and udevd. And the functions in the files
are not specific to logind, and quite general enough to move to
libshared.
2021-01-19 07:04:19 +09:00
Yu Watanabe
100fd93f55 tmpfiles: move offline-passwd.[ch] to src/tmpfiles
offline-passwd.[ch] are only used by systemd-tmpfiles and the relevant
test. And are not included in libshared. So, it is not suitable to
located under src/shared.
2021-01-19 07:04:18 +09:00
Yu Watanabe
99b9f8fddd sd-journal: move source files for sd-journal to src/libsystemd/sd-journal 2021-01-19 07:04:18 +09:00
Yu Watanabe
b9b442a0cc analyze: resolve executable path if it is relative
Fixes #18252.
2021-01-19 06:39:25 +09:00
Yu Watanabe
ece852c845 path-util: also check absolute path is a directory or not in find_executable() 2021-01-19 06:39:07 +09:00
Luca Boccassi
4db4792a93
Merge pull request #17228 from bluca/bind_path_runtime
core: add systemctl and DBUS method to bind mount new paths without service restart
2021-01-18 21:22:57 +00:00
Lucas Werkmeister
e372584067 man: document effects of concurrent truncation
Co-authored-by: Lennart Poettering <lennart@poettering.net>
2021-01-18 21:59:19 +01:00
Susant Sahani
df24a407a5 import: use - hashmap_ensure_put 2021-01-18 21:53:28 +01:00
Susant Sahani
630837065e core: execute - use hashmap_ensure_put 2021-01-18 21:53:25 +01:00
Susant Sahani
9b059ee022 core: dbus - use set_ensure_put 2021-01-18 21:53:22 +01:00
Susant Sahani
02288f3ef8 network: sd-dhcp6-client - use ordered_hashmap_ensure_put 2021-01-18 21:53:19 +01:00
Susant Sahani
5088e5e79f share: bus-unit-procs - use hashmap_ensure_put 2021-01-18 21:53:16 +01:00
Susant Sahani
ae4ad9df48 resolve: link - use hashmap_ensure_put 2021-01-18 21:53:13 +01:00
Susant Sahani
b5bcd73895 remount-fs: Use hashmap_ensure_put 2021-01-18 21:53:11 +01:00
Susant Sahani
acf56b72f2 core: transaction - use hashmap_ensure_put 2021-01-18 21:52:58 +01:00
Zbigniew Jędrzejewski-Szmek
4ea8b443de resolved: fix use-after-free with queries hitting the cache
When dns_transaction_complete() manages to resolve a query, it invalidates the
query candidate object. It shall not be accessed afterwards.

We have the following chain of calls:
dns_query_candidate_go → dns_transaction_go → dns_transaction_prepare → dns_cache_lookup (success: 1)
                                                                      → dns_transaction_complete
After returning back to dns_query_candidate_go(), we'd attempt to continue
iteration over the list of transactions attached to the query candidate,
accessing already freed (and overwritten) memory:

(gdb) bt
0  0x00007f637297cf47 in hashmap_iterate_entry (i=0x7ffe7e15cc90, h=0x706f746b73656465) at ../src/basic/hashmap.c:703
1  _hashmap_iterate (h=0x706f746b73656465, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88,
    key=key@entry=0x0) at ../src/basic/hashmap.c:712
2  0x00007f637297d01b in set_iterate (s=<optimized out>, i=i@entry=0x7ffe7e15cc90, value=value@entry=0x7ffe7e15cc88)
    at ../src/basic/hashmap.c:733
hence we crash

3  0x0000557bc99eb80f in dns_query_candidate_go (c=c@entry=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:139
...but c is not valid here in the second iteration of the loop

4  0x0000557bc99eb720 in dns_query_candidate_notify (c=0x557bcaf86890) at ../src/resolve/resolved-dns-query.c:271
c was valid here at entry...

5  0x0000557bc99efe28 in dns_transaction_complete (t=0x557bcac072f0, state=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:350
t is a valid transaction (11481 in the backtrace below)

6  0x0000557bc99f1efb in dns_transaction_process_reply (t=0x557bcac072f0, p=<optimized out>)
    at ../src/resolve/resolved-dns-transaction.c:1171
7  0x0000557bc99f2d41 in on_dns_packet (s=<optimized out>, fd=<optimized out>, revents=<optimized out>,
    userdata=0x557bcac072f0) at ../src/resolve/resolved-dns-transaction.c:1223
8  0x00007f6372a25217 in source_dispatch (s=s@entry=0x557bcb162c50) at ../src/libsystemd/sd-event/sd-event.c:3181
9  0x00007f6372a254fd in sd_event_dispatch (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3620
10 0x00007f6372a267c8 in sd_event_run (e=e@entry=0x557bcb15b050, timeout=timeout@entry=18446744073709551615)
    at ../src/libsystemd/sd-event/sd-event.c:3678
11 0x00007f6372a269ef in sd_event_loop (e=0x557bcb15b050) at ../src/libsystemd/sd-event/sd-event.c:3700
12 0x0000557bc99ddc14 in run (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:92
13 0x0000557bc99d260a in main (argc=<optimized out>, argv=<optimized out>) at ../src/resolve/resolved.c:99

xxx.name.net systemd-resolved[31705]: Got message type=method_call sender=:1.3644 destination=org.freedesktop.resolve1 path=/org/freedesktop/resolve1 interface=org.freedesktop.resolve1.Manager member=ResolveHostname cookie=2 reply_cookie=0 signature=isit error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: idn2_lookup_u8: xxx → xxx
xxx.name.net systemd-resolved[31705]: Looking up RR for xxx IN A.
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=1102 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetNameOwner cookie=1103 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1103 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Cache miss for xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> scope dns on enp42s0/*.
xxx.name.net systemd-resolved[31705]: Using feature level UDP for transaction 11481.
xxx.name.net systemd-resolved[31705]: Using DNS server 192.168.1.1 for transaction 11481.
xxx.name.net systemd-resolved[31705]: Sending query packet with id 11481 of size 35.
xxx.name.net systemd-resolved[31705]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.3324 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1102 signature= error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Match type='signal',sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0=':1.3644' successfully installed.
xxx.name.net systemd-resolved[31705]: Processing incoming packet on transaction 11481 (rcode=NXDOMAIN).
xxx.name.net systemd-resolved[31705]: Not caching negative entry without a SOA record: xxx.name.net IN A
xxx.name.net systemd-resolved[31705]: Transaction 11481 for <xxx.name.net IN A> on scope dns on enp42s0/* now complete with <rcode-failure> from network (unsigned).
xxx.name.net systemd-resolved[31705]: Positive cache hit for xxx.lan IN A
xxx.name.net systemd-resolved[31705]: Transaction 64364 for <xxx.lan IN A> on scope dns on enp42s0/* now complete with <success> from cache (unsigned).
xxx.name.net systemd-resolved[31705]: Sent message type=method_return sender=n/a destination=:1.3644 path=n/a interface=n/a member=n/a cookie=1104 reply_cookie=2 signature=a(iiay)st error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=1105 reply_cookie=0 signature=s error-name=n/a error-message=n/a
xxx.name.net systemd-resolved[31705]: Freeing transaction 64364.
xxx.name.net systemd[1]: systemd-resolved.service: Main process exited, code=dumped, status=11/SEGV
xxx.name.net systemd[1]: systemd-resolved.service: Failed with result 'core-dump'.

Fixes #16168, https://bugzilla.redhat.com/show_bug.cgi?id=1895937.
2021-01-18 21:45:03 +01:00
Susant Sahani
f334debabb sysusers: use ordered_hashmap_ensure_put 2021-01-18 21:37:39 +01:00
Susant Sahani
1b5d349788 sd-netlink: use hashmap_ensure_put 2021-01-18 21:35:31 +01:00
Susant Sahani
1d2d1654c6 varlink: use hashmap_ensure_put 2021-01-18 21:35:28 +01:00
Susant Sahani
ee9ead76bb network: wait-online - add a assert 2021-01-18 21:35:24 +01:00
Susant Sahani
3f70f938a0 network: wait-online - use hashmap_ensure_put 2021-01-18 21:35:20 +01:00
Susant Sahani
b2cb2e82c8 network: radv - use hashmap_ensure_put 2021-01-18 21:34:46 +01:00
Susant Sahani
0b83974b91 install: use ordered_hashmap_ensure_put 2021-01-18 21:12:32 +01:00
Susant Sahani
b5b9b0e7ba network: Use TAKE_PTR 2021-01-18 21:11:31 +01:00
Susant Sahani
9fa3e794ac network: network -- use ordered_hashmap_ensure_put 2021-01-18 21:11:01 +01:00
Susant Sahani
28d9587be5 network: address - use ordered_hashmap_ensure_put 2021-01-18 21:09:27 +01:00
Lennart Poettering
33295214fa update TODO 2021-01-18 21:05:32 +01:00
Susant Sahani
9d6bb21f37 network: macsec - use ordered_hashmap_ensure_put 2021-01-18 20:16:50 +01:00
Luca Boccassi
fa7a3cd00e test: run strace with -f and copy log out 2021-01-18 17:24:05 +00:00
Luca Boccassi
a9d34376e6 test: skip missing optional libraries in image install
Not all optional libraries might be available on developers machines,
so log and skip.
Also some pkg-config files are broken (eg: tss2 on Debian Stable) so
skip if the required variables are missing, and improve logs.
2021-01-18 17:24:05 +00:00
Luca Boccassi
5e8deb94c6 core: add DBUS method to bind mount new nodes without service restart
Allow to setup new bind mounts for a service at runtime (via either
DBUS or a new 'systemctl bind' verb) with a new helper that forks into
the unit's mount namespace.
Add a new integration test to cover this.

Useful for zero-downtime addition to services that are running inside
mount namespaces, especially when using RootImage/RootDirectory.

If a service runs with a read-only root, a tmpfs is added on /run
to ensure we can create the airlock directory for incoming mounts
under /run/host/incoming.
2021-01-18 17:24:05 +00:00
Luca Boccassi
94293d65cd MountAPIVFS: always mount a tmpfs on /run
We need a writable /run for most operations, but in case a read-only
RootImage (or similar) is used, by default there's no additional
tmpfs mount on /run. Change this behaviour and document it.
2021-01-18 17:24:05 +00:00
Luca Boccassi
f7c18d3de8 machine: use file descriptor when chasing bind mount sources
Allows to always operate on pinned inodes, rather than paths, so that
races are less likely
2021-01-18 17:24:05 +00:00
Luca Boccassi
98f654fdea machine: enter target PID namespace when adding a live mount
machinectl fails since 21935150a0 as it's now
mounting onto a file descriptor in a target namespace, without joining the
target's PID namespace.
Note that it's not enough to setns CLONE_NEWPID, but a double-fork is required
as well, as implemented by namespace_fork().

Add a test case to TEST-13-NSPAWN to cover this use case.
2021-01-18 17:24:05 +00:00
Luca Boccassi
2338a175fd shared/mount-util: use namespace_fork utils 2021-01-18 17:23:46 +00:00
Luca Boccassi
724e689715 machine: adjust error message to use 'normalized' instead of ../ 2021-01-18 17:23:12 +00:00
Luca Boccassi
6af52c3a45 machine/basic: factor out helper function to add airlocked mount to namespace 2021-01-18 17:23:11 +00:00
moson-mo
2a613b34cc hwdb: Add Logitech MX 518 Legendary mouse
Add Logitech MX 518 Legendary model to hwdb.
2021-01-18 16:49:30 +01:00
Zbigniew Jędrzejewski-Szmek
9dffdb4e3c
Merge pull request #18289 from yuwata/core-load-fragment-cleanups
pid1: several cleanups for conf parsers
2021-01-18 16:48:44 +01:00
Susant Sahani
d1ce835989 network: bond - use ordered_set_ensure_put 2021-01-18 13:00:35 +01:00
Susant Sahani
becee4da44 journal: context - use hashmap_ensure_put 2021-01-18 12:16:34 +01:00