From e219f88c18bf1565b632b505fcbea99e437fd3b2 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 24 Jan 2010 14:30:57 +0000 Subject: [PATCH] MFC r202500: 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 git-svn-id: svn://svn.freebsd.org/base/stable/8@202929 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libutil/login_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libutil/login_tty.c b/lib/libutil/login_tty.c index a14e244e4..92dc87fe7 100644 --- a/lib/libutil/login_tty.c +++ b/lib/libutil/login_tty.c @@ -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); -- 2.45.2