Project

General

Profile

Feature #1010 » permission-setting-for-captive-portal2.patch

Erik Fonnesbeck, 11/29/2010 06:29 PM

View differences:

etc/inc/globals.inc
"disablehelpmenu" => false,
"disablehelpicon" => false,
"debug" => false,
"latest_config" => "7.5",
"latest_config" => "7.6",
"nopkg_platforms" => array("cdrom"),
"minimum_ram_warning" => "105",
"minimum_ram_warning_text" => "128 MB",
etc/inc/priv/user.priv.inc
global $priv_list;
$priv_list['user-services-captiveportal-login'] = array();
$priv_list['user-services-captiveportal-login']['name'] = gettext("User - Services - Captive portal login");
$priv_list['user-services-captiveportal-login']['descr'] = gettext("Indicates whether the user is able to login on ".
"the captive portal.");
$priv_list['user-shell-access'] = array();
$priv_list['user-shell-access']['name'] = "User - System - Shell account access";
$priv_list['user-shell-access']['descr'] = "Indicates whether the user is able to login for ".
etc/inc/upgrade_config.inc
$config['system']['user'] = array();
/* migrate captivate portal to user manager */
if (is_array($config['captiveportal']['user'])) {
$config['cpusernames_temp'] = array();
foreach($config['captiveportal']['user'] as $user) {
// avoid user conflicts
$found = false;
......
}
$user['uid'] = $config['system']['nextuid']++;
$config['system']['user'][] = $user;
$config['cpusernames_temp'][] = $user['name'];
}
unset($config['captiveportal']['user']);
}
......
rename_field($config['crl'], 'name', 'descr');
}
function upgrade_075_to_076() {
global $config;
if (!isset($config['captiveportal']['enable']) && !isset($config['cpusernames_temp']))
return;
$cpusers = array();
$cpusers['name'] = "cpusers";
// Search for a group name that doesn't conflict, in case cpusers already exists
if (is_array($config['system']['group'])) {
do {
$found = false;
foreach ($config['system']['group'] as $groupent)
if ($groupent['name'] == $cpusers['name']) {
$found = true;
$cpusers['name'] = "cpusers" . (substr($cpusers['name'], 7) + 1);
break;
}
} while ($found);
} else
$config['system']['group'] = array();
$cpusers['description'] = gettext("Captive Portal Users");
$cpusers['gid'] = $config['system']['nextgid']++;
$cpusers['priv'] = array("user-services-captiveportal-login");
$cpusers['member'] = array();
if (is_array($config['system']['user'])) {
if (isset($config['cpusernames_temp'])) {
foreach ($config['system']['user'] as $userent)
if (in_array($userent['name'], $config['cpusernames_temp']))
$cpusers['member'][] = $userent['uid'];
} else {
foreach ($config['system']['user'] as $userent)
if ($userent['uid'] != 0)
$cpusers['member'][] = $userent['uid'];
}
}
if (isset($config['cpusernames_temp']))
unset($config['cpusernames_temp']);
if (empty($cpusers['member']))
unset($cpusers['member']);
$config['system']['group'][] = $cpusers;
}
?>
usr/local/captiveportal/index.php
//check against local user manager
$loginok = local_backed($_POST['auth_user'], $_POST['auth_pass']);
if ($loginok)
if (!userHasPrivilege(getUserEntry($_POST['auth_user']), "user-services-captiveportal-login"))
$loginok = false;
if ($loginok){
captiveportal_logportalauth($_POST['auth_user'],$clientmac,$clientip,"LOGIN");
portal_allow($clientip, $clientmac,$_POST['auth_user']);
usr/local/www/services_captiveportal.php
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2"><span class="vexpl"><span class="red"><strong><?=gettext("Note:"); ?></strong></span><br>
<?=gettext("When using the local user manager for authentication, only users with the Captive Portal Login privilege are allowed access. This may be given by adding the user to a Captive Portal Users group that has the privilege or by assigning the privilege directly."); ?></span></td>
</tr><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
(2-2/2)