Commit d178bd83 authored by Franco Fichtner's avatar Franco Fichtner

src: adapted more dormant debug code

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