From owner-freebsd-bugs@FreeBSD.ORG Wed May 20 15:10:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 798A0106568B for ; Wed, 20 May 2009 15:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 653FA8FC2F for ; Wed, 20 May 2009 15:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n4KFA207087422 for ; Wed, 20 May 2009 15:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n4KFA242087421; Wed, 20 May 2009 15:10:02 GMT (envelope-from gnats) Date: Wed, 20 May 2009 15:10:02 GMT Message-Id: <200905201510.n4KFA242087421@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Glen Barber Cc: Subject: Re: bin/134694: gives false-positive when unable to obtain socket [WAS: sshd(8) - alert user when fails to execute from rc.d] X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Glen Barber List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 15:10:03 -0000 The following reply was made to PR bin/134694; it has been noted by GNATS. From: Glen Barber To: rea-fbsd@codelabs.ru Cc: hackers@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/134694: gives false-positive when unable to obtain socket [WAS: sshd(8) - alert user when fails to execute from rc.d] Date: Wed, 20 May 2009 10:38:18 -0400 Hi, Eygene On Wed, May 20, 2009 at 6:19 AM, Eygene Ryabinkin wr= ote: > Glen, good day. > > Mon, May 18, 2009 at 10:49:52PM -0400, Glen Barber wrote: >> Earlier this evening, I submitted a PR about sshd(8) giving a >> false-positive when starting on an already occupied socket[1]. =A0I >> would like to enable some form of console output when the rc.d script >> is called if the service cannot properly bind to the socket, but I >> want to make sure I do it "the right way." > > Reading through the PR, I can't figure out what do you mean. > You're saying that > =A01. you spawn the other service on a port N; > =A02. then you're spawning SSH on the same port via rc.d script; > =A03. after this '/etc/rc.d/sshd status' gives you 'sshd is not running'. > > But this is completely right: after step 2 there will be no SSH daemon > listening, because it fails to bind to the port. =A0And the 'status' > command of an rc.d script is perfectly correct -- no SSH daemon is > running, really. > That is correct. There is no daemon running, but there is no output on the console that starting sshd failed -- it is only listed in messages. (And if you don't know it failed, you may never look in messages to realize this.) >> I was digging through src/crypto/openssh/sshd.c hoping to submit a >> patch to enable this, but I'm not certain that is the right place to >> be looking. =A0After digging through erc/etc/rc.d/sshd, I am failing to >> understand how the service would check the listening port, so now I >> feel like I am hitting a wall. > > You seem to mix two things: binding to the port and the output from rc.d > 'status' command. =A0Binding to the port is done by SSH by the bind(2) > system call and if something is already listening on the given address, > the socket won't be bound, so SSH daemon terminates. > > 'status' (for the case of /etc/rc.d/sshd) deduces the status of the > service from it's pid file (variable pidfile) with the subroutine > check_pidfile. =A0Look at /etc/rc.subr: 'status' is handled via > "run_rc_command status" that evaluates _pidcmd that sets $rc_pid. =A0And > then $rc_pid it checked for being non-empty, and if emptiness found, > command > ----- > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0echo "${na= me} is not running." > ----- > is executed. =A0It produces the result you're seeing. > > So, I would say that the PR in question is somewhat false positive. > -- > Eygene > =A0_ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0___ =A0 =A0 =A0 _.--. =A0 # > =A0\`.|\..----...-'` =A0 `-._.-'_.-'` =A0 # =A0Remember that it is hard > =A0/ =A0' ` =A0 =A0 =A0 =A0 , =A0 =A0 =A0 __.--' =A0 =A0 =A0# =A0to read = the on-line manual > =A0)/' _/ =A0 =A0 \ =A0 `-_, =A0 / =A0 =A0 =A0 =A0 =A0 =A0# =A0while sing= le-stepping the kernel. > =A0`-'" `"\_ =A0,_.-;_.-\_ ', =A0fsc/as =A0 # > =A0 =A0 _.-'_./ =A0 {_.' =A0 ; / =A0 =A0 =A0 =A0 =A0 # =A0 =A0-- FreeBSD = Developers handbook > =A0 =A0{_.-``-' =A0 =A0 =A0 =A0 {_/ =A0 =A0 =A0 =A0 =A0 =A0# > --=20 Glen Barber