Imported Upstream version 2.5.1
[ossec-hids.git] / src / agentlessd / scripts / ssh_integrity_check_linux
1 #!/usr/bin/env expect
2
3 # @(#) $Id$
4 # Agentless monitoring
5 #
6 # Copyright (C) 2009 Trend Micro Inc.
7 # All rights reserved.
8
9 # This program is a free software; you can redistribute it
10 # and/or modify it under the terms of the GNU General Public
11 # License (version 2) as published by the FSF - Free Software
12 # Foundation.
13
14
15 # Main script.
16 source "agentless/main.exp"
17
18
19 # SSHing to the box and passing the directories to check.
20 if [catch {
21     spawn ssh $hostname
22 } loc_error] {
23     send_user "ERROR: Opening connection: $loc_error.\n"
24     exit 1;
25 }
26
27
28 source $sshsrc
29 source $susrc
30
31 set timeout 600
32 send "echo \"INFO: Starting.\"; for i in `find $args 2>/dev/null`;do tail \$i >/dev/null 2>&1 && md5=`md5sum \$i | cut -d \" \" -f 1` && sha1=`sha1sum \$i | cut -d \" \" -f 1` && echo FWD: `stat --printf \"%s:%a:%u:%g\" \$i`:\$md5:\$sha1 \$i; done; exit\r"
33 send "exit\r"
34
35 expect {
36     timeout {
37         send_user "ERROR: Timeout while running commands on host: $hostname .\n"
38         exit 1;
39     }
40     eof {
41         send_user "\nINFO: Finished.\n"
42         exit 0;
43     }
44 }
45
46 exit 0;