Subject: Re: bin/282: sliplogin tells lies to ifconfig and ifconfig believes it!
To: Jonathan O'Brien <obrien@hulk.sfsu.edu>
From: Chris G. Demetriou <cgd@alpha.bostic.com>
List: netbsd-bugs
Date: 06/30/1994 03:51:23
>sliplogin will read in all of its args then pass the list out to slip.login.
>Problem is that the last few args aren't nulled out causing probs in ifconfig.
>
> Ex.
> For this slip.hosts:
> Smedusa	hulk		medusa		0xffff0000	metric 1
> This is passed to slip.login:
> /sbin/ifconfig sl0 inet hulk medusa netmask 0xffff0000 metric 1 00 01
> This is the output of ifconfig sl0:
> sl0: flags=d011<UP,POINTOPOINT,LINK0,LINK2,MULTICAST> metric 1
> 	inet 130.212.3.12 --> 0.0.0.1 netmask 0xffff0000 

actually, that's not the problem at all.  the problem exists entirely
in the slip.login script, and is caused my a "little oversight".

basically, $10 and $11 _aren't_ valid positional parameters, in sh.
there's no way to get to positional parameters after $9 in sh,
without using 'shift'.  therefore, $10 and $11 were being evaluated
into: ($1)0 and ($1)1, respectively.  (obviously, the parens are added
for human parsability...  8-)

since $1 was 0 (because the slip unit was 0), the resul was the 00 and
01 you saw...

> In my view this problem is twofold, sliplogin should null all its arg's, and
> ifconfig should not allow the bogus args at the end to hose it.

as noted, this _wasn't_ sliplogin's problem, but rather the default
slip.login shell script's problem.  also, ifconfig should _not_
ignore "bogus" args -- how do you define a "bogus argument?"
ifconfig should take what it's given, and do that appropriate thing
with it...

> >Fix:
> 	
> I fixed it by removing the extra unnecessary arg's in the slip.login. i.e. I
> nuked $10 and $11. This is not the proper fix.

Actually, that's a perfectly valid fix.  i went whole hog, though,
and now slip.login looks like:

#!/bin/sh -
#
#       $NetBSD: slip.login,v 1.3 1994/06/30 07:50:26 cgd Exp $
#       @(#)slip.login  5.1 (Berkeley) 7/1/90

#
# generic login file for a slip line.  sliplogin invokes this with
# the parameters:
#      1        2         3        4          5         6     7-n
#   slipunit ttyspeed loginname local-addr remote-addr mask opt-args
#
UNIT=$1
LOCALADDR=$4
REMOTEADDR=$5
NETMASK=$6
shift 6
OPTARGS=$*

/sbin/ifconfig sl${UNIT} inet ${LOCALADDR} ${REMOTEADDR} netmask ${NETMASK} \
    ${OPTARGS}
exit



chris

------------------------------------------------------------------------------