jail's periodic stuff
Jeremie Le Hen
jeremie at le-hen.org
Fri Sep 23 09:30:46 PDT 2005
> Problem 1? "These scripts fail when you attempt to run then inside a jail(8)"
> I don't see this as a problem, I see it as correct behaviour. You try to do
> something which you are not allowed to do, and the kernel prohibits it. The
> same would be true if you tried to run these scripts as a non-root user, for
> I wouldn't expect to see magic in these scripts saying
> if [ `id -u` != 0 ]; then
> exit 0
> so I don't see any need to add magic to exit early if the script is run in a
> Problem 2? "These scripts are invoked by cron periodically in a default jail
> installation, and this causes spurious error mails to be sent out every day"
> This I agree is undesirable behaviour, and it derives from the fact that a
> jail installation is just a normal FreeBSD installation, which expects that
> it needs to run periodic machine-level admin tasks when in fact it is
> running at the jail level where these tasks are inappropriate.
> So for me the obvious solution is to make a jail installation slightly
> different from a normal installation, by installing /etc/periodic.conf which
> disables those tasks that send out spurious mails.
> If you want to run the machine-level tasks only when cron is running outside
> a jail, without explicit configuration, then I'd suggest the place to put
> the magic is /etc/defaults/periodic.conf (which is, after all, just a shell
> if [ `sysctl -n security.jail.jailed` == 0 ]; then
> # 600.ip6fwdenied
> # 610.ipf6denied
> This seems cleaner to me, as it still allows you to override these policies
> (even if that's not currently a useful thing to do)
Actually, I was thinking of the rc.d scripts. In the maneer of periodic
scripts, they are not intended to be executed by a normal user (as all
scripts under /etc), so they don't need this kind of magic. I agree
with you on this point.
Nonetheless rc.d scripts does have a ``nojail'' keyword, but these are
run through the rc(8) framework, which is not the case of periodic
scripts. Therefore we can't easily use such a keyword.
There are two options offered to us in my point of view :
o add the following test to each script that can't be run in
a jail environnement :
% if [ `sysctl -n security.jail.jailed` -eq 1 ]
% exit 0
o modify periodic(8) in order to handle such a keyword.
In my opinion, given that there is only a few scripts that should be
avoided inside a jail, the second solution is a little bit overkill,
but I wanted to be sure of this, thus my question here.
But the solution you proposed below is quite attractive because this is
little intrusive and doesn't require code duplication across periodic
scripts. The attached patch modifies etc/defaults/periodic.conf and
Note that I'm still not sure about these scripts :
For instance, 420 uses ``netstat -in''. It will not be able to run
inside a jail, unless /dev/mem is available (I'm not sure this is
still the case with rwatson@ recent changes), which is, while still
possible, very unlikely. I would like to hear some advice of wise
people about this.
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >
-------------- next part --------------
RCS file: /donald/repo/FreeBSD/src/etc/defaults/periodic.conf,v
retrieving revision 1.33
diff -u -p -r1.33 periodic.conf
--- defaults/periodic.conf 24 Jan 2005 22:21:13 -0000 1.33
+++ defaults/periodic.conf 23 Sep 2005 16:25:25 -0000
@@ -22,6 +22,12 @@ periodic_conf_files="/etc/periodic.conf
# periodic script dirs
+# Use $nojail for things that are not intended to be run inside a jail.
+if [ `sysctl -n security.jail.jailed` -eq 1 ]
# Daily options
@@ -148,25 +154,25 @@ daily_status_security_chkuid0_enable="YE
More information about the freebsd-current