Project

General

Profile

Download (16.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services.inc
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
/* include all configuration functions */
33
require_once("functions.inc");
34

    
35
function services_dhcpd_configure() {
36
	global $config, $g;
37

    
38
	/* kill any running dhcpd */
39
	killbypid("{$g['varrun_path']}/dhcpd.pid");
40

    
41
	$syscfg = $config['system'];
42
	$dhcpdcfg = $config['dhcpd'];
43

    
44
	/* DHCP enabled on any interfaces? */
45
	$dhcpdenable = false;
46
	foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
47
		if (isset($dhcpifconf['enable']) &&
48
			(($dhcpif == "lan") ||
49
			(isset($config['interfaces'][$dhcpif]['enable']) &&
50
			$config['interfaces'][$dhcpif]['if'] && (!$config['interfaces'][$dhcpif]['bridge']))))
51
			$dhcpdenable = true;
52
	}
53

    
54
	if (!$dhcpdenable)
55
		return 0;
56

    
57
	if ($g['booting'])
58
		echo "Starting DHCP service... ";
59
	else
60
		sleep(1);
61

    
62
	/* write dhcpd.conf */
63
	$fd = fopen("{$g['varetc_path']}/dhcpd.conf", "w");
64
	if (!$fd) {
65
		printf("Error: cannot open dhcpd.conf in services_dhcpd_configure().\n");
66
		return 1;
67
	}
68

    
69
	$dhcpdconf = <<<EOD
70
option domain-name "{$syscfg['domain']}";
71
default-lease-time 7200;
72
max-lease-time 86400;
73
authoritative;
74
log-facility local7;
75
ddns-update-style none;
76

    
77
EOD;
78

    
79
	$dhcpdifs = array();
80
	foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
81

    
82
		$ifcfg = $config['interfaces'][$dhcpif];
83

    
84
		if (!isset($dhcpifconf['enable']) ||
85
			(($dhcpif != "lan") &&
86
			(!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
87
			continue;
88

    
89
		$subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);
90
		$subnetmask = gen_subnet_mask($ifcfg['subnet']);
91

    
92
		$dnscfg = "";
93

    
94
		if ($dhcpifconf['domain']) {
95
			$dnscfg .= "	option domain-name \"{$dhcpifconf['domain']}\";\n";
96
		}
97

    
98
		if (is_array($dhcpifconf['dnsserver']) && ($dhcpifconf['dnsserver'][0])) {
99
			$dnscfg .= "	option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
100
		} else if (isset($config['dnsmasq']['enable'])) {
101
			$dnscfg .= "	option domain-name-servers " . $ifcfg['ipaddr'] . ";";
102
		} else if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
103
			$dnscfg .= "	option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
104
		}
105

    
106
		$dhcpdconf .= "subnet $subnet netmask $subnetmask {\n";
107
		$dhcpdconf .= "	pool {\n";
108
		if (isset($dhcpifconf['denyunknown']))
109
		   $dhcpdconf .= "		deny unknown clients;\n";
110

    
111
		if ($dhcpifconf['gateway'])
112
			$routers = $dhcpifconf['gateway'];
113
		else
114
			$routers = $ifcfg['ipaddr'];
115

    
116
		$dhcpdconf .= <<<EOD
117
		range {$dhcpifconf['range']['from']} {$dhcpifconf['range']['to']};
118
	}
119
	option routers {$routers};
120
$dnscfg
121

    
122
EOD;
123

    
124
		if ($dhcpifconf['defaultleasetime'])
125
			$dhcpdconf .= "	default-lease-time {$dhcpifconf['defaultleasetime']};\n";
126
		if ($dhcpifconf['maxleasetime'])
127
			$dhcpdconf .= "	max-lease-time {$dhcpifconf['maxleasetime']};\n";
128

    
129
		if (is_array($dhcpifconf['winsserver']) && $dhcpifconf['winsserver'][0]) {
130
			$dhcpdconf .= "	option netbios-name-servers " . join(",", $dhcpifconf['winsserver']) . ";\n";
131
			$dhcpdconf .= "	option netbios-node-type 8;\n";
132
		}
133

    
134
		if ($dhcpifconf['next-server'])
135
			$dhcpdconf .= "	next-server {$dhcpifconf['next-server']};\n";
136
		if ($dhcpifconf['filename'])
137
			$dhcpdconf .= "	filename \"{$dhcpifconf['filename']}\";\n";
138

    
139
		$dhcpdconf .= <<<EOD
140
}
141

    
142
EOD;
143

    
144
		/* add static mappings */
