summaryrefslogtreecommitdiffstats
path: root/envsetup.sh
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2014-05-20 02:52:23 -0500
committerMichael Bestas <mikeioannina@gmail.com>2015-10-27 00:45:16 +0200
commitdfd4c087646297ecaebe43a5d711fd85ca00c41e (patch)
treea4b38fc68721a323ae7091c9a0d2bc26a2ef0428 /envsetup.sh
parentce5e2e0f5dad411bf2d51a410075e6842470a829 (diff)
downloadbuild-dfd4c087646297ecaebe43a5d711fd85ca00c41e.zip
build-dfd4c087646297ecaebe43a5d711fd85ca00c41e.tar.gz
build-dfd4c087646297ecaebe43a5d711fd85ca00c41e.tar.bz2
envsetup: dopush: set file permissions on files pushed to /data too
* If pushing to /data, transfer old file owner, group, permissions to pushed files, then restorecon Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org> Change-Id: Ibf2945adee457a680a288f2bdfba3d2e29ba25a1
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh44
1 files changed, 42 insertions, 2 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 36b00b4..cb0b75d 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -2199,11 +2199,29 @@ function dopush()
# Copy: <file>
LOC="$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Copy: ' | cut -d ':' -f 2)"
+ # If any files are going to /data, push an octal file permissions reader to device
+ if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then
+ CHKPERM="/data/local/tmp/chkfileperm.sh"
+(
+cat <<'EOF'
+#!/system/xbin/sh
+FILE=$@
+if [ -e $FILE ]; then
+ ls -l $FILE | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' | cut -d ' ' -f1
+fi
+EOF
+) > $OUT/.chkfileperm.sh
+ echo "Pushing file permissions checker to device"
+ adb push $OUT/.chkfileperm.sh $CHKPERM
+ adb shell chmod 755 $CHKPERM
+ rm -f $OUT/.chkfileperm.sh
+ fi
+
stop_n_start=false
for FILE in $LOC; do
- # Make sure file is in $OUT/system
+ # Make sure file is in $OUT/system or $OUT/data
case $FILE in
- $OUT/system/*)
+ $OUT/system/*|$OUT/data/*)
# Get target file name (i.e. /system/bin/adb)
TARGET=$(echo $FILE | sed "s#$OUT##")
;;
@@ -2211,6 +2229,25 @@ function dopush()
esac
case $TARGET in
+ /data/*)
+ # fs_config only sets permissions and se labels for files pushed to /system
+ if [ -n "$CHKPERM" ]; then
+ OLDPERM=$(adb shell $CHKPERM $TARGET)
+ OLDPERM=$(echo $OLDPERM | tr -d '\r' | tr -d '\n')
+ OLDOWN=$(adb shell ls -al $TARGET | awk '{print $2}')
+ OLDGRP=$(adb shell ls -al $TARGET | awk '{print $3}')
+ fi
+ echo "Pushing: $TARGET"
+ adb push $FILE $TARGET
+ if [ -n "$OLDPERM" ]; then
+ echo "Setting file permissions: $OLDPERM, $OLDOWN":"$OLDGRP"
+ adb shell chown "$OLDOWN":"$OLDGRP" $TARGET
+ adb shell chmod "$OLDPERM" $TARGET
+ else
+ echo "$TARGET did not exist previously, you should set file permissions manually"
+ fi
+ adb shell restorecon "$TARGET"
+ ;;
/system/priv-app/SystemUI/SystemUI.apk|/system/framework/*)
# Only need to stop services once
if ! $stop_n_start; then
@@ -2226,6 +2263,9 @@ function dopush()
;;
esac
done
+ if [ -n "$CHKPERM" ]; then
+ adb shell rm $CHKPERM
+ fi
if $stop_n_start; then
adb shell start
fi