summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--README5
-rw-r--r--TODO7
-rw-r--r--hwdb/70-mouse.hwdb12
-rw-r--r--man/systemd.service.xml13
-rw-r--r--rules/60-persistent-storage.rules2
-rw-r--r--shell-completion/bash/machinectl7
-rw-r--r--shell-completion/bash/systemctl.in2
-rw-r--r--shell-completion/zsh/_busctl15
-rw-r--r--src/basic/def.h1
-rw-r--r--src/boot/bootctl.c2
-rw-r--r--src/bus-proxyd/bus-proxyd.c7
-rw-r--r--src/bus-proxyd/stdio-bridge.c7
-rw-r--r--src/core/automount.c1
-rw-r--r--src/core/service.c1
-rw-r--r--src/core/socket.c1
-rw-r--r--src/core/timer.c1
-rw-r--r--src/dbus1-generator/dbus1-generator.c9
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c188
-rw-r--r--src/import/pull-tar.c8
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c6
-rw-r--r--src/libsystemd/sd-bus/bus-control.c1
-rw-r--r--src/libsystemd/sd-bus/bus-convenience.c1
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c2
-rw-r--r--src/libsystemd/sd-bus/bus-internal.c42
-rw-r--r--src/libsystemd/sd-bus/bus-internal.h26
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c1
-rw-r--r--src/libsystemd/sd-bus/bus-match.c1
-rw-r--r--src/libsystemd/sd-bus/bus-message.c5
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c1
-rw-r--r--src/libsystemd/sd-bus/bus-track.c1
-rw-r--r--src/libsystemd/sd-bus/busctl.c1
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c15
-rw-r--r--src/libsystemd/sd-bus/test-bus-benchmark.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-cleanup.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-error.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-gvariant.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-kernel.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-objects.c1
-rw-r--r--src/libsystemd/sd-bus/test-bus-server.c1
-rw-r--r--src/libsystemd/sd-daemon/sd-daemon.c14
-rw-r--r--src/libsystemd/sd-netlink/netlink-message.c2
-rw-r--r--src/login/logind-inhibit.c16
-rw-r--r--src/nss-myhostname/nss-myhostname.c3
-rw-r--r--src/resolve-host/resolve-host.c4
-rw-r--r--src/resolve/resolved-dns-query.c166
-rw-r--r--src/resolve/resolved-dns-scope.c8
-rw-r--r--src/shared/bus-util.c34
-rw-r--r--src/shared/bus-util.h28
-rw-r--r--src/systemctl/systemctl.c1
-rw-r--r--src/udev/udev-builtin-blkid.c5
-rw-r--r--src/udev/udev-ctrl.c3
54 files changed, 451 insertions, 237 deletions
diff --git a/NEWS b/NEWS
index 97dd000d4e..fe5eb31672 100644
--- a/NEWS
+++ b/NEWS
@@ -756,7 +756,7 @@ CHANGES WITH 218:
* When querying unit file enablement status (for example via
"systemctl is-enabled"), a new state "indirect" is now known
which indicates that a unit might not be enabled itself, but
- another unit listed in its Alias= setting might be.
+ another unit listed in its Also= setting might be.
* Similar to the various existing ConditionXYZ= settings for
units there are now matching AssertXYZ= settings. While
diff --git a/README b/README
index 7595949765..d84bf8ea69 100644
--- a/README
+++ b/README
@@ -274,8 +274,3 @@ WARNINGS:
servers if not specified otherwise at configure time. You
really should not ship an OS or device with this default
setting. See DISTRO_PORTING for details.
-
-ENGINEERING AND CONSULTING SERVICES:
- ENDOCODE <https://endocode.com/> offers professional
- engineering and consulting services for systemd. Please
- contact Chris Kühl <chris@endocode.com> for more information.
diff --git a/TODO b/TODO
index 81cd353a5a..c5af6ce392 100644
--- a/TODO
+++ b/TODO
@@ -26,6 +26,12 @@ External:
Features:
+* PID 1 should send out sd_notify("WATCHDOG=1") messages (for usage in the --user mode, and when run via nspawn)
+
+* nspawn should send out sd_notify("WATCHDOG=1") messages
+
+* nspawn should optionally support receiving WATCHDOG=1 messages from its payload PID 1...
+
* introduce "machinectl shell" that is like systemd-run -M foo /bin/bash -t but also adds PAMName=login
* allow loging into host with "machinectl login".
@@ -464,6 +470,7 @@ Features:
ReadOnlyDirectories=... for whitelisting files for a service.
* sd-bus:
+ - figure out wat the UNPRIVILEGED flag shall mean for props that can be read *and* written
- GetAllProperties() on a non-existing object does not result in a failure currently
- kdbus: process fd=-1 for incoming msgs
- port to sd-resolve for connecting to TCP dbus servers
diff --git a/hwdb/70-mouse.hwdb b/hwdb/70-mouse.hwdb
index 7373be4778..1451fc02cc 100644
--- a/hwdb/70-mouse.hwdb
+++ b/hwdb/70-mouse.hwdb
@@ -171,6 +171,8 @@ mouse:usb:v17efp6044:name:ThinkPad USB Laser Mouse:
# Logitech M-BJ58 Optical Mouse
mouse:usb:v046dpc00e:name:Logitech USB-PS/2 Optical Mouse:
+# Logitech Mini Optical Mouse
+mouse:usb:v046dpc016:name:Logitech Optical USB Mouse:
# Logitech MX310 Optical Mouse
mouse:usb:v046dpc01b:name:Logitech USB-PS/2 Optical Mouse:
# Logitech USB-PS/2 M-BT58
@@ -219,6 +221,8 @@ mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:4008:
# Logitech M705 (marathon mouse)
mouse:usb:v046dp101b:name:Logitech M705:
mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:101b:
+# Logitech Performance MX
+mouse:usb:v046dp101a:name:Logitech Performance MX:
MOUSE_DPI=800@166
# Logitech MX Revolution
@@ -300,6 +304,10 @@ mouse:usb:v046dpc068:name:Logitech G500:
mouse:bluetooth:v046dpb00d:name:Ultrathin Touch Mouse:
MOUSE_DPI=1000@1000
+# ImPS/2 Logitech Wheel Mouse
+mouse:ps2:*:name:ImPS/2 Logitech Wheel Mouse:
+ MOUSE_DPI=400@100
+
# ImExPS/2 Logitech Wheel Mouse
mouse:ps2:*:name:ImExPS/2 Logitech Wheel Mouse:
MOUSE_DPI=400@250
@@ -314,6 +322,10 @@ mouse:usb:v045ep0040:name:Microsoft Microsoft 3-Button Mouse with IntelliEye(TM)
# Note: unsure that these work, it's likely that all devices on these
# receivers show up with the same vid/pid/name
+# Microsoft Wireless Mouse 5000
+mouse:usb:v045ep0745:name:Microsoft Microsoft® 2.4GHz Transceiver v6.0:
+ MOUSE_DPI=800@142
+
# Microsoft Sculpt Ergonomic Mouse
mouse:usb:v045ep07a5:name:Microsoft Microsoft® 2.4GHz Transceiver v9.0:
MOUSE_DPI=1000@142
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 7e96989583..4c113a3479 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -337,6 +337,19 @@
<literal>-</literal>) fail, the rest are not executed and the
unit is considered failed.</para>
+ <para><varname>ExecStart=</varname> commands are only run after
+ all <varname>ExecStartPre=</varname> commands that were not prefixed
+ with a <literal>-</literal> exit successfully.</para>
+
+ <para><varname>ExecStartPost=</varname> commands are only run after
+ the service has started, as determined by <varname>Type=</varname>
+ (i.e. The process has been started for <varname>Type=simple</varname>
+ or <varname>Type=idle</varname>, the process exits successfully for
+ <varname>Type=oneshot</varname>, the initial process exits successfully
+ for <varname>Type=forking</varname>, <literal>READY=1</literal> is sent
+ for <varname>Type=notify</varname>, or the <varname>BusName=</varname>
+ has been taken for <varname>Type=dbus</varname>).</para>
+
<para>Note that <varname>ExecStartPre=</varname> may not be
used to start long-running processes. All processes forked
off by processes invoked via <varname>ExecStartPre=</varname> will
diff --git a/rules/60-persistent-storage.rules b/rules/60-persistent-storage.rules
index 5ab03fc278..0b14bb4a11 100644
--- a/rules/60-persistent-storage.rules
+++ b/rules/60-persistent-storage.rules
@@ -6,7 +6,7 @@
ACTION=="remove", GOTO="persistent_storage_end"
SUBSYSTEM!="block", GOTO="persistent_storage_end"
-KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*|cciss*|dasd*", GOTO="persistent_storage_end"
+KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*|cciss*|dasd*|ubd*", GOTO="persistent_storage_end"
# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end"
diff --git a/shell-completion/bash/machinectl b/shell-completion/bash/machinectl
index 3789492d72..0d09258a0b 100644
--- a/shell-completion/bash/machinectl
+++ b/shell-completion/bash/machinectl
@@ -26,7 +26,8 @@ __contains_word() {
__get_machines() {
local a b
- machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
+ (machinectl list-images --no-legend --no-pager; machinectl list --no-legend --no-pager) | \
+ { while read a b; do echo " $a"; done; } | sort -u;
}
_machinectl() {
@@ -39,8 +40,8 @@ _machinectl() {
)
local -A VERBS=(
- [STANDALONE]='list'
- [MACHINES]='status show terminate kill reboot login'
+ [STANDALONE]='list list-images'
+ [MACHINES]='status show start login enable disable poweroff reboot terminate kill copy-to copy-from image-status show-image clone rename read-only remove set-limit list-transfers cancel-transfer'
)
_init_completion || return
diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in
index c2707ba3a6..0bcd49f923 100644
--- a/shell-completion/bash/systemctl.in
+++ b/shell-completion/bash/systemctl.in
@@ -108,7 +108,7 @@ _systemctl () {
comps=$(compgen -A signal)
;;
--type|-t)
- comps='automount busname device mount path service snapshot socket swap target timer'
+ comps=$(__systemctl $mode -t help)
;;
--state)
comps='loaded not-found stub
diff --git a/shell-completion/zsh/_busctl b/shell-completion/zsh/_busctl
index fb1841341e..ef790e558f 100644
--- a/shell-completion/zsh/_busctl
+++ b/shell-completion/zsh/_busctl
@@ -24,7 +24,14 @@
local -a _busctl_cmds
_busctl_cmds=(
"list:List bus names"
+ "status:Show bus service, process or bus owner credentials"
"monitor:Show bus traffic"
+ "capture:Capture bus traffix as pcap"
+ "tree:Show object tree of service"
+ "introspect:Introspect object"
+ "call:Call a method"
+ "get-property:Get property value"
+ "set-property:Set property value"
)
if (( CURRENT == 1 )); then
_describe -t commands 'busctl command' _busctl_cmds || compadd "$@"
@@ -54,4 +61,12 @@ _arguments \
'--acquired[Only show acquired names]' \
'--activatable[Only show activatable names]' \
'--match=[Only show matching messages]:match' \
+ '--list[Do not show tree, but simple object path list]' \
+ '--quiet[Do not show method call reply]'\
+ '--verbose[Show result values in long format]' \
+ '--expect-reply=[Expect a method call reply]:boolean:(1 0)' \
+ '--auto-start=[Auto-start destination service]:boolean:(1 0)' \
+ '--allow-interactive-authorization=[Allow interactive authorization for operation]:boolean:(1 0)' \
+ '--timeout=[Maximum time to wait for method call completion]:timeout (seconds)' \
+ '--augment-creds=[Extend credential data with data read from /proc/$PID]:boolean:(1 0)' \
'*::busctl command:_busctl_command'
diff --git a/src/basic/def.h b/src/basic/def.h
index 5aaba1fe87..e0d6822f38 100644
--- a/src/basic/def.h
+++ b/src/basic/def.h
@@ -63,7 +63,6 @@
#define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket"
#define KERNEL_SYSTEM_BUS_ADDRESS "kernel:path=/sys/fs/kdbus/0-system/bus"
-#define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS
#define UNIX_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
#define KERNEL_USER_BUS_ADDRESS_FMT "kernel:path=/sys/fs/kdbus/"UID_FMT"-user/bus"
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 359fde9998..ac1711b318 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -818,7 +818,7 @@ static int remove_boot_efi(const char *esp_path) {
if (r < 0)
return log_error_errno(errno, "Failed to remove \"%s/%s\": %m", p, de->d_name);
- log_info("Removed \"%s/\%s\".", p, de->d_name);
+ log_info("Removed \"%s/%s\".", p, de->d_name);
}
c++;
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 3cc3b33ae7..6e07aea94e 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -177,8 +177,9 @@ static int help(void) {
" --configuration=PATH Configuration file or directory\n"
" --machine=MACHINE Connect to specified machine\n"
" --address=ADDRESS Connect to the bus specified by ADDRESS\n"
- " (default: " DEFAULT_SYSTEM_BUS_ADDRESS ")\n",
- program_invocation_short_name);
+ " (default: %s)\n",
+ program_invocation_short_name,
+ is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
return 0;
}
@@ -262,7 +263,7 @@ static int parse_argv(int argc, char *argv[]) {
}
if (!arg_address) {
- arg_address = strdup(DEFAULT_SYSTEM_BUS_ADDRESS);
+ arg_address = strdup(is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
if (!arg_address)
return log_oom();
}
diff --git a/src/bus-proxyd/stdio-bridge.c b/src/bus-proxyd/stdio-bridge.c
index f275f6705f..c5dac396d3 100644
--- a/src/bus-proxyd/stdio-bridge.c
+++ b/src/bus-proxyd/stdio-bridge.c
@@ -50,8 +50,9 @@ static int help(void) {
" --version Show package version\n"
" --machine=MACHINE Connect to specified machine\n"
" --address=ADDRESS Connect to the bus specified by ADDRESS\n"
- " (default: " DEFAULT_SYSTEM_BUS_ADDRESS ")\n",
- program_invocation_short_name);
+ " (default: %s)\n",
+ program_invocation_short_name,
+ is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
return 0;
}
@@ -137,7 +138,7 @@ static int parse_argv(int argc, char *argv[]) {
}
if (!arg_address) {
- arg_address = strdup(DEFAULT_SYSTEM_BUS_ADDRESS);
+ arg_address = strdup(is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
if (!arg_address)
return log_oom();
}
diff --git a/src/core/automount.c b/src/core/automount.c
index 4af381b4b6..2b84c441b2 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -39,7 +39,6 @@
#include "path-util.h"
#include "dbus-automount.h"
#include "bus-util.h"
-#include "bus-error.h"
#include "formats-util.h"
#include "process-util.h"
#include "async.h"
diff --git a/src/core/service.c b/src/core/service.c
index b790ec98be..7bd8cb8b91 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -42,7 +42,6 @@
#include "utf8.h"
#include "env-util.h"
#include "fileio.h"
-#include "bus-error.h"
#include "bus-util.h"
#include "bus-kernel.h"
#include "formats-util.h"
diff --git a/src/core/socket.c b/src/core/socket.c
index a387057473..c78e8ad01b 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -43,7 +43,6 @@
#include "def.h"
#include "smack-util.h"
#include "bus-util.h"
-#include "bus-error.h"
#include "selinux-util.h"
#include "dbus-socket.h"
#include "unit.h"
diff --git a/src/core/timer.c b/src/core/timer.c
index 7f4a2eb716..51cd56ca84 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -27,7 +27,6 @@
#include "dbus-timer.h"
#include "special.h"
#include "bus-util.h"
-#include "bus-error.h"
static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
[TIMER_DEAD] = UNIT_INACTIVE,
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 4980fccc31..25c8e209fd 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -84,7 +84,8 @@ static int create_dbus_files(
fprintf(f, "Environment=DBUS_STARTER_BUS_TYPE=%s\n", type);
if (streq(type, "system"))
- fprintf(f, "Environment=DBUS_STARTER_ADDRESS=" DEFAULT_SYSTEM_BUS_ADDRESS "\n");
+ fprintf(f, "Environment=DBUS_STARTER_ADDRESS=%s\n",
+ is_kdbus_available() ? KERNEL_SYSTEM_BUS_ADDRESS : UNIX_SYSTEM_BUS_ADDRESS);
else if (streq(type, "session")) {
char *run;
@@ -94,8 +95,10 @@ static int create_dbus_files(
return -EINVAL;
}
- fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT "\n",
- getuid(), run);
+ if (is_kdbus_available())
+ fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_ADDRESS_FMT "\n", getuid());
+ else
+ fprintf(f, "Environment=DBUS_STARTER_ADDRESS="UNIX_USER_BUS_ADDRESS_FMT "\n", run);
}
}
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 9d889c17d8..0a34f86be7 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -240,82 +240,6 @@ static int add_mount(
return 0;
}
-static int add_automount(
- const char *id,
- const char *what,
- const char *where,
- const char *fstype,
- bool rw,
- const char *options,
- const char *description,
- usec_t timeout) {
-
- _cleanup_free_ char *unit = NULL, *lnk = NULL;
- _cleanup_free_ char *opt, *p = NULL;
- _cleanup_fclose_ FILE *f = NULL;
- int r;
-
- assert(id);
- assert(where);
- assert(description);
-
- if (options)
- opt = strjoin(options, ",noauto", NULL);
- else
- opt = strdup("noauto");
- if (!opt)
- return log_oom();
-
- r = add_mount(id,
- what,
- where,
- fstype,
- rw,
- opt,
- description,
- NULL);
- if (r < 0)
- return r;
-
- r = unit_name_from_path(where, ".automount", &unit);
- if (r < 0)
- return log_error_errno(r, "Failed to generate unit name: %m");
-
- p = strjoin(arg_dest, "/", unit, NULL);
- if (!p)
- return log_oom();
-
- f = fopen(p, "wxe");
- if (!f)
- return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
-
- fprintf(f,
- "# Automatically generated by systemd-gpt-auto-generator\n\n"
- "[Unit]\n"
- "Description=%s\n"
- "Documentation=man:systemd-gpt-auto-generator(8)\n"
- "[Automount]\n"
- "Where=%s\n"
- "TimeoutIdleSec=%lld\n",
- description,
- where,
- (unsigned long long)timeout / USEC_PER_SEC);
-
- r = fflush_and_check(f);
- if (r < 0)
- return log_error_errno(r, "Failed to write unit file %s: %m", p);
-
- lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL);
- if (!lnk)
- return log_oom();
- mkdir_parents_label(lnk, 0755);
-
- if (symlink(p, lnk) < 0)
- return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
-
- return 0;
-}
-
static bool path_is_busy(const char *where) {
int r;
@@ -441,8 +365,84 @@ static int add_swap(const char *path) {
return 0;
}
-static int add_boot(const char *what) {
#ifdef ENABLE_EFI
+static int add_automount(
+ const char *id,
+ const char *what,
+ const char *where,
+ const char *fstype,
+ bool rw,
+ const char *options,
+ const char *description,
+ usec_t timeout) {
+
+ _cleanup_free_ char *unit = NULL, *lnk = NULL;
+ _cleanup_free_ char *opt, *p = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
+ int r;
+
+ assert(id);
+ assert(where);
+ assert(description);
+
+ if (options)
+ opt = strjoin(options, ",noauto", NULL);
+ else
+ opt = strdup("noauto");
+ if (!opt)
+ return log_oom();
+
+ r = add_mount(id,
+ what,
+ where,
+ fstype,
+ rw,
+ opt,
+ description,
+ NULL);
+ if (r < 0)
+ return r;
+
+ r = unit_name_from_path(where, ".automount", &unit);
+ if (r < 0)
+ return log_error_errno(r, "Failed to generate unit name: %m");
+
+ p = strjoin(arg_dest, "/", unit, NULL);
+ if (!p)
+ return log_oom();
+
+ f = fopen(p, "wxe");
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
+
+ fprintf(f,
+ "# Automatically generated by systemd-gpt-auto-generator\n\n"
+ "[Unit]\n"
+ "Description=%s\n"
+ "Documentation=man:systemd-gpt-auto-generator(8)\n"
+ "[Automount]\n"
+ "Where=%s\n"
+ "TimeoutIdleSec=%lld\n",
+ description,
+ where,
+ (unsigned long long)timeout / USEC_PER_SEC);
+
+ r = fflush_and_check(f);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write unit file %s: %m", p);
+
+ lnk = strjoin(arg_dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/", unit, NULL);
+ if (!lnk)
+ return log_oom();
+ mkdir_parents_label(lnk, 0755);
+
+ if (symlink(p, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
+
+ return 0;
+}
+
+static int add_boot(const char *what) {
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
const char *fstype = NULL, *uuid = NULL;
sd_id128_t id, type_id;
@@ -532,10 +532,12 @@ static int add_boot(const char *what) {
120 * USEC_PER_SEC);
return r;
+}
#else
+static int add_boot(const char *what) {
return 0;
-#endif
}
+#endif
static int enumerate_partitions(dev_t devnum) {
@@ -616,9 +618,12 @@ static int enumerate_partitions(dev_t devnum) {
errno = 0;
r = blkid_do_safeprobe(b);
- if (r == -2 || r == 1) /* no result or uncertain */
+ if (r == 1)
+ return 0; /* no results */
+ else if (r == -2) {
+ log_warning("%s: probe gave ambiguous results, ignoring", node);
return 0;
- else if (r != 0)
+ } else if (r != 0)
return log_error_errno(errno ?: EIO, "%s: failed to probe: %m", node);
errno = 0;
@@ -666,7 +671,6 @@ static int enumerate_partitions(dev_t devnum) {
blkid_partition pp;
dev_t qn;
int nr;
- unsigned long long flags;
q = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
if (!q)
@@ -690,13 +694,6 @@ static int enumerate_partitions(dev_t devnum) {
if (!pp)
continue;
- flags = blkid_partition_get_flags(pp);
-
- /* Ignore partitions that are not marked for automatic
- * mounting on discovery */
- if (flags & GPT_FLAG_NO_AUTO)
- continue;
-
nr = blkid_partition_get_partno(pp);
if (nr < 0)
continue;
@@ -709,6 +706,11 @@ static int enumerate_partitions(dev_t devnum) {
continue;
if (sd_id128_equal(type_id, GPT_SWAP)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
if (flags & GPT_FLAG_READ_ONLY) {
log_debug("%s marked as read-only swap partition, which is bogus. Ignoring.", subnode);
@@ -732,6 +734,11 @@ static int enumerate_partitions(dev_t devnum) {
return log_oom();
} else if (sd_id128_equal(type_id, GPT_HOME)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We only care for the first /home partition */
if (home && nr >= home_nr)
@@ -745,6 +752,11 @@ static int enumerate_partitions(dev_t devnum) {
return log_oom();
} else if (sd_id128_equal(type_id, GPT_SRV)) {
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We only care for the first /srv partition */
if (srv && nr >= srv_nr)
diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c
index a6605d248f..71b8908a58 100644
--- a/src/import/pull-tar.c
+++ b/src/import/pull-tar.c
@@ -127,13 +127,7 @@ int tar_pull_new(
i->grow_machine_directory = path_startswith(i->image_root, "/var/lib/machines");
- if (event)
- i->event = sd_event_ref(event);
- else {
- r = sd_event_default(&i->event);
- if (r < 0)
- return r;
- }
+ i->event = sd_event_ref(event);
r = curl_glue_new(&i->glue, i->event);
if (r < 0)
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index e0874aebad..f5b9e22589 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -954,7 +954,7 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
}
for (i = 0; i <= DHCP_OPTION_PRIVATE_LAST - DHCP_OPTION_PRIVATE_BASE; i++) {
- uint8_t *data;
+ _cleanup_free_ uint8_t *data = NULL;
size_t len;
if (!options[i])
@@ -965,10 +965,8 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
return r;
r = dhcp_lease_insert_private_option(lease, DHCP_OPTION_PRIVATE_BASE + i, data, len);
- if (r < 0) {
- free(data);
+ if (r < 0)
return r;
- }
}
*ret = lease;
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 773c264cf0..92b12f2ae8 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -32,7 +32,6 @@
#include "bus-message.h"
#include "bus-control.h"
#include "bus-bloom.h"
-#include "bus-util.h"
#include "capability.h"
_public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c
index dfd82e746d..87898449e6 100644
--- a/src/libsystemd/sd-bus/bus-convenience.c
+++ b/src/libsystemd/sd-bus/bus-convenience.c
@@ -22,7 +22,6 @@
#include "bus-internal.h"
#include "bus-message.h"
#include "bus-signature.h"
-#include "bus-util.h"
#include "bus-type.h"
_public_ int sd_bus_emit_signal(
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 1c365b7fcd..130fbf7a23 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -31,10 +31,10 @@
#include "fileio.h"
#include "audit.h"
#include "bus-message.h"
-#include "bus-util.h"
#include "strv.h"
#include "bus-creds.h"
#include "bus-label.h"
+#include "bus-internal.h"
enum {
CAP_OFFSET_INHERITABLE = 0,
diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c
index fea796cd30..f4ab57f5bc 100644
--- a/src/libsystemd/sd-bus/bus-internal.c
+++ b/src/libsystemd/sd-bus/bus-internal.c
@@ -371,3 +371,45 @@ int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error) {
return 1;
}
+
+bool is_kdbus_wanted(void) {
+ _cleanup_free_ char *value = NULL;
+#ifdef ENABLE_KDBUS
+ const bool configured = true;
+#else
+ const bool configured = false;
+#endif
+ int r;
+
+ if (get_proc_cmdline_key("kdbus", NULL) > 0)
+ return true;
+
+ r = get_proc_cmdline_key("kdbus=", &value);
+ if (r <= 0)
+ return configured;
+
+ return parse_boolean(value) == 1;
+}
+
+bool is_kdbus_available(void) {
+ static int cached = -1;
+ _cleanup_close_ int fd = -1;
+ struct kdbus_cmd cmd = { .size = sizeof(cmd), .flags = KDBUS_FLAG_NEGOTIATE };
+
+ if (cached >= 0)
+ return (bool) cached;
+
+ if (!is_kdbus_wanted()) {
+ cached = false;
+ return false;
+ }
+
+ fd = open("/sys/fs/kdbus/control", O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
+ if (fd < 0) {
+ cached = false;
+ return false;
+ }
+
+ cached = ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0;
+ return cached;
+}
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index c3e20ee1bf..d420a7594f 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -37,6 +37,29 @@
#include "bus-kernel.h"
#include "kdbus.h"
+typedef enum BusTransport {
+ BUS_TRANSPORT_LOCAL,
+ BUS_TRANSPORT_REMOTE,
+ BUS_TRANSPORT_MACHINE,
+ _BUS_TRANSPORT_MAX,
+ _BUS_TRANSPORT_INVALID = -1
+} BusTransport;
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_flush_close_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_slot*, sd_bus_slot_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_track*, sd_bus_track_unref);
+
+#define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp)
+#define _cleanup_bus_flush_close_unref_ _cleanup_(sd_bus_flush_close_unrefp)
+#define _cleanup_bus_slot_unref_ _cleanup_(sd_bus_slot_unrefp)
+#define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp)
+#define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp)
+#define _cleanup_bus_track_unref_ _cleanup_(sd_bus_slot_unrefp)
+#define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free)
+
struct reply_callback {
sd_bus_message_handler_t callback;
usec_t timeout;
@@ -393,3 +416,6 @@ int bus_remove_match_by_string(sd_bus *bus, const char *match, sd_bus_message_ha
int bus_get_root_path(sd_bus *bus);
int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
+
+bool is_kdbus_wanted(void);
+bool is_kdbus_available(void);
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 22a43c4542..21f3700128 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -45,7 +45,6 @@
#include "bus-message.h"
#include "bus-kernel.h"
#include "bus-bloom.h"
-#include "bus-util.h"
#include "bus-label.h"
#define UNIQUE_NAME_MAX (3+DECIMAL_STR_MAX(uint64_t))
diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
index 18c36ce243..f3b49c0c90 100644
--- a/src/libsystemd/sd-bus/bus-match.c
+++ b/src/libsystemd/sd-bus/bus-match.c
@@ -22,7 +22,6 @@
#include "bus-internal.h"
#include "bus-message.h"
#include "bus-match.h"
-#include "bus-util.h"
#include "strv.h"
/* Example:
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 006e4a2b58..b0577cc412 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -35,7 +35,6 @@
#include "bus-type.h"
#include "bus-signature.h"
#include "bus-gvariant.h"
-#include "bus-util.h"
static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored);
@@ -608,8 +607,8 @@ static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
m->header = (struct bus_header*) ((uint8_t*) m + ALIGN(sizeof(struct sd_bus_message)));
m->header->endian = BUS_NATIVE_ENDIAN;
m->header->type = type;
- m->header->version = bus ? bus->message_version : 1;
- m->allow_fds = !bus || bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
+ m->header->version = bus->message_version;
+ m->allow_fds = bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
m->root_container.need_offsets = BUS_MESSAGE_IS_GVARIANT(m);
m->bus = sd_bus_ref(bus);
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index c25293e5e9..17ce297510 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -26,7 +26,6 @@
#include "bus-type.h"
#include "bus-signature.h"
#include "bus-introspect.h"
-#include "bus-util.h"
#include "bus-slot.h"
#include "bus-objects.h"
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
index e43891be25..7803e39c3d 100644
--- a/src/libsystemd/sd-bus/bus-track.c
+++ b/src/libsystemd/sd-bus/bus-track.c
@@ -20,7 +20,6 @@
***/
#include "sd-bus.h"
-#include "bus-util.h"
#include "bus-internal.h"
#include "bus-track.h"
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index a1f0f30d6c..181621ffc7 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -30,7 +30,6 @@
#include "set.h"
#include "sd-bus.h"
-#include "bus-internal.h"
#include "bus-util.h"
#include "bus-dump.h"
#include "bus-signature.h"
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 0f075907d5..763f830e2d 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -43,7 +43,6 @@
#include "bus-kernel.h"
#include "bus-control.h"
#include "bus-objects.h"
-#include "bus-util.h"
#include "bus-container.h"
#include "bus-protocol.h"
#include "bus-track.h"
@@ -1173,7 +1172,10 @@ int bus_set_address_system(sd_bus *b) {
if (e)
return sd_bus_set_address(b, e);
- return sd_bus_set_address(b, DEFAULT_SYSTEM_BUS_ADDRESS);
+ if (is_kdbus_available())
+ return sd_bus_set_address(b, KERNEL_SYSTEM_BUS_ADDRESS);
+
+ return sd_bus_set_address(b, UNIX_SYSTEM_BUS_ADDRESS);
}
_public_ int sd_bus_open_system(sd_bus **ret) {
@@ -1221,16 +1223,17 @@ int bus_set_address_user(sd_bus *b) {
return sd_bus_set_address(b, e);
e = secure_getenv("XDG_RUNTIME_DIR");
- if (e) {
+ if (is_kdbus_available())
+ (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
+ else if (e) {
_cleanup_free_ char *ee = NULL;
ee = bus_address_escape(e);
if (!ee)
return -ENOMEM;
- (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, getuid(), ee);
- } else
- (void) asprintf(&b->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid());
+ (void) asprintf(&b->address, UNIX_USER_BUS_ADDRESS_FMT, ee);
+ }
if (!b->address)
return -ENOMEM;
diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c
index d14110aa04..d3bf6da850 100644
--- a/src/libsystemd/sd-bus/test-bus-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-benchmark.c
@@ -28,7 +28,6 @@
#include "sd-bus.h"
#include "bus-kernel.h"
#include "bus-internal.h"
-#include "bus-util.h"
#define MAX_SIZE (2*1024*1024)
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 754335b5e7..b97729caf7 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -33,7 +33,6 @@
#include "bus-error.h"
#include "bus-match.h"
#include "bus-internal.h"
-#include "bus-util.h"
static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
log_info("Match triggered! interface=%s member=%s", strna(sd_bus_message_get_interface(m)), strna(sd_bus_message_get_member(m)));
diff --git a/src/libsystemd/sd-bus/test-bus-cleanup.c b/src/libsystemd/sd-bus/test-bus-cleanup.c
index f586880593..b483d47468 100644
--- a/src/libsystemd/sd-bus/test-bus-cleanup.c
+++ b/src/libsystemd/sd-bus/test-bus-cleanup.c
@@ -22,7 +22,6 @@
#include <stdio.h>
#include "sd-bus.h"
-#include "bus-util.h"
#include "bus-internal.h"
#include "bus-message.h"
#include "refcnt.h"
diff --git a/src/libsystemd/sd-bus/test-bus-error.c b/src/libsystemd/sd-bus/test-bus-error.c
index 5753c04b0e..f2cfbc706f 100644
--- a/src/libsystemd/sd-bus/test-bus-error.c
+++ b/src/libsystemd/sd-bus/test-bus-error.c
@@ -20,7 +20,6 @@
***/
#include "sd-bus.h"
-#include "bus-error.h"
#include "bus-util.h"
#include "errno-list.h"
#include "bus-common-errors.h"
diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c
index b078bdc5f6..414d4e9a58 100644
--- a/src/libsystemd/sd-bus/test-bus-gvariant.c
+++ b/src/libsystemd/sd-bus/test-bus-gvariant.c
@@ -27,7 +27,6 @@
#include "macro.h"
#include "sd-bus.h"
#include "bus-gvariant.h"
-#include "bus-util.h"
#include "bus-internal.h"
#include "bus-message.h"
#include "bus-dump.h"
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 6506eaab2e..6284153a58 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -25,8 +25,8 @@
#include "log.h"
#include "sd-bus.h"
-#include "bus-kernel.h"
#include "bus-util.h"
+#include "bus-kernel.h"
#include "bus-dump.h"
int main(int argc, char *argv[]) {
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 83cb5c62c2..f659ba3124 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -24,7 +24,6 @@
#include "bus-match.h"
#include "bus-message.h"
-#include "bus-util.h"
#include "bus-slot.h"
static bool mask[32];
diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c
index 359984c7f3..1457759d0e 100644
--- a/src/libsystemd/sd-bus/test-bus-objects.c
+++ b/src/libsystemd/sd-bus/test-bus-objects.c
@@ -30,7 +30,6 @@
#include "sd-bus.h"
#include "bus-internal.h"
#include "bus-message.h"
-#include "bus-util.h"
#include "bus-dump.h"
struct context {
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
index 080d8eddb7..604df098cc 100644
--- a/src/libsystemd/sd-bus/test-bus-server.c
+++ b/src/libsystemd/sd-bus/test-bus-server.c
@@ -28,7 +28,6 @@
#include "sd-bus.h"
#include "bus-internal.h"
-#include "bus-util.h"
struct context {
int fds[2];
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
index 82ac72c72a..d230a48daf 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -90,7 +90,7 @@ finish:
_public_ int sd_is_fifo(int fd, const char *path) {
struct stat st_fd;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
if (fstat(fd, &st_fd) < 0)
return -errno;
@@ -120,7 +120,7 @@ _public_ int sd_is_fifo(int fd, const char *path) {
_public_ int sd_is_special(int fd, const char *path) {
struct stat st_fd;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
if (fstat(fd, &st_fd) < 0)
return -errno;
@@ -155,7 +155,7 @@ _public_ int sd_is_special(int fd, const char *path) {
static int sd_is_socket_internal(int fd, int type, int listening) {
struct stat st_fd;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
assert_return(type >= 0, -EINVAL);
if (fstat(fd, &st_fd) < 0)
@@ -198,7 +198,7 @@ static int sd_is_socket_internal(int fd, int type, int listening) {
_public_ int sd_is_socket(int fd, int family, int type, int listening) {
int r;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
assert_return(family >= 0, -EINVAL);
r = sd_is_socket_internal(fd, type, listening);
@@ -226,7 +226,7 @@ _public_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint
socklen_t l = sizeof(sockaddr);
int r;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
assert_return(IN_SET(family, 0, AF_INET, AF_INET6), -EINVAL);
r = sd_is_socket_internal(fd, type, listening);
@@ -269,7 +269,7 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
socklen_t l = sizeof(sockaddr);
int r;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
r = sd_is_socket_internal(fd, type, listening);
if (r <= 0)
@@ -310,7 +310,7 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
_public_ int sd_is_mq(int fd, const char *path) {
struct mq_attr attr;
- assert_return(fd >= 0, -EINVAL);
+ assert_return(fd >= 0, -EBADF);
if (mq_getattr(fd, &attr) < 0)
return -errno;
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
index 3ba62a6be9..aee2ced2d9 100644
--- a/src/libsystemd/sd-netlink/netlink-message.c
+++ b/src/libsystemd/sd-netlink/netlink-message.c
@@ -501,7 +501,7 @@ static int netlink_message_read_internal(sd_netlink_message *m, unsigned short t
assert_return(m, -EINVAL);
assert_return(m->sealed, -EPERM);
assert_return(data, -EINVAL);
- assert(m->n_containers <= RTNL_CONTAINER_DEPTH);
+ assert(m->n_containers < RTNL_CONTAINER_DEPTH);
assert(m->containers[m->n_containers].attributes);
assert(type < m->containers[m->n_containers].n_attributes);
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index a261e6a719..cfae186edd 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -109,20 +109,24 @@ int inhibitor_save(Inhibitor *i) {
_cleanup_free_ char *cc = NULL;
cc = cescape(i->who);
- if (!cc)
+ if (!cc) {
r = -ENOMEM;
- else
- fprintf(f, "WHO=%s\n", cc);
+ goto fail;
+ }
+
+ fprintf(f, "WHO=%s\n", cc);
}
if (i->why) {
_cleanup_free_ char *cc = NULL;
cc = cescape(i->why);
- if (!cc)
+ if (!cc) {
r = -ENOMEM;
- else
- fprintf(f, "WHY=%s\n", cc);
+ goto fail;
+ }
+
+ fprintf(f, "WHY=%s\n", cc);
}
if (i->fifo_path)
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
index ab96cb231e..69069cc75d 100644
--- a/src/nss-myhostname/nss-myhostname.c
+++ b/src/nss-myhostname/nss-myhostname.c
@@ -39,7 +39,6 @@
#define LOCALADDRESS_IPV4 (htonl(0x7F000002))
#define LOCALADDRESS_IPV6 &in6addr_loopback
-#define LOOPBACK_INTERFACE "lo"
NSS_GETHOSTBYNAME_PROTOTYPES(myhostname);
NSS_GETHOSTBYADDR_PROTOTYPES(myhostname);
@@ -117,7 +116,7 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
}
/* If this call fails we fill in 0 as scope. Which is fine */
- lo_ifi = n_addresses <= 0 ? if_nametoindex(LOOPBACK_INTERFACE) : 0;
+ lo_ifi = n_addresses <= 0 ? LOOPBACK_IFINDEX : 0;
l = strlen(canonical);
ms = ALIGN(l+1) + ALIGN(sizeof(struct gaih_addrtuple)) * (n_addresses > 0 ? n_addresses : 2);
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 0edba415b6..4d557bdf02 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -336,10 +336,6 @@ static int resolve_record(sd_bus *bus, const char *name) {
if (r < 0)
return bus_log_create_error(r);
- r = sd_bus_message_set_auto_start(req, false);
- if (r < 0)
- return bus_log_create_error(r);
-
assert((uint16_t) arg_type == arg_type);
r = sd_bus_message_append(req, "isqqt", arg_ifindex, name, arg_class, arg_type, arg_flags);
if (r < 0)
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index 418d9721ef..3ada442006 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -19,6 +19,8 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "hostname-util.h"
+#include "dns-domain.h"
#include "resolved-dns-query.h"
@@ -212,6 +214,156 @@ static int dns_query_add_transaction_split(DnsQuery *q, DnsScope *s) {
return 0;
}
+static int SYNTHESIZE_IFINDEX(int ifindex) {
+
+ /* When the caller asked for resolving on a specific interface,
+ * we synthesize the answer for that interface. However, if
+ * nothing specific was claimed, we synthesize the answer for
+ * localhost. */
+
+ if (ifindex > 0)
+ return ifindex;
+
+ return LOOPBACK_IFINDEX;
+}
+
+static int SYNTHESIZE_FAMILY(uint64_t flags) {
+
+ /* Picks an address family depending on set flags. This is
+ * purely for synthesized answers, where the family we return
+ * for the reply should match what was requested in the
+ * question, even though we are synthesizing the answer
+ * here. */
+
+ if (!(flags & SD_RESOLVED_DNS)) {
+ if (flags & SD_RESOLVED_LLMNR_IPV4)
+ return AF_INET;
+ if (flags & SD_RESOLVED_LLMNR_IPV6)
+ return AF_INET6;
+ }
+
+ return AF_UNSPEC;
+}
+
+static DnsProtocol SYNTHESIZE_PROTOCOL(uint64_t flags) {
+
+ /* Similar as SYNTHESIZE_FAMILY() but does this for the
+ * protocol. If resolving via DNS was requested, we claim it
+ * was DNS. Similar, if nothing specific was
+ * requested. However, if only resolving via LLMNR was
+ * requested we return that. */
+
+ if (flags & SD_RESOLVED_DNS)
+ return DNS_PROTOCOL_DNS;
+ if (flags & SD_RESOLVED_LLMNR)
+ return DNS_PROTOCOL_LLMNR;
+
+ return DNS_PROTOCOL_DNS;
+}
+
+static void dns_query_synthesize_reply(DnsQuery *q, DnsTransactionState *state) {
+ _cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
+ unsigned i;
+ int r;
+
+ assert(q);
+ assert(state);
+
+ /* Tries to synthesize localhost RR replies where appropriate */
+
+ if (!IN_SET(*state,
+ DNS_TRANSACTION_FAILURE,
+ DNS_TRANSACTION_NO_SERVERS,
+ DNS_TRANSACTION_TIMEOUT,
+ DNS_TRANSACTION_ATTEMPTS_MAX_REACHED))
+ return;
+
+ for (i = 0; i < q->question->n_keys; i++) {
+ _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
+ const char *name;
+
+ if (q->question->keys[i]->class != DNS_CLASS_IN &&
+ q->question->keys[i]->class != DNS_CLASS_ANY)
+ continue;
+
+ name = DNS_RESOURCE_KEY_NAME(q->question->keys[i]);
+
+ if (is_localhost(name)) {
+
+ switch (q->question->keys[i]->type) {
+
+ case DNS_TYPE_A:
+ case DNS_TYPE_ANY:
+ rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_A, name);
+ if (!rr) {
+ log_oom();
+ return;
+ }
+
+ rr->a.in_addr.s_addr = htobe32(INADDR_LOOPBACK);
+ break;
+
+ case DNS_TYPE_AAAA:
+ rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_AAAA, name);
+ if (!rr) {
+ log_oom();
+ return;
+ }
+
+ rr->aaaa.in6_addr = in6addr_loopback;
+ break;
+ }
+
+ } else if (IN_SET(q->question->keys[i]->type, DNS_TYPE_PTR, DNS_TYPE_ANY) &&
+ (dns_name_endswith(name, "127.in-addr.arpa") > 0 ||
+ dns_name_equal(name, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0)) {
+
+ rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR, name);
+ if (!rr) {
+ log_oom();
+ return;
+ }
+
+ rr->ptr.name = strdup("localhost");
+ if (!rr->ptr.name) {
+ log_oom();
+ return;
+ }
+ }
+
+ if (!rr)
+ continue;
+
+ if (!answer) {
+ answer = dns_answer_new(q->question->n_keys);
+ if (!answer) {
+ log_oom();
+ return;
+ }
+ }
+
+ r = dns_answer_add(answer, rr);
+ if (r < 0) {
+ log_error_errno(r, "Failed to add synthetic RR to answer: %m");
+ return;
+ }
+ }
+
+ if (!answer)
+ return;
+
+ dns_answer_unref(q->answer);
+ q->answer = answer;
+ answer = NULL;
+
+ q->answer_ifindex = SYNTHESIZE_IFINDEX(q->ifindex);
+ q->answer_family = SYNTHESIZE_FAMILY(q->flags);
+ q->answer_protocol = SYNTHESIZE_PROTOCOL(q->flags);
+ q->answer_rcode = DNS_RCODE_SUCCESS;
+
+ *state = DNS_TRANSACTION_SUCCESS;
+}
+
int dns_query_go(DnsQuery *q) {
DnsScopeMatch found = DNS_SCOPE_NO;
DnsScope *s, *first = NULL;
@@ -253,8 +405,17 @@ int dns_query_go(DnsQuery *q) {
}
}
- if (found == DNS_SCOPE_NO)
+ if (found == DNS_SCOPE_NO) {
+ DnsTransactionState state = DNS_TRANSACTION_NO_SERVERS;
+
+ dns_query_synthesize_reply(q, &state);
+ if (state != DNS_TRANSACTION_NO_SERVERS) {
+ dns_query_complete(q, state);
+ return 1;
+ }
+
return -ESRCH;
+ }
r = dns_query_add_transaction_split(q, first);
if (r < 0)
@@ -428,6 +589,9 @@ void dns_query_ready(DnsQuery *q) {
q->answer_family = scope ? scope->family : AF_UNSPEC;
}
+ /* Try to synthesize a reply if we couldn't resolve something. */
+ dns_query_synthesize_reply(q, &state);
+
dns_query_complete(q, state);
}
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index b8414da87e..57d9071dfc 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -325,10 +325,6 @@ DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, co
if ((SD_RESOLVED_FLAGS_MAKE(s->protocol, s->family) & flags) == 0)
return DNS_SCOPE_NO;
- STRV_FOREACH(i, s->domains)
- if (dns_name_endswith(domain, *i) > 0)
- return DNS_SCOPE_YES;
-
if (dns_name_root(domain) != 0)
return DNS_SCOPE_NO;
@@ -340,6 +336,10 @@ DnsScopeMatch dns_scope_good_domain(DnsScope *s, int ifindex, uint64_t flags, co
dns_name_equal(domain, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa") > 0)
return DNS_SCOPE_NO;
+ STRV_FOREACH(i, s->domains)
+ if (dns_name_endswith(domain, *i) > 0)
+ return DNS_SCOPE_YES;
+
if (s->protocol == DNS_PROTOCOL_DNS) {
if (dns_name_endswith(domain, "254.169.in-addr.arpa") == 0 &&
dns_name_endswith(domain, "0.8.e.f.ip6.arpa") == 0 &&
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index aa87cd0910..0df0594ea3 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -2027,37 +2027,3 @@ int bus_path_decode_unique(const char *path, const char *prefix, char **ret_send
*ret_external = external;
return 1;
}
-
-bool is_kdbus_wanted(void) {
- _cleanup_free_ char *value = NULL;
-#ifdef ENABLE_KDBUS
- const bool configured = true;
-#else
- const bool configured = false;
-#endif
-
- int r;
-
- if (get_proc_cmdline_key("kdbus", NULL) > 0)
- return true;
-
- r = get_proc_cmdline_key("kdbus=", &value);
- if (r <= 0)
- return configured;
-
- return parse_boolean(value) == 1;
-}
-
-bool is_kdbus_available(void) {
- _cleanup_close_ int fd = -1;
- struct kdbus_cmd cmd = { .size = sizeof(cmd), .flags = KDBUS_FLAG_NEGOTIATE };
-
- if (!is_kdbus_wanted())
- return false;
-
- fd = open("/sys/fs/kdbus/control", O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
- if (fd < 0)
- return false;
-
- return ioctl(fd, KDBUS_CMD_BUS_MAKE, &cmd) >= 0;
-}
diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h
index 4ae216b7d9..0c683c0713 100644
--- a/src/shared/bus-util.h
+++ b/src/shared/bus-util.h
@@ -23,18 +23,12 @@
#include "sd-event.h"
#include "sd-bus.h"
+#include "bus-error.h"
+#include "bus-internal.h"
#include "hashmap.h"
#include "install.h"
#include "time-util.h"
-typedef enum BusTransport {
- BUS_TRANSPORT_LOCAL,
- BUS_TRANSPORT_REMOTE,
- BUS_TRANSPORT_MACHINE,
- _BUS_TRANSPORT_MAX,
- _BUS_TRANSPORT_INVALID = -1
-} BusTransport;
-
typedef int (*bus_property_set_t) (sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
struct bus_properties_map {
@@ -135,21 +129,6 @@ typedef struct UnitInfo {
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_flush_close_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_slot*, sd_bus_slot_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_creds*, sd_bus_creds_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_track*, sd_bus_track_unref);
-
-#define _cleanup_bus_unref_ _cleanup_(sd_bus_unrefp)
-#define _cleanup_bus_flush_close_unref_ _cleanup_(sd_bus_flush_close_unrefp)
-#define _cleanup_bus_slot_unref_ _cleanup_(sd_bus_slot_unrefp)
-#define _cleanup_bus_message_unref_ _cleanup_(sd_bus_message_unrefp)
-#define _cleanup_bus_creds_unref_ _cleanup_(sd_bus_creds_unrefp)
-#define _cleanup_bus_track_unref_ _cleanup_(sd_bus_slot_unrefp)
-#define _cleanup_bus_error_free_ _cleanup_(sd_bus_error_free)
-
#define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \
int function(sd_bus *bus, \
const char *path, \
@@ -197,6 +176,3 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet, Un
int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path);
int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external);
-
-bool is_kdbus_wanted(void);
-bool is_kdbus_available(void);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 4e850ea1cf..1a9dbadbe1 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -7292,6 +7292,7 @@ static int halt_now(enum action a) {
reboot(RB_POWER_OFF);
return -errno;
+ case ACTION_KEXEC:
case ACTION_REBOOT: {
_cleanup_free_ char *param = NULL;
diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c
index 1dad4476f3..b8066ea6e9 100644
--- a/src/udev/udev-builtin-blkid.c
+++ b/src/udev/udev-builtin-blkid.c
@@ -143,6 +143,11 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) {
if (sd_id128_equal(type, GPT_ESP)) {
sd_id128_t id, esp;
+ unsigned long long flags;
+
+ flags = blkid_partition_get_flags(pp);
+ if (flags & GPT_FLAG_NO_AUTO)
+ continue;
/* We found an ESP, let's see if it matches
* the ESP we booted from. */
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index b0ad277f73..b4ae0944eb 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -379,13 +379,14 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl_connection *conn) {
cmsg_close_all(&smsg);
cmsg = CMSG_FIRSTHDR(&smsg);
- cred = (struct ucred *) CMSG_DATA(cmsg);
if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
log_error("no sender credentials received, message ignored");
goto err;
}
+ cred = (struct ucred *) CMSG_DATA(cmsg);
+
if (cred->uid != 0) {
log_error("sender uid="UID_FMT", message ignored", cred->uid);
goto err;