Commit Graph

46619 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek d0e5db44d9 sd-bus: allow localhost addresses
By settings AI_ADDRCONFIG in hints we cannot for example resolve "localhost"
when the local machine only has a loopback interface. This seems like an
unnecessary restriction, drop it.

Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=1839007.
2020-09-15 16:45:03 +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 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 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 a1447e77a7
Merge pull request #16973 from poettering/btrfs-dev-root
print friendly error message if btrfs tells us /dev/root was backing block device of root fs
2020-09-08 19:55:12 +02:00
Lennart Poettering f3f4abad29
Merge pull request #16979 from keszybz/return-log-debug
Fix 'return log_error()' and 'return log_warning()' patterns
2020-09-08 19:54:38 +02:00
Michal Sekletár 9a1e90aee5 cgroup: freezer action must be NOP when cgroup v2 freezer is not available
Low-level cgroup freezer state manipulation is invoked directly from the
job engine when we are about to execute the job in order to make sure
the unit is not frozen and job execution is not blocked because of
that.

Currently with cgroup v1 we would needlessly do a bunch of work in the
function and even falsely update the freezer state. Don't do any of this
and skip the function silently when v2 freezer is not available.

Following bug is fixed by this commit,

$ systemd-run --unit foo.service /bin/sleep infinity
$ systemctl restart foo.service
$ systemctl show -p FreezerState foo.service

Before (cgroup v1, i.e. full "legacy" mode):
FreezerState=thawing

After:
FreezerState=running
2020-09-08 19:54:13 +02:00
Lennart Poettering c6552f7cd5
Merge pull request #16955 from keszybz/test-execute-cleanup
One patch for test-execute and assorted cleanups
2020-09-08 18:33:12 +02:00
Lennart Poettering d161680e7a tree-wide: if get_block_device() returns zero devno, check for it in all cases
And add a comment for the existing cases where things aren't clear
already.
2020-09-08 18:10:26 +02:00
Lennart Poettering 67f0ac8c79 btrfs: if BTRFS_IOC_DEV_INFO returns /dev/root generate a friendly error message
On systems that boot without initrd on a btrfs root file systems the
BTRFS_IOC_DEV_INFO ioctl returns /dev/root as backing device. That
sucks, since that is not a real device visible to userspace.

Since this has been that way since forever, and it doesn't look like the
kernel will get fixed soon for this, let's at least generate a useful
error message in this case.

This is not a bug fix, just a tweak to make this more recognizable.

Once the kernel gets fixed to report the correct device nodes in this
case, in a way userspace can make sense of them things will magically
work for systemd, too.

(Note that this doesn't add a log message about this to really all cases
we call get_device() in, but just the main ones that are called in early
boot context, after all all there's no benefit in seeing this message
too many times.)

https://github.com/systemd/systemd/issues/16953
https://bugs.freedesktop.org/show_bug.cgi?id=84689
https://bugzilla.kernel.org/show_bug.cgi?id=89721
2020-09-08 18:10:26 +02:00
Zbigniew Jędrzejewski-Szmek 1c5950bd61 sleep: reword some debug messages
I think the sentences sound more natural this way.
2020-09-08 17:40:46 +02:00
Zbigniew Jędrzejewski-Szmek 44f0dd628c basic/log: make log_{info,warning,...} return void
log_debug still returns 0. I think it is legitimate to use 'return log_debug()' to
return 0. It is different than the other functions, since we often want to supress
errors logged at debug level. This case is quite common in the codebase and
we could use 'return log_debug_errno()' to make the code more consise.

