Project

General

Profile

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

    
7
    Copyright (C) 2008 Shrew Soft Inc.
8
    All rights reserved.
9

    
10
    Copyright (C) 2005 Paul Taylor <paultaylor@winn-dixie.com>.
11
    All rights reserved.
12

    
13
    Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
14
    All rights reserved.
15

    
16
    Redistribution and use in source and binary forms, with or without
17
    modification, are permitted provided that the following conditions are met:
18

    
19
    1. Redistributions of source code must retain the above copyright notice,
20
       this list of conditions and the following disclaimer.
21

    
22
    2. Redistributions in binary form must reproduce the above copyright
23
       notice, this list of conditions and the following disclaimer in the
24
       documentation and/or other materials provided with the distribution.
25

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

    
42
##|+PRIV
43
##|*IDENT=page-system-usermanager
44
##|*NAME=System: User Manager page
45
##|*DESCR=Allow access to the 'System: User Manager' page.
46
##|*MATCH=system_usermanager.php*
47
##|-PRIV
48

    
49
require("certs.inc");
50
require("guiconfig.inc");
51

    
52
if (isAllowedPage("system_usermanager.php*")) {
53

    
54
	// start admin user code
55
	$pgtitle = array(gettext("System"),gettext("User Manager"));
56

    
57
	$id = $_GET['id'];
58
	if (isset($_POST['id']))
59
		$id = $_POST['id'];
60

    
61
	if (!is_array($config['system']['user'])) 
62
		$config['system']['user'] = array();
63

    
64
	$a_user = &$config['system']['user'];
65

    
66
	if ($_GET['act'] == "deluser") {
67

    
68
		if (!$a_user[$id]) {
69
			pfSenseHeader("system_usermanager.php");
70
			exit;
71
		}
72

    
73
		local_user_del($a_user[$id]);
74
		$userdeleted = $a_user[$id]['name'];
75
		unset($a_user[$id]);
76
		write_config();
77
		$savemsg = gettext("User")." {$userdeleted} ".
78
					gettext("successfully deleted")."<br/>";
79
	}
80

    
81
	if ($_GET['act'] == "delpriv") {
82

    
83
		if (!$a_user[$id]) {
84
			pfSenseHeader("system_usermanager.php");
85
			exit;
86
		}
87

    
88
		$privdeleted = $priv_list[$a_user[$id]['priv'][$_GET['privid']]]['name'];
89
		unset($a_user[$id]['priv'][$_GET['privid']]);
90
		local_user_set($a_user[$id]);
91
		write_config();
92
		$_GET['act'] = "edit";
93
		$savemsg = gettext("Privilege")." {$privdeleted} ".
94
					gettext("successfully deleted")."<br/>";
95
	}
96

    
97
	if ($_GET['act'] == "expcert") {
98

    
99
		if (!$a_user[$id]) {
100
			pfSenseHeader("system_usermanager.php");
101
			exit;
102
		}
103

    
104
		$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
105

    
106
		$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.crt");
107
		$exp_data = base64_decode($cert['crt']);
108
		$exp_size = strlen($exp_data);
109

    
110
		header("Content-Type: application/octet-stream");
111
		header("Content-Disposition: attachment; filename={$exp_name}");
112
		header("Content-Length: $exp_size");
113
		echo $exp_data;
114
		exit;
115
	}
116

    
117
	if ($_GET['act'] == "expckey") {
118

    
119
		if (!$a_user[$id]) {
120
			pfSenseHeader("system_usermanager.php");
121
			exit;
122
		}
123

    
124
		$cert =& lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
125

    
126
		$exp_name = urlencode("{$a_user[$id]['name']}-{$cert['descr']}.key");
127
		$exp_data = base64_decode($cert['prv']);
128
		$exp_size = strlen($exp_data);
129

    
130
		header("Content-Type: application/octet-stream");
131
		header("Content-Disposition: attachment; filename={$exp_name}");
132
		header("Content-Length: $exp_size");
133
		echo $exp_data;
134
		exit;
135
	}
136

    
137
	if ($_GET['act'] == "delcert") {
138

    
139
		if (!$a_user[$id]) {
140
			pfSenseHeader("system_usermanager.php");
141
			exit;
142
		}
143

    
144
		$certdeleted = lookup_cert($a_user[$id]['cert'][$_GET['certid']]);
145
		$certdeleted = $certdeleted['descr'];
146
		unset($a_user[$id]['cert'][$_GET['certid']]);
147
		write_config();
148
		$_GET['act'] = "edit";
149
		$savemsg = gettext("Certificate")." {$certdeleted} ".
150
					gettext("association removed.")."<br/>";
151
	}
152

    
153
	if ($_GET['act'] == "edit") {
154
		if (isset($id) && $a_user[$id]) {
155
			$pconfig['usernamefld'] = $a_user[$id]['name'];
156
			$pconfig['descr'] = $a_user[$id]['descr'];
157
			$pconfig['expires'] = $a_user[$id]['expires'];
158
			$pconfig['groups'] = local_user_get_groups($a_user[$id]);
159
			$pconfig['utype'] = $a_user[$id]['scope'];
160
			$pconfig['uid'] = $a_user[$id]['uid'];
161
			$pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
162
			$pconfig['priv'] = $a_user[$id]['priv'];
163
			$pconfig['ipsecpsk'] = $a_user[$id]['ipsecpsk'];
164
			$pconfig['disabled'] = isset($a_user[$id]['disabled']);
165
		}
166
	}
167

    
168
	if ($_GET['act'] == "new") {
169
		/*
170
		 * set this value cause the text field is read only
171
		 * and the user should not be able to mess with this
172
		 * setting.
173
		 */
174
		$pconfig['utype'] = "user";
175
		$pconfig['lifetime'] = 3650;
176
	}
177

    
178
	if ($_POST) {
179
		unset($input_errors);
180
		$pconfig = $_POST;
181

    
182
		/* input validation */
183
		if (isset($id) && ($a_user[$id])) {
184
			$reqdfields = explode(" ", "usernamefld");
185
			$reqdfieldsn = array(gettext("Username"));
186
		} else {
187
			if (empty($_POST['name'])) {
188
				$reqdfields = explode(" ", "usernamefld passwordfld1");
189
				$reqdfieldsn = array(
190
					gettext("Username"),
191
					gettext("Password"));
192
			} else {
193
				$reqdfields = explode(" ", "usernamefld passwordfld1 name caref keylen lifetime");
194
				$reqdfieldsn = array(
195
					gettext("Username"),
196
					gettext("Password"),
197
					gettext("Descriptive name"),
198
					gettext("Certificate authority"),
199
					gettext("Key length"),
200
					gettext("Lifetime"));
201
			}
202
		}
203

    
204
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
205

    
206
		if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
207
			$input_errors[] = gettext("The username contains invalid characters.");
208

    
209
		if (strlen($_POST['usernamefld']) > 16)
210
			$input_errors[] = gettext("The username is longer than 16 characters.");
211

    
212
		if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
213
			$input_errors[] = gettext("The passwords do not match.");
214

    
215
		if (isset($id) && $a_user[$id])
216
			$oldusername = $a_user[$id]['name'];
217
		else
218
			$oldusername = "";
219
		/* make sure this user name is unique */
220
		if (!$input_errors) {
221
			foreach ($a_user as $userent) {
222
				if ($userent['name'] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
223
					$input_errors[] = gettext("Another entry with the same username already exists.");
224
					break;
225
				}
226
			}
227
		}
228
		/* also make sure it is not reserved */
229
		if (!$input_errors) {
230
			$system_users = explode("\n", file_get_contents("/etc/passwd"));
231
			foreach ($system_users as $s_user) {
232
				$ent = explode(":", $s_user);
233
				if ($ent[0] == $_POST['usernamefld'] && $oldusername != $_POST['usernamefld']) {
234
					$input_errors[] = gettext("That username is reserved by the system.");
235
					break;
236
				}
237
			}
238
		}
239

    
240
		/*
241
		 * Check for a valid expirationdate if one is set at all (valid means,
242
		 * strtotime() puts out a time stamp so any strtotime compatible time
243
		 * format may be used. to keep it simple for the enduser, we only
244
		 * claim to accept MM/DD/YYYY as inputs. Advanced users may use inputs
245
		 * like "+1 day", which will be converted to MM/DD/YYYY based on "now".
246
		 * Otherwhise such an entry would lead to an invalid expiration data.
247
		 */
248
		if ($_POST['expires']){
249
			if(strtotime($_POST['expires']) > 0){
250
				if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($_POST['expires'])))) {
251
					// Allow items to lie in the past which ends up disabling.
252
				} else {
253
					//convert from any strtotime compatible date to MM/DD/YYYY
254
					$expdate = strtotime($_POST['expires']);
255
					$_POST['expires'] = date("m/d/Y",$expdate);
256
				}
257
			} else {
258
				$input_errors[] = gettext("Invalid expiration date format; use MM/DD/YYYY instead.");
259
			}
