summaryrefslogtreecommitdiff
path: root/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-13 21:13:49 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-13 21:13:49 +0200
commitd8b4e2e9acb8c68cd46405ae1e9b8fb06cb75269 (patch)
tree80b02bca5b2936beab8b2298de20be340423b4b9 /execute.c
parent10a94420172b33a7472a16b2e829689dbc570cad (diff)
execute: fix terminal chowning logic
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/execute.c b/execute.c
index a82d016cbc..73d82d5a76 100644
--- a/execute.c
+++ b/execute.c
@@ -342,8 +342,7 @@ static int chown_terminal(int fd, uid_t uid) {
if (fstat(fd, &st) < 0)
return -errno;
- if (st.st_uid != uid ||
- st.st_mode != TTY_MODE)
+ if (st.st_uid != uid || (st.st_mode & 0777) != TTY_MODE)
return -EPERM;
return 0;
@@ -834,6 +833,12 @@ int exec_spawn(ExecCommand *command,
r = EXIT_USER;
goto fail;
}
+
+ if (is_terminal_input(context->std_input))
+ if (chown_terminal(STDIN_FILENO, uid) < 0) {
+ r = EXIT_STDIN;
+ goto fail;
+ }
}
if (apply_permissions)
@@ -842,12 +847,6 @@ int exec_spawn(ExecCommand *command,
goto fail;
}
- if (is_terminal_input(context->std_input))
- if (chown_terminal(STDIN_FILENO, uid) < 0) {
- r = EXIT_STDIN;
- goto fail;
- }
-
if (apply_chroot) {
if (context->root_directory)
if (chroot(context->root_directory) < 0) {