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 <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
d28caaed68
commit
7985831a65
@@ -191,8 +191,12 @@ setup_environment(struct passwd* passwd, bool preserveEnvironment, bool chngdir)
|
|||||||
setenv("USER", passwd->pw_name, true);
|
setenv("USER", passwd->pw_name, true);
|
||||||
|
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
if (ioctl(STDIN_FILENO, TIOCSPGRP, &pid) != 0)
|
// If stdin is not open, don't bother trying to TIOCSPGRP. (This is the
|
||||||
return errno;
|
// 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)
|
if (passwd->pw_gid && setgid(passwd->pw_gid) != 0)
|
||||||
return errno;
|
return errno;
|
||||||
|
|||||||
Reference in New Issue
Block a user