Commit Graph

30503 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 6016b4b0ba Add reciprocal test for password hashing and checking 2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 2ae297fe0d Move test_password_{one,many} to libcrypt-util.c
They are only used under src/home/, but I want to add tests in test-libcrypt-util.c.
And the functions are almost trivial, so I think it is OK to move them to shared.
2020-09-15 11:52:30 +02:00
Juergen Hoetzel 150c430fd4 busctl: add missing shortopt -l 2020-09-15 09:38:10 +02:00
Yu Watanabe 8cc53fae36 core: use strv_free_and_replace() at one more place 2020-09-15 09:36:34 +02:00
Zbigniew Jędrzejewski-Szmek a937ce2d85 shared/libcrypt-util: use libcrypt_ra()
This lets the libc/xcrypt allocate as much storage area as it needs.
Should fix #16965:

testsuite-46.sh[74]: ==74==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f3e972e1080 at pc 0x7f3e9be8deed bp 0x7ffce4f28530 sp 0x7ffce4f27ce0
testsuite-46.sh[74]: WRITE of size 131232 at 0x7f3e972e1080 thread T0
testsuite-46.sh[74]:     #0 0x7f3e9be8deec  (/usr/lib/clang/10.0.1/lib/linux/libclang_rt.asan-x86_64.so+0x9feec)
testsuite-46.sh[74]:     #1 0x559cd05a6412 in user_record_make_hashed_password /systemd-meson-build/../build/src/home/user-record-util.c:818:21
testsuite-46.sh[74]:     #2 0x559cd058fb03 in create_home /systemd-meson-build/../build/src/home/homectl.c:1112:29
testsuite-46.sh[74]:     #3 0x7f3e9b5b3058 in dispatch_verb /systemd-meson-build/../build/src/shared/verbs.c:103:24
testsuite-46.sh[74]:     #4 0x559cd058c101 in run /systemd-meson-build/../build/src/home/homectl.c:3325:16
testsuite-46.sh[74]:     #5 0x559cd058c00a in main /systemd-meson-build/../build/src/home/homectl.c:3328:1
testsuite-46.sh[74]:     #6 0x7f3e9a88b151 in __libc_start_main (/usr/lib/libc.so.6+0x28151)
testsuite-46.sh[74]:     #7 0x559cd0583e7d in _start (/usr/bin/homectl+0x24e7d)
testsuite-46.sh[74]: Address 0x7f3e972e1080 is located in stack of thread T0 at offset 32896 in frame
testsuite-46.sh[74]:     #0 0x559cd05a60df in user_record_make_hashed_password /systemd-meson-build/../build/src/home/user-record-util.c:789
testsuite-46.sh[74]:   This frame has 6 object(s):
testsuite-46.sh[74]:     [32, 40) 'priv' (line 790)
testsuite-46.sh[74]:     [64, 72) 'np' (line 791)
testsuite-46.sh[74]:     [96, 104) 'salt' (line 809)
testsuite-46.sh[74]:     [128, 32896) 'cd' (line 810)
testsuite-46.sh[74]:     [33152, 33168) '.compoundliteral' <== Memory access at offset 32896 partially underflows this variable
testsuite-46.sh[74]:     [33184, 33192) 'new_array' (line 832) <== Memory access at offset 32896 partially underflows this variable
testsuite-46.sh[74]: HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
testsuite-46.sh[74]:       (longjmp and C++ exceptions *are* supported)
testsuite-46.sh[74]: SUMMARY: AddressSanitizer: stack-buffer-overflow (/usr/lib/clang/10.0.1/lib/linux/libclang_rt.asan-x86_64.so+0x9feec)

It seems 'struct crypt_data' is 32896 bytes, but libclang_rt wants more, at least 33168?
2020-09-15 09:30:56 +02:00
Zbigniew Jędrzejewski-Szmek 0e98d17e77 Add a helper function that does make_salt+crypt_r
No functional change.
2020-09-15 09:30:56 +02:00
Yu Watanabe 41bed67613
Merge pull request #16998 from zonque/networkd/mdb
network: add support for setting MDB entries
2020-09-15 16:30:39 +09:00
Christian Göttsche 67f5ae2d69 socket-util: reset length argument for second getsockopt call in fd_[gs]et_rcvbuf
In case the first getsockopt() call changes the value.
2020-09-15 09:35:36 +09:00
Yu Watanabe 3c460bfde6
Merge pull request #16976 from keszybz/systemctl-service-log-levels
systemctl: add service-log-{level,target} verbs
2020-09-15 09:34:07 +09:00
Yu Watanabe c2c61531a2
Merge pull request #17055 from keszybz/two-coverity-fixes
Two coverity fixes
2020-09-15 09:22:39 +09:00
Lennart Poettering 2a407487b2
Merge pull request #17049 from mrc0mmand/code-and-spell-check
tree-wide: assorted cleanups/fixes
2020-09-14 23:00:02 +02:00
Zbigniew Jędrzejewski-Szmek e2146e9b67 basic/copy: vodify unlinkat() call
Not much we can do at this point.