145
		if (is_array($dhcpifconf['staticmap'])) {
146

    
147
			$i = 0;
148
			foreach ($dhcpifconf['staticmap'] as $sm) {
149
				$dhcpdconf .= <<<EOD
150
host s_{$dhcpif}_{$i} {
151
	hardware ethernet {$sm['mac']};
152

    
153
EOD;
154
				if ($sm['ipaddr'])
155
					$dhcpdconf .= "	fixed-address {$sm['ipaddr']};\n";
156

    
157
				$dhcpdconf .= "}\n";
158
				$i++;
159
			}
160
		}
161

    
162
		$dhcpdifs[] = $ifcfg['if'];
163
	}
164

    
165
	fwrite($fd, $dhcpdconf);
166
	fclose($fd);
167

    
168
	/* create an empty leases database */
169
	touch("{$g['vardb_path']}/dhcpd.leases");
170

    
171
	/* fire up dhcpd */
172
	mwexec("/usr/local/sbin/dhcpd -cf {$g['varetc_path']}/dhcpd.conf " .
173
		join(" ", $dhcpdifs));
174

    
175
	if ($g['booting']) {
176
                print "done.\n";
177
	}
178

    
179
	return 0;
180
}
181

    
182
function interfaces_staticarp_configure($if) {
183
        global $config, $g;
184
        
185
        $ifcfg = $config['interfaces'][$if];
186

    
187
        /* Enable staticarp, if enabled */
188
        if(isset($config['dhcpd'][$if]['staticarp'])) {
189
                mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " staticarp " );
190
                mwexec("/usr/sbin/arp -ad > /dev/null 2>&1 ");
191
                if (is_array($config['dhcpd'][$if]['staticmap'])) {
192

    
193
                        foreach ($config['dhcpd'][$if]['staticmap'] as $arpent) {
194
                                mwexec("/usr/sbin/arp -s " . escapeshellarg($arpent['ipaddr']) . " " . escapeshellarg($arpent['mac']));
195

    
196
                        }
197
                        
198
                }
199
        } else {
200
                mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " -staticarp " );
201
                mwexec("/usr/sbin/arp -ad > /dev/null 2>&1 ");
202
        }
203

    
204
        return 0;
205
}
206

    
207
function services_dhcrelay_configure() {
208
	global $config, $g;
209

    
210
	/* kill any running dhcrelay */
211
	killbypid("{$g['varrun_path']}/dhcrelay.pid");
212

    
213
	$dhcrelaycfg = $config['dhcrelay'];
214

    
215
	/* DHCPRelay enabled on any interfaces? */
216
	$dhcrelayenable = false;
217
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
218
		if (isset($dhcrelayifconf['enable']) &&
219
			(($dhcrelayif == "lan") ||
220
			(isset($config['interfaces'][$dhcrelayif]['enable']) &&
221
			$config['interfaces'][$dhcrelayif]['if'] && (!$config['interfaces'][$dhcrelayif]['bridge']))))
222
			$dhcrelayenable = true;
223
	}
224

    
225
	if (!$dhcrelayenable)
226
		return 0;
227

    
228
	if ($g['booting'])
229
		echo "Starting DHCP relay service... ";
230
	else
231
		sleep(1);
232

    
233
	$dhcrelayifs = array();
234
	foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
235

    
236
		$ifcfg = $config['interfaces'][$dhcrelayif];
