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 2012-05-28 20:44:11 +00:00
parent a2b635f68f
commit 5ddbe53eac
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. * Run a single command for a jail, possible inside the jail.
*/ */
int static int
run_command(struct cfjail *j) run_command(struct cfjail *j)
{ {
const struct passwd *pwd; const struct passwd *pwd;
@ -290,6 +290,8 @@ run_command(struct cfjail *j)
} else { } else {
if (create_jail(j) < 0) if (create_jail(j) < 0)
return -1; return -1;
if (iflag)
printf("%d\n", j->jid);
if (verbose >= 0 && (j->name || verbose > 0)) if (verbose >= 0 && (j->name || verbose > 0))
jail_note(j, "created\n"); jail_note(j, "created\n");
dep_done(j, DF_LIGHT); dep_done(j, DF_LIGHT);

View File

@ -55,6 +55,7 @@ struct permspec {
}; };
const char *cfname; const char *cfname;
int iflag;
int note_remove; int note_remove;
int verbose; int verbose;
@ -129,7 +130,7 @@ main(int argc, char **argv)
size_t sysvallen; size_t sysvallen;
unsigned op, pi; unsigned op, pi;
int ch, docf, error, i, oldcl, sysval; int ch, docf, error, i, oldcl, sysval;
int dflag, iflag, Rflag; int dflag, Rflag;
char enforce_statfs[4]; char enforce_statfs[4];
#if defined(INET) || defined(INET6) #if defined(INET) || defined(INET6)
char *cs, *ncs; char *cs, *ncs;
@ -139,7 +140,7 @@ main(int argc, char **argv)
#endif #endif
op = 0; op = 0;
dflag = iflag = Rflag = 0; dflag = Rflag = 0;
docf = 1; docf = 1;
cfname = CONF_FILE; cfname = CONF_FILE;
JidFile = NULL; JidFile = NULL;
@ -415,8 +416,6 @@ main(int argc, char **argv)
continue; continue;
jail_create_done: jail_create_done:
clear_persist(j); clear_persist(j);
if (iflag)
printf("%d\n", j->jid);
if (jfp != NULL) if (jfp != NULL)
print_jail(jfp, j, oldcl); print_jail(jfp, j, oldcl);
dep_done(j, 0); dep_done(j, 0);

View File

@ -227,6 +227,7 @@ extern struct cfjails cfjails;
extern struct cfjails ready; extern struct cfjails ready;
extern struct cfjails depend; extern struct cfjails depend;
extern const char *cfname; extern const char *cfname;
extern int iflag;
extern int note_remove; extern int note_remove;
extern int paralimit; extern int paralimit;
extern int verbose; extern int verbose;