Skip to content

Commit

Permalink
fix getAllowedPages / privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Apr 14, 2015
1 parent b795925 commit ee7be88
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/etc/inc/auth.inc
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function local_user_get_groups($user, $all = false)
}

foreach ($config['system']['group'] as $group) {
if (is_array($group['member'])) {
if (isset($group['member'])) {
if (in_array($user['uid'], $group['member']) || ($group['name'] == "all" && $all)) {
$groups[] = $group['name'];
}
Expand Down
6 changes: 6 additions & 0 deletions src/etc/inc/priv.defs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1462,3 +1462,9 @@ $priv_list['user-pptp-dialin']['descr'] = "Indicates whether the user is allowed
$priv_list['user-pppoe-dialin'] = array();
$priv_list['user-pppoe-dialin']['name'] = "User - VPN - PPPOE Dialin";
$priv_list['user-pppoe-dialin']['descr'] = "Indicates whether the user is allowed to dial in via PPPOE";

// sort by name ( case insensitive )
uasort($priv_list,function($a,$b) {
return strcasecmp($a["name"], $b["name"]) ;
});

26 changes: 13 additions & 13 deletions src/etc/inc/priv.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@

require_once 'priv.defs.inc';

if (is_array($priv_list)) {
usort($priv_list, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
}

function cmp_page_matches($page, & $matches, $fullwc = true) {

// $dbg_matches = implode(",", $matches);
Expand Down Expand Up @@ -172,7 +166,7 @@ function isAllowedPage($page)
function getPrivPages(& $entry, & $allowed_pages) {
global $priv_list;

if (!is_array($entry['priv']))
if (!isset($entry['priv']) || !is_array($entry['priv']))
return;

foreach ($entry['priv'] as $pname) {
Expand All @@ -198,7 +192,11 @@ function getAllowedPages($username) {
$allowed_pages = array();
$allowed_groups = array();

$authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
if (isset($config['system']['webgui']['authmode'])) {
$authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
} else {
$authcfg['type'] = 'local';
}
// obtain ldap groups if we are in ldap mode
if ($authcfg['type'] == "ldap")
$allowed_groups = @ldap_get_groups($username, $authcfg);
Expand All @@ -208,15 +206,17 @@ function getAllowedPages($username) {
getPrivPages($local_user, $allowed_pages);

// obtain local groups if we have a local user
if ($local_user)
$allowed_groups = local_user_get_groups($local_user);
$allowed_groups = local_user_get_groups($local_user);
}

// build a list of allowed pages
if (is_array($config['system']['group']) && is_array($allowed_groups))
foreach ($config['system']['group'] as $group)
if (in_array($group['name'], $allowed_groups))
if (is_array($config['system']['group']) && is_array($allowed_groups)) {
foreach ($config['system']['group'] as $group) {
if (in_array($group['name'], $allowed_groups)) {
getPrivPages($group, $allowed_pages);
}
}
}

// $dbg_pages = implode(",", $allowed_pages);
// $dbg_groups = implode(",", $allowed_groups);
Expand Down

0 comments on commit ee7be88

Please sign in to comment.