bectl(8): Provide -u option to unset jail parameters
All but name, host.hostname, and path may be completely unset.
This commit is contained in:
parent
8983506f04
commit
b98d40579d
@ -40,7 +40,7 @@ destroy
|
||||
.Ao Ar beName | beName@snapshot Ac
|
||||
.Nm
|
||||
jail
|
||||
.Op Fl o Ar key Ns = Ns Ar value Oc Ns ...
|
||||
.Oo Fl o Ar key Ns = Ns Ar value | Fl u Ar key Oc Ns ...
|
||||
.Ao Ar jailID | jailName Ac
|
||||
.Ao Ar bootenv Ac
|
||||
.Nm
|
||||
@ -124,15 +124,32 @@ Specifying
|
||||
will automatically unmount without confirmation.
|
||||
.Pp
|
||||
.It Ic jail
|
||||
.Op Fl o Ar key Ns = Ns Ar value Oc Ns ...
|
||||
.Oo Fl o Ar key Ns = Ns Ar value | Fl u Ar key Oc Ns ...
|
||||
.Ao Ar jailID | jailName Ac
|
||||
.Ao Ar bootenv Ac
|
||||
.Pp
|
||||
Creates a jail of the given boot environment.
|
||||
Multiple
|
||||
.Fl o
|
||||
and
|
||||
.Fl u
|
||||
arguments may be specified.
|
||||
Al
|
||||
.Fl o
|
||||
will set a jail parameter, and
|
||||
.Fl u
|
||||
will unset a jail parameter.
|
||||
.Pp
|
||||
The
|
||||
.Va name ,
|
||||
.Va host.hostname ,
|
||||
and
|
||||
.Va path
|
||||
may not actually be unset.
|
||||
Attempts to unset any of these will revert them to the default values specified
|
||||
below, if they have been overwritten by
|
||||
.Fl o .
|
||||
.Pp
|
||||
All
|
||||
.Ar key ,
|
||||
.Ar value
|
||||
pairs are interpreted as jail parameters as described in
|
||||
@ -148,9 +165,8 @@ The following default parameters are provided:
|
||||
Set to a path in /tmp generated by
|
||||
.Xr libbe 8 .
|
||||
.El
|
||||
.pp
|
||||
All default parameters may be overwritten.
|
||||
.Pp
|
||||
All default parameters may be overwritten.
|
||||
.It Ic list
|
||||
.Op Fl a
|
||||
.Op Fl D
|
||||
|
@ -70,7 +70,7 @@ usage(bool explicit)
|
||||
"\tbectl export sourceBe\n"
|
||||
"\tbectl import targetBe\n"
|
||||
"\tbectl add (path)*\n"
|
||||
"\tbectl jail [ -o key=value ]... bootenv\n"
|
||||
"\tbectl jail [ -o key=value | -u key ]... bootenv\n"
|
||||
"\tbectl list [-a] [-D] [-H] [-s]\n"
|
||||
"\tbectl mount beName [mountpoint]\n"
|
||||
"\tbectl rename origBeName newBeName\n"
|
||||
|
@ -43,7 +43,9 @@
|
||||
|
||||
static void jailparam_grow(void);
|
||||
static void jailparam_add(const char *name, const char *val);
|
||||
static void jailparam_del(const char *name);
|
||||
static bool jailparam_addarg(char *arg);
|
||||
static bool jailparam_delarg(char *arg);
|
||||
|
||||
static int bectl_search_jail_paths(const char *mnt);
|
||||
static int bectl_locate_jail(const char *ident);
|
||||
@ -89,6 +91,34 @@ jailparam_add(const char *name, const char *val)
|
||||
++jpused;
|
||||
}
|
||||
|
||||
static void
|
||||
jailparam_del(const char *name)
|
||||
{
|
||||
int i;
|
||||
char *val;
|
||||
|
||||
for (i = 0; i < jpused; ++i) {
|
||||
if (strcmp(name, jp[i].jp_name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Not found... technically successful */
|
||||
if (i == jpused)
|
||||
return;
|
||||
|
||||
for (; i < jpused - 1; ++i) {
|
||||
val = jailparam_export(&jp[i + 1]);
|
||||
|
||||
jailparam_free(&jp[i], 1);
|
||||
jailparam_init(&jp[i], jp[i + 1].jp_name);
|
||||
jailparam_import(&jp[i], val);
|
||||
free(val);
|
||||
}
|
||||
|
||||
jailparam_free(&jp[i], 1);
|
||||
--jpused;
|
||||
}
|
||||
|
||||
static bool
|
||||
jailparam_addarg(char *arg)
|
||||
{
|
||||
@ -117,6 +147,23 @@ jailparam_addarg(char *arg)
|
||||
return (true);
|
||||
}
|
||||
|
||||
static bool
|
||||
jailparam_delarg(char *arg)
|
||||
{
|
||||
char *name, *val;
|
||||
|
||||
if (arg == NULL)
|
||||
return (false);
|
||||
name = arg;
|
||||
if ((val = strchr(name, '=')) != NULL)
|
||||
*val++ = '\0';
|
||||
|
||||
if (strcmp(name, "path") == 0)
|
||||
*mnt_loc = '\0';
|
||||
jailparam_del(name);
|
||||
return (true);
|
||||
}
|
||||
|
||||
int
|
||||
bectl_cmd_jail(int argc, char *argv[])
|
||||
{
|
||||
@ -135,7 +182,7 @@ bectl_cmd_jail(int argc, char *argv[])
|
||||
jailparam_add("allow.mount.devfs", "true");
|
||||
jailparam_add("enforce_statfs", "1");
|
||||
|
||||
while ((opt = getopt(argc, argv, "o:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "o:u:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
if (jailparam_addarg(optarg)) {
|
||||
@ -149,6 +196,14 @@ bectl_cmd_jail(int argc, char *argv[])
|
||||
default_hostname = false;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
if (jailparam_delarg(optarg)) {
|
||||
if (strcmp(optarg, "name") == 0)
|
||||
default_name = true;
|
||||
if (strcmp(optarg, "host.hostname") == 0)
|
||||
default_hostname = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bectl jail: unknown option '-%c'\n",
|
||||
optopt);
|
||||
|
Loading…
Reference in New Issue
Block a user