This file is indexed.

/usr/sbin/ccs_config_validate is in cman 3.1.7-0ubuntu2.

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
#!/bin/bash

if [ -z "$COROSYNC_DEFAULT_CONFIG_IFACE" ]; then
	# rpm based distros
	if [ -d /etc/sysconfig ]; then
		[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
		[ -f /etc/sysconfig/cman ] && . /etc/sysconfig/cman
	fi

	# deb based distros
	if [ -d /etc/default ]; then
		[ -f /etc/default/cluster ] && . /etc/default/cluster
		[ -f /etc/default/cman ] && . /etc/default/cman
	fi

	[ -z "$CONFIG_LOADER" ] && CONFIG_LOADER=xmlconfig
	export COROSYNC_DEFAULT_CONFIG_IFACE=$CONFIG_LOADER:cmanpreconfig
fi

get_config_version() {
	local file=$1

	echo "xpath /cluster/@config_version" | \
		xmllint --shell "$file" | \
		grep content | \
	cut -f2 -d=
}

print_usage() {
	echo "Usage:"
	echo ""
	echo "ccs_config_validate [options]"
	echo ""
	echo "Options:"
	echo "  -h               Print this help, then exit"
	echo "  -V               Print program version information, then exit"
	echo "  -v               Produce verbose output"
	echo "  -q               Be very quiet"
	echo ""
	echo "Validating XML configuraton files:"
	echo "  -f configfile    Validate an alternate config file"
	echo "  -l configfile    Validate an alternate config file (load test)"
	echo ""
	echo "Advanced options:"
	echo "  -u               Do not update relaxng schema"
	echo "  -r               Force validation of runtime config"
	echo "  -C config_loader Override config plugin loader"
	echo "  -t tempfile      Force temporay file to tempfile"
	echo "  -n               Do not remove temporary file"
	echo "  -o               Overwrite temporary file (dangerous)"
	echo "  -R version       When validating configuration update, ensure the"
	echo "                   new config is newer than the specified version."
}

check_opts() {
	while [ "$1" != "--" ]; do
		case $1 in
		-h)
			print_usage
			exit 0
		;;
		-V)
			echo "ccs_config_validate version 3.1.7"
			exit 0
		;;
		-t)
			shift
			tempfile="$1"
		;;
		-n)
			notempfilerm=1
		;;
		-o)
			overwritetempfile=1
		;;
		-R)	
			shift
			old_version=$1
		;;
		-C)
			shift
			export COROSYNC_DEFAULT_CONFIG_IFACE=$1:cmanpreconfig
			loaderoverride=1
			if [ -n "$runtimetest" ] || \
			   [ -n "$filetest" ] || \
			   [ -n "$noloadtest" ]; then
				echo "Error: invalid options. -C can not be set together with -l or -r or -f" >&2
				exit 255
			fi
		;;
		-l)
			shift
			export COROSYNC_CLUSTER_CONFIG_FILE=$1
			export COROSYNC_DEFAULT_CONFIG_IFACE=xmlconfig:cmanpreconfig
			filetest=1
			if [ -n "$loaderoverride" ] || \
			   [ -n "$runtimetest" ] || \
			   [ -n "$noloadtest" ]; then
				echo "Error: invalid options. -l can not be set together with -r or -C or -f" >&2
				exit 255
			fi
		;;
		-f)
			shift
			export COROSYNC_CLUSTER_CONFIG_FILE=$1
			unset COROSYNC_DEFAULT_CONFIG_IFACE
			noloadtest=1
			if [ -n "$loaderoverride" ] || \
			   [ -n "$runtimetest" ] || \
			   [ -n "$filetest" ]; then
				echo "Error: invalid options. -f can not be set together with -r or -C or -l" >&2
				exit 255
			fi
		;;
		-r)
			unset COROSYNC_DEFAULT_CONFIG_IFACE
			runtimetest=1
			if [ -n "$noloadtest" ] || \
			   [ -n "$loaderoverride" ] || \
			   [ -n "$filetest" ]; then
				echo "Error: invalid options. -r can not be set together with -l or -C or -f" >&2
				exit 255
			fi
		;;
		-v)
			verbose=1
			if [ -n "$quiet" ]; then
				echo "Error: invalid options. -v can not be set together with -q" >&2
				exit 255
			fi
		;;
		-q)
			quiet=1
			if [ -n "$verbose" ]; then
				echo "Error: invalid options. -q can not be set together with -v" >&2
				exit 255
			fi
		;;
		-u)
			updaterelaxng=0
		;;
		esac
		shift
	done
}

lecho()
{
	[ -n "$verbose" ] && echo $@
	return 0
}

opts=$(getopt t:hVnC:f:l:rR:ovqu $@)
if [ "$?" != 0 ]; then
	print_usage >&2
	exit 255
fi
check_opts $opts

if [ -n "$tempfile" ]; then
	if [ -f "$tempfile" ] && [ -z "$overwritetempfile" ]; then
		echo "Selected temporary file $tempfile already exists" >&2
		echo "Use -o to force overwrite (dangerous)" >&2
		exit 255
	fi
else
	tempfile=$(mktemp)
	if [ -z "$tempfile" ]; then
		echo "Unable to create temporary file" >&2
		exit 255
	fi
fi
lecho "Creating temporary file: $tempfile"
lecho "Config interface set to: $COROSYNC_DEFAULT_CONFIG_IFACE"

if [ -n "$noloadtest" ]; then
	cp $COROSYNC_CLUSTER_CONFIG_FILE $tempfile
else
	export CMAN_PIPE=2
	if ! ccs_config_dump > $tempfile; then
		[ -z "$notempfilerm" ] && rm -f $tempfile
		echo
		echo "Unable to get the configuration" >&2
		exit 255
	fi
fi
lecho "Configuration stored in temporary file"

lecho "Updating relaxng schema"
if [ "$updaterelaxng" != 0 ]; then
	updateerr="$(ccs_update_schema 2>&1)"
	if [ $? != 0 ]; then
		echo "Unable to update relaxng schema: $updateerr" >&2
		exit 255
	fi
fi

if [ -f /var/lib/cluster/rng_update.lock ]; then
	echo "Relax-ng schema update in progress" >&2
	exit 255
fi

if [ ! -e /usr/share/cluster/cluster.rng ]; then
	echo "Unable to verify a configuration without relaxng schema" >&2
	exit 255
fi

lecho "Validating.."

xmlout=$(xmllint --noout \
	--relaxng /usr/share/cluster/cluster.rng \
	$tempfile 2>&1)
res=$?

if [ -n "$old_version" ] && [ $old_version -ne 0 ] && [ $res -eq 0 ]; then
	new_version=$(get_config_version $tempfile)
	if [ -z "$new_version" ]; then
		[ -z "$quiet" ] && \
			echo "Error: Unable to determine new config version!" >&2
		[ -z "$notempfilerm" ] && rm -f $tempfile
		exit 253
	fi
	lecho "Old version: $old_version   New version: $new_version"
	if [ $new_version -le $old_version ]; then
		[ -z "$quiet" ] && \
			echo "Error: Configuration version is older than running config!" >&2
		[ -z "$notempfilerm" ] && rm -f $tempfile
		exit 254
	fi
fi

if [ -z "$quiet" ] || [ "$res" != "0" ]; then
	echo "$xmlout" | sed \
		-e 's#.*validates$#Configuration validates#g' \
		-e 's#.*validate$#Configuration fails to validate#g' \
		-e 's#'$tempfile'#tempfile#g'
fi

lecho "Validation completed"

[ -z "$notempfilerm" ] && rm -f $tempfile
exit $res