Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2020 11:31:46 +0200
From:      David Marec <david.marec@davenulle.org>
To:        freebsd-stable@freebsd.org
Subject:   What was the intention about "jail -e" in the first place ?
Message-ID:  <158a9402-eac6-90ed-7931-3477f1374c3e@davenulle.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------E1354458253F9E35C3C68FF2
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

The manpage and usage output doesn't match.

The manpage tells us that this option should be used alone on the 
command line, as any other command will be discarded.

The usage ouput does not mention the "-r" flag but "cmr" (with a typo).

Both suggest that the user can request information about one single 
jail, or all the jails using a wildcard or no other argument.

Well, looking at the code, it sounds that the only way to make it work 
is to use it alone on the command line, and their is no way get 
information about a single jail.

Attached is a short patch to get information about one single jail or 
all jails (wildcards or empty).


But,how was "jail -e" intending to be used, actually ?


-- 
David Marec
https://lapinbilly.eu/

--------------E1354458253F9E35C3C68FF2
Content-Type: text/x-patch; charset=UTF-8;
 name="jail.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="jail.patch"

Index: jail.c
===================================================================
--- jail.c	(revision 359745)
+++ jail.c	(working copy)
@@ -282,16 +282,12 @@
 					    ? NULL : "false");
 			}
 		}
-	} else if (op == JF_STOP || op == JF_SHOW) {
-		/* Just print list of all configured non-wildcard jails */
-		if (op == JF_SHOW) {
-			load_config();
-			show_jails();
-			exit(0);
-		}
+	} else if (op == JF_STOP ) {
+
 		/* Jail remove, perhaps using the config file */
 		if (!docf || argc == 0)
 			usage();
+
 		if (!Rflag)
 			for (i = 0; i < argc; i++)
 				if (strchr(argv[i], '='))
@@ -300,6 +296,17 @@
 		     (!strcmp(cfname, "-") || stat(cfname, &st) == 0)))
 			load_config();
 		note_remove = docf || argc > 1 || wild_jail_name(argv[0]);
+	} else if(op == JF_SHOW) {
+		/* Just print list of all configured non-wildcard jails */
+		if (op == JF_SHOW && (argc==0|| wild_jail_name(argv[0]))) {
+			load_config();
+			show_jails();
+			exit(0);
+		}
+
+		if(argc>1)
+			usage();
+		load_config();
 	} else if (argc > 1 || (argc == 1 && strchr(argv[0], '='))) {
 		/* Single jail specified on the command line */
 		if (Rflag)
@@ -474,6 +481,9 @@
 			dep_done(j, 0);
 			break;
 
+		case JF_SHOW:
+			print_jail(stdout, j, 0, 0);
+			break;
 		case JF_STOP:
 		case JF_RESTART:
 			if (j->comparam == NULL) {
@@ -1040,8 +1050,8 @@
 	(void)fprintf(stderr,
 	    "usage: jail [-dhilqv] [-J jid_file] [-u username] [-U username]\n"
 	    "            -[cmr] param=value ... [command=command ...]\n"
-	    "       jail [-dqv] [-f file] [-e separator] -[cmr] [jail]\n"
-	    "       jail [-qv] [-f file] -[rR] ['*' | jail ...]\n"
+	    "       jail [-dqv] [-f file] [-e separator] [-cmr] [jail]\n"
+	    "       jail [-qv] [-f file] [-rR] ['*' | jail ...]\n"
 	    "       jail [-dhilqv] [-J jid_file] [-u username] [-U username]\n"
 	    "            [-n jailname] [-s securelevel]\n"
 	    "            path hostname [ip[,...]] command ...\n");
Index: jailp.h
===================================================================
--- jailp.h	(revision 359745)
+++ jailp.h	(working copy)
@@ -69,7 +69,7 @@
 #define JF_FROM_RUNQ	0x0800	/* Has already been on the run queue */
 #define JF_SHOW		0x1000	/* -e Exhibit list of configured jails */
 
-#define JF_OP_MASK		(JF_START | JF_SET | JF_STOP)
+#define JF_OP_MASK		(JF_START | JF_SET | JF_STOP | JF_SHOW)
 #define JF_RESTART		(JF_START | JF_STOP)
 #define JF_START_SET		(JF_START | JF_SET)
 #define JF_SET_RESTART		(JF_SET | JF_STOP)

--------------E1354458253F9E35C3C68FF2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?158a9402-eac6-90ed-7931-3477f1374c3e>