summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Grooms <mgrooms@pfsense.org>2008-07-25 02:28:31 +0000
committerMatthew Grooms <mgrooms@pfsense.org>2008-07-25 02:28:31 +0000
commit45ee90edb38f3c52a242d248468a992bf19f1c44 (patch)
tree14e5a6b3c6a7ff340858442dddc9241b3e8fc9a0
parent8057888036bfcacd59c9d0fcf235aba5dc65682b (diff)
downloadpfsense-45ee90edb38f3c52a242d248468a992bf19f1c44.zip
pfsense-45ee90edb38f3c52a242d248468a992bf19f1c44.tar.gz
Rewrite portions of the user manager to ensure data is properly synced to
the system password and group databases. This is to provide better support for centralized user management when local account administration is preferred. I also took this opportunity to do some housekeeping. A lot of funtions that were only being used in one place or not at all were removed. The user page privelege checks were also simplified in preperation for future work in this area.
-rw-r--r--conf.default/config.xml14
-rw-r--r--etc/inc/auth.inc508
-rw-r--r--etc/inc/authgui.inc405
-rw-r--r--etc/inc/config.inc95
-rw-r--r--etc/inc/globals.inc2
-rw-r--r--etc/inc/pfsense-utils.inc193
-rw-r--r--etc/inc/xmlparse.inc2
-rwxr-xr-xetc/rc.initial.password20
-rwxr-xr-xusr/local/www/fbegin.inc22
-rwxr-xr-xusr/local/www/firewall_nat_edit.php13
-rwxr-xr-xusr/local/www/firewall_rules.php10
-rwxr-xr-xusr/local/www/firewall_rules_edit.php14
-rwxr-xr-xusr/local/www/head.inc5
-rwxr-xr-xusr/local/www/index.php5
-rw-r--r--usr/local/www/system_groupmanager.php384
-rw-r--r--usr/local/www/system_usermanager.php918
-rw-r--r--usr/local/www/system_usermanager_edit.php87
17 files changed, 1365 insertions, 1332 deletions
diff --git a/conf.default/config.xml b/conf.default/config.xml
index b0f55c2..f644439 100644
--- a/conf.default/config.xml
+++ b/conf.default/config.xml
@@ -113,12 +113,18 @@
<dnsserver></dnsserver>
<dnsallowoverride/>
<group>
+ <name>all</name>
+ <description>All Users</description>
+ <scope>system</scope>
+ </pages>
+ <gid>1998</gid>
+ </group>
+ <group>
<name>admins</name>
<description>System Administrators</description>
<scope>system</scope>
<pages>ANY</pages>
- <home>index.php</home>
- <gid>110</gid>
+ <gid>1999</gid>
</group>
<user>
<name>admin</name>
@@ -148,8 +154,8 @@
<descr>This user is associated with the UNIX root user (you should associate this privilege only with one single user).</descr>
</priv>
</user>
- <nextuid>115</nextuid>
- <nextgid>115</nextgid>
+ <nextuid>2000</nextuid>
+ <nextgid>2000</nextgid>
<timezone>Etc/UTC</timezone>
<time-update-interval>300</time-update-interval>
<timeservers>0.pfsense.pool.ntp.org</timeservers>
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc
index 12267ff..47a2431 100644
--- a/etc/inc/auth.inc
+++ b/etc/inc/auth.inc
@@ -36,101 +36,91 @@
*/
require_once("functions.inc");
+
$groupindex = index_groups();
$userindex = index_users();
-function logout_session() {
- global $_SESSION;
-
- if (hasLockAbility($_SESSION['Username']))
- unlink_if_exists("{$g['tmp_path']}/webconfigurator.lock");
-
- /* wipe out $_SESSION */
- $_SESSION = array();
-
- /* and destroy it */
- session_destroy();
+function isAllowedPage($page) {
+ global $config, $userindex, $_SESSION;
+
+ /* admin/root access check */
+ $username = $_SESSION['Username'];
+ if (isset($username))
+ $user = &$config['system']['user'][$userindex[$username]];
+ if (isset($user))
+ if (isset($user['uid']))
+ if ($user['uid']==0)
+ return true;
+
+ /* user privelege access check */
+ $allowed_pages = $_SESSION['privs'];
+ if (in_array("ANY", $allowed_pages))
+ return true;
+ if (in_array(basename($page), $allowed_pages))
+ return true;
- $scriptName = split("/", $_SERVER["SCRIPT_FILENAME"]);
- $scriptElms = count($scriptName);
- $scriptName = $scriptName[$scriptElms-1];
+ return false;
}
-function getAllowedGroups($logged_in_user) {
- global $g, $config;
+function getAllowedPages($logged_in_user) {
+ global $config, $_SESSION;
if (!function_exists("ldap_connect"))
return;
- $allowed = array();
+ $allowed_pages = array();
$allowed_groups = array();
$ldapon = $_SESSION['ldapon'];
//log_error("Getting groups for {$logged_in_user}.");
-
- $local_user = false;
- //log_error("Local_user = {$local_user}");
+ /* search for a local user by name */
+ $local_user = false;
+ foreach ($config['system']['user'] as $user) {
+ if ($user['name'] == $logged_in_user) {
+ $local_user = $user;
+ break;
+ }
+ }
- foreach ($config['system']['user'] as $username)
- if ($username['name'] == $logged_in_user)
- $local_user = true;
+ /* obtain local groups if we have a local user */
+ if ($local_user) {
+ $allowed_groups = get_local_user_groups($local_user);
+ foreach ($config['system']['group'] as $group)
+ if (in_array($group['name'], $allowed_groups))
+ if (is_array($group['pages']))
+ foreach ($group['pages'] as $page)
+ $allowed_pages[] = $page;
+ }
- /* return ldap groups if we are in ldap mode */
- if ($config['system']['webgui']['backend'] == "ldap" && $local_user == false) {
+ /* obtain ldap groups if we are in ldap mode */
+ if ($config['system']['webgui']['backend'] == "ldap" && !$local_user) {
//log_error("Calling LDAP_GET_GROUPS from the first section");
$allowed_groups = ldap_get_groups($logged_in_user);
- $fdny = fopen("/tmp/groups","w");
- fwrite($fdny, print_r($allowed, true));
- fclose($fdny);
- $allowed = array();
if (is_array($config['system']['group']) && is_array($allowed_groups))
foreach ($config['system']['group'] as $group)
if (in_array($group['name'], $allowed_groups))
foreach ($group['pages'] as $page)
- $allowed[] = $page;
- return $allowed;
+ $allowed_pages[] = $page;
}
-
- if ($config['system']['webgui']['backend'] == "ldapother" && $local_user == false) {
+ if ($config['system']['webgui']['backend'] == "ldapother" && !$local_user) {
//log_error("Calling LDAP_GET_GROUPS from the first section");
$allowed_groups = ldap_get_groups($logged_in_user);
- $fdny = fopen("/tmp/groups","w");
- fwrite($fdny, print_r($allowed, true));
- fclose($fdny);
- $allowed = array();
if (is_array($config['system']['group']) && is_array($allowed_groups))
foreach ($config['system']['group'] as $group)
if (in_array($group['name'], $allowed_groups))
foreach ($group['pages'] as $page)
- $allowed[] = $page;
- return $allowed;
+ $allowed_pages[] = $page;
}
- $final_allowed = array();
-
- foreach ($config['system']['user'] as $username)
- if ($username['name'] == $logged_in_user)
- $allowed_groups = explode(",", $username['groupname']);
-
- foreach ($config['system']['group'] as $group)
- if (in_array($group['name'], $allowed_groups))
- foreach ($group['pages'] as $page)
- $allowed[] = $page;
-
- return $allowed;
-}
-
-function &getSystemAdminNames() {
- global $config, $g, $userindex;
- $adminUsers = array();
+ $allowed_groups = print_r($allowed, true);
+ $fdny = fopen("/tmp/groups", "w");
+ fwrite($fdny, $allowed_groups);
+ fclose($fdny);
- if (is_array($config['system']['user']))
- foreach ($config['system']['user'] as $user)
- if (isSystemAdmin($user['name']))
- $adminUsers[] = $user['name'];
+ $_SESSION['privs'] = $allowed_pages;
- return $adminUsers;
+ return $allowed_pages;
}
function &getSystemPrivs() {
@@ -171,229 +161,286 @@ function &getSystemPrivs() {
return $privs;
}
-function assignUID($username = "") {
- global $userindex, $config, $g;
-
- if ($username == "")
- return;
-
- $nextuid = $config['system']['nextuid'];
- $user =& $config['system']['user'][$userindex[$username]];
-
- if (empty($user['uid'])) {
- $user['uid'] = $nextuid;
- $nextuid++;
- $config['system']['nextuid'] = $nextuid;
-
- write_config();
- return $user;
- }
+function & getUserEntry($name) {
+ global $config, $userindex;
+ return $config['system']['user'][$userindex[$name]];
}
-function assignGID($groupname = "") {
- global $groupindex, $config, $g;
-
- if ($groupname == "")
- return;
-
- $nextgid = $config['system']['nextgid'];
- $group =& $config['system']['group'][$groupindex[$groupname]];
-
- if (empty($group['gid'])) {
- $group['gid'] = $nextgid;
- $nextgid++;
- $config['system']['nextgid'] = $nextgid;
-
- write_config();
- return $group;
- }
+function & getGroupEntry($name) {
+ global $config, $groupindex;
+ return $config['system']['group'][$groupindex[$name]];
}
-function hasPrivilege($user, $privid = "") {
- global $userindex, $config, $g;
+function userHasPrivilege($userent, $privid = false) {
- if ($privid == "" || ! isset($userindex[$user]))
- return 0;
+ if (!$privid || !is_array($userent))
+ return false;
- $privs = &$config['system']['user'][$userindex[$user]]['priv'];
+ if (!is_array($userent['priv']))
+ return false;
- if (is_array($privs))
- foreach ($privs as $priv)
- if ($priv['id'] == $privid)
- return 1;
- return 0;
+ foreach ($userent['priv'] as $priv)
+ if ($priv['id'] == $privid)
+ return true;
}
-function isAllowedToCopyFiles($username) {
- global $userindex, $config, $g;
-
- if ($username == "")
- return 0;
-
- return hasPrivilege($username, "copyfiles");
+function hasPrivilegeCopyFiles($userent) {
+ return userHasPrivilege($userent, "copyfiles");
}
-function hasLockAbility($username) {
- global $userindex, $config, $g;
-
- if ($username == "")
- return 0;
-
- return hasPrivilege($username, "lockwc");
+function hasPrivilegeLock($userent) {
+ return userHasPrivilege($userent, "lockwc");
}
-function hasPageLockAbility($username) {
- global $userindex, $config, $g;
-
- if ($username == "")
- return 0;
-
- return hasPrivilege($username, "lock-ipages");
+function hasPrivilegeLockPages($userent) {
+ return userHasPrivilege($userent, "lock-ipages");
}
-function hasShellAccess($username) {
- global $userindex, $config, $g;
+function hasPrivilegeShell($userent) {
+ return userHasPrivilege($userent, "hasshell");
+}
- if ($username == "")
- return 0;
+function sync_local_accounts() {
+ global $config;
- return hasPrivilege($username, "hasshell");
-}
+ /* remove local users to avoid uid conflicts */
+ $fd = popen("/usr/sbin/pw usershow -a 2>&1", "r");
+ if ($fd) {
+ while (!feof($fd)) {
+ $line = explode(":",fgets($fd));
+ if (!strncmp($line[0], "_", 1))
+ continue;
+ if ($line[2] < 2000)
+ continue;
+ if ($line[2] > 65000)
+ continue;
+ mwexec("/usr/sbin/pw userdel {$line[2]}");
+ }
+ pclose($fd);
+ }
-function isUNIXRoot($username = "") {
- global $userindex, $config;
+ /* remove local groups to avoid gid conflicts */
+ $gids = array();
+ $fd = popen("/usr/sbin/pw groupshow -a 2>&1", "r");
+ if ($fd) {
+ while (!feof($fd)) {
+ $line = explode(":",fgets($fd));
+ if (!strncmp($line[0], "_", 1))
+ continue;
+ if ($line[2] < 2000)
+ continue;
+ if ($line[2] > 65000)
+ continue;
+ mwexec("/usr/sbin/pw groupdel {$line[2]}");
+ }
+ pclose($fd);
+ }
- if ($username == "")
- return 0;
+ /* sync all local users */
+ if (is_array($config['system']['user']))
+ foreach ($config['system']['user'] as $user)
+ set_local_user($user);
- if (isSystemAdmin($username))
- return hasPrivilege($username, "isroot");
+ /* sync all local groups */
+ if (is_array($config['system']['group']))
+ foreach ($config['system']['group'] as $group)
+ set_local_group($group);
- return 0;
+ sync_webgui_passwords();
}
-function setUserFullName($name = "", $new_name = "") {
- global $config, $g, $userindex;
+function set_local_user($user) {
- if ($name == "" || $new_name == "")
- return;
+ $home_base = $g['platform'] == "pfSense" ? "/home" : "/var/home";
+ if (!is_dir($home_base))
+ mkdir($home_base, 0755);
- $user = &$config['system']['user'][$userindex[$name]];
- $user['fullname'] = $new_name;
-}
+ $user_uid = $user['uid'];
+ $user_name = $user['name'];
+ $user_home = "{$home_base}/$user_name";
+ $user_shell = "/etc/rc.initial";
+ $user_group = "nobody";
-function setUserName($name = "", $new_name = "") {
- global $config, $g, $userindex;
+ /* configure shell type */
+ if (!hasPrivilegeShell($user)) {
+ if (!hasPrivilegeCopyFiles($user))
+ $user_shell = "/sbin/nologin";
+ else
+ $user_shell = "/usr/local/bin/scponly";
+ }
- if ($name == "" || $new_name == "")
- return;
+ /* root user special handling */
+ if ($user_uid == 0) {
+ $fd = popen("/usr/sbin/pw usermod -n root -s /bin/sh -H 0", "w");
+ fwrite($fd, $user['password']);
+ pclose($fd);
+ $user_group = "wheel";
+ }
- $user = &$config['system']['user'][$userindex[$name]];
- $user['name'] = $new_name;
+ /* read from pw db */
+ $fd = popen("/usr/sbin/pw usershow {$user_name} 2>&1", "r");
+ $pwread = fgets($fd);
+ pclose($fd);
+
+ /* determine add or mod */
+ if (!strncmp($pwread, "pw:", 3))
+ $user_op = "useradd";
+ else
+ $user_op = "usermod";
+
+ /* add or mod pw db */
+ $cmd = "/usr/sbin/pw {$user_op} -u {$user_uid} -n {$user_name}".
+ " -g {$user_group} -G all -s {$user_shell} -d {$user_home}".
+ " -c ".escapeshellarg($user['fullname'])." -H 0";
+
+ log_error("Running: {$cmd}");
+ $fd = popen($cmd, "w");
+ fwrite($fd, $user['password']);
+ pclose($fd);
+
+ /* create user directory if required */
+ if (!is_dir($user_home))
+ mkdir($user_home, 0755);
+ chown($user_home, $user_name);
+ chgrp($user_home, $user_group);
+ chmod($user_home, 0700);
+
+ /* FIXME : ssh keys should be per-admin user */
+ if(isset($config['system']['ssh']['sshdkeyonly']) && hasPrivilegeShell($user))
+ create_authorized_keys($user_name, $user_home);
}
-function setUserPWD($name = "", $password = "") {
- global $config, $g, $userindex;
+function del_local_user($user) {
- if ($name == "" || $password == "")
- return;
+ /* remove all memberships */
+ set_local_user_groups($user);
- $user = &$config['system']['user'][$userindex[$name]];
- $user['password'] = crypt($password);
-}
+ /* delete from pw db */
+ $cmd = "/usr/sbin/pw userdel {$user['name']}";
-function setUserGroupName($name = "", $new_name = "") {
- global $config, $g, $userindex;
+ log_error("Running: {$cmd}");
+ $fd = popen($cmd, "w");
+ fwrite($fd, $user['password']);
+ pclose($fd);
+}
- if ($name == "" || $new_name == "")
- return;
+function get_local_user_groups($user, $all = false) {
+ global $config;
- $user = &$config['system']['user'][$userindex[$name]];
- $user['groupname'] = $new_name;
-}
+ $groups = array();
+ if (!is_array($config['system']['group']))
+ return $groups;
-function setUserType($name = "", $new_type = "") {
- global $config, $g, $userindex;
+ foreach ($config['system']['group'] as $group)
+ if ( $all || ( !$all && ($group['name'] != "all")))
+ if (is_array($group['member']))
+ if (in_array($user['uid'], $group['member']))
+ $groups[] = $group['name'];
- if ($name == "" || $new_type == "")
- return;
+ sort($groups);
- $user = &$config['system']['user'][$userindex[$name]];
- $user['scope'] = $new_type;
+ return $groups;
}
-function getUNIXRoot() {
- global $config, $g, $userindex;
+function set_local_user_password(& $user, $password) {
- if (is_array($config['system']['user'])) {
- foreach($config['system']['user'] as $user) {
- if (isUNIXRoot($user['name'])) {
- $root = &$config['system']['user'][$userindex[$user['name']]];
- return $root;
- }
- }
+ $user['password'] = crypt($password);
+ $user['md5-hash'] = md5($password);
+
+ /*
+ * NOTE : This section of code id based on the BSD
+ * licensed CHAP.php courtesy of Michael Retterklieber.
+ */
+ /* Waiting for mhash to settle into the tree
+ // Converts ascii to unicode.
+ $astr = (string) $password;
+ $ustr = '';
+ for ($i = 0; $i < strlen($astr); $i++) {
+ $a = ord($astr{$i}) << 8;
+ $ustr.= sprintf("%X", $a);
}
- return NULL;
+ // Generate the NT-HASH from the unicode string
+ $user['nt-hash'] = bin2hex(mhash(MHASH_MD4, $ustr));
+ */
}
-function getUNIXRootName() {
- global $config, $g, $userindex;
+function set_local_user_groups($user, $new_groups = NULL ) {
+ global $config, $groupindex;
- if (is_array($config['system']['user']))
- foreach ($config['system']['user'] as $user)
- if (isUNIXRoot($user['name']))
- return $user['name'];
-
- return NULL;
-}
+ if (!is_array($config['system']['group']))
+ return;
-function getGroupHomePage($group = "") {
- global $groupindex, $config, $g;
+ $cur_groups = get_local_user_groups($user);
+ $mod_groups = array();
- if ($group == "")
- return "";
+ if (!is_array($new_groups))
+ $new_groups = array();
- $page = $config['system']['group'][$groupindex[$group]]['home'];
- if (empty($page))
- $page = "";
+ if (!is_array($cur_groups))
+ $cur_groups = array();
- return $page;
-}
+ /* determine which memberships to add */
+ foreach ($new_groups as $groupname) {
+ if (in_array($groupname,$cur_groups))
+ continue;
+ $group = & $config['system']['group'][$groupindex[$groupname]];
+ $group['member'][] = $user['uid'];
+ $mod_groups[] = $group;
+ }
-function isSystemAdmin($username = "") {
- global $groupindex, $userindex, $config, $g, $_SESSION;
+ /* determine which memberships to remove */
+ foreach ($cur_groups as $groupname) {
+ if (in_array($groupname,$new_groups))
+ continue;
+ $group = & $config['system']['group'][$groupindex[$groupname]];
+ $index = array_search($user['uid'], $group['member']);
+ array_splice($group['member'], $index, 1);
+ $mod_groups[] = $group;
+ }
- if ($_SESSION['isSystemAdmin'])
- return $_SESSION['isSystemAdmin'];
+ /* sync all modified groups */
+ foreach ($mod_groups as $group)
+ set_local_group($group);
+}
- if (!function_exists("ldap_connect"))
- return;
+function set_local_group($group) {
- if ($username == "") {
- $_SESSION['isSystemAdmin'] = false;
- return 0;
- }
+ $group_name = $group['name'];
+ $group_gid = $group['gid'];
+ $group_members = "''";
+ if (count($group['member']))
+ $group_members = implode(",",$group['member']);
- $gname = $config['system']['group'][$groupindex[$config['system']['user'][$userindex[$username]]['groupname']]]['name'];
+ /* read from group db */
+ $fd = popen("/usr/sbin/pw groupshow {$group_name} 2>&1", "r");
+ $pwread = fgets($fd);
+ pclose($fd);
- if (isset($gname)) {
- $_SESSION['isSystemAdmin'] = $gname === $g["admin_group"];
- return ($gname === $g["admin_group"]);
- }
+ /* determine add or mod */
+ if (!strncmp($pwread, "pw:", 3))
+ $group_op = "groupadd";
+ else
+ $group_op = "groupmod";
- $_SESSION['isSystemAdmin'] = false;
+ /* add or mod group db */
+ $cmd = "/usr/sbin/pw {$group_op} {$group_name} -g {$group_gid} -M {$group_members}";
- return 0;
+ log_error("Running: {$cmd}");
+ $fd = popen($cmd, "w");
+ fwrite($fd, $user['password']);
+ pclose($fd);
}
-function getRealName($username = "") {
- global $userindex, $config;
+function del_local_group($group) {
- if ($username == "")
- return "";
+ /* delete from group db */
+ $cmd = "/usr/sbin/pw groupdel {$group['name']}";
- return $config['system']['user'][$userindex[$username]]['fullname'];
+ log_error("Running: {$cmd}");
+ $fd = popen($cmd, "w");
+ fwrite($fd, $user['password']);
+ pclose($fd);
}
function basic_auth($backing) {
@@ -475,6 +522,9 @@ function session_auth($backing) {
}
}
+ /* obtain user object */
+ $user = getUserEntry($_SESSION['Username']);
+
/* user hit the logout button */
if (isset($_GET['logout'])) {
@@ -483,7 +533,7 @@ function session_auth($backing) {
else
log_error("User logged out for user '{$_SESSION['Username']}' from: {$_SERVER['REMOTE_ADDR']}");
- if (hasLockAbility($_SESSION['Username']))
+ if (hasPrivilegeLock($user))
unlink_if_exists("{$g['tmp_path']}/webconfigurator.lock");
/* wipe out $_SESSION */
@@ -512,7 +562,7 @@ function session_auth($backing) {
* user wants to explicitely delete the lock file.
* Requires a particular privilege.
*/
- if ($_GET['deletelock'] && hasLockAbility($_SESSION['Username'])) {
+ if ($_GET['deletelock'] && hasPrivilegeLock($user)) {
unlink_if_exists("{$g['tmp_path']}/webconfigurator.lock");
$HTTP_SERVER_VARS['AUTH_USER'] = $_SESSION['Username'];
return true;
@@ -522,10 +572,9 @@ function session_auth($backing) {
* user wants to explicitely create a lock.
* Requires a particular privilege.
*/
- if ($_GET['createlock'] && hasLockAbility($_SESSION['Username'])) {
+ if ($_GET['createlock'] && hasPrivilegeLock($user)) {
$fd = fopen("{$g['tmp_path']}/webconfigurator.lock", "w");
- fputs($fd, "{$_SERVER['REMOTE_ADDR']} (" .
- getRealName($_SESSION['Username']) . ")");
+ fputs($fd, "{$_SERVER['REMOTE_ADDR']}.{$_SESSION['Username']}");
fclose($fd);
/*
@@ -560,7 +609,7 @@ function session_auth($backing) {
/*
* is the user is allowed to create a lock
*/
- if (hasLockAbility($_SESSION['Username'])) {
+ if (hasPrivilegeLock($user)) {
/*
* create a lock once per session
@@ -568,8 +617,7 @@ function session_auth($backing) {
if (!isset($_SESSION['Lock_Created'])) {
$fd = fopen("{$g['tmp_path']}/webconfigurator.lock", "w");
- fputs($fd, "{$_SERVER['REMOTE_ADDR']} (" .
- getRealName($_SESSION['Username']) . ")");
+ fputs($fd, "{$_SERVER['REMOTE_ADDR']}.{$_SESSION['Username']}");
fclose($fd);
/*
diff --git a/etc/inc/authgui.inc b/etc/inc/authgui.inc
index 12f45bc..7467ccd 100644
--- a/etc/inc/authgui.inc
+++ b/etc/inc/authgui.inc
@@ -41,243 +41,254 @@ require_once("functions.inc");
/* We only support htpasswd backed HTTP Basic auth and session
* based backing methods at the moment.
* session_auth - this will use session based authentication and timeout
- * htpasswd_backed - this uses the "standard" .htpasswd file
- * passwd_backed - this will use the system passwd file in /etc
- * radius_backed - this will allow you to use a radius server
- * pam_backed - this uses the system's PAM facility .htpasswd file
+ * htpasswd_backed - this uses the "standard" .htpasswd file
+ * passwd_backed - this will use the system passwd file in /etc
+ * radius_backed - this will allow you to use a radius server
+ * pam_backed - this uses the system's PAM facility .htpasswd file
*/
$auth_method="session_auth";
/* enable correct auth backend, default to htpasswd_backed */
-
$ldapcase = $config['system']['webgui']['backend'];
switch($ldapcase)
{
-case ldap:
- $backing_method="ldap_backed";
- break;
-case ldapother:
- $backing_method="ldap_backed";
- break;
-default:
- $backing_method="htpasswd_backed";
+ case ldap:
+ $backing_method="ldap_backed";
+ break;
+ case ldapother:
+ $backing_method="ldap_backed";
+ break;
+ default:
+ $backing_method="htpasswd_backed";
}
/* Authenticate user - exit if failed */
-if (!$auth_method($backing_method)) { exit; }
+if (!$auth_method($backing_method))
+ exit;
+
+/*
+ * scriptname is set in headjs.php if the user tried to access
+ * a page other than index.php without beeing logged in.
+ *
+ * NOTE : This doesn't make sense to me. -mgrooms
+ */
+/* if (isset($_POST['scriptname']) && isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
+ * pfSenseHeader("{$_POST['scriptname']}");
+ * exit;
+ * }
+ */
+
+/*
+ * Once here, the user has authenticated with the web server.
+ * We give them access only to the appropriate pages based on
+ * the user or group privileges.
+ */
+getAllowedPages($HTTP_SERVER_VARS['AUTH_USER']);
-/* scriptname is set in headjs.php if the user did try to access a page other
- * than index.php without beeing logged in.
+/*
+ * get the group homepage, to be able to forward
+ * the user to this particular PHP page.
+ */
+$home = $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['home'];
+if (!$home)
+ $home = "/index.php";
+
+/*
+ * If the user tries to explicitly access a particular
+ * page, set $home to that page instead.
*/
-if (isset($_POST['scriptname']) && isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
- pfSenseHeader("{$_POST['scriptname']}");
- exit;
+if (isset($_POST['scriptname']) &&
+ $_POST['scriptname'] <> "/" && $_POST['scriptname'] <> "/index.php") {
+ $home = str_replace('/', '', basename($_POST['scriptname']));
+ $pagereq = $home;
}
-// Once here, the user has authenticated with the web server.
-// Now, we give them access only to the appropriate pages for their group.
-
-if (!(isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))) {
- $_SESSION['privs'] = getAllowedGroups($HTTP_SERVER_VARS['AUTH_USER']);
- $allowed = $_SESSION['privs'];
-
- $allowed_groups = print_r($_SESSION['privs'],true);
- $fdny = fopen("/tmp/groups", "w");
- fwrite($fdny, $allowed_groups);
- fclose($fdny);
-
- $group = $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname'];
- /* get the group homepage, to be able to forward
- * the user to this particular PHP page.
- */
- getGroupHomePage($group) == "" ? $home = "/index.php" : $home = "/" . getGroupHomePage($group);
-
- /* okay but if the user realy tries to explicitely access a particular
- * page, set $home to that page instead.
- */
- if (isset($_POST['scriptname']) && $_POST['scriptname'] <> "/" && $_POST['scriptname'] <> "/index.php") {
- $home = str_replace('/', '', basename($_POST['scriptname']));
- $pagereq = $home;
- }
-
- // If the user is attempting to hit the default page, set it to specifically look for /index.php.
- // Without this, any user would have access to the index page.
- if ($_SERVER['SCRIPT_NAME'] == '/')
- $_SERVER['SCRIPT_NAME'] = $home;
- if ($pagereq == "")
+/*
+ * If the user is attempting to hit the default page, set it to
+ * specifically look for /index.php. Without this, any user would
+ * have access to the index page.
+ */
+if ($_SERVER['SCRIPT_NAME'] == '/')
+ $_SERVER['SCRIPT_NAME'] = $home;
+if ($pagereq == "")
$pagereq = str_replace('/', '', basename($_SERVER['SCRIPT_NAME']));
- // Strip the leading / from the currently requested PHP page
- if (!in_array($pagereq,$allowed) && !in_array("ANY", $allowed)) {
- // The currently logged in user is not allowed to access the page
- // they are attempting to go to. Redirect them to an allowed page.
-
- if(stristr($_SERVER['SCRIPT_NAME'],"sajax")) {
- echo "||Access to AJAX has been disallowed for this user.";
- exit;
- }
-
- if ($pagereq <> "" && (in_array($pagereq, $allowed) || in_array("ANY", $allowed))) {
- pfSenseHeader("{$home}");
- exit;
- } else {
- header("HTTP/1.0 401 Unauthorized");
- header("Status: 401 Unauthorized");
-
- echo display_error_form("401", "Unauthorized. You do not have access to the page {$pagereq}");
- exit;
- }
- }
-
- if (isset($_SESSION['Logged_In'])) {
- /*
- * only forward if the user has just logged in
- * TODO: session auth based - may be an issue.
- */
- if ($_SERVER['SCRIPT_NAME'] <> $home && empty($_SESSION['First_Visit'])) {
- $_SESSION['First_Visit'] = "False";
- pfSenseHeader("{$home}");
- exit;
- }
- }
+/*
+ * determine if the user is allowed access to the requested page
+ */
+if (!isAllowedPage($pagereq)) {
+
+ /*
+ * The currently logged in user is not allowed to access the page
+ * they are attempting to view. Redirect them to an allowed page.
+ */
+ if(stristr($_SERVER['SCRIPT_NAME'],"sajax")) {
+ echo "||Access to AJAX has been disallowed for this user.";
+ exit;
+ }
+
+ header("HTTP/1.0 401 Unauthorized");
+ header("Status: 401 Unauthorized");
+ display_error_form("401", "Unauthorized. You do not have access to the page {$pagereq}");
+ exit;
+}
+
+if (isset($_SESSION['Logged_In'])) {
+ /*
+ * only forward if the user has just logged in
+ * TODO: session auth based - may be an issue.
+ */
+ if ($_SERVER['SCRIPT_NAME'] <> $home && empty($_SESSION['First_Visit'])) {
+ $_SESSION['First_Visit'] = "False";
+ pfSenseHeader("{$home}");
+ exit;
+ }
}
function display_error_form($http_code, $desc) {
- global $config, $g;
- $g['theme'] = $config['theme'];
+ global $config, $g;
+ $g['theme'] = $config['theme'];
if(isAjax()) {
echo "Error: {$http_code} Description: {$desc}";
return;
}
?>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
- <head>
- <script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
- <script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
- <title>An error occurred: {$http_code}</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
- <?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
- <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
- <?php else: ?>
- <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
- <?php endif; ?>
- <script type="text/javascript">
- <title>An error occurred: {$http_code}</title>
- <!--
- function page_load() {
- NiftyCheck();
- Rounded("div#login inputerrors","bl br","transparent","#cccccc","smooth");
- Effect.Pulsate('errortext', { duration: 10 });
- }
- <?php
- require("headjs.php");
- echo getHeadJS();
- ?>
- //-->
- </script>
- <script type="text/javascript" src="/themes/{$g['theme']}/javascript/niftyjsCode.js"></script>
- </head>
- <body onload="page_load();">
- <div id="errordesc">
- <h1>&nbsp</h1>
- <a href="/">
- <p id="errortext" style="vertical-align: middle; text-align: center;"><span style="color: #000000; font-weight: bold;">{$desc}</span></p>
- </div>
- </body>
+ <head>
+ <script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
+ <script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
+ <title><?=$http_code?></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
+ <?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
+ <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
+ <?php else: ?>
+ <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
+ <?php endif; ?>
+ <script type="text/javascript">
+ <!--
+ function page_load() {}
+ function clearError() {
+ if($('inputerrors'))
+ $('inputerrors').innerHTML='';
+ }
+ <?php
+ require("headjs.php");
+ echo getHeadJS();
+ ?>
+ //-->
+ </script>
+ <script type="text/javascript" src="/themes/<?= $g['theme'] ?>/javascript/niftyjsCode.js"></script>
+ </head>
+ <body onload="page_load();">
+ <div id="errordesc">
+ <h1>&nbsp</h1>
+ <a href="/">
+ <p id="errortext" style="vertical-align: middle; text-align: center;">
+ <span style="color: #000000; font-weight: bold;">
+ <?=$desc;?>
+ </span>
+ </p>
+ </div>
+ </body>
</html>
+
<?php
-} // end function
+} // end function
function display_login_form() {
- require_once("globals.inc");
- global $config, $g;
- $g['theme'] = $config['theme'];
-
- unset($input_errors);
-
- if(isAjax()) {
- if (isset($_POST['login'])) {
- if($_SESSION['Logged_In'] <> "True") {
- isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = "unknown reason";
- echo "showajaxmessage('Invalid login ({$login_error}).');";
- }
- if (file_exists("{$g['tmp_path']}/webconfigurator.lock")) {
- // TODO: add the IP from the user who did lock the device
- $whom = file_get_contents("{$g['tmp_path']}/webconfigurator.lock");
- echo "showajaxmessage('This device is currently beeing maintained by: {$whom}.');";
- }
- }
- exit;
- }
+ require_once("globals.inc");
+ global $config, $g;
+ $g['theme'] = $config['theme'];
+
+ unset($input_errors);
+
+ if(isAjax()) {
+ if (isset($_POST['login'])) {
+ if($_SESSION['Logged_In'] <> "True") {
+ isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = "unknown reason";
+ echo "showajaxmessage('Invalid login ({$login_error}).');";
+ }
+ if (file_exists("{$g['tmp_path']}/webconfigurator.lock")) {
+ // TODO: add the IP from the user who did lock the device
+ $whom = file_get_contents("{$g['tmp_path']}/webconfigurator.lock");
+ echo "showajaxmessage('This device is currently beeing maintained by: {$whom}.');";
+ }
+ }
+ exit;
+ }
?>
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
- <head>
- <script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
- <script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
- <title><?=gettext("Login"); ?></title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
- <?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
- <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
- <?php else: ?>
- <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
- <?php endif; ?>
- <script type="text/javascript">
- <!--
- function page_load() {}
- function clearError() {
- if($('inputerrors'))
- $('inputerrors').innerHTML='';
- }
- <?php
- require("headjs.php");
- echo getHeadJS();
- ?>
- //-->
- </script>
- <script type="text/javascript" src="/themes/<?= $g['theme'] ?>/javascript/niftyjsCode.js"></script>
- </head>
- <body onload="page_load()">
- <div id="login">
- <form id="iform" name="login_iform" method="post" autocomplete="off" action="<?= $_SERVER['SCRIPT_NAME'] ?>">
- <h1>&nbsp</h1>
- <div id="inputerrors"></div>
- <p>
- <span style="text-align:left">
- <?=gettext("Username"); ?>:<br>
- <input onclick="clearError();" onchange="clearError();" id="usernamefld" type="text" name="usernamefld" class="formfld user" tabindex="1" />
- </span>
- </p>
- <br>
- <p>
- <span style="text-align:left">
- <?=gettext("Password"); ?>: <br>
- <input onclick="clearError();" onchange="clearError();" id="passwordfld" type="password" name="passwordfld" class="formfld pwd" tabindex="2" />
- </span>
- </p>
- <br>
- <p>
- <span style="text-align:center; font-weight: normal ; font-style: italic"><?=gettext("Enter username and password to login."); ?></span>
- </p>
- <p>
- <span style="text-align:center">
- <input type="submit" name="login" class="formbtn" value="<?=gettext("Login"); ?>" tabindex="3" />
- </span>
- </P>
- </form>
- </div>
- </body>
+ <head>
+ <script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
+ <script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
+ <title><?=gettext("Login"); ?></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <link rel="shortcut icon" href="/themes/<?= $g['theme'] ?>/images/icons/favicon.ico" />
+ <?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/login.css")): ?>
+ <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/login.css" media="all" />
+ <?php else: ?>
+ <link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/all.css" media="all" />
+ <?php endif; ?>
+ <script type="text/javascript">
+ <!--
+ function page_load() {}
+ function clearError() {
+ if($('inputerrors'))
+ $('inputerrors').innerHTML='';
+ }
+ <?php
+ require("headjs.php");
+ echo getHeadJS();
+ ?>
+ //-->
+ </script>
+ <script type="text/javascript" src="/themes/<?= $g['theme'] ?>/javascript/niftyjsCode.js"></script>
+ </head>
+ <body onload="page_load()">
+ <div id="login">
+ <form id="iform" name="login_iform" method="post" autocomplete="off" action="<?= $_SERVER['SCRIPT_NAME'] ?>">
+ <h1></h1>
+ <div id="inputerrors"><?=$_SESSION['Login_Error'];?></div>
+ <p>
+ <span style="text-align:left">
+ <?=gettext("Username"); ?>:<br>
+ <input onclick="clearError();" onchange="clearError();" id="usernamefld" type="text" name="usernamefld" class="formfld user" tabindex="1" />
+ </span>
+ </p>
+ <br>
+ <p>
+ <span style="text-align:left">
+ <?=gettext("Password"); ?>: <br>
+ <input onclick="clearError();" onchange="clearError();" id="passwordfld" type="password" name="passwordfld" class="formfld pwd" tabindex="2" />
+ </span>
+ </p>
+ <br>
+ <p>
+ <span style="text-align:center; font-weight: normal ; font-style: italic">
+ <?=gettext("Enter username and password to login."); ?>
+ </span>
+ </p>
+ <p>
+ <span style="text-align:center">
+ <input type="submit" name="login" class="formbtn" value="<?=gettext("Login"); ?>" tabindex="3" />
+ </span>
+ </P>
+ </form>
+ </div>
+ </body>
</html>
<?php
} // end function
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index cb12d94..5e58689 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -1470,7 +1470,7 @@ function convert_config() {
}
/* Convert 4.7 -> 4.8 */
- if ($config['version'] <= 4.7) {
+ if ($config['version'] <= 4.7) {
$config['dyndnses']['dyndns'] = array();
if (isset($config['dyndns']['enable'])) {
$tempdyn = array();
@@ -1502,7 +1502,7 @@ function convert_config() {
$config['dnsupdates']['dnsupdate'][] = $pconfig;
unset($config['dnsupdate']);
}
-
+
if (is_array($config['pppoe'])) {
$pconfig = array();
$pconfig['username'] = $config['pppoe']['username'];
@@ -1518,28 +1518,87 @@ function convert_config() {
$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
}
if (is_array($config['pptp'])) {
- $pconfig = array();
- $pconfig['username'] = $config['pptp']['username'];
- $pconfig['password'] = $config['pptp']['password'];
- $pconfig['provider'] = $config['pptp']['provider'];
- $pconfig['ondemand'] = isset($config['pptp']['ondemand']);
- $pconfig['timeout'] = $config['pptp']['timeout'];
- unset($config['pptp']);
- $config['interfaces']['wan']['username'] = $pconfig['username'];
- $config['interfaces']['wan']['password'] = $pconfig['password'];
- $config['interfaces']['wan']['provider'] = $pconfig['provider'];
- $config['interfaces']['wan']['username'] = isset($pconfig['ondemand']
-);
- $config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
- }
+ $pconfig = array();
+ $pconfig['username'] = $config['pptp']['username'];
+ $pconfig['password'] = $config['pptp']['password'];
+ $pconfig['provider'] = $config['pptp']['provider'];
+ $pconfig['ondemand'] = isset($config['pptp']['ondemand']);
+ $pconfig['timeout'] = $config['pptp']['timeout'];
+ unset($config['pptp']);
+ $config['interfaces']['wan']['username'] = $pconfig['username'];
+ $config['interfaces']['wan']['password'] = $pconfig['password'];
+ $config['interfaces']['wan']['provider'] = $pconfig['provider'];
+ $config['interfaces']['wan']['username'] = isset($pconfig['ondemand'] );
+ $config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
+ }
$config['version'] = 4.8;
}
+ /* Convert 4.8 -> 4.9 */
+ if ($config['version'] <= 4.8) {
+
+ /* setup new all users group */
+ $all = array();
+ $all['name'] = "all";
+ $all['description'] = "All Users";
+ $all['scope'] = "System";
+ $all['gid'] = 1998;
+ $all['member'] = array();
+
+ if (!is_array($config['system']['group']))
+ $config['system']['group'] = array();
+
+ /* work around broken uid assignments */
+ $config['system']['nextuid'] = 2000;
+ foreach ($config['system']['user'] as & $user) {
+ if (isset($user['uid']) && !$user['uid'])
+ continue;
+ $user['uid'] = $config['system']['nextuid']++;
+ }
+
+ /* work around broken gid assignments */
+ $config['system']['nextgid'] = 2000;
+ foreach ($config['system']['group'] as & $group) {
+ if ($group['name'] == $g['admin_group'])
+ $group['gid'] = 1999;
+ else
+ $group['gid'] = $config['system']['nextgid']++;
+ }
+
+ /* build group membership information */
+ foreach ($config['system']['group'] as & $group) {
+ $group['member'] = array();
+ foreach ($config['system']['user'] as & $user) {
+ $groupnames = explode(",", $user['groupname']);
+ if (in_array($group['name'],$groupnames))
+ $group['member'][] = $user['uid'];
+ }
+ }
+
+ /* reset user group information */
+ foreach ($config['system']['user'] as & $user) {
+ unset($user['groupname']);
+ $all['member'][] = $user['uid'];
+ }
+
+ /* insert new all group */
+ $groups = Array();
+ $groups[] = $all;
+ $groups = array_merge($config['system']['group'],$groups);
+ $config['system']['group'] = $groups;
+ set_local_group($all);
+
+ /* sync all local account information */
+ sync_local_accounts();
+
+ $config['version'] = 4.9;
+ }
+
$now = date("H:i:s");
log_error("Ended Configuration upgrade at $now");
-// if ($prev_version != $config['version'])
+ if ($prev_version != $config['version'])
write_config("Upgraded config version level from {$prev_version} to {$config['version']}");
}
@@ -2434,4 +2493,4 @@ function set_device_perms() {
if($g['booting']) echo ".";
$config = parse_config();
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc
index ddc9724..c37119b 100644
--- a/etc/inc/globals.inc
+++ b/etc/inc/globals.inc
@@ -60,7 +60,7 @@ $g = array(
"n_pppoe_units" => 16, /* this value can be overriden in pppoe->n_pppoe_units */
"pppoe_subnet" => 28, /* this value can be overriden in pppoe->pppoe_subnet */
"debug" => false,
- "latest_config" => "4.8",
+ "latest_config" => "4.9",
"nopkg_platforms" => array("cdrom"),
"minimum_ram_warning" => "115",
"minimum_ram_warning_text" => "128 megabytes",
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 4a47a2a..311e077 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -42,12 +42,8 @@
* returns true if user has access to edit a specific firewall nat one to one interface
******/
function have_natonetooneruleint_access($if) {
- global $config, $g, $HTTP_SERVER_VARS;
- $allowed = $g['privs'];
- if (isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))
- return true;
$security_url = "firewall_nat_1to1_edit.php?if=". strtolower($if);
- if(in_array($security_url, $allowed))
+ if(isAllowedPage($security_url, $allowed))
return true;
return false;
}
@@ -61,13 +57,8 @@ function have_natonetooneruleint_access($if) {
* returns true if user has access to edit a specific firewall nat port forward interface
******/
function have_natpfruleint_access($if) {
- global $config, $g, $HTTP_SERVER_VARS, $allowed;
- if(!$allowed)
- $allowed = $g['privs'];
- if (isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))
- return true;
$security_url = "firewall_nat_edit.php?if=". strtolower($if);
- if(in_array($security_url, $allowed))
+ if(isAllowedPage($security_url, $allowed))
return true;
return false;
}
@@ -81,14 +72,9 @@ function have_natpfruleint_access($if) {
* returns true if user has access to edit a specific firewall interface
******/
function have_ruleint_access($if) {
- global $config, $g, $HTTP_SERVER_VARS;
- $allowed = $g['privs'];
- if (isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))
- return true;
$security_url = "firewall_rules.php?if=". strtolower($if);
- if(is_array($allowed))
- if(in_array($security_url, $allowed))
- return true;
+ if(isAllowedPage($security_url))
+ return true;
return false;
}
@@ -2336,43 +2322,42 @@ function display_top_tabs(& $tab_array) {
global $HTTP_SERVER_VARS;
global $config;
global $g;
- $allowed = $g['privs'];
- if(!$allowed)
- $allowed = $_SESSION['privs'];
-
- /* does the user have access to this tab?
- * master user has access to everything.
- * if the user does not have access, simply
- * unset the tab item.
+
+ /* does the user have access to this tab?
+ * master user has access to everything.
+ * if the user does not have access, simply
+ * unset the tab item.
+ */
+
+ $tab_temp = array ();
+ foreach ($tab_array as $ta)
+ if(isAllowedPage($ta[2]))
+ $tab_temp[] = $ta;
+ /*
+ // FIXME : if the checks are not good enough
+ // in isAllowedPage, it needs to be
+ // fixed instead of kludging here
+
+ // TODO: humm what shall we do with pkg_edit.php and pkg.php?
+ if ((strpos($link, "pkg.php")) !== false || (strpos($link, "pkg_edit.php")) !== false) {
+ $pos_equal = strpos($link, "=");
+ $pos_xmlsuffix = strpos($link, ".xml");
+ // do we match an absolute url including ?xml= foo
+ if(!isAllowedPage($link, $allowed))
+ $link = substr($link, $pos_equal +1, ($pos_xmlsuffix - $pos_equal +3));
+ }
+ // next check - what if the basename contains a query string?
+ if ((strpos($link, "?")) !== false) {
+ $pos_qmark = strpos($link, "?");
+ $link = substr($link, 0, $pos_qmark);
+ }
+ $authorized_text = print_r($allowed, true);
+ if(is_array($authorized))
+ if (in_array(basename($link), $authorized))
*/
- if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
- $authorized = & $allowed;
- $tab_temp = array ();
- foreach ($tab_array as $ta) {
- $link = $ta[2];
- // TODO: humm what shall we do with pkg_edit.php and pkg.php?
- if ((strpos($link, "pkg.php")) !== false || (strpos($link, "pkg_edit.php")) !== false) {
- $pos_equal = strpos($link, "=");
- $pos_xmlsuffix = strpos($link, ".xml");
- /* do we match an absolute url including ?xml= foo */
- if(!in_array($link, $allowed))
- $link = substr($link, $pos_equal +1, ($pos_xmlsuffix - $pos_equal +3));
- }
- // next check - what if the basename contains a query string?
- if ((strpos($link, "?")) !== false) {
- $pos_qmark = strpos($link, "?");
- $link = substr($link, 0, $pos_qmark);
- }
- $authorized_text = print_r($allowed, true);
-// log_error("comparing " . basename($link) . " {$authorized_text}");
- if(is_array($authorized))
- if (in_array(basename($link), $authorized))
- $tab_temp[] = $ta;
- }
- unset ($tab_array);
- $tab_array = & $tab_temp;
- }
+ unset ($tab_array);
+ $tab_array = & $tab_temp;
echo "<table cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
@@ -2595,7 +2580,7 @@ function reload_interfaces() {
/****f* pfsense-utils/sync_webgui_passwords
* NAME
- * sync_webgui_passwords - syncs webgui and ssh passwords
+ * sync_webgui_passwords - syncs all www pwdb entries
* INPUTS
* none
* RESULT
@@ -2613,111 +2598,13 @@ function sync_webgui_passwords() {
}
/* loop through custom users and add "virtual" entries */
- if ($config['system']['user']) {
+ if ($config['system']['user'])
foreach ($config['system']['user'] as $user)
fwrite($fd, "{$user['name']}:{$user['password']}\n");
- }
fclose($fd);
chmod("{$g['varrun_path']}/htpasswd", 0600);
- $root =& getUNIXRoot();
- $crypted_pw = &$root['password'];
-
- if (!$crypted_pw) {
- log_error("Error: cannot determine root pwd in sync_webgui_passwords().\nRoot user struct follows:\n");
- if(!$root)
- log_error("Unable to determine root user" . print_r($root, true));
- log_error("Testing whether your system has the necessary users... ");
- empty($config['system']['user']) ? log_error("users are missing.\n") : log_error("users found.\n");
- return 1;
- }
-
- if(file_exists("/etc/pwd.db.tmp"))
- unlink("/etc/pwd.db.tmp");
-
- mwexec("/usr/sbin/pwd_mkdb -d /etc -p /etc/master.passwd");
- mwexec("/usr/sbin/pwd_mkdb -p /etc/master.passwd");
- /* sync root */
- $fd = popen("/usr/sbin/pw usermod -n root -H 0", "w");
- fwrite($fd, $crypted_pw);
- pclose($fd);
- mwexec("/usr/sbin/pw usermod -n root -s /bin/sh");
-
- /* and again for shell users */
- /* only users with hasShellAccess() == true should be synced */
- if($config['system']['user']) {
- $home_base = $g['platform'] == "pfSense" ? "/home" : "/var/home";
-
- if(! is_dir($home_base))
- mkdir($home_base, 0755);
-
- foreach($config['system']['user'] as $user) {
- if (hasShellAccess($user['name']) || isAllowedToCopyFiles($user['name'])) {
- $home = hasShellAccess($user['name']) ? "{$home_base}/{$user['name']}" : "{$home_base}/scponly";
- $shell = isAllowedToCopyFiles($user['name']) ? "/usr/local/bin/scponly" : "/etc/rc.initial";
- if (isAllowedToCopyFiles($user['name']))
- $user['groupname'] = "scponly";
-
- $fd = popen("/usr/sbin/pw groupshow -n {$user['groupname']} 2>&1", "r");
- $pwread = fgets($fd, 4096);
- pclose($fd);
-
- if (strpos($pwread, "unknown group") !== false) {
- $groupname = $user['groupname'];
- $group = $config['system']['group'][$groupindex[$groupname]];
-
- if (isset($group) && is_array($group)) {
- log_error("Running: /usr/sbin/pw groupadd -g {$group['gid']} -n {$group['name']}");
- $fd = popen("/usr/sbin/pw groupadd -g {$group['gid']} -n {$group['name']}", "r");
- pclose($fd);
- } elseif (isAllowedToCopyFiles($user['name'])) {
- log_error("Running: /usr/sbin/pw groupadd -g 100 -n scponly");
- $fd = popen("/usr/sbin/pw groupadd -g 100 -n scponly", "r");
- pclose($fd);
- }
- }
-
- $fd = popen("/usr/sbin/pw usershow -n {$user['name']} 2>&1", "r");
- $pwread = fgets($fd, 4096);
- pclose($fd);
-
- isSystemAdmin($user['name']) ? $group = "wheel" : $group = "staff";
-
- if (strpos($pwread, "no such user") === false) {
- log_error("Running: /usr/sbin/pw usermod -n {$user['name']} -g {$user['groupname']} -G {$group} -H 0");
- $fd = popen("/usr/sbin/pw usermod -n {$user['name']} -g {$user['groupname']} -G {$group} -H 0", "w");
- fwrite($fd, $user['password']);
- pclose($fd);
- } else {
- log_error("Running: /usr/sbin/pw useradd -u {$user['uid']} -n {$user['name']} -c '" . escapeshellarg($user['fullname']) . " -g {$user['groupname']} -G {$group} -H 0");
- $fd = popen("/usr/sbin/pw useradd -u {$user['uid']} -n {$user['name']} -c " . escapeshellarg($user['fullname']) . " -g {$user['groupname']} -G {$group} -H 0", "w");
- fwrite($fd, $user['password']);
- pclose($fd);
- }
-
- /* common user related operations */
- mwexec("/usr/sbin/pw usermod -n {$user['name']} -s {$shell}");
-
- if(! is_dir($home)) mkdir($home, 0755);
- mwexec("/usr/sbin/pw usermod -n {$user['name']} -d {$home} -m");
-
- if (isAllowedToCopyFiles($user['name'])) {
- mwexec("/usr/sbin/pw usermod -n {$user['name']} -g scponly");
- }
-
- if (file_exists("{$home_base}/scponly"))
- mwexec("chmod 0660 {$home_base}/scponly");
-
- if(isset($config['system']['ssh']['sshdkeyonly']) && ! isAllowedToCopyFiles($user['name'])) {
- create_authorized_keys($user['name'], $home);
- }
- }
- }
- }
-
- mwexec("/usr/sbin/pwd_mkdb -d /etc -p /etc/master.passwd");
- mwexec("/usr/sbin/pwd_mkdb -p /etc/master.passwd");
conf_mount_ro();
}
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index d74ff0d..3409aa1 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -34,7 +34,7 @@
function listtags() {
$ret = explode(" ", "element alias aliasurl allowedip cacert config columnitem disk dnsserver domainoverrides " .
"earlyshellcmd encryption-algorithm-option field fieldname hash-algorithm-option " .
- "hosts group interface_array item key lbpool menu mobilekey mount onetoone option ppp package passthrumac phase1 phase2 priv proxyarpnet " .
+ "hosts group member interface_array item key lbpool menu mobilekey mount onetoone option ppp package passthrumac phase1 phase2 priv proxyarpnet " .
"queue pages pipe route row rule schedule service servernat servers serversdisabled earlyshellcmd shellcmd staticmap subqueue " .
"timerange tunnel user vip virtual_server vlan winsserver ntpserver wolentry widget depends_on_package gateway_item gateway_group dyndns dnsupdate gre gif");
return $ret;
diff --git a/etc/rc.initial.password b/etc/rc.initial.password
index 6cf0228..64dd34e 100755
--- a/etc/rc.initial.password
+++ b/etc/rc.initial.password
@@ -41,12 +41,17 @@ The webConfigurator password will be reset to the default (which is "' . strtolo
gettext('Do you want to proceed [y|n]?');
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
- $adminUserName = getUNIXRootName();
- setUserName($adminUserName, "admin");
- setUserPWD($adminUserName, strtolower($g['product_name']));
- write_config(gettext("password changed from console menu"));
- system_password_configure();
+ foreach ($config['system']['user'] as & $user) {
+ if (isset($user['uid']) && !$user['uid']) {
+ $user['name'] = "admin";
+ set_local_user_password($user,strtolower($g['product_name']));
+ set_local_user($user);
+ write_config(gettext("password changed from console menu"));
+ system_password_configure();
+ break;
+ }
+ }
echo "\n" . gettext('
The password for the webConfigurator has been reset and
@@ -58,7 +63,4 @@ the default as soon as you have logged into the webConfigurator.') . "\n" .
fgets($fp);
}
-
- sync_webgui_passwords();
-
-?> \ No newline at end of file
+?>
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index 23efdb1..80da3e5 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -293,8 +293,8 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') {
<div id="right">
-
<?php
+
/* display a top alert bar if need be */
$need_alert_display = false;
$found_notices = are_notices_pending();
@@ -317,25 +317,9 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') {
echo "</div>";
}
- $auth_user = $HTTP_SERVER_VARS['AUTH_USER'];
-
- $groupindex = index_groups();
- $userindex = index_users();
-
- $allowed = array();
- $allowed[] = '';
- if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))
- if (isset($config['system']['group'][$groupindex[$config['system']['user'][$userindex[$auth_user]]['groupname']]]['pages']))
- $allowed = &$config['system']['group'][$groupindex[$config['system']['user'][$userindex[$auth_user]]['groupname']]]['pages'];
-
function output_menu_item($url, $name) {
- global $auth_user, $groupindex, $userindex, $allowed, $HTTP_SERVER_VARS, $allowed;
- if(!$allowed)
- $allowed = $_SESSION['privs'];
- if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']))
- if (!in_array(basename($url), $allowed))
- return;
- echo "<li><a href=\"{$url}\" class=\"navlnk\">{$name}</a></li>\n";
+ if (isAllowedPage($url))
+ echo "<li><a href=\"{$url}\" class=\"navlnk\">{$name}</a></li>\n";
}
?>
diff --git a/usr/local/www/firewall_nat_edit.php b/usr/local/www/firewall_nat_edit.php
index 1dfc947..e5be4d9 100755
--- a/usr/local/www/firewall_nat_edit.php
+++ b/usr/local/www/firewall_nat_edit.php
@@ -61,19 +61,6 @@ if (isset($id) && $a_nat[$id]) {
$pconfig['interface'] = "wan";
}
-if($id > -1) {
- $if = $a_nat[$id]['interface'];
- $security_url = "firewall_nat_edit.php?if=". strtolower($if);
- if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
- if(!in_array($security_url, $allowed)) {
- // User does not have access
- // echo "displaying error {$security_url}"; print_r($allowed);
- echo display_error_form("401", "Unauthorized. You do not have access to edit nat rules on the interface {$if}");
- exit;
- }
- }
-}
-
if (isset($_GET['dup']))
unset($id);
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php
index a12449a..77b8273 100755
--- a/usr/local/www/firewall_rules.php
+++ b/usr/local/www/firewall_rules.php
@@ -77,16 +77,6 @@ if (!$if || !isset($iflist[$if])) {
$if = "wan";
}
-$security_url = "firewall_rules.php?if=". strtolower($if);
-if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
- if(!in_array($security_url, $allowed)) {
- // User does not have access
-// echo "displaying error {$security_url}"; print_r($allowed);
- echo display_error_form("401", "Unauthorized. You do not have access to the page {$pagereq} for interface {$if}");
- exit;
- }
-}
-
if ($_POST) {
$pconfig = $_POST;
diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php
index 70d973f..3c2ffb7 100755
--- a/usr/local/www/firewall_rules_edit.php
+++ b/usr/local/www/firewall_rules_edit.php
@@ -55,20 +55,6 @@ if (isset($_GET['dup'])) {
$after = $_GET['dup'];
}
-if($id > -1) {
- $if = $a_filter[$id]['interface'];
- $security_url = "firewall_rules_edit.php?if=". strtolower($if);
- if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
- log_error("Checking for {$security_url}");
- if(!in_array($security_url, $allowed)) {
- // User does not have access
- // echo "displaying error {$security_url}"; print_r($allowed);
- echo display_error_form("401", "Unauthorized. You do not have access to edit rules on the interface {$if}");
- exit;
- }
- }
-}
-
if (isset($id) && $a_filter[$id]) {
$pconfig['interface'] = $a_filter[$id]['interface'];
diff --git a/usr/local/www/head.inc b/usr/local/www/head.inc
index df81b3f..a7a0376 100755
--- a/usr/local/www/head.inc
+++ b/usr/local/www/head.inc
@@ -7,12 +7,13 @@ if($config['theme'] <> "")
$g['theme'] = $config['theme'];
else
$g['theme'] = "pfsense";
+
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title><?=gentitle($pgtitle);?></title>
+ <title>gentitle( $pgtitle )</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php if (strpos($_SERVER["SCRIPT_FILENAME"], "wizard.php") !== false &&
file_exists("{$g['www_path']}/themes/{$g['theme']}/wizard.css")): ?>
@@ -24,8 +25,8 @@ else
<script type="text/javascript">var theme = "<?php echo $g['theme']; ?>"</script>
<script type="text/javascript" src="/themes/<?php echo $g['theme']; ?>/loader.js"></script>
-
<?
+
/*
* Find all javascript files that need to be included
* for this page ... from the arrays ... :)
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index 3b3f47a..7e33836 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -128,7 +128,7 @@
}
fclose($fd);
}
-
+
##build list of widgets
$directory = "/usr/local/www/widgets/widgets/";
$dirhandle = opendir($directory);
@@ -411,7 +411,6 @@ $closehead = false;
$pgtitle = array("{$g['product_name']} Dashboard");
include("head.inc");
-
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
@@ -720,4 +719,4 @@ echo $jscriptstr;
</script>
</form>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/usr/local/www/system_groupmanager.php b/usr/local/www/system_groupmanager.php
index 59bc1ec..48f3a7b 100644
--- a/usr/local/www/system_groupmanager.php
+++ b/usr/local/www/system_groupmanager.php
@@ -208,24 +208,24 @@ if (isset($_POST['id']))
if ($_GET['act'] == "del") {
if ($a_group[$_GET['id']]) {
- $ok_to_delete = true;
- if (isset($config['system']['user'])) {
- foreach ($config['system']['user'] as $userent) {
- if ($userent['groupname'] == $a_group[$_GET['id']]['name']) {
- $ok_to_delete = false;
- $input_errors[] = "users still exist who are members of this group!";
- break;
- }
- }
- }
- if ($ok_to_delete) {
- unset($a_group[$_GET['id']]);
- write_config();
- header("Location: system_groupmanager.php");
- exit;
- }
+ del_local_group($a_group[$_GET['id']]);
+ unset($a_group[$_GET['id']]);
+ write_config();
+ header("Location: system_groupmanager.php");
+ exit;
}
}
+
+if($_GET['act']=="edit"){
+ if (isset($id) && $a_group[$id]) {
+ $pconfig['name'] = $a_group[$id]['name'];
+ $pconfig['description'] = $a_group[$id]['description'];
+ if (is_array($a_group[$id]['pages']))
+ $pconfig['pages'] = $a_group[$id]['pages'];
+ else
+ $pconfig['pages'] = array();
+ }
+}
if ($_POST) {
@@ -252,30 +252,30 @@ if ($_POST) {
}
if (!$input_errors) {
-
+ $group = array();
if (isset($id) && $a_group[$id])
$group = $a_group[$id];
- if($id)
- unset($a_group[$id]);
-
$group['name'] = $_POST['groupname'];
$group['description'] = $_POST['description'];
+
unset($group['pages']);
-
foreach ($pages as $fname => $title) {
$identifier = str_replace('.php','XXXUMXXX',$fname);
$identifier = str_replace('.','XXXDOTXXX',$identifier);
if ($_POST[$identifier] == 'yes') {
$group['pages'][] = $fname;
}
- }
-
+ }
+
if (isset($id) && $a_group[$id])
$a_group[$id] = $group;
- else
+ else {
+ $group['gid'] = $config['system']['nextgid']++;
$a_group[] = $group;
-
+ }
+
+ set_local_group($group);
write_config();
header("Location: system_groupmanager.php");
@@ -286,161 +286,191 @@ if ($_POST) {
include("head.inc");
?>
-<?php include("fbegin.inc"); ?>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
- <ul id="tabnav">
- <?php
- $tab_array = array();
- $tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
- $tab_array[] = array(gettext("Group"), true, "system_groupmanager.php");
- $tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
- display_top_tabs($tab_array);
- ?>
- </ul>
- </td></tr>
-<tr>
- <td class="tabcont">
+
+<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
<?php
-if($_GET['act']=="new" || $_GET['act']=="edit"){
- if($_GET['act']=="edit"){
- if (isset($id) && $a_group[$id]) {
- $pconfig['name'] = $a_group[$id]['name'];
- $pconfig['description'] = $a_group[$id]['description'];
- $pconfig['pages'] = $a_group[$id]['pages'];
- }
- }
+ include("fbegin.inc");
+ if ($input_errors)
+ print_input_errors($input_errors);
+ if ($savemsg)
+ print_info_box($savemsg);
?>
-<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
-
-<script type="text/javascript">
- function checkall() {
- var el = document.getElementById('iform');
- for (var i = 0; i < el.elements.length; i++) {
- el.elements[i].checked = true;
- }
- }
- function checknone() {
- var el = document.getElementById('iform');
- for (var i = 0; i < el.elements.length; i++) {
- el.elements[i].checked = false;
- }
- }
-</script>
-<form action="system_groupmanager.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vncellreq">Group name</td>
- <td width="78%" class="vtable">
- <?php
- $inuse = false;
- foreach($config['system']['user'] as $su) {
- if($su['groupname'] == $pconfig['name'])
- $inuse = true;
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+ <ul id="tabnav">
+ <?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
+ $tab_array[] = array(gettext("Group"), true, "system_groupmanager.php");
+ $tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
+ display_top_tabs($tab_array);
+ ?>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabcont">
+
+ <?php if($_GET['act']=="new" || $_GET['act']=="edit"): ?>
+
+ <script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ function checkall() {
+ var el = document.getElementById('iform');
+ for (var i = 0; i < el.elements.length; i++)
+ el.elements[i].checked = true;
+ }
+ function checknone() {
+ var el = document.getElementById('iform');
+ for (var i = 0; i < el.elements.length; i++)
+ el.elements[i].checked = false;
}
- ?>
- <?php if($inuse == false): ?>
- <input name="groupname" type="text" class="formfld" id="groupname" size="20" value="<?=htmlspecialchars($pconfig['name']);?>">
- <?php else: ?>
- <?php echo $pconfig['name']; ?>
- <input name="groupname" type="hidden" class="formfld" id="groupname" value="<?=htmlspecialchars($pconfig['name']);?>">
- <?php endif; ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable">
- <input name="description" type="text" class="formfld" id="description" size="20" value="<?=htmlspecialchars($pconfig['description']);?>">
- <br>
- Group description, for your own information only</td>
- </tr>
- <tr>
- <td colspan="4"><br>&nbsp;Select that pages that this group may access. Members of this group will be able to perform all actions that<br>&nbsp; are possible from each individual web page. Ensure you set access levels appropriately.<br><br>
- <span class="vexpl"><span class="red"><strong>&nbsp;Note: </strong></span>Pages
- marked with an * are strongly recommended for every group.</span>
- </td>
+ </script>
+ <form action="system_groupmanager.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Group name</td>
+ <td width="78%" class="vtable">
+ <input name="groupname" type="text" class="formfld" id="groupname" size="20" value="<?=htmlspecialchars($pconfig['name']);?>">
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Description</td>
+ <td width="78%" class="vtable">
+ <input name="description" type="text" class="formfld" id="description" size="20" value="<?=htmlspecialchars($pconfig['description']);?>">
+ <br>
+ Group description, for your own information only
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <br>
+ Select that pages that this group may access.
+ Members of this group will be able to perform
+ all actions that are possible from each
+ individual web page. Ensure you set access
+ levels appropriately.<br>
+ <br>
+ <span class="vexpl">
+ <span class="red">
+ <strong>&nbsp;Note:</strong>
+ </span>
+ Pages marked with an * are strongly recommended
+ for every group.
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <input type="button" name="types[]" value="Check All" onClick="checkall(); return false;">
+ <input type="button" name="types[]" value="Check None" onClick="checknone(); return false;">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="listhdrr">&nbsp;</td>
+ <td class="listhdrr">Page Description</td>
+ <td class="listhdr">Filename</td>
+ </tr>
+ <?php
+ foreach ($pages as $fname => $title):
+ $identifier = str_replace('.php','XXXUMXXX',$fname);
+ $identifier = str_replace('.','XXXDOTXXX',$identifier);
+ $checked = "";
+ if (in_array($fname,$pconfig['pages']))
+ $checked = "checked";
+ ?>
+ <tr>
+ <td class="listlr">
+ <input class="check" name="<?=$identifier?>" type="checkbox" id="<?=$identifier?>" value="yes" <?=$checked;?>>
+ </td>
+ <td class="listr"><?=$title?></td>
+ <td class="listr"><?=$fname?></td>
+ </tr>
+ <?php endforeach; ?>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="save" type="submit" class="formbtn" value="Save">
+ <?php if (isset($id) && $a_group[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <?php else: ?>
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="25%" class="listhdrr">Group name</td>
+ <td width="25%" class="listhdrr">Description</td>
+ <td width="15%" class="listhdrr">Member Count</td>
+ <td width="15%" class="listhdrr">Pages Accessible</td>
+ <td width="10%" class="list"></td>
</tr>
- <tr><td colspan="4">
- <input type="button" name="types[]" value="Check All" onClick="checkall(); return false;">
- <input type="button" name="types[]" value="Check None" onClick="checknone(); return false;">
- </td></tr>
- <tr>
- <td colspan="2">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="listhdrr">&nbsp;</td>
- <td class="listhdrr">Page Description</td>
- <td class="listhdr">Filename</td>
- </tr>
- <?php
- foreach ($pages as $fname => $title) {
- $identifier = str_replace('.php','XXXUMXXX',$fname);
- $identifier = str_replace('.','XXXDOTXXX',$identifier);
- ?>
- <tr><td class="listlr">
- <input class="check" name="<?=$identifier?>" type="checkbox" id="<?=$identifier?>" value="yes" <?php if (in_array($fname,$pconfig['pages'])) echo "checked"; ?>></td>
- <td class="listr"><?=$title?></td>
- <td class="listr"><?=$fname?></td>
- </tr>
- <?
- } ?>
- </table>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="save" type="submit" class="formbtn" value="Save">
- <?php if (isset($id) && $a_group[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>">
- <?php endif; ?>
- </td>
- </tr>
- </table>
- </form>
-<?php
-} else {
-?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="35%" class="listhdrr">Group name</td>
- <td width="20%" class="listhdrr">Description</td>
- <td width="20%" class="listhdrr">Pages Accessible</td>
- <td width="10%" class="list"></td>
- </tr>
- <?php $i = 0; foreach($a_group as $group): ?>
- <tr>
- <td class="listlr">
- <?=htmlspecialchars($group['name']); ?>&nbsp;
- </td>
- <td class="listr">
- <?=htmlspecialchars($group['description']);?>&nbsp;
- </td>
- <td class="listbg">
- <font color="white">
- <?=count($group['pages']);?>&nbsp;
- </td>
- <td valign="middle" nowrap class="list"> <a href="system_groupmanager.php?act=edit&id=<?=$i; ?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit group" width="17" height="17" border="0"></a>
- &nbsp;<a href="system_groupmanager.php?act=del&id=<?=$i; ?>" onclick="return confirm('Do you really want to delete this group?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete group" width="17" height="17" border="0"></a></td>
- </tr>
- <?php $i++; endforeach; ?>
- <tr>
- <td class="list" colspan="3"></td>
- <td class="list"> <a href="system_groupmanager.php?act=new"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add group" width="17" height="17" border="0"></a></td>
- </tr>
- <tr>
- <td colspan="3">
- Additional webGui admin groups can be added here. Each group can be restricted to specific portions of the webGUI. Individually select the desired web pages each group may access. For example, a troubleshooting group could be created which has access only to selected Status and Diagnostics pages.
- </td>
- </tr>
- </table>
-<?php } ?>
+ <?php
+ $i = 0;
+ foreach($a_group as $group):
+ ?>
+ <tr>
+ <td class="listlr">
+ <?=htmlspecialchars($group['name']); ?>&nbsp;
+ </td>
+ <td class="listr">
+ <?=htmlspecialchars($group['description']);?>&nbsp;
+ </td>
+ <td class="listr">
+ <?=count($group['member'])?>
+ </td>
+ <td class="listbg">
+ <font color="white">
+ <?=count($group['pages']);?>
+ </font>
+ </td>
+ <td valign="middle" nowrap class="list">
+ <a href="system_groupmanager.php?act=edit&id=<?=$i;?>">
+ <img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit group" width="17" height="17" border="0">
+ </a>
+ &nbsp;
+ <a href="system_groupmanager.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group?')">
+ <img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete group" width="17" height="17" border="0">
+ </a>
+ </td>
+ </tr>
+ <?php
+ $i++;
+ endforeach;
+ ?>
+ <tr>
+ <td class="list" colspan="4"></td>
+ <td class="list">
+ <a href="system_groupmanager.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="add group" width="17" height="17" border="0">
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ Additional webGui admin groups can be added here.
+ Each group can be restricted to specific portions of the webGUI.
+ Individually select the desired web pages each group may access.
+ For example, a troubleshooting group could be created which has
+ access only to selected Status and Diagnostics pages.
+ </td>
+ </tr>
+ </table>
+
+ <? endif; ?>
- </td>
- </tr>
- </table>
-
-
+ </td>
+ </tr>
+</table>
+</body>
<?php include("fend.inc"); ?>
diff --git a/usr/local/www/system_usermanager.php b/usr/local/www/system_usermanager.php
index 725511f..0c440b0 100644
--- a/usr/local/www/system_usermanager.php
+++ b/usr/local/www/system_usermanager.php
@@ -33,479 +33,539 @@
*/
require("guiconfig.inc");
-// The page title for non-admins
-$pgtitle = array("System","User Password");
-/* Check for custom priv system_usermanager (no .php ending) */
-$isAdminUser = false;
-$allowed = $g['privs'];
-if(is_array($allowed))
- if (in_array("system_usermanager", $allowed))
- $isAdminUser = true;
+if (isAllowedPage("system_usermanager")) {
-if (isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']) or $isAdminUser == true) {
- // Page title for main admin
- $pgtitle = array("System","User Manager");
+ // start admin user code
+ $pgtitle = array("System","User Manager");
- $id = $_GET['id'];
- if (isset($_POST['id']))
- $id = $_POST['id'];
+ $id = $_GET['id'];
+ if (isset($_POST['id']))
+ $id = $_POST['id'];
if (!is_array($config['system']['user']))
$config['system']['user'] = array();
- admin_users_sort();
- if (is_array($config['system']['user']))
+ admin_users_sort();
+ if (is_array($config['system']['user']))
$a_user = &$config['system']['user'];
- $t_privs = $a_user[$id]['priv'];
-
- if ($_GET['act'] == "del" && $_GET['what'] == "user") {
- if ($a_user[$_GET['id']]) {
- $userdeleted = $a_user[$_GET['id']]['name'];
- unset($a_user[$_GET['id']]);
- write_config();
- $retval = system_password_configure();
- $savemsg = get_std_save_message($retval);
- $savemsg = gettext("User") . " " . $userdeleted . " " . gettext("successfully deleted") . "<br />";
- }
- } else if ($_GET['act'] == "del" && $_GET['what'] == "priv") {
- if ($t_privs[$_GET['privid']]) {
- $privdeleted = $t_privs[$_GET['privid']]['id'];
- unset($a_user[$id]['priv'][$_GET['privid']]);
- write_config();
- unset($t_privs[$_GET['privid']]);
- $_GET['act'] = "edit";
- $retval = 0;
- $savemsg = get_std_save_message($retval);
- $savemsg = gettext("Privilege") . " " . $privdeleted . " " . gettext("of user") . " " . $a_user[$_GET['id']]['name'] . " " . gettext("successfully deleted") . "<br />";
- }
- }
-
- if ($_POST) {
- unset($input_errors);
- $pconfig = $_POST;
-
- if(!$_POST['groupname'] and $_POST['usernamefld'] != "admin")
- $input_errors[] = "You must specify at least one group!";
-
- /* input validation */
- if (isset($id) && ($a_user[$id])) {
- $reqdfields = explode(" ", "usernamefld");
- $reqdfieldsn = explode(",", "Username");
- } else {
- $reqdfields = explode(" ", "usernamefld passwordfld1");
- $reqdfieldsn = explode(",", "Username,Password");
- }
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (hasShellAccess($_POST['usernamefld'])) {
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
- $input_errors[] = gettext("The username contains invalid characters.");
- } else {
- if (preg_match("/[^a-zA-Z0-9\@\.\-_]/", $_POST['usernamefld']))
- $input_errors[] = gettext("The username contains invalid characters.");
- }
-
- if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
- $input_errors[] = gettext("The passwords do not match.");
-
- if (!$input_errors && !(isset($id) && $a_user[$id])) {
- /* make sure there are no dupes */
- foreach ($a_user as $userent) {
- if ($userent['name'] == $_POST['usernamefld']) {
- $input_errors[] = gettext("Another entry with the same username already exists.");
- break;
- }
- }
- }
-
- if(is_array($_POST['groupname'])) {
- foreach($_POST['groupname'] as $groupname) {
- if ($pconfig['utype'] <> "system" && !isset($groupindex[$groupname])) {
- $input_errors[] = gettext("group {$groupname} does not exist, please define the group before assigning users.");
- }
+ $t_privs = $a_user[$id]['priv'];
+
+ if ($_GET['act'] == "del") {
+
+ if (($_GET['what'] == "user") && $a_user[$_GET['id']]) {
+ del_local_user($a_user[$_GET['id']]);
+ $userdeleted = $a_user[$_GET['id']]['name'];
+ unset($a_user[$_GET['id']]);
+ write_config();
+ $retval = system_password_configure();
+ $savemsg = gettext("User")." {$userdeleted} ".
+ gettext("successfully deleted")."<br/>";
+ }
+
+ if (($_GET['what'] == "priv") && $t_privs[$_GET['privid']]) {
+ $privdeleted = $t_privs[$_GET['privid']]['id'];
+ unset($a_user[$id]['priv'][$_GET['privid']]);
+ write_config();
+ unset($t_privs[$_GET['privid']]);
+ $_GET['act'] = "edit";
+ $savemsg = gettext("Privilege")." {$privdeleted} ".
+ gettext("of user")." {$a_user[$_GET['id']]['name']} ".
+ gettext("successfully deleted")."<br/>";
+ }
+ }
+
+ if ($_GET['act'] == "edit") {
+ if (isset($id) && $a_user[$id]) {
+ $pconfig['usernamefld'] = $a_user[$id]['name'];
+ $pconfig['fullname'] = $a_user[$id]['fullname'];
+ $pconfig['groups'] = get_local_user_groups($a_user[$id]);
+ $pconfig['utype'] = $a_user[$id]['scope'];
+ $pconfig['uid'] = $a_user[$id]['uid'];
+ $pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
+ }
+ }
+
+ if ($_GET['act'] == "new") {
+ /*
+ * set this value cause the text field is read only
+ * and the user should not be able to mess with this
+ * setting.
+ */
+ $pconfig['utype'] = "user";
+ }
+
+ if ($_POST) {
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if (isset($id) && ($a_user[$id])) {
+ $reqdfields = explode(" ", "usernamefld");
+ $reqdfieldsn = explode(",", "Username");
+ } else {
+ $reqdfields = explode(" ", "usernamefld passwordfld1");
+ $reqdfieldsn = explode(",", "Username,Password");
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld']))
+ $input_errors[] = gettext("The username contains invalid characters.");
+
+ if (($_POST['passwordfld1']) && ($_POST['passwordfld1'] != $_POST['passwordfld2']))
+ $input_errors[] = gettext("The passwords do not match.");
+
+ /* make sure this user name is unique */
+ if (!$input_errors && !(isset($id) && $a_user[$id])) {
+ foreach ($a_user as $userent) {
+ if ($userent['name'] == $_POST['usernamefld']) {
+ $input_errors[] = gettext("Another entry with the same username already exists.");
+ break;
+ }
}
}
- if (isset($config['system']['ssh']['sshdkeyonly']) &&
- empty($_POST['authorizedkeys'])) {
- $input_errors[] = gettext("You must provide an authorized key otherwise you won't be able to login into this system.");
- }
+ if(is_array($_POST['groups']))
+ foreach($_POST['groups'] as $groupname)
+ if ($pconfig['utype'] <> "system" && !isset($groupindex[$groupname]))
+ $input_errors[] = gettext("group {$groupname} does not exist, please define the group before assigning users.");
- /* if this is an AJAX caller then handle via JSON */
- if (isAjax() && is_array($input_errors)) {
- input_errors2Ajax($input_errors);
- exit;
- }
+ if (isset($config['system']['ssh']['sshdkeyonly']) && empty($_POST['authorizedkeys']))
+ $input_errors[] = gettext("You must provide an authorized key otherwise you won't be able to login into this system.");
- if (!$input_errors) {
- $userent = "";
- if (isset($id) && $a_user[$id])
- $userent = $a_user[$id];
+ /* if this is an AJAX caller then handle via JSON */
+ if (isAjax() && is_array($input_errors)) {
+ input_errors2Ajax($input_errors);
+ exit;
+ }
- /* the user did change his username */
- if ($_POST['usernamefld'] <> $_POST['oldusername']) {
- $_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
- }
+ if (!$input_errors) {
+ $userent = array();
+ if (isset($id) && $a_user[$id])
+ $userent = $a_user[$id];
- $userent['name'] = $_POST['usernamefld'];
- $userent['fullname'] = $_POST['fullname'];
+ /* the user did change his username */
+ if ($_POST['usernamefld'] <> $_POST['oldusername'])
+ $_SERVER['REMOTE_USER'] = $_POST['usernamefld'];
- if ($pconfig['utype'] <> "system")
- $userent['groupname'] = implode(",", $_POST['groupname']);
+ $userent['name'] = $_POST['usernamefld'];
+ $userent['fullname'] = $_POST['fullname'];
- isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
+ isset($_POST['utype']) ? $userent['scope'] = $_POST['utype'] : $userent['scope'] = "system";
- if ($_POST['passwordfld1'])
- $userent['password'] = crypt($_POST['passwordfld1']);
+ if ($_POST['passwordfld1'])
+ set_local_user_password($userent, $_POST['passwordfld1']);
- if(isset($config['system']['ssh']['sshdkeyonly'])) {
- $userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
- }
+ if(isset($config['system']['ssh']['sshdkeyonly']))
+ $userent['authorizedkeys'] = base64_encode($_POST['authorizedkeys']);
- if (isset($id) && $a_user[$id])
- $a_user[$id] = $userent;
- else
- $a_user[] = $userent;
+ if (isset($id) && $a_user[$id])
+ $a_user[$id] = $userent;
+ else {
+ $userent['uid'] = $config['system']['nextuid']++;
+ $a_user[] = $userent;
+ }
- write_config();
- $retval = system_password_configure();
- sync_webgui_passwords();
+ set_local_user($userent);
+ set_local_user_groups($userent,$_POST['groups']);
+ write_config();
+ $retval = system_password_configure();
- pfSenseHeader("system_usermanager.php");
- }
- }
+ pfSenseHeader("system_usermanager.php");
+ }
+ }
- include("head.inc");
+ include("head.inc");
?>
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc");?>
-<?php if ($input_errors) print_input_errors($input_errors);?>
-<?php if ($savemsg) print_info_box($savemsg);?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabnavtbl">
-<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
- $tab_array[] = array(gettext("Group"), false, "system_groupmanager.php");
- $tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
- display_top_tabs($tab_array);
-?>
- </td>
- </tr>
- <tr>
- <td class="tabcont">
-<?php
- if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors) {
- if ($_GET['act'] == "edit") {
- if (isset($id) && $a_user[$id]) {
- $pconfig['usernamefld'] = $a_user[$id]['name'];
- $pconfig['fullname'] = $a_user[$id]['fullname'];
- $pconfig['groupname'] = split(",", $a_user[$id]['groupname']);
- $pconfig['utype'] = $a_user[$id]['scope'];
- $pconfig['authorizedkeys'] = base64_decode($a_user[$id]['authorizedkeys']);
- }
- } else if ($_GET['act'] == "new") {
- /* set this value cause the text field is read only
- * and the user should not be able to mess with this
- * setting.
- */
- $pconfig['utype'] = "user";
- }
-?>
- <form action="system_usermanager.php" method="post" name="iform" id="iform">
- <div id="inputerrors"></div>
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
- <td width="78%" class="vtable">
- <input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?php if ($pconfig['utype'] == "system") { echo "readonly=\"readonly\" "; }?>/>
- <input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
- <td width="78%" class="vtable">
- <input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
- </td>
- </tr>
- <tr>
- <td width="78%" class="vtable">
- <input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
- <td width="78%" class="vtable">
- <input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?php if ($pconfig['utype'] == "system") { echo "readonly=\"readonly\" "; }?>/>
- <br />
- <?=gettext("User's full name, for your own information only");?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("User type");?></td>
- <td width="78%" class="vtable">
- <input name="utype" type="text" class="formfld unknown" id="utype" size="20" value="<?=htmlspecialchars($pconfig['utype']);?>" readonly="readonly" />
- <br />
- <?=gettext("Indicates whether this is a system (aka non-deletable) user or a user created by a particular user.");?>
- </td>
- </tr>
- <?php if (isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])): ?>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("User Privileges");?></td>
- <td width="78%" class="vtable">
- <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="5%" class="listhdrr"><?=gettext("ID");?></td>
- <td width="30%" class="listhdrr"><?=gettext("Name");?></td>
- <td width="40%" class="listhdrr"><?=gettext("Description");?></td>
- <td width="5%" class="list"></td>
- </tr>
-
- <?php if(is_array($t_privs)): ?>
- <?php $i = 0; foreach ($t_privs as $priv): ?>
- <?php if($priv['id'] <> ""): ?>
- <tr>
- <td class="listlr" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit.php?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
- <?=htmlspecialchars($priv['id']);?>
- </td>
- <td class="listlr" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit.php?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
- <?=htmlspecialchars($priv['name']);?>
- </td>
- <td class="listbg" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
- <font color="#FFFFFF"><?=htmlspecialchars($priv['descr']);?>&nbsp;</font>
- </td>
- <td valign="middle" nowrap class="list">
- <?php if($a_user[$id]['scope'] == "user"): ?>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="system_usermanager_edit.php?id=<?=$i;?>&userid=<?= $id ?>&useract=<?= $_GET['act'] ?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" /></a></td>
- <td valign="middle"><a href="system_usermanager.php?act=del&privid=<?=$i;?>&what=priv&id=<?= $id ?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" /></a></td>
- </tr>
- </table>
- <?php endif; ?>
- </td>
- </tr>
- <?php endif; ?>
- <?php $i++; endforeach; ?>
- <?php endif; ?>
-
- <?php if($a_user[$id]['scope'] == "user"): ?>
- <tr>
- <td class="list" colspan="3"></td>
- <td class="list">
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="system_usermanager_edit.php?userid=<?= $id ?>&useract=<?= $_GET['act'] ?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" /></a></td>
- </tr>
- </table>
- </td>
- </tr>
- <?php endif; ?>
- </table>
- </td>
- </tr>
- <?php endif; ?>
- <?php if (isset($config['system']['ssh']['sshdkeyonly'])): ?>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
- <td width="78%" class="vtable">
- <textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
- <br />
- <?=gettext("Paste an authorized keys file here.");?>
- </td>
- </tr>
- <?php endif; ?>
- <tr>
- <td width="22%" valign="top" class="vncell"><?=gettext("Group Name");?></td>
- <td width="78%" class="vtable">
- <select size="10" name="groupname[]" class="formselect" id="groupname" <?php if ($pconfig['utype'] == "system") { echo "disabled=\"disabled\" "; } ?> MULTIPLE>
- <?php foreach ($config['system']['group'] as $group): ?>
- <option value="<?=$group['name'];?>" <?php if (in_array($group['name'],$pconfig['groupname'])) { echo "selected"; } ?>>
- <?=htmlspecialchars($group['name']);?>
- </option>
- <?php endforeach;?>
- </select>
- <br />
- <?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input id="submit" name="save" type="submit" class="formbtn" value="Save" />
- <?php if (isset($id) && $a_user[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>" />
- <?php endif;?>
- </td>
- </tr>
- </table>
- </form>
-<?php
- } else {
-?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="35%" class="listhdrr">Username</td>
- <td width="20%" class="listhdrr">Full name</td>
- <td width="20%" class="listhdrr">Group</td>
- <td width="10%" class="list"></td>
- </tr>
-<?php
- $i = 0;
- foreach($a_user as $userent):
-?>
- <tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
- <td class="listlr">
- <table border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td align="left" valign="middle">
- <?php if($userent['scope'] == "user"): ?>
- <img src="/themes/<?=$g['theme'];?>/images/icons/icon_system-user.png" alt="User" title="User" border="0" height="20" width="20" />
- <?php else: ?>
- <img src="/themes/<?=$g['theme'];?>/images/icons/icon_system-user-grey.png" alt="User" title="User" border="0" height="20" width="20" />
- <?php endif; ?>
- &nbsp;
- </td>
- <td align="left" valign="middle">
- <?=htmlspecialchars($userent['name']);?>
- </td>
- </tr>
- </table>
- </td>
- <td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
- <td class="listbg">
- <?php
- $groupname = split(",", $userent['groupname']);
- ?>
- <font color="white"><?=htmlspecialchars(implode(",",$groupname));?></font>&nbsp;
- </td>
- <td valign="middle" nowrap class="list">
- <a href="system_usermanager.php?act=edit&id=<?=$i;?>">
- <img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
- </a>
- <?php if($userent['scope'] == "user"): ?>
- &nbsp;
- <a href="system_usermanager.php?act=del&what=user&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
- <img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
- </a>
- <?php endif; ?>
- </td>
- </tr>
<?php
- $i++;
- endforeach;
+ include("fbegin.inc");
+ if ($input_errors)
+ print_input_errors($input_errors);
+ if ($savemsg)
+ print_info_box($savemsg);
?>
- <tr>
- <td class="list" colspan="3"></td>
- <td class="list">
- <a href="system_usermanager.php?act=new">
- <img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
- </a>
- </td>
- </tr>
- <tr>
- <td colspan="3">
- <p>
- <?=gettext("Additional webConfigurator users can be added here. User permissions are determined by the admin group they are a member of.");?>
- </p>
- <p>
- <?=gettext("An user icon that appears grey indicates that it is a system user and thus it's only possible to modified a subset of the regular user data. Additionally such an user can't be deleted.");?>
- </p>
- </td>
- </tr>
- </table>
-<?php
- }
-?>
- </td>
- </tr>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabnavtbl">
+ <?php
+ $tab_array = array();
+ $tab_array[] = array(gettext("Users"), true, "system_usermanager.php");
+ $tab_array[] = array(gettext("Group"), false, "system_groupmanager.php");
+ $tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
+ display_top_tabs($tab_array);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabcont">
+
+ <?php if ($_GET['act'] == "new" || $_GET['act'] == "edit" || $input_errors): ?>
+
+ <form action="system_usermanager.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <?php
+ $ro = "";
+ if ($pconfig['utype'] == "system")
+ $ro = "readonly = \"readonly\"";
+ ?>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
+ <td width="78%" class="vtable">
+ <input name="usernamefld" type="text" class="formfld user" id="usernamefld" size="20" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" <?=$ro;?>/>
+ <input name="oldusername" type="hidden" id="oldusername" value="<?=htmlspecialchars($pconfig['usernamefld']);?>" />
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq" rowspan="2"><?=gettext("Password");?></td>
+ <td width="78%" class="vtable">
+ <input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" value="" />
+ </td>
+ </tr>
+ <tr>
+ <td width="78%" class="vtable">
+ <input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" value="" />&nbsp;<?= gettext("(confirmation)"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Full name");?></td>
+ <td width="78%" class="vtable">
+ <input name="fullname" type="text" class="formfld unknown" id="fullname" size="20" value="<?=htmlspecialchars($pconfig['fullname']);?>" <?=$ro;?>/>
+ <br/>
+ <?=gettext("User's full name, for your own information only");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("User type");?></td>
+ <td width="78%" class="vtable">
+ <input name="utype" type="text" class="formfld unknown" id="utype" size="20" value="<?=htmlspecialchars($pconfig['utype']);?>" readonly="readonly" />
+ <br/>
+ <?=gettext("Indicates whether this is a system (aka non-deletable) user or a user created by a particular user.");?>
+ </td>
+ </tr>
+
+ <?php if ($pconfig['uid']): ?>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("User Privileges");?></td>
+ <td width="78%" class="vtable">
+ <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="5%" class="listhdrr"><?=gettext("ID");?></td>
+ <td width="30%" class="listhdrr"><?=gettext("Name");?></td>
+ <td width="40%" class="listhdrr"><?=gettext("Description");?></td>
+ <td width="5%" class="list"></td>
+ </tr>
+ <?php
+ if(is_array($t_privs)):
+ $i = 0;
+ foreach ($t_privs as $priv):
+ if($priv['id'] <> ""):
+ ?>
+ <tr>
+ <td class="listlr" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit.php?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
+ <?=htmlspecialchars($priv['id']);?>
+ </td>
+ <td class="listr" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit.php?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
+ <?=htmlspecialchars($priv['name']);?>
+ </td>
+ <td class="listbg" <?php if($a_user[$id]['scope'] == "user") echo "ondblclick=\"document.location='system_usermanager_edit?id={$i}&userid={$id}&useract={$_GET['act']}';\""; ?>>
+ <font color="#FFFFFF"><?=htmlspecialchars($priv['descr']);?>&nbsp;</font>
+ </td>
+ <td valign="middle" nowrap class="list">
+ <?php if($a_user[$id]['scope'] == "user"): ?>
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle">
+ <a href="system_usermanager_edit.php?id=<?=$i;?>&userid=<?= $id ?>&useract=<?= $_GET['act'] ?>">
+ <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ <td valign="middle">
+ <a href="system_usermanager.php?act=del&privid=<?=$i;?>&what=priv&id=<?= $id ?>" onclick="return confirm('<?=gettext("Do you really want to delete this mapping?");?>')">
+ <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ </table>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php
+ endif;
+ $i++;
+ endforeach;
+ endif;
+ if ($a_user[$id]['scope'] == "user"):
+ ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle">
+ <a href="system_usermanager_edit.php?userid=<?= $id ?>&useract=<?= $_GET['act'] ?>">
+ <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
+ </a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php
+ endif;
+ ?>
+ </table>
+ </td>
+ </tr>
+
+ <?php endif; ?>
+ <?php if (isset($config['system']['ssh']['sshdkeyonly'])): ?>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Authorized keys");?></td>
+ <td width="78%" class="vtable">
+ <textarea name="authorizedkeys" cols="65" rows="7" id="authorizedkeys" class="formfld_cert" wrap="off"><?=htmlspecialchars($pconfig['authorizedkeys']);?></textarea>
+ <br/>
+ <?=gettext("Paste an authorized keys file here.");?>
+ </td>
+ </tr>
+
+ <?php endif; ?>
+
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
+ <td width="78%" class="vtable">
+ <select size="10" name="groups[]" class="formselect" id="groups" multiple>
+ <?php
+ foreach ($config['system']['group'] as $group):
+ if ($group['gid'] != 1998): /* all users group */
+ $selected = "";
+ if (in_array($group['name'],$pconfig['groups']))
+ $selected = "selected";
+ ?>
+ <option value="<?=$group['name'];?>" <?=$selected;?>>
+ <?=htmlspecialchars($group['name']);?>
+ </option>
+ <?php
+ endif;
+ endforeach;
+ ?>
+ </select>
+ <br/>
+ <?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input id="submit" name="save" type="submit" class="formbtn" value="Save" />
+ <?php if (isset($id) && $a_user[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>" />
+ <?php endif;?>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+ <?php else: ?>
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="25%" class="listhdrr">Username</td>
+ <td width="25%" class="listhdrr">Full name</td>
+ <td width="30%" class="listhdrr">Groups</td>
+ <td width="10%" class="list"></td>
+ </tr>
+ <?php
+ $i = 0;
+ foreach($a_user as $userent):
+ ?>
+ <tr ondblclick="document.location='system_usermanager.php?act=edit&id=<?=$i;?>'">
+ <td class="listlr">
+ <table border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="left" valign="center">
+ <?php
+ if($userent['scope'] == "user")
+ $usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user.png";
+ else
+ $usrimg = "/themes/{$g['theme']}/images/icons/icon_system-user-grey.png";
+ ?>
+ <img src="<?=$usrimg;?>" alt="User" title="User" border="0" height="16" width="16" />
+ </td>
+ <td align="left" valign="middle">
+ <?=htmlspecialchars($userent['name']);?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="listr"><?=htmlspecialchars($userent['fullname']);?>&nbsp;</td>
+ <td class="listbg">
+ <font color="white">
+ <?=implode(",",get_local_user_groups($userent));?>
+ </font>
+ &nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <a href="system_usermanager.php?act=edit&id=<?=$i;?>">
+ <img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="edit user" alt="edit user" width="17" height="17" border="0" />
+ </a>
+ <?php if($userent['scope'] == "user"): ?>
+ &nbsp;
+ <a href="system_usermanager.php?act=del&what=user&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this User?");?>')">
+ <img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete user" alt="delete user" width="17" height="17" border="0" />
+ </a>
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php
+ $i++;
+ endforeach;
+ ?>
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <a href="system_usermanager.php?act=new">
+ <img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add user" alt="add user" width="17" height="17" border="0" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <p>
+ <?=gettext("Additional webConfigurator users can be added here. User permissions are determined by the admin group they are a member of.");?>
+ </p>
+ <p>
+ <?=gettext("An user icon that appears grey indicates that it is a system user and thus it's only possible to modified a subset of the regular user data. Additionally such an user can't be deleted.");?>
+ </p>
+ </td>
+ </tr>
+ </table>
+
+ <?php endif; ?>
+
+ </td>
+ </tr>
</table>
+<?php include("fend.inc");?>
+</body>
+
<?php
-} else { // end of admin user code, start of normal user code
- if (isset($_POST['save'])) {
- unset($input_errors);
- /* input validation */
- $reqdfields = explode(" ", "passwordfld1");
- $reqdfieldsn = explode(",", "Password");
+ // end admin user code
+
+} else {
+
+ // start normal user code
+ $pgtitle = array("System","User Password");
+
+ if (isset($_POST['save'])) {
+ unset($input_errors);
+
+ /* input validation */
+ $reqdfields = explode(" ", "passwordfld1");
+ $reqdfieldsn = explode(",", "Password");
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
- if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
- $input_errors[] = "The passwords do not match.";
+ if ($_POST['passwordfld1'] != $_POST['passwordfld2'])
+ $input_errors[] = "The passwords do not match.";
- if (!$input_errors) {
- // all values are okay --> saving changes
- $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
+ if (!$input_errors) {
+ // all values are okay --> saving changes
+ $config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['password'] = crypt(trim($_POST['passwordfld1']));
- write_config();
+ write_config();
- sync_webgui_passwords();
+ sync_webgui_passwords();
- $retval = system_password_configure();
- $savemsg = get_std_save_message($retval);
- $savemsg = "Password successfully changed<br />";
- }
- }
+ $retval = system_password_configure();
+ $savemsg = "Password successfully changed<br />";
+ }
+ }
+
+ /* deterimine if user is not local to system */
+ $islocal = false;
+ foreach($config['system']['user'] as $user)
+ if($user['name'] == $_SESSION['Username'])
+ $islocal = true;
?>
+<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
<?php
include("head.inc");
+ include("fbegin.inc");
+ if ($input_errors)
+ print_input_errors($input_errors);
+ if ($savemsg)
+ print_info_box($savemsg);
+
+ if($islocal == false) {
+ echo "Sorry, you cannot change the password for a LDAP user.";
+ include("fend.inc");
+ exit;
+ }
?>
-<?php include("fbegin.inc");?>
-<?php if ($input_errors) print_input_errors($input_errors);?>
-<?php if ($savemsg) print_info_box($savemsg);?>
-<?php
-
-/* deterimine if user is not local to system */
-$islocal = false;
-foreach($config['system']['user'] as $user)
- if($user['name'] == $_SESSION['Username'])
- $islocal = true;
-if($islocal == false) {
- echo "Sorry, you cannot change the password for a LDAP user.";
- include("fend.inc");
- exit;
-}
+<form action="system_usermanager.php" method="post" name="iform" id="iform">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
+ <td width="78%" class="vtable">
+ <input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
+ </td>
+ </tr>
+ <tr>
+ <td width="78%" class="vtable">
+ <input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
+ &nbsp;<?=gettext("(confirmation)");?>
+ <br/>
+ <span class="vexpl">
+ <?=gettext("Select a new password");?>
+ </span>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top">&nbsp;</td>
+ <td width="78%">
+ <input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
+ </td>
+ </tr>
+ </table>
+</form>
+<?php include("fend.inc");?>
+</body>
-?>
- <body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
- <form action="system_usermanager.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td colspan="2" valign="top" class="listtopic"><?=$HTTP_SERVER_VARS['AUTH_USER']?>'s Password</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell" rowspan="2">Password</td>
- <td width="78%" class="vtable">
- <input name="passwordfld1" type="password" class="formfld pwd" id="passwordfld1" size="20" />
- </td>
- </tr>
- <tr>
- <td width="78%" class="vtable">
- <input name="passwordfld2" type="password" class="formfld pwd" id="passwordfld2" size="20" />
- &nbsp;<?=gettext("(confirmation)");?>
- <br />
- <span class="vexpl"><?=gettext("Select a new password");?></span>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
- </td>
- </tr>
- </table>
- </form>
<?php
} // end of normal user code
-?>
-<?php include("fend.inc");?>
-</body>
-</html>
+/*
+ * NOTE : sections of the code below are based on the BSD
+ * licensed CHAP.php courtesy of Michael Retterklieber.
+ */
+function set_password_hashes(& $userent, $password) {
+ $userent['password'] = crypt($password);
+ $userent['md5-hash'] = md5($password);
+/*
+ * Waiting for mhash
+ *
+ * // Converts ascii to unicode.
+ * $astr = (string) $password;
+ * $ustr = '';
+ * for ($i = 0; $i < strlen($astr); $i++) {
+ * $a = ord($astr{$i}) << 8;
+ * $ustr.= sprintf("%X", $a);
+ * }
+ *
+ * // Generate the NT-HASH from the unicode string
+ * $userent['nt-hash'] = bin2hex(mhash(MHASH_MD4, $ustr));
+ */
+}
+
+?>
diff --git a/usr/local/www/system_usermanager_edit.php b/usr/local/www/system_usermanager_edit.php
index 14bf3e5..af4a9b3 100644
--- a/usr/local/www/system_usermanager_edit.php
+++ b/usr/local/www/system_usermanager_edit.php
@@ -33,19 +33,19 @@ require("guiconfig.inc");
$pgtitle = array("System","User manager","Edit privilege");
/*
- The following code presumes, that the following XML structure exists or
- if it does not exist, it will be created.
-
- <priv>
- <id>fooid</id>
- <name>foo</name>
- <descr>foo desc</descr>
- </priv>
- <priv>
- <id>barid</id>
- <name>bar</name>
- <descr>bar desc</descr>
- </priv>
+ NOTE: The following code presumes, that the following XML structure
+ exists or if it does not exist, it will be created.
+
+ <priv>
+ <id>fooid</id>
+ <name>foo</name>
+ <descr>foo desc</descr>
+ </priv>
+ <priv>
+ <id>barid</id>
+ <name>bar</name>
+ <descr>bar desc</descr>
+ </priv>
*/
$useract = $_GET['useract'];
@@ -63,24 +63,23 @@ if (isset($_POST['id']))
$id = $_POST['id'];
if (empty($config['system']['user'][$userid])) {
- pfSenseHeader("system_usermanager.php?id={$userid}&act={$_GET['useract']}");
- exit;
+ pfSenseHeader("system_usermanager.php?id={$userid}&act={$_GET['useract']}");
+ exit;
}
-if (!is_array($config['system']['user'][$userid]['priv'])) {
- $config['system']['user'][$userid]['priv'] = array();
-}
+if (!is_array($config['system']['user'][$userid]['priv']))
+ $config['system']['user'][$userid]['priv'] = array();
$t_privs = &$config['system']['user'][$userid]['priv'];
if (isset($id) && $t_privs[$id]) {
- $pconfig['pid'] = $t_privs[$id]['id'];
- $pconfig['pname'] = $t_privs[$id]['name'];
- $pconfig['descr'] = $t_privs[$id]['descr'];
+ $pconfig['pid'] = $t_privs[$id]['id'];
+ $pconfig['pname'] = $t_privs[$id]['name'];
+ $pconfig['descr'] = $t_privs[$id]['descr'];
} else {
- $pconfig['pid'] = $_GET['pid'];
- $pconfig['pname'] = $_GET['pname'];
- $pconfig['descr'] = $_GET['descr'];
+ $pconfig['pid'] = $_GET['pid'];
+ $pconfig['pname'] = $_GET['pname'];
+ $pconfig['descr'] = $_GET['descr'];
}
if ($_POST) {
@@ -96,22 +95,18 @@ if ($_POST) {
/* check for overlaps */
foreach ($t_privs as $priv) {
- if (isset($id) && ($t_privs[$id]) && ($t_privs[$id] === $priv)) {
+ if (isset($id) && ($t_privs[$id]) && ($t_privs[$id] === $priv))
continue;
- }
if ($priv['id'] == $pconfig['pid']) {
$input_errors[] = gettext("This privilege ID already exists.");
break;
}
}
- if (hasShellAccess($userindex[$userid]['name']) ||
- isAllowedToCopyFiles($userindex[$userid]['name'])) {
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $userindex[$userid]['name']))
- $input_errors[] = gettext("The username contains invalid characters " .
- "((this means this user can't be used to create" .
- " a shell account).");
- }
+ if (preg_match("/[^a-zA-Z0-9\.\-_]/", $userindex[$userid]['name']))
+ $input_errors[] = gettext("The username contains invalid characters " .
+ "((this means this user can't be used to create" .
+ " a shell account).");
/* if this is an AJAX caller then handle via JSON */
if(isAjax() && is_array($input_errors)) {
@@ -130,30 +125,18 @@ if ($_POST) {
else
$t_privs[] = $priv;
- $name = $config['system']['user'][$userid]['name'];
- $groupname = $config['system']['user'][$userid]['groupname'];
-
- if ($priv['id'] == "hasshell") {
- log_error("Assigning UID to $name / $groupname");
- assignUID($name);
- assignGID($groupname);
- }
-
- write_config();
+ set_local_user($config['system']['user'][$userid]);
+ write_config();
- /* sync usernames and password db */
- $retval = system_password_configure();
- sync_webgui_passwords();
-
- $retval = 0;
- config_lock();
- config_unlock();
+ $retval = 0;
+ config_lock();
+ config_unlock();
- $savemsg = get_std_save_message($retval);
+ $savemsg = get_std_save_message($retval);
pfSenseHeader("system_usermanager.php?id={$userid}&act={$useract}");
exit;
- }
+ }
}
/* if ajax is calling, give them an update message */
OpenPOWER on IntegriCloud