Fix a regression that was introduced in r191882.

I changed login_tty() to only work when the application is not a session
leader yet. This works fine for applications in the base system, but it
turns out various applications call this function after daemonizing,
which means they already use their own session.

If setsid() fails, just call tcsetsid() on the current session.
tcsetsid() will already perform proper security checks.

Reported by:	Oliver Lehmann
MFC after:	1 week
This commit is contained in:
Ed Schouten 2010-01-17 17:52:35 +00:00
parent 79a7dbf111
commit 2c8d07a874

View File

@ -50,7 +50,7 @@ login_tty(int fd)
s = setsid();
if (s == -1)
return (-1);
s = getsid(0);
if (tcsetsid(fd, s) == -1)
return (-1);
(void) dup2(fd, 0);