Bug 274568 - rc.conf(5): Empty "jail_list" does not start jails defined in "/etc/jail.conf.d"
Summary: rc.conf(5): Empty "jail_list" does not start jails defined in "/etc/jail.conf.d"
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 13.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-jail (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-18 17:14 UTC by Stephen Fox
Modified: 2023-11-03 11:36 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Fox 2023-10-18 17:14:27 UTC
According to the manual page for rc.conf(5), an empty "jail_list" variable should result in all jails being started on boot or with "service jail start":

  jail_list   (str) A space-delimited list of jail names.  When left empty,
                   all of the jail(8) instances defined in the configuration
                   file are started.  The names specified in this list control
                   the jail startup order.  jail(8) instances missing from
                   jail_list must be started manually.  Note that a jail's
                   depend parameter in the configuration file may override this
                   list.

In FreeBSD 13.2-RELEASE, "service jail start" with an empty jail_list results in the following error message with an exit status of 0:

  "/etc/jail.conf: No such file or directory"

The following shell output demonstrates this issue:

```
# uname -a
FreeBSD freebsd-sketch 13.2-RELEASE-p3 FreeBSD 13.2-RELEASE-p3 GENERIC amd64
# file /etc/jail.conf.d/foo.conf 
/etc/jail.conf.d/foo.conf: ASCII text
# grep '^jail_list' /etc/rc.conf
jail_list=""
root@freebsd-sketch:~ # service jail start
Starting jails:jail: /etc/jail.conf: No such file or directory
.
# echo $?
0
# jls
   JID  IP Address      Hostname                      Path
# # Edit rc.conf to manually specify the "foo" jail.
# grep '^jail_list' /etc/rc.conf
jail_list="foo"
# service jail start
Starting jails: foo.
# jls
   JID  IP Address      Hostname                      Path
     3                  foo.                          /zroot/jails/foo
```
Comment 1 crest 2023-10-20 11:21:14 UTC
It would be nice if it did, but an empty $jail_list just starts the jails in the global /etc/jail.conf. To have per jail jail.conf files in FreeBSD < 14 you need to list them in $jail_list. The least painful way to do this is through `sysrc jail_list+=$name`.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2023-10-20 19:10:23 UTC
Is this just a documentation bug in 13.2?  What changed between 13.2 and 14.0 such that this stopped being a problem?
Comment 3 Antranig Vartanian 2023-10-21 11:44:37 UTC
Greetings,


In FreeBSD 13.2-RELEASE, jail_list="" will start the jails that are defined in jail.conf. If you want to start the jails in jails.conf.d, you have to use jail_list.

In FreeBSD 14, the behavior seems to be the same (at least according to the code). However, you can do the following in jail.conf


.include("/etc/jail.conf.d/foo.conf")


which is better than using jail_list, as it will give you the ability to use features such as depends, multi-layer includes, etc.


This, indeed, seems like a bug in documentation. I will fix it.