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;
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)
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) {