1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 20:24:45 +02:00

Compare commits

...

26 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
d0b3039837
Merge pull request #19226 from keszybz/reenable-maybe-unitialized-warning
meson: re-enable -Wmaybe-uninitialized
2021-04-08 20:29:05 +02:00
Zbigniew Jędrzejewski-Szmek
d8e4c59785
Merge pull request #19250 from keszybz/sd-bus-is-ready-simplification
Simplify how sd_bus_is_ready() is used
2021-04-08 20:26:30 +02:00
Luca Boccassi
9f519e491f tests: allow for os-release quote variability in TEST-50-DISSECT
Quoting of values differs between distros: Fedora doesn't quote the ID_
fields, but CentOS does.
Adjust the test checks to account for this.

Fixes #19242
2021-04-08 16:16:55 +02:00
Zbigniew Jędrzejewski-Szmek
5dbec9bd32 networkd: simplify sd_bus_is_ready() checks
Also add "system" in the messages, because we set the internal value,
and are just skipping the setting of the external value, so the message
could be confusing without that clarification.
2021-04-08 15:04:18 +02:00
Zbigniew Jędrzejewski-Szmek
3bbb76f621 sd-bus: make sd_bus_is_{ready,open} accept NULL
We didn't document this behaviour one way or another, so I think it's
OK to change. All callers do the NULL check before callling this to avoid
the assert warning, so it seems reasonable to do it internally.

sd_bus_can_send() is similar, but there we expressly say that an
error is returned on NULL, so I didn't change it.
2021-04-08 14:59:10 +02:00
Yu Watanabe
a73f8e9f32 network: do not emit changed properties when bus connection is not ready
Prompted by #19212.
2021-04-08 14:48:46 +02:00
Yu Watanabe
ecb4b08c2e test: move check of nat table existence
As test_v4() with iptables backend will be called after nftables tests.

Follow-up for afbcd905526111e3a1bd55b0d6d5ee4413734735.
2021-04-08 14:39:53 +02:00
Zbigniew Jędrzejewski-Szmek
2fe2941646
Merge pull request #19237 from yuwata/udev-builtin-net-id-follow-ups-for-19017
udev: fix several issues around hotplug slot detection
2021-04-08 14:37:02 +02:00
Zbigniew Jędrzejewski-Szmek
68c98a411d meson: re-enable -Wmaybe-uninitialized on -O[02] with recent gcc versions
The warning was disabled in 8794164fed5f0142c34358613f92f4f761af4edd to avoid
false positives. But it is useful in finding errors, even if it sometimes
results in untrue warnings (c.f. 77fac974fe, da46a1bc3c).

After #19168, #19169, and #19175, there are no warnings with
-Dbuildtype=debug-optimized/-O2 and gcc-11.0.1-0.3.fc34.x86_64. Warnings
are reenabled for -O[23]