260
		}
261

    
262
		if (!empty($_POST['name'])) {
263
			$ca = lookup_ca($_POST['caref']);
264
        		if (!$ca)
265
                		$input_errors[] = gettext("Invalid internal Certificate Authority") . "\n";
266
		}
267

    
268
		/* if this is an AJAX caller then handle via JSON */
269
		if (isAjax() && is_array($input_errors)) {
270
			input_errors2Ajax($input_errors);
271
			exit;
272
		}
273

    
274
		if (!$input_errors) {
275
			conf_mount_rw();
276
			$userent = array();
277
			if (isset($id) && $a_user[$id])
278
				$userent = $a_user[$id];
279

    
280
			isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
281

    
282
			/* the user name was modified */
283
			if ($_POST['usernamefld'] <> $_POST['oldusername'])
284
				$_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
285

    
286
			/* the user password was mofified */
287
			if ($_POST['passwordfld1'])
288
				local_user_set_password($userent, $_POST['passwordfld1']);
289

    
290
			$userent['name'] = $_POST['usernamefld'];
291
			$userent['descr'] = $_POST['descr'];
292
			$userent['expires'] = $_POST['expires'];
293
			$userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
294
			$userent['ipsecpsk'] = $_POST['ipsecpsk'];
295
			
296
			if($_POST['disabled'])
297
				$userent['disabled'] = true;
298
			else 
299
				unset($userent['disabled']);
300

    
301
			if (isset($id) && $a_user[$id])
302
				$a_user[$id] = $userent;
303
			else {
304
				if (!empty($_POST['name'])) {
305
					$cert = array();
306
					$cert['refid'] = uniqid();
307
                        		$userent['cert'] = array();
308

    
309
					$cert['descr'] = $_POST['name'];
310

    
311
                			$subject = cert_get_subject_array($ca['crt']);
312

    
313
                			$dn = array(
314
                        			'countryName' => $subject[0]['v'],
315
                        			'stateOrProvinceName' => $subject[1]['v'],
316
                        			'localityName' => $subject[2]['v'],
317
                        			'organizationName' => $subject[3]['v'],
318
                        			'emailAddress' => $subject[4]['v'],
319
                        			'commonName' => $userent['name']);
320

    
321
					cert_create($cert, $_POST['caref'], $_POST['keylen'],
322
						(int)$_POST['lifetime'], $dn);
323

    
324
					if (!is_array($config['cert']))
325
						$config['cert'] = array();
326
					$config['cert'][] = $cert;
327
					$userent['cert'][] = $cert['refid'];
328
				}
329
				$userent['uid'] = $config['system']['nextuid']++;
330
				/* Add the user to All Users group. */
331
				foreach ($config['system']['group'] as $gidx => $group) {
332
					if ($group['name'] == "all") {
333
						if (!is_array($config['system']['group'][$gidx]['member']))
334
							$config['system']['group'][$gidx]['member'] = array();
335
						$config['system']['group'][$gidx]['member'][] = $userent['uid'];
336
						break;
337
					}
338
				}
339

    
340
				$a_user[] = $userent;
341
			}
342

    
343
			local_user_set_groups($userent,$_POST['groups']);
344
			local_user_set($userent);
345
			write_config();
346

    
347
			if(is_dir("/etc/inc/privhooks"))
348
				run_plugins("/etc/inc/privhooks");
349

    
350
			conf_mount_ro();
351
			
352
			pfSenseHeader("system_usermanager.php");
353
		}
