summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-03-22 20:43:30 +0100
committerMike Yuan <me@yhndnzj.com>2024-03-22 20:43:30 +0100
commitf2859ba52fd3e2d7f28ae9ddf20df1c540ad06cb (patch)
treebb1ae0bd9b7eb6325ec97e3377ea0c31813c8eb0 /src
parentcore/execute: use STR_IN_SET where appropriate (diff)
downloadsystemd-f2859ba52fd3e2d7f28ae9ddf20df1c540ad06cb.tar.xz
systemd-f2859ba52fd3e2d7f28ae9ddf20df1c540ad06cb.zip
core/dynamic-user: trivial modernization
Diffstat (limited to 'src')
-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);