Commit Graph

22348 Commits

Author SHA1 Message Date
Lennart Poettering 334415b16e
Merge pull request #10094 from keszybz/wants-loading
Fix bogus fragment paths in units in .wants/.requires
2018-10-05 17:36:31 +02:00
Lennart Poettering 083d27b654
Merge pull request #10152 from yuwata/udev-use-extract
udev: small cleanups
2018-10-05 17:11:43 +02:00
Patrik Flykt aabcb75409 networkd-link: Don't start a DHCPv6 informational exchange automatically
When a link is configured, wait until there is a Router Advertisement before
attempting to start DHCPv6. The intended DHCPv6 mode will be evaluated in
ndisc_router_handler() in networkd-ndisc.c.
2018-10-05 16:58:06 +02:00
Yu Watanabe 35f2cb2841 sd-resolve: make struct addrinfo defined 2018-10-05 17:09:26 +09:00
Yu Watanabe d6263ee4d5 meson: also run compile tests for not installed systemd headers
Follow-up for b62f900866 (#10277).
2018-10-05 17:08:10 +09:00
Yu Watanabe e913b7988f
test-execute: add a test for systemcall filter (#10273)
This adds a test for issue #9939 which is fixed by
a5404992cc (#9942).
2018-10-05 14:46:30 +09:00
Yu Watanabe 30782b4396 sd-netlink: sort headers and include net/ethernet.h 2018-10-05 14:27:32 +09:00
Thomas Haller b62f900866 dhcp6: don't include internal header "sparse-endian.h" in "sd-dhcp6-client.h"
Arguably, libsystemd-network is (still) entirely internal API.
However there is the aim of maybe exposing it as public API.
For that reason, it cannot include internal headers from
"src/basic/".

Note how files "src/systemd/sd-*.h" don't include any systemd
headers which don't themself have an "sd-" prefix.

Fixes: d89a400ed6
2018-10-04 21:29:35 +02:00
Yu Watanabe b81b9d406d test: fix memleak in test-fs-util
Fixes #10267 and CID#1395997.
2018-10-04 16:24:44 +09:00
Zbigniew Jędrzejewski-Szmek 2796485404 test-fs-util: run all tests on the specified directory
This removes $RENAME_NOREPLACE_DIR and uses a command-line argument instead.
Logging is added, and tests are skipped if we get -EPERM or friends
(which happens on FAT and other filesystems).
2018-10-04 16:18:58 +09:00
Zbigniew Jędrzejewski-Szmek 7158b4b3fc test-fs-util: simplify testdir creation 2018-10-03 13:42:08 +02:00
Zbigniew Jędrzejewski-Szmek 9a21d8b9fd
Merge pull request #10251 from poettering/renameat-racy
rename_noreplace() fallback for file systems where neither RENAME_REPLACE nor link()/unlinkat() is available
2018-10-03 13:37:53 +02:00
Zbigniew Jędrzejewski-Szmek 1ee55f52a8
Merge pull request #10257 from pfl/dhcp6_pd_enable_later_link
DHCP6 PD enable later link
2018-10-03 11:04:41 +02:00
Yu Watanabe b7172f3471 test-execute: also tests under the condition that unshare() is filtered
This is mainly for testing 1beab8b0d0.
2018-10-03 08:33:23 +02:00
Yu Watanabe 84452783b8 dhcp6: check option length before reading values
Fixes oss-fuzz#10746
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746.
2018-10-03 08:49:55 +09:00
Yu Watanabe 9380d34c2a test: add test for sd_device 2018-10-02 23:04:55 +02:00
Joe Hershberger d81186ef4f udev: Allow acpi_index and index to be "0"
0 can be a valid index returned by the BIOS, so allow that by using the
parsing function safe_atolu() to check for errors without excluding the
valid value "0".

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
2018-10-02 22:58:15 +02:00
Patrik Flykt 107523437c networkd-dhcp6: Request prefix delegation for a new link
Request prefix delegation for a new downstream link that is enabled
after any number of upstream DHCPv6 links. Submit the request after
the link has been configured with a link-local address.

If the upstream DHCPv6 client has already been configured to request
prefixes, attempt to re-assign any possible prefixes between the
already existing links and the new one. If no prefixes are yet
acquired, nothing will happen right away and any prefixes will be
distributed after a reply from the DHCPv6 server.

If none of the already existing downstream links have requested
DHCPv6 prefixes to be assigned, enable prefix delegation for each
client and restart them one by one if they are already running. This
causes the DHCPv6 clients to re-acquire addresses and prefixes and
to re-distribute them to all links when receiving an updated
response from their respective DHCPv6 servers. If the DHCPv6 client
in question was not already running, it is set to request prefixes
but not restarted.

When an error occurs while setting or restarting the DHCPv6 client,
log the incident and move over to the next link.

Fixes #9758.
2018-10-02 12:32:46 -06:00
Patrik Flykt 03d4fc2ed2 networkd-dhcp: Rename function and reduce its logging
Rename dhcp6_verify_link() to dhcp6_get_prefix_delegation() in order
to be clearer in what it does. Reduce unnecessary logging.
2018-10-02 12:32:46 -06:00
Zbigniew Jędrzejewski-Szmek 0f0159e313
Merge pull request #10252 from poettering/recv-log-msg-bump
tiny sd-ravd/sd-ndisc logging fixes
2018-10-02 17:56:31 +02:00
Zbigniew Jędrzejewski-Szmek e80ef269a1
Merge pull request #10255 from poettering/hide-new-id128
drop references to "journalctl --new-id128"
2018-10-02 17:54:36 +02:00
Lennart Poettering 29088d374e
Merge pull request #9898 from keszybz/id128
Add a new tool 'systemd-id128'
2018-10-02 17:43:37 +02:00
Lennart Poettering eb74d3b97a
Merge pull request #10249 from keszybz/lgtm-fixes
Fixes for issues found by LGTM
2018-10-02 17:42:55 +02:00
Lennart Poettering b9d016d684 tree-wide: drop all references to "journalctl --new-id128"
Let's advertise "systemd-id128 new" instead.
2018-10-02 16:43:54 +02:00
Lennart Poettering 19a073db9b journalctl: drop --new-id128 from help and man texts
Let's remove redundancy and not advertise "journalctl --new-id128"
anymore, now that we have "systemd-id128 new" in a proper tool.

This allows us to reduce the overly large journalctl command set a bit.

Note that this just removes the --help and man text, the call remains
available for compat reasons.
2018-10-02 16:42:30 +02:00
Lennart Poettering 8eb41f4c08 sd-radv: EAGAIN is not really unexpected, distinguishit from other errors when logging 2018-10-02 16:26:50 +02:00
Lennart Poettering 437524f178 sd-ndisc: generate debug log messages on unexpected errors
We really should make it possible to debug unexpected errors, hence log
something at LOG_DEBUG.
2018-10-02 16:25:54 +02:00
Lennart Poettering fdc2afc102 sd-radv: remove log_radv_warning_errno()
According to our CODING_STYLE our library code should generally not log
beyond LOG_DEBUG. Let's hence get rid of log_radv_warning_errno() and
just use log_radv_errno() instead.
2018-10-02 16:22:54 +02:00
Lennart Poettering 4a5d77615e test: add test case for rename_noreplace() 2018-10-02 16:11:10 +02:00
Lennart Poettering 2f15b6253a fs-util: add racy RENAME_NOREPLACE fallback using access()
Apparently FAT on some recent kernels can't do RENAME_NOREPLACE, and of
course cannot do linkat()/unlinkat() either (as the hard link concept
does not exist on FAT). Add a fallback using an explicit beforehand
faccessat() check. This sucks, but what we can do if the safe operations
are not available?

Fixes: #10063
2018-10-02 16:11:10 +02:00
Lennart Poettering eaa680c09e fileio: fix error propagation in link_tmpfile() 2018-10-02 16:11:10 +02:00
Ronny Chevalier afc1feaeba bus-unit-util: fix parsing of IPAddress{Allow,Deny}
While the config parser correctly handles the case of multiple IPs,
bus_append_cgroup_property was only parsing one IP,
and it would fail with "Failed to parse IP address prefix" when given
a list of IPs.
2018-10-02 15:46:15 +02:00
Lennart Poettering c3281539da
Merge pull request #10246 from keszybz/fuzz-buss
Bus fuzzer
2018-10-02 15:45:21 +02:00
Zbigniew Jędrzejewski-Szmek 91db8ed5b2 journal-upload: add asserts that snprintf does not return an error
LGMT complains:
> The size argument of this snprintf call is derived from its return value,
> which may exceed the size of the buffer and overflow.

Let's make sure that r is non-negative. (This shouldn't occur unless the format
string is borked, so let's just add an assert.)
Then, let's reorder the comparison to avoid the potential overflow.
2018-10-02 15:36:24 +02:00
Zbigniew Jędrzejewski-Szmek 7c3733d5de pid1: remove unnecessary error reassignment
LGTM was complaining:
> Comparison is always true because r >= 0.
2018-10-02 15:36:24 +02:00
Zbigniew Jędrzejewski-Szmek 459500a32c shared/install: avoid overwriting 'r' counter with a partial result
We want to store either the first error or the total number of changes in 'r'.
Instead, we were overwriting this with the return value from
install_info_traverse().

LGTM complained later in the loop that:
> Comparison is always true because r >= 0.
2018-10-02 15:36:24 +02:00
Zbigniew Jędrzejewski-Szmek 87d57be06f Prettify printing of uuids
I know this a bit over the top, but I'm following reviewers' requests.
2018-10-02 15:15:10 +02:00
Zbigniew Jędrzejewski-Szmek 0d1d512f7f systemd-id128: a new tool to print machine/boot/invocation/app-specific ids
The raison d'etre for this program is printing machine-app-specific IDs. We
provide a library function for that, but not a convenient API. We can hardly
ask people to quickly hack their own C programs or call libsystemd through CFFI
in python or another scripting language if they just want to print an ID.

Verb 'new' was already available as 'journalctl --new-id128', but this makes
it more discoverable.

v2:
- rename binary to systemd-id128
- make --app-specific= into a switch that applies to boot-id and machine-id
2018-10-02 15:15:10 +02:00
Zbigniew Jędrzejewski-Szmek 65d410c7ca sd-id128: add sd_id128_get_boot_app_specific() 2018-10-02 15:15:10 +02:00
Zbigniew Jędrzejewski-Szmek ff7dad484c journalctl: move generate_new_id128() to shared 2018-10-02 15:13:17 +02:00
Evgeny Vereshchagin 14f37112c8 icmp6-util: stop ignoring EAGAIN and EINTR in icmp6_receive
The code handling the errors was originally part of ndisc_recv, which,
being an event handler, would be simply turned off if it returned a negative
error code. It's no longer necessary. Plus, it helps avoid passing
an uninitialized value to radv_send.

Closes https://github.com/systemd/systemd/issues/10223.
2018-10-02 12:58:07 +02:00
Zbigniew Jędrzejewski-Szmek 0a587335d2 journal-verify: add comment and silence LGTM warning 2018-10-02 12:54:00 +02:00
Zbigniew Jędrzejewski-Szmek cac4d95ec8 boot: change multiplication order
LGTM was complaining:
> Multiplication result may overflow 'unsigned int' before it is converted to 'unsigned long'.
2018-10-02 12:54:00 +02:00
Zbigniew Jędrzejewski-Szmek 3d6c184474 basic/hexdecoct: check for overflow
LGTM was complaining:
> Multiplication result may overflow 'int' before it is converted to 'long'.
Fix this by changing all types to ssize_t and add a check for overflow
while at it.
2018-10-02 12:54:00 +02:00
Zbigniew Jędrzejewski-Szmek 902000c198 bus-message: avoid wrap-around when using length read from message
We would read (-1), and then add 1 to it, call message_peek_body(..., 0, ...),
and when trying to make use of the data.

The fuzzer test case is just for one site, but they all look similar.

v2: fix two UINT8_MAX/UINT32_MAX mismatches founds by LGTM
2018-10-02 11:59:08 +02:00
Zbigniew Jędrzejewski-Szmek d831fb6f2b bus-message: return -EBADMSG not -EINVAL on invalid !gvariant messages 2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 3d338a302f bus-message: also properly copy struct signature when skipping
The change is similar to that in the previous commit, but I don't have
a reproducer / test case case for this one, so I'm keeping it seperate.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 73777ddba5 bus-message: fix skipping of array fields in !gvariant messages
We copied part of the string into a buffer that was off by two.
If the element signature had length one, we'd copy 0 bytes and crash when
looking at the "first" byte. Otherwise, we would crash because strncpy would
not terminate the string.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 0b4775b527 bus-message: output debug information about offset troubles 2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 10a7ec96d8 test-bus-gvariant: turn on debug output
I thought the test was wrong, but it turns out one of my patches was at
fault. But this helps to diagnose issues.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 8792bdf8a3 bus-message: drop asserts in functions which are wrappers for varargs version
The function does no processing on it's own, and just forwards arguments
to the other function. Let's just use the asserts there.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek f88214cf9d bus-message: fix calculation of offsets table for arrays
This is similar to the grandparent commit 'fix calculation of offsets table',
except that now the change is for array elements. Same story as before: we need
to make sure that the offsets increase enough taking alignment into account.

While at it, rename 'p' to 'previous' to match similar code in other places.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 4d82a8d505 bus-message: remove duplicate assignment 2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 12603b84d2 bus-message: fix calculation of offsets table
The offsets specify the ends of variable length data. We would trust the
incoming data, putting the offsets specified in our message
into the offsets tables after doing some superficial verification.
But when actually reading the data we apply alignment, so we would take
the previous offset, align it, making it bigger then current offset, and
then we'd try to read data of negative length.

In the attached example, the message specifies the following offsets:
[1, 4]
but the alignment of those items is
[1, 8]
so we'd calculate the second item as starting at 8 and ending at 4.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek e8fd7e4b5b bus: do not print (null) if the message has unknown type 2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek f22c308aff bus-message: use define 2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 9c65778d61 bus-message: rename function for clarity
There's already message_free_last_container(), so rename to match.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 81b6e63029 bus-message: do not crash on message with a string of zero length
We'd calculate the "real" length of the string as 'item_size - 1', which does
not work out well when item_size == 0.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 69bd42ca07 bus-message: let's always use -EBADMSG when the message is bad
-EINVAL means the arguments were somehow wrong, so translate the code we get
internally into -EBADMSG when returning.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek ec6bda56cb bus-message: avoid an infinite loop on empty structures
The alternative would be to treat gvariant and !gvariant messages differently.
But this is a problem because we check signatures is variuos places before we
have an actual message, for example in sd_bus_add_object_vtable(). It seems
better to treat things consistent (i.e. follow the lowest common denominator)
and disallow empty structures everywhere.
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek 6d1e0f4fcb sd-bus: unify three code-paths which free struct bus_container
We didn't free one of the fields in two of the places.

$ valgrind --show-leak-kinds=all --leak-check=full \
  build/fuzz-bus-message \
  test/fuzz/fuzz-bus-message/leak-c09c0e2256d43bc5e2d02748c8d8760e7bc25d20
...
==14457== HEAP SUMMARY:
==14457==     in use at exit: 3 bytes in 1 blocks
==14457==   total heap usage: 509 allocs, 508 frees, 51,016 bytes allocated
==14457==
==14457== 3 bytes in 1 blocks are definitely lost in loss record 1 of 1
==14457==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==14457==    by 0x53AFE79: strndup (in /usr/lib64/libc-2.27.so)
==14457==    by 0x4F52EB8: free_and_strndup (string-util.c:1039)
==14457==    by 0x4F8E1AB: sd_bus_message_peek_type (bus-message.c:4193)
==14457==    by 0x4F76CB5: bus_message_dump (bus-dump.c:144)
==14457==    by 0x108F12: LLVMFuzzerTestOneInput (fuzz-bus-message.c:24)
==14457==    by 0x1090F7: main (fuzz-main.c:34)
==14457==
==14457== LEAK SUMMARY:
==14457==    definitely lost: 3 bytes in 1 blocks
2018-10-02 11:53:20 +02:00
Zbigniew Jędrzejewski-Szmek cf81c68e96 bus-message: use structured initialization to avoid use of unitialized memory
As far as I can see, we would either reuse some values from a previously exited
container or just random bytes from the heap.

Should fix #10127.
2018-10-02 11:53:18 +02:00
Zbigniew Jędrzejewski-Szmek 7f546026ab Introduce free_and_strndup and use it in bus-message.c
v2: fix error in free_and_strndup()

When the orignal and copied message were the same, but shorter than specified
length l, memory read past the end of the buffer would be performed. A test
case is included: a string that had an embedded NUL ("q\0") is used to replace
"q".

v3: Fix one more bug in free_and_strndup and add tests.

v4: Some style fixed based on review, one more use of free_and_replace, and
make the tests more comprehensive.
2018-10-02 11:42:45 +02:00
Zbigniew Jędrzejewski-Szmek 56b560c263 fuzz-bus-message: add fuzzer for message parsing
As with other fuzzers, SYSTEMD_FUZZ_OUTPUT=1 and SYSTEMD_LOG_LEVEL=debug can be
used for debugging.
2018-10-02 11:09:05 +02:00
Zbigniew Jędrzejewski-Szmek 3ddf3d4394 test-bus-marshal: use cescaping instead of hexmem
It is easier to see the contents this way by eye.
2018-10-02 09:41:25 +02:00
Yu Watanabe 5c434af721
Merge pull request #10218 from keszybz/export-sd-device-hwdb
Export functions in sd-device and sd-hwdb
2018-10-01 19:45:55 +02:00
Zbigniew Jędrzejewski-Szmek 4dd73b883f test-sd-hwdb: skip tests if hwdb cannot be opened 2018-10-01 15:22:55 +02:00
Yu Watanabe f9c8c01fcc test: try system bus if user bus cannot be opened 2018-10-01 10:15:54 +02:00
Zbigniew Jędrzejewski-Szmek 3bdce0eac0
Merge pull request #10138 from yuwata/test-check-container
test: skip several tests when running in container
2018-10-01 10:09:54 +02:00
Zbigniew Jędrzejewski-Szmek 41ad5ea198
Merge pull request #10220 from floppym/efi-cc
meson: use an array option for efi-cc
2018-10-01 09:28:22 +02:00
Yu Watanabe e986910e87 import: sparse_write() returns negative errno 2018-10-01 08:29:16 +02:00
Mike Gilbert 5f723125ae meson: avoid calling the shell to resolve efi_libdir 2018-09-30 16:22:07 -04:00
Mike Gilbert 595343fb4c meson: use an array option for efi-cc
Fixes: https://github.com/systemd/systemd/issues/10211
2018-09-30 15:43:39 -04:00
Thomas Haller f21f31b24b trivial: fix spelling in code comments
Based-on-patch-by: Rafael Fontenelle <rafaelff@gnome.org>
2018-09-30 21:32:33 +02:00
Zbigniew Jędrzejewski-Szmek 6083c4b763 libsystemd: export all functions in sd-hwdb.h
sd-hwdb.h is now also installed in /usr/include/systemd.
2018-09-30 20:39:02 +02:00
Zbigniew Jędrzejewski-Szmek ca7a9afc7e test-sd-hwdb: add a simple test for export sd-hwdb functions 2018-09-30 20:39:02 +02:00
Zbigniew Jędrzejewski-Szmek 3f608087bd libsystemd: export all functions in sd-device.h
sd-device.h is now also installed in /usr/include/systemd.
2018-09-30 20:39:02 +02:00
Yu Watanabe 213e759ad5 dhcp6: fix memleak about sd_event 2018-09-30 14:17:33 +02:00
Evgeny Vereshchagin b387d3c132 dhcp6: fix an off-by-one error in dhcp6_option_parse_domainname
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
READ of size 1 at 0x60200055fa9c thread T0
    #0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
    #1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
    #2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
    #3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
    #4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
    #5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
    #6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
    #7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
    #8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
    #9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
    #10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
    #11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
    #12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
    #13 0x580ca6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:838:5
    #14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
    #15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)
2018-09-29 03:07:29 +00:00
Evgeny Vereshchagin 45a7becfea tests: make fuzz-dhcp6-client work in containers provided by the OSS-Fuzz project
The containers come with an empty machine-id, which causes the fuzzer
to fail as soon as it starts.

See https://github.com/systemd/systemd/pull/9014#discussion_r189594104
2018-09-29 02:57:04 +00:00
Evgeny Vereshchagin d89a400ed6 fuzz: add a fuzzer for dhcp6_client 2018-09-29 02:27:07 +00:00
Zbigniew Jędrzejewski-Szmek 83043e8dc8
Merge pull request #10190 from evverx/fuzz-ndisc-rs
Add a fuzzer for sd-ndisc and a reproducer for an infinite loop in ndisc_handle_datagram
2018-09-28 15:54:04 +02:00
Helmut Grohne df7cacae69 meson: use the host architecture compiler/linker for src/boot/efi
cross building systemd to arm64 presently fails, because the build
system uses plain gcc and plain ld (build architecture compiler and
linker respectively) for building src/boot/efi. These values come from
the efi-cc and efi-ld options respectively. It rather should be using
host tools here.

Fixes: b710072da4 ("add support for building efi modules")
2018-09-28 14:42:56 +02:00
Zbigniew Jędrzejewski-Szmek 22041e475f
Merge pull request #10186 from yuwata/fix-10149
network: Fix memleaks found by test
2018-09-28 14:20:12 +02:00
Zbigniew Jędrzejewski-Szmek b87dadcdb2 networkd-routing-policy-rule.c: drop unnecessary check
set_get() already does that.
2018-09-27 18:14:56 +02:00
Yu Watanabe 431a4bc8c0 dhcp6: fix memleak
Let's drop client_set_lease() because just writing what it does in both
places is simpler.

Fixes #10157.
2018-09-27 18:14:19 +02:00
Lennart Poettering 12580bc3ed bootspec: rename "filename" field to "id"
This follows the renaming done a few commits earlier too systemd-boot
itself.

Also, let's show the ID, since it's useful.
2018-09-27 17:31:37 +02:00
Lennart Poettering 195b36cf21 bootspec: fix include lines
List all files we use definitions from.
2018-09-27 17:31:37 +02:00
Lennart Poettering 2f3db9c907 uft8: add comment, requested by @keszybz 2018-09-27 17:21:18 +02:00
Yu Watanabe cb1bdeaf56 dhcp6: fix buffer size checking 2018-09-27 23:48:51 +09:00
Yu Watanabe 23976cb928 dhcp6: use offsetof instead of sizeof 2018-09-27 23:41:23 +09:00
Yu Watanabe e2975f8548 sd-dhcp-lease: fix memleaks 2018-09-27 18:04:59 +09:00
Yu Watanabe 09348d4081 sd-dhecp-lease: use free_and_replace() at one more 2018-09-27 18:04:08 +09:00
Yu Watanabe 727ba17f55 network: fix memleak around Network.dhcp_vendor_class_identifier 2018-09-27 17:48:34 +09:00
Yu Watanabe 598c85cc46 network: fix alignment 2018-09-27 17:48:34 +09:00
Yu Watanabe eeab051b28 network: strdup iif and oif when creating RoutingPolicyRule object 2018-09-27 17:48:34 +09:00
Yu Watanabe 8e37fcbd21 network: use TAKE_PTR() at one more place 2018-09-27 17:48:34 +09:00
Yu Watanabe 1b3194d8f2 network: fix memleak about routing policy 2018-09-27 17:48:34 +09:00
Yu Watanabe 9d66b48c7c network: use structured initializer at one more place 2018-09-27 17:48:34 +09:00
Zbigniew Jędrzejewski-Szmek b6de93096e
Merge pull request #10173 from poettering/sd-boot-utf
the utf8.c changes from PR #9437 (i.e. the boot counting PR)
2018-09-27 08:21:20 +02:00
Lennart Poettering ff6c6cc117 nspawn: when --quiet is passed, simply downgrade log messages to LOG_DEBUG (#10181)
With this change almost all log messages that are suppressed through
--quiet are not actually suppressed anymore, but simply downgraded to
LOG_DEBUG. Previously we did it this way for some log messages and fully
suppressed them for others. With this it's pretty much systematic.

Inspired by #10122.
2018-09-26 23:40:39 +02:00
Susant Sahani 6cf0a20491 udev/net: add support for the equivalent of "ethtool advertise" to .link files
This work adds support for the equivalent of "ethtool advertise" to .link files?
http://lists.freedesktop.org/archives/systemd-devel/2015-April/030112.html
2018-09-26 22:21:42 +02:00
Yu Watanabe f3241c61f1 ndisc: fix two infinite loops 2018-09-26 18:54:21 +00:00
Evgeny Vereshchagin 0f0a1dad7d tests: add a fuzzer for sd-ndisc 2018-09-26 16:39:03 +00:00
Evgeny Vereshchagin 89f180201c nspawn: chown() the legacy hierarchy when it's used in a container
This is a follow-up to 720f0a2f3c.

Closes https://github.com/systemd/systemd/issues/10026
Closes https://github.com/systemd/systemd/issues/9563
2018-09-26 17:29:17 +02:00
Anita Zhang c87700a133 Make Watchdog Signal Configurable
Allows configuring the watchdog signal (with a default of SIGABRT).
This allows an alternative to SIGABRT when coredumps are not desirable.

Appropriate references to SIGABRT or aborting were renamed to reflect
more liberal watchdog signals.

Closes #8658
2018-09-26 16:14:29 +02:00
Yu Watanabe c1ee267489 udev: use path_make_relative() 2018-09-26 22:58:57 +09:00
Yu Watanabe 6d93eeb7c8 udev-builtin: replace udev_build_argv() by strv_split_extract() 2018-09-26 22:58:51 +09:00
Lennart Poettering ee8d493cbd
Merge pull request #10158 from keszybz/seccomp-log-tightening
Seccomp log tightening
2018-09-26 15:56:32 +02:00
Yu Watanabe feaa6db7ac udev-event: replace udev_build_argv() by strv_split_full()
This also modernize udev_event_spawn() a bit.
2018-09-26 22:55:22 +09:00
Yu Watanabe bd206af402 test: introduce test-udev-build-argv
This intends to clarify the rule udev_build_argv() uses.
2018-09-26 22:52:01 +09:00
Yu Watanabe 1f938af811 test: add tests for strv_split_full() 2018-09-26 22:50:02 +09:00
Yu Watanabe 8059aa9c92 strv: introduce 'relax' mode to strv_split_full()
If SPLIT_RELAX is specified, then it accepts unfinished quotes or
missing separator after right quote.
2018-09-26 22:48:17 +09:00
Lennart Poettering 0eeba7a39f
Merge pull request #10168 from keszybz/coverity-fixes
Coverity fixes
2018-09-26 15:37:22 +02:00
Patrik Flykt dd5ab7d913 networkd-dhcp6: Set initial value of route to NULL
Start with route set to NULL should there be no route created. Remove
the explicit route_free as the _cleanup_ will take care of that after
the continue;.
2018-09-26 15:15:37 +02:00
Yu Watanabe 2c3a11d86e strv: allow to set separator NULL in strv_split() or strv_split_full() 2018-09-26 19:20:43 +09:00
Yu Watanabe af0b60b37c strv: introduce strv_split_full() which optionally handle quotes 2018-09-26 19:17:51 +09:00
Yu Watanabe 0fbc35524c libsystemd: add missing 'global' specifier in libsystemd.sym 2018-09-25 23:30:58 +02:00
William Douglas 6d7b543342 RFC tmpfiles: Allow configuration to ignore execution errors
This is an implementation that covers making errors encountered when writing
file content optionally fatal. If this is something that folks would want I'll
add handling of this for all the other directives. I'd appreciate suggestions
on how this might better be structured as well (use of a goto fail or such) as
I'm not super happy with the approach.
2018-09-25 23:30:30 +02:00
Zbigniew Jędrzejewski-Szmek 97c7469bbe
Merge pull request #10169 from poettering/putenv-error-handling
add missing putenv() error handling
2018-09-25 19:50:49 +02:00
Lennart Poettering 80b0a59729 utf8: add utf8_to_utf16() helper 2018-09-25 15:57:47 +02:00
Lennart Poettering 2ac2ff3fc1 utf8: let's update utf16_to_utf8() a bit
Let's change utf16_to_utf8() prototype to refer to utf16 chars with char16_t rather than void

Let's not cast away a "const" needlessly.

Let's add a few comments.

Let's fix the calculations of the buffer size to allocate, and how long
to run the loop in case of uneven byte numbers
2018-09-25 15:57:47 +02:00
Lennart Poettering 7c42185784 utf8: change return type of utf8_encoded_expected_len() to size_t
After all it returns a lengths of a string in chars, and hence should
return size_t, exactly like strlen().
2018-09-25 15:57:47 +02:00
Lennart Poettering 07667be733 utf8: modernize utf16 inline calls a bit
Let's fix an indentation issue.

Let's avoid yoda comparisons.

Let's drop unnecessary ().

Let's make sure we convert 16bit values to 32bit before shifting them by
10bit to the left, to avoid overflows.

Let's avoid comparisons between signed literals and unsigned variables,
in particular if the literals are outside of the minimum range C
requires for "int".
2018-09-25 15:57:47 +02:00
Lennart Poettering e71fb4b302 utf8: update utf8_is_valid() a bit
Let's avoid a few casts in the function. Also, let's drop the "const"
when returning the string, for similar reasons as strchr() and friends
drop it: so that we don't add a const if the user passes in a non-const
string.
2018-09-25 15:57:47 +02:00
Lennart Poettering d3a94b3e80 killall: (void)ify more things 2018-09-25 12:50:35 +02:00
Lennart Poettering 20ca2d10bd killall: filter out bogus PIDs
we might as well filter these too since negative PIDs have special
semantics in kill(), and we should never trigger that...
2018-09-25 12:50:35 +02:00
Lennart Poettering e45154c770 killall: use is_kernel_thread() during killing spree process filtering too
Apparently the new "bpfilter" subsystem otherwise confuses us.

See: https://lists.freedesktop.org/archives/systemd-devel/2018-September/041392.html
2018-09-25 12:50:35 +02:00
Lennart Poettering 7c428bb5d5
Merge pull request #10059 from yuwata/env-exec-directory
core: introduce $RUNTIME_DIRECTORY= or friends
2018-09-25 12:34:30 +02:00
Lennart Poettering 653d469519 exec-util: add missing logging call
This function logs about all errors, but one case was forgotten. Fix
that.
2018-09-25 12:04:14 +02:00
Lennart Poettering ed689f7894 exec-util: handle putenv() errors
Just paranoia, as putenv() can fail and we should catch it, like we
catch all other errors.

Follow-up for #10073
2018-09-25 12:04:14 +02:00
Zbigniew Jędrzejewski-Szmek 6f48815918 test-journal-syslog: initialize variable
The *priority argument to syslog_parse_priority() needs to be initialized
if the last argument (with_facility) is false.

CID #1394690.
2018-09-25 11:34:52 +02:00
Zbigniew Jędrzejewski-Szmek 8a76031152 udev-builtin-net_id: do not assume "type" attribute exists
It *should*, but who knows, let's be more defensive here.

CID #1395805.
2018-09-25 11:29:54 +02:00
Zbigniew Jędrzejewski-Szmek ccc0ec6f71 journal-upload: fix off-by-one in assert()
CID #1394386.
2018-09-25 11:22:13 +02:00
Zbigniew Jędrzejewski-Szmek ec766a5168 sd-event: use new cleanup function more 2018-09-25 11:15:27 +02:00
Zbigniew Jędrzejewski-Szmek 8c75fe1765 sd-event: remove dead code and use _cleanup_
CID #1393250.
2018-09-25 11:10:12 +02:00
Thiago Macieira 044c2c7a2b Make bzip2 an optional dependency for systemd-importd
Yes, there are still a lot of users of bzip2, but it's fallen out of
favour after LZMA/xz, which can compress a lot more and often
decompresses faster than bzip2 too.
2018-09-25 10:58:09 +02:00
Lennart Poettering 4295fd9e82
Merge pull request #10163 from poettering/inhibit-format-table
systemd-inhibit --list: port to format-table.c
2018-09-25 10:24:30 +02:00
Zbigniew Jędrzejewski-Szmek 3318fd9c24
Merge pull request #10073 from xnox/execve
Execute generators with manager's environment exported
2018-09-25 10:07:23 +02:00
Zbigniew Jędrzejewski-Szmek 1346489f8c DHCPv6: use unsigned for flags 2018-09-25 09:29:36 +02:00
Zbigniew Jędrzejewski-Szmek d00de84373
Merge pull request #10164 from poettering/btrfs-resize-fix
btrfs resize fix
2018-09-25 09:24:14 +02:00
Lennart Poettering 614a8274f2 udev: fix some type sloppiness
We use strtoul() which returns an "unsigned long", but then assign this
to int or unsigned in, i.e. drop 32bit silently on 64bit systems. Let's
clean this up a bit, and retain the right types.
2018-09-25 09:20:16 +02:00
Lennart Poettering 6ac386855c logind: fix blacklist/whitelist confusion in comment (#10165)
Triggered by this:

602a41c22a (r30575293)
2018-09-25 07:02:41 +09:00
Lennart Poettering 7e69127871 btrfs: log at debug log when we ignore errors
This stuff is likely to fail in many setups (for example when quota is
not supported by the btrfs version), hence only log at debug
level. Previously we'd silently ignore things altogether which makes
things pretty hard to debug.
2018-09-24 19:47:42 +02:00
Lennart Poettering de89949a71 btrfs: fix loopback resizing code
This corrects the block device to use, to the right path, as it was
before 553e15f21b.

Replaces: #10153
2018-09-24 19:44:06 +02:00
Lennart Poettering a942661787 inhibit: use format-table to format systemd-inhibit --list
This changes the output a bit, as the previous multi-line output of each
inhibitor is changed to a single line, but it does unify the output look
with the one of our other tools. Moreover this adds proper sorting.
2018-09-24 19:21:00 +02:00
Lennart Poettering 2f47ef04ea inhibit: normalize variable types
When we parse an "u" from an sd_bus_message then we need to do that into
a uint32_t, not a pid_t or uid_t, even if this is likely the same.

Also, let's count objects we keep in memory as size_t as usual.
2018-09-24 19:21:00 +02:00
Lennart Poettering 0e6872cdfc inhibit: normalize when we log about failures to list inhibitors
let's print log messages about all types of errors inside of the
function, since otherwise we might sometimes log twice about some
specific cases.
2018-09-24 19:21:00 +02:00
Yu Watanabe 6c9c51e5e2 fs-util: make symlink_idempotent() optionally create relative link 2018-09-24 18:52:53 +03:00
Zbigniew Jędrzejewski-Szmek bee13f2e49
Merge pull request #9989 from yuwata/sd-device-enoent
sd-device: make sd_device_get_*() return -ENOENT if the values are not set
2018-09-24 17:27:49 +02:00
Zbigniew Jędrzejewski-Szmek 7e86bd73a4 seccomp: tighten checking of seccomp filter creation
In seccomp code, the code is changed to propagate errors which are about
anything other than unknown/unimplemented syscalls. I *think* such errors
should not happen in normal usage, but so far we would summarilly ignore all
errors, so that part is uncertain. If it turns out that other errors occur and
should be ignored, this should be added later.

In nspawn, we would count the number of added filters, but didn't use this for
anything. Drop that part.

The comments suggested that seccomp_add_syscall_filter_item() returned negative
if the syscall is unknown, but this wasn't true: it returns 0.

The error at this point can only be if the syscall was known but couldn't be
added. If the error comes from our internal whitelist in nspawn, treat this as
error, because it means that our internal table is wrong. If the error comes
from user arguments, warn and ignore. (If some syscall is not known at current
architecture, it is still silently ignored.)
2018-09-24 17:21:09 +02:00
Zbigniew Jędrzejewski-Szmek b54f36c604 seccomp: reduce logging about failure to add syscall to seccomp
Our logs are full of:
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldstat() / -10037, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call get_thread_area() / -10076, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call set_thread_area() / -10079, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldfstat() / -10034, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldolduname() / -10036, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call oldlstat() / -10035, ignoring: Numerical argument out of domain
Sep 19 09:22:10 autopkgtest systemd[690]: Failed to add rule for system call waitpid() / -10073, ignoring: Numerical argument out of domain
...
This is pointless and makes debug logs hard to read. Let's keep the logs
in test code, but disable it in nspawn and pid1. This is done through a function
parameter because those functions operate recursively and it's not possible to
make the caller to log meaningfully.


There should be no functional change, except the skipped debug logs.
2018-09-24 17:21:09 +02:00
Zbigniew Jędrzejewski-Szmek f09da7ccbc test-seccomp: log function names
Various tests produce similar output, and the function names make it
easier to see where the output is generated.
2018-09-24 17:21:09 +02:00
Zbigniew Jędrzejewski-Szmek 23e12f8e6c test-seccomp: move two similar tests closer 2018-09-24 17:19:11 +02:00
Zbigniew Jędrzejewski-Szmek 465815aaa7 test-udev: use _cleanup_ and modernize style 2018-09-24 15:42:50 +02:00
Zbigniew Jędrzejewski-Szmek c745d2bfa0 basic/mount-util: reword debug message
"because blacklisted" is not grammatical, it should be something like
"becuase it is blacklisted", which in turn in too verbose. Let's use
a shorter form.
2018-09-24 15:42:50 +02:00
Dimitri John Ledkov a3156a8ee4 core: execute generators with manager's environmnet 2018-09-24 13:40:50 +01:00
Dimitri John Ledkov ea368f0bd2 core: execute environment_generators with manager's environment 2018-09-24 13:40:10 +01:00
Dimitri John Ledkov 78ec1bb436 exec-util: in execute_directories, support initial exec environment 2018-09-24 13:40:10 +01:00
Zbigniew Jędrzejewski-Szmek f11aae7151
Merge pull request #10082 from porrided/udev-ipoib
Introduce predictable naming for IP-over-InfiniBand NICs
2018-09-24 13:14:06 +02:00
Zbigniew Jędrzejewski-Szmek 54e6f0a38f
Merge pull request #9981 from pfl/dhcp6_pd_other_information_quirk
DHCPv6 PD other information quirk
2018-09-24 13:02:24 +02:00
Yu Watanabe c679e12af1 tree-wide: drop unnecessary initializations 2018-09-23 17:18:50 +09:00
Yu Watanabe 2c740afd16 tree-wide: do not assign unused return values 2018-09-23 17:18:50 +09:00
Yu Watanabe 8a80712bcd logind-acl: replace strdup()+set_consume() by set_put_strdup() 2018-09-23 17:18:50 +09:00
Yu Watanabe 8090b41ed5 gpt-auto-generator: do not assign '*ret' on error 2018-09-23 17:18:50 +09:00
Yu Watanabe 403660c508 tree-wide: use streq() instead of streq_ptr() 2018-09-23 17:18:50 +09:00
Yu Watanabe dcfbde3a43 sd-device: make sd_device_get_*() return -ENOENT if the values are not set 2018-09-23 17:18:19 +09:00
Yu Watanabe feae122f3e test-udev: use LOG_REALM_UDEV
Otherwise, even if SYSTEMD_LOG_LEVEL=debug is specified, the test does
not show most debug messages.
2018-09-22 09:56:40 +02:00
Yu Watanabe 51b006e18d udevadm: show only version number for '--version' option
This effectively reverts 2bc54be485
and relevant changes in #9920, as it is used to determine the version
of udev, e.g., dracut.

Fixes dracutdevs/dracut#468.
2018-09-21 10:58:54 +02:00
Yu Watanabe 642d1a6d6e test-execute: skip several tests when running in container 2018-09-21 00:45:00 +09:00
Yu Watanabe 738c74d7b1 test-execute: also check python3 is installed or not 2018-09-21 00:45:00 +09:00
Yu Watanabe 767eab4750 test-process-util: skip several verifications when running in unprivileged container 2018-09-21 00:44:29 +09:00
Yu Watanabe 9590065f37 test-fs-util: skip some tests when running in unprivileged container 2018-09-21 00:44:29 +09:00
Yu Watanabe cd90ec7544 test-seccomp: add log messages when skipping tests 2018-09-21 00:32:44 +09:00
Yu Watanabe 92f6a1b6bc test-process-util: logs something when skipping tests 2018-09-21 00:32:36 +09:00
Zbigniew Jędrzejewski-Szmek 2e7e76af99 bus-util: drop now-unused functions 2018-09-20 16:52:02 +02:00
Zbigniew Jędrzejewski-Szmek b8b20f5a6a timesyncd: no need to reload dbus now 2018-09-20 16:52:02 +02:00
Zbigniew Jędrzejewski-Szmek 696fc8360d Revert "network: set DynamicUser= to systemd-networkd.service"
This reverts commit d4e9e574ea.
(systemd.conf.m4 part was already reverted in 5b5d82615011b9827466b7cd5756da35627a1608.)

Together those reverts should "fix" #10025 and #10011. ("fix" is in quotes
because this doesn't really fix the underlying issue, which is combining
DynamicUser= with strict container sandbox, but it avoids the problem by not
using that feature in our default installation.)

Dynamic users don't work well if the service requires matching configuration in
other places, for example dbus policy. This is true for those three services.
In effect, distros create the user statically [1, 2]. Dynamic users make more
sense for "add-on" services where not creating the user, or more precisely,
creating the user lazily, can save resources. For "basic" services, if we are
going to create the user on package installation anyway, setting DynamicUser=
just creates unneeded confusion. The only case where it is actually used is
when somebody forgets to do system configuration. But it's better to have the
service fail cleanly in this case too. If we want to turn on some side-effect
of DynamicUser=yes for those services, we should just do that directly through
fine-grained options. By not using DynamicUser= we also avoid the need to
restart dbus.

[1] bd9bf30727
[2] 48ac1cebde/f/systemd.spec (_473)
(Fedora does not create systemd-timesync user.)
2018-09-20 16:52:02 +02:00
Zbigniew Jędrzejewski-Szmek 62fb7e80fc Revert "resolve: enable DynamicUser= for systemd-resolved.service"
This reverts commit 0187368cad.
(systemd.conf.m4 part was already reverted in 5b5d82615011b9827466b7cd5756da35627a1608.)
2018-09-20 16:52:02 +02:00
Yu Watanabe 80f1b34442 sd-hwdb: initialize variable
The variable 'fn' was not initialized on compat mode.

Fixes CID#1395731.
2018-09-20 14:28:03 +02:00
Patrik Flykt 65dd5e3105 networkd-manager: Fix route removals on shutdown
In order to shut down networkd properly, the delegated routes added
need to be removed properly, and as error reporting is wanted, the
network link is needed in the debug output.

Solve this by calling manager_dhcp6_prefix_remove_all(), which will
remove each prefix stored in the Manager structure, and while doing
that reference each link so that it isn't freed before the route
removal callback is called. This in turn causes the network link to
be referenced once more, and an explicit hashmap_remove() must be
called to remove the network link from the m->links hashmap.

Also, since the registered callback is not called when the DHCPv6
client is stopped with sd_dhcp6_client_stop(), an explicit call
to dhcp6_lease_pd_prefix_lost() needs to be made to clean up any
unreachable routes set up for the delegated prefixes.
2018-09-19 13:45:18 -06:00
Patrik Flykt e1d737ef9d networkd-manager: Update logging of route additions and removals
Log route additions and removals when the action is to be done, as
the reply rtnl message may contain only a success or failure.
2018-09-19 13:45:18 -06:00
Patrik Flykt 7c881490c1 sd-dhcp6-client: Reference and unreference a stored lease
In order to be able to properly free a DHCPv6 lease, unreference the
previous lease and reference the new one.
2018-09-19 13:45:18 -06:00
Patrik Flykt e9c9605293 networkd-dhcp6: Remove functions whose output is not used
Remove dhcp6_reset_pd_prefix_network() that returns the network, but
whose output is not used anywhere.
2018-09-19 13:45:18 -06:00
Patrik Flykt 494c868d1f networkd-dhcp6: Set one unreachable route per DHCPv6 delegated prefix
Instead of setting many small unreachable routes for each of the /64
subnets that were not distributed between the links requesting delegated
prefixes, set one unreachable route for the size of the delegated
prefix. Each subnet asssigned to a downstream link will add a routable
subnet for that link, and as the subnet assigned to the downstream link
has a longer prefix than the whole delegated prefix, the downstream
link subnet routes are preferred over the unroutable delegated one.
The unreachable route is not added when the delegated prefix is exactly
a /64 as the prefix size cannot be used to sort out the order of routing
into a bigger blocking subnet with the smaller /64 punching routable
"holes" into it.

When stopping the DHCPv6 client, the unroutable delegated prefix is
removed before the downstream link prefixes are unassigned.
2018-09-19 13:45:18 -06:00
Patrik Flykt 9a7225de67 dhcp6-client: Store lease timeouts T1 and T1 in client struct
Since we now have the possibility to request prefixes to be delegated
without corresponding IPv6 addresses, it does not make sense to store
lease T1 and T2 timeouts in the otherwise unused IA_NA structure.
Therefore lease timeouts T1 and T2 are moved to the DHCPv6 client
structure, as there will be only one set of stateful timeouts required
by RFC 7550, Section 4.3.
2018-09-19 13:45:18 -06:00
Patrik Flykt 134ebaa45e dhcp6-client: Select T1 and T2 timeouts from IA_NA and IA_PD
Select T1 and T2 timeouts based on whether addresses or prefixes were
requested and what the server offered. The address and prefix timeouts
values have been computed earlier when the relevant DHCPv6 options were
parsed.
2018-09-19 13:45:18 -06:00
Patrik Flykt 49228c7520 dhcp6-lease: Add function to fetch the IAID for the prefix
Add function to fetch the IAID for the delegated IA_PD prefix. In
order to keep things simple in the implemntation, the same IAID
is used with IA_NA addresses and IA_PD prefixes. But the DHCPv6
server can choose to return only IA_PD prefixes, and the client
can nowadays omit requesting of IA_NA addresses. Since the function
fetching said IAID from the lease looks only for IA_NA ones, it
will return an empty IAID, which of course does not match the one
set for prefixes.

Fix this by adding a function returning the IAID for the prefix.
2018-09-19 13:45:18 -06:00
Patrik Flykt 125f20b4de networkd-network: Introduce DHCPv6 PD knob for RFC 7084 WPD-4
RFC 7084, WPD-4, requires Customer Edge end routers to behave
according to the following:

"WPD-4:  By default, the IPv6 CE router MUST initiate DHCPv6 prefix
           delegation when either the M or O flags are set to 1 in a
           received Router Advertisement (RA) message.  Behavior of the
           CE router to use DHCPv6 prefix delegation when the CE router
           has not received any RA or received an RA with the M and the
           O bits set to zero is out of scope for this document."

Since it cannot be automatically detected whether DHCPv6 is to be
operated as an CE end router or whether to initiate an Informational
exchange to obtain other useful network information via DHCPv6 when the
Router Advertisement 'O' bit is set, a 'ForceDHCPv6PDOtherInformation'
boolean network configuration option in the '[DHCP]' section of a is
introduced. Setting this option causes DHCPv6 to be started in stateful
mode, although only the 'O' bit is seen in the Router Advertisement.

When 'ForceDHCPv6PDOtherInformation' is set and the Router Advertisement
has only the Other information 'O' bit set, disable requests for IA_NA
addresses.

Fixes #9745.
2018-09-19 13:45:17 -06:00
Patrik Flykt 7776f2aeff dhcp6-client: Add tests for address, information and prefix requests
Add simple test cases to ensure the request for addresses, prefixes
and information request are handled as expected.
2018-09-19 13:45:17 -06:00
Patrik Flykt f311a62bef dhcp6-client: Function for enabling/disabling IA_NA request
Add function to enable/disable IA_NA address requests. Internally
handle the request as a bit mask and add IA_PD prefix delegation
to the same bit mask instead of having a separate boolean. Thus
the calling code can set requests for prefix and address delegation
separately. This is handy when supporting RFC 7084.

Add a check in the code that at least something is requested from
the server in Managed mode. By default request IA_NA addresses from
the DHCPv6 server. Although a value has been defined for IA_TA,
temporay IA_TA addresses are not yet requested.
2018-09-19 13:45:17 -06:00
Patrik Flykt d8c51121bb dhcp6_client: Add helper for fetching Prefix Delegation information
Add helper function for fetching enabled/disabled state of Prefix
Delegation for a DHCPv6 client. Update function setting prefix
delegation to use an int instead of a boolean.
2018-09-19 13:45:17 -06:00
Yu Watanabe d6609f8280 hwdb,udevadm: also unify hwdb_query() and hwdb_test() 2018-09-19 17:38:07 +09:00
Yu Watanabe e3b9fd0a27 sd-hwdb: use structured initializers 2018-09-19 17:36:19 +09:00
Yu Watanabe 6a34639e76 hwdb: unify duplicated code and move it to hwdb-util.c
Both 'systemd-hwdb update' and 'udevadm hwdb --update' creates hwdb
database. The database created by systemd-hwdb containes additional
information such that priority, line number, and source filename.
The unified function 'hwdb_update()' can take a flag 'compat' which
controls the format version of created database.
2018-09-19 17:36:03 +09:00
Yu Watanabe 73c63957d2 sd-hwdb: adjust included headers 2018-09-19 16:52:59 +09:00
Yu Watanabe 4d7783e937 hwdb: use _cleanup_ attribute at one more place 2018-09-19 16:52:59 +09:00
Yu Watanabe bf84dc168c hwdb: make trie_node_cleanup() can take NULL 2018-09-19 16:52:59 +09:00
Yu Watanabe cf37f937ee nspawn: suppress one more log message when --quiet is passed
Fixes #10119.
2018-09-19 08:42:17 +02:00
Yu Watanabe dc5f9c6f39 busctl,sd-lldp: explicitly specify type of argument in compare function
Several functions are shared by qsort and hash_ops or Prioq.
This makes these functions explicitly specify argument type,
and cast to __compar_fn_t where necessary.
2018-09-19 08:28:54 +09:00
Yu Watanabe bc861c2e09 tree-wide: use typesafe_bsearch() or typesafe_bsearch_r() 2018-09-19 08:08:03 +09:00
Yu Watanabe f0f6d791fe util: introduce typesafe_bsearch() and typesafe_bsearch_r() 2018-09-19 08:06:57 +09:00
Yu Watanabe ba0a7bfb98 tree-wide: use typesafe_qsort_r() 2018-09-19 08:05:13 +09:00
Yu Watanabe 5532395be7 util: introduce typesafe_qsort_r() 2018-09-19 08:04:40 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Arseny Maslennikov b8e8823e63 udev: Fix "strtol" -> "strtoul" for unsigned source values 2018-09-18 20:13:42 +03:00
Arseny Maslennikov cdd63a03ce udev: Provide a fallback for IPoIB device port numbers
In older kernels IPoIB network devices expose the port number via
the sysfs attribute 'dev_id', which is not intended to be used this way.
Let's support both options for a while.
2018-09-18 20:13:42 +03:00
Arseny Maslennikov a0d415da3a udev: Disable HW-address-based naming for IB NICs
An InfiniBand network address is 20 bytes long. Only the least
significant 8 bytes can be interpreted as a persistent hardware unit
identifier; the other 12 are transiently derived at runtime from metadata
specific to the protocol stack.

However, since the network interface name length is hard-capped by
IFNAMSIZ at 16 chars and the 2-byte type prefix with '\0' at the end
leave us only at 13, we cannot squeeze a descriptive representation of a
HW address into an interface name. Thus, it makes the most sense to drop
the scheme for IPoIB interfaces entirely.

Currently udev just gets confused and does what it has been taught
to do: fetches the first six bytes and puts them into a permanent
device attribute.
2018-09-18 20:13:42 +03:00
Arseny Maslennikov 938d30aa98 udev: Introduce predictable naming for InfiniBand NICs
We've long neglected IP-over-InfiniBand network interfaces, let's treat
them the same way we treat anyone else.

IPoIB interfaces will retain the 'ib' prefix; otherwise the naming scheme
is the same one we use for other network interfaces. E.g. a IPoIB network
device provided by a PCI card at bus 21 slot 0 function 6 will be named
'ibp21s0f6'.
2018-09-18 20:13:42 +03:00
Zbigniew Jędrzejewski-Szmek 6058516a14 detect-virt: do not try to read all of /proc/cpuinfo
Quoting https://github.com/systemd/systemd/issues/10074:
> detect_vm_uml() reads /proc/cpuinfo with read_full_file()
> read_full_file() has a file max limit size of READ_FULL_BYTES_MAX=(4U*1024U*1024U)
> Unfortunately, the size of my /proc/cpuinfo is bigger, approximately:
> echo $(( 4* $(cat /proc/cpuinfo | wc -c)))
> 9918072
> This causes read_full_file() to fail and the Condition test fallout.

Let's just read line by line until we find an intersting line. This also
helps if not running under UML, because we avoid reading as much data.
2018-09-18 16:53:36 +02:00
Yu Watanabe 010d436e02 verbs: reset optind (#10116)
optind may be used in each verb, e.g., udevadm. So, let's initialize
optind before calling verbs.

Without this, e.g., udevadm -d hwdb --update causes error in parsing arguments.
2018-09-18 16:24:58 +02:00
Alexander Filippov 047de7e1b1 core: fix the check if CONFIG_CGROUP_BPF is on
Since the commit torvalds/linux@fdb5c4531c
the syscall BPF_PROG_ATTACH return EBADF when CONFIG_CGROUP_BPF is
turned off and as result the bpf_firewall_supported() returns the
incorrect value.

This commmit replaces the syscall BPF_PROG_ATTACH with BPF_PROG_DETACH
which is still work as expected.

Resolves openbmc/linux#159
See also systemd/systemd#7054

Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
2018-09-18 16:19:51 +02:00
Yu Watanabe aca835ed2e core/execute: do not use the negative errno when setup_namespace() returns -ENOANO
Without this, log shows meaningless error message 'No anode', e.g.,
===
Failed to unshare the mount namespace: Operation not permitted
foo.service: Failed to set up mount namespacing: No anode
foo.service: Failed at step NAMESPACE spawning /usr/bin/test: No anode
===

Follow-up for 1beab8b0d0.
2018-09-18 14:31:09 +09:00
Yu Watanabe 2e4a4faea8 core/namespace: add more log messages 2018-09-18 14:31:09 +09:00
Yu Watanabe 5485deee6e
sd-device: use qsort_safe() (#10099)
The number of found devices may be zero. So, let's use qsort_safe().

Follow-up for 0a1665890c.
Fixes #10096.
2018-09-16 23:46:58 +09:00
Zbigniew Jędrzejewski-Szmek 32397af3d4
Merge pull request #9928 from yuwata/libudev-cleanups
libudev: coding style updates
2018-09-15 22:36:38 +02:00
Zbigniew Jędrzejewski-Szmek 23e8c79665 pid1: drop now-unused path parameter to resolve_template() 2018-09-15 20:03:32 +02:00
Zbigniew Jędrzejewski-Szmek 5a72417084 pid1: drop unused path parameter to add_two_dependencies_by_name() 2018-09-15 20:02:00 +02:00
Zbigniew Jędrzejewski-Szmek 35d8c19ace pid1: drop now-unused path parameter to add_dependency_by_name() 2018-09-15 19:57:52 +02:00
Zbigniew Jędrzejewski-Szmek 0c062fd3eb systemd: do not pass .wants fragment path to manager_load_unit
When loading units, sometimes we'd first encounter a unit from .wants or
.requires directory. A typical case would be when multi-user.target.wants/
contains a symlink to some unit. We would prepare to load this unit using
/etc/systemd/system/multi-user.target.wants/foo.service as the fragment
path. This is always wrong. Instead, let's use NULL as the path and let
manager_load_unit() figure out the path on its own.

Fixes #9921.

    path=0x5625ed9b01a0 "/usr/lib/systemd/system/local-fs.target.wants/systemd-remount-fs.service", e=0x0,
    _ret=0x7ffe64645000) at ../src/core/manager.c:1887
    name=0x5625ed9b01ce "systemd-remount-fs.service",
    path=0x5625ed9b01a0 "/usr/lib/systemd/system/local-fs.target.wants/systemd-remount-fs.service", e=0x0,
    _ret=0x7ffe64645000) at ../src/core/manager.c:1961
    name=0x5625ed9b01ce "systemd-remount-fs.service",
    path=0x5625ed9b01a0 "/usr/lib/systemd/system/local-fs.target.wants/systemd-remount-fs.service",
    add_reference=true, mask=UNIT_DEPENDENCY_FILE) at ../src/core/unit.c:2946
    dir_suffix=0x5625ebb179ed ".wants") at ../src/core/load-dropin.c:95
    path=0x0, e=0x0, _ret=0x7ffe646452c0) at ../src/core/manager.c:1965
    name=0x5625ebb186f8 "local-fs.target", path=0x0, add_reference=true,
    mask=UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT) at ../src/core/unit.c:2946
    where=0x5625ed9b3cc0 "/tmp", options=0x5625ed947110 "rw,nosuid,nodev,seclabel",
    fstype=0x5625ed95be90 "tmpfs", flags=0x7ffe64645395) at ../src/core/mount.c:1439
    where=0x5625ed9b3cc0 "/tmp", options=0x5625ed947110 "rw,nosuid,nodev,seclabel",
    fstype=0x5625ed95be90 "tmpfs", set_flags=false) at ../src/core/mount.c:1567
    at ../src/core/mount.c:1635
    ret_retval=0x7ffe64645660, ret_shutdown_verb=0x7ffe646456c0, ret_fds=0x7ffe646456d8,
    ret_switch_root_dir=0x7ffe646456b0, ret_switch_root_init=0x7ffe646456b8,
    ret_error_message=0x7ffe646456c8) at ../src/core/main.c:1669
