Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jul 2016 18:26:50 +0000
From:      Grzegorz Junka <list1@gjunka.com>
To:        freebsd-jail@freebsd.org
Subject:   Re: Effective rule sets in a jail?
Message-ID:  <8d24b89f-3a83-ac6b-5051-c50accb24e9d@gjunka.com>
In-Reply-To: <20160707153148.7da31609@eto-mona.office.smartweb.sk>
References:  <2aeb6798-11ee-27c0-610a-d745aa322f97@gjunka.com> <CANJ8om5R-BT=heC%2BgiMTXFH8YQXhuPQZjQ_S-P1bQ1XBGS16uQ@mail.gmail.com> <577E0A78.1040600@quip.cz> <2c9d10fd-35ba-5470-026d-a1483e47fcf2@gjunka.com> <577E1AFB.90100@quip.cz> <6ccead58-a38a-80a4-b5b8-a509c4271b8f@gjunka.com> <577E29A8.5000504@quip.cz> <4d3f5584-7dd1-e6fc-540f-9ed3f1fb63f4@gjunka.com> <20160707153148.7da31609@eto-mona.office.smartweb.sk>

next in thread | previous in thread | raw e-mail | index | archive | help

On 07/07/2016 13:31, Martin "eto" Misuth wrote:
> IMHO, regarding jails, better mental model would be like this:
>   - any single jail can have one and only one devfs ruleset number assigned
>     - however, different standalone jails can have different devfs ruleset
>       number assigned
>   - nested jails inherit ruleset number from their parent jail
>
> Regarding rulesets "inheritance"/"merging" you are probably looking into the
> wrong place. devfs ruleset system is completely orthogonal to jails, as it
> is used for other things as well.
>
> You can "merge" devfs rulesets in devfs /etc/devfs.rules.
>
> Look into /etc/defaults/devfs.rules how initial rulesets are built.
>
> First everything is hidden by ruleset 1 aka "devfsrules_hide_all". This is "by
> default deny" policy, which should, according to me, used whenever one can.
>
> Then, new rulesets are created by unhiding various groups of devices.
> Like for example you have minimal sub-ruleset 2 aka "devfsrules_unhide_basic".
> That one is required to get minimal working /dev. Otherwise most programs break.
>
> Finally ruleset 4 aka "devfsrules_jail" is built, which can be used by jails.
>
> I personally "classify" jail types into groups. Let's call such group a jail
> "class" (for the purpose of classification).
>
> Thus to get what you want, you should create custom ruleset per jail "class" and
> assign it to your jails based on their "class".
>
> [devfsrules_jail_class_no_zfs=16]
> add include $devfsrules_hide_all
> add include $devfsrules_unhide_basic
> add include $devfsrules_unhide_login
>
> Class might be not good word for this, as it is quite "loaded" by now, but I am
> using it that way.
>
> Some jails might end up so special, they require completely fine tuned ruleset.
> Those cannot be completely "classified" at all like this for example:
>
> [devfsrules_jail_proxy=333]
> add include $devfsrules_hide_all
> add include $devfsrules_unhide_basic
> add include $devfsrules_unhide_login
> add include $devfsrules_unhide_jail_proxy_tuns
>
> "devfsrules_unhide_jail_proxy_tuns" sub-rule in this case unhides
> several tun interfaces used solely by this jail only.
>
> devfs.conf files are "parsed" by /etc/rc.d/devfs rc script which is run quite
> early after boot. If you look at it you will see it is using /etc/rc.subr
> devfs_* subroutines of rc.d framework which invoke /sbin/devfs helper program.
>
> Theoretically if /etc/rc.d/devfs and /etc/rc.subr are not enough for
> you, you could write helper script to invoke /sbin/devfs to setup most
> convoluted rule ids directly by hand.
>
>    eto
> _______________________________________________
> freebsd-jail@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-jail
> To unsubscribe, send any mail to "freebsd-jail-unsubscribe@freebsd.org"

That's great! Thanks for the comprehensive explanation, I wish it was in 
the man already so I wouldn't need to enquiry additionally here. It 
makes sense, as I mentioned in my previous email, I got confused and 
messed jail inheritance with the inheritance of devfs rule sets, they 
are orthogonal as you stated. I amended my rules to include the basic 
ones from rule 4 to the more specific one for one particular jail and it 
works. Thanks again!
Grzegorz




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8d24b89f-3a83-ac6b-5051-c50accb24e9d>