diff options
author | Perry Mason <crazypark2@yahoo.dk> | 2009-12-09 17:02:35 +0100 |
---|---|---|
committer | Perry Mason <crazypark2@yahoo.dk> | 2009-12-09 17:02:35 +0100 |
commit | 57bc3cfa3e05ca7efecdc280e8c6ca353e9822e2 (patch) | |
tree | c6d56da4f31eb32bcfd569142e41cbcdd31d401e /config/Fit123/bin/ltsp | |
parent | 498ae4b7a1a8657116366e1a8abdd168c72ab252 (diff) | |
download | pfsense-packages-57bc3cfa3e05ca7efecdc280e8c6ca353e9822e2.tar.gz pfsense-packages-57bc3cfa3e05ca7efecdc280e8c6ca353e9822e2.tar.bz2 pfsense-packages-57bc3cfa3e05ca7efecdc280e8c6ca353e9822e2.zip |
Files in sync with release
Diffstat (limited to 'config/Fit123/bin/ltsp')
-rw-r--r-- | config/Fit123/bin/ltsp/services.inc | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | config/Fit123/bin/ltsp/services_dhcp.abc | 66 |
2 files changed, 70 insertions, 12 deletions
diff --git a/config/Fit123/bin/ltsp/services.inc b/config/Fit123/bin/ltsp/services.inc index a788a2b3..f999868a 100644 --- a/config/Fit123/bin/ltsp/services.inc +++ b/config/Fit123/bin/ltsp/services.inc @@ -61,6 +61,7 @@ function services_dhcpd_configure() { fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/etc\n"); fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr/local/sbin\n"); fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/db\n"); + fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/run\n"); fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr\n"); fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/lib\n"); fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/run\n"); @@ -278,9 +279,9 @@ EOD; $dhcpdconf .= " next-server {$dhcpifconf['next-server']};\n"; $dhcpdconf .= " filename \"{$dhcpifconf['filename']}\";\n"; } - if ($dhcpifconf['rootpath'] <> "") { - $dhcpdconf .= " option root-path \"{$dhcpifconf['rootpath']}\";\n"; - } + if ($dhcpifconf['rootpath'] <> "") { + $dhcpdconf .= " option root-path \"{$dhcpifconf['rootpath']}\";\n"; + } } $dhcpdconf .= <<<EOD } @@ -635,7 +636,7 @@ function services_dnsmasq_configure() { //} /* run dnsmasq */ - mwexec("/usr/local/sbin/dnsmasq {$args}"); + mwexec("/usr/local/sbin/dnsmasq --all-servers {$args}"); if ($g['booting']) echo "done.\n"; @@ -927,7 +928,10 @@ EOD; fclose($fd); /* generate update instructions */ - $upinst = "update delete {$config['dnsupdate']['host']} A\n"; + $upinst = ""; + if ($config['dnsupdate']['server']) + $upinst .= "server {$config['dnsupdate']['server']}\n"; + $upinst .= "update delete {$config['dnsupdate']['host']} A\n"; $upinst .= "update add {$config['dnsupdate']['host']} {$config['dnsupdate']['ttl']} A {$wanip}\n"; $upinst .= "\n"; /* mind that trailing newline! */ @@ -936,7 +940,7 @@ EOD; fclose($fd); /* invoke nsupdate */ - $cmd = "/usr/sbin/nsupdate -k {$g['varetc_path']}/K{$keyname}+157+00000.key"; + $cmd = "/usr/bin/nsupdate -k {$g['varetc_path']}/K{$keyname}+157+00000.key"; if (isset($config['dnsupdate']['usetcp'])) $cmd .= " -v"; $cmd .= " {$g['varetc_path']}/nsupdatecmds"; diff --git a/config/Fit123/bin/ltsp/services_dhcp.abc b/config/Fit123/bin/ltsp/services_dhcp.abc index 89548502..7a203491 100644..100755 --- a/config/Fit123/bin/ltsp/services_dhcp.abc +++ b/config/Fit123/bin/ltsp/services_dhcp.abc @@ -31,6 +31,57 @@ require("guiconfig.inc"); +/* Fix failover DHCP problem + * http://article.gmane.org/gmane.comp.security.firewalls.pfsense.support/18749 + */ +ini_set("memory_limit","64M"); + +/* This function will remove entries from dhcpd.leases that would otherwise + * overlap with static DHCP reservations. If we don't clean these out, + * then DHCP will print a warning in the logs about a duplicate lease + */ +function dhcp_clean_leases() { + global $g, $config; + $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"; + if (!file_exists($leasesfile)) + return; + /* Build list of static MACs */ + $staticmacs = array(); + foreach($config['interfaces'] as $ifname => $ifarr) + if (is_array($config['dhcpd'][$ifname]['staticmap'])) + foreach($config['dhcpd'][$ifname]['staticmap'] as $static) + $staticmacs[] = $static['mac']; + /* Read existing leases */ + $leases_contents = explode("\n", file_get_contents($leasesfile)); + $newleases_contents = array(); + $i=0; + while ($i < count($leases_contents)) { + /* Find a lease definition */ + if (substr($leases_contents[$i], 0, 6) == "lease ") { + $templease = array(); + $thismac = ""; + /* Read to the end of the lease declaration */ + do { + if (substr($leases_contents[$i], 0, 20) == " hardware ethernet ") + $thismac = substr($leases_contents[$i], 20, 17); + $templease[] = $leases_contents[$i]; + $i++; + } while ($leases_contents[$i-1] != "}"); + /* Check for a matching MAC address and if not present, keep it. */ + if (! in_array($thismac, $staticmacs)) + $newleases_contents = array_merge($newleases_contents, $templease); + } else { + /* It's a line we want to keep, copy it over. */ + $newleases_contents[] = $leases_contents[$i]; + $i++; + } + } + /* Write out the new leases file */ + $fd = fopen($leasesfile, 'w'); + fwrite($fd, implode("\n", $newleases_contents)); + fclose($fd); +} + $if = $_GET['if']; if ($_POST['if']) $if = $_POST['if']; @@ -225,7 +276,7 @@ if ($_POST) { $config['dhcpd'][$if]['netboot'] = ($_POST['netboot']) ? true : false; $config['dhcpd'][$if]['next-server'] = $_POST['nextserver']; $config['dhcpd'][$if]['filename'] = $_POST['filename']; - $config['dhcpd'][$if]['rootpath'] = $_POST['rootpath']; + $config['dhcpd'][$if]['rootpath'] = $_POST['rootpath']; write_config(); @@ -236,6 +287,9 @@ if ($_POST) { $retvaldhcp = 0; $retvaldns = 0; config_lock(); + /* Stop DHCP so we can cleanup leases */ + killbyname("dhcpd"); + dhcp_clean_leases(); /* dnsmasq_configure calls dhcpd_configure */ /* no need to restart dhcpd twice */ if (isset($config['dnsmasq']['regdhcpstatic'])) { @@ -302,7 +356,7 @@ function enable_change(enable_over) { document.iform.netboot.disabled = endis; document.iform.nextserver.disabled = endis; document.iform.filename.disabled = endis; - document.iform.rootpath.disabled = endis; + document.iform.rootpath.disabled = endis; document.iform.denyunknown.disabled = endis; } @@ -544,10 +598,10 @@ function show_netboot_config() { <p> <input name="filename" type="text" class="formfld" id="filename" size="20" value="<?=htmlspecialchars($pconfig['filename']);?>"><br> Enter the filename used for network booting.<br /> - Note: You need both a filename and a boot server configured for this to work!<br /> - <p> - <input name="rootpath" type="text" class="formfld" id="rootpath" size="20" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br> - Enter option root-path. + Note: You need both a filename and a boot server configured for this to work!<br /> + <p> + <input name="rootpath" type="text" class="formfld" id="rootpath" size="20" value="<?=htmlspecialchars($pconfig['rootpath']);?>"><br> + Enter option root-path. </div> </td> </tr> |