https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295107

--- Comment #3 from Rusty Sears <[email protected]> ---
rc.subr is trying to prevent the same jail from being started twice, but the
check is broken and unnecessary.

It's just checking to see if anything else in the system is running the jail
CLI tool, so it fails because of unrelated jail operations (so it cannot be
used in automation -- jails randomly fail to start), and also doesn't notice if
the jail it is starting is already running (which is fine -- the check is
unnecessary here).

It's unlikely this check was intentionally added by the person that wrote the
script: 

 - It is implicit.
 - The manpage for rc.subr implies the check does not run.

The proposed solution is simple: Disable the broken check by telling it to look
for a nonsensical process name (":").  There are probably other ways to get the
correct behavior; I'm not sure what the most idiomatic approach is.

References:

rc.subr(8) documents `${name}_program` as having "no effect if command
is unset."  The jail script never sets `command` (it defines custom
`start_cmd`/`stop_cmd` instead), so per the documentation `jail_program`
should not affect process detection.

And a trace of the bug in rc.subr:

rc.subr line 1123:  eval _override_command=\$${name}_program
                    -> _override_command=/usr/sbin/jail
rc.subr line 1124:  command=${_override_command:-$command}
                    -> command=/usr/sbin/jail
rc.subr line 1129:  _procname=${procname:-${command}}
                    -> _procname=/usr/sbin/jail
rc.subr line 1174:  _pidcmd='rc_pid=$(check_process /usr/sbin/jail)'

I attached a tarball with the LLM report.  (The LLM ran against 15.0, so the
line numbers shifted - I corrected them here, but not in its report)

I just confirmed reproduce.sh fails against 15.1-RELEASE-p1, and bumped the
version for this bug to 15.1-RELEASE.  Some of its subtests pass.  This is
expected.  Those confirm that things like double-starting a jail fail as
expected.  All the tests should pass against an acceptable fix.

reproduce-strict.sh runs stricter tests -- it also confirms that the shell exit
code is correct (bug #242437)  The tarball contains patches for both issues.

As for the documentation mismatch: You could either fix the man page, or change
rc.subr's behavior to match it.  I'm not sure how many other rc scripts are in
the same boat as jail, but that'd probably be the deciding factor.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to