]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
oracle: fix chcon warning when selinux disabled
authorDwight Engen <dwight.engen@oracle.com>
Fri, 6 Dec 2013 14:46:19 +0000 (09:46 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 6 Dec 2013 20:36:19 +0000 (15:36 -0500)
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
templates/lxc-oracle.in

index 67e46ab7e26fcc7920e1577cb325526c161a9090..3461e739d740d00365a6899ff8390cc8afd2d25f 100644 (file)
@@ -46,6 +46,15 @@ is_btrfs_subvolume()
     return 1
 }
 
+can_chcon()
+{
+    if which chcon >/dev/null 2>&1; then
+        selinuxenabled >/dev/null 2>&1
+        return $?
+    fi
+    return 1
+}
+
 # fix up the container_rootfs
 container_rootfs_configure()
 {
@@ -312,7 +321,7 @@ EOF
     if [ $container_rootfs != "/" -a -d $dev_path ]; then
         rm -rf $dev_path
         mkdir -p $dev_path
-        if which chcon >/dev/null 2>&1 ; then
+        if can_chcon; then
             # ensure symlinks created in /dev have the right context
             chcon -t device_t $dev_path
         fi
@@ -333,7 +342,7 @@ EOF
     mknod -m 600  $dev_path/initctl p
 
     # set selinux labels same as host
-    if which chcon >/dev/null 2>&1 ; then
+    if can_chcon; then
         for node in null zero random urandom pts shm \
                     tty tty0 tty1 tty2 tty3 tty4 full ;
         do