354
	}
355

    
356
	include("head.inc");
357
?>
358

    
359
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
360
<?php include("fbegin.inc"); ?>
361
<!--
362
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
363
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
364
//For this script, visit http://www.javascriptkit.com
365
// -->
366
<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js"></script>
367
<script language="JavaScript">
368
<!--
369

    
370
function setall_selected(id) {
371
	selbox = document.getElementById(id);
372
	count = selbox.options.length;
373
	for (index = 0; index<count; index++)
374
		selbox.options[index].selected = true;
375
}
376

    
377
function clear_selected(id) {
378
	selbox = document.getElementById(id);
379
	count = selbox.options.length;
380
	for (index = 0; index<count; index++)
381
		selbox.options[index].selected = false;
382
}
383

    
384
function remove_selected(id) {
385
	selbox = document.getElementById(id);
386
	index = selbox.options.length - 1;
387
	for (; index >= 0; index--)
388
		if (selbox.options[index].selected)
389
			selbox.remove(index);
390
}
391

    
392
function copy_selected(srcid, dstid) {
393
	src_selbox = document.getElementById(srcid);
394
	dst_selbox = document.getElementById(dstid);
395
	count = src_selbox.options.length;
396
	for (index = 0; index < count; index++) {
397
		if (src_selbox.options[index].selected) {
398
			option = document.createElement('option');
399
			option.text = src_selbox.options[index].text;
400
			option.value = src_selbox.options[index].value;
401
			dst_selbox.add(option, null);
402
		}
403
	}
404
}
405

    
406
function move_selected(srcid, dstid) {
407
	copy_selected(srcid, dstid);
408
	remove_selected(srcid);
409
}
410

    
411
function presubmit() {
412
	clear_selected('notgroups');
413
	setall_selected('groups');
414
}
415

    
416
function usercertClicked(obj) {
417
	if (obj.checked) {
418
		document.getElementById("usercertchck").style.display="none";
419
		document.getElementById("usercert").style.display="";
420
	} else {
421
		document.getElementById("usercert").style.display="none";
422
		document.getElementById("usercertchck").style.display="";
423
	}
424
}
425

    
426
function sshkeyClicked(obj) {
427
        if (obj.checked) {
428
                document.getElementById("sshkeychck").style.display="none";
429
                document.getElementById("sshkey").style.display="";
430
        } else {
431
                document.getElementById("sshkey").style.display="none";
432
                document.getElementById("sshkeychck").style.display="";
433
        }
434
}
435
//-->
436
</script>
437
<?php
438
	if ($input_errors)
