Package: lxc
Version: 0.7.5-19
Severity: normal
Dear Maintainer,
lxc-checkconfig breaks with /bin/sh → dash:
$ checkbashisms /tmp/lxc-checkconfig
possible bashism in /tmp/lxc-checkconfig line 24 (echo -e):
$SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
possible bashism in /tmp/lxc-checkconfig line 27 (echo -e):
$SETCOLOR_FAILURE && echo -e "required" && $SETCOLOR_NORMAL
possible bashism in /tmp/lxc-checkconfig line 29 (echo -e):
$SETCOLOR_WARNING && echo -e "missing" && $SETCOLOR_NORMAL
possible bashism in /tmp/lxc-checkconfig line 72 (echo -e):
$SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
possible bashism in /tmp/lxc-checkconfig line 90 (echo -e):
[ ${KVER_MINOR} -gt 32 ] && $SETCOLOR_SUCCESS && echo -e "enabled" &&
$ dash /usr/bin/lxc-checkconfig
Kernel config /proc/config.gz not found, looking in other places...
Found kernel config file /boot/config-3.2.1
--- Namespaces ---
Namespaces: -en
-e enabled
-en
...
File capabilities: /usr/bin/lxc-checkconfig: 89: [: #: unexpected operator
/usr/bin/lxc-checkconfig: 90: [: #: unexpected operator
...
See <https://wiki.ubuntu.com/DashAsBinSh>
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.1 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages lxc depends on:
ii debconf [debconf-2.0] 1.5.41
ii libc6 2.13-24
ii libcap2 1:2.22-1
Versions of packages lxc recommends:
ii cdebootstrap 0.5.8+b1
ii debootstrap 1.0.38
ii libcap2-bin 1:2.22-1
Versions of packages lxc suggests:
pn lxctl <none>
-- debconf information:
* lxc/directory: /media/storage/virt
lxc/title:
lxc/auto: true
lxc/shutdown: stop
--- /tmp/lxc-checkconfig 2012-01-14 17:39:22.730232210 +0100
+++ /usr/bin/lxc-checkconfig 2012-01-14 18:30:15.096409669 +0100
@@ -4,30 +4,33 @@
: ${CONFIG:=/proc/config.gz}
: ${GREP:=zgrep}
-SETCOLOR_SUCCESS="echo -en \\033[1;32m"
-SETCOLOR_FAILURE="echo -en \\033[1;31m"
-SETCOLOR_WARNING="echo -en \\033[1;33m"
-SETCOLOR_NORMAL="echo -en \\033[0;39m"
+SETCOLOR_SUCCESS () { printf '\033[1;32m'; }
+SETCOLOR_FAILURE () { printf '\033[1;31m'; }
+SETCOLOR_WARNING () { printf '\033[1;33m'; }
+SETCOLOR_NORMAL () { printf '\033[0;39m'; }
-is_set() {
- $GREP -q "$1=[y|m]" $CONFIG
+is_set () {
+ $GREP -q "$1=[y|m]" "$CONFIG"
return $?
}
-is_enabled() {
- mandatory=$2
+is_enabled () {
+ prefix=$1
+ option=$2
+ mandatory=$3
- is_set $1
+ is_set "$option"
RES=$?
+ echo -n "$prefix"
if [ $RES -eq 0 ]; then
- $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+ SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
else
- if [ ! -z "$mandatory" ] && [ "$mandatory" = yes ]; then
- $SETCOLOR_FAILURE && echo -e "required" && $SETCOLOR_NORMAL
- else
- $SETCOLOR_WARNING && echo -e "missing" && $SETCOLOR_NORMAL
- fi
+ if [ ! -z "$mandatory" ] && [ "$mandatory" = yes ]; then
+ SETCOLOR_FAILURE && echo "required" && SETCOLOR_NORMAL
+ else
+ SETCOLOR_WARNING && echo "missing" && SETCOLOR_NORMAL
+ fi
fi
}
@@ -39,12 +42,12 @@
[ -f "${HEADERS_CONFIG}" ] && CONFIG=${HEADERS_CONFIG}
[ -f "${BOOT_CONFIG}" ] && CONFIG=${BOOT_CONFIG}
GREP=grep
- if [ ! -f $CONFIG ]; then
+ if [ ! -f "$CONFIG" ]; then
echo
echo "The kernel configuration can not be retrieved."
echo "Please recompile with IKCONFIG_PROC, or"
- echo "install the kernel headers, or specify"
- echo "the path to the config file with: CONFIG=<path> lxc-checkconfig"
+ echo "install the kernel headers, or specify"
+ echo "the path to the config file with: CONFIG=<path> lxc-checkconfig"
echo
exit 1
else
@@ -53,45 +56,45 @@
fi
echo "--- Namespaces ---"
-echo -n "Namespaces: " && is_enabled CONFIG_NAMESPACES yes
-echo -n "Utsname namespace: " && is_enabled CONFIG_UTS_NS
-echo -n "Ipc namespace: " && is_enabled CONFIG_IPC_NS yes
-echo -n "Pid namespace: " && is_enabled CONFIG_PID_NS yes
-echo -n "User namespace: " && is_enabled CONFIG_USER_NS
-echo -n "Network namespace: " && is_enabled CONFIG_NET_NS
-echo -n "Multiple /dev/pts instances: " && is_enabled DEVPTS_MULTIPLE_INSTANCES
+is_enabled "Namespaces: " CONFIG_NAMESPACES yes
+is_enabled "Utsname namespace: " CONFIG_UTS_NS
+is_enabled "Ipc namespace: " CONFIG_IPC_NS yes
+is_enabled "Pid namespace: " CONFIG_PID_NS yes
+is_enabled "User namespace: " CONFIG_USER_NS
+is_enabled "Network namespace: " CONFIG_NET_NS
+is_enabled "Multiple /dev/pts instances: " DEVPTS_MULTIPLE_INSTANCES
echo
echo "--- Control groups ---"
CGROUP_MNT_PATH=$(grep -m1 "^cgroup" /proc/self/mounts | awk '{ print $2 }')
-echo -n "Cgroup: " && is_enabled CONFIG_CGROUPS yes
+is_enabled "Cgroup: " CONFIG_CGROUPS yes
-if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
+if [ -f "$CGROUP_MNT_PATH/cgroup.clone_children" ]; then
echo -n "Cgroup clone_children flag: " &&
- $SETCOLOR_SUCCESS && echo -e "enabled" && $SETCOLOR_NORMAL
+ SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
else
- echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
+ is_enabled "Cgroup namespace: " CONFIG_CGROUP_NS yes
fi
-echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
-echo -n "Cgroup sched: " && is_enabled CONFIG_CGROUP_SCHED
-echo -n "Cgroup cpu account: " && is_enabled CONFIG_CGROUP_CPUACCT
-echo -n "Cgroup memory controller: " && is_enabled CONFIG_CGROUP_MEM_RES_CTLR
-is_set CONFIG_SMP && echo -n "Cgroup cpuset: " && is_enabled CONFIG_CPUSETS
+is_enabled "Cgroup device: " CONFIG_CGROUP_DEVICE
+is_enabled "Cgroup sched: " CONFIG_CGROUP_SCHED
+is_enabled "Cgroup cpu account: " CONFIG_CGROUP_CPUACCT
+is_enabled "Cgroup memory controller: " CONFIG_CGROUP_MEM_RES_CTLR
+is_set CONFIG_SMP && is_enabled "Cgroup cpuset: " CONFIG_CPUSETS
echo
echo "--- Misc ---"
-echo -n "Veth pair device: " && is_enabled CONFIG_VETH
-echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN
-echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q
-KVER_MINOR=$($GREP '^# Linux' $CONFIG | \
- sed -r 's/.*2.6.([0-9]{2}).*/\1/')
-echo -n "File capabilities: " &&
- [ ${KVER_MINOR} -lt 33 ] && is_enabled CONFIG_SECURITY_FILE_CAPABILITIES ||
- [ ${KVER_MINOR} -gt 32 ] && $SETCOLOR_SUCCESS && echo -e "enabled" &&
- $SETCOLOR_NORMAL
-
+is_enabled "Veth pair device: " CONFIG_VETH
+is_enabled "Macvlan: " CONFIG_MACVLAN
+is_enabled "Vlan: " CONFIG_VLAN_8021Q
+KVER=$($GREP "^# Linux" "$CONFIG" | sed -r "s/.*([23])\.([0-9])+\.([0-9]+).*/\1 \2 \3/")
+kernel_version () { echo $(( ( $1 << 16 ) + ( $2 << 8 ) + $3)); }
+echo -n "File capabilities: "
+if [ $(kernel_version $KVER) -le $(kernel_version 2 6 32) ]; then
+ is_enabled CONFIG_SECURITY_FILE_CAPABILITIES
+else
+ SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
+fi
echo
echo "Note : Before booting a new kernel, you can check its configuration"
echo "usage : CONFIG=/path/to/config $0"
echo
-
#!/bin/sh
# Allow environment variables to override grep and config
: ${CONFIG:=/proc/config.gz}
: ${GREP:=zgrep}
SETCOLOR_SUCCESS () { printf '\033[1;32m'; }
SETCOLOR_FAILURE () { printf '\033[1;31m'; }
SETCOLOR_WARNING () { printf '\033[1;33m'; }
SETCOLOR_NORMAL () { printf '\033[0;39m'; }
is_set () {
$GREP -q "$1=[y|m]" "$CONFIG"
return $?
}
is_enabled () {
prefix=$1
option=$2
mandatory=$3
is_set "$option"
RES=$?
echo -n "$prefix"
if [ $RES -eq 0 ]; then
SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
else
if [ ! -z "$mandatory" ] && [ "$mandatory" = yes ]; then
SETCOLOR_FAILURE && echo "required" && SETCOLOR_NORMAL
else
SETCOLOR_WARNING && echo "missing" && SETCOLOR_NORMAL
fi
fi
}
if [ ! -f $CONFIG ]; then
echo "Kernel config $CONFIG not found, looking in other places..."
KVER="`uname -r`"
HEADERS_CONFIG="/lib/modules/$KVER/build/.config"
BOOT_CONFIG="/boot/config-$KVER"
[ -f "${HEADERS_CONFIG}" ] && CONFIG=${HEADERS_CONFIG}
[ -f "${BOOT_CONFIG}" ] && CONFIG=${BOOT_CONFIG}
GREP=grep
if [ ! -f "$CONFIG" ]; then
echo
echo "The kernel configuration can not be retrieved."
echo "Please recompile with IKCONFIG_PROC, or"
echo "install the kernel headers, or specify"
echo "the path to the config file with: CONFIG=<path> lxc-checkconfig"
echo
exit 1
else
echo "Found kernel config file $CONFIG"
fi
fi
echo "--- Namespaces ---"
is_enabled "Namespaces: " CONFIG_NAMESPACES yes
is_enabled "Utsname namespace: " CONFIG_UTS_NS
is_enabled "Ipc namespace: " CONFIG_IPC_NS yes
is_enabled "Pid namespace: " CONFIG_PID_NS yes
is_enabled "User namespace: " CONFIG_USER_NS
is_enabled "Network namespace: " CONFIG_NET_NS
is_enabled "Multiple /dev/pts instances: " DEVPTS_MULTIPLE_INSTANCES
echo
echo "--- Control groups ---"
CGROUP_MNT_PATH=$(grep -m1 "^cgroup" /proc/self/mounts | awk '{ print $2 }')
is_enabled "Cgroup: " CONFIG_CGROUPS yes
if [ -f "$CGROUP_MNT_PATH/cgroup.clone_children" ]; then
echo -n "Cgroup clone_children flag: " &&
SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
else
is_enabled "Cgroup namespace: " CONFIG_CGROUP_NS yes
fi
is_enabled "Cgroup device: " CONFIG_CGROUP_DEVICE
is_enabled "Cgroup sched: " CONFIG_CGROUP_SCHED
is_enabled "Cgroup cpu account: " CONFIG_CGROUP_CPUACCT
is_enabled "Cgroup memory controller: " CONFIG_CGROUP_MEM_RES_CTLR
is_set CONFIG_SMP && is_enabled "Cgroup cpuset: " CONFIG_CPUSETS
echo
echo "--- Misc ---"
is_enabled "Veth pair device: " CONFIG_VETH
is_enabled "Macvlan: " CONFIG_MACVLAN
is_enabled "Vlan: " CONFIG_VLAN_8021Q
KVER=$($GREP "^# Linux" "$CONFIG" | sed -r "s/.*([23])\.([0-9])+\.([0-9]+).*/\1 \2 \3/")
kernel_version () { echo $(( ( $1 << 16 ) + ( $2 << 8 ) + $3)); }
echo -n "File capabilities: "
if [ $(kernel_version $KVER) -le $(kernel_version 2 6 32) ]; then
is_enabled CONFIG_SECURITY_FILE_CAPABILITIES
else
SETCOLOR_SUCCESS && echo "enabled" && SETCOLOR_NORMAL
fi
echo
echo "Note : Before booting a new kernel, you can check its configuration"
echo "usage : CONFIG=/path/to/config $0"
echo