Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Dec 2001 10:40:01 -0800 (PST)
From:      Evan Sarmiento <evms@cs.bu.edu>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/32680: [PATCH] Allows users to start jails by hostname as well as IP address
Message-ID:  <200112131840.fBDIe1u40426@freefall.freebsd.org>

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

From: Evan Sarmiento <evms@cs.bu.edu>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: misc/32680: [PATCH] Allows users to start jails by hostname as well as IP address
Date: Thu, 13 Dec 2001 13:32:49 -0500 (EST)

 Finally, I fixed it, and it should all be fine now:
 
 --- jail.c	Thu Dec 13 11:24:04 2001
 +++ jail.new	Thu Dec 13 11:25:43 2001
 @@ -17,20 +17,20 @@
  #include <arpa/inet.h>
  
  #include <err.h>
 -#include <stdio.h>
 +#include <netdb.h>
  #include <stdlib.h>
 -#include <string.h>
  #include <unistd.h>
  
  int
  main(int argc, char **argv)
  {
 +	struct hostent *hp;
  	struct jail j;
  	int i;
  	struct in_addr in;
  
  	if (argc < 5) 
 -		errx(1, "Usage: %s path hostname ip-number command ...\n",
 +		errx(1, "Usage: %s path hostname address command ...\n",
  		    argv[0]);
  	i = chdir(argv[1]);
  	if (i)
 @@ -40,8 +40,18 @@
  	j.path = argv[1];
  	j.hostname = argv[2];
  	i = inet_aton(argv[3], &in);
 -	if (!i)
 -		errx(1, "Couldn't make sense of ip-number\n");
 +
 +	if (i == NULL) {
 +	        hp = gethostbyname(argv[3]);
 +
 +	        if (hp == NULL)
 +	            errx(1, "gethostbyname(%s): %s (and) inet_aton(%s): Could not make sense of either IP number or hostname.",
 +                         argv[3], hstrerror(h_errno), argv[3] );
 +
 +	        else if (hp)
 +	                in = *(struct in_addr *)hp->h_addr;
 +        }
 +	
  	j.ip_number = ntohl(in.s_addr);
  	i = jail(&j);
  	if (i)
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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