Commit aceea376 authored by Franco Fichtner's avatar Franco Fichtner

dhcpd: directly execute the chroot setup

parent 5a091c26
...@@ -386,35 +386,27 @@ function services_dhcpdv6_leasesfile() ...@@ -386,35 +386,27 @@ function services_dhcpdv6_leasesfile()
return "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases"; return "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
} }
function services_dhcpd_configure($family = "all", $blacklist = array()) function services_dhcpd_configure($family = 'all', $blacklist = array())
{ {
global $config, $g; global $g;
/* configure DHCPD chroot once */ $dirs = array('/dev', '/etc', '/lib', '/run', '/usr', '/usr/local/sbin', '/var/db', '/var/run');
$fd = fopen('/tmp/dhcpd.sh', 'w');
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}\n"); foreach ($dirs as $dir) {
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/dev\n"); mwexecf('/bin/mkdir -p %s', "{$g['dhcpd_chroot_path']}{$dir}");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/etc\n"); }
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/usr/local/sbin\n");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db\n"); if (mwexecf('/sbin/mount -uw %s', "{$g['dhcpd_chroot_path']}/dev", true)) {
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/run\n"); mwexecf('/sbin/mount -t devfs devfs %s', "{$g['dhcpd_chroot_path']}/dev");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/usr\n"); }
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/lib\n");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/run\n");
$status = `/sbin/mount -t devfs | /usr/bin/grep "{$g['dhcpd_chroot_path']}/dev"`;
if (!trim($status)) {
fwrite($fd, "/sbin/mount -t devfs devfs {$g['dhcpd_chroot_path']}/dev\n");
}
fwrite($fd, "/usr/sbin/chown -R dhcpd:dhcpd {$g['dhcpd_chroot_path']}\n");
fclose($fd);
mwexec('/bin/sh /tmp/dhcpd.sh'); mwexecf('/usr/sbin/chown -R dhcpd:dhcpd %s', $g['dhcpd_chroot_path']);
if ($family == "all" || $family == "inet") { if ($family == 'all' || $family == 'inet') {
services_dhcpdv4_configure(); services_dhcpdv4_configure();
} }
if ($family == "all" || $family == "inet6") { if ($family == 'all' || $family == 'inet6') {
services_dhcpdv6_configure($blacklist); services_dhcpdv6_configure($blacklist);
services_radvd_configure($blacklist); services_radvd_configure($blacklist);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment