~ubuntu-branches/ubuntu/quantal/lxc/quantal-201206250626

« back to all changes in this revision

Viewing changes to src/lxc/lxc-checkconfig.in

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2012-05-07 21:22:26 UTC
  • Revision ID: package-import@ubuntu.com-20120507212226-ukrx93wnbtfcq82w
Tags: 0.8.0~rc1-4ubuntu5
* 0082-umount-old-proc: fix proc auto-mount.  If /proc is already mounted,
  make sure that /proc/self points to 1, since we are container init.
  Otherwise, assume proc is an old one, and umount it and remount our own.
  If we keep the old proc mounted, apparmor transitions will by tried for
  wrong task and fail.  Also move check for whether apparmor is enabled so
  that it is called by lxc-execute.  (LP: #993706)
* update 0074-lxc-execute-find-init to look for lxc-init in
  LXCINITDIR/lxc/lxc-init
* debian/control: add cloud-utils to lxc Recommends, as lxc-ubuntu-cloud
  needs it.  (LP: 995361)
* debian/lxc.upstart: load apparmor profiles before auto-starting containers.
  (LP: #989853)
* pop 06-bash.patch and 0075-lxc-ls-bash.  lxc-clone also has bashims, just
  stick to using bash until upstream is also converted (so we are safe
  against patches).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
 
1
#!/bin/bash
2
2
 
3
3
# Allow environment variables to override grep and config
4
4
: ${CONFIG:=/proc/config.gz}
5
5
: ${GREP:=zgrep}
6
6
 
7
 
SETCOLOR_SUCCESS () { printf '\033[1;32m'; }
8
 
SETCOLOR_FAILURE () { printf '\033[1;31m'; }
9
 
SETCOLOR_WARNING () { printf '\033[1;33m'; }
10
 
SETCOLOR_NORMAL  () { printf '\033[0;39m'; }
 
7
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
 
8
SETCOLOR_FAILURE="echo -en \\033[1;31m"
 
9
SETCOLOR_WARNING="echo -en \\033[1;33m"
 
10
SETCOLOR_NORMAL="echo -en \\033[0;39m"
11
11
 
12
12
is_set() {
13
 
    $GREP -q "$1=[y|m]" "$CONFIG"
 
13
    $GREP -q "$1=[y|m]" $CONFIG
14
14
    return $?
15
15
}
16
16
 
17
17
is_enabled() {
18
 
    prefix=$1
19
 
    option=$2
20
 
    mandatory=$3
 
18
    mandatory=$2
21
19
 
22
 
    is_set "$option"
 
20
    is_set $1
23
21
    RES=$?
24
22
 
25
 
    echo -n "$prefix"
26
23
    if [ $RES -eq 0 ]; then
27
 
        SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
 
24
        $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
28
25
    else
29
 
        if [ ! -z "$mandatory" ] && [ "$mandatory" = yes ]; then
30
 
            SETCOLOR_FAILURE && echo "required" && SETCOLOR_NORMAL
 
26
        if [ ! -z "$mandatory" -a "$mandatory" = yes ]; then
 
27
            $SETCOLOR_FAILURE && echo -e "required" && $SETCOLOR_NORMAL
31
28
        else
32
 
            SETCOLOR_WARNING && echo "missing" && SETCOLOR_NORMAL
 
29
            $SETCOLOR_WARNING && echo -e "missing" && $SETCOLOR_NORMAL
33
30
        fi
34
31
    fi
35
32
}
36
33
 
37
 
if [ ! -f "$CONFIG" ]; then
 
34
if [ ! -f $CONFIG ]; then
38
35
    echo "Kernel config $CONFIG not found, looking in other places..."
39
36
    KVER="`uname -r`"
40
37
    HEADERS_CONFIG="/lib/modules/$KVER/build/.config"
56
53
fi
57
54
 
58
55
echo "--- Namespaces ---"
59
 
is_enabled "Namespaces: " CONFIG_NAMESPACES yes
60
 
is_enabled "Utsname namespace: " CONFIG_UTS_NS
61
 
is_enabled "Ipc namespace: " CONFIG_IPC_NS yes
62
 
is_enabled "Pid namespace: " CONFIG_PID_NS yes
63
 
is_enabled "User namespace: " CONFIG_USER_NS
64
 
is_enabled "Network namespace: " CONFIG_NET_NS
65
 
is_enabled "Multiple /dev/pts instances: " DEVPTS_MULTIPLE_INSTANCES
 
56
echo -n "Namespaces: " && is_enabled CONFIG_NAMESPACES yes
 
57
echo -n "Utsname namespace: " && is_enabled CONFIG_UTS_NS
 
58
echo -n "Ipc namespace: " && is_enabled CONFIG_IPC_NS yes
 
59
echo -n "Pid namespace: " && is_enabled CONFIG_PID_NS yes
 
60
echo -n "User namespace: " && is_enabled CONFIG_USER_NS
 
61
echo -n "Network namespace: " && is_enabled CONFIG_NET_NS
 
62
echo -n "Multiple /dev/pts instances: " && is_enabled DEVPTS_MULTIPLE_INSTANCES
66
63
echo
67
64
echo "--- Control groups ---"
68
65
 
73
70
 
74
71
CGROUP_MNT_PATH=`print_cgroups cgroup /proc/self/mounts | head -1`
75
72
 
76
 
is_enabled "Cgroup: " CONFIG_CGROUPS yes
 
73
echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
77
74
 
78
 
if [ -f "$CGROUP_MNT_PATH/cgroup.clone_children" ]; then
 
75
if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
79
76
    echo -n "Cgroup clone_children flag: " &&
80
 
    SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
 
77
    $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
81
78
else
82
79
    echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
83
80
fi
84
 
is_enabled "Cgroup device: " CONFIG_CGROUP_DEVICE
85
 
is_enabled "Cgroup sched: " CONFIG_CGROUP_SCHED
86
 
is_enabled "Cgroup cpu account: " CONFIG_CGROUP_CPUACCT
87
 
is_enabled "Cgroup memory controller: " CONFIG_CGROUP_MEM_RES_CTLR
88
 
is_set CONFIG_SMP && is_enabled "Cgroup cpuset: " CONFIG_CPUSETS
 
81
echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
 
82
echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
 
83
echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
 
84
echo -n "Cgroup memory controller: " && is_enabled CONFIG_CGROUP_MEM_RES_CTLR
 
85
is_set CONFIG_SMP && echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
89
86
echo
90
87
echo "--- Misc ---"
91
 
is_enabled "Veth pair device: " CONFIG_VETH
92
 
is_enabled "Macvlan: " CONFIG_MACVLAN
93
 
is_enabled "Vlan: " CONFIG_VLAN_8021Q
94
 
KVER=$($GREP "^# Linux" "$CONFIG" | sed -r "s/.*([23])\.([0-9])+\.([0-9]+).*/\1 \2 \3/")
95
 
kernel_version () { echo $(( ( $1 << 16 ) + ( $2 << 8 ) + $3)); }
96
 
echo -n "File capabilities: "
97
 
if [ $(kernel_version $KVER) -le $(kernel_version 2 6 32) ]; then
98
 
        is_enabled CONFIG_SECURITY_FILE_CAPABILITIES
 
88
echo -n "Veth pair device: " && is_enabled CONFIG_VETH
 
89
echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
 
90
echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
 
91
KVER_MAJOR=$($GREP '^# Linux' $CONFIG | \
 
92
    sed -r 's/.* ([0-9])\.[0-9]{1,2}\.[0-9]{1,3}.*/\1/')
 
93
if [[ $KVER_MAJOR == 2 ]]; then
 
94
KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
 
95
    sed -r 's/.* 2.6.([0-9]{2}).*/\1/')
99
96
else
100
 
        SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
 
97
KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
 
98
    sed -r 's/.* [0-9]\.([0-9]{1,3})\.[0-9]{1,3}.*/\1/')
101
99
fi
 
100
echo -n "File capabilities: " &&
 
101
    ( [[ ${KVER_MAJOR} == 2 && ${KVER_MINOR} < 33 ]] &&
 
102
       is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ) ||
 
103
    ( [[ ( ${KVER_MAJOR} == 2 && ${KVER_MINOR} > 32 ) ||
 
104
         ${KVER_MAJOR} > 2 ]] && $SETCOLOR_SUCCESS &&
 
105
         echo -e "enabled" && $SETCOLOR_NORMAL )
102
106
 
103
107
echo
104
108
echo "Note : Before booting a new kernel, you can check its configuration"
105
109
echo "usage : CONFIG=/path/to/config $0"
106
110
echo
 
111