439
		print_input_errors($input_errors);
440
	if ($savemsg)
441
		print_info_box($savemsg);
442
?>
443
<table width="100%" border="0" cellpadding="0" cellspacing="0">
444
	<tr>
445
		<td>
446
		<?php
447
			$tab_array = array();
448
			$tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
449
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
450
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
451
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
452
			display_top_tabs($tab_array);
453
		?>
454
		</td>
455
	</tr>
456
	<tr>
457
		<td id="mainarea">
458
			<div class="tabcont">
459

    
460
				<?php if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors): ?>
461

    
462
				<form action="system_usermanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
463
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
464
						<?php
465
							$ro = "";
466
							if ($pconfig['utype'] == "system")
467
								$ro = "readonly = \"readonly\"";
468
						?>
469
	                    <tr>
470
	                        <td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
471
	                        <td width="78%" class="vtable">
472
	                            <strong><?=strtoupper($pconfig['utype']);?></strong>
473
								<input name="utype" type="hidden" value="<?=htmlspecialchars($pconfig['utype'])?>"/>
474
	                        </td>
475
	                    </tr>
476
						<tr>
477
							<td width="22%" valign="top" class="vncell"><?=gettext("Disabled");?></td>
478
							<td width="78%" class="vtable">
479
								<input name="disabled" type="checkbox" id="disabled" <?php if($pconfig['disabled']) echo "CHECKED"; ?>>
480
							</td>
481
						</tr>
482
						<tr>
483
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
484
							<td width="78%" class="vtable">
485
								<input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" maxlength="16" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
486
								<input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
487
							</td>
488
						</tr>
489
						<tr>
490
							<td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
491
							<td width="78%" class="vtable">
492
								<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
493
							</td>
494
						</tr>
495
						<tr>
496
							<td width="78%" class="vtable">
497
								<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
498
							</td>
499
						</tr>
500
						<tr>
501
							<td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
502
							<td width="78%" class="vtable">
503
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>" <?=$ro;?>/>
504
								<br/>
505
								<?=gettext("User's full name, for your own information only");?>
506
							</td>
507
						</tr>
508
						<tr>
