Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jun 2006 23:00:43 GMT
From:      Rostislav Krasny <rosti.bsd@gmail.com>
To:        freebsd-rc@FreeBSD.org
Subject:   Re: conf/94377 : [patch] /etc/rc.d/sshd improperly tests random dev state
Message-ID:  <200606082300.k58N0hv8075410@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/94377; it has been noted by GNATS.

From: Rostislav Krasny <rosti.bsd@gmail.com>
To: Doug White <dwhite@gumbysoft.com>
Cc: Florent Thoumie <flz@FreeBSD.org>, bug-followup@FreeBSD.org
Subject: Re: conf/94377 : [patch] /etc/rc.d/sshd improperly tests random dev
 state
Date: Thu, 8 Jun 2006 22:03:58 +0300

 On Thu, 8 Jun 2006 10:36:05 -0700 (PDT)
 Doug White <dwhite@gumbysoft.com> wrote:
 
 > On Thu, 8 Jun 2006, Rostislav Krasny wrote:
 > 
 > > I've seen that patch just today, when it is already MFCed. I think it
 > > could be simpler. Instead of
 > >
 > > [ "x${seeded}" != "x" ] && [ ${seeded} -eq 0 ]
 > >
 > > you can write just
 > >
 > > [ "${seeded}" = "0" ]
 > >
 > > and it will be still correct against sysctl failing and returning an
 > > empty string.
 > 
 > No, because if ${seeded} is empty, the shell interprets the test as
 > 
 > [ = "0" ]
 > 
 > which results in a syntax error. The 'x' in the first test is significant.
 
 No, if ${seeded} is empty, the shell interprets the
 
 [ "${seeded}" = "0" ]
 
 as
 
 [ "" = "0" ]
 
 which has no syntax error because the ${seeded} is between the double
 quotes. Try following simple script to test it:
 
 #!/bin/sh
 
 seeded=`sysctl -n kern.random.sys.seededdd 2>/dev/null`
 echo ${seeded}
 
 if [ "${seeded}" = "0" ]
 then
         echo true
 else
         echo false
 fi
 
 The sysctl will fail because of a wrong variable name, but no syntax
 error will occur. If you remove the double quotes around the ${seeded}
 only then a syntaxt error will happen.
 
 If on CURRENT it works differently then most likely it has a bug
 in sh(1).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606082300.k58N0hv8075410>