Revision 107e8acc
Added by Ovidiu Predescu about 13 years ago
etc/inc/services.inc | ||
---|---|---|
39 | 39 |
pfSense_MODULE: utils |
40 | 40 |
*/ |
41 | 41 |
|
42 |
function strify($str) { |
|
43 |
return '"' . $str . '"'; |
|
44 |
}; |
|
45 |
|
|
46 |
|
|
42 | 47 |
/* implement ipv6 route advertising deamon */ |
43 | 48 |
function services_rtadvd_configure() { |
44 | 49 |
global $config, $g; |
45 |
|
|
46 |
if ($g['platform'] == 'jail')
|
|
50 |
|
|
51 |
if ($g['platform'] == 'jail') |
|
47 | 52 |
return; |
48 | 53 |
|
49 | 54 |
if(isset($config['system']['developerspew'])) { |
... | ... | |
122 | 127 |
break; |
123 | 128 |
default: |
124 | 129 |
$rtadvdconf .= "\t:raflags#0:\\\n"; |
125 |
break;
|
|
130 |
break; |
|
126 | 131 |
|
127 | 132 |
} |
128 | 133 |
$rtadvdconf .= "\t:tc=ether:\\\n"; |
... | ... | |
196 | 201 |
$rtadvdconf .= "\t:rdnss=\"{$dnsstring}\":\\\n"; |
197 | 202 |
} |
198 | 203 |
$rtadvdconf .= "\t:tc=ether:\\\n"; |
199 |
$rtadvdconf .= "\n\n";
|
|
204 |
$rtadvdconf .= "\n\n"; |
|
200 | 205 |
$rtadvdnum++; |
201 | 206 |
} |
202 | 207 |
} |
... | ... | |
214 | 219 |
continue; |
215 | 220 |
|
216 | 221 |
$rtadvdifs[] = $realif; |
217 |
|
|
222 |
|
|
218 | 223 |
/* find the interface which has the 6RD prefix defined and it's IPv4 address */ |
219 | 224 |
foreach($Iflist as $rdif => $rdifdescr) { |
220 | 225 |
if($config['interfaces'][$rdif]['ipaddrv6'] == "6rd") { |
... | ... | |
267 | 272 |
$rtadvdconf .= "\t:rdnss=\"{$dnsstring}\":\\\n"; |
268 | 273 |
} |
269 | 274 |
$rtadvdconf .= "\t:tc=ether:\\\n"; |
270 |
$rtadvdconf .= "\n\n";
|
|
275 |
$rtadvdconf .= "\n\n"; |
|
271 | 276 |
$rtadvdnum++; |
272 | 277 |
} |
273 | 278 |
} |
... | ... | |
313 | 318 |
} |
314 | 319 |
function services_dhcpdv4_configure() { |
315 | 320 |
global $config, $g; |
316 |
|
|
317 |
if($g['services_dhcp_server_enable'] == false)
|
|
321 |
|
|
322 |
if($g['services_dhcp_server_enable'] == false) |
|
318 | 323 |
return; |
319 | 324 |
|
320 | 325 |
if(isset($config['system']['developerspew'])) { |
321 | 326 |
$mt = microtime(); |
322 | 327 |
echo "services_dhcpdv4_configure($if) being called $mt\n"; |
323 | 328 |
} |
324 |
|
|
329 |
|
|
325 | 330 |
/* kill any running dhcpd */ |
326 | 331 |
if(is_process_running("dhcpd")) { |
327 | 332 |
killbypid("{$g['dhcpd_chroot_path']}{$g['varrun_path']}/dhcpd.pid"); |
... | ... | |
357 | 362 |
$config['dhcpd'] = array(); |
358 | 363 |
$dhcpdcfg = $config['dhcpd']; |
359 | 364 |
$Iflist = get_configured_interface_list(); |
360 |
|
|
365 |
|
|
361 | 366 |
if ($g['booting']) |
362 | 367 |
echo gettext("Starting DHCP service..."); |
363 | 368 |
else |
... | ... | |
371 | 376 |
} |
372 | 377 |
|
373 | 378 |
$custoptions = ""; |
374 |
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
|
|
379 |
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) { |
|
375 | 380 |
if(is_array($dhcpifconf['numberoptions']) && is_array($dhcpifconf['numberoptions']['item'])) { |
376 | 381 |
foreach($dhcpifconf['numberoptions']['item'] as $itemidx => $item) { |
377 | 382 |
if(!empty($item['type'])) |
... | ... | |
384 | 389 |
} |
385 | 390 |
|
386 | 391 |
$dhcpdconf = <<<EOD |
387 |
|
|
392 |
|
|
388 | 393 |
option domain-name "{$syscfg['domain']}"; |
389 | 394 |
option ldap-server code 95 = text; |
390 | 395 |
option domain-search-list code 119 = text; |
... | ... | |
402 | 407 |
if(!isset($dhcpifconf['disableauthoritative'])) |
403 | 408 |
$dhcpdconf .= "authoritative;\n"; |
404 | 409 |
|
405 |
if(isset($dhcpifconf['alwaysbroadcast']))
|
|
410 |
if(isset($dhcpifconf['alwaysbroadcast'])) |
|
406 | 411 |
$dhcpdconf .= "always-broadcast on\n"; |
407 | 412 |
|
408 | 413 |
$dhcpdifs = array(); |
... | ... | |
494 | 499 |
if ($dhcpifconf['domain']) { |
495 | 500 |
$dnscfg .= " option domain-name \"{$dhcpifconf['domain']}\";\n"; |
496 | 501 |
} |
497 |
|
|
502 |
|
|
498 | 503 |
if($dhcpifconf['domainsearchlist'] <> "") { |
499 | 504 |
$dnscfg .= " option domain-search \"" . join("\",\"", preg_split("/[ ;]+/", $dhcpifconf['domainsearchlist'])) . "\";\n"; |
505 |
$domains = implode(',', array_map(strify, explode(' ', $dhcpifconf['domainsearchlist']))); |
|
506 |
$dnscfg .= " option domain-search {$domains};\n"; |
|
500 | 507 |
} |
501 | 508 |
|
502 | 509 |
if (isset($dhcpifconf['ddnsupdate'])) { |
... | ... | |
597 | 604 |
$dhcpdconf .= " option root-path \"{$dhcpifconf['rootpath']}\";\n"; |
598 | 605 |
} |
599 | 606 |
} |
600 |
|
|
607 |
|
|
601 | 608 |
$dhcpdconf .= <<<EOD |
602 | 609 |
} |
603 | 610 |
|
... | ... | |
640 | 647 |
|
641 | 648 |
/* create an empty leases database */ |
642 | 649 |
touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); |
643 |
|
|
650 |
|
|
644 | 651 |
|
645 | 652 |
/* fire up dhcpd in a chroot */ |
646 | 653 |
if(count($dhcpdifs) > 0) { |
... | ... | |
657 | 664 |
|
658 | 665 |
function services_dhcpdv6_configure() { |
659 | 666 |
global $config, $g; |
660 |
|
|
661 |
if($g['services_dhcp_server_enable'] == false)
|
|
667 |
|
|
668 |
if($g['services_dhcp_server_enable'] == false) |
|
662 | 669 |
return; |
663 | 670 |
|
664 | 671 |
if(isset($config['system']['developerspew'])) { |
665 | 672 |
$mt = microtime(); |
666 | 673 |
echo "services_dhcpd_configure($if) being called $mt\n"; |
667 | 674 |
} |
668 |
|
|
675 |
|
|
669 | 676 |
/* kill any running dhcpd */ |
670 | 677 |
if(is_process_running("dhcpd")) { |
671 | 678 |
killbypid("{$g['dhcpd_chroot_path']}{$g['varrun_path']}/dhcpdv6.pid"); |
... | ... | |
701 | 708 |
$config['dhcpdv6'] = array(); |
702 | 709 |
$dhcpdv6cfg = $config['dhcpdv6']; |
703 | 710 |
$Iflist = get_configured_interface_list(); |
704 |
|
|
711 |
|
|
705 | 712 |
if ($g['booting']) |
706 | 713 |
echo "Starting DHCPv6 service..."; |
707 | 714 |
else |
... | ... | |
715 | 722 |
} |
716 | 723 |
|
717 | 724 |
$custoptionsv6 = ""; |
718 |
foreach ($dhcpdv6cfg as $dhcpv6if => $dhcpv6ifconf) {
|
|
725 |
foreach ($dhcpdv6cfg as $dhcpv6if => $dhcpv6ifconf) { |
|
719 | 726 |
if(is_array($dhcpv6ifconf['numberoptions']) && is_array($dhcpv6ifconf['numberoptions']['item'])) { |
720 | 727 |
foreach($dhcpv6ifconf['numberoptions']['item'] as $itemv6idx => $itemv6) { |
721 | 728 |
$custoptionsv6 .= "option custom-{$dhcpv6if}-{$itemv6idx} code {$itemv6['number']} = text;\n"; |
... | ... | |
724 | 731 |
} |
725 | 732 |
|
726 | 733 |
$dhcpdv6conf = <<<EOD |
727 |
|
|
734 |
|
|
728 | 735 |
option domain-name "{$syscfg['domain']}"; |
729 | 736 |
option ldap-server code 95 = text; |
730 | 737 |
option domain-search-list code 119 = text; |
... | ... | |
742 | 749 |
if(!isset($dhcpv6ifconf['disableauthoritative'])) |
743 | 750 |
$dhcpdv6conf .= "authoritative;\n"; |
744 | 751 |
|
745 |
if(isset($dhcpv6ifconf['alwaysbroadcast']))
|
|
752 |
if(isset($dhcpv6ifconf['alwaysbroadcast'])) |
|
746 | 753 |
$dhcpdv6conf .= "always-broadcast on\n"; |
747 | 754 |
|
748 | 755 |
$dhcpdv6ifs = array(); |
... | ... | |
828 | 835 |
if ($dhcpv6ifconf['domain']) { |
829 | 836 |
$dnscfgv6 .= " option domain-name \"{$dhcpv6ifconf['domain']}\";\n"; |
830 | 837 |
} |
831 |
|
|
838 |
|
|
832 | 839 |
if($dhcpv6ifconf['domainsearchlist'] <> "") { |
833 | 840 |
$dnscfgv6 .= " option domain-search \"" . join("\",\"", preg_split("/[ ;]+/", $dhcpv6ifconf['domainsearchlist'])) . "\";\n"; |
834 | 841 |
} |
... | ... | |
935 | 942 |
$dhcpdv6conf .= " option root-path \"{$dhcpv6ifconf['rootpath']}\";\n"; |
936 | 943 |
} |
937 | 944 |
} |
938 |
|
|
945 |
|
|
939 | 946 |
$dhcpdv6conf .= <<<EOD |
940 | 947 |
} |
941 | 948 |
|
... | ... | |
970 | 977 |
$i++; |
971 | 978 |
} |
972 | 979 |
} |
973 |
|
|
980 |
|
|
974 | 981 |
if($config['dhcpdv6'][$dhcpv6if]['mode'] <> "unmanaged") { |
975 | 982 |
$realif = escapeshellcmd(get_real_interface($dhcpv6if)); |
976 | 983 |
$dhcpdv6ifs[] = $realif; |
... | ... | |
987 | 994 |
fclose($fdv6); |
988 | 995 |
/* create an empty leases v6 database */ |
989 | 996 |
touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases"); |
990 |
|
|
997 |
|
|
991 | 998 |
|
992 | 999 |
/* fire up dhcpd in a chroot */ |
993 | 1000 |
if(count($dhcpdv6ifs) > 0) { |
... | ... | |
1093 | 1100 |
$dhcrelayifs[] = get_real_interface($dhcrelayif); |
1094 | 1101 |
} |
1095 | 1102 |
|
1096 |
/*
|
|
1103 |
/* |
|
1097 | 1104 |
* In order for the relay to work, it needs to be active |
1098 | 1105 |
* on the interface in which the destination server sits. |
1099 | 1106 |
*/ |
... | ... | |
1138 | 1145 |
} |
1139 | 1146 |
} |
1140 | 1147 |
} |
1141 |
|
|
1148 |
|
|
1142 | 1149 |
if (!isset($destif)) { |
1143 | 1150 |
if (is_array($config['gateways']['gateway_item'])) { |
1144 | 1151 |
foreach ($config['gateways']['gateway_item'] as $gateway) { |
... | ... | |
1146 | 1153 |
$a_gateways = return_gateways_array(true); |
1147 | 1154 |
$destif = $a_gateways[$rtent['gateway']]['interface']; |
1148 | 1155 |
break; |
1149 |
}
|
|
1156 |
} |
|
1150 | 1157 |
} |
1151 | 1158 |
} else |
1152 | 1159 |
$destif = get_real_interface("wan"); |
... | ... | |
1209 | 1216 |
$dhcrelayifs[] = get_real_interface($dhcrelayif); |
1210 | 1217 |
} |
1211 | 1218 |
|
1212 |
/*
|
|
1219 |
/* |
|
1213 | 1220 |
* In order for the relay to work, it needs to be active |
1214 | 1221 |
* on the interface in which the destination server sits. |
1215 | 1222 |
*/ |
... | ... | |
1254 | 1261 |
} |
1255 | 1262 |
} |
1256 | 1263 |
} |
1257 |
|
|
1264 |
|
|
1258 | 1265 |
if (!isset($destif)) { |
1259 | 1266 |
if (is_array($config['gateways']['gateway_item'])) { |
1260 | 1267 |
foreach ($config['gateways']['gateway_item'] as $gateway) { |
... | ... | |
1262 | 1269 |
$a_gateways = return_gateways_array(true); |
1263 | 1270 |
$destif = $a_gateways[$rtent['gateway']]['interface']; |
1264 | 1271 |
break; |
1265 |
}
|
|
1272 |
} |
|
1266 | 1273 |
} |
1267 | 1274 |
} else |
1268 | 1275 |
$destif = get_real_interface("wan"); |
... | ... | |
1303 | 1310 |
$dnsUser = $conf['username'], |
1304 | 1311 |
$dnsPass = $conf['password'], |
1305 | 1312 |
$dnsWilcard = $conf['wildcard'], |
1306 |
$dnsMX = $conf['mx'],
|
|
1313 |
$dnsMX = $conf['mx'], |
|
1307 | 1314 |
$dnsIf = "{$conf['interface']}", |
1308 | 1315 |
$dnsBackMX = NULL, |
1309 | 1316 |
$dnsServer = NULL, |
... | ... | |
1322 | 1329 |
$dyndnscfg = $config['dyndnses']['dyndns']; |
1323 | 1330 |
|
1324 | 1331 |
if (is_array($dyndnscfg)) { |
1325 |
if ($g['booting'])
|
|
1332 |
if ($g['booting']) |
|
1326 | 1333 |
echo gettext("Starting DynDNS clients..."); |
1327 | 1334 |
|
1328 | 1335 |
foreach ($dyndnscfg as $dyndns) { |
... | ... | |
1344 | 1351 |
function services_dnsmasq_configure() { |
1345 | 1352 |
global $config, $g; |
1346 | 1353 |
$return = 0; |
1347 |
|
|
1354 |
|
|
1348 | 1355 |
if(isset($config['system']['developerspew'])) { |
1349 | 1356 |
$mt = microtime(); |
1350 | 1357 |
echo "services_dnsmasq_configure() being called $mt\n"; |
... | ... | |
1370 | 1377 |
if (isset($config['dnsmasq']['regdhcp'])) { |
1371 | 1378 |
$args .= " --dhcp-hostsfile={$g['varetc_path']}/hosts "; |
1372 | 1379 |
} |
1373 |
|
|
1380 |
|
|
1374 | 1381 |
/* Setup forwarded domains */ |
1375 | 1382 |
if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) { |
1376 | 1383 |
foreach($config['dnsmasq']['domainoverrides'] as $override) { |
... | ... | |
1455 | 1462 |
/* kill any running snmpd */ |
1456 | 1463 |
sigkillbypid("{$g['varrun_path']}/snmpd.pid", "TERM"); |
1457 | 1464 |
sleep(2); |
1458 |
if(is_process_running("bsnmpd"))
|
|
1465 |
if(is_process_running("bsnmpd")) |
|
1459 | 1466 |
mwexec("/usr/bin/killall bsnmpd", true); |
1460 | 1467 |
|
1461 | 1468 |
if (isset($config['snmpd']['enable'])) { |
... | ... | |
1705 | 1712 |
if (isset($dnsupdate['usetcp'])) |
1706 | 1713 |
$cmd .= " -v"; |
1707 | 1714 |
$cmd .= " {$g['varetc_path']}/nsupdatecmds{$i}"; |
1708 |
|
|
1715 |
|
|
1709 | 1716 |
mwexec_bg($cmd); |
1710 | 1717 |
} |
1711 | 1718 |
} |
... | ... | |
2008 | 2015 |
conf_mount_rw(); |
2009 | 2016 |
/* preserve existing crontab entries */ |
2010 | 2017 |
$crontab_contents = file("/etc/crontab", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
2011 |
|
|
2018 |
|
|
2012 | 2019 |
for ($i = 0; $i < count($crontab_contents); $i++) { |
2013 | 2020 |
$cron_item =& $crontab_contents[$i]; |
2014 | 2021 |
if (strpos($cron_item, "# pfSense specific crontab entries") !== false) { |
... | ... | |
2017 | 2024 |
} |
2018 | 2025 |
} |
2019 | 2026 |
$crontab_contents = implode("\n", $crontab_contents) . "\n"; |
2020 |
|
|
2021 |
|
|
2027 |
|
|
2028 |
|
|
2022 | 2029 |
if (is_array($config['cron']['item'])) { |
2023 | 2030 |
$crontab_contents .= "#\n"; |
2024 | 2031 |
$crontab_contents .= "# " . gettext("pfSense specific crontab entries") . "\n"; |
... | ... | |
2034 | 2041 |
$crontab_contents .= "{$item['who']}\t"; |
2035 | 2042 |
$crontab_contents .= "{$item['command']}"; |
2036 | 2043 |
} |
2037 |
|
|
2044 |
|
|
2038 | 2045 |
$crontab_contents .= "\n#\n"; |
2039 | 2046 |
$crontab_contents .= "# " . gettext("If possible do not add items to this file manually.") . "\n"; |
2040 | 2047 |
$crontab_contents .= "# " . gettext("If you do so, this file must be terminated with a blank line (e.g. new line)") . "\n"; |
2041 | 2048 |
$crontab_contents .= "#\n\n"; |
2042 | 2049 |
} |
2043 |
|
|
2050 |
|
|
2044 | 2051 |
/* please maintain the newline at the end of file */ |
2045 | 2052 |
file_put_contents("/etc/crontab", $crontab_contents); |
2046 | 2053 |
|
Also available in: Unified diff
Make domain search list work for MacOS X clients, by adding
option domain-search "domain1", "domain2", "domain3";
to /var/dhcpd/etc/dhcpd.conf
I reported this as a bug on the pfSense forums here:
http://forum.pfsense.org/index.php/topic,47579.0.html