This file is indexed.

/etc/init.d/xenstored is in xen-utils-common 4.6.0-1ubuntu4.

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
#!/bin/sh
### BEGIN INIT INFO
# Provides:          xenstored
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Xenstore daemon
# Description:       Xenstore daemon
### END INIT INFO

. /lib/init/vars.sh
. /lib/lsb/init-functions

# Default variables
XENSTORED_DIR="/var/run/xenstored"

[ -r /etc/default/xen ] && . /etc/default/xen
[ -r /etc/default/xend ] && . /etc/default/xend

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Xenstore daemon"

ROOT=$(/usr/lib/xen-common/bin/xen-dir 2>/dev/null)
if [ $? -ne 0 ]; then
	log_warning_msg "Not running within Xen or no compatible utils"
	exit 0
fi
TOOLSTACK=$(/usr/lib/xen-common/bin/xen-toolstack 2>/dev/null)
if [ $? -ne 0 ]; then
	log_warning_msg "No usable Xen toolstack selected"
	exit 0
fi

XENSTORED="$ROOT"/bin/xenstored
XENSTORED_PIDFILE="/var/run/xenstore.pid"

modules_setup()
{
	modprobe xenfs 2>/dev/null
	modprobe xen-evtchn 2>/dev/null
	modprobe xen-gntdev 2>/dev/null
}

xenfs_setup()
{
	[ -e "/proc/xen/capabilities" ] && return 0
	log_progress_msg "xenfs"
	[ -d "/proc/xen" ] || return 1
	mount -t xenfs xenfs /proc/xen || return 1
	return 0
}

capability_check()
{
	[ -e "/proc/xen/capabilities" ] || return 1
	grep -q "control_d" /proc/xen/capabilities || return 1
	return 0
}

env_setup()
{
	[ -d /run/xen ] && return 0

	mkdir -m 700 /run/xen
}

xenstored_start()
{
	log_progress_msg "xenstored"
	#
	# Work-around kernel regression where short name links of
	# /proc/$$/exe get replaced on rename unconditionally. This
	# should be fixed in the kernel but hitting a bad kernel is
	# fatal with starting qemu in dom0 (dpkg/qemu hangs).
	#
	if [ -f $XENSTORED_PIDFILE ]; then
		XSPID="$(cat $XENSTORED_PIDFILE)"
		XSBIN="$(ls -la /proc/$XSPID/exe 2>/dev/null)"
		XSBIN="${XSBIN#*-> }"
		XSBIN="${XSBIN% (deleted)}"
		if [ "$XSBIN" != "" ]; then
			if [ "$(basename $XSBIN)" = "xenstored.dpkg-new" ]; then
				return 1
			fi
		fi
	fi
	start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" --test > /dev/null \
		|| return 1
	[ -d "$XENSTORED_DIR" ] || mkdir -p "$XENSTORED_DIR"
	export XENSTORED_ROOTDIR="$XENSTORED_DIR"
	start-stop-daemon --start --quiet --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED" -- \
		$XENSTORED_ARGS --pid-file="$XENSTORED_PIDFILE" \
		|| return 2
}

xenstored_stop()
{
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile "$XENSTORED_PIDFILE" --exec "$XENSTORED"
	RETVAL="$?"
	[ "$RETVAL" = 2 ] && return 2
	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$XENSTORED"
	[ "$?" = 2 ] && return 2
	rm -f $XENSTORED_PIDFILE
	return "$RETVAL"
}

case "$1" in
  start)
	log_daemon_msg "Starting $DESC"
	modules_setup
	xenfs_setup
	case "$?" in
		0) ;;
		*) log_end_msg 1; exit ;;
	esac
	capability_check
	case "$?" in
		0) ;;
		*) log_end_msg 255; exit ;;
	esac
	env_setup
	xenstored_start
	case "$?" in
		0|1) ;;
		*) log_end_msg 1; exit ;;
	esac
	log_end_msg 0
	;;
  stop)
	capability_check
	case "$?" in
		0) ;;
		*) exit ;;
	esac
	log_daemon_msg "Stopping $DESC"
	ret=0
	xenstored_stop
	case "$?" in
		0|1) ;;
		*) ret=1 ;;
	esac
	log_end_msg $ret
	;;
  restart|force-reload)
	;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac

exit 0