mirror of
https://github.com/systemd/systemd
synced 2025-10-06 20:24:45 +02:00
Compare commits
26 Commits
71d1e58309
...
d0b3039837
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d0b3039837 | ||
![]() |
d8e4c59785 | ||
![]() |
9f519e491f | ||
![]() |
5dbec9bd32 | ||
![]() |
3bbb76f621 | ||
![]() |
a73f8e9f32 | ||
![]() |
ecb4b08c2e | ||
![]() |
2fe2941646 | ||
![]() |
68c98a411d | ||
![]() |
98d81cf974 | ||
![]() |
3b9e6fb490 | ||
![]() |
a03e335b86 | ||
![]() |
cb8c948738 | ||
![]() |
5a6e56ec17 | ||
![]() |
19ed9a114c | ||
![]() |
c304cb0146 | ||
![]() |
fa28023c0f | ||
![]() |
70c35e4bfd | ||
![]() |
b08c3fbe0e | ||
![]() |
46cbdcd9fe | ||
![]() |
4a3ad75efa | ||
![]() |
f1e7cbaef7 | ||
![]() |
1b09b81cf4 | ||
![]() |
7756528e9b | ||
![]() |
462035d599 | ||
![]() |
9b4aba104e |
@ -57,6 +57,9 @@
|
||||
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>
|
||||
|
||||
<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
|
||||
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
|
||||
install a match for the <function>Connected()</function> signal on the
|
||||
@ -68,8 +71,8 @@
|
||||
<refsect1>
|
||||
<title>Return Value</title>
|
||||
|
||||
<para>On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style
|
||||
error code.</para>
|
||||
<para>Those functions return 0 if the bus is <emphasis>not</emphasis> in the given state, and a positive
|
||||
integer when it is. On failure, a negative errno-style error code is returned.</para>
|
||||
|
||||
<refsect2>
|
||||
<title>Errors</title>
|
||||
|
13
meson.build
13
meson.build
@ -395,10 +395,6 @@ possible_cc_flags = [
|
||||
'-Wno-error=#warnings', # 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',
|
||||
'-fno-common',
|
||||
'-fdiagnostics-show-option',
|
||||
@ -409,6 +405,15 @@ possible_cc_flags = [
|
||||
'--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,
|
||||
# run mesonconf to see what is enabled
|
||||
possible_link_flags = [
|
||||
|
@ -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) {
|
||||
_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;
|
||||
|
||||
assert(pid >= 0);
|
||||
|
@ -1072,7 +1072,7 @@ int copy_file_full(
|
||||
|
||||
_cleanup_close_ int fdf = -1;
|
||||
struct stat st;
|
||||
int fdt = -1, r;
|
||||
int r, fdt = -1; /* avoid false maybe-uninitialized warning */
|
||||
|
||||
assert(from);
|
||||
assert(to);
|
||||
|
@ -107,11 +107,9 @@ static void bubbleinsert(struct strbuf_node *node,
|
||||
/* add string, return the index/offset into the buffer */
|
||||
ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len) {
|
||||
uint8_t c;
|
||||
struct strbuf_node *node;
|
||||
size_t depth;
|
||||
char *buf_new;
|
||||
struct strbuf_child_entry *child;
|
||||
struct strbuf_node *node_child;
|
||||
struct strbuf_node *node;
|
||||
ssize_t off;
|
||||
|
||||
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;
|
||||
|
||||
node = str->root;
|
||||
for (depth = 0; depth <= len; depth++) {
|
||||
for (size_t depth = 0; depth <= len; depth++) {
|
||||
struct strbuf_child_entry search;
|
||||
|
||||
/* 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';
|
||||
|
||||
/* new node */
|
||||
_cleanup_free_ struct strbuf_node *node_child = NULL;
|
||||
|
||||
node_child = new(struct strbuf_node, 1);
|
||||
if (!node_child)
|
||||
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 */
|
||||
child = reallocarray(node->children, node->children_count + 1, sizeof(struct strbuf_child_entry));
|
||||
if (!child) {
|
||||
free(node_child);
|
||||
if (!child)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
str->nodes_count++;
|
||||
|
||||
node->children = child;
|
||||
bubbleinsert(node, c, node_child);
|
||||
bubbleinsert(node, c, TAKE_PTR(node_child));
|
||||
|
||||
return off;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ static int bus_cgroup_set_transient_property(
|
||||
int b;
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -441,7 +441,7 @@ static int bus_cgroup_set_transient_property(
|
||||
CGroupMask mask = 0;
|
||||
|
||||
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");
|
||||
if (r < 0)
|
||||
@ -944,7 +944,7 @@ int bus_cgroup_set_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
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);
|
||||
|
||||
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)) {
|
||||
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);
|
||||
|
||||
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)) {
|
||||
CGroupBlockIODeviceWeight *a = NULL, *b;
|
||||
@ -1476,12 +1476,12 @@ int bus_cgroup_set_property(
|
||||
while ((r = sd_bus_message_read(message, "(ss)", &path, &rwm)) > 0) {
|
||||
|
||||
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))
|
||||
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)) {
|
||||
CGroupDeviceAllow *a = NULL, *b;
|
||||
|
@ -2060,7 +2060,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
c->syslog_priority = (c->syslog_priority & LOG_FACMASK) | level;
|
||||
@ -2077,7 +2077,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
c->syslog_priority = (facility << 3) | LOG_PRI(c->syslog_priority);
|
||||
@ -2094,7 +2094,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
|
||||
@ -2140,13 +2140,13 @@ int bus_exec_context_set_transient_property(
|
||||
break;
|
||||
|
||||
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);
|
||||
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))
|
||||
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)) {
|
||||
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;
|
||||
|
||||
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)) {
|
||||
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;
|
||||
|
||||
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 (streq(s, "~")) {
|
||||
@ -2678,7 +2678,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
|
||||
@ -2830,7 +2830,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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 (strv_isempty(l)) {
|
||||
@ -2864,7 +2864,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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 (strv_isempty(l)) {
|
||||
@ -2897,7 +2897,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
c->oom_score_adjust = oa;
|
||||
@ -3018,7 +3018,7 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
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 (strv_isempty(l)) {
|
||||
@ -3193,7 +3193,7 @@ int bus_exec_context_set_transient_property(
|
||||
if (!path_is_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))
|
||||
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)) {
|
||||
r = bind_mount_add(&c->bind_mounts, &c->n_bind_mounts,
|
||||
|
@ -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);
|
||||
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 {
|
||||
u = manager_get_unit(m, name);
|
||||
if (!u)
|
||||
@ -504,7 +504,7 @@ static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userd
|
||||
else if (sz == 16)
|
||||
memcpy(&id, a, sz);
|
||||
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)) {
|
||||
_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)
|
||||
return r;
|
||||
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);
|
||||
@ -1259,7 +1259,7 @@ static int method_unsubscribe(sd_bus_message *message, void *userdata, sd_bus_er
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
@ -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) {
|
||||
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) {
|
||||
@ -1624,7 +1624,7 @@ static int method_set_environment(sd_bus_message *message, void *userdata, sd_bu
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -1729,7 +1729,7 @@ static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_
|
||||
return r;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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
|
||||
* concept, but the Controller field stores exactly that. */
|
||||
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);
|
||||
if (r < 0)
|
||||
|
@ -109,7 +109,7 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
|
||||
assert(u);
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -120,12 +120,12 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
|
||||
return r;
|
||||
|
||||
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))
|
||||
dest = src;
|
||||
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) {
|
||||
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 */
|
||||
|
||||
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
|
||||
* there's an assert in exec_needs_mount_namespace, so double-check just in case. */
|
||||
c = unit_get_exec_context(u);
|
||||
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))
|
||||
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 */
|
||||
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);
|
||||
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);
|
||||
if (is_image)
|
||||
|
@ -183,7 +183,7 @@ static int timer_add_one_calendar_spec(
|
||||
|
||||
r = calendar_spec_from_string(str, &c);
|
||||
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)
|
||||
return r;
|
||||
|
||||
|
@ -527,7 +527,7 @@ int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *
|
||||
}
|
||||
|
||||
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(
|
||||
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);
|
||||
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)
|
||||
return r;
|
||||
|
||||
@ -719,9 +719,9 @@ int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error
|
||||
if (r == -EOPNOTSUPP)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not supporting cleaning.", u->id);
|
||||
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)
|
||||
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)
|
||||
return r;
|
||||
|
||||
@ -768,9 +768,9 @@ static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userda
|
||||
if (r == -EOPNOTSUPP)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Unit '%s' does not support freezing.", u->id);
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
@ -1442,10 +1442,10 @@ int bus_unit_method_attach_processes(sd_bus_message *message, void *userdata, sd
|
||||
}
|
||||
|
||||
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)))
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -1930,7 +1930,7 @@ static int bus_unit_set_live_property(
|
||||
return r;
|
||||
|
||||
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 (some_absolute)
|
||||
@ -1999,7 +1999,7 @@ static int bus_set_transient_exit_status(
|
||||
return r;
|
||||
|
||||
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)) {
|
||||
*p = k < 0 ? -1 : k;
|
||||
@ -2205,11 +2205,11 @@ static int bus_unit_set_transient_property(
|
||||
const char *s;
|
||||
|
||||
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)
|
||||
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))
|
||||
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);
|
||||
if (r < 0)
|
||||
|
@ -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) ||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1367,7 +1367,7 @@ static int status_welcome(void) {
|
||||
|
||||
static int write_container_id(void) {
|
||||
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");
|
||||
if (isempty(c))
|
||||
|
@ -1732,13 +1732,13 @@ int manager_add_job(
|
||||
assert(mode < _JOB_MODE_MAX);
|
||||
|
||||
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)
|
||||
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)
|
||||
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));
|
||||
|
||||
|
@ -250,7 +250,7 @@ int mac_selinux_generic_access_check(
|
||||
if (!enforce)
|
||||
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";
|
||||
@ -270,7 +270,7 @@ int mac_selinux_generic_access_check(
|
||||
r = errno_or_else(EPERM);
|
||||
|
||||
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",
|
||||
|
@ -59,7 +59,7 @@ int bus_message_read_home_record(sd_bus_message *m, UserRecordLoadFlags flags, U
|
||||
|
||||
r = user_record_load(hr, v, flags);
|
||||
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);
|
||||
return 0;
|
||||
|
@ -437,19 +437,19 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
|
||||
switch (e) {
|
||||
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
@ -457,21 +457,21 @@ static int convert_worker_errno(Home *h, int e, sd_bus_error *error) {
|
||||
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);
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
@ -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!",
|
||||
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;
|
||||
@ -1402,10 +1402,10 @@ static int home_update_internal(
|
||||
assert(hr);
|
||||
|
||||
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 */
|
||||
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)) {
|
||||
r = user_record_clone(hr, USER_RECORD_EXTRACT_SECRET, &saved_secret);
|
||||
@ -1454,7 +1454,7 @@ static int home_update_internal(
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
@ -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 (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 */
|
||||
} else {
|
||||
@ -2349,6 +2349,8 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
|
||||
assert(o);
|
||||
assert(o->type == OPERATION_ACQUIRE);
|
||||
|
||||
assert(!h->current_operation);
|
||||
|
||||
switch (home_get_state(h)) {
|
||||
|
||||
case HOME_UNFIXATED:
|
||||
@ -2357,8 +2359,9 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
r = sd_bus_error_setf(&error, BUS_ERROR_HOME_ABSENT,
|
||||
"Home %s is currently missing or not plugged in.", h->user_name);
|
||||
goto check;
|
||||
|
||||
case HOME_INACTIVE:
|
||||
case HOME_DIRTY:
|
||||
@ -2382,14 +2385,11 @@ static int home_dispatch_acquire(Home *h, Operation *o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(!h->current_operation);
|
||||
|
||||
if (call) {
|
||||
r = home_ratelimit(h, &error);
|
||||
if (r >= 0)
|
||||
r = call(h, o->secret, for_state, &error);
|
||||
}
|
||||
|
||||
check:
|
||||
if (r != 0) /* failure or completed */
|
||||
operation_result(o, r, &error);
|
||||
else /* ongoing */
|
||||
@ -2660,7 +2660,7 @@ int home_schedule_operation(Home *h, Operation *o, sd_bus_error *error) {
|
||||
|
||||
if (o) {
|
||||
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);
|
||||
if (r < 0)
|
||||
|
@ -1457,7 +1457,7 @@ int manager_sign_user_record(Manager *m, UserRecord *u, UserRecord **ret, sd_bus
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
}
|
||||
|
@ -1351,16 +1351,16 @@ int user_record_is_supported(UserRecord *hr, sd_bus_error *error) {
|
||||
assert(hr);
|
||||
|
||||
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))
|
||||
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)
|
||||
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"))
|
||||
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;
|
||||
}
|
||||
|
@ -1080,7 +1080,7 @@ static int method_cancel_transfer(sd_bus_message *msg, void *userdata, sd_bus_er
|
||||
if (r < 0)
|
||||
return r;
|
||||
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));
|
||||
if (!t)
|
||||
|
@ -212,12 +212,12 @@ _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) {
|
||||
int r;
|
||||
|
||||
if (!name)
|
||||
return 0;
|
||||
if (!e)
|
||||
goto finish;
|
||||
|
||||
if (e) {
|
||||
assert_return(!bus_error_is_dirty(e), -EINVAL);
|
||||
|
||||
e->name = strdup(name);
|
||||
@ -230,9 +230,11 @@ _public_ int sd_bus_error_set(sd_bus_error *e, const char *name, const char *mes
|
||||
e->message = strdup(message);
|
||||
|
||||
e->_need_free = 1;
|
||||
}
|
||||
|
||||
finish:
|
||||
return -bus_error_name_to_errno(name);
|
||||
r = bus_error_name_to_errno(name);
|
||||
assert(r > 0);
|
||||
return -r;
|
||||
}
|
||||
|
||||
int bus_error_setfv(sd_bus_error *e, const char *name, const char *format, va_list ap) {
|
||||
|
@ -1800,7 +1800,9 @@ void bus_enter_closing(sd_bus *bus) {
|
||||
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus, sd_bus, bus_free);
|
||||
|
||||
_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_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) {
|
||||
assert_return(bus, -EINVAL);
|
||||
if (!bus)
|
||||
return 0;
|
||||
|
||||
assert_return(bus = bus_resolve(bus), -ENOPKG);
|
||||
assert_return(!bus_pid_changed(bus), -ECHILD);
|
||||
|
||||
@ -2410,7 +2414,7 @@ _public_ int sd_bus_call(
|
||||
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)
|
||||
return sd_bus_error_copy(error, &incoming->error);
|
||||
|
@ -491,7 +491,6 @@ int device_read_uevent_file(sd_device *device) {
|
||||
const char *syspath, *key = NULL, *value = NULL, *major = NULL, *minor = NULL;
|
||||
char *path;
|
||||
size_t uevent_len;
|
||||
unsigned i;
|
||||
int r;
|
||||
|
||||
enum {
|
||||
@ -527,7 +526,7 @@ int device_read_uevent_file(sd_device *device) {
|
||||
|
||||
device->uevent_loaded = true;
|
||||
|
||||
for (i = 0; i < uevent_len; i++)
|
||||
for (size_t i = 0; i < uevent_len; i++)
|
||||
switch (state) {
|
||||
case PRE_KEY:
|
||||
if (!strchr(NEWLINE, uevent[i])) {
|
||||
@ -706,7 +705,7 @@ static int device_new_from_child(sd_device **ret, sd_device *child) {
|
||||
|
||||
pos = strrchr(subdir, '/');
|
||||
if (!pos || pos < subdir + 2)
|
||||
break;
|
||||
return -ENODEV;
|
||||
|
||||
*pos = '\0';
|
||||
|
||||
@ -716,8 +715,6 @@ static int device_new_from_child(sd_device **ret, sd_device *child) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
_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) {
|
||||
_cleanup_free_ char *db = NULL;
|
||||
const char *value;
|
||||
size_t db_len, i;
|
||||
size_t db_len;
|
||||
char key;
|
||||
int r;
|
||||
|
||||
@ -1349,7 +1346,7 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) {
|
||||
|
||||
device->db_loaded = true;
|
||||
|
||||
for (i = 0; i < db_len; i++) {
|
||||
for (size_t i = 0; i < db_len; i++) {
|
||||
switch (state) {
|
||||
case PRE_KEY:
|
||||
if (!strchr(NEWLINE, db[i])) {
|
||||
@ -1387,7 +1384,8 @@ int device_read_db_internal_filename(sd_device *device, const char *filename) {
|
||||
db[i] = '\0';
|
||||
r = handle_db_line(device, key, value);
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
if (r < 0) {
|
||||
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 */
|
||||
@ -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);
|
||||
if (r < 0) {
|
||||
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) &&
|
||||
@ -686,7 +686,7 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
|
||||
(model && !string_is_safe(model)) ||
|
||||
(variant && !string_is_safe(variant)) ||
|
||||
(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);
|
||||
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));
|
||||
|
||||
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.");
|
||||
}
|
||||
|
@ -695,9 +695,9 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
|
||||
return r;
|
||||
|
||||
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())
|
||||
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))
|
||||
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 &&
|
||||
m->seat0->positions[vtnr] &&
|
||||
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)
|
||||
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)
|
||||
return r;
|
||||
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))
|
||||
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 {
|
||||
/* 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
|
||||
@ -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_ignore_inhibit = "org.freedesktop.login1.halt-ignore-inhibit";
|
||||
} 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,
|
||||
action_ignore_inhibit, 0, error);
|
||||
@ -2672,7 +2672,7 @@ static int method_set_reboot_to_firmware_setup(
|
||||
|
||||
r = efi_reboot_to_firmware_supported();
|
||||
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)
|
||||
return r;
|
||||
|
||||
@ -2684,7 +2684,7 @@ static int method_set_reboot_to_firmware_setup(
|
||||
if (r < 0)
|
||||
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
|
||||
/* non-EFI case: $SYSTEMD_REBOOT_TO_FIRMWARE_SETUP is set to on */
|
||||
use_efi = false;
|
||||
@ -2840,7 +2840,7 @@ static int method_set_reboot_to_boot_loader_menu(
|
||||
if (r < 0)
|
||||
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))
|
||||
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;
|
||||
|
||||
@ -2850,7 +2850,7 @@ static int method_set_reboot_to_boot_loader_menu(
|
||||
if (r < 0)
|
||||
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
|
||||
/* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU is set to on */
|
||||
use_efi = false;
|
||||
@ -3042,7 +3042,7 @@ static int method_set_reboot_to_boot_loader_entry(
|
||||
if (r < 0)
|
||||
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))
|
||||
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;
|
||||
|
||||
@ -3052,7 +3052,7 @@ static int method_set_reboot_to_boot_loader_entry(
|
||||
if (r < 0)
|
||||
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
|
||||
/* non-EFI case: $SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY is set to on */
|
||||
use_efi = false;
|
||||
|
@ -206,7 +206,7 @@ static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_erro
|
||||
return r;
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
|
@ -256,11 +256,11 @@ static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_
|
||||
return r;
|
||||
|
||||
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);
|
||||
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)
|
||||
return r;
|
||||
|
||||
@ -289,7 +289,7 @@ static int method_set_locked_hint(sd_bus_message *message, void *userdata, sd_bu
|
||||
return r;
|
||||
|
||||
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);
|
||||
|
||||
@ -364,7 +364,7 @@ static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_e
|
||||
return r;
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -380,7 +380,7 @@ static int method_release_control(sd_bus_message *message, void *userdata, sd_bu
|
||||
assert(s);
|
||||
|
||||
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);
|
||||
|
||||
@ -406,7 +406,7 @@ static int method_set_type(sd_bus_message *message, void *userdata, sd_bus_error
|
||||
"Invalid session type '%s'", t);
|
||||
|
||||
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);
|
||||
|
||||
@ -428,10 +428,10 @@ static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_er
|
||||
return r;
|
||||
|
||||
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)))
|
||||
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);
|
||||
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
|
||||
* than one fd (it would be functionally
|
||||
* 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);
|
||||
if (r < 0)
|
||||
@ -478,15 +478,15 @@ static int method_release_device(sd_bus_message *message, void *userdata, sd_bus
|
||||
return r;
|
||||
|
||||
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)))
|
||||
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);
|
||||
sd = hashmap_get(s->devices, &dev);
|
||||
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_save(s);
|
||||
@ -509,15 +509,15 @@ static int method_pause_device_complete(sd_bus_message *message, void *userdata,
|
||||
return r;
|
||||
|
||||
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)))
|
||||
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);
|
||||
sd = hashmap_get(s->devices, &dev);
|
||||
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);
|
||||
|
||||
@ -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);
|
||||
|
||||
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)
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -559,7 +559,7 @@ static int method_set_brightness(sd_bus_message *message, void *userdata, sd_bus
|
||||
return r;
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
|
@ -41,7 +41,7 @@ int bus_image_method_remove(
|
||||
assert(image);
|
||||
|
||||
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(
|
||||
message,
|
||||
@ -146,7 +146,7 @@ int bus_image_method_clone(
|
||||
assert(m);
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -252,7 +252,7 @@ int bus_image_method_set_limit(
|
||||
if (r < 0)
|
||||
return r;
|
||||
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(
|
||||
message,
|
||||
|
@ -331,12 +331,12 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
|
||||
if (r < 0)
|
||||
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -415,15 +415,15 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
|
||||
if (r < 0)
|
||||
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -628,7 +628,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
|
||||
if (r < 0)
|
||||
return r;
|
||||
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[] = {
|
||||
"machine", m->name,
|
||||
@ -820,19 +820,19 @@ int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bu
|
||||
assert(m);
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
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))
|
||||
dest = src;
|
||||
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(
|
||||
message,
|
||||
@ -852,7 +852,7 @@ int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bu
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
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);
|
||||
|
||||
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)
|
||||
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);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
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))
|
||||
dest = src;
|
||||
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(
|
||||
message,
|
||||
@ -1074,7 +1074,7 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
|
||||
if (r < 0)
|
||||
return sd_bus_error_set_errnof(error, r, "Failed to wait for child: %m");
|
||||
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);
|
||||
if (fd < 0)
|
||||
@ -1084,7 +1084,7 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
|
||||
}
|
||||
|
||||
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);
|
||||
@ -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));
|
||||
|
||||
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);
|
||||
if (r == -ENXIO)
|
||||
|
@ -241,7 +241,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
|
||||
if (r < 0)
|
||||
return r;
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -251,7 +251,7 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
|
||||
else if (n == 16)
|
||||
memcpy(&id, v, n);
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -275,14 +275,14 @@ static int method_create_or_register_machine(Manager *manager, sd_bus_message *m
|
||||
else {
|
||||
c = machine_class_from_string(class);
|
||||
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)
|
||||
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))
|
||||
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) {
|
||||
_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);
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -842,7 +842,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
|
||||
if (r < 0)
|
||||
return r;
|
||||
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(
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
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);
|
||||
if (r == -ESRCH)
|
||||
|
@ -22,14 +22,14 @@ static int operation_done(sd_event_source *s, const siginfo_t *si, void *userdat
|
||||
o->pid = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (si->si_status == EXIT_SUCCESS)
|
||||
r = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ int manager_request_product_uuid(Manager *m, Link *link) {
|
||||
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.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
|
||||
if (r == 0)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", 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);
|
||||
if (r < 0)
|
||||
@ -854,7 +854,7 @@ int link_send_changed_strv(Link *link, char **properties) {
|
||||
assert(link->manager);
|
||||
assert(properties);
|
||||
|
||||
if (!link->manager->bus)
|
||||
if (sd_bus_is_ready(link->manager->bus) <= 0)
|
||||
return 0;
|
||||
|
||||
p = link_bus_path(link);
|
||||
|
@ -339,7 +339,7 @@ int manager_send_changed_strv(Manager *manager, char **properties) {
|
||||
assert(manager);
|
||||
assert(properties);
|
||||
|
||||
if (!manager->bus)
|
||||
if (sd_bus_is_ready(manager->bus) <= 0)
|
||||
return 0;
|
||||
|
||||
return sd_bus_emit_properties_changed_strv(
|
||||
|
@ -767,8 +767,8 @@ int manager_set_hostname(Manager *m, const char *hostname) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting hostname later.");
|
||||
if (sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting system hostname later.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -784,7 +784,6 @@ int manager_set_hostname(Manager *m, const char *hostname) {
|
||||
"sb",
|
||||
hostname,
|
||||
false);
|
||||
|
||||
if (r < 0)
|
||||
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)
|
||||
return r;
|
||||
|
||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting timezone later.");
|
||||
if (sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting system timezone later.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ static int method_set_pool_limit(sd_bus_message *message, void *userdata, sd_bus
|
||||
if (r < 0)
|
||||
return r;
|
||||
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(
|
||||
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);
|
||||
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)
|
||||
return sd_bus_error_set_errnof(error, r, "Failed to adjust quota limit: %m");
|
||||
|
||||
|
@ -443,7 +443,7 @@ int bus_image_common_remove(
|
||||
}
|
||||
|
||||
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,
|
||||
message,
|
||||
@ -781,7 +781,7 @@ int bus_image_common_set_limit(
|
||||
if (r < 0)
|
||||
return r;
|
||||
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,
|
||||
message,
|
||||
|
@ -20,14 +20,14 @@ static int operation_done(sd_event_source *s, const siginfo_t *si, void *userdat
|
||||
o->pid = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (si->si_status == EXIT_SUCCESS)
|
||||
r = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ static int validate_and_mangle_flags(
|
||||
SD_RESOLVED_NO_TRUST_ANCHOR|
|
||||
SD_RESOLVED_NO_NETWORK|
|
||||
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 */
|
||||
*flags |= SD_RESOLVED_PROTOCOLS_ALL;
|
||||
@ -420,7 +420,7 @@ static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata,
|
||||
return r;
|
||||
|
||||
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))
|
||||
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;
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -738,7 +738,7 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
|
||||
return r;
|
||||
|
||||
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);
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
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;
|
||||
|
||||
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))
|
||||
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);
|
||||
|
||||
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);
|
||||
if (r < 0)
|
||||
@ -1861,7 +1861,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
|
||||
assert(m);
|
||||
|
||||
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);
|
||||
if (!service)
|
||||
@ -1928,7 +1928,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
|
||||
return r;
|
||||
|
||||
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))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "TXT key '%s' contains non-ASCII symbols", key);
|
||||
|
@ -386,7 +386,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
|
||||
if (r == 0)
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid search domain %s", 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) {
|
||||
prefixed = strjoin("~", name);
|
||||
|
@ -46,14 +46,13 @@ static const BaseFilesystem table[] = {
|
||||
|
||||
int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
size_t i;
|
||||
int r;
|
||||
|
||||
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
|
||||
if (fd < 0)
|
||||
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)
|
||||
continue;
|
||||
|
||||
@ -94,10 +93,9 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
|
||||
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)
|
||||
return log_error_errno(errno, "Failed to chown symlink at %s/%s: %m", root, table[i].dir);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -114,11 +112,10 @@ int base_filesystem_create(const char *root, uid_t uid, gid_t gid) {
|
||||
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)
|
||||
return log_error_errno(errno, "Failed to chown directory at %s/%s: %m", root, table[i].dir);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ int bus_message_read_ifindex(sd_bus_message *message, sd_bus_error *error, int *
|
||||
return r;
|
||||
|
||||
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;
|
||||
|
||||
@ -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);
|
||||
|
||||
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)
|
||||
*ret_family = family;
|
||||
@ -99,7 +99,7 @@ static int bus_message_read_dns_one(
|
||||
return r;
|
||||
|
||||
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);
|
||||
return r;
|
||||
}
|
||||
|
@ -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, ...) {
|
||||
TableDataType type;
|
||||
va_list ap;
|
||||
TableCell *last_cell = NULL;
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
assert(t);
|
||||
assert(first_type >= 0);
|
||||
assert(first_type < _TABLE_DATA_TYPE_MAX);
|
||||
|
||||
type = first_type;
|
||||
|
||||
va_start(ap, first_type);
|
||||
for (;;) {
|
||||
|
||||
for (TableDataType type = first_type;; type = va_arg(ap, TableDataType)) {
|
||||
const void *data;
|
||||
union {
|
||||
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);
|
||||
|
||||
r = table_set_minimum_width(t, last_cell, w);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_MAXIMUM_WIDTH: {
|
||||
size_t w = va_arg(ap, size_t);
|
||||
r = table_set_maximum_width(t, last_cell, w);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_WEIGHT: {
|
||||
unsigned w = va_arg(ap, unsigned);
|
||||
r = table_set_weight(t, last_cell, w);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_ALIGN_PERCENT: {
|
||||
unsigned p = va_arg(ap, unsigned);
|
||||
r = table_set_align_percent(t, last_cell, p);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_ELLIPSIZE_PERCENT: {
|
||||
unsigned p = va_arg(ap, unsigned);
|
||||
r = table_set_ellipsize_percent(t, last_cell, p);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_COLOR: {
|
||||
const char *c = va_arg(ap, const char*);
|
||||
r = table_set_color(t, last_cell, c);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_RGAP_COLOR: {
|
||||
const char *c = va_arg(ap, const char*);
|
||||
r = table_set_rgap_color(t, last_cell, c);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_URL: {
|
||||
const char *u = va_arg(ap, const char*);
|
||||
r = table_set_url(t, last_cell, u);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
case TABLE_SET_UPPERCASE: {
|
||||
int u = va_arg(ap, int);
|
||||
r = table_set_uppercase(t, last_cell, u);
|
||||
break;
|
||||
goto check;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
if (type < _TABLE_DATA_TYPE_MAX)
|
||||
r = table_add_cell(t, &last_cell, type, data);
|
||||
|
||||
check:
|
||||
if (r < 0) {
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
type = va_arg(ap, TableDataType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ static void test_ensure_cap_64bit(void) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -61,6 +61,13 @@ static bool test_v4(FirewallContext *ctx) {
|
||||
|
||||
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, 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)
|
||||
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)
|
||||
test_v6(ctx);
|
||||
|
||||
|
@ -96,21 +96,17 @@ static int print_status_info(const StatusInfo *i) {
|
||||
} else
|
||||
log_warning("Could not get time from timedated and not operating locally, ignoring.");
|
||||
|
||||
if (have_time)
|
||||
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm));
|
||||
|
||||
n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S %Z", localtime_r(&sec, &tm)) : 0;
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Local time:",
|
||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||
TABLE_STRING, n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
return table_log_add_error(r);
|
||||
|
||||
if (have_time)
|
||||
n = strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm));
|
||||
|
||||
n = have_time ? strftime(a, sizeof a, "%a %Y-%m-%d %H:%M:%S UTC", gmtime_r(&sec, &tm)) : 0;
|
||||
r = table_add_many(table,
|
||||
TABLE_STRING, "Universal time:",
|
||||
TABLE_STRING, have_time && n > 0 ? a : "n/a");
|
||||
TABLE_STRING, n > 0 ? a : "n/a");
|
||||
if (r < 0)
|
||||
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);
|
||||
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,
|
||||
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)
|
||||
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:");
|
||||
if (r < 0)
|
||||
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)
|
||||
return table_log_add_error(r);
|
||||
|
||||
|
||||
/* Restore the $TZ */
|
||||
r = set_unset_env("TZ", old_tz, true);
|
||||
if (r < 0)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <linux/pci_regs.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "device-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
@ -262,18 +263,60 @@ static bool is_pci_bridge(sd_device *dev) {
|
||||
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) {
|
||||
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;
|
||||
_cleanup_(sd_device_unrefp) sd_device *pci = NULL;
|
||||
sd_device *hotplug_slot_dev;
|
||||
char slots[PATH_MAX];
|
||||
_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;
|
||||
|
||||
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;
|
||||
while (hotplug_slot_dev) {
|
||||
if (sd_device_get_sysname(hotplug_slot_dev, &sysname) < 0)
|
||||
continue;
|
||||
struct dirent *dent;
|
||||
|
||||
/* 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 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);
|
||||
r = parse_hotplug_slot_from_function_id(hotplug_slot_dev, slots, &hotplug_slot);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
if (r > 0) {
|
||||
domain = 0; /* See comments in parse_hotplug_slot_from_function_id(). */
|
||||
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) {
|
||||
int i;
|
||||
char str[PATH_MAX];
|
||||
_cleanup_free_ char *address = NULL;
|
||||
char str[PATH_MAX];
|
||||
uint32_t i;
|
||||
|
||||
if (dot_or_dot_dot(dent->d_name))
|
||||
continue;
|
||||
|
||||
r = safe_atoi(dent->d_name, &i);
|
||||
r = safe_atou32(dent->d_name, &i);
|
||||
if (r < 0 || i <= 0)
|
||||
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
|
||||
* collision. */
|
||||
if (naming_scheme_has(NAMING_BRIDGE_NO_SLOT) && is_pci_bridge(hotplug_slot_dev))
|
||||
hotplug_slot = 0;
|
||||
return 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hotplug_slot >= 0)
|
||||
if (hotplug_slot > 0)
|
||||
break;
|
||||
if (sd_device_get_parent_with_subsystem_devtype(hotplug_slot_dev, "pci", NULL, &hotplug_slot_dev) < 0)
|
||||
break;
|
||||
@ -411,7 +439,7 @@ static int dev_pci_slot(sd_device *dev, struct netnames *names) {
|
||||
l = sizeof(names->pci_slot);
|
||||
if (domain > 0)
|
||||
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))
|
||||
l = strpcpyf(&s, l, "f%d", func);
|
||||
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);
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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 ${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}.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 ${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}.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-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 -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
|
||||
cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f $os_release
|
||||
|
Loading…
x
Reference in New Issue
Block a user