509
							<td width="22%" valign="top" class="vncell"><?=gettext("Expiration date"); ?></td>
510
							<td width="78%" class="vtable">
511
								<input name="expires" type="text" class="formfld unknown" id="expires" size="10" value="<?=htmlspecialchars($pconfig['expires']);?>">
512
								<a href="javascript:NewCal('expires','mmddyyyy')">
513
									<img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_cal.gif" width="16" height="16" border="0" alt="<?=gettext("Pick a date");?>">
514
								</a>
515
								<br>
516
								<span class="vexpl"><?=gettext("Leave blank if the account shouldn't expire, otherwise enter the expiration date in the following format: mm/dd/yyyy"); ?></span></td>
517
						</tr>
518
						<tr>
519
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
520
							<td width="78%" class="vtable" align="center">
521
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
522
									<tr>
523
										<td align="center" width="50%">
524
											<strong><?=gettext("Not Member Of"); ?></strong><br/>
525
											<br/>
526
											<select size="10" style="width: 75%" name="notgroups[]" class="formselect" id="notgroups" onChange="clear_selected('groups')" multiple>
527
												<?php
528
													foreach ($config['system']['group'] as $group):
529
														if ($group['gid'] == 1998) /* all users group */
530
															continue;
531
														if (is_array($pconfig['groups']) && in_array($group['name'],$pconfig['groups']))
532
															continue;
533
												?>
534
												<option value="<?=$group['name'];?>" <?=$selected;?>>
535
													<?=htmlspecialchars($group['name']);?>
536
												</option>
537
												<?php endforeach; ?>
538
											</select>
539
											<br/>
540
										</td>
541
										<td>
542
											<br/>
543
											<a href="javascript:move_selected('notgroups','groups')">
544
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_right.gif" title="<?=gettext("Add Groups"); ?>" alt="<?=gettext("Add Groups"); ?>" width="17" height="17" border="0" />
545
											</a>
546
											<br/><br/>
547
											<a href="javascript:move_selected('groups','notgroups')">
548
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_left.gif" title="<?=gettext("Remove Groups"); ?>" alt="<?=gettext("Remove Groups"); ?>" width="17" height="17" border="0" />
549
											</a>
550
										</td>
551
										<td align="center" width="50%">
552
											<strong><?=gettext("Member Of"); ?></strong><br/>
553
											<br/>
554
											<select size="10" style="width: 75%" name="groups[]" class="formselect" id="groups" onChange="clear_selected('nogroups')" multiple>
555
												<?php
556
												if (is_array($pconfig['groups'])) {
557
													foreach ($config['system']['group'] as $group):
558
														if ($group['gid'] == 1998) /* all users group */
559
															continue;
560
														if (!in_array($group['name'],$pconfig['groups']))
561
															continue;
562
												?>
563
												<option value="<?=$group['name'];?>">
564
													<?=htmlspecialchars($group['name']);?>
565
												</option>
566
												<?php endforeach;
567
												} ?>
568
											</select>
569
											<br/>
570
										</td>
571
									</tr>
572
								</table>
573
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
574
							</td>
575
						</tr>
576

    
577
						<?php if ($pconfig['uid']): ?>
578

    
579
						<tr>
580
							<td width="22%" valign="top" class="vncell"><?=gettext("Effective Privileges");?></td>
581
							<td width="78%" class="vtable">
582
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
583
									<tr>
584
										<td width="20%" class="listhdrr"><?=gettext("Inherited From");?></td>
585
										<td width="30%" class="listhdrr"><?=gettext("Name");?></td>
586
										<td width="40%" class="listhdrr"><?=gettext("Description");?></td>
587
										<td class="list"></td>
588
									</tr>
589
									<?php
590
											
591
										$privdesc = get_user_privdesc($a_user[$id]);
592
										if(is_array($privdesc)):
593
											$i = 0;
594
											foreach ($privdesc as $priv):
595
											$group = false;
596
											if ($priv['group'])
597
												$group = $priv['group'];
598
									?>
599
									<tr>
600
										<td class="listlr"><?=$group;?></td>
601
										<td class="listr">
602
											<?=htmlspecialchars($priv['name']);?>
603
										</td>
604
										<td class="listbg">
605
												<?=htmlspecialchars($priv['descr']);?>
606
										</td>