Coverity CID#1432670.
2020-09-14 22:34:43 +02:00
Zbigniew Jędrzejewski-Szmek 649bde89ca test: use pclose() for popen()
Coverity CID#1432701.
2020-09-14 22:32:52 +02:00
Zbigniew Jędrzejewski-Szmek e6e691aebf systemctl: give a nice hint about org.freedesktop.LogControl1 when applicable 2020-09-14 22:12:14 +02:00
Zbigniew Jędrzejewski-Szmek 094c6fc338
Merge pull request #17031 from poettering/path-start-limit
core: propagate start limit hit from triggered unit to path unit
2020-09-14 21:51:39 +02:00
Zbigniew Jędrzejewski-Szmek bc2ed3bbf0
Merge pull request #17039 from poettering/dbus-default-dep
tweak when we synthesize dbus deps for service units
2020-09-14 21:45:53 +02:00
Lennart Poettering 2a03b9ed21 tree-wide: don't needlessly negate error number passed to bus_error_message()
Like it's customary in our codebase bus_error_message() internally takes
abs() of the passed error anyway, hence no need to explicitly negate it.
We mostly got this right, but in too many cases we didn't. Fix that.
2020-09-14 21:42:22 +02:00
Lennart Poettering ad0b610b0c bootctl: handle if LoaderSystemToken is invalid for some reason
This points to some firmware issue, but we should still be able to
correct things if this happens. Hence log about this and fix it.

Fixes: #17041
2020-09-14 21:33:31 +02:00
Frantisek Sumsal 05827831a6 shared: drop a redundant if statement 2020-09-14 16:18:18 +02:00
Frantisek Sumsal 8d16f29b23 libsystemd: drop a redundant if statement 2020-09-14 16:18:02 +02:00
Frantisek Sumsal 890ea05ac2 home: return SYNTHETIC_ERRNO() when appropriate 2020-09-14 16:16:59 +02:00
Frantisek Sumsal 60d7a2029a basic: drop a redundant if statement 2020-09-14 16:16:18 +02:00
Frantisek Sumsal 973bc32ab6 core: consolidate alloc & put operations into one statement 2020-09-14 16:13:44 +02:00
Frantisek Sumsal 69e3234db7 tree-wide: fix typos found by codespell
Reported by Fossies.org
2020-09-14 15:32:37 +02:00
Lennart Poettering 22f401b269 unit-def: drop pointless 0 initialization of first enum value
This is implied in C and we generally don't bother with this, so don't
bother with this here either.
2020-09-14 13:05:09 +02:00
Lennart Poettering 47ab8f73e3 core: propagate unit start limit hit state to triggering path unit
We already do this for socket and automount units, do it for path units
too: if the triggered service keeps hitting the start limit, then fail
the triggering unit too, so that we don#t busy loop forever.

(Note that this leaves only timer units out in the cold for this kind of
protection, but it shouldn't matter there, as they are naturally
protected against busy loops: they are scheduled by time anyway).

Fixes: #16669
2020-09-14 13:05:09 +02:00
Lennart Poettering 0377cd2936 core: propagate triggered unit in more load states
In 4c2ef32767 we enabled propagating
triggered unit state to the triggering unit for service units in more
load states, so that we don't accidentally stop tracking state
correctly.

Do the same for our other triggering unit states: automounts, paths, and
timers.

Also, make this an assertion rather than a simple test. After all it
should never happen that we get called for half-loaded units or units of
the wrong type. The load routines should already have made this
impossible.
2020-09-14 13:05:09 +02:00
Lennart Poettering df8b14b591 test-fileio: test test strings with shell, too 2020-09-14 12:26:41 +02:00
Lennart Poettering 55f99c26c6 test-env-file: add test that tests our env file read + writer + shell against each other
Should hopefully make regressions on this unlikely.
2020-09-14 12:26:41 +02:00
Lennart Poettering de008e537d env-file: bring our decoding of double-quoted strings in env files in line with shell
In shell, inside of double quotes only a select few chars should be
escaped. If other chars are escaped this has no effect. Correct the list
of chars that need such escaping.

