Re: jail.$jailname.conf not directly in /etc/ ?

From: Kyle Evans <kevans_at_freebsd.org>
Date: Sat, 19 Feb 2022 17:03:08 UTC
On Sat, Feb 19, 2022 at 3:29 AM Jon Clausen <freebsd-questions@ymmv.dk> wrote:
>
> Hi
>
> I'm reworking my jails setup, transitioning from ezjail to a "manual" setup
> which involves vnet and some homegrown scripts to set up zfs, nullfs
> overlays, epairs, etc.
>
> I'm trying to keep things segregated from the base system, which basically
> just means that I'm putting all of the datasets, config files and whatever
> under /usr/local/ somewhere.
>
> I'm making good progress, and am generally happy with everything except
> that I can't find a way to tell the "rc" system to look for the
> jail.$jailname.conf files someplace other than /etc/
>
> Basically, I think it's sort of messy and and impractical to have a bunch of
> individual jail config files laying directly in /etc/. I would prefer to
> have them all under, say, /usr/local/etc/jails/ or even /usr/local/etc/.
>
> But if the files aren't in /etc/, then `service` cannot find them, and jail
> start/stop/whatever operations fail.
>
> I assume that the functionality is there, but the manpages for jail.conf,
> rc.conf aren't making it obvious. And from an (admittedly superficial)
> glance at /etc/rc.d/jail I don't really see how it would work with a
> "global" path for the config files, other than the hardcoded /etc/.
>
> What I was hoping for would be some global setting in /etc/rc.conf,
> /etc/jail.conf or somewhere...
>
> For this round of jails I am working on both 12.3-RELEASE and 13.0-RELEASE,
> (both for the host systems and the jails) so it would be nice to find
> something that works on both versions.
>
> Am I just being dense?
>
> I'm not having much luck finding any discussions about this anywhere
> online either. But I can't believe that this topic has never come up
> before, so I must assume that it's just me failing to compose my search
> terms correctly...
>
> Any ideas?
>

In main we've added a facility to organize jail confs a little
differently: /etc/jail.conf.d/<jail>.conf. I think, personally, if
we're going to allow a flexible config here (which I think we should),
we should just expand this latest form and leave the others be. I
might've even brought this up in the review, because I had thought
about it; maybe something like this:
https://people.freebsd.org/~kevans/jail_conf_dirs.diff to search
/etc/jail.conf.d and /usr/local/etc/jail.conf.d by default.

That doesn't really solve the problem at hand, but it might be a clean
solution for the future.

Thanks,

Kyle Evans