From 4a055e5a3e8c8559c326dd4b3e01edbbcc70a86b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 1 Apr 2023 16:15:12 +0200 Subject: [PATCH 1/8] core: typos in comments --- src/core/dbus-service.c | 2 +- src/core/dbus-unit.c | 7 +++---- src/core/execute.c | 16 ++++++++-------- src/core/unit.c | 4 ++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index a6758e616b..0f6e315233 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -723,7 +723,7 @@ int bus_service_set_property( return r; if (u->transient && u->load_state == UNIT_STUB) { - /* This is a transient unit, let's load a little more */ + /* This is a transient unit, let's allow a little more */ r = bus_service_set_transient_property(s, name, message, flags, error); if (r != 0) diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index a9e63b0678..f01e7c7604 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -2407,10 +2407,9 @@ int bus_unit_set_properties( assert(u); assert(message); - /* We iterate through the array twice. First run we just check - * if all passed data is valid, second run actually applies - * it. This is to implement transaction-like behaviour without - * actually providing full transactions. */ + /* We iterate through the array twice. First run just checks if all passed data is valid, second run + * actually applies it. This implements transaction-like behaviour without actually providing full + * transactions. */ r = sd_bus_message_enter_container(message, 'a', "(sv)"); if (r < 0) diff --git a/src/core/execute.c b/src/core/execute.c index 81e48f12c6..348222adcc 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -4655,8 +4655,7 @@ static int exec_child( return log_unit_error_errno(unit, r, "Failed to determine $HOME for user: %m"); } - /* If a socket is connected to STDIN/STDOUT/STDERR, we - * must sure to drop O_NONBLOCK */ + /* If a socket is connected to STDIN/STDOUT/STDERR, we must drop O_NONBLOCK */ if (socket_fd >= 0) (void) fd_nonblock(socket_fd, false); @@ -5197,9 +5196,10 @@ static int exec_child( } #endif - /* We repeat the fd closing here, to make sure that nothing is leaked from the PAM modules. Note that we are - * more aggressive this time since socket_fd and the netns and ipcns fds we don't need anymore. We do keep the exec_fd - * however if we have it as we want to keep it open until the final execve(). */ + /* We repeat the fd closing here, to make sure that nothing is leaked from the PAM modules. Note that + * we are more aggressive this time, since we don't need socket_fd and the netns and ipcns fds any + * more. We do keep exec_fd however, if we have it, since we need to keep it open until the final + * execve(). */ r = close_all_fds(keep_fds, n_keep_fds); if (r >= 0) @@ -5221,9 +5221,9 @@ static int exec_child( if (needs_sandboxing) { uint64_t bset; - /* Set the RTPRIO resource limit to 0, but only if nothing else was explicitly - * requested. (Note this is placed after the general resource limit initialization, see - * above, in order to take precedence.) */ + /* Set the RTPRIO resource limit to 0, but only if nothing else was explicitly requested. + * (Note this is placed after the general resource limit initialization, see above, in order + * to take precedence.) */ if (context->restrict_realtime && !context->rlimit[RLIMIT_RTPRIO]) { if (setrlimit(RLIMIT_RTPRIO, &RLIMIT_MAKE_CONST(0)) < 0) { *exit_status = EXIT_LIMITS; diff --git a/src/core/unit.c b/src/core/unit.c index 642db41e41..ce7b5a177c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4333,8 +4333,8 @@ char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf) { s = t; } - /* We either do c-escaping or shell-escaping, to additionally escape characters that we parse for - * ExecStart= and friend, i.e. '$' and ';' and quotes. */ + /* We either do C-escaping or shell-escaping, to additionally escape characters that we parse for + * ExecStart= and friends, i.e. '$' and ';' and quotes. */ if (flags & UNIT_ESCAPE_EXEC_SYNTAX) { char *t2 = shell_escape(s, "$;'\""); From 68ecb48b90bd88c92253729304cac4647e143b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 1 Apr 2023 16:23:47 +0200 Subject: [PATCH 2/8] core: simplify unit_escape_setting() The function had a provision for NULL input, and would return NULL, but that looks like an error and all callers pass in a non-NULL arg and report oom on NULL. So assert that the input is non-NULL. All callers specifed the output buffer, so we can simplify the logic to only make an allocation if appropriate and change the return type to 'const *'. No functional change. --- src/core/unit.c | 26 ++++++++++---------------- src/core/unit.h | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index ce7b5a177c..e0deccc7b9 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4310,20 +4310,18 @@ static const char* unit_drop_in_dir(Unit *u, UnitWriteFlags flags) { return NULL; } -char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf) { +const char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf) { + assert(s); assert(!FLAGS_SET(flags, UNIT_ESCAPE_EXEC_SYNTAX | UNIT_ESCAPE_C)); + assert(buf); _cleanup_free_ char *t = NULL; - if (!s) - return NULL; - - /* Escapes the input string as requested. Returns the escaped string. If 'buf' is specified then the - * allocated return buffer pointer is also written to *buf, except if no escaping was necessary, in - * which case *buf is set to NULL, and the input pointer is returned as-is. This means the return - * value always contains a properly escaped version, but *buf when passed only contains a pointer if - * an allocation was necessary. If *buf is not specified, then the return value always needs to be - * freed. Callers can use this to optimize memory allocations. */ + /* Returns a string with any escaping done. If no escaping was necessary, *buf is set to NULL, and + * the input pointer is returned as-is. If an allocation was needed, the return buffer pointer is + * written to *buf. This means the return value always contains a properly escaped version, but *buf + * only contains a pointer if an allocation was made. Callers can use this to optimize memory + * allocations. */ if (flags & UNIT_ESCAPE_SPECIFIERS) { t = specifier_escape(s); @@ -4353,12 +4351,8 @@ char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf) { s = t; } - if (buf) { - *buf = TAKE_PTR(t); - return (char*) s; - } - - return TAKE_PTR(t) ?: strdup(s); + *buf = TAKE_PTR(t); + return s; } char* unit_concat_strv(char **l, UnitWriteFlags flags) { diff --git a/src/core/unit.h b/src/core/unit.h index 513c8181f5..420405b2b7 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -964,7 +964,7 @@ ExecRuntime *unit_get_exec_runtime(Unit *u) _pure_; int unit_setup_exec_runtime(Unit *u); -char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf); +const char* unit_escape_setting(const char *s, UnitWriteFlags flags, char **buf); char* unit_concat_strv(char **l, UnitWriteFlags flags); int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const char *data); From 3ff67ec43a0bfa14514cb4241e93aa36545f025c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 13:50:29 +0200 Subject: [PATCH 3/8] core: unify two similar paths, avoid formatting of unused string After 'if (DEBUG_LOGGING)' is added, the two call sites are almost identical, except that we forgot LOG_UNIT_INVOCATION_ID(unit). I removed the handling of the log_oom(). It's a debug message only after all, and it's unlikely to fail. --- src/core/execute.c | 47 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/core/execute.c b/src/core/execute.c index 348222adcc..b1160cd4d6 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -4397,6 +4397,22 @@ static int collect_open_file_fds( return 0; } +static void log_command_line(Unit *unit, const char *msg, const char *executable, char **argv) { + assert(unit); + assert(msg); + assert(executable); + + if (!DEBUG_LOGGING) + return; + + _cleanup_free_ char *cmdline = quote_command_line(argv, SHELL_ESCAPE_EMPTY); + + log_unit_struct(unit, LOG_DEBUG, + "EXECUTABLE=%s", executable, + LOG_UNIT_MESSAGE(unit, "%s: %s", msg, strnull(cmdline)), + LOG_UNIT_INVOCATION_ID(unit)); +} + static int exec_child( Unit *unit, const ExecCommand *command, @@ -5496,19 +5512,7 @@ static int exec_child( } else final_argv = command->argv; - if (DEBUG_LOGGING) { - _cleanup_free_ char *line = NULL; - - line = quote_command_line(final_argv, SHELL_ESCAPE_EMPTY); - if (!line) { - *exit_status = EXIT_MEMORY; - return log_oom(); - } - - log_unit_struct(unit, LOG_DEBUG, - "EXECUTABLE=%s", executable, - LOG_UNIT_MESSAGE(unit, "Executing: %s", line)); - } + log_command_line(unit, "Executing", executable, final_argv); if (exec_fd >= 0) { uint8_t hot = 1; @@ -5555,7 +5559,6 @@ int exec_spawn(Unit *unit, _cleanup_free_ char *subcgroup_path = NULL; _cleanup_strv_free_ char **files_env = NULL; size_t n_storage_fds = 0, n_socket_fds = 0; - _cleanup_free_ char *line = NULL; pid_t pid; assert(unit); @@ -5593,21 +5596,13 @@ int exec_spawn(Unit *unit, if (r < 0) return log_unit_error_errno(unit, r, "Failed to load environment files: %m"); - line = quote_command_line(command->argv, SHELL_ESCAPE_EMPTY); - if (!line) - return log_oom(); - /* Fork with up-to-date SELinux label database, so the child inherits the up-to-date db and, until the next SELinux policy changes, we save further reloads in future children. */ mac_selinux_maybe_reload(); - log_unit_struct(unit, LOG_DEBUG, - LOG_UNIT_MESSAGE(unit, "About to execute %s", line), - "EXECUTABLE=%s", command->path, /* We won't know the real executable path until we create - the mount namespace in the child, but we want to log - from the parent, so we need to use the (possibly - inaccurate) path here. */ - LOG_UNIT_INVOCATION_ID(unit)); + /* We won't know the real executable path until we create the mount namespace in the child, but we + want to log from the parent, so we use the possibly inaccurate path here. */ + log_command_line(unit, "About to execute", command->path, command->argv); if (params->cgroup_path) { r = exec_parameters_get_cgroup_path(params, &subcgroup_path); @@ -6895,7 +6890,7 @@ void exec_command_append_list(ExecCommand **l, ExecCommand *e) { end = LIST_FIND_TAIL(command, *l); LIST_INSERT_AFTER(command, *l, end, e); } else - *l = e; + *l = e; } int exec_command_set(ExecCommand *c, const char *path, ...) { From 8202c017010090abf0c0777d10093ffba3c42811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 20:05:18 +0200 Subject: [PATCH 4/8] man: move description of command line substitution out of ExecStart= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The description was split — part was under ExecStart= and part in "Command lines". Now the whole generic part is moved to the separate section, and under ExecStart= only the stuff that is specific to that option is described. This just moves the text and removes some repetitions. --- man/systemd.service.xml | 145 +++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 76 deletions(-) diff --git a/man/systemd.service.xml b/man/systemd.service.xml index 665128ee77..036ac66b2d 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -356,11 +356,8 @@ ExecStart= - Commands with their arguments that are - executed when this service is started. The value is split into - zero or more command lines according to the rules described - below (see section "Command Lines" below). - + Commands that are executed when this service is started. The value is split into zero + or more command lines according to the rules described in the section "Command Lines" below. Unless Type= is , exactly one command must be given. When Type=oneshot is used, zero or more commands may be specified. Commands may be specified by @@ -371,66 +368,6 @@ ExecStop= line set. (Services lacking both ExecStart= and ExecStop= are not valid.) - For each of the specified commands, the first argument must be either an absolute path to an executable - or a simple file name without any slashes. Optionally, this filename may be prefixed with a number of special - characters: - - - Special executable prefixes - - - - - - - - Prefix - Effect - - - - - @ - If the executable path is prefixed with @, the second specified token will be passed as argv[0] to the executed process (instead of the actual filename), followed by the further arguments specified. - - - - - - If the executable path is prefixed with -, an exit code of the command normally considered a failure (i.e. non-zero exit status or abnormal exit due to signal) is recorded, but has no further effect and is considered equivalent to success. - - - - : - If the executable path is prefixed with :, environment variable substitution (as described by the "Command Lines" section below) is not applied. - - - - + - If the executable path is prefixed with + then the process is executed with full privileges. In this mode privilege restrictions configured with User=, Group=, CapabilityBoundingSet= or the various file system namespacing options (such as PrivateDevices=, PrivateTmp=) are not applied to the invoked command line (but still affect any other ExecStart=, ExecStop=, … lines). However, note that this will not bypass options that apply to the whole control group, such as DevicePolicy=, see systemd.resource-control5 for the full list. - - - - ! - - Similar to the + character discussed above this permits invoking command lines with elevated privileges. However, unlike + the ! character exclusively alters the effect of User=, Group= and SupplementaryGroups=, i.e. only the stanzas that affect user and group credentials. Note that this setting may be combined with DynamicUser=, in which case a dynamic user/group pair is allocated before the command is invoked, but credential changing is left to the executed process itself. - - - - !! - - This prefix is very similar to !, however it only has an effect on systems lacking support for ambient process capabilities, i.e. without support for AmbientCapabilities=. It's intended to be used for unit files that take benefit of ambient capabilities to run processes with minimal privileges wherever possible while remaining compatible with systems that lack ambient capabilities support. Note that when !! is used, and a system lacking ambient capability support is detected any configured SystemCallFilter= and CapabilityBoundingSet= stanzas are implicitly modified, in order to permit spawned processes to drop credentials and capabilities themselves, even if this is configured to not be allowed. Moreover, if this prefix is used and a system lacking ambient capability support is detected AmbientCapabilities= will be skipped and not be applied. On systems supporting ambient capabilities, !! has no effect and is redundant. - - - -
- - @, -, :, and one of - +/!/!! may be used together and they can appear in any - order. However, only one of +, !, !! may be used at a - time. Note that these prefixes are also supported for the other command line settings, - i.e. ExecStartPre=, ExecStartPost=, ExecReload=, - ExecStop= and ExecStopPost=. - If more than one command is specified, the commands are invoked sequentially in the order they appear in the unit file. If one of the commands fails (and is not prefixed with @@ -1294,6 +1231,73 @@ The command to execute may contain spaces, but control characters are not allowed. + Each command may be prefixed with a number of special characters: + + + Special executable prefixes + + + + + + + + Prefix + Effect + + + + + @ + If the executable path is prefixed with @, the second specified token will be passed as argv[0] to the executed process (instead of the actual filename), followed by the further arguments specified. + + + + - + If the executable path is prefixed with -, an exit code of the command normally considered a failure (i.e. non-zero exit status or abnormal exit due to signal) is recorded, but has no further effect and is considered equivalent to success. + + + + : + If the executable path is prefixed with :, environment variable substitution (as described by the "Command Lines" section below) is not applied. + + + + + + If the executable path is prefixed with + then the process is executed with full privileges. In this mode privilege restrictions configured with User=, Group=, CapabilityBoundingSet= or the various file system namespacing options (such as PrivateDevices=, PrivateTmp=) are not applied to the invoked command line (but still affect any other ExecStart=, ExecStop=, … lines). However, note that this will not bypass options that apply to the whole control group, such as DevicePolicy=, see systemd.resource-control5 for the full list. + + + + ! + + Similar to the + character discussed above this permits invoking command lines with elevated privileges. However, unlike + the ! character exclusively alters the effect of User=, Group= and SupplementaryGroups=, i.e. only the stanzas that affect user and group credentials. Note that this setting may be combined with DynamicUser=, in which case a dynamic user/group pair is allocated before the command is invoked, but credential changing is left to the executed process itself. + + + + !! + + This prefix is very similar to !, however it only has an effect on systems lacking support for ambient process capabilities, i.e. without support for AmbientCapabilities=. It's intended to be used for unit files that take benefit of ambient capabilities to run processes with minimal privileges wherever possible while remaining compatible with systems that lack ambient capabilities support. Note that when !! is used, and a system lacking ambient capability support is detected any configured SystemCallFilter= and CapabilityBoundingSet= stanzas are implicitly modified, in order to permit spawned processes to drop credentials and capabilities themselves, even if this is configured to not be allowed. Moreover, if this prefix is used and a system lacking ambient capability support is detected AmbientCapabilities= will be skipped and not be applied. On systems supporting ambient capabilities, !! has no effect and is redundant. + + + +
+ + @, -, :, and one of + +/!/!! may be used together and they can appear in any + order. However, only one of +, !, !! may be used at a + time. + + For each command, the first argument must be either an absolute path to an executable or a simple + file name without any slashes. If the command is not a full (absolute) path, it will be resolved to a + full path using a fixed search path determined at compilation time. Searched directories include + /usr/local/bin/, /usr/bin/, /bin/ on + systems using split /usr/bin/ and /bin/ directories, and their + sbin/ counterparts on systems using split bin/ and + sbin/. It is thus safe to use just the executable name in case of executables + located in any of the "standard" directories, and an absolute path must be used in other cases. Using an + absolute path is recommended to avoid ambiguity. Hint: this search path may be queried using + systemd-path search-binaries-default. + The command line accepts % specifiers as described in systemd.unit5. @@ -1308,17 +1312,6 @@ For this type of expansion, quotes are respected when splitting into words, and afterwards removed.
- If the command is not a full (absolute) path, it will be resolved to a full path using a - fixed search path determined at compilation time. Searched directories include - /usr/local/bin/, /usr/bin/, /bin/ - on systems using split /usr/bin/ and /bin/ - directories, and their sbin/ counterparts on systems using split - bin/ and sbin/. It is thus safe to use just the - executable name in case of executables located in any of the "standard" directories, and an - absolute path must be used in other cases. Using an absolute path is recommended to avoid - ambiguity. Hint: this search path may be queried using - systemd-path search-binaries-default. - Example: Environment="ONE=one" 'TWO=two two' From 4d7ae2557ba681db13087f18f3c1c60c3d8352aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 20:16:01 +0200 Subject: [PATCH 5/8] man/systemd.service: add example for char prefixes The prefixes can be specified for any part of the command. The docs imply this, but it's not entirely obvious. Let's add an example. --- man/systemd.service.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/man/systemd.service.xml b/man/systemd.service.xml index 036ac66b2d..f64a8e538f 100644 --- a/man/systemd.service.xml +++ b/man/systemd.service.xml @@ -1249,7 +1249,7 @@ @ - If the executable path is prefixed with @, the second specified token will be passed as argv[0] to the executed process (instead of the actual filename), followed by the further arguments specified. + If the executable path is prefixed with @, the second specified token will be passed as argv[0] to the executed process (instead of the actual filename), followed by the further arguments specified. @@ -1364,6 +1364,17 @@ ExecStart=/bin/echo $ONE $TWO $THREE Example: + Type=oneshot +ExecStart=:echo $USER ; -false ; +:@true $TEST + + This will execute /usr/bin/echo with the literal argument + $USER (: suppresses variable expansion), and then + /usr/bin/false (the return value will be ignored because - + suppresses checking of the return value), and /usr/bin/true (with elevated privileges, + with $TEST as argv[0]). + + Example: + ExecStart=echo / >/dev/null & \; \ ls From 6db00b5de149ec06efdc4b92bc3df40cabb58ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 20:53:51 +0200 Subject: [PATCH 6/8] man/sd_bus_message_open_container: mention two common errors --- man/sd_bus_message_open_container.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/man/sd_bus_message_open_container.xml b/man/sd_bus_message_open_container.xml index 688f43227b..0b9164e9bf 100644 --- a/man/sd_bus_message_open_container.xml +++ b/man/sd_bus_message_open_container.xml @@ -91,7 +91,7 @@ with sd_bus_message_enter_container(). It behaves mostly the same as sd_bus_message_close_container(). Note that sd_bus_message_exit_container() may only be called after iterating through all - members of the container, i.e. reading or skipping them. Use + members of the container, i.e. reading or skipping over them. Use sd_bus_message_skip3 to skip over fields of a container in order to be able to exit the container with sd_bus_message_exit_container() without reading all members. @@ -121,6 +121,20 @@ NULL or type is invalid.
+ + -EBADMSG + + Message m has invalid structure. + + + + -ENXIO + + Message m does not have a container of type + type at the current position, or the contents do not match + contents. + + -EPERM From 44d82df46e38c5bc36ed3722301eeae15df29763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 21:08:35 +0200 Subject: [PATCH 7/8] core: a more informative error when SetProperties/StartTransientUnit fails I was changing how some properties are appended to the StartTransientUnit call and messed up the message contents. When something is wrong with how the message is structed, we would return a very generic "Failed to start transient service unit: No such device or address". Mention that it was property setting that failed, and translate ENXIO to a different message. bus_unit_set_properties() or any of the children it calls may also return other errors, in particular EBADMSG or ENOMEM, but the error message that is generated for those is understandable, so we don't need to "translate" them explicitly. bus_unit_set_properties() is called from two places, so it seems nicer to generate the message internally, rather than ask the caller to do that. Also, now bus_unit_set_properties() always sets , which is nicer for the callers. --- src/core/dbus-unit.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index f01e7c7604..3f083a8174 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -2413,7 +2413,7 @@ int bus_unit_set_properties( r = sd_bus_message_enter_container(message, 'a', "(sv)"); if (r < 0) - return r; + goto error; for (;;) { const char *name; @@ -2421,7 +2421,7 @@ int bus_unit_set_properties( r = sd_bus_message_enter_container(message, 'r', "sv"); if (r < 0) - return r; + goto error; if (r == 0) { if (for_real || UNIT_WRITE_FLAGS_NOOP(flags)) break; @@ -2429,7 +2429,7 @@ int bus_unit_set_properties( /* Reached EOF. Let's try again, and this time for realz... */ r = sd_bus_message_rewind(message, false); if (r < 0) - return r; + goto error; for_real = true; continue; @@ -2437,11 +2437,11 @@ int bus_unit_set_properties( r = sd_bus_message_read(message, "s", &name); if (r < 0) - return r; + goto error; r = sd_bus_message_enter_container(message, 'v', NULL); if (r < 0) - return r; + goto error; /* If not for real, then mask out the two target flags */ f = for_real ? flags : (flags & ~(UNIT_RUNTIME|UNIT_PERSISTENT)); @@ -2455,7 +2455,7 @@ int bus_unit_set_properties( if (r == 0) r = bus_unit_set_live_property(u, name, message, f, error); if (r < 0) - return r; + goto error; if (r == 0) return sd_bus_error_setf(error, SD_BUS_ERROR_PROPERTY_READ_ONLY, @@ -2463,23 +2463,32 @@ int bus_unit_set_properties( r = sd_bus_message_exit_container(message); if (r < 0) - return r; + goto error; r = sd_bus_message_exit_container(message); if (r < 0) - return r; + goto error; n += for_real; } r = sd_bus_message_exit_container(message); if (r < 0) - return r; + goto error; if (commit && n > 0 && UNIT_VTABLE(u)->bus_commit_properties) UNIT_VTABLE(u)->bus_commit_properties(u); return n; + + error: + /* Pretty much any of the calls above can fail if the message is not formed properly + * or if it has unexpected contents. Fill in a more informative error message here. */ + if (sd_bus_error_is_set(error)) + return r; + return sd_bus_error_set_errnof(error, r, + r == -ENXIO ? "Failed to set unit properties: Unexpected message contents" + : "Failed to set unit properties: %m"); } int bus_unit_validate_load_state(Unit *u, sd_bus_error *error) { From 91053fc94e9697cdbe610f6c8593d78568b5b573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Apr 2023 23:07:33 +0200 Subject: [PATCH 8/8] sd-bus: use macros for standard bus error names consistently Also add definitions for a few names that didn't have them and update the list in the man page. --- man/rules/meson.build | 4 ++ man/sd-bus-errors.xml | 72 ++++++++++++++++------------- src/core/unit.c | 2 +- src/libsystemd/sd-bus/bus-control.c | 2 +- src/libsystemd/sd-bus/bus-error.c | 68 +++++++++++++-------------- src/systemd/sd-bus-protocol.h | 65 +++++++++++++------------- 6 files changed, 115 insertions(+), 98 deletions(-) diff --git a/man/rules/meson.build b/man/rules/meson.build index 39cc55a929..63a68c3211 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -85,6 +85,7 @@ manpages = [ 'SD_BUS_ERROR_INCONSISTENT_MESSAGE', 'SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED', 'SD_BUS_ERROR_INVALID_ARGS', + 'SD_BUS_ERROR_INVALID_FILE_CONTENT', 'SD_BUS_ERROR_INVALID_SIGNATURE', 'SD_BUS_ERROR_IO_ERROR', 'SD_BUS_ERROR_LIMITS_EXCEEDED', @@ -96,8 +97,11 @@ manpages = [ 'SD_BUS_ERROR_NO_NETWORK', 'SD_BUS_ERROR_NO_REPLY', 'SD_BUS_ERROR_NO_SERVER', + 'SD_BUS_ERROR_OBJECT_PATH_IN_USE', 'SD_BUS_ERROR_PROPERTY_READ_ONLY', + 'SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN', 'SD_BUS_ERROR_SERVICE_UNKNOWN', + 'SD_BUS_ERROR_TIMED_OUT', 'SD_BUS_ERROR_TIMEOUT', 'SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN', 'SD_BUS_ERROR_UNKNOWN_INTERFACE', diff --git a/man/sd-bus-errors.xml b/man/sd-bus-errors.xml index f3b1515c78..dc9d9fc63b 100644 --- a/man/sd-bus-errors.xml +++ b/man/sd-bus-errors.xml @@ -45,9 +45,13 @@ SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN SD_BUS_ERROR_INVALID_SIGNATURE SD_BUS_ERROR_INCONSISTENT_MESSAGE + SD_BUS_ERROR_TIMED_OUT SD_BUS_ERROR_MATCH_RULE_NOT_FOUND SD_BUS_ERROR_MATCH_RULE_INVALID SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED + SD_BUS_ERROR_INVALID_FILE_CONTENT + SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN + SD_BUS_ERROR_OBJECT_PATH_IN_USE Standard D-Bus error names @@ -56,38 +60,44 @@ #include <systemd/sd-bus.h> -#define SD_BUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" -#define SD_BUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" -#define SD_BUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" -#define SD_BUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" -#define SD_BUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" -#define SD_BUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" -#define SD_BUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" -#define SD_BUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" -#define SD_BUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" -#define SD_BUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" -#define SD_BUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" -#define SD_BUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" -#define SD_BUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" -#define SD_BUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" -#define SD_BUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" -#define SD_BUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" -#define SD_BUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" -#define SD_BUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" -#define SD_BUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" -#define SD_BUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" -#define SD_BUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" -#define SD_BUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface" -#define SD_BUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" -#define SD_BUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" -#define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" -#define SD_BUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" -#define SD_BUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage" -#define SD_BUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" -#define SD_BUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" + +#define SD_BUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" +#define SD_BUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" +#define SD_BUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" +#define SD_BUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" +#define SD_BUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" +#define SD_BUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" +#define SD_BUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" +#define SD_BUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" +#define SD_BUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" +#define SD_BUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" +#define SD_BUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" +#define SD_BUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" +#define SD_BUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" +#define SD_BUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" +#define SD_BUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" +#define SD_BUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" +#define SD_BUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" +#define SD_BUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" +#define SD_BUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" +#define SD_BUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" +#define SD_BUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" +#define SD_BUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface" +#define SD_BUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" +#define SD_BUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" +#define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" +#define SD_BUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" +#define SD_BUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage" +#define SD_BUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" +#define SD_BUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" +#define SD_BUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" #define SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED \ - "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" - + "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" +#define SD_BUS_ERROR_INVALID_FILE_CONTENT "org.freedesktop.DBus.Error.InvalidFileContent" +#define SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN \ + "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" +#define SD_BUS_ERROR_OBJECT_PATH_IN_USE "org.freedesktop.DBus.Error.ObjectPathInUse" + diff --git a/src/core/unit.c b/src/core/unit.c index e0deccc7b9..846d15b415 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3465,7 +3465,7 @@ static int get_name_owner_handler(sd_bus_message *message, void *userdata, sd_bu e = sd_bus_message_get_error(message); if (e) { - if (!sd_bus_error_has_name(e, "org.freedesktop.DBus.Error.NameHasNoOwner")) { + if (!sd_bus_error_has_name(e, SD_BUS_ERROR_NAME_HAS_NO_OWNER)) { r = sd_bus_error_get_errno(e); log_unit_error_errno(u, r, "Unexpected error response from GetNameOwner(): %s", diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index d96b7256a1..83d68562dc 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -693,7 +693,7 @@ _public_ int sd_bus_get_name_creds( "s", unique ?: name); if (r < 0) { - if (!sd_bus_error_has_name(&error, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown")) + if (!sd_bus_error_has_name(&error, SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN)) return r; /* no data is fine */ diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c index 413e2dd43f..7a2303350c 100644 --- a/src/libsystemd/sd-bus/bus-error.c +++ b/src/libsystemd/sd-bus/bus-error.c @@ -16,40 +16,40 @@ #include "strv.h" BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_standard_errors[] = { - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.Failed", EACCES), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NoMemory", ENOMEM), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.ServiceUnknown", EHOSTUNREACH), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NameHasNoOwner", ENXIO), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NoReply", ETIMEDOUT), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.IOError", EIO), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.BadAddress", EADDRNOTAVAIL), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NotSupported", EOPNOTSUPP), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.LimitsExceeded", ENOBUFS), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.AccessDenied", EACCES), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.AuthFailed", EACCES), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.InteractiveAuthorizationRequired", EACCES), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NoServer", EHOSTDOWN), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.Timeout", ETIMEDOUT), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.NoNetwork", ENONET), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.AddressInUse", EADDRINUSE), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.Disconnected", ECONNRESET), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.InvalidArgs", EINVAL), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.FileNotFound", ENOENT), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.FileExists", EEXIST), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.UnknownMethod", EBADR), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.UnknownObject", EBADR), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.UnknownInterface", EBADR), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.UnknownProperty", EBADR), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.PropertyReadOnly", EROFS), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.UnixProcessIdUnknown", ESRCH), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.InvalidSignature", EINVAL), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.InconsistentMessage", EBADMSG), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.TimedOut", ETIMEDOUT), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.MatchRuleInvalid", EINVAL), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.InvalidFileContent", EINVAL), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.MatchRuleNotFound", ENOENT), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", ESRCH), - SD_BUS_ERROR_MAP("org.freedesktop.DBus.Error.ObjectPathInUse", EBUSY), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_FAILED, EACCES), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NO_MEMORY, ENOMEM), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_SERVICE_UNKNOWN, EHOSTUNREACH), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NAME_HAS_NO_OWNER, ENXIO), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NO_REPLY, ETIMEDOUT), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_IO_ERROR, EIO), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_BAD_ADDRESS, EADDRNOTAVAIL), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NOT_SUPPORTED, EOPNOTSUPP), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_LIMITS_EXCEEDED, ENOBUFS), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_ACCESS_DENIED, EACCES), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_AUTH_FAILED, EACCES), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NO_SERVER, EHOSTDOWN), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_TIMEOUT, ETIMEDOUT), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_NO_NETWORK, ENONET), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_ADDRESS_IN_USE, EADDRINUSE), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_DISCONNECTED, ECONNRESET), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_INVALID_ARGS, EINVAL), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_FILE_NOT_FOUND, ENOENT), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_FILE_EXISTS, EEXIST), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_UNKNOWN_METHOD, EBADR), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_UNKNOWN_OBJECT, EBADR), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_UNKNOWN_INTERFACE, EBADR), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_UNKNOWN_PROPERTY, EBADR), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_PROPERTY_READ_ONLY, EROFS), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN, ESRCH), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_INVALID_SIGNATURE, EINVAL), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_INCONSISTENT_MESSAGE, EBADMSG), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_TIMED_OUT, ETIMEDOUT), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_MATCH_RULE_NOT_FOUND, ENOENT), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_MATCH_RULE_INVALID, EINVAL), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, EACCES), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_INVALID_FILE_CONTENT, EINVAL), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN, ESRCH), + SD_BUS_ERROR_MAP(SD_BUS_ERROR_OBJECT_PATH_IN_USE, EBUSY), SD_BUS_ERROR_MAP_END }; diff --git a/src/systemd/sd-bus-protocol.h b/src/systemd/sd-bus-protocol.h index 1581642275..25c9ab3358 100644 --- a/src/systemd/sd-bus-protocol.h +++ b/src/systemd/sd-bus-protocol.h @@ -62,37 +62,40 @@ enum { /* Well-known errors. Note that this is only a sanitized subset of the * errors that the reference implementation generates. */ -#define SD_BUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" -#define SD_BUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" -#define SD_BUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" -#define SD_BUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" -#define SD_BUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" -#define SD_BUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" -#define SD_BUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" -#define SD_BUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" -#define SD_BUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" -#define SD_BUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" -#define SD_BUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" -#define SD_BUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" -#define SD_BUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" -#define SD_BUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" -#define SD_BUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" -#define SD_BUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" -#define SD_BUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" -#define SD_BUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" -#define SD_BUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" -#define SD_BUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" -#define SD_BUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" -#define SD_BUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface" -#define SD_BUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" -#define SD_BUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" -#define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" -#define SD_BUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" -#define SD_BUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage" -#define SD_BUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" -#define SD_BUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" -#define SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED \ - "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" +#define SD_BUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" +#define SD_BUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" +#define SD_BUS_ERROR_SERVICE_UNKNOWN "org.freedesktop.DBus.Error.ServiceUnknown" +#define SD_BUS_ERROR_NAME_HAS_NO_OWNER "org.freedesktop.DBus.Error.NameHasNoOwner" +#define SD_BUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" +#define SD_BUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" +#define SD_BUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" +#define SD_BUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" +#define SD_BUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" +#define SD_BUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" +#define SD_BUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" +#define SD_BUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" +#define SD_BUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" +#define SD_BUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" +#define SD_BUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" +#define SD_BUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" +#define SD_BUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" +#define SD_BUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" +#define SD_BUS_ERROR_FILE_EXISTS "org.freedesktop.DBus.Error.FileExists" +#define SD_BUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" +#define SD_BUS_ERROR_UNKNOWN_OBJECT "org.freedesktop.DBus.Error.UnknownObject" +#define SD_BUS_ERROR_UNKNOWN_INTERFACE "org.freedesktop.DBus.Error.UnknownInterface" +#define SD_BUS_ERROR_UNKNOWN_PROPERTY "org.freedesktop.DBus.Error.UnknownProperty" +#define SD_BUS_ERROR_PROPERTY_READ_ONLY "org.freedesktop.DBus.Error.PropertyReadOnly" +#define SD_BUS_ERROR_UNIX_PROCESS_ID_UNKNOWN "org.freedesktop.DBus.Error.UnixProcessIdUnknown" +#define SD_BUS_ERROR_INVALID_SIGNATURE "org.freedesktop.DBus.Error.InvalidSignature" +#define SD_BUS_ERROR_INCONSISTENT_MESSAGE "org.freedesktop.DBus.Error.InconsistentMessage" +#define SD_BUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" +#define SD_BUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" +#define SD_BUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" +#define SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED "org.freedesktop.DBus.Error.InteractiveAuthorizationRequired" +#define SD_BUS_ERROR_INVALID_FILE_CONTENT "org.freedesktop.DBus.Error.InvalidFileContent" +#define SD_BUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" +#define SD_BUS_ERROR_OBJECT_PATH_IN_USE "org.freedesktop.DBus.Error.ObjectPathInUse" /* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature */ #define SD_BUS_MAXIMUM_SIGNATURE_LENGTH 255