From db30fd170bc54eccda287cf50eb25cac65ec6b5a Mon Sep 17 00:00:00 2001 From: rettenbe Date: Fri, 7 Nov 2008 15:58:11 +0000 Subject: [PATCH] * fixes save_log probelm: install logs are now commited to si-server again * another perl module is used to create random files under /tmp git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12974 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/gosaTriggered.pm | 9 ++++--- gosa-si/gosa-si-client | 33 ++++++++++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gosa-si/client/events/gosaTriggered.pm b/gosa-si/client/events/gosaTriggered.pm index 6edc2758f..dca6f6308 100644 --- a/gosa-si/client/events/gosaTriggered.pm +++ b/gosa-si/client/events/gosaTriggered.pm @@ -50,7 +50,7 @@ use warnings; use GOSA::GosaSupportDaemon; use Data::Dumper; use MIME::Base64; -use Data::Random qw(:all); +use File::Temp qw/ tempfile/; BEGIN {} @@ -126,10 +126,9 @@ sub usr_msg { my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]); my $message = &decode_base64(@{$msg_hash->{'message'}}[0]); - my $rand_file = "/tmp/goto_notify_".join("",rand_chars(set=>'alphanumeric', min=>16, max=>16)); - open(DATEI, ">$rand_file"); - print DATEI "source:$source\ntarget:$target\nusr:$to\nsubject:".@{$msg_hash->{'subject'}}[0]."\nmessage:".@{$msg_hash->{'message'}}[0]."\n"; - close DATEI; + my ($rand_fh, $rand_file) = tempfile( SUFFIX => '.goto_notify'); + print $rand_fh "source:$source\ntarget:$target\nusr:$to\nsubject:".@{$msg_hash->{'subject'}}[0]."\nmessage:".@{$msg_hash->{'message'}}[0]."\n"; + close $rand_fh; my $feedback = system("/usr/bin/goto-notify user-message '$to' '$subject' '$message' '$rand_file' &" ); diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 9c7e09e2f..d3965ce39 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -889,30 +889,37 @@ sub save_fai_log { my ($fai_log_dir) = @_ ; my $FAI_DIR; - opendir($FAI_DIR, $fai_log_dir); - if (not defined $FAI_DIR) { - daemon_log("ERROR: can not open directory $fai_log_dir: $!", 1); + my $log_dir = File::Spec->catdir($fai_log_dir, "localhost/last"); + + if (not -r -d $log_dir) { + daemon_log("ERROR: cannot open directory $log_dir", 1); return; } + opendir($FAI_DIR, "$log_dir"); my @log_files = readdir($FAI_DIR); closedir($FAI_DIR); - my @log_list; + my @log_list; foreach my $log_file (@log_files) { if( $log_file eq "." || $log_file eq ".." ) { next; } + my $log = "log_file:$log_file:"; - $log_file = File::Spec->catfile( $fai_log_dir, $log_file ); - open(my $FILE, "<$log_file"); - if (not defined $FILE ) { - daemon_log("ERROR: can not open '$log_file': $!", 1); + $log_file = File::Spec->catfile( $log_dir, $log_file ); + + if (not -r -f $log_file) { + daemon_log("ERROR: cannot read $log_file", 1); next; } - my @lines = <$FILE>; - my $log_string = join("", @lines); - $log .= &encode_base64($log_string); - push(@log_list, $log); - close ($FILE); + + if (-r -f $log_file) { + open(FILE, "<$log_file"); + my @lines = ; + close (FILE); + my $log_string = join("", @lines); + $log .= &encode_base64($log_string); + push(@log_list, $log); + } } my $all_log_string = join("\n", @log_list); -- 2.30.2