-O0 is good for development, and -O2 is the default optimization level for
Fedora package builds. -Os, -O3, -O1, and -Og still generate some warnings. In
fact, with -Os the number of warnings seems completely hopeless. Dozens and
dozens.
2021-04-08 13:12:56 +02:00
Zbigniew Jędrzejewski-Szmek
98d81cf974 home: use goto to make it clear that variables are initialized
gcc-11.0.1-0.3.fc34.x86_64 with -Og was complaining that 'r' might be
unitialized. It cannot, but let's rework the code to use a goto instead of
conditionalizing on 'call' being unset, which I think is clearer and less error
prone. This silences the warning.
2021-04-08 13:00:50 +02:00
Zbigniew Jędrzejewski-Szmek
3b9e6fb490 basic/strbuf: use _cleanup_ 2021-04-08 13:00:50 +02:00
Zbigniew Jędrzejewski-Szmek
a03e335b86 timedatectl: rework handling of conditions in print_status_info()
gcc-11.0.1-0.3.fc34.x86_64 was complaining that n might be unset with
--optimization=1. It was wrong, but let's rework the code to make it
obvious that it is always set.
2021-04-08 13:00:50 +02:00
Yu Watanabe
cb8c948738 udev: use snprintf_ok() 2021-04-08 01:38:47 +09:00
Yu Watanabe
5a6e56ec17 udev: fix potential infinite loop 2021-04-08 01:38:47 +09:00
Yu Watanabe
19ed9a114c udev: make dev_pci_slot() return earlier when PCI bridge is found 2021-04-08 01:38:47 +09:00
Yu Watanabe
c304cb0146 udev: use uint32_t for hotplug_slot
This also makes function id is parsed as uint64_t. Kernel internally
uses uint32_t for function id (see the definition of 'struct zpci_dev),
but it maybe extended in the future.
2021-04-08 01:38:43 +09:00
Yu Watanabe
fa28023c0f udev: split out logic of parsing s390 PCI slots
This also adds several debugging logs.
2021-04-08 01:35:43 +09:00
Yu Watanabe
70c35e4bfd udev: it is not necessary that the path is readable 2021-04-08 01:35:43 +09:00
Yu Watanabe
b08c3fbe0e udev: add missing initialization to fix freeing invalid address 2021-04-08 01:35:43 +09:00
Zbigniew Jędrzejewski-Szmek
46cbdcd9fe shared/format-table: use goto to make code flow clear
gcc 9.3.0 "cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" with --optimization=1 was
not able to figure out that all cases are covered because r is either set in
the switch or type < _TABLE_DATA_TYPE_MAX.

But for a human reader this might also not be obvious: the cases are not in
exactly the same order as enum definitions, and it's a long list. By using the
goto, there should be no doubt, and we avoid checking the condition a second
time.
2021-04-07 17:05:35 +02:00
Zbigniew Jędrzejewski-Szmek
4a3ad75efa shared/format-table: rework loop
Not a big difference, but I think it's a bit nicer this way.
2021-04-07 17:05:35 +02:00
Zbigniew Jędrzejewski-Szmek
f1e7cbaef7 sd-bus: make sd_bus_error_set() more like sd_bus_error_setfv()
In b9c19bc384fd41c173a8e453bd157544400af059, I added an assert to _setfv() and
_setf(), but I forgot to do the same in _set(). Let's do this for completeness.

While at it, restructure _set() to use the same style as _setfv().
2021-04-07 16:04:52 +02:00
Zbigniew Jędrzejewski-Szmek
1b09b81cf4 tree-wide: sd_bus_error_setf → set_bus_error_set
strdup() is more efficient than asprintf().
2021-04-07 16:04:52 +02:00
Zbigniew Jędrzejewski-Szmek
7756528e9b tree-wide: use the same comment for work-around initializations
This should make it easier to remove those warnings when the compiler
gets smarter. Not sure if I got them all...

Double space before the comment start to make it easier to separate from the
preceding line.
2021-04-07 16:04:22 +02:00
Zbigniew Jędrzejewski-Szmek
462035d599 sd-device: small modernization 2021-04-07 14:36:37 +02:00
Zbigniew Jędrzejewski-Szmek
9b4aba104e shared/base-filesystem: modernization 2021-04-07 14:36:25 +02:00
49 changed files with 345 additions and 321 deletions

View File

@ -57,6 +57,9 @@
zero outside of this state, and positive otherwise. Effectively, this function returns positive while regular zero outside of this state, and positive otherwise. Effectively, this function returns positive while regular
messages can be sent or received on the connection.</para> messages can be sent or received on the connection.</para>
<para>The <parameter>bus</parameter> argument may be <constant>NULL</constant>, zero is also returned in
that case.</para>
<para>To be notified when the connection is fully established, use <para>To be notified when the connection is fully established, use
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> and <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
install a match for the <function>Connected()</function> signal on the install a match for the <function>Connected()</function> signal on the
@ -68,8 +71,8 @@
<refsect1> <refsect1>
<title>Return Value</title> <title>Return Value</title>
<para>On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style <para>Those functions return 0 if the bus is <emphasis>not</emphasis> in the given state, and a positive
error code.</para> integer when it is. On failure, a negative errno-style error code is returned.</para>
<refsect2> <refsect2>
<title>Errors</title> <title>Errors</title>

View File

@ -395,10 +395,6 @@ possible_cc_flags = [
'-Wno-error=#warnings', # clang '-Wno-error=#warnings', # clang
'-Wno-string-plus-int', # clang '-Wno-string-plus-int', # clang
# Disable -Wmaybe-uninitialized, since it's noisy on gcc 8 with
# optimizations enabled, producing essentially false positives.
'-Wno-maybe-uninitialized',
'-ffast-math', '-ffast-math',
'-fno-common', '-fno-common',
'-fdiagnostics-show-option', '-fdiagnostics-show-option',
@ -409,6 +405,15 @@ possible_cc_flags = [
'--param=ssp-buffer-size=4', '--param=ssp-buffer-size=4',
] ]
# Disable -Wmaybe-unitialized when compiling with -Os/-O1/-O3/etc. There are
# too many false positives with gcc >= 8. Effectively, we only test with -O0
# and -O2; this should be enough to catch most important cases without too much
# busywork. See https://github.com/systemd/systemd/pull/19226.
if cc.get_id() == 'gcc' and (not '02'.contains(get_option('optimization')) or
cc.version().version_compare('<10'))
possible_cc_flags += '-Wno-maybe-uninitialized'
endif
# --as-needed and --no-undefined are provided by meson by default, # --as-needed and --no-undefined are provided by meson by default,
# run mesonconf to see what is enabled # run mesonconf to see what is enabled
possible_link_flags = [ possible_link_flags = [

View File

@ -660,7 +660,7 @@ int cg_remove_xattr(const char *controller, const char *path, const char *name)
int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) { int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
const char *fs, *controller_str = NULL; /* silence gcc warning about unitialized variable */ const char *fs, *controller_str = NULL; /* avoid false maybe-uninitialized warning */
int unified, r; int unified, r;
assert(pid >= 0); assert(pid >= 0);

View File

@ -1072,7 +1072,7 @@ int copy_file_full(
_cleanup_close_ int fdf = -1; _cleanup_close_ int fdf = -1;
struct stat st; struct stat st;
int fdt = -1, r; int r, fdt = -1; /* avoid false maybe-uninitialized warning */
assert(from); assert(from);
assert(to); assert(to);

View File

@ -107,11 +107,9 @@ static void bubbleinsert(struct strbuf_node *node,
/* add string, return the index/offset into the buffer */ /* add string, return the index/offset into the buffer */
ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) { ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
uint8_t c; uint8_t c;
struct strbuf_node *node;
size_t depth;
char *buf_new; char *buf_new;
struct strbuf_child_entry *child; struct strbuf_child_entry *child;
struct strbuf_node *node_child; struct strbuf_node *node;
ssize_t off; ssize_t off;
if (!str->root) if (!str->root)
@ -127,7 +125,7 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
str->in_len += len; str->in_len += len;
node = str->root; node = str->root;
for (depth = 0; depth <= len; depth++) { for (size_t depth = 0; depth <= len; depth++) {
struct strbuf_child_entry search; struct strbuf_child_entry search;
/* match against current node */ /* match against current node */
@ -159,6 +157,8 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
str->buf[str->len++] = '\0'; str->buf[str->len++] = '\0';
/* new node */ /* new node */
_cleanup_free_ struct strbuf_node *node_child = NULL;
node_child = new(struct strbuf_node, 1); node_child = new(struct strbuf_node, 1);
if (!node_child) if (!node_child)
return -ENOMEM; return -ENOMEM;
@ -169,15 +169,13 @@ ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
/* extend array, add new entry, sort for bisection */ /* extend array, add new entry, sort for bisection */
child = reallocarray(node->children, node->children_count + 1, sizeof(struct strbuf_child_entry)); child = reallocarray(node->children, node->children_count + 1, sizeof(struct strbuf_child_entry));
if (!child) { if (!child)
free(node_child);
return -ENOMEM; return -ENOMEM;
}
str->nodes_count++; str->nodes_count++;
node->children = child; node->children = child;
bubbleinsert(node, c, node_child); bubbleinsert(node, c, TAKE_PTR(node_child));
return off; return off;
} }

View File

@ -422,7 +422,7 @@ static int bus_cgroup_set_transient_property(
int b; int b;
if (!UNIT_VTABLE(u)->can_delegate) if (!UNIT_VTABLE(u)->can_delegate)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type");
r = sd_bus_message_read(message, "b", &b); r = sd_bus_message_read(message, "b", &b);
if (r < 0) if (r < 0)
@ -441,7 +441,7 @@ static int bus_cgroup_set_transient_property(
CGroupMask mask = 0; CGroupMask mask = 0;
if (streq(name, "DelegateControllers") && !UNIT_VTABLE(u)->can_delegate) if (streq(name, "DelegateControllers") && !UNIT_VTABLE(u)->can_delegate)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type");
r = sd_bus_message_enter_container(message, 'a', "s"); r = sd_bus_message_enter_container(message, 'a', "s");
if (r < 0) if (r < 0)
@ -944,7 +944,7 @@ int bus_cgroup_set_property(
return r; return r;
if (u64 <= 0) if (u64 <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "CPUQuotaPerSecUSec= value out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "CPUQuotaPerSecUSec= value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->cpu_quota_per_sec_usec = u64; c->cpu_quota_per_sec_usec = u64;
@ -1122,7 +1122,7 @@ int bus_cgroup_set_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!CGROUP_WEIGHT_IS_OK(weight) || weight == CGROUP_WEIGHT_INVALID) if (!CGROUP_WEIGHT_IS_OK(weight) || weight == CGROUP_WEIGHT_INVALID)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "IODeviceWeight= value out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "IODeviceWeight= value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
CGroupIODeviceWeight *a = NULL, *b; CGroupIODeviceWeight *a = NULL, *b;
@ -1380,7 +1380,7 @@ int bus_cgroup_set_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path '%s' specified in %s= is not normalized.", name, path);
if (!CGROUP_BLKIO_WEIGHT_IS_OK(weight) || weight == CGROUP_BLKIO_WEIGHT_INVALID) if (!CGROUP_BLKIO_WEIGHT_IS_OK(weight) || weight == CGROUP_BLKIO_WEIGHT_INVALID)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "BlockIODeviceWeight= out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "BlockIODeviceWeight= out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
CGroupBlockIODeviceWeight *a = NULL, *b; CGroupBlockIODeviceWeight *a = NULL, *b;
@ -1476,12 +1476,12 @@ int bus_cgroup_set_property(
while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) { while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) {
if (!valid_device_allow_pattern(path) || strpbrk(path, WHITESPACE)) if (!valid_device_allow_pattern(path) || strpbrk(path, WHITESPACE))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires device node or pattern"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires device node or pattern");
if (isempty(rwm)) if (isempty(rwm))
rwm = "rwm"; rwm = "rwm";
else if (!in_charset(rwm, "rwm")) else if (!in_charset(rwm, "rwm"))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires combination of rwm flags"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "DeviceAllow= requires combination of rwm flags");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
CGroupDeviceAllow *a = NULL, *b; CGroupDeviceAllow *a = NULL, *b;

View File

@ -2060,7 +2060,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!log_level_is_valid(level)) if (!log_level_is_valid(level))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Log level value out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Log level value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->syslog_priority = (c->syslog_priority & LOG_FACMASK) | level; c->syslog_priority = (c->syslog_priority & LOG_FACMASK) | level;
@ -2077,7 +2077,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!log_facility_unshifted_is_valid(facility)) if (!log_facility_unshifted_is_valid(facility))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Log facility value out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Log facility value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->syslog_priority = (facility << 3) | LOG_PRI(c->syslog_priority); c->syslog_priority = (facility << 3) | LOG_PRI(c->syslog_priority);
@ -2094,7 +2094,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!isempty(n) && !log_namespace_name_valid(n)) if (!isempty(n) && !log_namespace_name_valid(n))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Log namespace name not valid"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Log namespace name not valid");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
@ -2140,13 +2140,13 @@ int bus_exec_context_set_transient_property(
break; break;
if (memchr(p, 0, sz)) if (memchr(p, 0, sz))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field contains zero byte"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field contains zero byte");
eq = memchr(p, '=', sz); eq = memchr(p, '=', sz);
if (!eq) if (!eq)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field contains no '=' character"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field contains no '=' character");
if (!journal_field_valid(p, eq - (const char*) p, false)) if (!journal_field_valid(p, eq - (const char*) p, false))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field invalid"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field invalid");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
t = reallocarray(c->log_extra_fields, c->n_log_extra_fields+1, sizeof(struct iovec)); t = reallocarray(c->log_extra_fields, c->n_log_extra_fields+1, sizeof(struct iovec));
@ -2163,7 +2163,7 @@ int bus_exec_context_set_transient_property(
((uint8_t*) copy)[sz] = 0; ((uint8_t*) copy)[sz] = 0;
if (!utf8_is_valid(copy)) if (!utf8_is_valid(copy))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field is not valid UTF-8"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field is not valid UTF-8");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->log_extra_fields[c->n_log_extra_fields++] = IOVEC_MAKE(copy, sz); c->log_extra_fields[c->n_log_extra_fields++] = IOVEC_MAKE(copy, sz);
@ -2649,7 +2649,7 @@ int bus_exec_context_set_transient_property(
missing_ok = false; missing_ok = false;
if (!isempty(s) && !streq(s, "~") && !path_is_absolute(s)) if (!isempty(s) && !streq(s, "~") && !path_is_absolute(s))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "WorkingDirectory= expects an absolute path or '~'"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "WorkingDirectory= expects an absolute path or '~'");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (streq(s, "~")) { if (streq(s, "~")) {
@ -2678,7 +2678,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!isempty(s) && !fdname_is_valid(s)) if (!isempty(s) && !fdname_is_valid(s))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid file descriptor name"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid file descriptor name");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
@ -2830,7 +2830,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!strv_env_is_valid(l)) if (!strv_env_is_valid(l))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment block."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment block.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) { if (strv_isempty(l)) {
@ -2864,7 +2864,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!strv_env_name_or_assignment_is_valid(l)) if (!strv_env_name_or_assignment_is_valid(l))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UnsetEnvironment= list."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UnsetEnvironment= list.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) { if (strv_isempty(l)) {
@ -2897,7 +2897,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!oom_score_adjust_is_valid(oa)) if (!oom_score_adjust_is_valid(oa))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "OOM score adjust value out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "OOM score adjust value out of range");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
c->oom_score_adjust = oa; c->oom_score_adjust = oa;
@ -3018,7 +3018,7 @@ int bus_exec_context_set_transient_property(
return r; return r;
if (!strv_env_name_is_valid(l)) if (!strv_env_name_is_valid(l))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PassEnvironment= block."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PassEnvironment= block.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (strv_isempty(l)) { if (strv_isempty(l)) {
@ -3193,7 +3193,7 @@ int bus_exec_context_set_transient_property(
if (!path_is_absolute(destination)) if (!path_is_absolute(destination))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path %s is not absolute.", destination); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path %s is not absolute.", destination);
if (!IN_SET(mount_flags, 0, MS_REC)) if (!IN_SET(mount_flags, 0, MS_REC))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown mount flags."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown mount flags.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
r = bind_mount_add(&c->bind_mounts, &c->n_bind_mounts, r = bind_mount_add(&c->bind_mounts, &c->n_bind_mounts,

View File

@ -380,7 +380,7 @@ static int bus_get_unit_by_name(Manager *m, sd_bus_message *message, const char
u = manager_get_unit_by_pid(m, pid); u = manager_get_unit_by_pid(m, pid);
if (!u) if (!u)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Client not member of any unit."); return sd_bus_error_set(error, BUS_ERROR_NO_SUCH_UNIT, "Client not member of any unit.");
} else { } else {
u = manager_get_unit(m, name); u = manager_get_unit(m, name);
if (!u) if (!u)
@ -504,7 +504,7 @@ static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userd
else if (sz == 16) else if (sz == 16)
memcpy(&id, a, sz); memcpy(&id, a, sz);
else else
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid invocation ID"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid invocation ID");
if (sd_id128_is_null(id)) { if (sd_id128_is_null(id)) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@ -1235,7 +1235,7 @@ static int method_subscribe(sd_bus_message *message, void *userdata, sd_bus_erro
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, BUS_ERROR_ALREADY_SUBSCRIBED, "Client is already subscribed."); return sd_bus_error_set(error, BUS_ERROR_ALREADY_SUBSCRIBED, "Client is already subscribed.");
} }
return sd_bus_reply_method_return(message, NULL); return sd_bus_reply_method_return(message, NULL);
@ -1259,7 +1259,7 @@ static int method_unsubscribe(sd_bus_message *message, void *userdata, sd_bus_er
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed."); return sd_bus_error_set(error, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed.");
} }
return sd_bus_reply_method_return(message, NULL); return sd_bus_reply_method_return(message, NULL);
@ -1309,7 +1309,7 @@ static int method_dump_by_fd(sd_bus_message *message, void *userdata, sd_bus_err
} }
static int method_refuse_snapshot(sd_bus_message *message, void *userdata, sd_bus_error *error) { static int method_refuse_snapshot(sd_bus_message *message, void *userdata, sd_bus_error *error) {
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Support for snapshots has been removed."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Support for snapshots has been removed.");
} }
static int verify_run_space(const char *message, sd_bus_error *error) { static int verify_run_space(const char *message, sd_bus_error *error) {
@ -1624,7 +1624,7 @@ static int method_set_environment(sd_bus_message *message, void *userdata, sd_bu
if (r < 0) if (r < 0)
return r; return r;
if (!strv_env_is_valid(plus)) if (!strv_env_is_valid(plus))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
r = bus_verify_set_environment_async(m, message, error); r = bus_verify_set_environment_async(m, message, error);
if (r < 0) if (r < 0)
@ -1729,7 +1729,7 @@ static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_
return r; return r;
if (MANAGER_IS_SYSTEM(m) && detect_container() <= 0) if (MANAGER_IS_SYSTEM(m) && detect_container() <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "ExitCode can only be set for user service managers or in containers."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "ExitCode can only be set for user service managers or in containers.");
m->return_value = code; m->return_value = code;

View File

@ -133,7 +133,7 @@ static int bus_scope_set_transient_property(
/* We can't support direct connections with this, as direct connections know no service or unique name /* We can't support direct connections with this, as direct connections know no service or unique name
* concept, but the Controller field stores exactly that. */ * concept, but the Controller field stores exactly that. */
if (sd_bus_message_get_bus(message) != u->manager->api_bus) if (sd_bus_message_get_bus(message) != u->manager->api_bus)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Sorry, Controller= logic only supported via the bus."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Sorry, Controller= logic only supported via the bus.");
r = sd_bus_message_read(message, "s", &controller); r = sd_bus_message_read(message, "s", &controller);
if (r < 0) if (r < 0)

View File

@ -109,7 +109,7 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
assert(u); assert(u);
if (!MANAGER_IS_SYSTEM(u->manager)) if (!MANAGER_IS_SYSTEM(u->manager))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Adding bind mounts at runtime is only supported for system managers."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Adding bind mounts at runtime is only supported for system managers.");
r = mac_selinux_unit_access_check(u, message, "start", error); r = mac_selinux_unit_access_check(u, message, "start", error);
if (r < 0) if (r < 0)
@ -120,12 +120,12 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
return r; return r;
if (!path_is_absolute(src) || !path_is_normalized(src)) if (!path_is_absolute(src) || !path_is_normalized(src))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute and normalized."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute and normalized.");
if (!is_image && isempty(dest)) if (!is_image && isempty(dest))
dest = src; dest = src;
else if (!path_is_absolute(dest) || !path_is_normalized(dest)) else if (!path_is_absolute(dest) || !path_is_normalized(dest))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute and normalized."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute and normalized.");
if (is_image) { if (is_image) {
r = bus_read_mount_options(message, error, &options, NULL, ""); r = bus_read_mount_options(message, error, &options, NULL, "");
@ -147,23 +147,23 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (u->type != UNIT_SERVICE) if (u->type != UNIT_SERVICE)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not of type .service"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not of type .service");
/* If it would be dropped at startup time, return an error. The context should always be available, but /* If it would be dropped at startup time, return an error. The context should always be available, but
* there's an assert in exec_needs_mount_namespace, so double-check just in case. */ * there's an assert in exec_needs_mount_namespace, so double-check just in case. */
c = unit_get_exec_context(u); c = unit_get_exec_context(u);
if (!c) if (!c)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot access unit execution context"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot access unit execution context");
if (path_startswith_strv(dest, c->inaccessible_paths)) if (path_startswith_strv(dest, c->inaccessible_paths))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "%s is not accessible to this unit", dest); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "%s is not accessible to this unit", dest);
/* Ensure that the unit was started in a private mount namespace */ /* Ensure that the unit was started in a private mount namespace */
if (!exec_needs_mount_namespace(c, NULL, unit_get_exec_runtime(u))) if (!exec_needs_mount_namespace(c, NULL, unit_get_exec_runtime(u)))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit not running in private mount namespace, cannot activate bind mount"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unit not running in private mount namespace, cannot activate bind mount");
unit_pid = unit_main_pid(u); unit_pid = unit_main_pid(u);
if (unit_pid == 0 || !UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) if (unit_pid == 0 || !UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u)))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not running"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not running");
propagate_directory = strjoina("/run/systemd/propagate/", u->id); propagate_directory = strjoina("/run/systemd/propagate/", u->id);
if (is_image) if (is_image)

View File

@ -183,7 +183,7 @@ static int timer_add_one_calendar_spec(
r = calendar_spec_from_string(str, &c); r = calendar_spec_from_string(str, &c);
if (r == -EINVAL) if (r == -EINVAL)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid calendar spec"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid calendar spec");
if (r < 0) if (r < 0)
return r; return r;

View File