237

    
238
		if (!isset($dhcrelayifconf['enable']) ||
239
			(($dhcrelayif != "lan") &&
240
			(!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
241
			continue;
242

    
243
		$dhcrelayifs[] = $ifcfg['if'];
244
	}
245

    
246
	/* In order for the relay to work, it needs to be active on the
247
	   interface in which the destination server sits */
248
	foreach ($config['interfaces'] as $ifname) {
249
		$subnet = $ifname['ipaddr'] . "/" . $ifname['subnet'];
250
		if (ip_in_subnet($dhcrelaycfg['server'],$subnet))
251
			$destif = $ifname['if'];
252
	}
253

    
254
	if (!isset($destif))
255
		$destif = $config['interfaces']['wan']['if'];
256

    
257
	$dhcrelayifs[] = $destif;
258
	$dhcrelayifs = array_unique($dhcrelayifs);
259

    
260
	/* fire up dhcrelay */
261
	$cmd = "/usr/local/sbin/dhcrelay -i " .  join(" -i ", $dhcrelayifs);
262

    
263
	if (isset($dhcrelaycfg['agentoption']))
264
		$cmd .=  " -a -m replace";
265

    
266
	$cmd .= " {$dhcrelaycfg['server']}";
267
	mwexec($cmd);
268

    
269
	if (!$g['booting']) {
270
		/* set the reload filter dity flag */
271
		touch("{$g['tmp_path']}/filter_dirty");
272
	}
273

    
274
	return 0;
275
}
276

    
277
function services_dyndns_reset() {
278
	global $config, $g;
279

    
280
	if (file_exists("{$g['vardb_path']}/ez-ipupdate.cache")) {
281
		unlink("{$g['vardb_path']}/ez-ipupdate.cache");
282
	}
283

    
284
	if (file_exists("{$g['conf_path']}/ez-ipupdate.cache")) {
285
		conf_mount_rw();
286
		unlink("{$g['conf_path']}/ez-ipupdate.cache");
287
		conf_mount_ro();
288
	}
289

    
290
	return 0;
291
}
292

    
293
function services_dyndns_configure() {
294
	global $config, $g;
295

    
296
	/* kill any running ez-ipupdate */
297
	/* ez-ipupdate needs SIGQUIT instead of SIGTERM */
298
	sigkillbypid("{$g['varrun_path']}/ez-ipupdate.pid", "QUIT");
299

    
300
	$dyndnscfg = $config['dyndns'];
301
	$wancfg = $config['interfaces']['wan'];
302

    
303
	if (isset($dyndnscfg['enable'])) {
304

    
305
		if ($g['booting'])
306
			echo "Starting DynDNS client... ";
307
		else
308
			sleep(1);
309

    
310
		/* determine WAN interface name */
311
		$wanif = get_real_wan_interface();
312

    
313
		/* write ez-ipupdate.conf */
314
		$fd = fopen("{$g['varetc_path']}/ez-ipupdate.conf", "w");
315
		if (!$fd) {
316
			printf("Error: cannot open ez-ipupdate.conf in services_dyndns_configure().\n");
317
			return 1;
318
		}
319

    
320
		$ezipupdateconf = <<<EOD
321
service-type={$dyndnscfg['type']}
322
user={$dyndnscfg['username']}:{$dyndnscfg['password']}
323
host={$dyndnscfg['host']}
324
interface=$wanif
325
max-interval=2073600
326
pid-file={$g['varrun_path']}/ez-ipupdate.pid
327
cache-file={$g['vardb_path']}/ez-ipupdate.cache
328
execute=/etc/rc.dyndns.storecache
329
daemon
330

    
331
EOD;
332

    
333
		/* enable MX? */
334
		if ($dyndnscfg['mx']) {
335
			$ezipupdateconf .= "mx={$dyndnscfg['mx']}\n";
336
		}
337

    
338
		/* enable wildcards? */
339
		if (isset($dyndnscfg['wildcard'])) {
340
			$ezipupdateconf .= "wildcard\n";
341
		}
342

    
343
		fwrite($fd, $ezipupdateconf);
344
		fclose($fd);
345

    
346
		/* if we're booting, copy the cache file from /conf */
347
		if ($g['booting']) {
348
			if (file_exists("{$g['conf_path']}/ez-ipupdate.cache")) {
349
				copy("{$g['conf_path']}/ez-ipupdate.cache", "{$g['vardb_path']}/ez-ipupdate.cache");
350
			}
351
		}
352

    
353
		/* run ez-ipupdate */
354
		mwexec("/usr/local/bin/ez-ipupdate -c {$g['varetc_path']}/ez-ipupdate.conf");
355

    
356
		if ($g['booting'])
357
			echo "done.\n";
358
	}
359

    
360
	return 0;
361
}
362

    
363
function services_dnsmasq_configure() {
364
	global $config, $g;
365

    
366
	/* kill any running dnsmasq */
367
	sigkillbypid("{$g['varrun_path']}/dnsmasq.pid", "TERM");
368

    
369
	if (isset($config['dnsmasq']['enable'])) {
370

    
371
		if ($g['booting'])
372
			echo "Starting DNS forwarder... ";
373
		else
374
			sleep(1);
375

    
376
		/* generate hosts file */
377
		system_hosts_generate();
378

    
379
		$args = "";
380

    
381
		if (isset($config['dnsmasq']['regdhcp'])) {
382

    
383
			$args .= " -l {$g['vardb_path']}/dhcpd.leases" .
384
				" -s {$config['system']['domain']}";
385
		}
386

    
387
                if (isset($config['dnsmasq']['domainoverrides']) && is_array($config['dnsmasq']['domainoverrides'])) {
388
                        foreach($config['dnsmasq']['domainoverrides'] as $override) {
389
                                $args .= ' --server=/' . $override['domain'] . '/' . $override['ip'];
390
                        }
391
                }
392

    
393
		/* run dnsmasq */
394
		mwexec("/usr/local/sbin/dnsmasq {$args}");
395

    
396
		if ($g['booting'])
397
			echo "done.\n";
398
	}
399

    
400
	if (!$g['booting']) {
401
		services_dhcpd_configure();
402
	}
403

    
404
	return 0;
405
}
406

    
407
function services_snmpd_configure() {
408
	global $config, $g;
409

    
410
	/* kill any running snmpd */
411
	sigkillbypid("{$g['varrun_path']}/snmpd.pid", "TERM");
412

    
413
	if (isset($config['snmpd']['enable'])) {
414

    
415
		if ($g['booting'])
416
			echo "Starting SNMP daemon... ";
417

    
418
		/* generate snmpd.conf */
419
		$fd = fopen("{$g['varetc_path']}/snmpd.conf", "w");
420
		if (!$fd) {
421
			printf("Error: cannot open snmpd.conf in services_snmpd_configure().\n");
422
			return 1;
423
		}
424

    
425

    
426
		$snmpdconf = <<<EOD
427
location := "{$config['snmpd']['syslocation']}"
428
contact := "{$config['snmpd']['syscontact']}"
429
read := "{$config['snmpd']['rocommunity']}"
430

    
431
EOD;
432

    
433
/* No docs on what write strings do there for disable for now.
434
		if(isset($config['snmpd']['rwenable']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
435
		    $snmpdconf .= <<<EOD
436
# write string
437
write := "{$config['snmpd']['rwcommunity']}"
438

    
439
EOD;
440
		}
441
*/
442

    
443

    
444
		if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
445
		    $snmpdconf .= <<<EOD
446
# SNMP Trap support.
447
traphost := {$config['snmpd']['trapserver']}
448
trapport := {$config['snmpd']['trapserverport']}
449
trap := "{$config['snmpd']['trapstring']}"
450

    
451

    
452
EOD;
453
		}
454

    
455

    
456
		$snmpdconf .= <<<EOD
457
system := 1     # pfSense
458
%snmpd
459
begemotSnmpdDebugDumpPdus       = 2
460
begemotSnmpdDebugSyslogPri      = 7
461
begemotSnmpdCommunityString.0.1 = $(read)
462

    
463
EOD;
464

    
465
/* No docs on what write strings do there for disable for now.
466
		if(isset($config['snmpd']['rwcommunity']) && preg_match('/^\S+$/', $config['snmpd']['rwcommunity'])){
467
		    $snmpdconf .= <<<EOD
468
begemotSnmpdCommunityString.0.2 = $(write)
469

    
470
EOD;
471
		}
472
*/
473

    
474
		
475
		if(isset($config['snmpd']['trapenable']) && preg_match('/^\S+$/', $config['snmpd']['trapserver'])){
476
		    $snmpdconf .= <<<EOD
477
begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4
478
begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2
479
begemotTrapSinkComm.[$(traphost)].$(trapport) = $(trap)
480

    
481
EOD;
482
		}
483

    
484

    
485
		$snmpdconf .= <<<EOD
486
begemotSnmpdCommunityDisable    = 1
487
begemotSnmpdPortStatus.0.0.0.0.161 = 1
488
begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1
489
begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4
490

    
491
sysContact      = $(contact)
492
sysLocation     = $(location)
493
sysObjectId     = 1.3.6.1.4.1.12325.1.1.2.1.$(system)
494

    
495
snmpEnableAuthenTraps = 2
496
begemotSnmpdModulePath."mibII"  = "/usr/lib/snmp_mibII.so"
497
begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so"
498
%netgraph
499
begemotNgControlNodeName = "snmpd"
500
begemotSnmpdModulePath."pf"     = "/usr/lib/snmp_pf.so"
501
# config must end with blank line
502

    
503
EOD;
504

    
505
		fwrite($fd, $snmpdconf);
506
		fclose($fd);
507

    
508
		/* run bsnmpd */
509
		mwexec("/usr/sbin/bsnmpd -c {$g['varetc_path']}/snmpd.conf" .
510
			" -p {$g['varrun_path']}/snmpd.pid");		  
511
//		mwexec("/usr/local/sbin/snmpd -c {$g['varetc_path']}/snmpd.conf" .
512
//			" -P {$g['varrun_path']}/snmpd.pid");
513

    
514
		if ($g['booting'])
515
			echo "done.\n";
516
	}
517

    
518
	return 0;
519
}
520

    
521
function services_proxyarp_configure() {
522
	global $config, $g;
523

    
524
	/* kill any running choparp */
525
	killbyname("choparp");
526

    
527
	if (is_array($config['proxyarp']) && count($config['proxyarp'])) {
528

    
529
		$paa = array();
530

    
531
		/* group by interface */
532
		foreach ($config['proxyarp']['proxyarpnet'] as $paent) {
533
			if ($paent['interface'])
534
				$if = $paent['interface'];
535
			else
536
				$if = "wan";
537

    
538
			if (!is_array($paa[$if]))
539
				$paa[$if] = array();
540

    
541
			$paa[$if][] = $paent;
542
		}
543

    
544
		foreach ($paa as $paif => $paents) {
545
			if ($paif == "wan" && !(is_ipaddr($config['interfaces']['wan']['ipaddr']) ||
546
                                       ($config['interfaces']['wan']['ipaddr'] == "dhcp") ||
547
                                       ($config['interfaces']['wan']['ipaddr'] == "bigpond")))
548
                               continue;
549

    
550
			$args = $config['interfaces'][$paif]['if'] . " auto";
551

    
552
			foreach ($paents as $paent) {
553

    
554
				if (isset($paent['network']))
555
					$args .= " " . escapeshellarg($paent['network']);
556
				else if (isset($paent['range']))
557
					$args .= " " . escapeshellarg($paent['range']['from'] . "-" .
558
						$paent['range']['to']);
559
			}
560

    
561
			mwexec_bg("/usr/local/sbin/choparp " . $args);
562
		}
563
	}
564
}
565

    
566
function services_dnsupdate_process() {
567
	global $config, $g;
568
	
569
	/* Dynamic DNS updating active? */
570
	if (isset($config['dnsupdate']['enable'])) {
571
		
572
		$wanip = get_current_wan_address();
573
		if ($wanip) {
574
			
575
			$keyname = $config['dnsupdate']['keyname'];
576
			/* trailing dot */
577
			if (substr($keyname, -1) != ".")
578
				$keyname .= ".";
579
			
580
			$hostname = $config['dnsupdate']['host'];
581
			/* trailing dot */
582
			if (substr($hostname, -1) != ".")
583
				$hostname .= ".";
584
			
585
			/* write private key file
586
			   this is dumb - public and private keys are the same for HMAC-MD5,
587
			   but nsupdate insists on having both */
588
			$fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.private", "w");
589
			$privkey .= <<<EOD
590
Private-key-format: v1.2
591
Algorithm: 157 (HMAC)
592
Key: {$config['dnsupdate']['keydata']}
593

    
594
EOD;
595
			fwrite($fd, $privkey);
596
			fclose($fd);
597
			
598
			/* write public key file */
599
			if ($config['dnsupdate']['keytype'] == "zone") {
600
				$flags = 257;
601
				$proto = 3;
602
			} else if ($config['dnsupdate']['keytype'] == "host") {
603
				$flags = 513;
604
				$proto = 3;
605
			} else if ($config['dnsupdate']['keytype'] == "user") {
606
				$flags = 0;
607
				$proto = 2;
608
			}
609
			
610
			$fd = fopen("{$g['varetc_path']}/K{$keyname}+157+00000.key", "w");
611
			fwrite($fd, "{$keyname} IN KEY {$flags} {$proto} 157 {$config['dnsupdate']['keydata']}\n");
612
			fclose($fd);
613
			
614
			/* generate update instructions */
615
			$upinst =  "update delete {$config['dnsupdate']['host']} A\n";
616
			$upinst .= "update add {$config['dnsupdate']['host']} {$config['dnsupdate']['ttl']} A {$wanip}\n";
617
			$upinst .= "\n";	/* mind that trailing newline! */
618
			
619
			$fd = fopen("{$g['varetc_path']}/nsupdatecmds", "w");
620
			fwrite($fd, $upinst);
621
			fclose($fd);
622
			
623
			/* invoke nsupdate */
624
			$cmd = "/usr/sbin/nsupdate -k {$g['varetc_path']}:{$keyname}";
625
			if (isset($config['dnsupdate']['usetcp']))
626
				$cmd .= " -v";
627
			$cmd .= " {$g['varetc_path']}/nsupdatecmds";
628
			
629
			mwexec_bg($cmd);
630
		}
631
	}
632
	
633
	return 0;
634
}
635

    
636
?>
(14-14/21)