For all other variants, a separate return line is required.
Previous commit changes all the non-conforming instances, now we can make it mandatory.
2020-09-08 17:40:46 +02:00
Zbigniew Jędrzejewski-Szmek c413bb28df tree-wide: correct cases where return log_{error,warning} is used without value
In various cases, we would say 'return log_warning()' or 'return log_error()'. Those
functions return 0 if no error is passed in. For log_warning or log_error this doesn't
make sense, and we generally want to propagate the error. In the few cases where
the error should be ignored, I think it's better to split it in two, and call 'return 0'
on a separate line.
2020-09-08 17:40:46 +02:00
Zbigniew Jędrzejewski-Szmek fc706b4816 man: fix quickhelp listing in sysusers.d(5)
Fixes #16958.
2020-09-08 17:30:42 +02:00
Lennart Poettering 26c65933ba
Merge pull request #16978 from keszybz/two-variable-reduction-patches
Two variable reduction patches
2020-09-08 17:13:21 +02:00
Zbigniew Jędrzejewski-Szmek a9aa8deb29
Merge pull request #16618 from yuwata/network-ipv6token-prefixstable
network: make prefixstable mode of IPv6Token= can be applied any received prefixes
2020-09-08 13:36:27 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Zbigniew Jędrzejewski-Szmek 12375b95dd core/unit: reduce scope of variables 2020-09-08 12:07:05 +02:00
Zbigniew Jędrzejewski-Szmek 8195283265
Merge pull request #16725 from yuwata/network-fix-ndisc-multiple-routers
network: fix NDisc behavior when multiple routers exist
2020-09-08 08:16:33 +02:00
Michal Sekletár 332d387f47 core: introduce support for setting NUMAMask= to special "all" value
Fixes #14113
2020-09-08 08:16:03 +02:00
Yu Watanabe 68248f43fc test-network: add test for IPv6Token=prefixstable 2020-09-08 14:32:44 +09:00
Yu Watanabe b27caa34f6 network: make prefixstable mode of IPv6Token= can be applied to any received prefixes
Closes #4625.
2020-09-08 14:32:33 +09:00
Yu Watanabe 50550722e3 network: fix NDisc handling for the case when multiple routers exist
69203fba70 does not consider the case that
multiple routers exist, and causes #16719.

Fixes #16719.
2020-09-08 02:30:04 +09:00
Yu Watanabe 501b09dbf2 network: expose route_{hash,compare}_func() 2020-09-08 02:30:04 +09:00
Yu Watanabe 99a2878457 network: expose address_{hash,compare}_func() 2020-09-08 02:30:04 +09:00
Yu Watanabe badd49288d util: expose in6_addr_{hash,compare}_func() 2020-09-08 02:30:04 +09:00
Zbigniew Jędrzejewski-Szmek 6743a1caf4
Merge pull request #16928 from poettering/statx-fallback
stat-util: provide single statx() fallback on top of fstatat()
2020-09-05 22:04:18 +02:00
Christian Göttsche e813a74ae8 selinux: create /run/user/${USERID}/systemd with default context 2020-09-05 21:39:44 +02:00
Christian Göttsche 1006038cf1 selinux: early exit in mac_selinux_maybe_reload if not initialized
Binaries might not initialize SELinux, e.g. when they normally do not
create files with the SELinux default context.
If they, via an internal libary function, call a _label() function,
mac_selinux_maybe_reload() gets called. Since the SELinux status page
has not been opened, selinux_status_updated() will fail with EINVAL.

This affects particularly test binaries.

Just exit early and avoid confusing debug logs.
2020-09-05 21:39:12 +02:00
George Rawlinson 22c2f841db man: fix typo in resolved.conf 2020-09-05 21:38:01 +02:00
Zbigniew Jędrzejewski-Szmek ad161cd6bb
Merge pull request #16951 from yuwata/resolve-follow-ups-for-extra-dns-stub-listener
resolve: follow-ups for extra DNS stub listener
2020-09-05 15:55:22 +02:00
Zbigniew Jędrzejewski-Szmek 5615e92efa
Merge pull request #16854 from yuwata/sd-bus-error-set-errnofv
sd-bus: rework sd_bus_error_set_errnofv()
2020-09-05 15:47:37 +02:00
Zbigniew Jędrzejewski-Szmek 7de6b05160
Merge pull request #16957 from poettering/sd-bus-proto-def-move
three unrelated, minor fixes
2020-09-05 12:06:15 +02:00
Lennart Poettering 8d91b2206c varlink: properly allocate connection event source
Let's make sure we keep a reference to the event source