@ -527,7 +527,7 @@ int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *
} }
if (!SIGNAL_VALID(signo)) if (!SIGNAL_VALID(signo))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Signal number out of range."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Signal number out of range.");
r = bus_verify_manage_units_async_full( r = bus_verify_manage_units_async_full(
u, u,
@ -653,7 +653,7 @@ int bus_unit_method_unref(sd_bus_message *message, void *userdata, sd_bus_error
r = bus_unit_track_remove_sender(u, message); r = bus_unit_track_remove_sender(u, message);
if (r == -EUNATCH) if (r == -EUNATCH)
return sd_bus_error_setf(error, BUS_ERROR_NOT_REFERENCED, "Unit has not been referenced yet."); return sd_bus_error_set(error, BUS_ERROR_NOT_REFERENCED, "Unit has not been referenced yet.");
if (r < 0) if (r < 0)
return r; return r;
@ -719,9 +719,9 @@ int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error
if (r == -EOPNOTSUPP) if (r == -EOPNOTSUPP)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not supporting cleaning.", u->id); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not supporting cleaning.", u->id);
if (r == -EUNATCH) if (r == -EUNATCH)
return sd_bus_error_setf(error, BUS_ERROR_NOTHING_TO_CLEAN, "No matching resources found."); return sd_bus_error_set(error, BUS_ERROR_NOTHING_TO_CLEAN, "No matching resources found.");
if (r == -EBUSY) if (r == -EBUSY)
return sd_bus_error_setf(error, BUS_ERROR_UNIT_BUSY, "Unit is not inactive or has pending job."); return sd_bus_error_set(error, BUS_ERROR_UNIT_BUSY, "Unit is not inactive or has pending job.");
if (r < 0) if (r < 0)
return r; return r;
@ -768,9 +768,9 @@ static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userda
if (r == -EOPNOTSUPP) if (r == -EOPNOTSUPP)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not support freezing.", u->id); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not support freezing.", u->id);
if (r == -EBUSY) if (r == -EBUSY)
return sd_bus_error_setf(error, BUS_ERROR_UNIT_BUSY, "Unit has a pending job."); return sd_bus_error_set(error, BUS_ERROR_UNIT_BUSY, "Unit has a pending job.");
if (r == -EHOSTDOWN) if (r == -EHOSTDOWN)
return sd_bus_error_setf(error, BUS_ERROR_UNIT_INACTIVE, "Unit is inactive."); return sd_bus_error_set(error, BUS_ERROR_UNIT_INACTIVE, "Unit is inactive.");
if (r == -EALREADY) if (r == -EALREADY)
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Previously requested freezer operation for unit '%s' is still in progress.", u->id); return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Previously requested freezer operation for unit '%s' is still in progress.", u->id);
if (r < 0) if (r < 0)
@ -1442,10 +1442,10 @@ int bus_unit_method_attach_processes(sd_bus_message *message, void *userdata, sd
} }
if (!unit_cgroup_delegate(u)) if (!unit_cgroup_delegate(u))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Process migration not available on non-delegated units."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Process migration not available on non-delegated units.");
if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u))) if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not active, refusing."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unit is not active, refusing.");
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID|SD_BUS_CREDS_PID, &creds); r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID|SD_BUS_CREDS_PID, &creds);
if (r < 0) if (r < 0)
@ -1930,7 +1930,7 @@ static int bus_unit_set_live_property(
return r; return r;
if (some_plus_minus && some_absolute) if (some_plus_minus && some_absolute)
return sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING, "Bad marker syntax."); return sd_bus_error_set(error, BUS_ERROR_BAD_UNIT_SETTING, "Bad marker syntax.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
if (some_absolute) if (some_absolute)
@ -1999,7 +1999,7 @@ static int bus_set_transient_exit_status(
return r; return r;
if (k > 255) if (k > 255)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Exit status must be in range 0…255 or negative."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Exit status must be in range 0…255 or negative.");
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
*p = k < 0 ? -1 : k; *p = k < 0 ? -1 : k;
@ -2205,11 +2205,11 @@ static int bus_unit_set_transient_property(
const char *s; const char *s;
if (!UNIT_HAS_CGROUP_CONTEXT(u)) if (!UNIT_HAS_CGROUP_CONTEXT(u))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "The slice property is only available for units with control groups."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "The slice property is only available for units with control groups.");
if (u->type == UNIT_SLICE) if (u->type == UNIT_SLICE)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Slice may not be set for slice units."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Slice may not be set for slice units.");
if (unit_has_name(u, SPECIAL_INIT_SCOPE)) if (unit_has_name(u, SPECIAL_INIT_SCOPE))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot set slice for init.scope"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot set slice for init.scope");
r = sd_bus_message_read(message, "s", &s); r = sd_bus_message_read(message, "s", &s);
if (r < 0) if (r < 0)

View File

@ -164,7 +164,7 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd
if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) || if (manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SERVICE) ||
manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) { manager_unit_inactive_or_pending(m, SPECIAL_DBUS_SOCKET)) {
r = sd_bus_error_setf(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down."); r = sd_bus_error_set(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
goto failed; goto failed;
} }

View File

@ -1367,7 +1367,7 @@ static int status_welcome(void) {
static int write_container_id(void) { static int write_container_id(void) {
const char *c; const char *c;
int r = 0; /* silence gcc warning about r being unitialized below */ int r = 0; /* avoid false maybe-uninitialized warning */
c = getenv("container"); c = getenv("container");
if (isempty(c)) if (isempty(c))

View File

@ -1732,13 +1732,13 @@ int manager_add_job(
assert(mode < _JOB_MODE_MAX); assert(mode < _JOB_MODE_MAX);
if (mode == JOB_ISOLATE && type != JOB_START) if (mode == JOB_ISOLATE && type != JOB_START)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Isolate is only valid for start."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Isolate is only valid for start.");
if (mode == JOB_ISOLATE && !unit->allow_isolate) if (mode == JOB_ISOLATE && !unit->allow_isolate)
return sd_bus_error_setf(error, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated."); return sd_bus_error_set(error, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
if (mode == JOB_TRIGGERING && type != JOB_STOP) if (mode == JOB_TRIGGERING && type != JOB_STOP)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "--job-mode=triggering is only valid for stop."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "--job-mode=triggering is only valid for stop.");
log_unit_debug(unit, "Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode)); log_unit_debug(unit, "Trying to enqueue job %s/%s/%s", unit->id, job_type_to_string(type), job_mode_to_string(mode));

View File

@ -250,7 +250,7 @@ int mac_selinux_generic_access_check(
if (!enforce) if (!enforce)
return 0; return 0;
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to get current context."); return sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to get current context.");
} }
tclass = "system"; tclass = "system";
@ -270,7 +270,7 @@ int mac_selinux_generic_access_check(
r = errno_or_else(EPERM); r = errno_or_else(EPERM);
if (enforce) if (enforce)
sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access."); sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access.");
} }
log_debug_errno(r, "SELinux access check scon=%s tcon=%s tclass=%s perm=%s state=%s path=%s cmdline=%s: %m", log_debug_errno(r, "SELinux access check scon=%s tcon=%s tclass=%s perm=%s state=%s path=%s cmdline=%s: %m",

View File

@ -59,7 +59,7 @@ int bus_message_read_home_record(sd_bus_message *m, UserRecordLoadFlags flags, U
r = user_record_load(hr, v, flags); r = user_record_load(hr, v, flags);
if (r < 0) if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "JSON data is not a valid identity record"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "JSON data is not a valid identity record");
*ret = TAKE_PTR(hr); *ret = TAKE_PTR(hr);
return 0; return 0;

View File

@ -437,19 +437,19 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
switch (e) { switch (e) {
case -EMSGSIZE: case -EMSGSIZE:
return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type cannot be shrunk"); return sd_bus_error_set(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type cannot be shrunk");
case -ETXTBSY: case -ETXTBSY:
return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type can only be shrunk offline"); return sd_bus_error_set(error, BUS_ERROR_BAD_HOME_SIZE, "File systems of this type can only be shrunk offline");
case -ERANGE: case -ERANGE:
return sd_bus_error_setf(error, BUS_ERROR_BAD_HOME_SIZE, "File system size too small"); return sd_bus_error_set(error, BUS_ERROR_BAD_HOME_SIZE, "File system size too small");
case -ENOLINK: case -ENOLINK:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "System does not support selected storage backend"); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "System does not support selected storage backend");
case -EPROTONOSUPPORT: case -EPROTONOSUPPORT:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "System does not support selected file system"); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "System does not support selected file system");
case -ENOTTY: case -ENOTTY:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Operation not supported on storage backend"); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Operation not supported on storage backend");
case -ESOCKTNOSUPPORT: case -ESOCKTNOSUPPORT:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Operation not supported on file system"); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Operation not supported on file system");
case -ENOKEY: case -ENOKEY:
return sd_bus_error_setf(error, BUS_ERROR_BAD_PASSWORD, "Password for home %s is incorrect or not sufficient for authentication.", h->user_name); return sd_bus_error_setf(error, BUS_ERROR_BAD_PASSWORD, "Password for home %s is incorrect or not sufficient for authentication.", h->user_name);
case -EBADSLT: case -EBADSLT:
@ -457,21 +457,21 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
case -EREMOTEIO: case -EREMOTEIO:
return sd_bus_error_setf(error, BUS_ERROR_BAD_RECOVERY_KEY, "Recovery key for home %s is incorrect or not sufficient for authentication.", h->user_name); return sd_bus_error_setf(error, BUS_ERROR_BAD_RECOVERY_KEY, "Recovery key for home %s is incorrect or not sufficient for authentication.", h->user_name);
case -ENOANO: case -ENOANO:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_PIN_NEEDED, "PIN for security token required."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_PIN_NEEDED, "PIN for security token required.");
case -ERFKILL: case -ERFKILL:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_PROTECTED_AUTHENTICATION_PATH_NEEDED, "Security token requires protected authentication path."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_PROTECTED_AUTHENTICATION_PATH_NEEDED, "Security token requires protected authentication path.");
case -EMEDIUMTYPE: case -EMEDIUMTYPE:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_USER_PRESENCE_NEEDED, "Security token requires user presence."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_USER_PRESENCE_NEEDED, "Security token requires user presence.");
case -ENOSTR: case -ENOSTR:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_ACTION_TIMEOUT, "Token action timeout. (User was supposed to verify presence or similar, by interacting with the token, and didn't do that in time.)"); return sd_bus_error_set(error, BUS_ERROR_TOKEN_ACTION_TIMEOUT, "Token action timeout. (User was supposed to verify presence or similar, by interacting with the token, and didn't do that in time.)");
case -EOWNERDEAD: case -EOWNERDEAD:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_PIN_LOCKED, "PIN of security token locked."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_PIN_LOCKED, "PIN of security token locked.");
case -ENOLCK: case -ENOLCK:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_BAD_PIN, "Bad PIN of security token."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_BAD_PIN, "Bad PIN of security token.");
case -ETOOMANYREFS: case -ETOOMANYREFS:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_BAD_PIN_FEW_TRIES_LEFT, "Bad PIN of security token, and only a few tries left."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_BAD_PIN_FEW_TRIES_LEFT, "Bad PIN of security token, and only a few tries left.");
case -EUCLEAN: case -EUCLEAN:
return sd_bus_error_setf(error, BUS_ERROR_TOKEN_BAD_PIN_ONE_TRY_LEFT, "Bad PIN of security token, and only one try left."); return sd_bus_error_set(error, BUS_ERROR_TOKEN_BAD_PIN_ONE_TRY_LEFT, "Bad PIN of security token, and only one try left.");
case -EBUSY: case -EBUSY:
return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "Home %s is currently being used, or an operation on home %s is currently being executed.", h->user_name, h->user_name); return sd_bus_error_setf(error, BUS_ERROR_HOME_BUSY, "Home %s is currently being used, or an operation on home %s is currently being executed.", h->user_name, h->user_name);
case -ENOEXEC: case -ENOEXEC:
@ -1104,7 +1104,7 @@ static int home_ratelimit(Home *h, sd_bus_error *error) {
return sd_bus_error_setf(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT, "Too many login attempts, please try again in %s!", return sd_bus_error_setf(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT, "Too many login attempts, please try again in %s!",
format_timespan(buf, sizeof(buf), t - n, USEC_PER_SEC)); format_timespan(buf, sizeof(buf), t - n, USEC_PER_SEC));
return sd_bus_error_setf(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT, "Too many login attempts, please try again later."); return sd_bus_error_set(error, BUS_ERROR_AUTHENTICATION_LIMIT_HIT, "Too many login attempts, please try again later.");
} }
return 0; return 0;
@ -1402,10 +1402,10 @@ static int home_update_internal(
assert(hr); assert(hr);
if (!user_record_compatible(hr, h->record)) if (!user_record_compatible(hr, h->record))
return sd_bus_error_setf(error, BUS_ERROR_HOME_RECORD_MISMATCH, "Updated user record is not compatible with existing one."); return sd_bus_error_set(error, BUS_ERROR_HOME_RECORD_MISMATCH, "Updated user record is not compatible with existing one.");
c = user_record_compare_last_change(hr, h->record); /* refuse downgrades */ c = user_record_compare_last_change(hr, h->record); /* refuse downgrades */
if (c < 0) if (c < 0)
return sd_bus_error_setf(error, BUS_ERROR_HOME_RECORD_DOWNGRADE, "Refusing to update to older home record."); return sd_bus_error_set(error, BUS_ERROR_HOME_RECORD_DOWNGRADE, "Refusing to update to older home record.");
if (!secret && FLAGS_SET(hr->mask, USER_RECORD_SECRET)) { if (!secret && FLAGS_SET(hr->mask, USER_RECORD_SECRET)) {
r = user_record_clone(hr, USER_RECORD_EXTRACT_SECRET, &saved_secret); r = user_record_clone(hr, USER_RECORD_EXTRACT_SECRET, &saved_secret);
@ -1454,7 +1454,7 @@ static int home_update_internal(
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, BUS_ERROR_HOME_RECORD_MISMATCH, "Home record different but timestamp remained the same, refusing."); return sd_bus_error_set(error, BUS_ERROR_HOME_RECORD_MISMATCH, "Home record different but timestamp remained the same, refusing.");
} }
r = home_start_work(h, verb, new_hr, secret); r = home_start_work(h, verb, new_hr, secret);
@ -1528,7 +1528,7 @@ int home_resize(Home *h, uint64_t disk_size, UserRecord *secret, sd_bus_error *e
if (disk_size == UINT64_MAX || disk_size == h->record->disk_size) { if (disk_size == UINT64_MAX || disk_size == h->record->disk_size) {
if (h->record->disk_size == UINT64_MAX) if (h->record->disk_size == UINT64_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "No disk size to resize to specified."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "No disk size to resize to specified.");
c = user_record_ref(h->record); /* Shortcut if size is unspecified or matches the record */ c = user_record_ref(h->record); /* Shortcut if size is unspecified or matches the record */
} else { } else {
@ -2349,6 +2349,8 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
assert(o); assert(o);
assert(o->type == OPERATION_ACQUIRE); assert(o->type == OPERATION_ACQUIRE);
assert(!h->current_operation);
switch (home_get_state(h)) { switch (home_get_state(h)) {
case HOME_UNFIXATED: case HOME_UNFIXATED:
@ -2357,8 +2359,9 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
break; break;
case HOME_ABSENT: case HOME_ABSENT:
r = sd_bus_error_setf(&error, BUS_ERROR_HOME_ABSENT, "Home %s is currently missing or not plugged in.", h->user_name); r = sd_bus_error_setf(&error, BUS_ERROR_HOME_ABSENT,
break; "Home %s is currently missing or not plugged in.", h->user_name);
goto check;
case HOME_INACTIVE: case HOME_INACTIVE:
case HOME_DIRTY: case HOME_DIRTY:
@ -2382,14 +2385,11 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
return 0; return 0;
} }
assert(!h->current_operation); r = home_ratelimit(h, &error);
if (r >= 0)
if (call) { r = call(h, o->secret, for_state, &error);
r = home_ratelimit(h, &error);
if (r >= 0)
r = call(h, o->secret, for_state, &error);
}
check:
if (r != 0) /* failure or completed */ if (r != 0) /* failure or completed */
operation_result(o, r, &error); operation_result(o, r, &error);
else /* ongoing */ else /* ongoing */
@ -2660,7 +2660,7 @@ int home_schedule_operation(Home *h, Operation *o, sd_bus_error *error) {
if (o) { if (o) {
if (ordered_set_size(h->pending_operations) >= PENDING_OPERATIONS_MAX) if (ordered_set_size(h->pending_operations) >= PENDING_OPERATIONS_MAX)
return sd_bus_error_setf(error, BUS_ERROR_TOO_MANY_OPERATIONS, "Too many client operations requested"); return sd_bus_error_set(error, BUS_ERROR_TOO_MANY_OPERATIONS, "Too many client operations requested");
r = ordered_set_ensure_put(&h->pending_operations, &operation_hash_ops, o); r = ordered_set_ensure_put(&h->pending_operations, &operation_hash_ops, o);
if (r < 0) if (r < 0)

View File

@ -1457,7 +1457,7 @@ int manager_sign_user_record(Manager *m, UserRecord *u, UserRecord **ret, sd_bus
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, BUS_ERROR_NO_PRIVATE_KEY, "Can't sign without local key."); return sd_bus_error_set(error, BUS_ERROR_NO_PRIVATE_KEY, "Can't sign without local key.");
return user_record_sign(u, m->private_key, ret); return user_record_sign(u, m->private_key, ret);
} }

View File

@ -1351,16 +1351,16 @@ int user_record_is_supported(UserRecord *hr, sd_bus_error *error) {
assert(hr); assert(hr);
if (hr->disposition >= 0 && hr->disposition != USER_REGULAR) if (hr->disposition >= 0 && hr->disposition != USER_REGULAR)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot manage anything but regular users."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Cannot manage anything but regular users.");
if (hr->storage >= 0 && !IN_SET(hr->storage, USER_LUKS, USER_DIRECTORY, USER_SUBVOLUME, USER_FSCRYPT, USER_CIFS)) if (hr->storage >= 0 && !IN_SET(hr->storage, USER_LUKS, USER_DIRECTORY, USER_SUBVOLUME, USER_FSCRYPT, USER_CIFS))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "User record has storage type this service cannot manage."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "User record has storage type this service cannot manage.");
if (gid_is_valid(hr->gid) && hr->uid != (uid_t) hr->gid) if (gid_is_valid(hr->gid) && hr->uid != (uid_t) hr->gid)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "User record has to have matching UID/GID fields."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "User record has to have matching UID/GID fields.");
if (hr->service && !streq(hr->service, "io.systemd.Home")) if (hr->service && !streq(hr->service, "io.systemd.Home"))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not accepted with service not matching io.systemd.Home."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Not accepted with service not matching io.systemd.Home.");
return 0; return 0;
} }

