mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
src: adapted more dormant debug code
This commit is contained in:
parent
93d00ecd20
commit
d178bd83e8
@ -109,15 +109,6 @@ function RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, $radiusservers,
|
||||
// If we encounter an error immediately stop this function and go back
|
||||
$racct->close();
|
||||
return $retvalue;
|
||||
|
||||
/* Old code:
|
||||
* $status = $racct->start();
|
||||
* if(PEAR::isError($status)) {
|
||||
* if ($debug)
|
||||
* printf("Radius start: %s<br />\n", $status->getMessage());
|
||||
* exit;
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -184,8 +184,9 @@ unset($security_passed);
|
||||
$groupindex = index_groups();
|
||||
$userindex = index_users();
|
||||
|
||||
function index_groups() {
|
||||
global $g, $debug, $config, $groupindex;
|
||||
function index_groups()
|
||||
{
|
||||
global $config, $groupindex;
|
||||
|
||||
$groupindex = array();
|
||||
|
||||
@ -200,8 +201,9 @@ function index_groups() {
|
||||
return ($groupindex);
|
||||
}
|
||||
|
||||
function index_users() {
|
||||
global $g, $debug, $config;
|
||||
function index_users()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (is_array($config['system']['user'])) {
|
||||
$i = 0;
|
||||
@ -214,14 +216,16 @@ function index_users() {
|
||||
return ($userindex);
|
||||
}
|
||||
|
||||
function & getUserEntry($name) {
|
||||
global $debug, $config, $userindex;
|
||||
function &getUserEntry($name)
|
||||
{
|
||||
global $config, $userindex;
|
||||
if (isset($userindex[$name]))
|
||||
return $config['system']['user'][$userindex[$name]];
|
||||
}
|
||||
|
||||
function & getUserEntryByUID($uid) {
|
||||
global $debug, $config;
|
||||
function &getUserEntryByUID($uid)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (is_array($config['system']['user']))
|
||||
foreach ($config['system']['user'] as & $user)
|
||||
@ -231,35 +235,44 @@ function & getUserEntryByUID($uid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function & getGroupEntry($name) {
|
||||
global $debug, $config, $groupindex;
|
||||
if (isset($groupindex[$name]))
|
||||
function &getGroupEntry($name)
|
||||
{
|
||||
global $config, $groupindex;
|
||||
|
||||
if (isset($groupindex[$name])) {
|
||||
return $config['system']['group'][$groupindex[$name]];
|
||||
}
|
||||
}
|
||||
|
||||
function & getGroupEntryByGID($gid) {
|
||||
global $debug, $config;
|
||||
function &getGroupEntryByGID($gid)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (is_array($config['system']['group']))
|
||||
foreach ($config['system']['group'] as & $group)
|
||||
if ($group['gid'] == $gid)
|
||||
if (is_array($config['system']['group'])) {
|
||||
foreach ($config['system']['group'] as & $group) {
|
||||
if ($group['gid'] == $gid) {
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_user_privileges(& $user) {
|
||||
|
||||
function get_user_privileges(&$user)
|
||||
{
|
||||
$privs = $user['priv'];
|
||||
if (!is_array($privs))
|
||||
if (!is_array($privs)) {
|
||||
$privs = array();
|
||||
}
|
||||
|
||||
$names = local_user_get_groups($user, true);
|
||||
|
||||
foreach ($names as $name) {
|
||||
$group = getGroupEntry($name);
|
||||
if (is_array($group['priv']))
|
||||
$privs = array_merge( $privs, $group['priv']);
|
||||
if (is_array($group['priv'])) {
|
||||
$privs = array_merge($privs, $group['priv']);
|
||||
}
|
||||
}
|
||||
|
||||
return $privs;
|
||||
@ -364,9 +377,8 @@ function local_sync_accounts()
|
||||
|
||||
}
|
||||
|
||||
function local_user_set(& $user) {
|
||||
global $g, $debug;
|
||||
|
||||
function local_user_set(&$user)
|
||||
{
|
||||
if (empty($user['password'])) {
|
||||
log_error("There is something wrong in your config because user {$user['name']} password is missing!");
|
||||
return;
|
||||
@ -410,8 +422,6 @@ function local_user_set(& $user) {
|
||||
/* root user special handling */
|
||||
if ($user_uid == 0) {
|
||||
$cmd = "/usr/sbin/pw usermod -q -n root -s /usr/local/etc/rc.initial -H 0";
|
||||
if($debug)
|
||||
log_error(sprintf(gettext("Running: %s"), $cmd));
|
||||
$fd = popen($cmd, "w");
|
||||
fwrite($fd, $user['password']);
|
||||
pclose($fd);
|
||||
@ -439,8 +449,6 @@ function local_user_set(& $user) {
|
||||
" -g {$user_group} -s {$user_shell} -d {$user_home}".
|
||||
" -c ".escapeshellarg($comment)." -H 0 2>&1";
|
||||
|
||||
if($debug)
|
||||
log_error(sprintf(gettext("Running: %s"), $cmd));
|
||||
$fd = popen($cmd, "w");
|
||||
fwrite($fd, $user['password']);
|
||||
pclose($fd);
|
||||
@ -512,8 +520,9 @@ function local_user_set_password(& $user, $password)
|
||||
$user['nt-hash'] = bin2hex(hash("md4", $ustr));
|
||||
}
|
||||
|
||||
function local_user_get_groups($user, $all = false) {
|
||||
global $debug, $config;
|
||||
function local_user_get_groups($user, $all = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$groups = array();
|
||||
if (!is_array($config['system']['group']))
|
||||
@ -525,8 +534,9 @@ function local_user_get_groups($user, $all = false) {
|
||||
if (in_array($user['uid'], $group['member']))
|
||||
$groups[] = $group['name'];
|
||||
|
||||
if ( $all )
|
||||
$groups[] = "all";
|
||||
if ($all) {
|
||||
$groups[] = 'all';
|
||||
}
|
||||
|
||||
sort($groups);
|
||||
|
||||
@ -534,8 +544,9 @@ function local_user_get_groups($user, $all = false) {
|
||||
|
||||
}
|
||||
|
||||
function local_user_set_groups($user, $new_groups = NULL ) {
|
||||
global $debug, $config, $groupindex;
|
||||
function local_user_set_groups($user, $new_groups = null)
|
||||
{
|
||||
global $config, $groupindex;
|
||||
|
||||
if (!is_array($config['system']['group']))
|
||||
return;
|
||||
@ -595,9 +606,8 @@ function local_group_del_user($user) {
|
||||
}
|
||||
}
|
||||
|
||||
function local_group_set($group, $reset = false) {
|
||||
global $debug;
|
||||
|
||||
function local_group_set($group, $reset = false)
|
||||
{
|
||||
$group_name = $group['name'];
|
||||
$group_gid = $group['gid'];
|
||||
$group_members = "''";
|
||||
@ -618,25 +628,20 @@ function local_group_set($group, $reset = false) {
|
||||
/* add or mod group db */
|
||||
$cmd = "/usr/sbin/pw {$group_op} {$group_name} -g {$group_gid} -M {$group_members} 2>&1";
|
||||
|
||||
if($debug)
|
||||
log_error(sprintf(gettext("Running: %s"), $cmd));
|
||||
mwexec($cmd);
|
||||
|
||||
}
|
||||
|
||||
function local_group_del($group) {
|
||||
global $debug;
|
||||
|
||||
function local_group_del($group)
|
||||
{
|
||||
/* delete from group db */
|
||||
$cmd = "/usr/sbin/pw groupdel {$group['name']}";
|
||||
|
||||
if($debug)
|
||||
log_error(sprintf(gettext("Running: %s"), $cmd));
|
||||
mwexec($cmd);
|
||||
}
|
||||
|
||||
function ldap_test_connection($authcfg) {
|
||||
global $debug, $config, $g;
|
||||
function ldap_test_connection($authcfg)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($authcfg) {
|
||||
if (strstr($authcfg['ldap_urltype'], "Standard"))
|
||||
@ -673,8 +678,10 @@ function ldap_test_connection($authcfg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function ldap_setup_caenv($authcfg) {
|
||||
function ldap_setup_caenv($authcfg)
|
||||
{
|
||||
global $g;
|
||||
|
||||
require_once("certs.inc");
|
||||
|
||||
unset($caref);
|
||||
@ -702,8 +709,9 @@ function ldap_setup_caenv($authcfg) {
|
||||
}
|
||||
}
|
||||
|
||||
function ldap_test_bind($authcfg) {
|
||||
global $debug, $config, $g;
|
||||
function ldap_test_bind($authcfg)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($authcfg) {
|
||||
if (strstr($authcfg['ldap_urltype'], "Standard"))
|
||||
@ -763,8 +771,9 @@ function ldap_test_bind($authcfg) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function ldap_get_user_ous($show_complete_ou=true, $authcfg) {
|
||||
global $debug, $config, $g;
|
||||
function ldap_get_user_ous($show_complete_ou=true, $authcfg)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(!function_exists("ldap_connect"))
|
||||
return;
|
||||
@ -861,8 +870,9 @@ function ldap_get_user_ous($show_complete_ou=true, $authcfg) {
|
||||
return $ous;
|
||||
}
|
||||
|
||||
function ldap_get_groups($username, $authcfg) {
|
||||
global $debug, $config;
|
||||
function ldap_get_groups($username, $authcfg)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(!function_exists("ldap_connect"))
|
||||
return;
|
||||
@ -976,17 +986,17 @@ function ldap_get_groups($username, $authcfg) {
|
||||
|
||||
$groups = print_r($memberof,true);
|
||||
|
||||
//log_error("Returning groups ".$groups." for user $username");
|
||||
|
||||
return $memberof;
|
||||
}
|
||||
|
||||
function ldap_format_host($host) {
|
||||
function ldap_format_host($host)
|
||||
{
|
||||
return is_ipaddrv6($host) ? "[$host]" : $host ;
|
||||
}
|
||||
|
||||
function ldap_backed($username, $passwd, $authcfg) {
|
||||
global $debug, $config;
|
||||
function ldap_backed($username, $passwd, $authcfg)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(!$username)
|
||||
return;
|
||||
@ -1097,17 +1107,13 @@ function ldap_backed($username, $passwd, $authcfg) {
|
||||
/* Person. To later be used by ldap_get_groups. */
|
||||
/* that way we don't have to search twice. */
|
||||
/*****************************************************************/
|
||||
if ($debug)
|
||||
log_error(sprintf(gettext("Now Searching for %s in directory."), $username));
|
||||
|
||||
/* Iterate through the user containers for search */
|
||||
foreach ($ldac_splits as $i => $ldac_split) {
|
||||
$ldac_split = isset($authcfg['ldap_utf8']) ? utf8_encode($ldac_split) : $ldac_split;
|
||||
$ldapfilter = isset($authcfg['ldap_utf8']) ? utf8_encode($ldapfilter) : $ldapfilter;
|
||||
$ldapsearchbasedn = isset($authcfg['ldap_utf8']) ? utf8_encode("{$ldac_split},{$ldapbasedn}") : "{$ldac_split},{$ldapbasedn}";
|
||||
/* Make sure we just use the first user we find */
|
||||
if ($debug) {
|
||||
log_error(sprintf(gettext('Now Searching in server %1$s, container %2$s with filter %3$s.'), $ldapname, utf8_decode($ldac_split), utf8_decode($ldapfilter)));
|
||||
}
|
||||
if ($ldapscope == "one")
|
||||
$ldapfunc = "ldap_list";
|
||||
else
|
||||
@ -1146,19 +1152,15 @@ function ldap_backed($username, $passwd, $authcfg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
$userdn = isset($authcfg['ldap_utf8']) ? utf8_decode($userdn) : $userdn;
|
||||
log_error(sprintf(gettext('Logged in successfully as %1$s via LDAP server %2$s with DN = %3$s.'), $username, $ldapname, $userdn));
|
||||
}
|
||||
|
||||
/* At this point we are bound to LDAP so the user was auth'd okay. Close connection. */
|
||||
@ldap_unbind($ldap);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function radius_backed($username, $passwd, $authcfg, &$attributes = array()) {
|
||||
global $debug, $config;
|
||||
function radius_backed($username, $passwd, $authcfg, &$attributes = array())
|
||||
{
|
||||
global $config;
|
||||
$ret = false;
|
||||
|
||||
require_once("radius.inc");
|
||||
@ -1182,8 +1184,6 @@ function radius_backed($username, $passwd, $authcfg, &$attributes = array()) {
|
||||
if (PEAR::isError($rauth->start())) {
|
||||
$retvalue['auth_val'] = 1;
|
||||
$retvalue['error'] = $rauth->getError();
|
||||
if ($debug)
|
||||
printf(gettext("Radius start: %s<br />\n"), $retvalue['error']);
|
||||
}
|
||||
|
||||
// XXX - billm - somewhere in here we need to handle securid challenge/response
|
||||
@ -1193,19 +1193,13 @@ function radius_backed($username, $passwd, $authcfg, &$attributes = array()) {
|
||||
if (PEAR::isError($result)) {
|
||||
$retvalue['auth_val'] = 1;
|
||||
$retvalue['error'] = $result->getMessage();
|
||||
if ($debug)
|
||||
printf(gettext("Radius send failed: %s<br />\n"), $retvalue['error']);
|
||||
} else if ($result === true) {
|
||||
if ($rauth->getAttributes())
|
||||
$attributes = $rauth->listAttributes();
|
||||
$retvalue['auth_val'] = 2;
|
||||
if ($debug)
|
||||
printf(gettext("Radius Auth succeeded")."<br />\n");
|
||||
$ret = true;
|
||||
} else {
|
||||
$retvalue['auth_val'] = 3;
|
||||
if ($debug)
|
||||
printf(gettext("Radius Auth rejected")."<br />\n");
|
||||
}
|
||||
|
||||
// close OO RADIUS_AUTHENTICATION
|
||||
|
||||
@ -1285,11 +1285,6 @@
|
||||
* | work with other systems. pfSense base is FreeBSD.
|
||||
*/
|
||||
function _detectChange() {
|
||||
global $debug;
|
||||
|
||||
if ($debug)
|
||||
log_error("DynDns ({$this->_dnsHost}): _detectChange() starting.");
|
||||
|
||||
$currentTime = time();
|
||||
|
||||
$wan_ip = $this->_checkIP();
|
||||
@ -1375,23 +1370,14 @@
|
||||
* - status is returned from a DynDNS service provider.
|
||||
*/
|
||||
function _debug($data) {
|
||||
global $debug;
|
||||
|
||||
if ($debug) {
|
||||
$string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n";
|
||||
conf_mount_rw();
|
||||
$file = fopen($this->_debugFile, 'a');
|
||||
fwrite($file, $string);
|
||||
fclose($file);
|
||||
conf_mount_ro();
|
||||
}
|
||||
$string = date('m-d-y h:i:s').' - ('.$this->_debugID.') - ['.$this->_dnsService.'] - '.$data."\n";
|
||||
conf_mount_rw();
|
||||
$file = fopen($this->_debugFile, 'a');
|
||||
fwrite($file, $string);
|
||||
fclose($file);
|
||||
conf_mount_ro();
|
||||
}
|
||||
function _checkIP() {
|
||||
global $debug;
|
||||
|
||||
if ($debug)
|
||||
log_error("DynDns ({$this->_dnsHost}): _checkIP() starting.");
|
||||
|
||||
if ($this->_useIPv6 == true) {
|
||||
$ip_address = find_interface_ipv6($this->_if);
|
||||
if (!is_ipaddrv6($ip_address))
|
||||
|
||||
@ -1730,8 +1730,9 @@ if(!function_exists("split")) {
|
||||
}
|
||||
}
|
||||
|
||||
function update_alias_names_upon_change($section, $field, $new_alias_name, $origname) {
|
||||
global $g, $config, $pconfig, $debug;
|
||||
function update_alias_names_upon_change($section, $field, $new_alias_name, $origname)
|
||||
{
|
||||
global $g, $config, $pconfig;
|
||||
if(!$origname)
|
||||
return;
|
||||
|
||||
@ -1743,13 +1744,8 @@ function update_alias_names_upon_change($section, $field, $new_alias_name, $orig
|
||||
return;
|
||||
}
|
||||
|
||||
if($debug) $fd = fopen('/tmp/print_r', 'a');
|
||||
if($debug) fwrite($fd, print_r($pconfig, true));
|
||||
|
||||
if(is_array($sectionref)) {
|
||||
foreach($sectionref as $itemkey => $item) {
|
||||
if($debug) fwrite($fd, "$itemkey\n");
|
||||
|
||||
$fieldfound = true;
|
||||
$fieldref = &$sectionref[$itemkey];
|
||||
foreach($field as $fieldname) {
|
||||
@ -1761,14 +1757,10 @@ function update_alias_names_upon_change($section, $field, $new_alias_name, $orig
|
||||
}
|
||||
}
|
||||
if($fieldfound && $fieldref == $origname) {
|
||||
if($debug) fwrite($fd, "Setting old alias value $origname to $new_alias_name\n");
|
||||
$fieldref = $new_alias_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($debug) fclose($fd);
|
||||
|
||||
}
|
||||
|
||||
function update_alias_url_data() {
|
||||
|
||||
@ -48,10 +48,7 @@ if(!function_exists("update_output_window")) {
|
||||
if (!function_exists("pkg_debug")) {
|
||||
/* set up logging if needed */
|
||||
function pkg_debug($msg) {
|
||||
global $g, $debug, $fd_log;
|
||||
|
||||
if (!$debug)
|
||||
return;
|
||||
global $fd_log;
|
||||
|
||||
if (!$fd_log) {
|
||||
if (!$fd_log = fopen("/tmp/pkg_mgr_{$package}.log", "w"))
|
||||
|
||||
@ -486,10 +486,6 @@ if ($intip6 != '') {
|
||||
|
||||
if ($intip != '' || $intip6 != '') {
|
||||
if (count($ifdescrs) == "1" or $interface == "lan") {
|
||||
if ($debug) {
|
||||
echo "ifdescrs count is " . count($ifdescrs) . "\n";
|
||||
echo "interface is {$interface} \n";
|
||||
}
|
||||
echo gettext('You can now access the webConfigurator by opening the following URL in your web browser:') . "\n";
|
||||
if(!empty($config['system']['webgui']['port'])) {
|
||||
$webuiport = $config['system']['webgui']['port'];
|
||||
|
||||
@ -59,11 +59,6 @@ $tab = $_REQUEST['tab'];
|
||||
if($_POST)
|
||||
$origname = $_POST['origname'];
|
||||
|
||||
// Debugging
|
||||
if ($debug) {
|
||||
unlink_if_exists('/tmp/alias_rename_log.txt');
|
||||
}
|
||||
|
||||
function alias_same_type($name, $type) {
|
||||
global $config;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user