Bug 254741

Summary: jail(8) fails with "Usage" message when invocation is like it suggests
Product: Base System Reporter: Yuri Victorovich <yuri>
Component: binAssignee: Jamie Gritton <jamie>
Status: Closed FIXED    
Severity: Affects Only Me CC: jamie
Priority: ---    
Version: 12.2-STABLE   
Hardware: Any   
OS: Any   

Description Yuri Victorovich freebsd_committer freebsd_triage 2021-04-03 16:48:25 UTC
This command:
> # jail /disk/jail testjail /etc/rc
> usage: jail [-dhilqv] [-J jid_file] [-u username] [-U username]
>             -[cmr] param=value ... [command=command ...]
>        jail [-dqv] [-f file] -[cmr] [jail]
>        jail [-qv] [-f file] -[rR] ['*' | jail ...]
>        jail [-dhilqv] [-J jid_file] [-u username] [-U username]
>             [-n jailname] [-s securelevel]
>             path hostname [ip[,...]] command ...
>        jail [-f file] -e separator

fails with "Usage", but the invocation satisfies the 4th usage suggestion from the message:
>        jail [-dhilqv] [-J jid_file] [-u username] [-U username]
>             [-n jailname] [-s securelevel]
>             path hostname [ip[,...]] command ...
It is the same after removing optional elements.

So either the "Usage" message is wrong, or the problem is not in invocation but in something else.
Comment 1 Jamie Gritton freebsd_committer freebsd_triage 2021-04-04 17:48:25 UTC
The program is correct, and the problem is just in the usage message (also in the man page).  The "old-style" command line is four fixed arguments, with the non-optional IP address being one of them.  You can specify '' as the IP address, but there has to be an argument.

By the way, that will make a jail with no internet access at all; to make one without IP address restrictions, you'll need something like :

jail -c path=/disk/jail host.hostname=testjail ip4=inherit command=/etc/rc
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-04-04 17:53:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c1d956ffa0355ece3b63ea8587938176f87f072

commit 8c1d956ffa0355ece3b63ea8587938176f87f072
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2021-04-04 17:49:38 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2021-04-04 17:49:38 +0000

    jail: fix jail(8) synposis and usage message to match reality.

    Reported by:    yuri
    PR:             254741
    MFC after:      5 days

 usr.sbin/jail/jail.8 | 4 ++--
 usr.sbin/jail/jail.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-04-09 03:25:40 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6186592c106be2425dc4959c19c358c8ab86a307

commit 6186592c106be2425dc4959c19c358c8ab86a307
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2021-04-04 17:49:38 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2021-04-09 03:24:13 +0000

    MFC jail: fix jail(8) synposis and usage message to match reality.

    Reported by:    yuri
    PR:             254741

    (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072)

 usr.sbin/jail/jail.8 | 4 ++--
 usr.sbin/jail/jail.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-04-09 03:26:41 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=bdb392c1d3547097c5d08ab5ccfdef7235ea1190

commit bdb392c1d3547097c5d08ab5ccfdef7235ea1190
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2021-04-04 17:49:38 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2021-04-09 03:25:38 +0000

    MFC jail: fix jail(8) synposis and usage message to match reality.

    Reported by:    yuri
    PR:             254741
    MFC after:      5 days

    (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072)

 usr.sbin/jail/jail.8 | 4 ++--
 usr.sbin/jail/jail.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-04-09 03:27:42 UTC
A commit in branch stable/11 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=73b04801b3163417cff33b279f1bc42451f20009

commit 73b04801b3163417cff33b279f1bc42451f20009
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2021-04-04 17:49:38 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2021-04-09 03:26:58 +0000

    MFC jail: fix jail(8) synposis and usage message to match reality.

    Reported by:    yuri
    PR:             254741
    MFC after:      5 days

    (cherry picked from commit 8c1d956ffa0355ece3b63ea8587938176f87f072)

 usr.sbin/jail/jail.8 | 4 ++--
 usr.sbin/jail/jail.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)