diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index ab7f8337c1..fc6d5a2f96 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,10 @@ +2012-04-18 Dario Rodriguez + + * unix/pandora_agent: Fixed a problem detecting agent user to launch + proxy mode. Added logger function when an error occurs. + + MERGED FROM 4.0.2 + 2012-04-04 Ramon Novoa * unix/tentacle_client, diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index d7ccf98572..4b7d9395b3 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -227,6 +227,7 @@ sub print_usage () { sub error ($) { my $msg = shift; print ("[ERROR] $msg\n\n"); + `logger -i -t pandora_agent_daemon [ERROR] $msg 2>/dev/null`; exit 1; } @@ -301,7 +302,16 @@ sub log_message ($$;$) { if (defined ($dest)) { print $dest strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; } else { - print $LogFileFH strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; + #Trying to write into log file to test its writable + syswrite ($LogFileFH, ""); + + #If no error, the file is writable + if (!$!) { + print $LogFileFH strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; + } else { + #If error then log into syslog! + `logger -i -t pandora_agent_daemon [ERROR] $msg 2>/dev/null`; + } } } @@ -1740,7 +1750,7 @@ my $PID = $$; if ($Conf{'proxy_mode'}) { #Check if user is root - if ($< != 0) { + if ($> != 0) { launch_tentacle_proxy(); } else { error ('Proxy mode can not be launched as root');