From owner-freebsd-stable@freebsd.org Thu Apr 16 09:31:51 2020 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93C6B2B7B58 for ; Thu, 16 Apr 2020 09:31:51 +0000 (UTC) (envelope-from david.marec@davenulle.org) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 492vBG3v9Bz4G6h for ; Thu, 16 Apr 2020 09:31:50 +0000 (UTC) (envelope-from david.marec@davenulle.org) X-Originating-IP: 86.201.44.116 Received: from llanura.davidmarec.ddns.net (lfbn-tou-1-196-116.w86-201.abo.wanadoo.fr [86.201.44.116]) (Authenticated sender: david@dmarec.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id CCC9FFF811 for ; Thu, 16 Apr 2020 09:31:46 +0000 (UTC) To: freebsd-stable@freebsd.org From: David Marec Subject: What was the intention about "jail -e" in the first place ? Message-ID: <158a9402-eac6-90ed-7931-3477f1374c3e@davenulle.org> Date: Thu, 16 Apr 2020 11:31:46 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E1354458253F9E35C3C68FF2" Content-Language: en-US X-Rspamd-Queue-Id: 492vBG3v9Bz4G6h X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of david.marec@davenulle.org has no SPF policy when checking 217.70.183.199) smtp.mailfrom=david.marec@davenulle.org X-Spamd-Result: default: False [-1.31 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_XOIP(0.00)[]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[116.44.201.86.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; IP_SCORE(-1.35)[ip: (-3.91), ipnet: 217.70.176.0/20(-1.56), asn: 29169(-1.26), country: FR(0.00)]; R_DKIM_NA(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[199.183.70.217.list.dnswl.org : 127.0.5.1]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:29169, ipnet:217.70.176.0/20, country:FR]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.94)[-0.943,0]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.82)[-0.823,0]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-stable@freebsd.org]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+,1:+,2:~]; DMARC_NA(0.00)[davenulle.org]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2020 09:31:51 -0000 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--