607
										<td valign="middle" nowrap class="list">
608
											<?php if (!$group): ?>
609
											<a href="system_usermanager.php?act=delpriv&id=<?=$id?>&privid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this privilege?");?>')">
610
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
611
											</a>
612
											<?php endif; ?>
613
										</td>
614
									</tr>
615
									<?php
616
											/* can only delete user priv indexes */
617
											if (!$group)
618
												$i++;
619
											endforeach;
620
										endif;
621
									?>
622
									<tr>
623
										<td class="list" colspan="3"></td>
624
										<td class="list">
625
											<a href="system_usermanager_addprivs.php?userid=<?=$id?>">
626
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
627
											</a>
628
										</td>
629
									</tr>
630
								</table>
631
							</td>
632
						</tr>
633
						<tr>
634
							<td width="22%" valign="top" class="vncell"><?=gettext("User Certificates");?></td>
635
							<td width="78%" class="vtable">
636
								<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
637
									<tr>
638
										<td width="45%" class="listhdrr"><?=gettext("Name");?></td>
639
										<td width="45%" class="listhdrr"><?=gettext("CA");?></td>
640
										<td class="list"></td>
641
									</tr>
642
									<?php
643
										
644
										$a_cert = $a_user[$id]['cert'];
645
										if(is_array($a_cert)):
646
											$i = 0;
647
											foreach ($a_cert as $certref):
648
												$cert = lookup_cert($certref);
649
												$ca = lookup_ca($cert['caref']);
650
									?>
651
									<tr>
652
										<td class="listlr">
653
											<?=htmlspecialchars($cert['descr']);?>
654
											<?php if (is_cert_revoked($cert)): ?>
655
											(<b>Revoked</b>)
656
											<?php endif; ?>
657
										</td>
658
										<td class="listr">
659
											<?=htmlspecialchars($ca['descr']);?>
660
										</td>
661
										<td valign="middle" nowrap class="list">
662
											<a href="system_usermanager.php?act=expckey&id=<?=$id;?>&certid=<?=$i;?>">
663
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export private key"); ?>" alt="<?=gettext("export private key"); ?>" width="17" height="17" border="0" />
664
											</a>
665
											<a href="system_usermanager.php?act=expcert&id=<?=$id;?>&certid=<?=$i;?>">
666
												<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert"); ?>" alt="<?=gettext("export cert"); ?>" width="17" height="17" border="0" />
667
											</a>
668
											<a href="system_usermanager.php?act=delcert&id=<?=$id?>&certid=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to remove this certificate association?") .'\n'. gettext("(Certificate will not be deleted)");?>')">
669
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="<?=gettext("delete cert");?>" />
670
											</a>
671
										</td>
672
									</tr>
673
									<?php
674
												$i++;
675
											endforeach;
676
										endif;
677
									?>
678
									<tr>
679
										<td class="list" colspan="2"></td>
680
										<td class="list">
681
											<a href="system_certmanager.php?act=new&userid=<?=$id?>">
682
												<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
683
											</a>
684
										</td>
685
									</tr>
686
								</table>
687
							</td>
688
						</tr>
689

    
690
						<?php else : ?>
691
						<?php 	if (is_array($config['ca']) && count($config['ca']) > 0): ?>
692
						<?php		$i = 0; foreach( $config['ca'] as $ca) {
693
                                                                        	if (!$ca['prv'])
694
                                                                                	continue;
695
										$i++;
696
									}
697
						?>
698

    
699
						<tr id="usercertchck" name="usercertchck" >
700
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
701
                                                	<td width="78%" class="vtable">
702
							<input type="checkbox" onClick="javascript:usercertClicked(this)"> <?=gettext("Click to create a user certificate."); ?>
703
							</td>
704
						</tr>
705

    
706
						<?php		if ($i > 0): ?>
707

    
708
						<tr id="usercert" name="usercert" style="display:none">
709
							<td width="22%" valign="top" class="vncell"><?=gettext("Certificate");?></td>
710
                                                	<td width="78%" class="vtable">
711
							<table width="100%" border="0" cellpadding="6" cellspacing="0">
712
							<tr>
713
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
714
                                                        	<td width="78%" class="vtable">
715
									<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
716
                                                        	</td>
717
                                                	</tr>
718
                                                	<tr>
719
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
720
                                                        	<td width="78%" class="vtable">
