Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Dec 2001 14:02:42 -0500 (EST)
From:      Evan Sarmiento <evms@cs.bu.edu>
To:        freebsd-hackers@freebsd.org
Subject:   jail.c patch (fixed)
Message-ID:  <200112101902.fBAJ2gS23874@csa.bu.edu>

next in thread | raw e-mail | index | archive | help
Hey guys.

heh. Sorry about that, I just fixed it and it all works fine. :-) Exams are
making my brain fry.

Here is the revised patch.

Thanks,
- Evan

--- jail.c	Mon Jul 30 06:19:54 2001
+++ jail.mod	Mon Dec 10 14:00:57 2001
@@ -10,9 +10,8 @@
  * 
  */
 
-#include <stdio.h>
+#include <netdb.h>
 #include <stdlib.h>
-#include <string.h>
 #include <err.h>
 #include <sys/types.h>
 #include <sys/jail.h>
@@ -21,12 +20,13 @@
 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)
@@ -36,14 +36,26 @@
 	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) {
+	  hp = gethostbyname(argv[3]);
+
+	  if (hp == NULL)
+	   errx(1, "gethostbyname(%s): %s (and) inet_aton(%s): Could not
+           make sense of ip-number", 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]);
+	  err(1, "execv(%s)", argv[4]);
+
 	exit (0);
 }

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




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