From 2682fdb0618f03d83cbf693978b1bcb92953d462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Su=C3=A1rez?= Date: Mon, 5 Jun 2023 17:39:15 -0600 Subject: [PATCH] Remove aditional fallbacks --- pandora_agents/unix/pandora_agent | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 1c7fbfc912..f4f88e46a8 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1423,9 +1423,6 @@ sub start_log (;$) { # Open it if ($Conf{'logfile'} eq 'syslog' && eval { Sys::Syslog->can('openlog') }) { openlog('pandora_agent', 'nowait', 'daemon'); - } elsif($Conf{'logfile'} eq 'syslog') { - # Fallback if syslog is not available - } else { open ($LogFileFH, "> $Conf{'logfile'}") or error ("Could not open log file $Conf{'logfile'} for writing: $!."); print "Logging to $Conf{'logfile'}\n" if (!defined ($quiet)); @@ -1436,8 +1433,8 @@ sub start_log (;$) { # Rotates the agent logfile. ################################################################################ sub rotate_log () { - if ($Conf{'logfile'} eq 'syslog') { - # No action needed && no needed syslog fallback. + if ($Conf{'logfile'} eq 'syslog' && eval { Sys::Syslog->can('syslog') }) { + # No action needed. return; }else { if ($Conf{'logrotate'} < 0){ @@ -1461,9 +1458,6 @@ sub rotate_log () { sub stop_log () { if ($Conf{'logfile'} eq 'syslog' && eval { Sys::Syslog->can('closelog') }) { closelog(); - } elsif($Conf{'logfile'} eq 'syslog') { - # Fallback if syslog is not available - } else { close ($LogFileFH); } @@ -1479,9 +1473,6 @@ sub log_message ($$;$) { print $dest strftime ('%Y/%m/%d %H:%M:%S', localtime ()) . " - [$source] - $msg\n"; } elsif ($Conf{'logfile'} eq 'syslog' && eval { Sys::Syslog->can('syslog') }) { syslog('info', $msg); - } elsif($Conf{'logfile'} eq 'syslog') { - # Fallback if syslog is not available - } else { #Trying to write into log file to test its writable syswrite ($LogFileFH, "");