This file is indexed.

/usr/bin/lxc-destroy is in lxc 0.7.5-3ubuntu52.

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

#
# lxc: linux Container library

# Authors:
# Daniel Lezcano <daniel.lezcano@free.fr>

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.

# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#
# This script allows to set or remove the capabilities on the lxc tools.
# When the capabilities are set, a non root user can manage the containers.
#

usage() {
    echo "usage: $0 -n <name> [-f]"
    echo "  -f: if a container is running, stop it first.  Default is to abort"
}

if [ "$(id -u)" != "0" ]; then
   echo "This command has to be run as root"
   exit 1
fi

shortoptions='n:f'
longoptions='name:'
lxc_path=/var/lib/lxc
force=0

getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
if [ $? != 0 ]; then
    usage $0
    exit 1;
fi

eval set -- "$getopt"

while true; do
        case "$1" in
	    -n|--name)
		shift
		lxc_name=$1
		shift
		;;
	    -f)
		force=1
		shift
		;;
            --)
		shift
		break;;
            *)
		echo $1
		usage $0
		exit 1
		;;
        esac
done

if [ -z "$lxc_name" ]; then
    echo "no container name specified"
    usage $0
    exit 1
fi

if [ ! -d "$lxc_path/$lxc_name" ]; then
    echo "'$lxc_name' does not exist"
    exit 1
fi

# make sure the container isn't running
lxc-info -n $lxc_name 2>/dev/null | grep -q RUNNING
if [ $? -eq 0 ]; then
	if [ $force -eq 1 ]; then
		lxc-stop -n $lxc_name
		lxc-wait -n $lxc_name -s STOPPED
	else
		echo "Container $lxc_name is running, aborting the deletion."
		exit 1
	fi
fi

# Deduce the type of rootfs
# If LVM partition, destroy it.  If anything else, ignore it.  We'll support
# deletion of others later.
rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
if [ ! -z "$rootdev" ]; then
	if [ -b "$rootdev" -o -h "$rootdev" ]; then
		lvdisplay $rootdev > /dev/null 2>&1
		if [ $? -eq 0 ]; then
			echo "removing backing store: $rootdev"
			lvremove -f $rootdev
		fi
	fi
fi
if out=$(btrfs subvolume list "$lxc_path/$lxc_name/rootfs" 2>&1); then
	out=$(btrfs subvolume delete "$lxc_path/$lxc_name/rootfs" 2>&1) ||
		echo "WARN: failed btrfs subvolume delete: $out"
fi
# recursively remove the container to remove old container configuration
rm -rf --preserve-root $lxc_path/$lxc_name

# remove any autostart symlinks pointing to this container.
ls /etc/lxc/auto/* > /dev/null 2>&1 || exit 0;
for f in /etc/lxc/auto/*; do
	if [ -h "$f" ]; then
		l=`readlink $f`
		if [ $l = $lxc_path/$lxc_name/config ]; then
			rm -f $f
		fi
	fi
done