summaryrefslogtreecommitdiffstats
path: root/src/core/dynamic-user.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/dynamic-user.c')
-rw-r--r--src/core/dynamic-user.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c
index 4f8f764733..24ed889b61 100644
--- a/src/core/dynamic-user.c
+++ b/src/core/dynamic-user.c
@@ -143,7 +143,6 @@ static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret)
}
static int make_uid_symlinks(uid_t uid, const char *name, bool b) {
-
char path1[STRLEN("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1];
const char *path2;
int r = 0, k;
@@ -754,7 +753,6 @@ int dynamic_user_lookup_name(Manager *m, const char *name, uid_t *ret) {
int dynamic_creds_make(Manager *m, const char *user, const char *group, DynamicCreds **ret) {
_cleanup_(dynamic_creds_unrefp) DynamicCreds *creds = NULL;
- bool acquired = false;
int r;
assert(m);
@@ -777,20 +775,14 @@ int dynamic_creds_make(Manager *m, const char *user, const char *group, DynamicC
r = dynamic_user_acquire(m, user, &creds->user);
if (r < 0)
return r;
-
- acquired = true;
}
- if (creds->user && (!group || streq_ptr(user, group)))
- creds->group = dynamic_user_ref(creds->user);
- else if (group) {
+ if (group && !streq_ptr(user, group)) {
r = dynamic_user_acquire(m, group, &creds->group);
- if (r < 0) {
- if (acquired)
- creds->user = dynamic_user_unref(creds->user);
+ if (r < 0)
return r;
- }
- }
+ } else
+ creds->group = ASSERT_PTR(dynamic_user_ref(creds->user));
*ret = TAKE_PTR(creds);