bootparamd doesn't allow parameters?

Brian J. McGovern mcgovern at beta.com
Fri Aug 19 13:58:38 GMT 2005


Dan,
	Thanks. I'm out of the office today, but I'll give it a spin Monday
and report.

	-brian
 > 
 > --NzB8fVQJ5HfG6fxh
 > Content-Type: text/plain; charset=us-ascii
 > Content-Disposition: inline
 > 
 > In the last episode (Aug 18), Brian J. McGovern said:
 > > 	I'm in the process of trying to set up a Solaris jumpstart
 > > server in a lab, and I decided for chuckles to do it with FreeBSD.
 > > 
 > > 	The problem I'm running in to is that apparently, the Sun bootparamd
 > > allows you to pass parameters as fields, for instance, as a couple of
 > > sample fields out of the Solaris-generated /etc/bootparams (note:
 > > entry is clearly not complete, but I didn't want to distract)....
 > > 
 > > 	testserver	rootopts=:rsize=32768 term=:vt100
 > > 
 > > 	However, if I move this directly in to FreeBSD's /etc/bootparams, it
 > > will complain that it can not answer the request for "rootopts" from
 > > the Sun box.
 > > 
 > > 	Is there something I'm missing? the man page seems to allude to
 > > the fact that all entries should be in the format of
 > > <host>:</path/to/file>. Or, am I going to have to look at finding
 > > another bootparamd than the stock one?
 > 
 > The code silently fails if any host field doesn't resolve to a valid IP
 > address.  Try the attached diff, which lets your example line work for
 > me.
 >  
 > -- 
 > 	Dan Nelson
 > 	dnelson at allantgroup.com
 > 
 > --NzB8fVQJ5HfG6fxh
 > Content-Type: text/plain; charset=us-ascii
 > Content-Disposition: attachment; filename="bootparamd.diff"
 > 
 > Index: bootparamd.c
 > ===================================================================
 > RCS file: /home/ncvs/src/usr.sbin/bootparamd/bootparamd/bootparamd.c,v
 > retrieving revision 1.11.4.1
 > diff -u -p -r1.11.4.1 bootparamd.c
 > --- bootparamd.c	28 Nov 2004 14:10:19 -0000	1.11.4.1
 > +++ bootparamd.c	19 Aug 2005 03:20:23 -0000
 > @@ -114,7 +114,7 @@ bp_getfile_res *
 >  bp_getfile_arg *getfile;
 >  struct svc_req *req;
 >  {
 > -  char *where, *index();
 > +  char *where;
 >    static bp_getfile_res res;
 >  
 >    if (debug)
 > @@ -127,35 +127,47 @@ struct svc_req *req;
 >  
 >    he = NULL;
 >    he = gethostbyname(getfile->client_name);
 > -  if (! he ) goto failed;
 > +  if (! he ) {
 > +    if (debug) warnx("bad hostname %s", getfile->client_name);
 > +    goto failed;
 +  }
 >  
 >    strncpy(askname, he->h_name, sizeof(askname));
 >    askname[sizeof(askname)-1] = 0;
 >  
 >    if (getthefile(askname, getfile->file_id,buffer,sizeof(buffer))) {
 > +    if (debug) warnx("matched: %s",buffer);
 > +    res.server_name = "";
 > +    res.server_path = "";
 > +    res.server_address.address_type = IP_ADDR_TYPE;
 > +    bzero(&res.server_address.bp_address_u.ip_addr,4);
 > +
 >      if ( (where = index(buffer,':')) ) {
 >        /* buffer is re-written to contain the name of the info of file */
 >        strncpy(hostname, buffer, where - buffer);
 >        hostname[where - buffer] = '\0';
 >        where++;
 >        strcpy(path, where);
 > -      he = gethostbyname(hostname);
 > -      if ( !he ) goto failed;
 > -      bcopy( he->h_addr, &res.server_address.bp_address_u.ip_addr, 4);
 > -      res.server_name = hostname;
 >        res.server_path = path;
 > -      res.server_address.address_type = IP_ADDR_TYPE;
 > -    }
 > -    else { /* special for dump, answer with null strings */
 > -      if (!strcmp(getfile->file_id, "dump")) {
 > -	res.server_name = "";
 > -	res.server_path = "";
 > -        res.server_address.address_type = IP_ADDR_TYPE;
 > -	bzero(&res.server_address.bp_address_u.ip_addr,4);
 > -      } else goto failed;
 > +      if (hostname[0]) {
 > +        he = gethostbyname(hostname);
 > +        if ( !he ) {
 > +          if (debug) warnx("invalid hostname %s", hostname);
 > +          goto failed;
 > +        }
 > +        bcopy( he->h_addr, &res.server_address.bp_address_u.ip_addr, 4);
 > +        res.server_name = hostname;
 > +      }
 > +    } else { 
 > +      /* XXX allow "dump" keyword with no value.  Why? no idea. 
 > +         Fail otherwise. */
 > +      if (strcmp(getfile->file_id, "dump")) {
 > +        if (debug) warnx("invalid value for keyword %s", getfile->file_id);
 > +        goto failed;
 > +      }
 >      }
 >      if (debug)
 > -      fprintf(stderr, "returning server:%s path:%s address: %d.%d.%d.%d\n",
 > +      fprintf(stderr, "returning server:\"%s\" path:\"%s\" address: %d.%d.%
d.%d\n",
 >  	     res.server_name, res.server_path,
 >  	     255 &  res.server_address.bp_address_u.ip_addr.net,
 >  	     255 & res.server_address.bp_address_u.ip_addr.host,
 > 
 > --NzB8fVQJ5HfG6fxh--


More information about the freebsd-questions mailing list