Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 275684 - net-dns/bind chroot improvement suggestion
Summary: net-dns/bind chroot improvement suggestion
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: BIND Maintainers (DISABLED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-28 13:06 UTC by Christian Ruppert (idl0r)
Modified: 2009-08-13 00:48 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
bind.patch (bind.patch,1.67 KB, patch)
2009-06-28 13:07 UTC, Christian Ruppert (idl0r)
Details | Diff
init.patch (init.patch,1.96 KB, patch)
2009-06-28 13:07 UTC, Christian Ruppert (idl0r)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Ruppert (idl0r) gentoo-dev 2009-06-28 13:06:27 UTC
Hey guys,

I think we should improve the chroot handling in bind.
I'll attach some patches (my first idea) so they might need some further improvements.

So I hope you like my idea :)
Comment 1 Christian Ruppert (idl0r) gentoo-dev 2009-06-28 13:07:05 UTC
Created attachment 195947 [details, diff]
bind.patch

Ebuild patch, based on bind-9.4.3_p2.
Comment 2 Christian Ruppert (idl0r) gentoo-dev 2009-06-28 13:07:30 UTC
Created attachment 195948 [details, diff]
init.patch

init-script patch.
Comment 3 Christian Ruppert (idl0r) gentoo-dev 2009-07-19 19:58:42 UTC
Has been included in bind-9.6.1.
Comment 4 Daniel Solano Gómez 2009-07-30 13:02:53 UTC
I had previously updated to bind 9.6 using some of my own local ebuilds.  Now that 9.6.1* is in portage, I switched to using the ebuild that contains this patch.  Although I haven't tested the new init script, it seems to me like it may break old configurations that have all of the bind configuration inside the chroot gaol.  When I get the chance, I'll try it out on a non-production machine.

Also, is there really a need to mount /proc in the chroot?  I do not think I have seen it done or that it is necessary.  As such, doesn't mounting /proc possibly leak all sorts of information about the system into the jail?

In any case, I think there should be much stronger warnings about the new configuration.  Also, it may be a good idea to have some sort of flag to retain the old behaviour.
Comment 5 Christian Ruppert (idl0r) gentoo-dev 2009-07-31 14:12:46 UTC
(In reply to comment #4)
> Also, is there really a need to mount /proc in the chroot?  I do not think I
> have seen it done or that it is necessary.  As such, doesn't mounting /proc
> possibly leak all sorts of information about the system into the jail?
<snip>
echo "none    ${CHROOT}/proc    proc    defaults    0 0" >>/etc/fstab
mkdir ${CHROOT}/proc
mount -t proc none ${CHROOT}/proc
</snip>

Thats from a older bind ebuild, it will be executed during pkg_config.
My aim was to get a _clean_ chroot-dir after stopping bind.
So the only difference here is that we mount it each time again.
AFAIR it was/is necessary, at least some stuff.
I'll take a look at it again asap.

> 
> In any case, I think there should be much stronger warnings about the new
> configuration.  Also, it may be a good idea to have some sort of flag to retain
> the old behaviour.
>

Hm, if you take a look at the new and a old version of the ebuild you'll see that everything will be mounted instead of cp or mount once at boot or once at pkg_config.
With the new initscript you're able to change something in /etc/bind and it will be loaded after rndc reload.
The old: you'd have to cp the changed files into the chroot-dir and reload then.
IMHO its not more or less secure than the old behaviour.

Further suggestions are welcome so feel free :)
Comment 6 David Sparks 2009-08-10 19:34:48 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > Also, is there really a need to mount /proc in the chroot?  I do not think I
> > have seen it done or that it is necessary.  As such, doesn't mounting /proc
> > possibly leak all sorts of information about the system into the jail?
> <snip>
> echo "none    ${CHROOT}/proc    proc    defaults    0 0" >>/etc/fstab
> mkdir ${CHROOT}/proc
> mount -t proc none ${CHROOT}/proc
> </snip>

The above echo >>/etc/fstab must be (somewhat) new as I have been running bind on Gentoo for years and don't have this entry.  I don't mount proc inside the chroot and have never noticed any shortcomings.

bind-mounting /etc/bind inside the chroot wasn't compatible with my configuration without a lot of housekeeping.  I doubt many people edited config in /etc/bind and then cp to /chroot/dns/etc, rather they just edited in /chroot/dns/etc so the new scripts may not work asis for a large number of users.

I'm running the 9.6.x ebuilds for the statistics channel and things like a working max-cache setting (cache will grow in 9.4.x until memory is exhausted).
Comment 7 Christian Ruppert (idl0r) gentoo-dev 2009-08-13 00:48:18 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > (In reply to comment #4)
> > > Also, is there really a need to mount /proc in the chroot?  I do not think I
> > > have seen it done or that it is necessary.  As such, doesn't mounting /proc
> > > possibly leak all sorts of information about the system into the jail?
> > <snip>
> > echo "none    ${CHROOT}/proc    proc    defaults    0 0" >>/etc/fstab
> > mkdir ${CHROOT}/proc
> > mount -t proc none ${CHROOT}/proc
> > </snip>
> 
> The above echo >>/etc/fstab must be (somewhat) new as I have been running bind
> on Gentoo for years and don't have this entry.  I don't mount proc inside the
> chroot and have never noticed any shortcomings.
> 
I can confirm that mounting proc is not necessary, I tested it on my own server without any issues.
I removed the proc mount from the init-script.

> bind-mounting /etc/bind inside the chroot wasn't compatible with my
> configuration without a lot of housekeeping.  I doubt many people edited config
> in /etc/bind and then cp to /chroot/dns/etc, rather they just edited in
> /chroot/dns/etc so the new scripts may not work asis for a large number of
> users.
> 

I'll try to get much more informations about all that so I'll change the init-script and chroot config part again as soon as possible.
This page http://www.cymru.com/Documents/secure-bind-template.html and the links there seems to be very interesting.
Maybe we can include some stuff.