(Note that this code is currently not used, which is why this was never
used: in all cases we do not add listener fds after the event is
attached, but before. In that case this code is not called.)
2020-09-04 23:54:14 +02:00
Lennart Poettering 1ba37106b3 ptyfwd: don't set prio if event source that might not exist
We support read-only ptyfwd options, and on those the input event source
won't be allocated. Deal with that and don't invoke a function on it
that will then instantly fail.
2020-09-04 23:52:41 +02:00
Lennart Poettering fb2cfa6c13 sd-bus: move SD_BUS_MAXIMUM_(SIGNATURE|NAME)_LENGTH to sd-bus-protocol.h
So far we kept all defines directly originating from the spec in
sd-bus-protocol.h, do this for this too.

The precise place doesn't matter much API-wise given that sd-bus.h includes
sd-bus-protocol.h, hence let's just clean this up.
2020-09-04 23:51:21 +02:00
Zbigniew Jędrzejewski-Szmek d11578f30e test-sizeof: print pointer sizes
This is useful information, I don't know why we forgot to add it there.

gcc doesn't like arithemetic on a pointer to a function or void*, so don't
print signedness info there. It doesn't matter anyway.
C says function pointers can be different... Though I guess our code isn't
prepared for that.
2020-09-04 18:45:44 +02:00
Zbigniew Jędrzejewski-Szmek a9030b81c1 udev-test: do not rely on "mail" group being defined
"audio" should be there, at least we declare it. "mail" nowadays is less
likely to exist than in the past.

Fixes one of the items in #16942.
2020-09-04 18:45:44 +02:00
Zbigniew Jędrzejewski-Szmek cced2b98ef test-execute: check if private directories have bad permissions before running test_exec_dynamicuser()
If the directory (/var/lib/private is most likely) has borked permissions, the
test will fail with a cryptic message and EXIT_STATE_DIRECTORY or similar. The
message from the child with more details gets lost somewhere. Let's avoid running
the test in that case and provide a simple error message instead.

E.g. systemd-238-12.git07f8cd5.fc28.ppc64 (which I encountered on a test machine)
has /var/lib/private with 0755.
2020-09-04 18:45:44 +02:00
Zbigniew Jędrzejewski-Szmek 9978e631cd core/manager: reindent table for readability 2020-09-04 18:14:26 +02:00
Zbigniew Jędrzejewski-Szmek 5b10116e49 core/{execute, manager}: reduce scope of iterator variables a bit 2020-09-04 18:14:26 +02:00
Zbigniew Jędrzejewski-Szmek 0b3861d224 test-execute/exec-dynamicuser-statedir.service: fix quoting
All backslashes that should be single in shell syntax need to be written as "\\" because
our parser will remove one level of quoting. Also, single quotes were doubly nested, which
cannot work.

Should fix the following message:
test-execute/exec-dynamicuser-statedir.service:16: Ignoring unknown escape sequences: "test $$(find / \( -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o -path /sys/fs/bpf -o -path /dev/.lxc \) -prune -o -type d -writable -print 2>/dev/null | sort -u | tr -d \\n) = /var/lib/private/quux/pief/var/lib/private/waldo"
2020-09-04 18:11:22 +02:00
Zbigniew Jędrzejewski-Szmek f90d2d7bf1 test-execute: simplify condition
tests is always a static array, it cannot be NULL.
2020-09-04 18:11:22 +02:00
Luca Boccassi 836540070d core: add [Enable|Disable]UnitFilesWithFlags DBUS methods
The new methods work as the unflavoured ones, but takes flags as a
single uint64_t DBUS parameters instead of different booleans, so
that it can be extended without breaking backward compatibility.
Add new flag to allow adding/removing symlinks in
[/etc|/run]/systemd/system.attached so that portable services
configuration files can be self-contained in those directories, without
affecting the system services directories.
Use the new methods and flags from portablectl --enable.

Useful in case /etc is read-only, with only the portable services
directories being mounted read-write.
2020-09-04 17:56:37 +02:00
Yu Watanabe f3f14c573b util: constify the second argument of set_get() 2020-09-04 17:52:26 +02:00
Yu Watanabe 89f7435d0c resolve: use correct fd for UDP stub listner 2020-09-04 23:54:35 +09:00
Yu Watanabe d1fb8cdae2 resolve: do not check sender and destination for packet received by extra DNS stub listner 2020-09-04 23:54:35 +09:00
Yu Watanabe 7216a3b5dc resolve: use sd_event_source_set_io_fd_own() for stub listners 2020-09-04 23:54:35 +09:00