View File

@ -1080,7 +1080,7 @@ static int method_cancel_transfer(sd_bus_message *msg, void *userdata, sd_bus_er
if (r < 0) if (r < 0)
return r; return r;
if (id <= 0) if (id <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid transfer id"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid transfer id");
t = hashmap_get(m->transfers, UINT32_TO_PTR(id)); t = hashmap_get(m->transfers, UINT32_TO_PTR(id));
if (!t) if (!t)

View File

@ -212,27 +212,29 @@ _public_ void sd_bus_error_free(sd_bus_error *e) {
} }
_public_ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message) { _public_ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *message) {
int r;
if (!name) if (!name)
return 0; return 0;
if (!e)
goto finish;
assert_return(!bus_error_is_dirty(e), -EINVAL); if (e) {
assert_return(!bus_error_is_dirty(e), -EINVAL);
e->name = strdup(name); e->name = strdup(name);
if (!e->name) { if (!e->name) {
*e = BUS_ERROR_OOM; *e = BUS_ERROR_OOM;
return -ENOMEM; return -ENOMEM;
}
if (message)
e->message = strdup(message);
e->_need_free = 1;
} }
if (message) r = bus_error_name_to_errno(name);
e->message = strdup(message); assert(r > 0);
return -r;
e->_need_free = 1;
finish:
return -bus_error_name_to_errno(name);
} }
int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) { int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) {

View File

@ -1800,7 +1800,9 @@ void bus_enter_closing(sd_bus *bus) {
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus, sd_bus, bus_free); DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus, sd_bus, bus_free);
_public_ int sd_bus_is_open(sd_bus *bus) { _public_ int sd_bus_is_open(sd_bus *bus) {
assert_return(bus, -EINVAL); if (!bus)
return 0;
assert_return(bus = bus_resolve(bus), -ENOPKG); assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(!bus_pid_changed(bus), -ECHILD); assert_return(!bus_pid_changed(bus), -ECHILD);
@ -1808,7 +1810,9 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
} }
_public_ int sd_bus_is_ready(sd_bus *bus) { _public_ int sd_bus_is_ready(sd_bus *bus) {
assert_return(bus, -EINVAL); if (!bus)
return 0;
assert_return(bus = bus_resolve(bus), -ENOPKG); assert_return(bus = bus_resolve(bus), -ENOPKG);
assert_return(!bus_pid_changed(bus), -ECHILD); assert_return(!bus_pid_changed(bus), -ECHILD);
@ -2410,7 +2414,7 @@ _public_ int sd_bus_call(
return 1; return 1;
} }
return sd_bus_error_setf(error, SD_BUS_ERROR_INCONSISTENT_MESSAGE, "Reply message contained file descriptors which I couldn't accept. Sorry."); return sd_bus_error_set(error, SD_BUS_ERROR_INCONSISTENT_MESSAGE, "Reply message contained file descriptors which I couldn't accept. Sorry.");
} else if (incoming->header->type == SD_BUS_MESSAGE_METHOD_ERROR) } else if (incoming->header->type == SD_BUS_MESSAGE_METHOD_ERROR)
return sd_bus_error_copy(error, &incoming->error); return sd_bus_error_copy(error, &incoming->error);

View File

