svn commit: r236356 - stable/9/usr.sbin/jail

Jamie Gritton jamie at FreeBSD.org
Thu May 31 14:18:20 UTC 2012


Author: jamie
Date: Thu May 31 14:18:19 2012
New Revision: 236356
URL: http://svn.freebsd.org/changeset/base/236356

Log:
  MFC r235949, r236198:
  
     Don't try to set a null TERM environment.
  
     When writing the jid via the -i flag, do it right when the jail is created,
     before any commands run.  /etc/rc.d/jail depends on this.

Modified:
  stable/9/usr.sbin/jail/command.c
  stable/9/usr.sbin/jail/jail.c
  stable/9/usr.sbin/jail/jailp.h
Directory Properties:
  stable/9/usr.sbin/jail/   (props changed)

Modified: stable/9/usr.sbin/jail/command.c
==============================================================================
--- stable/9/usr.sbin/jail/command.c	Thu May 31 08:22:02 2012	(r236355)
+++ stable/9/usr.sbin/jail/command.c	Thu May 31 14:18:19 2012	(r236356)
@@ -246,7 +246,7 @@ next_proc(int nonblock)
 /*
  * Run a single command for a jail, possible inside the jail.
  */
-int
+static int
 run_command(struct cfjail *j)
 {
 	const struct passwd *pwd;
@@ -290,6 +290,8 @@ run_command(struct cfjail *j)
 		} else {
 			if (create_jail(j) < 0)
 				return -1;
+			if (iflag)
+				printf("%d\n", j->jid);
 			if (verbose >= 0 && (j->name || verbose > 0))
 				jail_note(j, "created\n");
 			dep_done(j, DF_LIGHT);
@@ -584,7 +586,8 @@ run_command(struct cfjail *j)
 			term = getenv("TERM");
 			environ = &cleanenv;
 			setenv("PATH", "/bin:/usr/bin", 0);
-			setenv("TERM", term, 1);
+			if (term != NULL)
+				setenv("TERM", term, 1);
 		}
 		if (setusercontext(lcap, pwd, pwd->pw_uid, username
 		    ? LOGIN_SETALL & ~LOGIN_SETGROUP & ~LOGIN_SETLOGIN

Modified: stable/9/usr.sbin/jail/jail.c
==============================================================================
--- stable/9/usr.sbin/jail/jail.c	Thu May 31 08:22:02 2012	(r236355)
+++ stable/9/usr.sbin/jail/jail.c	Thu May 31 14:18:19 2012	(r236356)
@@ -55,6 +55,7 @@ struct permspec {
 };
 
 const char *cfname;
+int iflag;
 int note_remove;
 int verbose;
 
@@ -129,7 +130,7 @@ main(int argc, char **argv)
 	size_t sysvallen;
 	unsigned op, pi;
 	int ch, docf, error, i, oldcl, sysval;
-	int dflag, iflag, Rflag;
+	int dflag, Rflag;
 	char enforce_statfs[4];
 #if defined(INET) || defined(INET6)
 	char *cs, *ncs;
@@ -139,7 +140,7 @@ main(int argc, char **argv)
 #endif
 
 	op = 0;
-	dflag = iflag = Rflag = 0;
+	dflag = Rflag = 0;
 	docf = 1;
 	cfname = CONF_FILE;
 	JidFile = NULL;
@@ -415,8 +416,6 @@ main(int argc, char **argv)
 				continue;
 		jail_create_done:
 			clear_persist(j);
-			if (iflag)
-				printf("%d\n", j->jid);
 			if (jfp != NULL)
 				print_jail(jfp, j, oldcl);
 			dep_done(j, 0);

Modified: stable/9/usr.sbin/jail/jailp.h
==============================================================================
--- stable/9/usr.sbin/jail/jailp.h	Thu May 31 08:22:02 2012	(r236355)
+++ stable/9/usr.sbin/jail/jailp.h	Thu May 31 14:18:19 2012	(r236356)
@@ -228,6 +228,7 @@ extern struct cfjails cfjails;
 extern struct cfjails ready;
 extern struct cfjails depend;
 extern const char *cfname;
+extern int iflag;
 extern int note_remove;
 extern int paralimit;
 extern int verbose;


More information about the svn-src-stable-9 mailing list