From c9e77d73568cfa96949c9a163a922920d3398565 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 8 Nov 2018 13:52:23 +0100 Subject: [PATCH 1/2] if compress option is select but no libraries are present, tentacle will send the data uncompressed --- pandora_agents/unix/tentacle_client | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/pandora_agents/unix/tentacle_client b/pandora_agents/unix/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/unix/tentacle_client +++ b/pandora_agents/unix/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response From f35bd1369bf34fa0f8306f04c240f574d6771fcb Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 8 Nov 2018 14:38:01 +0100 Subject: [PATCH 2/2] updated tentacle_client --- pandora_agents/pc/tentacle_client | 23 ++++++++++++++----- .../shellscript/linux/tentacle_client | 23 ++++++++++++++----- .../shellscript/mac_osx/tentacle_client | 23 ++++++++++++++----- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/pandora_agents/pc/tentacle_client b/pandora_agents/pc/tentacle_client index ffed3da859..0d8ed2992f 100644 --- a/pandora_agents/pc/tentacle_client +++ b/pandora_agents/pc/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/shellscript/linux/tentacle_client b/pandora_agents/shellscript/linux/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/shellscript/linux/tentacle_client +++ b/pandora_agents/shellscript/linux/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response diff --git a/pandora_agents/shellscript/mac_osx/tentacle_client b/pandora_agents/shellscript/mac_osx/tentacle_client index ffed3da859..0d8ed2992f 100755 --- a/pandora_agents/shellscript/mac_osx/tentacle_client +++ b/pandora_agents/shellscript/mac_osx/tentacle_client @@ -58,8 +58,17 @@ use strict; use File::Basename; use Getopt::Std; use IO::Select; -use IO::Compress::Zip qw(zip $ZipError); -use IO::Uncompress::Unzip qw(unzip $UnzipError); +my $zlib_available = 1; + +eval { + eval "use IO::Compress::Zip qw(zip);1" or die($@); + eval "use IO::Uncompress::Unzip qw(unzip);1" or die($@); +}; +if ($@) { + print_log ("Zip transfer not available, required libraries not found (IO::Compress::Zip, IO::Uncompress::Unzip)."); + $zlib_available = 0; +} + use Socket (qw(SOCK_STREAM AF_INET AF_INET6)); my $SOCKET_MODULE = eval { require IO::Socket::INET6 } ? 'IO::Socket::INET6' @@ -324,7 +333,9 @@ sub parse_options { # Compress data if (defined ($opts{'z'})) { - $t_zip = 1; + if ($zlib_available == 1) { + $t_zip = 1; + } } } @@ -622,7 +633,7 @@ sub zrecv_file { # Receive file $zdata = recv_data_block ($size); if (!unzip(\$zdata => \$data)) { - print_log ("Uncompress error: $UnzipError"); + print_log ("Uncompress error: $IO::Uncompress::Unzip::UnzipError"); send_data ("ZRECV ERR\n"); return; } @@ -705,7 +716,7 @@ sub zsend_file { # Read the file and compress its contents if (! zip($file => \$data)) { send_data ("QUIT\n"); - error ("Compression error: $ZipError"); + error ("Compression error: $IO::Compress::Zip::ZipError"); return; } @@ -725,7 +736,7 @@ sub zsend_file { error ("Server responded $response."); } - print_log ("Server responded SEND OK"); + print_log ("Server responded ZSEND OK"); send_data ($data); # Wait for server response