This file is indexed.

/usr/lib/stonith/plugins/external/xen0 is in cluster-glue 1.0.8-2ubuntu6.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/sh
#
# External STONITH module for Xen Dom0 through ssh.
#
# Description:  Uses Xen Dom0 Domain as a STONITH device
#               to control DomUs.
#
#
# Author:       Serge Dubrouski (sergeyfd@gmail.com)
#               Inspired by Lars Marowsky-Bree's external/ssh agent.
#
# Copyright 2007 Serge Dubrouski <sergeyfd@gmail.com>
# License:      GNU General Public License (GPL)
#

STOP_COMMAND="xm destroy"
START_COMMAND="xm create"
DUMP_COMMAND="xm dump-core"
DEFAULT_XEN_DIR="/etc/xen"
SSH_COMMAND="/usr/bin/ssh -q -x -n"

# Rewrite the hostlist to accept "," as a delimeter for hostnames too.
hostlist=`echo $hostlist | tr ',' ' '`

CheckIfDead() {
    for j in 1 2 3 4 5
    do
        if ! ping -w1 -c1 "$1" >/dev/null 2>&1
        then
            return 0
        fi
        sleep 1
    done
    
    return 1
}

CheckHostList() {
    if [ "x" = "x$hostlist" ]
    then
        ha_log.sh err "hostlist isn't set"
        exit 1
    fi
}

CheckDom0() {
    if [ "x" = "x$dom0" ]
    then
        ha_log.sh err "dom0 isn't set"
        exit 1
    fi
}

RunCommand() {
    CheckHostList
    CheckDom0
    
    for h in $hostlist
    do
        CIFS=$IFS
        IFS=:
        read node cfg << -!
$h
-!
        IFS=$CIFS

        if [ "x" = "x$node" ]
        then
            ha_log.sh err "Syntax error in host list"
            exit 1
        fi
        
        if [ "x" = "x$cfg" ]
        then
            cfg="${DEFAULT_XEN_DIR}/${node}.cfg"
        fi
        
        if [ "$node" != "$1" ]
        then
            continue
        fi
          
        case $2 in
            stop)
                 kill_node=`$SSH_COMMAND $dom0 "grep ^[[:space:]]*name $cfg" | cut -f 2 -d '=' |  sed -e 's,",,g'`
                 if [ "x" = "x$kill_node" ]
                 then
                     ha_log.sh err "Couldn't find a node name to stop"
                     exit 1
                 fi

                 if [ "x$run_dump" != "x" ]
                 then
                     #Need to run core dump
                     if [ "x$dump_dir" != "x" ]
                     then
			 #Dump with the specified core file
			 TIMESTAMP=`date +%Y-%m%d-%H%M.%S`
			 DOMAINNAME=`printf "%s" $kill_node`
                         COREFILE=$dump_dir/$TIMESTAMP-$DOMAINNAME.core
                         $SSH_COMMAND $dom0 "(mkdir -p $dump_dir; $DUMP_COMMAND $kill_node $COREFILE) >/dev/null 2>&1"
                     else 
                         $SSH_COMMAND $dom0 "$DUMP_COMMAND $kill_node >/dev/null 2>&1"
		     fi
                 fi
                 $SSH_COMMAND $dom0 "(sleep 2; $STOP_COMMAND $kill_node) >/dev/null 2>&1 &"
                break;;
            start)
                $SSH_COMMAND $dom0 "(sleep 2; $START_COMMAND $cfg) >/dev/null 2>&1 &"
                break;;
        esac
        exit 0
    done
}


# Main code

case $1 in
gethosts)
    CheckHostList
    
    for h in $hostlist ; do
        CIFS=$IFS
        IFS=:
        read node cfg << -!
$h
-!
        IFS=$CIFS

        echo $node
    done
    exit 0
    ;;
on)
    RunCommand $2 start
    exit $?
    ;;
off)
    if RunCommand $2 stop
    then
        if CheckIfDead $2
        then 
            exit 0
        fi
    fi
           
    exit 1
    ;;
reset)
    RunCommand $2 stop
        
    if CheckIfDead $2
    then
        RunCommand $2 start 
        exit 0
    fi

    exit 1
    ;;
status)
    CheckHostList
    
    for h in $hostlist
    do
        CIFS=$IFS
        IFS=:
        read node cfg << -!
$h
-!
        IFS=$CIFS
        
        echo $node
        if ping -w1 -c1 "$node" 2>&1 | grep "unknown host"
        then
            exit 1
	fi
    done
    exit 0
    ;;
getconfignames)
    echo "hostlist dom0"
    exit 0
    ;;
getinfo-devid)
    echo "xen0 STONITH device"
    exit 0
    ;;
getinfo-devname)
    echo "xen0 STONITH external device"
    exit 0
    ;;
getinfo-devdescr)
    echo "ssh-based Linux host reset for Xen DomU trough Dom0"
    echo "Fine for testing, but not really suitable for production!"
    exit 0
    ;;
getinfo-devurl)
    echo "http://openssh.org http://www.xensource.com/ http://linux-ha.org/wiki"
    exit 0
    ;;
getinfo-xml)
    cat << SSHXML
<parameters>
<parameter name="hostlist" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
Hostlist
</shortdesc>
<longdesc lang="en">
The list of controlled nodes in a format node[:config_file].
For example: "node1:/opt/xen/node1.cfg node2"
If config file isn't set it defaults to /etc/xen/{node_name}.cfg
</longdesc>
</parameter>
<parameter name="dom0" unique="1" required="1">
<content type="string" />
<shortdesc lang="en">
Dom0
</shortdesc>
<longdesc lang="en">
Name of the Dom0 Xen node. Root user shall be able to ssh to that node.
</longdesc>
</parameter>
<parameter name="run_dump" unique="0" required="0">
<content type="string" />
<shortdesc lang="en">
Run dump-core
</shortdesc>
<longdesc lang="en">
If set plugin will call "xm dump-core" before killing DomU
</longdesc>
</parameter>
<parameter name="dump_dir" unique="1" required="0">
<content type="string" />
<shortdesc lang="en">
Run dump-core with the specified directory 
</shortdesc>
<longdesc lang="en">
This parameter can indicate the dump destination.
Should be set as a full path format, ex.) "/var/log/dump"
The above example would dump the core, like;
/var/log/dump/2009-0316-1403.37-domU.core
</longdesc>
</parameter>
</parameters>
SSHXML
    exit 0
    ;;
*)
    exit 1
    ;;
esac