Also, make sure we can read back the stuff we wrote out without loss.

Fixes: #16788
2020-09-14 11:08:43 +02:00
Lennart Poettering 6fe3196350 test-fileio: use test strings that are actually valid in shell 2020-09-14 11:08:43 +02:00
Lennart Poettering a7f49f0b7c service: add implicit dbus deps only for Type=dbus units
We want to be able to use BusName= in services that run during early boot
already, and thus don't synthesize deps on dbus there. Instead add them
when Type=dbus is set, because in that case we actually really need
D-Bus support.

Fixes: #17037
2020-09-14 11:07:30 +02:00
Lennart Poettering 31d74c66e2 core: don't warn if BusName= is used for non-Type=dbus services
It's useful for more than just Type=dbus now, given #16976. Hence, let's
drop the warning.
2020-09-14 11:07:12 +02:00
Zbigniew Jędrzejewski-Szmek d94bab0805 systemctl: immediately reject invalid log levels
Symbolic names and number in the appropriate range are allowed
(log_level_from_string() DTRT already).

The target names are more messy, so we leave the verification to the service.
2020-09-12 10:22:51 +02:00
Zbigniew Jędrzejewski-Szmek 77db9433a7 systemctl: merge log_target(), log_level(), service_log_setting() 2020-09-12 10:22:51 +02:00
Zbigniew Jędrzejewski-Szmek 6824c132e9 systemctl: add service-log-{level,target} verbs
Heavily inspired by #15622. This adds:
  systemctl service-log-level systemd-resolved
  systemctl service-log-level systemd-resolved info
  systemctl service-log-target systemd-resolved
  systemctl service-log-target systemd-resolved console

We already have systemctl verbs log-level, log-target, and service-watchdogs.
Those two new verbs tie nicely into this scheme.
2020-09-12 10:22:51 +02:00
Zbigniew Jędrzejewski-Szmek 4b6bc95c01
Merge pull request #17009 from poettering/rootprefix-noslash
remove duplicate slashes in systemd-path output if rootprefixdir is "/"
2020-09-12 10:07:40 +02:00
Lennart Poettering ae0b700a85 hashmap: make sure to initialize shared hash key atomically
if we allocate a bunch of hash tables all at the same time, with none
earlier than the other, there's a good chance we'll initialize the
shared hash key multiple times, so that some threads will see a
different shared hash key than others.

Let's fix that, and make sure really everyone sees the same hash key.

Fixes: #17007
2020-09-12 09:33:33 +02:00
Lennart Poettering 35b4e3c1bc socket: downgrade log warnings about inability to set socket buffer sizes
In containers we might lack the privs to up the socket buffers. Let's
not complain so loudly about that. Let's hence downgrade this to debug
logging if it's a permission problem.

