Commit graph

48835 commits

Author SHA1 Message Date
Yu Watanabe 8d40961c3c meson: slightly disentangle code dependencies
But, still sd-id128 is used in src/basic.
2021-01-19 07:06:32 +09:00
Yu Watanabe b61016f207 meson: sort inclusion of meson.build files in subdirectories 2021-01-19 07:06:32 +09:00
Yu Watanabe 529642936b meson: move libjournal_core definition to src/journal/meson.build 2021-01-19 07:06:32 +09:00
Yu Watanabe 3976f372ae meson: move libudev related definitions to src/libudev/meson.build
Also, this makes libudev.so built in build directory.
2021-01-19 07:06:32 +09:00
Yu Watanabe f6fe732ff3 meson: move and gather find_program() 2021-01-19 07:06:32 +09:00
Yu Watanabe 73e994f291 meson: drop redundant source files in executable() 2021-01-19 07:06:32 +09:00
Yu Watanabe 0275e918af meson: move source file list for systemd-xdg-autostart-generator and its tests 2021-01-19 07:06:32 +09:00
Yu Watanabe f98df767e1 meson: move source file list for busctl 2021-01-19 07:06:32 +09:00
Yu Watanabe 2ad279cfa4 meson: move source file list for systemd-cryptenroll 2021-01-19 07:06:32 +09:00
Yu Watanabe b4d1892aac meson: move source file list for systemd-cryptsetup 2021-01-19 07:06:32 +09:00
Yu Watanabe 18b49798a6 meson: show standalone-binaries setting in the summary 2021-01-19 07:06:32 +09:00
Yu Watanabe d33b0daa6c meson: use condition argument in test definition 2021-01-19 07:06:32 +09:00
Yu Watanabe cbaaf7b9dd meson: drop redundant directory specification in additional source files 2021-01-19 07:06:32 +09:00
Yu Watanabe c35125732f meson: move definition of systemctl source files 2021-01-19 07:06:29 +09:00
Yu Watanabe f5a5284ea1 meson: introduce libtimesyncd_core library 2021-01-19 07:04:19 +09:00
Yu Watanabe b09f01463a meson: enable several tests even if the relevant features are disabled 2021-01-19 07:04:19 +09:00
Yu Watanabe a28c0617de meson: fix indentation 2021-01-19 07:04:19 +09:00
Yu Watanabe 4fc47fa82a meson: drop unnecessary variable declarations 2021-01-19 07:04:19 +09:00
Yu Watanabe 7087e4729f meson: drop unnecessary loop 2021-01-19 07:04:19 +09:00
Yu Watanabe 6969a671d9 test: drop bus-util.h from sd-bus
To drop src/shared from include directories to build libsystemd.so later.
2021-01-19 07:04:19 +09:00
Yu Watanabe 0159eee04a efi: create symbolic link to efi/loader-feature.h
To drop src/boot/efi from include directories for binaries later.
2021-01-19 07:04:19 +09:00
Yu Watanabe c11e5f43d2 util: move several DNS related definitions to src/basic/dns-def.h
DNS_HOSTNAME_MAX is used by sd-resolve, but it was defined in
src/shared/dns-domain.h. The library libsystemd should be independent
of source files under src/shared.
2021-01-19 07:04:19 +09:00
Yu Watanabe af182ae1dc util: move unit-file.[ch] to src/basic
As basic/path-lookup.[ch] depend on them.
2021-01-19 07:04:19 +09:00
Yu Watanabe 22eadc289b util: move parse_syscall_and_errno() to seccomp-util.c
This makes parse-util.c independent of seccomp-util.c, which is located
in src/shared.
2021-01-19 07:04:19 +09:00
Yu Watanabe 09f7c7c668 fuzzers: move several fuzzers 2021-01-19 07:04:19 +09:00
Yu Watanabe c5abccfa58 meson: fix indentation 2021-01-19 07:04:19 +09:00
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
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
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
Lennart Poettering 33295214fa update TODO 2021-01-18 21:05:32 +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