From bb2b469cfc24c5c98c1842ade4c3bafb0220122c Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Thu, 6 Oct 2022 23:12:59 -0500 Subject: [PATCH] Emit stack backtrace if syslog call fails --- gatekeeper.pl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 445d0ea..b0d2969 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -106,6 +106,8 @@ use warnings; use constant (); # load this now for use in later BEGIN blocks +use Carp qw(cluck); # for stack trace on error in ftp_syslog + use FindBin; use File::Spec; @@ -349,13 +351,10 @@ sub ftp_syslog { # The syslog function is pretty picky, and (sometimes) dies silently # when using non-valid syslog priorities. - # That's why we run it inside an eval, and print out any errors to STDERR. - eval { - syslog($priority, $message); - }; - if ($@) { - print STDERR "$@\n"; - } + # That's why we run it inside an eval, with errors printed to STDERR, + # complete with stack backtrace. + eval { syslog($priority, $message) }; + cluck($@) if $@; } sub ftp_warn($) { -- 2.25.1