2018-09-15 19:43:58 +02:00
Zbigniew Jędrzejewski-Szmek 9035119518
Merge pull request #9958 from yuwata/sd-device-enum-set
sd-device: make sd_device_enumerator_get_*_next() not destroy the list
2018-09-15 18:33:18 +02:00
Yu Watanabe 0ac4f1a513
Merge pull request #10070 from keszybz/test-reporting
Test reporting improvements
2018-09-15 15:55:15 +09:00
Yu Watanabe 3332004e28 test-catalog: drop unused variable
Follow-up for 49cdae63d1.
2018-09-15 01:59:14 +09:00
Yu Watanabe 72a4d9f96c bus-util: use _printf_ attribute
Follow-up for eda193578e.

Fixes oss-fuzz#10350.
2018-09-15 01:50:59 +09:00
Franck Bui 10ce2e0681 socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if SO_RCVBUF/SO_SNDBUF fails
Both SO_SNDBUFFORCE and SO_RCVBUFFORCE requires capability 'net_admin'.

If this capability is not granted to the service the first attempt to increase
the recv/snd buffers (via sd_notify()) with SO_RCVBUFFORCE/SO_SNDBUFFORCE will
fail, even if the requested size is lower than the limit enforced by the
kernel.

If apparmor is used, the DENIED logs for net_admin will show up. These log
entries are seen as red warning light, because they could indicate that a
program has been hacked and tries to compromise the system.

