From dacda6b4d9ed29ab9240b3260a0c1660f2f47d4a Mon Sep 17 00:00:00 2001
From: Tomas Plesnik <plesnik@ics.muni.cz>
Date: Mon, 9 Feb 2015 16:04:12 +0100
Subject: [PATCH] pwd zjistovana pomoci modulu FindBin; smazana volba
 warden-dir

---
 src/warden-client/bin/sender-cli.pl | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/warden-client/bin/sender-cli.pl b/src/warden-client/bin/sender-cli.pl
index 86ea5b3..4658298 100755
--- a/src/warden-client/bin/sender-cli.pl
+++ b/src/warden-client/bin/sender-cli.pl
@@ -9,8 +9,8 @@ use warnings;
 
 use DateTime;
 use Getopt::Long;
-use File::Basename;
-use FindBin qw($RealScript);
+use FindBin qw($RealBin $RealScript);
+FindBin::again;
 
 #-------------------------------------------------------------------------------
 # Warden 2.2. Command-line Client, Sender
@@ -36,7 +36,6 @@ my $opt_a = ""; # attack scale
 my $opt_n = ""; # note
 
 # Other attributes
-my $opt_w; # path to warden directory
 my $opt_h; # display help
 
 # Check whether mandatory fields are given. Otherwise print help and exit.
@@ -49,11 +48,10 @@ if (!GetOptions("service|s=s" => \$opt_s,
                 "port|r=i"         => \$opt_r,
                 "attack-scale|a=i" => \$opt_a,
                 "note|n=s"         => \$opt_n,
-                "warden-dir|w=s"   => \$opt_w,
-                "help|h"           => \$opt_h) || 
-    !defined($opt_s) || !defined($opt_e) || !defined($opt_o) || 
+                "help|h"           => \$opt_h) ||
+    !defined($opt_s) || !defined($opt_e) || !defined($opt_o) ||
     $opt_h) {
-  print "\nUsage: ./$RealScript -s <service> -e <event_type> -o <source_type> [-t <timestamp_of_detection>] [-v <source>] [-p <protocol>] [-r <port>] [-a <attack_scale>] [-n <note>] [-w <warden_directory>] [-h]\n";
+  print "Usage: ./$RealScript -s <service> -e <event_type> -o <source_type> [-t <timestamp_of_detection>] [-v <source>] [-p <protocol>] [-r <port>] [-a <attack_scale>] [-n <note>] [-w <warden_directory>] [-h]\n";
   print "\nArguments:\n\n";
   print "  -s SERVICE, --service=SERVICE                -  Name of detection service\n\n";
   print "  -e EVENT_TYPE, --event-type=EVENT_TYPE       -  Type of detected event\n\n";
@@ -67,11 +65,10 @@ if (!GetOptions("service|s=s" => \$opt_s,
   print "  -r PORT, --port=PORT                         -  Port\n\n";
   print "  -a ATTACK_SCALE, --attack-scale=ATTACK_SCALE -  Scale of detected event\n\n";
   print "  -n NOTE, --note=NOTE                         -  Note, comment or other data\n\n";
-  print "  -w WARDEN_DIR, --warden-dir=WARDEN_DIR       -  Path to the warden-client directory.\n\n";
   print "  -h, --help                                   -  Print help\n\n";
 
-  print "\nExample #1: ./$RealScript -s PhishTracker -e webattack -o URL -v 123.123.098.098 -p TCP -r 443 -a 100 -n \"important notice\"\n";
-  print "\nExample #2: ./$RealScript --service=ScanGuardian --event-type=portscan --source-type=IP --timestamp=\"2013-04-25T13:36:31\" --source-value=\"123.123.1.23\" --proto=TCP --port=25 --attack-scale=1234 --note=\"The very first run of ScanGuardian :)\" --warden-dir \"/opt/warden/warden-client\"\n";
+  print "\nExample: ./$RealScript -s PhishTracker -e webattack -o URL -v 123.123.098.098 -p TCP -r 443 -a 100 -n \"important notice\"\n";
+  print "\nExample: ./$RealScript --service=ScanGuardian --event-type=portscan --source-type=IP --timestamp=\"2013-04-25T13:36:31\" --source-value=\"123.123.1.23\" --proto=TCP --port=25 --attack-scale=1234 --note=\"The very first run of ScanGuardian :)\"\n";
 
   print "\nNOTE: For more information see <warden-client_path>/doc/README file.\n\n";
 
@@ -85,8 +82,7 @@ my @event = ($opt_s, $opt_t, $opt_e, $opt_o, $opt_v, $opt_p, $opt_r, $opt_a, $op
 # Use of warden-client sender.
 
 # Load Warden client library and use main module
-my $bin = File::Basename::dirname(__FILE__);
-use lib "$bin/../lib";
+use lib "$RealBin/../lib";
 use WardenClient;
 
 # Sending event to Warden server
-- 
GitLab