Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
775 stephane 1
<?php
2
/*
3
This class handled of ldap configuration.
4
WARNING! This class can't says if the configuration is valid or not.
5
*/
6
require_once('configreader.php');
7
class siteConfig
8
{
9
	/*
10
	$_sections : radius sections container
11
	*/
12
	protected $_sections = Array();
13
 
14
	public function __construct() {
15
		$this->_sections['authorize']		= new sectionItem('authorize');
16
		$this->_sections['authenticate']	= new sectionItem('authorize');
17
		$this->_sections['preacct']			= new sectionItem('preacct');
18
		$this->_sections['accounting']		= new sectionItem('accounting');
19
		$this->_sections['session']			= new sectionItem('session');
20
		$this->_sections['post-auth']		= new sectionItem('post-auth');
21
		$this->_sections['pre-proxy']		= new sectionItem('pre-proxy');
22
		$this->_sections['post-proxy']		= new sectionItem('post-proxy');
23
	}
24
	private function _doSpace($nbspace = 0){
25
		$resp="";
26
		for ($i = 1; $i <= $nbspace; $i++){
27
			$resp.="	";
28
		}
29
		return $resp;
30
	}	
31
	private function _writeModule($module, $default=null, $space=0){
32
		if (is_object($module)){
33
			if ($module->getType()==='section'){
34
				$resp = $this->_doSpace($space).$module." ".$module->getInstanceName();
35
				if (count($module->getAll())>0){
36
					$resp .= " { \n";
37
					foreach ($module->getAll() as $childItem) {
38
						$resp .= $this->_writeModule($childItem, null, $space+1);
39
					}				
40
					$resp .= $this->_doSpace($space)." } \n";
41
				}	elseif ($module->getInstanceName()!==""){
42
					$resp .= " { \n";
43
					$resp .= "\n";
44
					$resp .= $this->_doSpace($space)." } \n";
45
				} else {
46
					$resp .= "\n";
47
				}
48
				return $resp;
49
			}elseif ($module->getType()==='pair'){
50
				$resp = $this->_doSpace($space).$module->getName()."=";
51
				$resp .=$module->getPair($module->getName());
52
				$resp .="\n";
53
				return $resp;
54
			} else {
55
 
56
			}
57
		} elseif (is_array($module)&&count($module)>0) {
58
			/*
59
			for section width multiple instance
60
			!!! empty section are array too!! we must count the array!
61
			*/
62
			$resp = "";
63
			foreach ($module as $instance) {
64
				$resp .= $this->_doSpace($space). $this->_writeModule($instance, $default, $space);
65
			}
66
			return $resp;
67
		} else {
68
			return $default;
69
		}
70
	}
71
	public function __get($attr){
72
		if (array_key_exists($attr, $this->_sections)){
73
			return $this->_sections[$attr];
74
		}
75
		return false;
76
	}
77
	public function __set($attr, $value){
78
	/*
79
	A FAIRE
80
	*/
81
	}
82
	public function load($confFile){
83
		// use here the parsing class
84
		require_once("configreader.php");
85
 
86
		$r = new configReader($confFile);
87
		$this->_sections['authorize']		= $r->getSection('authorize');
88
		$this->_sections['authenticate']	= $r->getSection('authenticate');
89
		$this->_sections['preacct']			= $r->getSection('preacct');
90
		$this->_sections['accounting']		= $r->getSection('accounting');
91
		$this->_sections['session']			= $r->getSection('session');
92
		$this->_sections['post-auth']		= $r->getSection('post-auth');
93
		$this->_sections['pre-proxy']		= $r->getSection('pre-proxy');
94
		$this->_sections['post-proxy']		= $r->getSection('post-proxy');
95
	}
96
	public function __toString() {
97
		return "siteConfig";
98
	}
99
	public function save($savefile = null, $returnconfig = false){
100
	/*
101
	outpout with template (faster and we can write a lot of comments)
102
	*/
103
	$config = "
104
######################################################################
105
#
106
#	As of 2.0.0, FreeRADIUS supports virtual hosts using the
107
#	\"server\" section, and configuration directives.
108
#
109
#	Virtual hosts should be put into the \"sites-available\"
110
#	directory.  Soft links should be created in the \"sites-enabled\"
111
#	directory to these files.  This is done in a normal installation.
112
#
113
#
114
######################################################################
115
#
116
#	Read \"man radiusd\" before editing this file.  See the section
117
#	titled DEBUGGING.  It outlines a method where you can quickly
118
#	obtain the configuration you want, without running into
119
#	trouble.  See also \"man unlang\", which documents the format
120
#	of this file.
121
#
122
#	This configuration is designed to work in the widest possible
123
#	set of circumstances, with the widest possible number of
124
#	authentication methods.  This means that in general, you should
125
#	need to make very few changes to this file.
126
#
127
#	The best way to configure the server for your local system
128
#	is to CAREFULLY edit this file.  Most attempts to make large
129
#	edits to this file will BREAK THE SERVER.  Any edits should
130
#	be small, and tested by running the server with \"radiusd -X\".
131
#	Once the edits have been verified to work, save a copy of these
132
#	configuration files somewhere.  (e.g. as a \"tar\" file).  Then,
133
#	make more edits, and test, as above.
134
#
135
#	There are many \"commented out\" references to modules such
136
#	as ldap, sql, etc.  These references serve as place-holders.
137
#	If you need the functionality of that module, then configure
138
#	it in radiusd.conf, and un-comment the references to it in
139
#	this file.  In most cases, those small changes will result
140
#	in the server being able to connect to the DB, and to
141
#	authenticate users.
142
#
143
######################################################################
144
 
145
#
146
#	In 1.x, the \"authorize\", etc. sections were global in
147
#	radiusd.conf.  As of 2.0, they SHOULD be in a server section.
148
#
149
#	The server section with no virtual server name is the \"default\"
150
#	section.  It is used when no server name is specified.
151
#
152
#	We don't indent the rest of this file, because doing so
153
#	would make it harder to read.
154
#
155
 
156
#  Authorization. First preprocess (hints and huntgroups files),
157
#  then realms, and finally look in the \"users\" file.
158
#
159
#  The order of the realm modules will determine the order that
160
#  we try to find a matching realm.
161
#
162
#  Make *sure* that 'preprocess' comes before any realm if you
163
#  need to setup hints for the remote radius server
164
authorize {
165
	#
166
	#  The preprocess module takes care of sanitizing some bizarre
167
	#  attributes in the request, and turning them into attributes
168
	#  which are more standard.
169
	#
170
	#  It takes care of processing the 'raddb/hints' and the
171
	#  'raddb/huntgroups' files.
172
	#
173
	#  It also adds the %{Client-IP-Address} attribute to the request.
174
	".$this->_writeModule($this->_sections['authorize']->preprocess, 'preprocess')."
175
 
176
	#
177
	#  If you want to have a log of authentication requests,
178
	#  un-comment the following line, and the 'detail auth_log'
179
	#  section, above.
180
	".$this->_writeModule($this->_sections['authorize']->getSection('auth-log'), '#	auth_log')."
181
	#
182
	#  The chap module will set 'Auth-Type := CHAP' if we are
183
	#  handling a CHAP request and Auth-Type has not already been set
184
".$this->_writeModule($this->_sections['authorize']->chap, '#	chap')."
185
	#
186
	#  If the users are logging in with an MS-CHAP-Challenge
187
	#  attribute for authentication, the mschap module will find
188
	#  the MS-CHAP-Challenge attribute, and add 'Auth-Type := MS-CHAP'
189
	#  to the request, which will cause the server to then use
190
	#  the mschap module for authentication.
191
".$this->_writeModule($this->_sections['authorize']->mschap, '#	mschap')."
192
	#
193
	#  If you have a Cisco SIP server authenticating against
194
	#  FreeRADIUS, uncomment the following line, and the 'digest'
195
	#  line in the 'authenticate' section.
196
".$this->_writeModule($this->_sections['authorize']->digest, '#	digest')."
197
	#
198
	#  Look for IPASS style 'realm/', and if not found, look for
199
	#  '@realm', and decide whether or not to proxy, based on
200
	#  that.
201
".$this->_writeModule($this->_sections['authorize']->IPASS, '#	IPASS')."
202
	#
203
	#  If you are using multiple kinds of realms, you probably
204
	#  want to set \"ignore_null = yes\" for all of them.
205
	#  Otherwise, when the first style of realm doesn't match,
206
	#  the other styles won't be checked.
207
	#
208
".$this->_writeModule($this->_sections['authorize']->suffix, '#	suffix')."
209
".$this->_writeModule($this->_sections['authorize']->ntdomain, '#	ntdomain')."
210
	#
211
	#  This module takes care of EAP-MD5, EAP-TLS, and EAP-LEAP
212
	#  authentication.
213
	#
214
	#  It also sets the EAP-Type attribute in the request
215
	#  attribute list to the EAP type from the packet.
216
	#
217
	#  As of 2.0, the EAP module returns \"ok\" in the authorize stage
218
	#  for TTLS and PEAP.  In 1.x, it never returned \"ok\" here, so
219
	#  this change is compatible with older configurations.
220
	#
221
	#  The example below uses module failover to avoid querying all
222
	#  of the following modules if the EAP module returns \"ok\".
223
	#  Therefore, your LDAP and/or SQL servers will not be queried
224
	#  for the many packets that go back and forth to set up TTLS
225
	#  or PEAP.  The load on those servers will therefore be reduced.
226
	#
227
".$this->_writeModule($this->_sections['authorize']->eap, '#	eap {
228
#		ok = return
229
#	}')."
230
	#
231
	#  Pull crypt'd passwords from /etc/passwd or /etc/shadow,
232
	#  using the system API's to get the password.  If you want
233
	#  to read /etc/passwd or /etc/shadow directly, see the
234
	#  passwd module in radiusd.conf.
235
	#
236
".$this->_writeModule($this->_sections['authorize']->unix, '#	unix')."
237
	#
238
	#  Read the 'users' file
239
".$this->_writeModule($this->_sections['authorize']->files, '#	files')."
240
	#
241
	#  Look in an SQL database.  The schema of the database
242
	#  is meant to mirror the \"users\" file.
243
	#
244
	#  See \"Authorization Queries\" in sql.conf
245
	".$this->_writeModule($this->_sections['authorize']->sql, 'sql')."
246
	".$this->_writeModule($this->_sections['authorize']->noresetcounter, 'noresetcounter')."
247
	".$this->_writeModule($this->_sections['authorize']->dailycounter, 'dailycounter')."
248
	".$this->_writeModule($this->_sections['authorize']->monthlycounter, 'monthlycounter')."
249
	#
250
	#  If you are using /etc/smbpasswd, and are also doing
251
	#  mschap authentication, the un-comment this line, and
252
	#  configure the 'etc_smbpasswd' module, above.
253
".$this->_writeModule($this->_sections['authorize']->etc_smbpasswd, '#	etc_smbpasswd')."
254
	#
255
	#  The ldap module will set Auth-Type to LDAP if it has not
256
	#  already been set
257
".$this->_writeModule($this->_sections['authorize']->ldap, '#	ldap {
258
#		fail = 1
259
#	}')."
260
	#
261
	#  Enforce daily limits on time spent logged in.
262
".$this->_writeModule($this->_sections['authorize']->daily, '#	daily')."
263
	#
264
	# Use the checkval modulel
265
".$this->_writeModule($this->_sections['authorize']->checkval, '#	checkval')."
266
	".$this->_writeModule($this->_sections['authorize']->expiration, 'expiration')."
267
".$this->_writeModule($this->_sections['authorize']->logintime, 'logintime')."
268
	#
269
	#  If no other module has claimed responsibility for
270
	#  authentication, then try to use PAP.  This allows the
271
	#  other modules listed above to add a \"known good\" password
272
	#  to the request, and to do nothing else.  The PAP module
273
	#  will then see that password, and use it to do PAP
274
	#  authentication.
275
	#
276
	#  This module should be listed last, so that the other modules
277
	#  get a chance to set Auth-Type for themselves.
278
	#
279
".$this->_writeModule($this->_sections['authorize']->pap, '#	pap')."
280
	#
281
	#  If \"status_server = yes\", then Status-Server messages are passed
282
	#  through the following section, and ONLY the following section.
283
	#  This permits you to do DB queries, for example.  If the modules
284
	#  listed here return \"fail\", then NO response is sent.
285
	#
286
".$this->_writeModule($this->_sections['authorize']->getSection('Autz-Type'), '#	Autz-Type Status-Server {
287
#
288
#	}')."
289
 
290
}
291
 
292
 
293
#  Authentication.
294
#
295
#
296
#  This section lists which modules are available for authentication.
297
#  Note that it does NOT mean 'try each module in order'.  It means
298
#  that a module from the 'authorize' section adds a configuration
299
#  attribute 'Auth-Type := FOO'.  That authentication type is then
300
#  used to pick the apropriate module from the list below.
301
#
302
 
303
#  In general, you SHOULD NOT set the Auth-Type attribute.  The server
304
#  will figure it out on its own, and will do the right thing.  The
305
#  most common side effect of erroneously setting the Auth-Type
306
#  attribute is that one authentication method will work, but the
307
#  others will not.
308
#
309
#  The common reasons to set the Auth-Type attribute by hand
310
#  is to either forcibly reject the user (Auth-Type := Reject),
311
#  or to or forcibly accept the user (Auth-Type := Accept).
312
#
313
#  Note that Auth-Type := Accept will NOT work with EAP.
314
#
315
#  Please do not put \"unlang\" configurations into the \"authenticate\"
316
#  section.  Put them in the \"post-auth\" section instead.  That's what
317
#  the post-auth section is for.
318
#
319
authenticate {
320
#	#
321
#	#  PAP authentication, when a back-end database listed
322
#	#  in the 'authorize' section supplies a password.  The
323
#	#  password can be clear-text, or encrypted.
324
".$this->_writeModule($this->_sections['authenticate']->getSectionInstance('Auth-Type','PAP'), '#	Auth-Type PAP {
325
#		pap
326
#	}')."
327
#
328
#	#
329
#	#  Most people want CHAP authentication
330
#	#  A back-end database listed in the 'authorize' section
331
#	#  MUST supply a CLEAR TEXT password.  Encrypted passwords
332
#	#  won't work.
333
".$this->_writeModule($this->_sections['authenticate']->getSectionInstance('Auth-Type','CHAP'), '#	Auth-Type CHAP {
334
#		chap
335
#	}')."
336
#
337
#	#
338
#	#  MSCHAP authentication.
339
".$this->_writeModule($this->_sections['authenticate']->getSectionInstance('Auth-Type','MS-CHAP'), '#	Auth-Type MS-CHAP {
340
#		mschap
341
#	}')."
342
#
343
#	#
344
#	#  If you have a Cisco SIP server authenticating against
345
#	#  FreeRADIUS, uncomment the following line, and the 'digest'
346
#	#  line in the 'authorize' section.
347
".$this->_writeModule($this->_sections['authenticate']->digest, '#	digest')."
348
#
349
#	#
350
#	#  Pluggable Authentication Modules.
351
".$this->_writeModule($this->_sections['authenticate']->pam, '#	pam')."
352
#
353
#	#
354
#	#  See 'man getpwent' for information on how the 'unix'
355
#	#  module checks the users password.  Note that packets
356
#	#  containing CHAP-Password attributes CANNOT be authenticated
357
#	#  against /etc/passwd!  See the FAQ for details.
358
#	#
359
".$this->_writeModule($this->_sections['authenticate']->unix, '#	unix')."
360
#
361
#	# Uncomment it if you want to use ldap for authentication
362
#	#
363
#	# Note that this means \"check plain-text password against
364
#	# the ldap database\", which means that EAP won't work,
365
#	# as it does not supply a plain-text password.
366
".$this->_writeModule($this->_sections['authenticate']->getSectionInstance('Auth-Type','LDAP'), '#	Auth-Type LDAP {
367
#		ldap
368
#	}')."
369
#
370
#	#
371
#	#  Allow EAP authentication.
372
".$this->_writeModule($this->_sections['authenticate']->eap, '#	eap')."
373
}
374
 
375
 
376
#
377
#  Pre-accounting.  Decide which accounting type to use.
378
#
379
preacct {
380
	".$this->_writeModule($this->_sections['preacct']->preprocess, '#	preprocess')."
381
 
382
	#
383
	#  Ensure that we have a semi-unique identifier for every
384
	#  request, and many NAS boxes are broken.
385
".$this->_writeModule($this->_sections['preacct']->acct_unique, '#	acct_unique')."
386
 
387
	#
388
	#  Look for IPASS-style 'realm/', and if not found, look for
389
	#  '@realm', and decide whether or not to proxy, based on
390
	#  that.
391
	#
392
	#  Accounting requests are generally proxied to the same
393
	#  home server as authentication requests.
394
".$this->_writeModule($this->_sections['preacct']->IPASS, '#	IPASS')."
395
".$this->_writeModule($this->_sections['preacct']->suffix, '#	suffix')."
396
".$this->_writeModule($this->_sections['preacct']->ntdomain, '#	ntdomain')."
397
 
398
	#
399
	#  Read the 'acct_users' file
400
".$this->_writeModule($this->_sections['preacct']->files, '#	files')."
401
}
402
 
403
#
404
#  Accounting.  Log the accounting data.
405
#
406
accounting {
407
	#
408
	#  Create a 'detail'ed log of the packets.
409
	#  Note that accounting requests which are proxied
410
	#  are also logged in the detail file.
411
".$this->_writeModule($this->_sections['accounting']->detail, '#	detail')."
412
".$this->_writeModule($this->_sections['accounting']->daily, '#	daily')."
413
 
414
	#  Update the wtmp file
415
	#
416
	#  If you don't use \"radlast\", you can delete this line.
417
".$this->_writeModule($this->_sections['accounting']->unix, '#	unix')."
418
 
419
	#
420
	#  For Simultaneous-Use tracking.
421
	#
422
	#  Due to packet losses in the network, the data here
423
	#  may be incorrect.  There is little we can do about it.
424
".$this->_writeModule($this->_sections['accounting']->radutmp, '#	radutmp')."
425
	".$this->_writeModule($this->_sections['accounting']->sradutmp, 'sradutmp')."
426
 
427
	#  Return an address to the IP Pool when we see a stop record.
428
".$this->_writeModule($this->_sections['accounting']->main_pool, '#	main_pool')."
429
 
430
	#
431
	#  Log traffic to an SQL database.
432
	#
433
	#  See \"Accounting queries\" in sql.conf
434
	".$this->_writeModule($this->_sections['accounting']->sql, 'sql')."
435
 
436
	#
437
	#  Instead of sending the query to the SQL server,
438
	#  write it into a log file.
439
	#
440
".$this->_writeModule($this->_sections['accounting']->sql_log, '#	sql_log')."
441
 
442
	#  Cisco VoIP specific bulk accounting
443
".$this->_writeModule($this->_sections['accounting']->getSection('pgsql-voip'), '#	pgsql-voip')."
444
 
445
	#  Filter attributes from the accounting response.
446
	".$this->_writeModule($this->_sections['accounting']->getSection('attr_filter.accounting_response'), 'attr_filter.accounting_response')."
447
 
448
	#
449
	#  See \"Autz-Type Status-Server\" for how this works.
450
	#
451
".$this->_writeModule($this->_sections['accounting']->getSectionInstance('Acct-Type','Status-Server'), '#	Acct-Type Status-Server {
452
#
453
#	}')."
454
 
455
}
456
 
457
 
458
#  Session database, used for checking Simultaneous-Use. Either the radutmp
459
#  or rlm_sql module can handle this.
460
#  The rlm_sql module is *much* faster
461
session {
462
".$this->_writeModule($this->_sections['session']->radutmp, '#	radutmp')."
463
 
464
	#
465
	#  See \"Simultaneous Use Checking Queries\" in sql.conf
466
	".$this->_writeModule($this->_sections['session']->sql, '#	sql')."
467
}
468
 
469
 
470
#  Post-Authentication
471
#  Once we KNOW that the user has been authenticated, there are
472
#  additional steps we can take.
473
post-auth {
474
	#  Get an address from the IP Pool.
475
".$this->_writeModule($this->_sections['post-auth']->main_pool, '#	main_pool')."
476
 
477
	#
478
	#  If you want to have a log of authentication replies,
479
	#  un-comment the following line, and the 'detail reply_log'
480
	#  section, above.
481
".$this->_writeModule($this->_sections['post-auth']->reply_log, '#	reply_log')."
482
 
483
	#
484
	#  After authenticating the user, do another SQL query.
485
	#
486
	#  See \"Authentication Logging Queries\" in sql.conf
487
".$this->_writeModule($this->_sections['post-auth']->sql, '#	sql')."
488
 
489
	#
490
	#  Instead of sending the query to the SQL server,
491
	#  write it into a log file.
492
	#
493
".$this->_writeModule($this->_sections['post-auth']->sql_log, '#	sql_log')."
494
 
495
	#
496
	#  Un-comment the following if you have set
497
	#  'edir_account_policy_check = yes' in the ldap module sub-section of
498
	#  the 'modules' section.
499
	#
500
".$this->_writeModule($this->_sections['post-auth']->ldap, '#	ldap')."
501
 
502
".$this->_writeModule($this->_sections['post-auth']->exec, '#	exec')."
503
 
504
	#
505
	#  Access-Reject packets are sent through the REJECT sub-section of the
506
	#  post-auth section.
507
	#
508
	#  Add the ldap module name (or instance) if you have set
509
	#  'edir_account_policy_check = yes' in the ldap module configuration
510
	#
511
	Post-Auth-Type REJECT {
512
		attr_filter.access_reject
513
	}
514
	".$this->_writeModule($this->_sections['post-auth']->files, '#	files')."
515
}
516
 
517
#
518
#  When the server decides to proxy a request to a home server,
519
#  the proxied request is first passed through the pre-proxy
520
#  stage.  This stage can re-write the request, or decide to
521
#  cancel the proxy.
522
#
523
#  Only a few modules currently have this method.
524
#
525
pre-proxy {
526
".$this->_writeModule($this->_sections['preacct']->attr_rewrite, '#	attr_rewrite')."
527
 
528
	#  Uncomment the following line if you want to change attributes
529
	#  as defined in the preproxy_users file.
530
".$this->_writeModule($this->_sections['preacct']->files, '#	files')."
531
 
532
	#  Uncomment the following line if you want to filter requests
533
	#  sent to remote servers based on the rules defined in the
534
	#  'attrs.pre-proxy' file.
535
".$this->_writeModule($this->_sections['preacct']->getSection('attr_filter.pre-proxy'), '#	attr_filter.pre-proxy')."
536
 
537
	#  If you want to have a log of packets proxied to a home
538
	#  server, un-comment the following line, and the
539
	#  'detail pre_proxy_log' section, above.
540
".$this->_writeModule($this->_sections['preacct']->pre_proxy_log, '#	pre_proxy_log')."
541
}
542
 
543
#
544
#  When the server receives a reply to a request it proxied
545
#  to a home server, the request may be massaged here, in the
546
#  post-proxy stage.
547
#
548
post-proxy {
549
 
550
	#  If you want to have a log of replies from a home server,
551
	#  un-comment the following line, and the 'detail post_proxy_log'
552
	#  section, above.
553
".$this->_writeModule($this->_sections['post-proxy']->post_proxy_log, '#	post_proxy_log')."
554
 
555
".$this->_writeModule($this->_sections['post-proxy']->attr_rewrite, '#	attr_rewrite')."
556
 
557
	#  Uncomment the following line if you want to filter replies from
558
	#  remote proxies based on the rules defined in the 'attrs' file.
559
".$this->_writeModule($this->_sections['post-proxy']->getSection('attr_filter.post-proxy'), '#	attr_filter.post-proxy')."
560
 
561
	#
562
	#  If you are proxying LEAP, you MUST configure the EAP
563
	#  module, and you MUST list it here, in the post-proxy
564
	#  stage.
565
	#
566
	#  You MUST also use the 'nostrip' option in the 'realm'
567
	#  configuration.  Otherwise, the User-Name attribute
568
	#  in the proxied request will not match the user name
569
	#  hidden inside of the EAP packet, and the end server will
570
	#  reject the EAP request.
571
	#
572
".$this->_writeModule($this->_sections['post-proxy']->eap, '#	eap')."
573
 
574
	#
575
	#  If the server tries to proxy a request and fails, then the
576
	#  request is processed through the modules in this section.
577
	#
578
	#  The main use of this section is to permit robust proxying
579
	#  of accounting packets.  The server can be configured to
580
	#  proxy accounting packets as part of normal processing.
581
	#  Then, if the home server goes down, accounting packets can
582
	#  be logged to a local \"detail\" file, for processing with
583
	#  radrelay.  When the home server comes back up, radrelay
584
	#  will read the detail file, and send the packets to the
585
	#  home server.
586
	#
587
	#  With this configuration, the server always responds to
588
	#  Accounting-Requests from the NAS, but only writes
589
	#  accounting packets to disk if the home server is down.
590
	#
591
".$this->_writeModule($this->_sections['post-proxy']->getSection('Post-Proxy-Type'), '#	Post-Proxy-Type Fail {
592
#			detail
593
#	}')."
594
 
595
}";
596
 
597
		if ($savefile !== null){
598
			// save config file
599
			if (is_file($savefile)){
600
				// save the file
601
				if (!is_writable($savefile))
602
					return false;
603
				$updatedFile = fopen( $savefile, 'w' );
604
				fwrite( $updatedFile, $config );
605
				fclose( $updatedFile );
606
			} else {
607
				// create a new file
608
				$newFile = fopen($savefile, 'w') or die("can't create file");
609
				fwrite( $newFile, $config );
610
				fclose( $newFile );
611
			}
612
		}	
613
		// test $returnconfig
614
		if ($returnconfig){
615
			return $config;
616
		}else{
617
			return true;
618
		}
619
	}
620
}