diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2322409b29..fe13ff932d 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,10 @@ +2009-08-27 Ramon Novoa <rnovoa@artica.es> + + * util/tentacle_serverd: Remote config .conf and + .md5 files are now stored in different subdirectories. + + * bin/tentacle_server: Updated to latest version. + 2009-08-25 Ramon Novoa <rnovoa@artica.es> * lib/PandoraFMS/Core.pm: Fixed compound alerts. diff --git a/pandora_server/bin/tentacle_server b/pandora_server/bin/tentacle_server index 443ce218ad..01a4032765 100755 --- a/pandora_server/bin/tentacle_server +++ b/pandora_server/bin/tentacle_server @@ -29,7 +29,7 @@ use Thread::Semaphore; use POSIX ":sys_wait_h"; # Program version -our $VERSION = '0.2.0'; +our $VERSION = '0.2.1'; # Address to listen on my $t_address = '0.0.0.0'; @@ -46,6 +46,9 @@ my $t_daemon = 0; # Storage directory my $t_directory = ''; +# Filters +my %t_filters; + # String containing quoted invalid file name characters my $t_invalid_chars = '\?\[\]\/\\\=\+\<\>\:\;\'\,\*\~'; @@ -115,6 +118,7 @@ sub print_help { print ("\t-e cert\t\tOpenSSL certificate file. Enables SSL.\n"); print ("\t-f ca_cert\tVerify that the peer certificate is signed by a ca.\n"); print ("\t-h\t\tShow help.\n"); + print ("\t-i\t\tFilters.\n"); print ("\t-k key\t\tOpenSSL private key file.\n"); print ("\t-m size\t\tMaximum file size in bytes (default ${t_max_size}b).\n"); print ("\t-o\t\tEnable file overwrite.\n"); @@ -190,7 +194,7 @@ sub parse_options { my $tmp; # Get options - if (getopts ('a:c:de:f:hk:m:op:qr:s:t:vwx:', \%opts) == 0 || defined ($opts{'h'})) { + if (getopts ('a:c:de:f:hi:k:m:op:qr:s:t:vwx:', \%opts) == 0 || defined ($opts{'h'})) { print_help (); exit 1; } @@ -243,6 +247,21 @@ sub parse_options { } } + # Filters (regexp:dir;regexp:dir...) + if (defined ($opts{'i'})) { + my @filters = split (';', $opts{'i'}); + foreach my $filter (@filters) { + my ($regexp, $dir) = split (':', $filter); + next unless defined ($regexp) && defined ($dir); + + # Remove any trailing / + my $char = chop ($dir); + $dir .= $char if ($char) ne '/'; + + $t_filters{$regexp} = $dir; + } + } + # SSL private key file if (defined ($opts{'k'})) { $t_ssl_key = $opts{'k'}; @@ -571,7 +590,8 @@ sub recv_file { return; } - $file = "$t_directory/$base_name"; + # Apply filters + $file = "$t_directory/" . apply_filters ($base_name) . $base_name; # Check if file exists if (-f $file && $t_overwrite == 0) { @@ -613,7 +633,8 @@ sub send_file { return; } - $file = "$t_directory/$base_name"; + # Apply filters + $file = "$t_directory/" . apply_filters ($base_name) . $base_name; # Check if file exists if (! -f $file) { @@ -856,6 +877,23 @@ sub ask_passwd { return $pwd1; } +################################################################################ +## SUB apply_filters +## Applies filters to the given file. +################################################################################ +sub apply_filters ($) { + my ($file_name) = @_; + + while (my ($regexp, $dir) = each (%t_filters)) { + if ($file_name =~ /$regexp/) { + print_log ("File '$file_name' matches filter '$regexp' (changing to directory '$dir')"); + return $dir . '/'; + } + } + + return ''; +} + ################################################################################ # Main ################################################################################ diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd index dd0c21d91a..3d4ca73915 100755 --- a/pandora_server/util/tentacle_serverd +++ b/pandora_server/util/tentacle_serverd @@ -3,7 +3,7 @@ # Tentacle server simple startup script # Copyright (c) 2007 Artica Soluciones Tecnologicas S.L. # Linux Version (generic) -# v0.1 Build 210508 +# v0.1 Build 090827 ### BEGIN INIT INTO # Provides: tentacle_server @@ -24,7 +24,7 @@ TENTACLE_USER="pandora" TENTACLE_ADDR="0.0.0.0" TENTACLE_PORT="41121" -TENTACLE_EXT_OPTS="" +TENTACLE_EXT_OPTS="-i.*\.conf:conf;.*\.md5:md5" # Set umask to 0002, because group MUST have access to write files to # use remote file management on Pandora FMS Enterprise.