@ -491,7 +491,6 @@ int device_read_uevent_file(sd_device *device) {
const char *syspath, *key = NULL, *value = NULL, *major = NULL, *minor = NULL; const char *syspath, *key = NULL, *value = NULL, *major = NULL, *minor = NULL;
char *path; char *path;
size_t uevent_len; size_t uevent_len;
unsigned i;
int r; int r;
enum { enum {
@ -527,7 +526,7 @@ int device_read_uevent_file(sd_device *device) {
device->uevent_loaded = true; device->uevent_loaded = true;
for (i = 0; i < uevent_len; i++) for (size_t i = 0; i < uevent_len; i++)
switch (state) { switch (state) {
case PRE_KEY: case PRE_KEY:
if (!strchr(NEWLINE, uevent[i])) { if (!strchr(NEWLINE, uevent[i])) {
@ -706,7 +705,7 @@ static int device_new_from_child(sd_device **ret, sd_device *child) {
pos = strrchr(subdir, '/'); pos = strrchr(subdir, '/');
if (!pos || pos < subdir + 2) if (!pos || pos < subdir + 2)
break; return -ENODEV;
*pos = '\0'; *pos = '\0';
@ -716,8 +715,6 @@ static int device_new_from_child(sd_device **ret, sd_device *child) {
return 0; return 0;
} }
return -ENODEV;
} }
_public_ int sd_device_get_parent(sd_device *child, sd_device **ret) { _public_ int sd_device_get_parent(sd_device *child, sd_device **ret) {
@ -1321,7 +1318,7 @@ int device_get_id_filename(sd_device *device, const char **ret) {
int device_read_db_internal_filename(sd_device *device, const char *filename) { int device_read_db_internal_filename(sd_device *device, const char *filename) {
_cleanup_free_ char *db = NULL; _cleanup_free_ char *db = NULL;
const char *value; const char *value;
size_t db_len, i; size_t db_len;
char key; char key;
int r; int r;
@ -1349,7 +1346,7 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) {
device->db_loaded = true; device->db_loaded = true;
for (i = 0; i < db_len; i++) { for (size_t i = 0; i < db_len; i++) {
switch (state) { switch (state) {
case PRE_KEY: case PRE_KEY:
if (!strchr(NEWLINE, db[i])) { if (!strchr(NEWLINE, db[i])) {
@ -1387,7 +1384,8 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) {
db[i] = '\0'; db[i] = '\0';
r = handle_db_line(device, key, value); r = handle_db_line(device, key, value);
if (r < 0) if (r < 0)
log_device_debug_errno(device, r, "sd-device: Failed to handle db entry '%c:%s', ignoring: %m", key, value); log_device_debug_errno(device, r, "sd-device: Failed to handle db entry '%c:%s', ignoring: %m",
key, value);
state = PRE_KEY; state = PRE_KEY;
} }

View File

@ -399,7 +399,7 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
r = locale_read_data(c, m); r = locale_read_data(c, m);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to read locale data: %m"); log_error_errno(r, "Failed to read locale data: %m");
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Failed to read locale data"); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Failed to read locale data");
} }
/* Merge with the current settings */ /* Merge with the current settings */
@ -673,7 +673,7 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
r = x11_read_data(c, m); r = x11_read_data(c, m);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to read x11 keyboard layout data: %m"); log_error_errno(r, "Failed to read x11 keyboard layout data: %m");
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Failed to read x11 keyboard layout data"); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Failed to read x11 keyboard layout data");
} }
if (streq_ptr(layout, c->x11_layout) && if (streq_ptr(layout, c->x11_layout) &&
@ -686,7 +686,7 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
(model && !string_is_safe(model)) || (model && !string_is_safe(model)) ||
(variant && !string_is_safe(variant)) || (variant && !string_is_safe(variant)) ||
(options && !string_is_safe(options))) (options && !string_is_safe(options)))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Received invalid keyboard data"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Received invalid keyboard data");
r = verify_xkb_rmlvo(model, layout, variant, options); r = verify_xkb_rmlvo(model, layout, variant, options);
if (r < 0) { if (r < 0) {
@ -694,7 +694,7 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
strempty(model), strempty(layout), strempty(variant), strempty(options)); strempty(model), strempty(layout), strempty(variant), strempty(options));
if (r == -EOPNOTSUPP) if (r == -EOPNOTSUPP)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Local keyboard configuration not supported on this system."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Local keyboard configuration not supported on this system.");
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Specified keymap cannot be compiled, refusing as invalid."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Specified keymap cannot be compiled, refusing as invalid.");
} }

View File

@ -695,9 +695,9 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
return r; return r;
if (!uid_is_valid(uid)) if (!uid_is_valid(uid))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UID"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UID");
if (leader < 0 || leader == 1 || leader == getpid_cached()) if (leader < 0 || leader == 1 || leader == getpid_cached())
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID");
if (isempty(type)) if (isempty(type))
t = _SESSION_TYPE_INVALID; t = _SESSION_TYPE_INVALID;
@ -831,7 +831,7 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
vtnr < m->seat0->position_count && vtnr < m->seat0->position_count &&
m->seat0->positions[vtnr] && m->seat0->positions[vtnr] &&
m->seat0->positions[vtnr]->class != SESSION_GREETER) m->seat0->positions[vtnr]->class != SESSION_GREETER)
return sd_bus_error_setf(error, BUS_ERROR_SESSION_BUSY, "Already occupied by a session"); return sd_bus_error_set(error, BUS_ERROR_SESSION_BUSY, "Already occupied by a session");
if (hashmap_size(m->sessions) >= m->sessions_max) if (hashmap_size(m->sessions) >= m->sessions_max)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED,
@ -1879,9 +1879,9 @@ static int method_do_shutdown_or_sleep(
if (r < 0) if (r < 0)
return r; return r;
if ((flags & ~SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC) != 0) if ((flags & ~SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC) != 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter");
if (!streq(unit_name, SPECIAL_REBOOT_TARGET) && (flags & SD_LOGIND_REBOOT_VIA_KEXEC)) if (!streq(unit_name, SPECIAL_REBOOT_TARGET) && (flags & SD_LOGIND_REBOOT_VIA_KEXEC))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Reboot via kexec is only applicable with reboot operations"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Reboot via kexec is only applicable with reboot operations");
} else { } else {
/* Old style method: no flags parameter, but interactive bool passed as boolean in /* Old style method: no flags parameter, but interactive bool passed as boolean in
* payload. Let's convert this argument to the new-style flags parameter for our internal * payload. Let's convert this argument to the new-style flags parameter for our internal
@ -2214,7 +2214,7 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
action_multiple_sessions = "org.freedesktop.login1.halt-multiple-sessions"; action_multiple_sessions = "org.freedesktop.login1.halt-multiple-sessions";
action_ignore_inhibit = "org.freedesktop.login1.halt-ignore-inhibit"; action_ignore_inhibit = "org.freedesktop.login1.halt-ignore-inhibit";
} else } else
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unsupported shutdown type"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Unsupported shutdown type");
r = verify_shutdown_creds(m, message, INHIBIT_SHUTDOWN, action, action_multiple_sessions, r = verify_shutdown_creds(m, message, INHIBIT_SHUTDOWN, action, action_multiple_sessions,
action_ignore_inhibit, 0, error); action_ignore_inhibit, 0, error);
@ -2672,7 +2672,7 @@ static int method_set_reboot_to_firmware_setup(
r = efi_reboot_to_firmware_supported(); r = efi_reboot_to_firmware_supported();
if (r == -EOPNOTSUPP) if (r == -EOPNOTSUPP)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Firmware does not support boot into firmware."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Firmware does not support boot into firmware.");
if (r < 0) if (r < 0)
return r; return r;
@ -2684,7 +2684,7 @@ static int method_set_reboot_to_firmware_setup(
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_FIRMWARE_SETUP: %m"); log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_FIRMWARE_SETUP: %m");
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Firmware does not support boot into firmware."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Firmware does not support boot into firmware.");
} else } else
/* non-EFI case: $SYSTEMD_REBOOT_TO_FIRMWARE_SETUP is set to on */ /* non-EFI case: $SYSTEMD_REBOOT_TO_FIRMWARE_SETUP is set to on */
use_efi = false; use_efi = false;
@ -2840,7 +2840,7 @@ static int method_set_reboot_to_boot_loader_menu(
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to determine whether reboot to boot loader menu is supported: %m"); log_warning_errno(r, "Failed to determine whether reboot to boot loader menu is supported: %m");
if (r < 0 || !FLAGS_SET(features, EFI_LOADER_FEATURE_CONFIG_TIMEOUT_ONE_SHOT)) if (r < 0 || !FLAGS_SET(features, EFI_LOADER_FEATURE_CONFIG_TIMEOUT_ONE_SHOT))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Boot loader does not support boot into boot loader menu."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Boot loader does not support boot into boot loader menu.");
use_efi = true; use_efi = true;
@ -2850,7 +2850,7 @@ static int method_set_reboot_to_boot_loader_menu(
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU: %m"); log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU: %m");
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Boot loader does not support boot into boot loader menu."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Boot loader does not support boot into boot loader menu.");
} else } else
/* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU is set to on */ /* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU is set to on */
use_efi = false; use_efi = false;
@ -3042,7 +3042,7 @@ static int method_set_reboot_to_boot_loader_entry(
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to determine whether reboot into boot loader entry is supported: %m"); log_warning_errno(r, "Failed to determine whether reboot into boot loader entry is supported: %m");
if (r < 0 || !FLAGS_SET(features, EFI_LOADER_FEATURE_ENTRY_ONESHOT)) if (r < 0 || !FLAGS_SET(features, EFI_LOADER_FEATURE_ENTRY_ONESHOT))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Loader does not support boot into boot loader entry."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Loader does not support boot into boot loader entry.");
use_efi = true; use_efi = true;
@ -3052,7 +3052,7 @@ static int method_set_reboot_to_boot_loader_entry(
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY: %m"); log_warning_errno(r, "Failed to parse $SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY: %m");
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Loader does not support boot into boot loader entry."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Loader does not support boot into boot loader entry.");
} else } else
/* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY is set to on */ /* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY is set to on */
use_efi = false; use_efi = false;

View File

@ -206,7 +206,7 @@ static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_erro
return r; return r;
if (to <= 0) if (to <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid virtual terminal"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid virtual terminal");
r = check_polkit_chvt(message, s->manager, error); r = check_polkit_chvt(message, s->manager, error);
if (r < 0) if (r < 0)

View File

@ -256,11 +256,11 @@ static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_
return r; return r;
if (uid != 0 && uid != s->user->user_record->uid) if (uid != 0 && uid != s->user->user_record->uid)
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may set idle hint"); return sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may set idle hint");
r = session_set_idle_hint(s, b); r = session_set_idle_hint(s, b);
if (r == -ENOTTY) if (r == -ENOTTY)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Idle hint control is not supported on non-graphical sessions."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Idle hint control is not supported on non-graphical sessions.");
if (r < 0) if (r < 0)
return r; return r;
@ -289,7 +289,7 @@ static int method_set_locked_hint(sd_bus_message *message, void *userdata, sd_bu
return r; return r;
if (uid != 0 && uid != s->user->user_record->uid) if (uid != 0 && uid != s->user->user_record->uid)
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may set locked hint"); return sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may set locked hint");
session_set_locked_hint(s, b); session_set_locked_hint(s, b);
@ -364,7 +364,7 @@ static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_e
return r; return r;
if (uid != 0 && (force || uid != s->user->user_record->uid)) if (uid != 0 && (force || uid != s->user->user_record->uid))
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may take control"); return sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may take control");
r = session_set_controller(s, sd_bus_message_get_sender(message), force, true); r = session_set_controller(s, sd_bus_message_get_sender(message), force, true);
if (r < 0) if (r < 0)
@ -380,7 +380,7 @@ static int method_release_control(sd_bus_message *message, void *userdata, sd_bu
assert(s); assert(s);
if (!session_is_controller(s, sd_bus_message_get_sender(message))) if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_setf(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session");
session_drop_controller(s); session_drop_controller(s);
@ -406,7 +406,7 @@ static int method_set_type(sd_bus_message *message, void *userdata, sd_bus_error
"Invalid session type '%s'", t); "Invalid session type '%s'", t);
if (!session_is_controller(s, sd_bus_message_get_sender(message))) if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_setf(error, BUS_ERROR_NOT_IN_CONTROL, "You must be in control of this session to set type"); return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You must be in control of this session to set type");
session_set_type(s, type); session_set_type(s, type);
@ -428,10 +428,10 @@ static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_er
return r; return r;
if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor)) if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid.");
if (!session_is_controller(s, sd_bus_message_get_sender(message))) if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_setf(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session");
dev = makedev(major, minor); dev = makedev(major, minor);
sd = hashmap_get(s->devices, &dev); sd = hashmap_get(s->devices, &dev);
@ -441,7 +441,7 @@ static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_er
* The caller should use dup() if it requires more * The caller should use dup() if it requires more
* than one fd (it would be functionally * than one fd (it would be functionally
* equivalent). */ * equivalent). */
return sd_bus_error_setf(error, BUS_ERROR_DEVICE_IS_TAKEN, "Device already taken"); return sd_bus_error_set(error, BUS_ERROR_DEVICE_IS_TAKEN, "Device already taken");
r = session_device_new(s, dev, true, &sd); r = session_device_new(s, dev, true, &sd);
if (r < 0) if (r < 0)
@ -478,15 +478,15 @@ static int method_release_device(sd_bus_message *message, void *userdata, sd_bus
return r; return r;
if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor)) if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid.");
if (!session_is_controller(s, sd_bus_message_get_sender(message))) if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_setf(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session");
dev = makedev(major, minor); dev = makedev(major, minor);
sd = hashmap_get(s->devices, &dev); sd = hashmap_get(s->devices, &dev);
if (!sd) if (!sd)
return sd_bus_error_setf(error, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); return sd_bus_error_set(error, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken");
session_device_free(sd); session_device_free(sd);
session_save(s); session_save(s);
@ -509,15 +509,15 @@ static int method_pause_device_complete(sd_bus_message *message, void *userdata,
return r; return r;
if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor)) if (!DEVICE_MAJOR_VALID(major) || !DEVICE_MINOR_VALID(minor))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Device major/minor is not valid.");
if (!session_is_controller(s, sd_bus_message_get_sender(message))) if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_setf(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session"); return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session");
dev = makedev(major, minor); dev = makedev(major, minor);
sd = hashmap_get(s->devices, &dev); sd = hashmap_get(s->devices, &dev);
if (!sd) if (!sd)
return sd_bus_error_setf(error, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken"); return sd_bus_error_set(error, BUS_ERROR_DEVICE_NOT_TAKEN, "Device not taken");
session_device_complete_pause(sd); session_device_complete_pause(sd);
@ -546,9 +546,9 @@ static int method_set_brightness(sd_bus_message *message, void *userdata, sd_bus
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not a valid device name %s, refusing.", name); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not a valid device name %s, refusing.", name);
if (!s->seat) if (!s->seat)
return sd_bus_error_setf(error, BUS_ERROR_NOT_YOUR_DEVICE, "Your session has no seat, refusing."); return sd_bus_error_set(error, BUS_ERROR_NOT_YOUR_DEVICE, "Your session has no seat, refusing.");
if (s->seat->active != s) if (s->seat->active != s)
return sd_bus_error_setf(error, BUS_ERROR_NOT_YOUR_DEVICE, "Session is not in foreground, refusing."); return sd_bus_error_set(error, BUS_ERROR_NOT_YOUR_DEVICE, "Session is not in foreground, refusing.");
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds); r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds);
if (r < 0) if (r < 0)
@ -559,7 +559,7 @@ static int method_set_brightness(sd_bus_message *message, void *userdata, sd_bus
return r; return r;
if (uid != 0 && uid != s->user->user_record->uid) if (uid != 0 && uid != s->user->user_record->uid)
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may change brightness."); return sd_bus_error_set(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may change brightness.");
r = sd_device_new_from_subsystem_sysname(&d, subsystem, name); r = sd_device_new_from_subsystem_sysname(&d, subsystem, name);
if (r < 0) if (r < 0)

View File

