hrev52300 adds 1 changeset to branch 'master'
old head: d28caaed686e8f2c5af499d1639c4baea4e85e9d
new head: 7985831a65d2aa8155444b54f826cd8754753393
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=7985831a65d2+%5Ed28caaed686e
----------------------------------------------------------------------------
7985831a65d2: bin/multiuser: Do not exit with an error if stdin is not open.
As the comment says, there are a number of scenarios when this is
the case, e.g. non-interactive SSH sessions.
Change-Id: I3a10043820039f344b3f036f7861c81f6fb7ef05
Reviewed-on: https://review.haiku-os.org/499
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52300
Commit: 7985831a65d2aa8155444b54f826cd8754753393
URL: https://git.haiku-os.org/haiku/commit/?id=7985831a65d2
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Tue Aug 28 23:31:34 2018 UTC
Committer: waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Tue Aug 28 23:34:27 2018 UTC
----------------------------------------------------------------------------
1 file changed, 6 insertions(+), 2 deletions(-)
src/bin/multiuser/multiuser_utils.cpp | 8 ++++++--
----------------------------------------------------------------------------
diff --git a/src/bin/multiuser/multiuser_utils.cpp
b/src/bin/multiuser/multiuser_utils.cpp
index 0d916ff2bc..d8804b193f 100644
--- a/src/bin/multiuser/multiuser_utils.cpp
+++ b/src/bin/multiuser/multiuser_utils.cpp
@@ -191,8 +191,12 @@ setup_environment(struct passwd* passwd, bool
preserveEnvironment, bool chngdir)
setenv("USER", passwd->pw_name, true);
pid_t pid = getpid();
- if (ioctl(STDIN_FILENO, TIOCSPGRP, &pid) != 0)
- return errno;
+ // If stdin is not open, don't bother trying to TIOCSPGRP. (This is the
+ // case when there is no PTY, e.g. for a noninteractive SSH session.)
+ if (fcntl(STDIN_FILENO, F_GETFD) != -1) {
+ if (ioctl(STDIN_FILENO, TIOCSPGRP, &pid) != 0)
+ return errno;
+ }
if (passwd->pw_gid && setgid(passwd->pw_gid) != 0)
return errno;