It would be nicer if they can be avoided without giving services (relying on
sd_notify) net_admin capability or dropping DENIED logs for all such services
via their apparmor profile.

I'm not sure if sd_notify really needs to forcibly increase the buffer sizes,
but at least if the requested size is below the kernel limit, the capability
(hence the log entries) should be avoided.

Hence let's first ask politely for increasing the buffers and only if it fails
then ignore the kernel limit if we have sufficient privileges.
2018-09-14 13:00:38 +02:00
Zbigniew Jędrzejewski-Szmek 1327f272d3
Merge pull request #9920 from yuwata/udev-cleanup-4
udev: drop unused udev structs and use verbs in udevadm
2018-09-14 10:05:59 +02:00
Zbigniew Jędrzejewski-Szmek 730d989acc tests: add a helper function to skip with errno 2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 6d7c403324 tests: use a helper function to parse environment and open logging
The advantages are that we save a few lines, and that we can override
logging using environment variables in more test executables.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 8b81c382c3 test-condition: make function return void
We don't look at the result anyway.
2018-09-14 09:29:57 +02:00
Zbigniew Jędrzejewski-Szmek 317bb217d3 tests: add helper to unify skipping a test and exiting 2018-09-14 09:29:57 +02:00
Yu Watanabe 2b8b1056d9 test: unset $XDG_{CONFIG,DATA}_DIRS
When $XDG_DATA_DIRS is unset, then, the default value
'/usr/local/share:/usr/share' is used.
When $XDG_DATA_DIRS contain the default paths but the order
is inverted: '/usr/share:/usr/local/share', then test-path-lookup fails.

