3 # @(#) $Id: ./src/agentlessd/scripts/ssh_foundry_diff, 2011/09/08 dcid Exp $
7 # Copyright (C) 2009 Trend Micro Inc.
10 # This program is a free software; you can redistribute it
11 # and/or modify it under the terms of the GNU General Public
12 # License (version 2) as published by the FSF - Free Software
17 send_user "ERROR: ssh_pixconfig_diff <hostname> <commands>\n";
22 # NOTE: this script must be called from within /var/ossec for it to work.
23 set passlist "agentless/.passlist"
24 set hostname [lindex $argv 0]
25 set commands [lrange $argv 1 end]
30 if {[string compare $hostname "test"] == 0} {
31 if {[string compare $commands "test"] == 0} {
36 # Reading the password list.
38 set in [open "$passlist" r]
40 send_user "ERROR: Password list not present (use \"register_host\" first).\n"
44 while {[gets $in line] != -1} {
45 set me [string first "|" $line]
46 set me2 [string last "|" $line]
47 set length [string length $line]
62 set host_list [string range $line 0 $me]
64 set pass_list [string range $line $me $me2]
66 set addpass_list [string range $line $me2 $length]
68 if {[string compare $host_list $hostname] == 0} {
70 set addpass "$addpass_list"
77 if {[string compare $pass "x"] == 0} {
78 send_user "ERROR: Password for '$hostname' not found.\n"
83 # SSHing to the box and passing the directories to check.
87 send_user "ERROR: Opening connection: $loc_error.\n"
92 "WARNING: REMOTE HOST" {
93 send_user "ERROR: RSA host key for '$hostname' has changed. Unable to access.\n"
96 "*sure you want to continue connecting*" {
98 expect "* password:*" {
102 "Permission denied" {
103 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
107 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
111 send_user "\nINFO: Starting.\n"
116 "ssh: connect to host*" {
117 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
120 "no address associated with name" {
121 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
124 "*Connection refused*" {
125 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
128 "*Connection closed by remote host*" {
129 send_user "ERROR: Unable to connect to remote host: $hostname .\n"
136 "Permission denied" {
137 send_user "ERROR: Incorrect password to remote host: $hostname .\n"
141 send_user "ERROR: Timeout while running on host (too long to finish): $hostname .\n"
145 send_user "INFO: Starting.\n"
150 send_user "ERROR: Timeout while connecting to host: $hostname . \n"
156 if {[string compare $addpass ""] != 0} {
157 # Going into enable mode.
165 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
168 "*rror - incorrect password*" {
169 send_user "ERROR: Incorrect enable password to remote host: $hostname .\n"
173 send_user "ERROR: Timeout while going to enable mode on host: $hostname .\n"
177 send_user "ok on enable pass\n"
182 send_user "ERROR: Timeout while running enable on host: $hostname .\n"
191 send_user "\nSTORE: now\n"
193 send "skip-page-display\r"
196 # Excluding uptime from the output
203 send_user "ERROR: Timeout while running commands on host: $hostname .\n"
207 send_user "\nINFO: Finished.\n"
212 send_user "ERROR: Unable to finish properly.\n"