From owner-freebsd-bugs Thu Dec 13 4: 0:11 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C4F4637B41B for ; Thu, 13 Dec 2001 04:00:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id fBDC03h34034; Thu, 13 Dec 2001 04:00:03 -0800 (PST) (envelope-from gnats) Date: Thu, 13 Dec 2001 04:00:03 -0800 (PST) Message-Id: <200112131200.fBDC03h34034@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Evan Sarmiento Subject: Re: misc/32680: [PATCH] Allows users to start jails by hostname as well as IP address Reply-To: Evan Sarmiento Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/32680; it has been noted by GNATS. From: Evan Sarmiento To: Will Andrews , FreeBSD GNATS DB Cc: Subject: Re: misc/32680: [PATCH] Allows users to start jails by hostname as well as IP address Date: Thu, 13 Dec 2001 06:55:44 -0500 (EST) Hello, Attached is the new, stylized (9) jail.c patch: --- jail.c Thu Dec 13 06:50:45 2001 +++ jail.new Thu Dec 13 06:52:24 2001 @@ -17,20 +17,20 @@ #include #include -#include +#include #include -#include #include 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,12 +40,22 @@ 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) - err(1, "Imprisonment failed"); + err(1, "Imprisonment failed"); i = execv(argv[4], argv + 4); if (i) err(1, "execv(%s)", argv[4]); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message