projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
obrisane nepotrebne datoteke od zadnjeg builda
[ossec-hids.git]
/
src
/
agentlessd
/
scripts
/
register_host.sh
diff --git
a/src/agentlessd/scripts/register_host.sh
b/src/agentlessd/scripts/register_host.sh
index
edc503d
..
4a14c2b
100755
(executable)
--- a/
src/agentlessd/scripts/register_host.sh
+++ b/
src/agentlessd/scripts/register_host.sh
@@
-1,22
+1,19
@@
#!/bin/sh
#!/bin/sh
-# @(#) $Id$
# Agentless monitoring
#
# Copyright (C) 2009 Trend Micro Inc.
# All rights reserved.
# Agentless monitoring
#
# Copyright (C) 2009 Trend Micro Inc.
# All rights reserved.
-#
+#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
-
MYNAME="register_host.sh"
MYPASS=".passlist"
MYNAME="register_host.sh"
MYPASS=".passlist"
-
-# Checking the location.
+# Check the location
ls -la $MYNAME > /dev/null 2>&1
if [ ! $? = 0 ]; then
LOCALDIR=`dirname $0`;
ls -la $MYNAME > /dev/null 2>&1
if [ ! $? = 0 ]; then
LOCALDIR=`dirname $0`;
@@
-26,10
+23,8
@@
if [ ! $? = 0 ]; then
if [ ! $? = 0 ]; then
echo "ERROR: You must run this script from the same directory."
exit 1;
if [ ! $? = 0 ]; then
echo "ERROR: You must run this script from the same directory."
exit 1;
- fi
-fi
-
-
+ fi
+fi
# Arguments
if [ "x$1" = "x" -o "x$1" = "xhelp" -o "x$1" = "x-h" ]; then
# Arguments
if [ "x$1" = "x" -o "x$1" = "xhelp" -o "x$1" = "x-h" ]; then
@@
-39,64
+34,57
@@
if [ "x$1" = "x" -o "x$1" = "xhelp" -o "x$1" = "x-h" ]; then
exit 0;
fi
exit 0;
fi
-
if [ "x$1" = "xlist" ]; then
echo "*Available hosts: "
if [ "x$2" = "xpasswords" ]; then
cat $MYPASS | sort | uniq;
if [ "x$1" = "xlist" ]; then
echo "*Available hosts: "
if [ "x$2" = "xpasswords" ]; then
cat $MYPASS | sort | uniq;
- else
+ else
cat $MYPASS | cut -d "|" -f 1 | sort | uniq;
cat $MYPASS | cut -d "|" -f 1 | sort | uniq;
- fi
+ fi
exit 0;
exit 0;
-
-
elif [ "x$1" = "xadd" ]; then
if [ "x$2" = "x" ]; then
echo "ERROR: Missing hostname name.";
echo "ex: $0 add <user@host> [<passwd>] (<additional_pass>)";
exit 1;
fi
elif [ "x$1" = "xadd" ]; then
if [ "x$2" = "x" ]; then
echo "ERROR: Missing hostname name.";
echo "ex: $0 add <user@host> [<passwd>] (<additional_pass>)";
exit 1;
fi
-
+
grep "$2|" $MYPASS > /dev/null 2>&1
if [ $? = 0 ]; then
echo "ERROR: Host '$2' already added.";
exit 1;
fi
grep "$2|" $MYPASS > /dev/null 2>&1
if [ $? = 0 ]; then
echo "ERROR: Host '$2' already added.";
exit 1;
fi
-
-
- # Checking if the password was supplied.
+
+ # Check if the password was supplied
if [ "x$3" = "x" ]; then
echo "Please provide password for host $2."
echo -n "Password: ";
stty -echo
read INPASS
stty echo
if [ "x$3" = "x" ]; then
echo "Please provide password for host $2."
echo -n "Password: ";
stty -echo
read INPASS
stty echo
-
+
echo "Please provide additional password for host $2 (<enter> for empty)."
echo -n "Password: ";
stty -echo
read ADDPASS
stty echo
else
echo "Please provide additional password for host $2 (<enter> for empty)."
echo -n "Password: ";
stty -echo
read ADDPASS
stty echo
else
- INPASS=$3
+ INPASS=$3
ADDPASS=$4
fi
ADDPASS=$4
fi
-
+
echo "$2|$INPASS|$ADDPASS" >> $MYPASS;
if [ ! $? = 0 ]; then
echo "ERROR: Unable to creating entry (echo failed)."
exit 1;
echo "$2|$INPASS|$ADDPASS" >> $MYPASS;
if [ ! $? = 0 ]; then
echo "ERROR: Unable to creating entry (echo failed)."
exit 1;
- fi
+ fi
+ chmod 744 $MYPASS
echo "*Host $2 added."
else
echo "*Host $2 added."
else
-
echo "ERROR: Invalid argument.";
exit 1;
echo "ERROR: Invalid argument.";
exit 1;
-
-fi
-
-# EOF
+fi