Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/jail/jail.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#define JP_RDTUN(jp) (((jp)->jp_ctltype & CTLFLAG_RDTUN) == CTLFLAG_RDTUN) | #define JP_RDTUN(jp) (((jp)->jp_ctltype & CTLFLAG_RDTUN) == CTLFLAG_RDTUN) | ||||
struct permspec { | struct permspec { | ||||
const char *name; | const char *name; | ||||
enum intparam ipnum; | enum intparam ipnum; | ||||
int rev; | int rev; | ||||
}; | }; | ||||
const char *cfname; | |||||
int iflag; | int iflag; | ||||
int note_remove; | int note_remove; | ||||
int verbose; | int verbose; | ||||
const char *separator = "\t"; | const char *separator = "\t"; | ||||
static void clear_persist(struct cfjail *j); | static void clear_persist(struct cfjail *j); | ||||
static int update_jail(struct cfjail *j); | static int update_jail(struct cfjail *j); | ||||
static int rdtun_params(struct cfjail *j, int dofail); | static int rdtun_params(struct cfjail *j, int dofail); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
int | int | ||||
main(int argc, char **argv) | main(int argc, char **argv) | ||||
{ | { | ||||
struct stat st; | struct stat st; | ||||
FILE *jfp; | FILE *jfp; | ||||
struct cfjail *j; | struct cfjail *j; | ||||
const char *cfname; | |||||
char *JidFile; | char *JidFile; | ||||
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, Rflag; | int dflag, Rflag; | ||||
#if defined(INET) || defined(INET6) | #if defined(INET) || defined(INET6) | ||||
char *cs, *ncs; | char *cs, *ncs; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | if (sysctlbyname("security.jail.jailed", &sysval, &sysvallen, | ||||
(sysval ? 1 : 0) ^ | (sysval ? 1 : 0) ^ | ||||
perm_sysctl[pi].rev | perm_sysctl[pi].rev | ||||
? NULL : "false"); | ? NULL : "false"); | ||||
} | } | ||||
} | } | ||||
} else if (op == JF_STOP || op == JF_SHOW) { | } else if (op == JF_STOP || op == JF_SHOW) { | ||||
/* Just print list of all configured non-wildcard jails */ | /* Just print list of all configured non-wildcard jails */ | ||||
if (op == JF_SHOW) { | if (op == JF_SHOW) { | ||||
load_config(); | load_config(cfname); | ||||
show_jails(); | show_jails(); | ||||
exit(0); | exit(0); | ||||
} | } | ||||
/* Jail remove, perhaps using the config file */ | /* Jail remove, perhaps using the config file */ | ||||
if (!docf || argc == 0) | if (!docf || argc == 0) | ||||
usage(); | usage(); | ||||
if (!Rflag) | if (!Rflag) | ||||
for (i = 0; i < argc; i++) | for (i = 0; i < argc; i++) | ||||
if (strchr(argv[i], '=')) | if (strchr(argv[i], '=')) | ||||
usage(); | usage(); | ||||
if ((docf = !Rflag && | if ((docf = !Rflag && | ||||
(!strcmp(cfname, "-") || stat(cfname, &st) == 0))) | (!strcmp(cfname, "-") || stat(cfname, &st) == 0))) | ||||
load_config(); | load_config(cfname); | ||||
note_remove = docf || argc > 1 || wild_jail_name(argv[0]); | note_remove = docf || argc > 1 || wild_jail_name(argv[0]); | ||||
} else if (argc > 1 || (argc == 1 && strchr(argv[0], '='))) { | } else if (argc > 1 || (argc == 1 && strchr(argv[0], '='))) { | ||||
/* Single jail specified on the command line */ | /* Single jail specified on the command line */ | ||||
if (Rflag) | if (Rflag) | ||||
usage(); | usage(); | ||||
docf = 0; | docf = 0; | ||||
for (i = 0; i < argc; i++) { | for (i = 0; i < argc; i++) { | ||||
if (!strncmp(argv[i], "command", 7) && | if (!strncmp(argv[i], "command", 7) && | ||||
Show All 31 Lines | |||||
#endif | #endif | ||||
else | else | ||||
add_param(NULL, NULL, 0, argv[i]); | add_param(NULL, NULL, 0, argv[i]); | ||||
} | } | ||||
} else { | } else { | ||||
/* From the config file, perhaps with a specified jail */ | /* From the config file, perhaps with a specified jail */ | ||||
if (Rflag || !docf) | if (Rflag || !docf) | ||||
usage(); | usage(); | ||||
load_config(); | load_config(cfname); | ||||
} | } | ||||
/* Find out which jails will be run. */ | /* Find out which jails will be run. */ | ||||
dep_setup(docf); | dep_setup(docf); | ||||
error = 0; | error = 0; | ||||
if (op == JF_STOP) { | if (op == JF_STOP) { | ||||
for (i = 0; i < argc; i++) | for (i = 0; i < argc; i++) | ||||
if (start_state(argv[i], docf, op, Rflag) < 0) | if (start_state(argv[i], docf, op, Rflag) < 0) | ||||
▲ Show 20 Lines • Show All 705 Lines • Show Last 20 Lines |