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.
This commit is contained in:
Jamie Gritton 2012-05-28 20:44:11 +00:00
parent 687aeb3821
commit a6486f6008
3 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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);

View File

@ -227,6 +227,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;