From owner-freebsd-rc@FreeBSD.ORG Thu Jun 8 23:00:48 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D0E0D16A418 for ; Thu, 8 Jun 2006 23:00:48 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82FF343D72 for ; Thu, 8 Jun 2006 23:00:43 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k58N0hOW075411 for ; Thu, 8 Jun 2006 23:00:43 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k58N0hv8075410; Thu, 8 Jun 2006 23:00:43 GMT (envelope-from gnats) Date: Thu, 8 Jun 2006 23:00:43 GMT Message-Id: <200606082300.k58N0hv8075410@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Rostislav Krasny Cc: Subject: Re: conf/94377 : [patch] /etc/rc.d/sshd improperly tests random dev state X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Rostislav Krasny List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 23:00:48 -0000 The following reply was made to PR conf/94377; it has been noted by GNATS. From: Rostislav Krasny To: Doug White Cc: Florent Thoumie , 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 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).