Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Apr 1997 10:28:33 +1000
From:      David Nugent <davidn@unique.usn.blaze.net.au>
To:        "Jordan K. Hubbard" <jkh@time.cdrom.com>
Cc:        hackers@freebsd.org
Subject:   Re: /etc/netstart bogons.. 
Message-ID:  <199704240028.KAA21258@unique.usn.blaze.net.au>
In-Reply-To: Your message of "Wed, 23 Apr 1997 11:05:56 MST." <2911.861818756@time.cdrom.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> In /etc/netstart (and elsewhere) we have constructs of the form:
[.. deletia ..]

> And so on.  This is, needless to say, DEEPLY DEEPLY EVIL since it will
> cause these features to be turned on in the _absence_ of any such flag
> setting, say because you have an old /etc/sysconfig file.

Yes, exactly this has happened to me a few times, when I've either
forgotten to update sysconfig or accidently missed an addition.


> Any objection to reversing the polarity on these various ifs?  If
> there's no variable or it's not explicitly set to YES, the operation
> should fail.  Speak now or hold your peace, please..

The problem is that it isn't always a "YES" that the variable is
set to. A test for an empty variable should, however, be made the
equivalent of "NO". That isn't always the case, though, but for
consistency's sake, it SHOULD always be like that. The question is,
how do you allow for an empty variable? Separate the test and its
use, of course.

BTW, since our /bin/sh groks functions, why aren't these blocks a
function? Something along the lines of:

conditional_run() {
  var=$1
  prog=$2
  show=$3
  # Allow two args
  if [ "x$show" = "x" ]; then
    show=$prog
  fi
  tvar="x$var"
  if [ "$tvar" != "x" -a "$tvar" != "xNO" ]; then
    echo -n " $show";
    eval $prog
  fi
}

[Of course, this is only an example - I have not thoroughly tested it ;-)]

Then:

conditional_run "$nisflags" "ypserv"
conditional_run "$tcp_extensions" \
		"sysctl -w net.inet.tcp.rfc1323=0;\
		 sysctl -w net.inet.tcp.rfc1644=0" \
		""
conditional_run "$gateway" \
		"sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1" \
		"configuring host as a gateway."
conditional_run "$router" \
		"${router} ${routerflags}" \
		"starting routing daemon: ${router}"

and so on. This makes /etc/{rc*,netstart} a hell of a lot more
configurable.

OF course, some of these blocks also test for the existence of a 
file, but that could be done easily too, either by extending the
above function or adding another similar one. For complex blocks
of code, define another function and pass the function name as
the 'prog'.


Regards,

David Nugent - Unique Computing Pty Ltd - Melbourne, Australia
Voice +61-3-9791-9547  Data/BBS +61-3-9792-3507  3:632/348@fidonet
davidn@freebsd.org davidn@blaze.net.au http://www.blaze.net.au/~davidn/




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