(This wasn't an issue before b92f350789
because back then the failures wouldn't be detected at all.)
2020-09-12 08:14:54 +02:00
Lennart Poettering e742ec6abc test-acl-util: skip test if /tmp doesn't do ACLs
Fixes: #17013
2020-09-12 08:12:36 +02:00
Lennart Poettering 0306d1598d
Merge pull request #17028 from poettering/logind-replace-job
logind: make TerminateSession() count
2020-09-11 22:17:41 +02:00
Yu Watanabe 85b6a8110d network: do not add prefix to RA if radv is not configured
Fixes #17017.
2020-09-11 19:28:46 +02:00
Michal Sekletár 882f5f429e cryptsetup: generate the unit to umount keydev filesystem
Previously we would call umount from ExecStartPost= of
systemd-cryptsetup instance in order to get rid of the keydev
mount (i.e. filesystem containing keyfile). Let's generate unit to
handle umount. Making this symmetrical (both mount and umount of keydev
are handled by units) fixes the problem with lingering keydev mounts.

Motivation for the change is the issue where keydev mount would stay
around even if device was successfully unlocked and mount is no longer
needed. That could happen previously because when generator options are
not prefixed with "rd." we run generators twice (e.g. rd.luks.key=...).

In such case disk is unlocked in initramfs phase of boot (assuming the
initrd image contains the generator and is able to handle unlocking of
LUKS devices). After switchroot we however enqueue start job for
systemd-cryptsetup instance (because units are regenerated second time)
and that pulls in its dependencies into transaction. Later the main
systemd-cryptsetup unit not actually started since it is already active
and has RemainaAfterExit=yes. Nevertheless, dependencies get activated
and keydev mount is attached again. Because previously we called umount
from ExecStartPost= of systemd-cryptsetup instance the umount is not
called second time and keydev filesystem stays lingering.
2020-09-11 19:20:28 +02:00
Lennart Poettering 1a42ce0920 logind: make sure when we are explicitly asked to terminate session/user/seat to use "replace" job mode
Otherwise our request will possibly fail if something else is already
enqeued, but given this is an explicit user request, let's not allow
things to fail.

Fixes: #16702
2020-09-11 18:09:34 +02:00
Lennart Poettering bda625730d logind: clarify what the second argument of session_stop() means when calling it 2020-09-11 18:09:30 +02:00
Lennart Poettering 40771cf524 logind: minor simplification 2020-09-11 18:09:11 +02:00
Lennart Poettering f7c87baeca
Merge pull request #17020 from yuwata/backlight
backlight: validate sysattr value
2020-09-11 14:23:47 +02:00
Lennart Poettering 2ac4d1d45b hostnamed: add various debugging log messages when we determine chassis type
No actual code flow changes, just a bunch of debug messages.
2020-09-11 13:14:05 +02:00
Lennart Poettering 6e65df89c3 pkg-config: prefix is not really configurable, don't pretend it was
We generally don't support prefix being != /usr, and this is hardcoded
all over the place. In the systemd.pc file it wasn't so far. Let's
adjust this to match the rest of the codebase.
2020-09-11 13:09:06 +02:00
Lennart Poettering b612c26ceb sd-path: use ROOTPREFIX without suffixed slash
We already have rootprefix_noslash as meson variable, export it so that
we can also use it in C code.

Fixes: #16773
2020-09-11 13:08:30 +02:00
Yu Watanabe 3bacb7e73b backlight: validate read sysattr value
If actual_brightness is larger than max_brightness, then fall back to
use brightness attribute.

Also, if the saved value is invalid, then this makes remove the file in
/var/lib/systemd/backlight.

Hopefully fixes #17011.
2020-09-11 17:46:11 +09:00
Yu Watanabe 06d98bdc81 backlight: do not claim that ID_BACKLIGHT_CLAMP= property is not set 2020-09-11 17:44:20 +09:00
Yu Watanabe ea2bc25762 sd-device: introduce sd_device_set_sysattr_valuef() 2020-09-11 17:41:10 +09:00
Lennart Poettering 5d0fe4233b tree-wide: add helper for IPv4/IPv6 sockopts
A variety of sockopts exist both for IPv4 and IPv6 but require a
different pair of sockopt level/option number. Let's add helpers for
these that internally determine the right sockopt to call.

This should shorten code that generically wants to support both ipv4 +
ipv6 and for the first time adds correct support for some cases where we
only called the ipv4 versions, and not the ipv6 options.
2020-09-11 10:33:13 +02:00
Lennart Poettering 00df39a56a timesyncd: don't attempt to call IP_TOS sockopt on IPv6 sockets 2020-09-11 10:16:39 +02:00
lichangze 7c5c59d4b1 hostnamed: map 'all-in-one' DMI chassis type to desktop 2020-09-11 09:55:44 +02:00
Zbigniew Jędrzejewski-Szmek f8bff7805e
Merge pull request #16933 from poettering/copy-hardlinks
copy: optionally recreate hardlinks when copying file trees
2020-09-10 19:04:52 +02:00
Daniel Mack 3db468ea87 network: add support for setting MDB entries
Multicast snooping enabled bridges maintain a database for multicast
port memberships to decide which mulicast packet is supposed to
egress on which port.

This patch teaches networkd to add entries to this database manually
by adding `[BridgeMDB]` sections to `.network` configuration files.
2020-09-10 18:55:15 +02:00
Lennart Poettering 6ae05c9b14
Merge pull request #16947 from keszybz/socket-parsing-rework
Socket parsing rework
2020-09-10 16:47:37 +02:00
Zbigniew Jędrzejewski-Szmek f29d38b7d4
Merge pull request #17003 from yuwata/conf-parser-downgrade-log-level
tree-wide: downgrade log level in conf-parsers
2020-09-10 15:43:29 +02:00
Daniel Mack 1903c9bbbb sd-netlink: add MDB types
These are used to configure multicast membership entries of bridge ports.
2020-09-10 15:29:14 +02:00
Lennart Poettering 3a17308c2a
Merge pull request #16986 from yuwata/network-fix-routing-policy-rule-issue-16784
network: fix routing policy rule issue
2020-09-10 14:50:38 +02:00
Lennart Poettering dee00c1939 fs-util,tmpfiles: fix error handling of fchmod_opath()
When 4dfaa528d4 was first commited its callers relied on `errno` instead of the
return value for error reporting. Which worked fine, since internally
under all conditions base were set — even if ugly and not inline with
our coding style. Things then got broken in
f8606626ed where suddenly additional
syscalls might end up being done in the function, thus corrupting `errno`.
2020-09-10 12:47:50 +02:00
Lennart Poettering c1b9708c10 bootctl: don't accidentally propagate errors in "bootctl status"
Fixes: #16989
2020-09-10 12:45:54 +02:00
Yu Watanabe 17d2b2e4ef network: replace FRA_IFNAME -> FRA_IIFNAME
No functional change, as FRA_IFNAME is an alias of FRA_IIFNAME.
2020-09-10 18:57:07 +09:00
Yu Watanabe 2102d33cfb network: also process RTM_NEWRULE or RTM_DELRULE message which does not contain src and dst addresses
Fixes #16784.
2020-09-10 18:57:07 +09:00
Yu Watanabe bd1000b4a0 network: fix the default mask for FirewallMark=
And always send FRA_FWMASK if FirewallMark= is set.

C.f. b8964ed9fa

Partially fixes #16784.
2020-09-10 18:56:18 +09:00
Yu Watanabe c2d6fcb147 network: do not assign return value if the parse_fwmark_fwmask() fails
This also removes redundant logs, and makes input string not copied if
it does not contain '/'.
2020-09-10 18:19:03 +09:00
Yu Watanabe d85b0d69f1 network: add debug log for removing routing policy rules 2020-09-10 18:19:03 +09:00
Yu Watanabe 755dbda355 network: also logs priority of routing policy rules 2020-09-10 18:18:59 +09:00
Yu Watanabe b6c7c4a87b network: update log message for rtnl messages 2020-09-10 18:14:24 +09:00
Yu Watanabe 323dda7806 core: downgrade error level and ignore several non-critical errors 2020-09-10 16:24:31 +09:00
Yu Watanabe 144fb165fd homed: downgrade log level 2020-09-10 15:21:43 +09:00
Yu Watanabe adb5848706 journal: downgrade log level 2020-09-10 15:20:35 +09:00
Yu Watanabe 196d41bcde login: downgrade log level if the error will be ignored 2020-09-10 15:18:26 +09:00
Yu Watanabe a864170745 nspawn: downgrade log level if the error will be ignored 2020-09-10 15:16:14 +09:00
Yu Watanabe e459258f19 repart: downgrade log level 2020-09-10 15:08:13 +09:00
Yu Watanabe 94069bef23 resolve: downgrade error level when the error will be ignored 2020-09-10 15:06:29 +09:00
Yu Watanabe 34136e1503 resolve: check DNSSD service name template before assigning it 2020-09-10 15:05:19 +09:00
Yu Watanabe 7a602af041 conf-parser: logs about OOM error 2020-09-10 14:14:19 +09:00
Yu Watanabe 3de39a1ad4 conf-parser: use SYNTHETIC_ERRNO() at one more place 2020-09-10 14:13:56 +09:00
Yu Watanabe c56566530b timesync: downgrade error level when the error will be ignored 2020-09-10 14:13:26 +09:00
Yu Watanabe 40f04cde5b xdg-autostart-generator: downgrade error level when the error will be ignored 2020-09-10 14:07:56 +09:00
Yu Watanabe 8add8b508d vlan: downgrade error level if the error will be ignored 2020-09-10 13:59:04 +09:00
Yu Watanabe 4c382a8772 ethtool: downgrade log level when the error will be ignored 2020-09-10 13:59:04 +09:00
Yu Watanabe e3489e96b3 network: slightly update log message 2020-09-10 13:59:04 +09:00
Yu Watanabe 2ca601d8cb network do not ignore OOM error in config_parse_macsec_key_id() 2020-09-10 13:59:04 +09:00
Yu Watanabe 696c0832e2 network: use _cleanup_ attribute at one more place 2020-09-10 13:59:04 +09:00
Yu Watanabe a8a50f4fb7 network: do not ignore OOM error in wireguard_decode_key_and_warn() 2020-09-10 13:59:04 +09:00
Yu Watanabe 02241e4339 network: unify config_parse_wireguard_public_key() and config_parse_wireguard_preshared_key() 2020-09-10 13:57:39 +09:00
Yu Watanabe c799c93c62 udev: fix indentation
Follow-up for 90e30d767a.
2020-09-10 13:11:43 +09:00
Zbigniew Jędrzejewski-Szmek c097bf1f50 Minor simplification in sockaddr_un_set_path() 2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 08224f38ac Use sockaddr_un_set_path() in socket_address_parse()
Two functional changes:
- "/" is now refused. The test is adjusted.
- The trailing NUL is *not* included in the returned size for abstract size. The
  comments in sockaddr_un_set_path() indicate that this is the right thing to do,
  and the code in socket_address_parse() wasn't doing that.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek a73569f180 shared/socket-netlink: set output in socket_address_parse_netlink() only on success 2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek a07ab56a49 Allow interface scopes to be specified in ListenStream=
Closes #12624.

The formatting in systemd.socket.xml is updated a bit.

Currently in_addr_port_ifindex_name_to_string() always prints the ifindex
numerically. This is not super useful since the interface numbers are
semi-random. Should we use interface names in preference?
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek c4c6ee3a95 resolved: drop duplicated check
The same conditional appears a few lines down.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 44ab234734 shared: don't unconditionally set SOCK_STREAM as type in socket_address_parse()
We would set .type to a fake value. All real callers (outside of tests)
immediately overwrite .type with a proper value after calling
socket_address_parse(). So let's not set it and adjust the few places
that relied on it being set to the fake value.

socket_address_parse() is modernized to only set the output argument on
success.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 75af1666d7 shared: make socket_address_parse use the generic parser for IPv[46] addresses
One special syntax is not supported anymore: "iface:port" would be parsed as an
interface name plus numerical port, equivalent to "[::]%iface:port". This was
added in 542563babd, but was undocumented, and we had no tests for it. It seems
that this actually wasn't doing anything useful, because the kernel only uses the
scope identifier for link-local addresses.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 222eaaf937 Get rid of in_addr_port_from_string_auto() again
With the commit "shared/socket-netlink: only allow ifindex if explicitly supported"
this helper is not necessary anymore.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek c1f848d73c shared: check interface name validity in in_addr_port_ifindex_name_from_string_auto()
We don't try to resolve invalid ifnames as all. A different return
code is used. This difference will be verified later in test_socket_address_parse()
when socket_address_parse() is converted to use
in_addr_port_ifindex_name_from_string_auto().
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek b16d17a68a basic: show interface scope in sockaddr_pretty()
If the interface scope is specified, this changes the meaning of the address
quite significantly. Let's show the IPv6 scope_id if present.

Sadly we don't even have a test for sockaddr_pretty() output :(
This will be implicitly tested through socket_address_parse() later on.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 2313524aa0 basic: convert ifname_valid_full() to take flags and allow numeric interfaces 2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 25b2d602b9 shared/socket-netlink: only allow ifindex if explicitly supported
Instead of ignoring ifindex if not wanted, refuse it is the caller
does not allow it.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 610618ff61 test-socket-netlink: print the proper expected string
We would use the return value from the tested function to decide
what to print as "expected", which is confusing when something is wrong
with the tested function.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 38c30b35f3 test-in-addr-util: add log headers 2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek d491917c9f resolved: unify the two functions to create main stubs
There is a small functional difference: IP_TTL==1 is now also set for the UDP
socket. I assume that it wasn't set by mistake.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek b5febb3f56 resolved: unify the two functions to create extra stubs
There is a minor functional change:
IPV6_FREEBIND is set of IPv6 sockets, not IP_FREEBIND. This was missed in
af8b1384, but I noticed only after the merging the two functions.

And a not-so-minor functional chagnge:
7216a3b5dc changed manager_dns_stub_tcp_fd_extra() to return the fd even
if the source was already initialized, but it didn't do the same change for
manager_dns_stub_udp_fd_extra(), so it would return 0 in that case. But
0354029bf5 uses manager_dns_stub_udp_fd_extra() when preparing to call
manager_send(), and will pass 0 as the fd in that case. For both socket types
fd is now always returned.
2020-09-10 00:44:53 +02:00
Zbigniew Jędrzejewski-Szmek e4bed40f40 resolve: move handler functions higher
No functional change, preparation for subsequent refactoring.
2020-09-10 00:06:35 +02:00
Lennart Poettering d8ea7f838b ethtool-util: don't pass error value that isn't used to log_syntax 2020-09-09 23:43:20 +02:00
Lennart Poettering e5f1b999eb network: don't fail on various config parse errors
We typically don't fail on config parse errors (to maximize compat),
let's not do this in these cases either.
2020-09-09 23:43:16 +02:00
Lennart Poettering 40eb1b0ae8 tree-wide: prefer AF_xyz over PF_xyz
This really doesn't matter given that AF_xyz and PF_xyz are equivalent
in all ways, but we almost always use AF_xyz, hence stick to it
universally and convert the remaining PF_ to AF_
2020-09-09 23:42:55 +02:00
Zbigniew Jędrzejewski-Szmek 2bb4d58eba
Merge pull request #16985 from poettering/resolve-dns-stub-extra-fixlets
resolved: dns stub listener extra fixes
2020-09-09 22:03:31 +02:00
Zbigniew Jędrzejewski-Szmek 5887cd7130
Merge pull request #16997 from poettering/foreach-word-followup
fix two coverity issues
2020-09-09 22:00:27 +02:00
Mikael Szreder 664ad0f6f5
cryptsetup: Fix null pointer dereference (#16987)
cryptsetup: Fix null pointer dereference

Fix null pointer dereference in the pkcs11 related code of systemd-cryptsetup
2020-09-09 21:26:21 +02:00
Lennart Poettering 652d90407a tree-wide: copy hardlinks wherever we deal with possibly large OS-style trees
Fixes: #7382
2020-09-09 20:21:49 +02:00
Lennart Poettering dd480f7835 copy: optionally, reproduce hardlinks from source in destination
This is useful for duplicating trees that contain hardlinks: we keep
track of potential hardlinks and try to reproduce them within the
destination tree. (We do not hardlink between source and destination!).

This is useful for trees like ostree images which heavily use hardlinks
and which are otherwise exploded into separate copies of all files when
we duplicate the trees.
2020-09-09 20:21:29 +02:00
Lennart Poettering 7a7e97ad94 sd-login: fix memory leak
Fixes: CID1432652
2020-09-09 20:14:30 +02:00
Lennart Poettering 4934ba2121 socket: fix copy/paste error
Fixes: CID1432653
2020-09-09 20:14:25 +02:00
Lennart Poettering 197db625a3 logind: fix merge issue
The two PRs #16664 and #16635 individually passed CI, but when combined
cannot build. Since both are merged now, let's fix that.
2020-09-09 20:13:57 +02:00
Robert Marko adbb2b6afe login: Add KEY_RESTART handling
KEY_RESTART is widely used in Linux to indicate device reboot.
So lets handle it in the same fashion as KEY_POWER.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2020-09-09 18:40:13 +02:00
Franck Bui 6e220b4b88 logind.conf: document UserStopDelaySec in logind.conf 2020-09-09 17:46:00 +02:00
Lennart Poettering 12ce0f4173
Merge pull request #16635 from keszybz/do-not-for-each-word
Drop FOREACH_WORD
2020-09-09 17:43:38 +02:00
Lennart Poettering a6b3be1abf
Merge pull request #16972 from wusto/ambient-and-keep-caps-corrections
Ambient capabilities documenation and keep-caps usage corrections
2020-09-09 17:09:42 +02:00
Zbigniew Jędrzejewski-Szmek 172338d51b systemctl: list unit introspection verbs first, modification second
The list was rather ad hoc, with "reset-failed" sandwiched between
"help" and "list-dependencies". Since a person will usually either want
to introspect state in various ways or modify state in a certain way, let's
put all the introspection commands together and all the ones that actually
have an effect second.
2020-09-09 16:59:18 +02:00
Lennart Poettering 244d9793ee
Merge pull request #16984 from yuwata/make-log_xxx_error-void
Make log_xxx_error() or friends return void
2020-09-09 16:28:51 +02:00
Tobias Kaufmann 198dc17845 core: fix set keep caps for ambient capabilities
The securebit keep-caps retains the capabilities in the permitted set
over an UID change (ambient capabilities are cleared though).

Setting the keep-caps securebit after the uid change and before execve
doesn't make sense as it is cleared during execve and there is no
additional user ID change after this point.

Altough the documentation (man 7 capabilities) is ambigious, keep-caps
is reset during execve although keep-caps-locked is set. After execve
only keep-caps-locked is set and keep-caps is cleared.
2020-09-09 11:17:42 +02:00
Tobias Kaufmann 16fcb1918a core: fix comments on ambient capabilities
The comments on the code for ambient capabilities was wrong/outdated.
2020-09-09 11:17:42 +02:00
Zbigniew Jędrzejewski-Szmek 90e30d767a Rename strv_split_extract() to strv_split_full()
Now that _full() is gone, we can rename _extract() to have the usual suffix
we use for the more featureful version.
2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 03b62851a9 Remove FOREACH_WORD and friends 2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 0645b83a40 tree-wide: replace strv_split_full() with strv_split_extract() everywhere
Behaviour is not identical, as shown by the tests in test-strv.
The combination of EXTRACT_UNQUOTE without EXTRACT_RELAX only appears in
the test, so it doesn't seem particularly important. OTOH, the difference
in handling of squished parameters could make a difference. New behaviour
is what both bash and python do, so I think we can ignore this corner case.

This change has the following advantages:
- the duplication of code paths that do a very similar thing is removed
- extract_one_word() / strv_split_extract() return a proper error code.
2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek d59d954d7f test-string-util: stop testing FOREACH_WORD 2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 45638a63c0 shared/fstab-util: replace FOREACH_WORD_SEPARATOR() with open-coded loop
The tricky part here is that the function is not allowed to fail in this code
path. Initially, I wanted to change the return value to allow it to fail, but
this cascades through all the places where fstab_test_option() and friends are
used; updating all those sites would be a lot of work. And since quoting is not
allowed here, a simple loop with strcspn() is easy to do.
2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 0e8d185938 shared/fstab-util: use free_and_str[n]dup()
No functional change. I'm keeping this separate to make review easier.
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek ecaf258eb4 Use extract_first_word() in generated conf parsers 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 087908c140 nspawn: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 2417658d6a getty-generator: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek da277e90a4 sd-journal: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek cc24f0b872 delta: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek dd2fff3a18 cryptsetup: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 7896ad8f66 core/load-fragment: use extract_first_word()
This is much nicer, and also fixes a potential overflow when we used
'word' in log_error() as if it was a NUL-terminated string.
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek dd630d3cac Let sd_machine_get_ifindices() omit the output param too
Nowadays we do that almost everywhere, let's also do it here.
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 0ef14adc1c Rewrite sd_machine_get_ifindices() to avoid FOREACH_WORD()
If we fail to parse the index, the failure is propogated as -EUNCLEAN.
(-EINVAL would be confused with invalid args to the function itself.)
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek aa3b40c3f9 Fix output value of sd_seat_get_sessions() and drop FOREACH_WORD use
sd_seat_get_sessions() would return 0 in the 'n_uids' (now 'ret_n_uids') output
parameter when 'uid' (now 'ret_uids') was passed as NULL.

While at it, drop FOREACH_WORD() use.

Also use any whitespace as separator. In practice this shouldn't matter, since
logind always uses spaces, but it seems nicer to not specify this explicitly,
and the default is more flexible.
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 87a4d416e5 sd-device: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek ae7ef63f21 basic/cgroup-util: port over to string_contains_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 46ed9f4ce1 logind: use extract_first_word() 2020-09-09 09:34:54 +02:00
Yu Watanabe e77f52e5f9 udev: warn if failed to set buffer size for device monitor 2020-09-09 06:46:54 +09:00
Yu Watanabe a725efb08b network: increase receive buffer size for device monitor
If networkd creates huge amount of netdevs, then the buffer of device
monitor becomes easily flowed.

Hopefully fixes #16865.
2020-09-09 06:39:05 +09:00
Yu Watanabe d31f33e3c9 network: do not start device monitor if /sys is read-only
Follow-up for bf331d8717.
2020-09-09 06:39:05 +09:00
Yu Watanabe e13af7bdb6 network: honor the buffer size specified in networkd.socket 2020-09-09 06:39:05 +09:00