diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-07-23 01:17:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-07-23 01:17:59 +0200 |
commit | 4b67834e9f8a336dbc917f3bf212550e61cc98b4 (patch) | |
tree | 69babe73a6daf006645912f0c31fcdc1868d3167 /src/tmpfiles.c | |
parent | e6a6b406791a76ca979ff5e615fd4d9a986a14b8 (diff) |
util: make use of get_user_creds() and get_group_creds() wherever applicable
Diffstat (limited to 'src/tmpfiles.c')
-rw-r--r-- | src/tmpfiles.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/tmpfiles.c b/src/tmpfiles.c index a1b2f8b1d2..3a1985a363 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -757,18 +757,11 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } if (user && !streq(user, "-")) { - uid_t uid; - struct passwd *p; - - if (streq(user, "root") || streq(user, "0")) - i->uid = 0; - else if (parse_uid(user, &uid) >= 0) - i->uid = uid; - else if ((p = getpwnam(user))) - i->uid = p->pw_uid; - else { + const char *u = user; + + r = get_user_creds(&u, &i->uid, NULL, NULL); + if (r < 0) { log_error("[%s:%u] Unknown user '%s'.", fname, line, user); - r = -ENOENT; goto finish; } @@ -776,18 +769,11 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } if (group && !streq(group, "-")) { - gid_t gid; - struct group *g; - - if (streq(group, "root") || streq(group, "0")) - i->gid = 0; - else if (parse_gid(group, &gid) >= 0) - i->gid = gid; - else if ((g = getgrnam(group))) - i->gid = g->gr_gid; - else { + const char *g = group; + + r = get_group_creds(&g, &i->gid); + if (r < 0) { log_error("[%s:%u] Unknown group '%s'.", fname, line, group); - r = -ENOENT; goto finish; } |