721
                                                                	<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
722
                                                                <?php
723
                                                                        foreach( $config['ca'] as $ca):
724
                                                                        if (!$ca['prv'])
725
                                                                                continue;
726
                                                                ?>
727
                                                                        <option value="<?=$ca['refid'];?>"><?=$ca['descr'];?></option>
728
                                                                <?php endforeach; ?>
729
                                                                	</select>
730
                                                        	</td>
731
                                                	</tr>
732
                                                	<tr>
733
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
734
                                                        	<td width="78%" class="vtable">
735
                                                                	<select name='keylen' class="formselect">
736
                                                                <?php
737
									$cert_keylens = array( "2048", "512", "1024", "4096");
738
                                                                        foreach( $cert_keylens as $len):
739
                                                                ?>
740
                                                                        <option value="<?=$len;?>"><?=$len;?></option>
741
                                                                <?php endforeach; ?>
742
                                                                	</select>
743
                                                                	bits
744
                                                        	</td>
745
                                                	</tr>
746
							<tr>
747
                                                        	<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
748
                                                        	<td width="78%" class="vtable">
749
                                                                	<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>days
750
                                                        	</td>
751
                                                	</tr>
752
						</table>
753
							</td>
754
						</tr>
755

    
756
						<?php 	endif; endif; ?>
757
						<?php endif; ?>
758

    
759
						<tr id="sshkeychck" name="sshkeychck" >
760
                                                        <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
761
                                                        <td width="78%" class="vtable">
762
                                                        <input type="checkbox" onClick="javascript:sshkeyClicked(this)"> <?=gettext("Click to paste an authorized key."); ?>
763
                                                        </td>
764
                                                </tr>
765
						<tr id="sshkey" name="sshkey" style="display:none">
766
							<td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
767
							<td width="78%" class="vtable">
768
								<textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
769
								<br/>
770
								<?=gettext("Paste an authorized keys file here.");?>
771
							</td>
772
						</tr>
773
						<tr id="ipsecpskrow" name="ipsecpskrow">
774
							<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Pre-Shared Key");?></td>
775
							<td width="78%" class="vtable">
776
								<input name="ipsecpsk" type="text" class="formfld unknown" id="ipsecpsk" size="65" value="<?=htmlspecialchars($pconfig['ipsecpsk']);?>">
777
							</td>
778
						</tr>
779
						<tr>
780
							<td width="22%" valign="top">&nbsp;</td>
781
							<td width="78%">
782
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
783
								<?php if (isset($id) && $a_user[$id]): ?>
784
								<input name="id" type="hidden" value="<?=$id;?>" />
785
								<?php endif;?>
786
							</td>
787
						</tr>
788
					</table>
789
				</form>
790

    
791
				<?php else: ?>
792

    
793
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
794
					<tr>
795
						<td width="25%" class="listhdrr"><?=gettext("Username"); ?></td>
796
						<td width="25%" class="listhdrr"><?=gettext("Full name"); ?></td>
797
						<td width="5%" class="listhdrr"><?=gettext("Disabled"); ?></td>
798
						<td width="25%" class="listhdrr"><?=gettext("Groups"); ?></td>
799
						<td width="10%" class="list"></td>
800
					</tr>
801
					<?php
802
						$i = 0;
803
						foreach($a_user as $userent):
804
					?>
805
					<tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
806
						<td class="listlr">
807
							<table border="0" cellpadding="0" cellspacing="0">
808
								<tr>
809
									<td align="left" valign="center">
810
										<?php
811
											if($userent['scope'] != "user")
812
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
813
											else
814
												$usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
815
										?>
816
										<img src="<?=$usrimg;?>" alt="<?=gettext("User"); ?>" title="<?=gettext("User"); ?>" border="0" height="16" width="16" />
817
									</td>
818
									<td align="left" valign="middle">
819
										<?=htmlspecialchars($userent['name']);?>
820
									</td>
821
								</tr>
822
							</table>
823
						</td>
824
						<td class="listr"><?=htmlspecialchars($userent['descr']);?>&nbsp;</td>
825
						<td class="listr"><?php if(isset($userent['disabled'])) echo "*"; ?></td>
826
						<td class="listbg">
827
								<?=implode(",",local_user_get_groups($userent));?>
828
							&nbsp;