@ -41,7 +41,7 @@ int bus_image_method_remove(
assert(image); assert(image);
if (m->n_operations >= OPERATIONS_MAX) if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations."); return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,
@ -146,7 +146,7 @@ int bus_image_method_clone(
assert(m); assert(m);
if (m->n_operations >= OPERATIONS_MAX) if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations."); return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
r = sd_bus_message_read(message, "sb", &new_name, &read_only); r = sd_bus_message_read(message, "sb", &new_name, &read_only);
if (r < 0) if (r < 0)
@ -252,7 +252,7 @@ int bus_image_method_set_limit(
if (r < 0) if (r < 0)
return r; return r;
if (!FILE_SIZE_VALID_OR_INFINITY(limit)) if (!FILE_SIZE_VALID_OR_INFINITY(limit))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,

View File

@ -331,12 +331,12 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
if (r < 0) if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m"); return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
if (r != EXIT_SUCCESS) if (r != EXIT_SUCCESS)
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Child died abnormally."); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Child died abnormally.");
break; break;
} }
default: default:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Requesting IP address data is only supported on container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Requesting IP address data is only supported on container machines.");
} }
r = sd_bus_message_close_container(reply); r = sd_bus_message_close_container(reply);
@ -415,15 +415,15 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
if (r < 0) if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m"); return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
if (r == EXIT_NOT_FOUND) if (r == EXIT_NOT_FOUND)
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Machine does not contain OS release information"); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Machine does not contain OS release information");
if (r != EXIT_SUCCESS) if (r != EXIT_SUCCESS)
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Child died abnormally."); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Child died abnormally.");
break; break;
} }
default: default:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Requesting OS release data is only supported on container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Requesting OS release data is only supported on container machines.");
} }
return bus_reply_pair_array(message, l); return bus_reply_pair_array(message, l);
@ -628,7 +628,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
if (r < 0) if (r < 0)
return r; return r;
if (!strv_env_is_valid(env)) if (!strv_env_is_valid(env))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment assignments");
const char *details[] = { const char *details[] = {
"machine", m->name, "machine", m->name,
@ -820,19 +820,19 @@ int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bu
assert(m); assert(m);
if (m->class != MACHINE_CONTAINER) if (m->class != MACHINE_CONTAINER)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Bind mounting is only supported on container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Bind mounting is only supported on container machines.");
r = sd_bus_message_read(message, "ssbb", &src, &dest, &read_only, &make_file_or_directory); r = sd_bus_message_read(message, "ssbb", &src, &dest, &read_only, &make_file_or_directory);
if (r < 0) if (r < 0)
return r; return r;
if (!path_is_absolute(src) || !path_is_normalized(src)) if (!path_is_absolute(src) || !path_is_normalized(src))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute and normalized."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute and normalized.");
if (isempty(dest)) if (isempty(dest))
dest = src; dest = src;
else if (!path_is_absolute(dest) || !path_is_normalized(dest)) else if (!path_is_absolute(dest) || !path_is_normalized(dest))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute and normalized."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute and normalized.");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,
@ -852,7 +852,7 @@ int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bu
if (r < 0) if (r < 0)
return r; return r;
if (uid != 0) if (uid != 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Can't bind mount on container with user namespacing applied."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Can't bind mount on container with user namespacing applied.");
propagate_directory = strjoina("/run/systemd/nspawn/propagate/", m->name); propagate_directory = strjoina("/run/systemd/nspawn/propagate/", m->name);
r = bind_mount_in_namespace(m->leader, r = bind_mount_in_namespace(m->leader,
@ -881,22 +881,22 @@ int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_erro
assert(m); assert(m);
if (m->manager->n_operations >= OPERATIONS_MAX) if (m->manager->n_operations >= OPERATIONS_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing copies."); return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing copies.");
if (m->class != MACHINE_CONTAINER) if (m->class != MACHINE_CONTAINER)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Copying files is only supported on container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Copying files is only supported on container machines.");
r = sd_bus_message_read(message, "ss", &src, &dest); r = sd_bus_message_read(message, "ss", &src, &dest);
if (r < 0) if (r < 0)
return r; return r;
if (!path_is_absolute(src)) if (!path_is_absolute(src))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Source path must be absolute.");
if (isempty(dest)) if (isempty(dest))
dest = src; dest = src;
else if (!path_is_absolute(dest)) else if (!path_is_absolute(dest))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Destination path must be absolute.");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,
@ -1074,7 +1074,7 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
if (r < 0) if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m"); return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
if (r != EXIT_SUCCESS) if (r != EXIT_SUCCESS)
return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED, "Child died abnormally."); return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Child died abnormally.");
fd = receive_one_fd(pair[0], MSG_DONTWAIT); fd = receive_one_fd(pair[0], MSG_DONTWAIT);
if (fd < 0) if (fd < 0)
@ -1084,7 +1084,7 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
} }
default: default:
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Opening the root directory is only supported on container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Opening the root directory is only supported on container machines.");
} }
return sd_bus_reply_method_return(message, "h", fd); return sd_bus_reply_method_return(message, "h", fd);
@ -1105,7 +1105,7 @@ int bus_machine_method_get_uid_shift(sd_bus_message *message, void *userdata, sd
return sd_bus_reply_method_return(message, "u", UINT32_C(0)); return sd_bus_reply_method_return(message, "u", UINT32_C(0));
if (m->class != MACHINE_CONTAINER) if (m->class != MACHINE_CONTAINER)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "UID/GID shift may only be determined for container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "UID/GID shift may only be determined for container machines.");
r = machine_get_uid_shift(m, &shift); r = machine_get_uid_shift(m, &shift);
if (r == -ENXIO) if (r == -ENXIO)

View File

@ -241,7 +241,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
if (r < 0) if (r < 0)
return r; return r;
if (!hostname_is_valid(name, 0)) if (!hostname_is_valid(name, 0))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine name"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine name");
r = sd_bus_message_read_array(message, 'y', &v, &n); r = sd_bus_message_read_array(message, 'y', &v, &n);
if (r < 0) if (r < 0)
@ -251,7 +251,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
else if (n == 16) else if (n == 16)
memcpy(&id, v, n); memcpy(&id, v, n);
else else
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine ID parameter"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine ID parameter");
r = sd_bus_message_read(message, "ssus", &service, &class, &leader, &root_directory); r = sd_bus_message_read(message, "ssus", &service, &class, &leader, &root_directory);
if (r < 0) if (r < 0)
@ -275,14 +275,14 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
else { else {
c = machine_class_from_string(class); c = machine_class_from_string(class);
if (c < 0) if (c < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid machine class parameter");
} }
if (leader == 1) if (leader == 1)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid leader PID");
if (!isempty(root_directory) && !path_is_absolute(root_directory)) if (!isempty(root_directory) && !path_is_absolute(root_directory))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root directory must be empty or an absolute path"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Root directory must be empty or an absolute path");
if (leader == 0) { if (leader == 0) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
@ -701,7 +701,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err
assert(message); assert(message);
if (m->n_operations >= OPERATIONS_MAX) if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations."); return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
r = sd_bus_message_read(message, "s", &mm); r = sd_bus_message_read(message, "s", &mm);
if (r < 0) if (r < 0)
@ -842,7 +842,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
if (r < 0) if (r < 0)
return r; return r;
if (!FILE_SIZE_VALID_OR_INFINITY(limit)) if (!FILE_SIZE_VALID_OR_INFINITY(limit))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,
@ -867,7 +867,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
r = btrfs_subvol_set_subtree_quota_limit("/var/lib/machines", 0, limit); r = btrfs_subvol_set_subtree_quota_limit("/var/lib/machines", 0, limit);
if (r == -ENOTTY) if (r == -ENOTTY)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs.");
if (r < 0) if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m"); return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m");
@ -898,7 +898,7 @@ static int method_map_from_machine_user(sd_bus_message *message, void *userdata,
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
if (machine->class != MACHINE_CONTAINER) if (machine->class != MACHINE_CONTAINER)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not supported for non-container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Not supported for non-container machines.");
r = machine_translate_uid(machine, uid, &converted); r = machine_translate_uid(machine, uid, &converted);
if (r == -ESRCH) if (r == -ESRCH)
@ -957,7 +957,7 @@ static int method_map_from_machine_group(sd_bus_message *message, void *userdata
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name); return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_MACHINE, "No machine '%s' known", name);
if (machine->class != MACHINE_CONTAINER) if (machine->class != MACHINE_CONTAINER)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Not supported for non-container machines."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Not supported for non-container machines.");
r = machine_translate_gid(machine, gid, &converted); r = machine_translate_gid(machine, gid, &converted);
if (r == -ESRCH) if (r == -ESRCH)

View File

@ -22,14 +22,14 @@ static int operation_done(sd_event_source *s, const siginfo_t *si, void *userdat
o->pid = 0; o->pid = 0;
if (si->si_code != CLD_EXITED) { if (si->si_code != CLD_EXITED) {
r = sd_bus_error_setf(&error, SD_BUS_ERROR_FAILED, "Child died abnormally."); r = sd_bus_error_set(&error, SD_BUS_ERROR_FAILED, "Child died abnormally.");
goto fail; goto fail;
} }
if (si->si_status == EXIT_SUCCESS) if (si->si_status == EXIT_SUCCESS)
r = 0; r = 0;
else if (read(o->errno_fd, &r, sizeof(r)) != sizeof(r)) { /* Try to acquire error code for failed operation */ else if (read(o->errno_fd, &r, sizeof(r)) != sizeof(r)) { /* Try to acquire error code for failed operation */
r = sd_bus_error_setf(&error, SD_BUS_ERROR_FAILED, "Child failed."); r = sd_bus_error_set(&error, SD_BUS_ERROR_FAILED, "Child failed.");
goto fail; goto fail;
} }

View File

@ -167,7 +167,7 @@ int manager_request_product_uuid(Manager *m, Link *link) {
return log_oom(); return log_oom();
} }
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) { if (sd_bus_is_ready(m->bus) <= 0) {
log_debug("Not connected to system bus, requesting product UUID later."); log_debug("Not connected to system bus, requesting product UUID later.");
return 0; return 0;
} }

View File

