This file is indexed.

/usr/bin/lxc-setcap 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
#!/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.
#

LXC_ATTACH_CAPS="cap_sys_admin,cap_dac_override"
LXC_CREATE_CAPS="cap_sys_admin"
LXC_NETSTAT_CAPS="cap_sys_admin"
LXC_INIT_CAPS="cap_sys_admin,cap_dac_override"
LXC_COMMON_CAPS="cap_net_admin,cap_net_raw,cap_sys_admin,cap_dac_override"
LXC_UNSHARE_CAPS=$LXC_COMMON_CAPS
LXC_START_CAPS="$LXC_COMMON_CAPS,cap_fowner,cap_sys_chroot,cap_setpcap"
LXC_EXECUTE_CAPS=$LXC_START_CAPS
LXC_RESTART_CAPS="$LXC_START_CAPS,cap_mknod"
LXC_CHECKPOINT_CAPS="$LXC_COMMON_CAPS,cap_sys_ptrace,cap_mknod"
LXC_DROP_CAPS=""

usage()
{
    echo "lxc-setcap [-d] : set or remove capabilities on the lxc tools"
}

lxc_setcaps()
{
    setcap $LXC_ATTACH_CAPS=ep /usr/bin/lxc-attach
    setcap $LXC_CREATE_CAPS=ep /usr/bin/lxc-create
    setcap $LXC_EXECUTE_CAPS=ep /usr/bin/lxc-execute
    setcap $LXC_START_CAPS=ep /usr/bin/lxc-start
    setcap $LXC_RESTART_CAPS=ep /usr/bin/lxc-restart
    setcap $LXC_UNSHARE_CAPS=ep /usr/bin/lxc-unshare
    setcap $LXC_NETSTAT_CAPS=ep /usr/bin/lxc-netstat
    setcap $LXC_CHECKPOINT_CAPS=ep /usr/bin/lxc-checkpoint
    setcap $LXC_INIT_CAPS=ep /usr/lib/lxc/lxc-init

    test -e /var/lib/lxc || mkdir -p /var/lib/lxc
    chmod 0777 /var/lib/lxc
}

lxc_dropcaps()
{
    setcap -r /usr/bin/lxc-attach
    setcap -r /usr/bin/lxc-create
    setcap -r /usr/bin/lxc-execute
    setcap -r /usr/bin/lxc-start
    setcap -r /usr/bin/lxc-restart
    setcap -r /usr/bin/lxc-unshare
    setcap -r /usr/bin/lxc-netstat
    setcap -r /usr/bin/lxc-checkpoint
    setcap -r /usr/lib/lxc/lxc-init
    chmod 0755 /var/lib/lxc
}

if [ "$(id -u)" != "0" ]; then
    echo "You have to be root to run this script"
    exit 1
fi


if [ $? != 0 ]; then
    usage
    exit 1
fi

set -- $(getopt dh "$@")

for i in "$@"; do
    case "$1" in
	-d)
	    LXC_DROP_CAPS="yes"
	    shift
	    ;;
	-h)
	    usage
	    exit 0
	    ;;
	--)
	    shift
	    break
	    ;;
	*)
	    usage
	    exit 1
	    ;;
    esac
done;

if [ -z "$LXC_DROP_CAPS" ]; then
    lxc_setcaps
else
    lxc_dropcaps
fi