829
						</td>
830
						<td valign="middle" nowrap class="list">
831
							<a href="system_usermanager.php?act=edit&id=<?=$i;?>">
832
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit user"); ?>" alt="<?=gettext("edit user"); ?>" width="17" height="17" border="0" />
833
							</a>
834
							<?php if($userent['scope'] != "system"): ?>
835
							&nbsp;
836
							<a href="system_usermanager.php?act=deluser&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
837
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete user"); ?>" alt="<?=gettext("delete user"); ?>" width="17" height="17" border="0" />
838
							</a>
839
							<?php endif; ?>
840
						</td>
841
					</tr>
842
					<?php
843
							$i++;
844
						endforeach;
845
					?>
846
					<tr>
847
						<td class="list" colspan="4"></td>
848
						<td class="list">
849
							<a href="system_usermanager.php?act=new">
850
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add user"); ?>" alt="<?=gettext("add user"); ?>" width="17" height="17" border="0" />
851
							</a>
852
						</td>
853
					</tr>
854
					<tr>
855
						<td colspan="4">
856
							<p>
857
								<?=gettext("Additional webConfigurator users can be added here.
858
								User permissions can be assigned directly or inherited from group memberships.
859
								An icon that appears grey indicates that it is a system defined object. 
860
								Some system object properties can be modified but they cannot be deleted."); ?>
861
							</p>
862
						</td>
863
					</tr>
864
				</table>
865

    
866
				<?php endif; ?>
867

    
868
			</div>
869
		</td>
870
	</tr>
871
</table>
872
<?php include("fend.inc");?>
873
</body>
874

    
875
<?php
876

    
877
	// end admin user code
878

    
879
} else {
880

    
881
	// start normal user code
882

    
883
	$pgtitle = array(gettext("System"),gettext("User Password"));
884

    
885
	if (isset($_POST['save'])) {
886
		unset($input_errors);
887

    
888
		/* input validation */
889
		$reqdfields = explode(" ", "passwordfld1");
890
		$reqdfieldsn = array(gettext("Password"));
891

    
892
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
893

    
894
		if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
895
			$input_errors[] = gettext("The passwords do not match.");
896

    
897
		if (!$input_errors) {
898
			// all values are okay --> saving changes
899
			$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
900
			local_user_set($config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]);
901
			write_config();
902
			$savemsg = gettext("Password successfully changed") . "<br />";
903
		}
904
	}
905

    
906
	/* determine if user is not local to system */
907
	$islocal = false;
908
	foreach($config['system']['user'] as $user) 
909
		if($user['name'] == $_SESSION['Username'])
910
			$islocal = true;
911
?>
912

    
913
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
914
<?php
915
    include("head.inc");
916
	include("fbegin.inc");
917
	if ($input_errors)
918
		print_input_errors($input_errors);
919
	if ($savemsg)
920
		print_info_box($savemsg);
921

    
922
	if($islocal == false) {
923
		echo gettext("Sorry, you cannot change the password for a LDAP user.");
924
		include("fend.inc");
925
		exit;
926
	}
927
?>
928
<div id="mainarea">
929
	<div class="tabcont">
930
		<form action="system_usermanager.php" method="post" name="iform" id="iform">
931
			<table width="100%" border="0" cellpadding="6" cellspacing="0">
932
				<tr>
933
					<td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s <?=gettext("Password"); ?></td>
934
				</tr>
935
				<tr>
936
					<td width="22%" valign="top" class="vncell" rowspan="2"><?=gettext("Password"); ?></td>
937
					<td width="78%" class="vtable">
938
						<input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
939
					</td>
940
				</tr>
941
				<tr>
942
					<td width="78%" class="vtable">
943
						<input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
944
						&nbsp;<?=gettext("(confirmation)");?>
945
						<br/>
946
						<span class="vexpl">
947
							<?=gettext("Select a new password");?>
948
						</span>
949
					</td>
950
				</tr>
951
				<tr>
952
					<td width="22%" valign="top">&nbsp;</td>
953
					<td width="78%">
954
						<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
955
					</td>
956
				</tr>
957
			</table>
958
		</form>
959
	</div>
960
</div>
961
<?php include("fend.inc");?>
962
</body>
963

    
964
<?php
965

    
966
} // end of normal user code
967

    
968
?>
(199-199/225)