From owner-FreeBSD-users-jp@jp.FreeBSD.org Wed Aug  4 15:50:03 2004
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id i746o3V82467;
	Wed, 4 Aug 2004 15:50:03 +0900 (JST)
	(envelope-from owner-FreeBSD-users-jp@jp.FreeBSD.org)
Received: from host1.fcc.ad.jp (host1.fcc.ad.jp [61.114.163.126])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with ESMTP/inet id i746o2882458
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Wed, 4 Aug 2004 15:50:02 +0900 (JST)
	(envelope-from sasaki@fcc.ad.jp)
Received: from core.noc.fcc.ad.jp (core.noc.fcc.ad.jp [192.168.1.20])
	by host1.fcc.ad.jp (8.12.11/8.12.11) with ESMTP id i746o0YT034967
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Wed, 4 Aug 2004 15:50:00 +0900 (JST)
	(envelope-from sasaki@fcc.ad.jp)
Received: from ayoki.noc.fcc.ad.jp (ayoki.noc.fcc.ad.jp [192.168.1.130])
	by core.noc.fcc.ad.jp (8.12.11/8.12.11) with ESMTP id i746o09p018741
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Wed, 4 Aug 2004 15:50:00 +0900 (JST)
Received: from localhost (localhost [IPv6:::1])
	by ayoki.noc.fcc.ad.jp (8.12.11/8.12.11) with ESMTP id i746nxQe002734
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Wed, 4 Aug 2004 15:50:00 +0900 (JST)
	(envelope-from sasaki@fcc.ad.jp)
Message-Id: <20040804.154959.127176548.sasaki@fcc.ad.jp>
To: FreeBSD-users-jp@jp.FreeBSD.org
From: Kan Sasaki <sasaki@fcc.ad.jp>
In-Reply-To: <200408040403.AA00139@polymer5.scphys.kyoto-u.ac.jp>
References: <20040803.164944.00198785.sasaki@fcc.ad.jp>
	<200408040403.AA00139@polymer5.scphys.kyoto-u.ac.jp>
X-Mailer: Mew version 4.0.66 on Emacs 21.3.50 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamd / ClamAV version devel-20040705, clamav-milter version 0.74a
	on host1.fcc.ad.jp
X-Virus-Status: Clean
Reply-To: FreeBSD-users-jp@jp.FreeBSD.org
Precedence: list
Date: Wed, 04 Aug 2004 15:49:59 +0900
X-Sequence: FreeBSD-users-jp 80482
Subject: [FreeBSD-users-jp 80482] Re: from address by /usr/bin/mail
Sender: owner-FreeBSD-users-jp@jp.FreeBSD.org
X-Originator: sasaki@fcc.ad.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+040717

> setsid(2)$B$NFbMF$r40A4$K$OM}2r$G$-$F$$$J$$$N$G$9$,!"(B
> sshd $B$G$O(B setlogin() $B$7$?;~E@$^$G$O2a5n$K(B setlogin() $B$G@_Dj$7$?%m%0%$%sL>$,;H$o$l$k!"(B
> $B$H$$$&$3$H$G$9$M!#$H$$$&$3$H$O!"%m%0%$%s$7$?%f!<%6$K(Bsetlogin()$B$7$?8z2L$,!"(B
> fork()$B$9$kA0$N?F%W%m%;%9$K$b1F6A$9$k$N$G$7$g$&$+!)$D$^$j!"$=$N8e$O$=$N%f!<%6$G(B
> $B%m%0%$%s$7$?$3$H$K$J$C$?$^$^$J$N$G$9$M!#(B

$B13=q$$$?$+$b!#$4$a$s$J$5$$!#(B

http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/sshd.c $B$r8+$k$H!"(B
rev1.241 $B$G0J2<$NJQ99$,$"$j$^$9!#(B

  Call setsid() in the child after sshd accepts the connection and forks.
  This is needed for privsep which calls setlogin() when it changes uids.
  Without this, there is a race where the login name of an existing connection,
  as returned by getlogin(), may be changed to the privsep user (sshd).

/usr/src/crypto/openssh/sshd.c $B$G3:Ev$9$kItJ,$r8+$k$H!"0J2<$N$h$&$KL5(B
$B8z$K$J$C$F$$$^$9!#(B

#if 0
        /* XXX: this breaks Solaris */
        if (!debug_flag && !inetd_flag && setsid() < 0)
                error("setsid: %.100s", strerror(errno));
#endif

$B$3$l$,860x$N$h$&$G$9$M!#;n$7$KM-8z$K$7$F$_$k$H!"(Bsshd $B$r5/F0$7$?%m%0%$(B
$B%s%f!<%6$+$i%a!<%k$,FO$/$h$&$K$J$j$^$7$?!#(B

$B$A$J$_$K(B CURRENT $B$N(B sshd (3.8.1p1) $B$d(B ports $B$N(B openssh-portable ($B$3$A(B
$B$i$b(B 3.8.1p1) $B$G$O(B SSHD_ACQUIRES_CTTY $B$NM-L5$G!"M-8z$K$9$k$+$I$&$+7h$a(B
$B$k$h$&$K$J$C$F$$$^$9!#(B

#if !defined(SSHD_ACQUIRES_CTTY)
        /*
         * If setsid is called, on some platforms sshd will later acquire a
         * controlling terminal which will result in "could not set
         * controlling tty" errors.
         */
        if (!debug_flag && !inetd_flag && setsid() < 0)
                error("setsid: %.100s", strerror(errno));
#endif

-- 
Fusion Communications Corp.
$B:4!9LZ(B  $B42(B  sasaki@fcc.ad.jp
