summaryrefslogtreecommitdiff
path: root/src/core/dbus-execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/dbus-execute.c')
-rw-r--r--src/core/dbus-execute.c80
1 files changed, 33 insertions, 47 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 9dfca14914..3be88ddf90 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -836,19 +836,9 @@ int bus_exec_context_set_transient_property(
return r;
if (mode != UNIT_CHECK) {
-
- if (isempty(uu))
- c->user = mfree(c->user);
- else {
- char *t;
-
- t = strdup(uu);
- if (!t)
- return -ENOMEM;
-
- free(c->user);
- c->user = t;
- }
+ r = free_and_strdup(&c->user, uu);
+ if (r < 0)
+ return r;
unit_write_drop_in_private_format(u, mode, name, "User=%s\n", uu);
}
@@ -863,19 +853,9 @@ int bus_exec_context_set_transient_property(
return r;
if (mode != UNIT_CHECK) {
-
- if (isempty(gg))
- c->group = mfree(c->group);
- else {
- char *t;
-
- t = strdup(gg);
- if (!t)
- return -ENOMEM;
-
- free(c->group);
- c->group = t;
- }
+ r = free_and_strdup(&c->group, gg);
+ if (r < 0)
+ return r;
unit_write_drop_in_private_format(u, mode, name, "Group=%s\n", gg);
}
@@ -889,19 +869,9 @@ int bus_exec_context_set_transient_property(
return r;
if (mode != UNIT_CHECK) {
-
- if (isempty(id)) {
- c->syslog_identifier = mfree(c->syslog_identifier);
- } else {
- char *t;
-
- t = strdup(id);
- if (!t)
- return -ENOMEM;
-
- free(c->syslog_identifier);
- c->syslog_identifier = t;
- }
+ r = free_and_strdup(&c->syslog_identifier, id);
+ if (r < 0)
+ return r;
unit_write_drop_in_private_format(u, mode, name, "SyslogIdentifier=%s\n", id);
}
@@ -1118,10 +1088,9 @@ int bus_exec_context_set_transient_property(
return r;
if (mode != UNIT_CHECK) {
- if (isempty(id))
- c->utmp_id = mfree(c->utmp_id);
- else if (free_and_strdup(&c->utmp_id, id) < 0)
- return -ENOMEM;
+ r = free_and_strdup(&c->utmp_id, id);
+ if (r < 0)
+ return r;
unit_write_drop_in_private_format(u, mode, name, "UtmpIdentifier=%s\n", strempty(id));
}
@@ -1156,10 +1125,9 @@ int bus_exec_context_set_transient_property(
return r;
if (mode != UNIT_CHECK) {
- if (isempty(n))
- c->pam_name = mfree(c->pam_name);
- else if (free_and_strdup(&c->pam_name, n) < 0)
- return -ENOMEM;
+ r = free_and_strdup(&c->pam_name, n);
+ if (r < 0)
+ return r;
unit_write_drop_in_private_format(u, mode, name, "PAMName=%s\n", strempty(n));
}
@@ -1478,6 +1446,24 @@ int bus_exec_context_set_transient_property(
return 1;
+ } else if (streq(name, "SELinuxContext")) {
+ const char *s;
+
+ r = sd_bus_message_read(message, "s", &s);
+ if (r < 0)
+ return r;
+
+ if (mode != UNIT_CHECK) {
+ if (isempty(s))
+ c->selinux_context = mfree(c->selinux_context);
+ else if (free_and_strdup(&c->selinux_context, s) < 0)
+ return -ENOMEM;
+
+ unit_write_drop_in_private_format(u, mode, name, "%s=%s\n", name, strempty(s));
+ }
+
+ return 1;
+
}
ri = rlimit_from_string(name);