IBM / ibmichroot

A set of scripts to facilitate the use of chroot-based containers for IBM i
MIT License
21 stars 9 forks source link

chmod not done inside chroot #33

Closed abmusse closed 8 years ago

abmusse commented 8 years ago

Original report by Aaron Bartell (Bitbucket: aaronbartell, GitHub: aaronbartell).


Ran across an issue when a chmod is done on a directory in a chroot environment that is a symbolic link. In short, it will NOT chmod the desired chroot file or directory but will instead do it to the file or directory in the base IFS. Yikes.

Below is the tested fix.

Looking for input to determine if this has any ramifications I am not thinking of.

diff --git a/lib/chroot_setup.sh b/lib/chroot_setup.sh
index ead3c89..aff5843 100644
--- a/lib/chroot_setup.sh
+++ b/lib/chroot_setup.sh
@@ -110,9 +110,9 @@ function chroot_tar_dir {
   fi
 }
 function chroot_chmod {
-  echo "chmod $1 $CHROOT_DIR$2"
+  echo "chroot $CHROOT_DIR /QOpenSys/usr/bin/bsh -c \"chmod $1 $2\""
   if (($CHROOT_DEBUG==0)); then
-    chmod $1 $CHROOT_DIR$2
+    chroot $CHROOT_DIR /QOpenSys/usr/bin/bsh -c "chmod $1 $2"
   fi
 }
 function chroot_chmod_dir {
@@ -121,9 +121,9 @@ function chroot_chmod_dir {
   else
     all="/*"
   fi
-  echo "chmod -R $1 $CHROOT_DIR$2$all"
+  echo "chroot $CHROOT_DIR /QOpenSys/usr/bin/bsh -c \"chmod -R $1 $2$all\""
   if (($CHROOT_DEBUG==0)); then
-    chmod -R $1 $CHROOT_DIR$2$all
+    chroot $CHROOT_DIR /QOpenSys/usr/bin/bsh -c "chmod -R $1 $2$all"
   fi
 }
 function chroot_chown {
abmusse commented 8 years ago

Original comment by Aaron Bartell (Bitbucket: aaronbartell, GitHub: aaronbartell).


Resolved in this commit

abmusse commented 8 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Looks ok to me.