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@gmail.com>
This commit is contained in:
parent
d28caaed68
commit
7985831a65
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user