@ -211,7 +211,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", name); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", name);
if (!route_only && dns_name_is_root(name)) if (!route_only && dns_name_is_root(name))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain");
r = dns_name_normalize(name, 0, &str); r = dns_name_normalize(name, 0, &str);
if (r < 0) if (r < 0)
@ -854,7 +854,7 @@ int link_send_changed_strv(Link *link, char **properties) {
assert(link->manager); assert(link->manager);
assert(properties); assert(properties);
if (!link->manager->bus) if (sd_bus_is_ready(link->manager->bus) <= 0)
return 0; return 0;
p = link_bus_path(link); p = link_bus_path(link);

View File

@ -339,7 +339,7 @@ int manager_send_changed_strv(Manager *manager, char **properties) {
assert(manager); assert(manager);
assert(properties); assert(properties);
if (!manager->bus) if (sd_bus_is_ready(manager->bus) <= 0)
return 0; return 0;
return sd_bus_emit_properties_changed_strv( return sd_bus_emit_properties_changed_strv(

View File

@ -767,8 +767,8 @@ int manager_set_hostname(Manager *m, const char *hostname) {
if (r < 0) if (r < 0)
return r; return r;
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) { if (sd_bus_is_ready(m->bus) <= 0) {
log_debug("Not connected to system bus, setting hostname later."); log_debug("Not connected to system bus, setting system hostname later.");
return 0; return 0;
} }
@ -784,7 +784,6 @@ int manager_set_hostname(Manager *m, const char *hostname) {
"sb", "sb",
hostname, hostname,
false); false);
if (r < 0) if (r < 0)
return log_error_errno(r, "Could not set transient hostname: %m"); return log_error_errno(r, "Could not set transient hostname: %m");
@ -817,8 +816,8 @@ int manager_set_timezone(Manager *m, const char *tz) {
if (r < 0) if (r < 0)
return r; return r;
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) { if (sd_bus_is_ready(m->bus) <= 0) {
log_debug("Not connected to system bus, setting timezone later."); log_debug("Not connected to system bus, setting system timezone later.");
return 0; return 0;
} }

View File

@ -357,7 +357,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
if (r < 0) if (r < 0)
return r; return r;
if (!FILE_SIZE_VALID_OR_INFINITY(limit)) if (!FILE_SIZE_VALID_OR_INFINITY(limit))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range");
r = bus_verify_polkit_async( r = bus_verify_polkit_async(
message, message,
@ -377,7 +377,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
r = btrfs_subvol_set_subtree_quota_limit("/var/lib/portables", 0, limit); r = btrfs_subvol_set_subtree_quota_limit("/var/lib/portables", 0, limit);
if (r == -ENOTTY) if (r == -ENOTTY)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Quota is only supported on btrfs.");
if (r < 0) if (r < 0)
return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m"); return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m");

View File

@ -443,7 +443,7 @@ int bus_image_common_remove(
} }
if (m->n_operations >= OPERATIONS_MAX) if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_setf(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations."); return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
r = bus_image_acquire(m, r = bus_image_acquire(m,
message, message,
@ -781,7 +781,7 @@ int bus_image_common_set_limit(
if (r < 0) if (r < 0)
return r; return r;
if (!FILE_SIZE_VALID_OR_INFINITY(limit)) if (!FILE_SIZE_VALID_OR_INFINITY(limit))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "New limit out of range");
r = bus_image_acquire(m, r = bus_image_acquire(m,
message, message,

View File

@ -20,14 +20,14 @@ static int operation_done(sd_event_source *s, const siginfo_t *si, void *userdat
o->pid = 0; o->pid = 0;
if (si->si_code != CLD_EXITED) { if (si->si_code != CLD_EXITED) {
r = sd_bus_error_setf(&error, SD_BUS_ERROR_FAILED, "Child died abnormally."); r = sd_bus_error_set(&error, SD_BUS_ERROR_FAILED, "Child died abnormally.");
goto fail; goto fail;
} }
if (si->si_status == EXIT_SUCCESS) if (si->si_status == EXIT_SUCCESS)
r = 0; r = 0;
else if (read(o->errno_fd, &r, sizeof(r)) != sizeof(r)) { /* Try to acquire error code for failed operation */ else if (read(o->errno_fd, &r, sizeof(r)) != sizeof(r)) { /* Try to acquire error code for failed operation */
r = sd_bus_error_setf(&error, SD_BUS_ERROR_FAILED, "Child failed."); r = sd_bus_error_set(&error, SD_BUS_ERROR_FAILED, "Child failed.");
goto fail; goto fail;
} }

View File

@ -299,7 +299,7 @@ static int validate_and_mangle_flags(
SD_RESOLVED_NO_TRUST_ANCHOR| SD_RESOLVED_NO_TRUST_ANCHOR|
SD_RESOLVED_NO_NETWORK| SD_RESOLVED_NO_NETWORK|
ok)) ok))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter");
if ((*flags & SD_RESOLVED_PROTOCOLS_ALL) == 0) /* If no protocol is enabled, enable all */ if ((*flags & SD_RESOLVED_PROTOCOLS_ALL) == 0) /* If no protocol is enabled, enable all */
*flags |= SD_RESOLVED_PROTOCOLS_ALL; *flags |= SD_RESOLVED_PROTOCOLS_ALL;
@ -420,7 +420,7 @@ static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata,
return r; return r;
if (ifindex < 0) if (ifindex < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index");
if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC)) if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
@ -581,7 +581,7 @@ static int bus_method_resolve_address(sd_bus_message *message, void *userdata, s
return r; return r;
if (ifindex < 0) if (ifindex < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index");
r = validate_and_mangle_flags(NULL, &flags, 0, error); r = validate_and_mangle_flags(NULL, &flags, 0, error);
if (r < 0) if (r < 0)
@ -738,7 +738,7 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
return r; return r;
if (ifindex < 0) if (ifindex < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index");
r = dns_name_is_valid(name); r = dns_name_is_valid(name);
if (r < 0) if (r < 0)
@ -749,7 +749,7 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
if (!dns_type_is_valid_query(type)) if (!dns_type_is_valid_query(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified resource record type %" PRIu16 " may not be used in a query.", type); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified resource record type %" PRIu16 " may not be used in a query.", type);
if (dns_type_is_zone_transer(type)) if (dns_type_is_zone_transer(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Zone transfers not permitted via this programming interface."); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Zone transfers not permitted via this programming interface.");
if (dns_type_is_obsolete(type)) if (dns_type_is_obsolete(type))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Specified DNS resource record type %" PRIu16 " is obsolete.", type); return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Specified DNS resource record type %" PRIu16 " is obsolete.", type);
@ -1267,7 +1267,7 @@ static int bus_method_resolve_service(sd_bus_message *message, void *userdata, s
return r; return r;
if (ifindex < 0) if (ifindex < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index");
if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC)) if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
@ -1289,7 +1289,7 @@ static int bus_method_resolve_service(sd_bus_message *message, void *userdata, s
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid domain '%s'", domain); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid domain '%s'", domain);
if (name && !type) if (name && !type)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Service name cannot be specified without service type."); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Service name cannot be specified without service type.");
r = validate_and_mangle_flags(name, &flags, SD_RESOLVED_NO_TXT|SD_RESOLVED_NO_ADDRESS, error); r = validate_and_mangle_flags(name, &flags, SD_RESOLVED_NO_TXT|SD_RESOLVED_NO_ADDRESS, error);
if (r < 0) if (r < 0)
@ -1861,7 +1861,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
assert(m); assert(m);
if (m->mdns_support != RESOLVE_SUPPORT_YES) if (m->mdns_support != RESOLVE_SUPPORT_YES)
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Support for MulticastDNS is disabled"); return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Support for MulticastDNS is disabled");
service = new0(DnssdService, 1); service = new0(DnssdService, 1);
if (!service) if (!service)
@ -1928,7 +1928,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
return r; return r;
if (isempty(key)) if (isempty(key))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Keys in DNS-SD TXT RRs can't be empty"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Keys in DNS-SD TXT RRs can't be empty");
if (!ascii_is_valid(key)) if (!ascii_is_valid(key))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TXT key '%s' contains non-ASCII symbols", key); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TXT key '%s' contains non-ASCII symbols", key);

View File

@ -386,7 +386,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
if (r == 0) if (r == 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", name); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", name);
if (!route_only && dns_name_is_root(name)) if (!route_only && dns_name_is_root(name))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Root domain is not suitable as search domain");
if (route_only) { if (route_only) {
prefixed = strjoin("~", name); prefixed = strjoin("~", name);

View File

@ -46,14 +46,13 @@ static const BaseFilesystem table[] = {
int base_filesystem_create(const char *root, uid_t uid, gid_t gid) { int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
size_t i;
int r; int r;
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW); fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
if (fd < 0) if (fd < 0)
return log_error_errno(errno, "Failed to open root file system: %m"); return log_error_errno(errno, "Failed to open root file system: %m");
for (i = 0; i < ELEMENTSOF(table); i ++) { for (size_t i = 0; i < ELEMENTSOF(table); i++) {
if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0) if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
continue; continue;
@ -94,10 +93,9 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
return -errno; return -errno;
} }
if (uid_is_valid(uid) || gid_is_valid(gid)) { if (uid_is_valid(uid) || gid_is_valid(gid))
if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0) if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0)
return log_error_errno(errno, "Failed to chown symlink at %s/%s: %m", root, table[i].dir); return log_error_errno(errno, "Failed to chown symlink at %s/%s: %m", root, table[i].dir);
}
continue; continue;
} }
@ -114,10 +112,9 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
return -errno; return -errno;
} }
if (uid != UID_INVALID || gid != UID_INVALID) { if (uid != UID_INVALID || gid != UID_INVALID)
if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0) if (fchownat(fd, table[i].dir, uid, gid, AT_SYMLINK_NOFOLLOW) < 0)
return log_error_errno(errno, "Failed to chown directory at %s/%s: %m", root, table[i].dir); return log_error_errno(errno, "Failed to chown directory at %s/%s: %m", root, table[i].dir);
}
} }
return 0; return 0;

View File

@ -17,7 +17,7 @@ int bus_message_read_ifindex(sd_bus_message *message, sd_bus_error *error, int *
return r; return r;
if (ifindex <= 0) if (ifindex <= 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface index");
*ret = ifindex; *ret = ifindex;
@ -62,7 +62,7 @@ int bus_message_read_in_addr_auto(sd_bus_message *message, sd_bus_error *error,
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family); return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
if (sz != FAMILY_ADDRESS_SIZE(family)) if (sz != FAMILY_ADDRESS_SIZE(family))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid address size"); return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid address size");
if (ret_family) if (ret_family)
*ret_family = family; *ret_family = family;
@ -99,7 +99,7 @@ static int bus_message_read_dns_one(
return r; return r;
if (!dns_server_address_valid(family, &a)) { if (!dns_server_address_valid(family, &a)) {
r = sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid DNS server address"); r = sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid DNS server address");
assert(r < 0); assert(r < 0);
return r; return r;
} }

View File

@ -783,19 +783,17 @@ int table_update(Table *t, TableCell *cell, TableDataType type, const void *data
} }
int table_add_many_internal(Table *t, TableDataType first_type, ...) { int table_add_many_internal(Table *t, TableDataType first_type, ...) {
TableDataType type;
va_list ap;
TableCell *last_cell = NULL; TableCell *last_cell = NULL;
va_list ap;
int r; int r;
assert(t); assert(t);
assert(first_type >= 0); assert(first_type >= 0);
assert(first_type < _TABLE_DATA_TYPE_MAX); assert(first_type < _TABLE_DATA_TYPE_MAX);
type = first_type;
va_start(ap, first_type); va_start(ap, first_type);
for (;;) {
for (TableDataType type = first_type;; type = va_arg(ap, TableDataType)) {
const void *data; const void *data;
union { union {
uint64_t size; uint64_t size;
@ -968,43 +966,43 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
size_t w = va_arg(ap, size_t); size_t w = va_arg(ap, size_t);
r = table_set_minimum_width(t, last_cell, w); r = table_set_minimum_width(t, last_cell, w);
break; goto check;
} }
case TABLE_SET_MAXIMUM_WIDTH: { case TABLE_SET_MAXIMUM_WIDTH: {
size_t w = va_arg(ap, size_t); size_t w = va_arg(ap, size_t);
r = table_set_maximum_width(t, last_cell, w); r = table_set_maximum_width(t, last_cell, w);
break; goto check;
} }
case TABLE_SET_WEIGHT: { case TABLE_SET_WEIGHT: {
unsigned w = va_arg(ap, unsigned); unsigned w = va_arg(ap, unsigned);
r = table_set_weight(t, last_cell, w); r = table_set_weight(t, last_cell, w);
break; goto check;
} }
case TABLE_SET_ALIGN_PERCENT: { case TABLE_SET_ALIGN_PERCENT: {
unsigned p = va_arg(ap, unsigned); unsigned p = va_arg(ap, unsigned);
r = table_set_align_percent(t, last_cell, p); r = table_set_align_percent(t, last_cell, p);
break; goto check;
} }
case TABLE_SET_ELLIPSIZE_PERCENT: { case TABLE_SET_ELLIPSIZE_PERCENT: {
unsigned p = va_arg(ap, unsigned); unsigned p = va_arg(ap, unsigned);
r = table_set_ellipsize_percent(t, last_cell, p); r = table_set_ellipsize_percent(t, last_cell, p);
break; goto check;
} }
case TABLE_SET_COLOR: { case TABLE_SET_COLOR: {
const char *c = va_arg(ap, const char*); const char *c = va_arg(ap, const char*);
r = table_set_color(t, last_cell, c); r = table_set_color(t, last_cell, c);
break; goto check;
} }
case TABLE_SET_RGAP_COLOR: { case TABLE_SET_RGAP_COLOR: {
const char *c = va_arg(ap, const char*); const char *c = va_arg(ap, const char*);
r = table_set_rgap_color(t, last_cell, c); r = table_set_rgap_color(t, last_cell, c);
break; goto check;
} }
case TABLE_SET_BOTH_COLORS: { case TABLE_SET_BOTH_COLORS: {
@ -1017,19 +1015,19 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
} }
r = table_set_rgap_color(t, last_cell, c); r = table_set_rgap_color(t, last_cell, c);
break; goto check;
} }
case TABLE_SET_URL: { case TABLE_SET_URL: {
const char *u = va_arg(ap, const char*); const char *u = va_arg(ap, const char*);
r = table_set_url(t, last_cell, u); r = table_set_url(t, last_cell, u);
break; goto check;
} }
case TABLE_SET_UPPERCASE: { case TABLE_SET_UPPERCASE: {
int u = va_arg(ap, int); int u = va_arg(ap, int);
r = table_set_uppercase(t, last_cell, u); r = table_set_uppercase(t, last_cell, u);
break; goto check;
} }
case _TABLE_DATA_TYPE_MAX: case _TABLE_DATA_TYPE_MAX:
@ -1041,15 +1039,12 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
assert_not_reached("Uh? Unexpected data type."); assert_not_reached("Uh? Unexpected data type.");
} }
if (type < _TABLE_DATA_TYPE_MAX) r = table_add_cell(t, &last_cell, type, data);
r = table_add_cell(t, &last_cell, type, data); check:
if (r < 0) { if (r < 0) {
va_end(ap); va_end(ap);
return r; return r;
} }
type = va_arg(ap, TableDataType);
} }
} }

View File

@ -242,7 +242,7 @@ static void test_ensure_cap_64bit(void) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
bool run_ambient = false; /* unnecessary initialization to silence gcc warning */ bool run_ambient = false; /* avoid false maybe-uninitialized warning */
test_setup_logging(LOG_INFO); test_setup_logging(LOG_INFO);

View File

