user-util: return malloc'ed strings in get_user_creds
get_user_creds would use getpwnam() and then returns strings pointing into the static buffer. This seems very iffy. Let's duplicate the strings properly
This commit is contained in:
+2
-4
@@ -2045,13 +2045,11 @@ static int socket_chown(Socket *s, PidRef *ret_pid) {
|
||||
/* Child */
|
||||
|
||||
if (!isempty(s->user)) {
|
||||
const char *user = s->user;
|
||||
|
||||
r = get_user_creds(&user, &uid, &gid, NULL, NULL, 0);
|
||||
r = get_user_creds(s->user, /* flags= */ 0, NULL, &uid, &gid, NULL, NULL);
|
||||
if (r < 0) {
|
||||
log_unit_error_errno(UNIT(s), r,
|
||||
"Failed to resolve user '%s': %s",
|
||||
user, STRERROR_USER(r));
|
||||
s->user, STRERROR_USER(r));
|
||||
_exit(EXIT_USER);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user