Commit 74fdb93e authored by Franco Fichtner's avatar Franco Fichtner

dhcpd: directly execute the chroot setup

(cherry picked from commit aceea376)
parent f65877a5
......@@ -386,35 +386,27 @@ function services_dhcpdv6_leasesfile()
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 */
$fd = fopen('/tmp/dhcpd.sh', 'w');
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}\n");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/dev\n");
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");
fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/run\n");
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);
$dirs = array('/dev', '/etc', '/lib', '/run', '/usr', '/usr/local/sbin', '/var/db', '/var/run');
foreach ($dirs as $dir) {
mwexecf('/bin/mkdir -p %s', "{$g['dhcpd_chroot_path']}{$dir}");
}
if (mwexecf('/sbin/mount -uw %s', "{$g['dhcpd_chroot_path']}/dev", true)) {
mwexecf('/sbin/mount -t devfs devfs %s', "{$g['dhcpd_chroot_path']}/dev");
}
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();
}
if ($family == "all" || $family == "inet6") {
if ($family == 'all' || $family == 'inet6') {
services_dhcpdv6_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