Fixes #10002.
2018-09-13 12:13:54 +02:00
Yu Watanabe fd1939fbe7 meson: do not build tests by default when '-Dtests=false'
[zj: it is still possible to build tests explicitly by calling
     ninja -C build test-name. This way we have full flexibility.]
2018-09-13 12:07:34 +02:00
Yu Watanabe 964bc0ad60 test: log when skipping tests in more cases
Follow-up for the previous commit.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 08d541ca06 test: when skipping tests, always print something
It is quite confusing if the test "fails" without printing anything at all.

A typo in an 'if' statement is also fixed.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 938be08926 meson: disable _all_ tests when -Dtests=false
Back in 08318a2c5a, value "false" was enabled for
'-Dtests=', but various tests were not conditionalized properly. So even with
-Dtests=false -Dslow-tests=false we'd run 120 tests. Let's make this consistent.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek f57d003cb6 test-barrier: just make this a slow test
test-barrier was using a custom mechanism to skip itself. Let's
just follow the normal scheme.
2018-09-13 12:07:34 +02:00
Zbigniew Jędrzejewski-Szmek 0cf29baac0 tests: centralize check for slow tests 2018-09-13 12:07:27 +02:00
Yu Watanabe fb2042dd55 core: add new environment variable $RUNTIME_DIRECTORY= or friends
The variable is generated from RuntimeDirectory= or friends.
If multiple directories are set, then they are concatenated with
the separator ':'.
2018-09-13 17:02:58 +09:00
Yu Watanabe a2917d3d2a test: replace swear words by 'hoge' 2018-09-13 17:02:58 +09:00
Yu Watanabe 474a595af7 test: add tests for strv_join_prefix() 2018-09-13 17:02:58 +09:00
Yu Watanabe 2b9a7d2e96 strv: introduce strv_join_prefix() 2018-09-13 17:02:58 +09:00
Yu Watanabe 7c1cb6f198 core: add one more assert() 2018-09-13 17:02:58 +09:00
Yu Watanabe 76a9460d44 core: fix assert() about number of built environment variables
Follow-up for 4b58153dd2 and
fd63e712b2.
2018-09-13 17:02:58 +09:00
afg 27b620b7db nspawn: use copy-static if systemd-resolved is up and image is writable 2018-09-12 20:48:21 +02:00
Lennart Poettering b0b3ba69c0
Merge pull request #10061 from xnox/fix-logindless-scheduled-shutdown
Fix logindless scheduled shutdown
2018-09-12 20:45:31 +02:00
Lennart Poettering b2b9edd4d1
Merge pull request #10060 from yuwata/property-take-value
bus-util: make --property= optionaly take value
2018-09-12 20:17:53 +02:00
Filipe Brandenburger 49cdae63d1 test: use ${builddir}/systemd-runtest.env for $SYSTEMD_CATALOG_DIR
This makes it so that tests no longer need to know the absolute paths to the
source and build dirs, instead using the systemd-runtest.env file to get these
paths when running from the build tree.

Confirmed that test-catalog works on `ninja test`, when called standalone and
also when the environment file is not present, in which case it will use the
installed location under /usr/lib/systemd/catalog.

The location can now also be overridden for this test by setting the
$SYSTEMD_CATALOG_DIR environment variable.
2018-09-12 09:49:03 -07:00
Filipe Brandenburger e2d413707f test: use ${builddir}/systemd-runtest.env to set $SYSTEMD_TEST_DATA
This simplifies get_testdata_dir() to simply checking for an environment
variable, with an additional function to locate a systemd-runtest.env file in
the same directory as the test binary and reading environment variable
assignments from that file if it exists.

This makes it possible to:
- Run `ninja test` from the build dir and have it use ${srcdir}/test for
  test unit definitions.
- Run a test directly, such as `build/test-execute` and have it locate
  them correctly.
- Run installed tests (from systemd-tests package) and locate the test
  units in the installed location (/usr/lib/systemd/tests/testdata), in
  which case the absence of the systemd-runtest.env file will have
  get_testdata_dir() use the installed location hardcoded into the
  binaries.

Explicit setting of $SYSTEMD_TEST_DATA still overrides the contents of
systemd-runtest.env.
2018-09-12 09:49:03 -07:00
Filipe Brandenburger 55890a40c3 test: remove support for suffix in get_testdata_dir()
Instead, use path_join() in callers wherever needed.
2018-09-12 09:49:03 -07:00
Yu Watanabe eda193578e bus-util: make --property= optionally take value 2018-09-12 12:11:25 +09:00