@ -61,6 +61,13 @@ static bool test_v4(FirewallContext *ctx) {
log_info("/* %s(backend=%s) */", __func__, firewall_backend_to_string(ctx->backend)); log_info("/* %s(backend=%s) */", __func__, firewall_backend_to_string(ctx->backend));
#if HAVE_LIBIPTC
if (ctx->backend == FW_BACKEND_IPTABLES && fw_iptables_init_nat(NULL) < 0) {
log_debug("iptables backend is used, but nat table is not enabled, skipping tests");
return false;
}
#endif
assert_se(fw_add_masquerade(&ctx, true, AF_INET, NULL, 0) == -EINVAL); assert_se(fw_add_masquerade(&ctx, true, AF_INET, NULL, 0) == -EINVAL);
assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.1.2.0", &u), 0) == -EINVAL); assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.1.2.0", &u), 0) == -EINVAL);
@ -102,11 +109,6 @@ int main(int argc, char *argv[]) {
if (ctx->backend == FW_BACKEND_NONE) if (ctx->backend == FW_BACKEND_NONE)
return EXIT_TEST_SKIP; return EXIT_TEST_SKIP;
#if HAVE_LIBIPTC
if (ctx->backend == FW_BACKEND_IPTABLES && fw_iptables_init_nat(NULL) < 0)
return EXIT_TEST_SKIP;
#endif
if (test_v4(ctx) && ctx->backend == FW_BACKEND_NFTABLES) if (test_v4(ctx) && ctx->backend == FW_BACKEND_NFTABLES)
test_v6(ctx); test_v6(ctx);

View File

@ -96,21 +96,17 @@ static int print_status_info(const StatusInfo *i) {
} else } else
log_warning("Could not get time from timedated and not operating locally, ignoring."); log_warning("Could not get time from timedated and not operating locally, ignoring.");
if (have_time) n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm)) : 0;
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm));
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, "Local time:", TABLE_STRING, "Local time:",
TABLE_STRING, have_time && n > 0 ? a : "n/a"); TABLE_STRING, n > 0 ? a : "n/a");
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
if (have_time) n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm)) : 0;
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm));
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, "Universal time:", TABLE_STRING, "Universal time:",
TABLE_STRING, have_time && n > 0 ? a : "n/a"); TABLE_STRING, n > 0 ? a : "n/a");
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
@ -119,26 +115,23 @@ static int print_status_info(const StatusInfo *i) {
rtc_sec = (time_t) (i->rtc_time / USEC_PER_SEC); rtc_sec = (time_t) (i->rtc_time / USEC_PER_SEC);
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S", gmtime_r(&rtc_sec, &tm)); n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S", gmtime_r(&rtc_sec, &tm));
} } else
n = 0;
r = table_add_many(table, r = table_add_many(table,
TABLE_STRING, "RTC time:", TABLE_STRING, "RTC time:",
TABLE_STRING, i->rtc_time > 0 && n > 0 ? a : "n/a"); TABLE_STRING, n > 0 ? a : "n/a");
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
if (have_time)
n = strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm));
r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:"); r = table_add_cell(table, NULL, TABLE_STRING, "Time zone:");
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%s (%s)", strna(i->timezone), have_time && n > 0 ? a : "n/a"); n = have_time ? strftime(a, sizeof a, "%Z, %z", localtime_r(&sec, &tm)) : 0;
r = table_add_cell_stringf(table, NULL, "%s (%s)", strna(i->timezone), n > 0 ? a : "n/a");
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);
/* Restore the $TZ */ /* Restore the $TZ */
r = set_unset_env("TZ", old_tz, true); r = set_unset_env("TZ", old_tz, true);
if (r < 0) if (r < 0)

View File

@ -23,6 +23,7 @@
#include <linux/pci_regs.h> #include <linux/pci_regs.h>
#include "alloc-util.h" #include "alloc-util.h"
#include "device-util.h"
#include "dirent-util.h" #include "dirent-util.h"
#include "fd-util.h" #include "fd-util.h"
#include "fileio.h" #include "fileio.h"
@ -262,18 +263,60 @@ static bool is_pci_bridge(sd_device *dev) {
return strneq(p + 2, "04", 2); return strneq(p + 2, "04", 2);
} }
static int parse_hotplug_slot_from_function_id(sd_device *dev, const char *slots, uint32_t *ret) {
uint64_t function_id;
char path[PATH_MAX];
const char *attr;
int r;
/* The <sysname>/function_id attribute is unique to the s390 PCI driver. If present, we know
* that the slot's directory name for this device is /sys/bus/pci/XXXXXXXX/ where XXXXXXXX is
* the fixed length 8 hexadecimal character string representation of function_id. Therefore we
* can short cut here and just check for the existence of the slot directory. As this directory
* has to exist, we're emitting a debug message for the unlikely case it's not found. Note that
* the domain part doesn't belong to the slot name here because there's a 1-to-1 relationship
* between PCI function and its hotplug slot. */
assert(dev);
assert(slots);
assert(ret);
if (!naming_scheme_has(NAMING_SLOT_FUNCTION_ID))
return 0;
if (sd_device_get_sysattr_value(dev, "function_id", &attr) < 0)
return 0;
r = safe_atou64(attr, &function_id);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to parse function_id, ignoring: %s", attr);
if (function_id <= 0 || function_id > UINT32_MAX)
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
"Invalid function id (0x%"PRIx64"), ignoring.",
function_id);
if (!snprintf_ok(path, sizeof path, "%s/%08"PRIx64, slots, function_id))
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG),
"PCI slot path is too long, ignoring.");
if (access(path, F_OK) < 0)
return log_device_debug_errno(dev, errno, "Cannot access %s, ignoring: %m", path);
*ret = (uint32_t) function_id;
return 1;
}
static int dev_pci_slot(sd_device *dev, struct netnames *names) { static int dev_pci_slot(sd_device *dev, struct netnames *names) {
unsigned long dev_port = 0;
unsigned domain, bus, slot, func;
int hotplug_slot = -1;
size_t l;
char *s;
const char *sysname, *attr, *port_name = NULL, *syspath; const char *sysname, *attr, *port_name = NULL, *syspath;
_cleanup_(sd_device_unrefp) sd_device *pci = NULL; _cleanup_(sd_device_unrefp) sd_device *pci = NULL;
sd_device *hotplug_slot_dev;
char slots[PATH_MAX];
_cleanup_closedir_ DIR *dir = NULL; _cleanup_closedir_ DIR *dir = NULL;
struct dirent *dent; unsigned domain, bus, slot, func;
sd_device *hotplug_slot_dev;
unsigned long dev_port = 0;
uint32_t hotplug_slot = 0;
char slots[PATH_MAX], *s;
size_t l;
int r; int r;
r = sd_device_get_sysname(names->pcidev, &sysname); r = sd_device_get_sysname(names->pcidev, &sysname);
@ -342,44 +385,29 @@ static int dev_pci_slot(sd_device *dev, struct netnames *names) {
hotplug_slot_dev = names->pcidev; hotplug_slot_dev = names->pcidev;
while (hotplug_slot_dev) { while (hotplug_slot_dev) {
if (sd_device_get_sysname(hotplug_slot_dev, &sysname) < 0) struct dirent *dent;
continue;
/* The <sysname>/function_id attribute is unique to the s390 PCI driver. r = parse_hotplug_slot_from_function_id(hotplug_slot_dev, slots, &hotplug_slot);
If present, we know that the slot's directory name for this device is if (r < 0)
/sys/bus/pci/XXXXXXXX/ where XXXXXXXX is the fixed length 8 hexadecimal return 0;
character string representation of function_id. if (r > 0) {
Therefore we can short cut here and just check for the existence of domain = 0; /* See comments in parse_hotplug_slot_from_function_id(). */
the slot directory. As this directory has to exist, we're emitting a
debug message for the unlikely case it's not found.
Note that the domain part of doesn't belong to the slot name here
because there's a 1-to-1 relationship between PCI function and its hotplug
slot.
*/
if (naming_scheme_has(NAMING_SLOT_FUNCTION_ID) &&
sd_device_get_sysattr_value(hotplug_slot_dev, "function_id", &attr) >= 0) {
int function_id;
_cleanup_free_ char *str;
if (safe_atoi(attr, &function_id) >= 0 &&
asprintf(&str, "%s/%08x/", slots, function_id) >= 0 &&
access(str, R_OK) == 0) {
hotplug_slot = function_id;
domain = 0;
} else
log_debug("No matching slot for function_id (%s).", attr);
break; break;
} }
r = sd_device_get_sysname(hotplug_slot_dev, &sysname);
if (r < 0)
return log_device_debug_errno(hotplug_slot_dev, r, "Failed to get sysname: %m");
FOREACH_DIRENT_ALL(dent, dir, break) { FOREACH_DIRENT_ALL(dent, dir, break) {
int i;
char str[PATH_MAX];
_cleanup_free_ char *address = NULL; _cleanup_free_ char *address = NULL;
char str[PATH_MAX];
uint32_t i;
if (dot_or_dot_dot(dent->d_name)) if (dot_or_dot_dot(dent->d_name))
continue; continue;
r = safe_atoi(dent->d_name, &i); r = safe_atou32(dent->d_name, &i);
if (r < 0 || i <= 0) if (r < 0 || i <= 0)
continue; continue;
@ -394,12 +422,12 @@ static int dev_pci_slot(sd_device *dev, struct netnames *names) {
* devices that will try to claim the same index and that would create name * devices that will try to claim the same index and that would create name
* collision. */ * collision. */
if (naming_scheme_has(NAMING_BRIDGE_NO_SLOT) && is_pci_bridge(hotplug_slot_dev)) if (naming_scheme_has(NAMING_BRIDGE_NO_SLOT) && is_pci_bridge(hotplug_slot_dev))
hotplug_slot = 0; return 0;
break; break;
} }
} }
if (hotplug_slot >= 0) if (hotplug_slot > 0)
break; break;
if (sd_device_get_parent_with_subsystem_devtype(hotplug_slot_dev, "pci", NULL, &hotplug_slot_dev) < 0) if (sd_device_get_parent_with_subsystem_devtype(hotplug_slot_dev, "pci", NULL, &hotplug_slot_dev) < 0)
break; break;
@ -411,7 +439,7 @@ static int dev_pci_slot(sd_device *dev, struct netnames *names) {
l = sizeof(names->pci_slot); l = sizeof(names->pci_slot);
if (domain > 0) if (domain > 0)
l = strpcpyf(&s, l, "P%d", domain); l = strpcpyf(&s, l, "P%d", domain);
l = strpcpyf(&s, l, "s%d", hotplug_slot); l = strpcpyf(&s, l, "s%"PRIu32, hotplug_slot);
if (func > 0 || is_pci_multifunction(names->pcidev)) if (func > 0 || is_pci_multifunction(names->pcidev))
l = strpcpyf(&s, l, "f%d", func); l = strpcpyf(&s, l, "f%d", func);
if (port_name) if (port_name)
@ -971,7 +999,7 @@ static int builtin_net_id(sd_device *dev, int argc, char *argv[], bool test) {
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str); udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
if (names.pci_slot[0] && if (names.pci_slot[0] &&
snprintf(str, sizeof str, "%s%s%s", prefix, names.pci_slot, names.bcma_core)) snprintf_ok(str, sizeof str, "%s%s%s", prefix, names.pci_slot, names.bcma_core))
udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str); udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str);
return 0; return 0;
} }

View File

@ -32,13 +32,13 @@ os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os
systemd-dissect --json=short ${image}.raw | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"partition_label":null,"fstype":"squashfs","architecture":null,"verity":"external"' systemd-dissect --json=short ${image}.raw | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"partition_label":null,"fstype":"squashfs","architecture":null,"verity":"external"'
systemd-dissect ${image}.raw | grep -q -F "MARKER=1" systemd-dissect ${image}.raw | grep -q -F "MARKER=1"
systemd-dissect ${image}.raw | grep -q -F -f $os_release systemd-dissect ${image}.raw | grep -q -F -f <(sed 's/"//g' $os_release)
mv ${image}.verity ${image}.fooverity mv ${image}.verity ${image}.fooverity
mv ${image}.roothash ${image}.foohash mv ${image}.roothash ${image}.foohash
systemd-dissect --json=short ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"partition_label":null,"fstype":"squashfs","architecture":null,"verity":"external"' systemd-dissect --json=short ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"partition_label":null,"fstype":"squashfs","architecture":null,"verity":"external"'
systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F "MARKER=1" systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F "MARKER=1"
systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F -f $os_release systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F -f <(sed 's/"//g' $os_release)
mv ${image}.fooverity ${image}.verity mv ${image}.fooverity ${image}.verity
mv ${image}.foohash ${image}.roothash mv ${image}.foohash ${image}.roothash
@ -130,7 +130,7 @@ VERITY_UUID=$(systemd-id128 -u show $(tail -c 32 ${image}.roothash) -u | tail -n
systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root","partition_uuid":"'$ROOT_UUID'","partition_label":"Root Partition","fstype":"squashfs","architecture":"'$architecture'","verity":"yes","node":' systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root","partition_uuid":"'$ROOT_UUID'","partition_label":"Root Partition","fstype":"squashfs","architecture":"'$architecture'","verity":"yes","node":'
systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root-verity","partition_uuid":"'$VERITY_UUID'","partition_label":"Verity Partition","fstype":"DM_verity_hash","architecture":"'$architecture'","verity":null,"node":' systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root-verity","partition_uuid":"'$VERITY_UUID'","partition_label":"Verity Partition","fstype":"DM_verity_hash","architecture":"'$architecture'","verity":null,"node":'
systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F "MARKER=1" systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F "MARKER=1"
systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F -f $os_release systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F -f <(sed 's/"//g' $os_release)
systemd-dissect --root-hash ${roothash} --mount ${image}.gpt ${image_dir}/mount systemd-dissect --root-hash ${roothash} --mount ${image}.gpt ${image_dir}/mount
cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f $os_release cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f $os_release