execute: generalize uid/gid handling in two cases for any kind of uid/gid
authorLennart Poettering <lennart@poettering.net>
Thu, 14 Mar 2019 16:24:47 +0000 (17:24 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Mar 2019 15:57:33 +0000 (16:57 +0100)
src/core/execute.c

index 6df9016..d464766 100644 (file)
@@ -3161,7 +3161,7 @@ static int exec_child(
                                       USER_PROCESS,
                                       username);
 
-        if (context->user) {
+        if (uid_is_valid(uid)) {
                 r = chown_terminal(STDIN_FILENO, uid);
                 if (r < 0) {
                         *exit_status = EXIT_STDIN;
@@ -3466,7 +3466,7 @@ static int exec_child(
         }
 
         if (needs_setuid) {
-                if (context->user) {
+                if (uid_is_valid(uid)) {
                         r = enforce_user(context, uid);
                         if (r < 0) {
                                 *exit_status = EXIT_USER;