From b9a3ef486ebcde18a5ade37865ff8f397185d24f Mon Sep 17 00:00:00 2001 From: Till Brehm <tbrehm@ispconfig.org> Date: Sun, 24 Jul 2016 05:30:59 -0400 Subject: [PATCH] Fixed #3979 Mailbox users unable to save autoresponders --- server/scripts/vlogger | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/server/scripts/vlogger b/server/scripts/vlogger index d136af1..5bc50f3 100755 --- a/server/scripts/vlogger +++ b/server/scripts/vlogger @@ -28,6 +28,7 @@ # 1.1 bugfix release # 1.2 support for mod_logio # 1.3 various contributed bugfixes +# 1.3ISPconfig1 This local version has been modified for ISPConfig. Namely: "Added better error handling to vlogger script in case the MySQL database connection is not available." # # # TODO: @@ -170,9 +171,9 @@ # log directory my $LOGDIR; if ( $ARGV[0] ) { - if ( !-d $ARGV[0] ) { + if ( !-d $ARGV[0] || -l $ARGV[0]) { print STDERR - "[vlogger] target directory $ARGV[0] does not exist - exiting.\n\n"; + "[vlogger] target directory $ARGV[0] does not exist or is a symlink - exiting.\n\n"; exit; } $LOGDIR = $ARGV[0]; @@ -252,9 +253,14 @@ } # test the connection - my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS ) - or die "DBI Error: $!"; - $dbh->disconnect; + eval { + my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS ) + or die "DBI Error: $!"; + $dbh->disconnect; + }; + if ($@) { + print "MySQL Connection problem\n"; + } # SIGALRM dumps the tracker hash $SIG{ALRM} = \&dump_tracker; @@ -423,6 +429,11 @@ unless ( -d "${vhost}" ) { mkdir("${vhost}"); } + + # Dont log to symlinks + if( -l "${vhost}/".time2str( $TEMPLATE, time() ) ) { + die("Log target is a symlink: $LOGDIR/${vhost}/".time2str( $TEMPLATE, time() )); + } # open the file using the template open $vhost, ">>${vhost}/" . time2str( $TEMPLATE, time() ) @@ -503,7 +514,8 @@ # sub to update the database with the tracker data sub dump_tracker { - if ( keys(%tracker) > 0 ) { + eval { + if ( keys(%tracker) > 0 ) { my $dbh = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS ) or warn "DBI Error: $!"; foreach my $key ( keys(%tracker) ) { @@ -529,6 +541,10 @@ %tracker = (); } alarm $DBI_DUMP; + }; + if ($@) { + print "Unable to store vlogger data in database\n"; + } } # print usage info -- Gitblit v1.9.1