Commit Graph

46997 Commits

Author SHA1 Message Date
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 60bcb45927 man: rework UMask= explanation
Mention the JSON user record stuff. Mention pam_umask explicitly.
Mention that UMask= of the per-user user@.service instance can be used
too.

Fixes: #16963
2020-09-14 21:44:06 +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
Lennart Poettering 0c94a31464
Merge pull request #17027 from poettering/env-escape-fix
make sure we our env file writer, parser and shell agree on things
2020-09-14 16:48:00 +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
Lennart Poettering 415f8a5bfe man: document that RemainAfterElapse=no means that also the triggered unit needs to deactivate
Fixes: #16378
2020-09-14 10:17:41 +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 95f7ab2fe6 mkosi: include libfido2 in fedora mkosi image
We want to build this image with as many deps turned on as we can make
happen, hence include libfido2 in the image.
2020-09-12 08:10:08 +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
Nazar Vinnichuk 5501da15ba man: document the random delay of persistent timers
The manual states that a persistent timer triggers it's service
immediately on activation to catch up with missed invocations, but since
PR #11608 it is no longer the case if RandomizedDelaySec= is set to a
non-zero value.
2020-09-11 18:08:40 +02:00
Yu Watanabe 766f8f388f test-network: add test for ENOBUFS issue #17012
The issue seems already fixed by PR #16982 and its follow-up commit
4934ba2121.
2020-09-11 18:07:47 +02:00
Lennart Poettering e67b818c2f unit: declare BusName= in all our units that are on the bus, event if they don't use Type=dbus
This information is always useful, so let's always declare it,
particular in the light of #16976.
2020-09-11 16:01:22 +02:00
Lennart Poettering f7c87baeca
Merge pull request #17020 from yuwata/backlight
backlight: validate sysattr value
2020-09-11 14:23:47 +02:00