Merge "Update fix_permissions to not clobber the UID and GID variables. This causes issues in bash." into froyo

This commit is contained in:
Steve Kondik 2010-09-02 12:23:11 +00:00 committed by Gerrit Code Review
commit 94a3184db3

View File

@ -61,8 +61,8 @@ DATE="busybox date"
# Initialise vars
CODEPATH=""
UID=""
GID=""
LOCALUID=""
LOCALGID=""
PACKAGE=""
REMOVE=0
NOSYSTEM=0
@ -295,14 +295,14 @@ fp_package()
endnum=$3
CODEPATH=$( $ECHO $pkgline | $SED 's%.* codePath="\(.*\)".*%\1%' | $CUT -d '"' -f1 )
PACKAGE=$( $ECHO $pkgline | $SED 's%.* name="\(.*\)".*%\1%' | $CUT -d '"' -f1 )
UID=$( $ECHO $pkgline | $SED 's%.*serId="\(.*\)".*%\1%' | $CUT -d '"' -f1 )
GID=$UID
LOCALUID=$( $ECHO $pkgline | $SED 's%.*serId="\(.*\)".*%\1%' | $CUT -d '"' -f1 )
LOCALGID=$LOCALUID
APPDIR=$( $ECHO $CODEPATH | $SED 's%^\(.*\)/.*%\1%' )
APK=$( $ECHO $CODEPATH | $SED 's%^.*/\(.*\..*\)$%\1%' )
#debug
if $TEST $DEBUG -eq 1; then
fp_print "CODEPATH: $CODEPATH APPDIR: $APPDIR APK:$APK UID/GID:$UID:$GID"
fp_print "CODEPATH: $CODEPATH APPDIR: $APPDIR APK:$APK UID/GID:$LOCALUID:$LOCALGID"
fi
#check for existence of apk
@ -331,7 +331,7 @@ fp_package()
fp_chmod $OLD_PER "rw-r--r--" 644 "$CODEPATH"
elif $TEST "$APPDIR" = "/data/app-private" || $TEST "$APPDIR" = "/sd-ext/app-private"; then
fp_chown_uid $OLD_UID 1000 "$CODEPATH"
fp_chown_gid $OLD_GID $GID "$CODEPATH"
fp_chown_gid $OLD_GID $LOCALGID "$CODEPATH"
fp_chmod $OLD_PER "rw-r-----" 640 "$CODEPATH"
fi
else
@ -361,11 +361,11 @@ fp_package()
ISLIB=0
REVPERM=755
REVPSTR="rwxr-xr-x"
REVUID=$UID
REVGID=$GID
REVUID=$LOCALUID
REVGID=$LOCALGID
if $TEST "$FOURDIR" = ""; then
#package directory, perms:755 owner:$UID:$GID
#package directory, perms:755 owner:$LOCALUID:$LOCALGID
fp_chmod $OLD_PER "rwxr-xr-x" 755 "$FILEDIR"
elif $TEST "$FOURDIR" = "lib"; then
#lib directory, perms:755 owner:1000:1000
@ -377,25 +377,25 @@ fp_package()
REVGID=1000
fp_chmod $OLD_PER "rwxr-xr-x" 755 "$FILEDIR"
elif $TEST "$FOURDIR" = "shared_prefs"; then
#shared_prefs directories, perms:771 owner:$UID:$GID
#shared_prefs files, perms:660 owner:$UID:$GID
#shared_prefs directories, perms:771 owner:$LOCALUID:$LOCALGID
#shared_prefs files, perms:660 owner:$LOCALUID:$LOCALGID
REVPERM=660
REVPSTR="rw-rw----"
fp_chmod $OLD_PER "rwxrwx--x" 771 "$FILEDIR"
elif $TEST "$FOURDIR" = "databases"; then
#databases directories, perms:771 owner:$UID:$GID
#databases files, perms:660 owner:$UID:$GID
#databases directories, perms:771 owner:$LOCALUID:$LOCALGID
#databases files, perms:660 owner:$LOCALUID:$LOCALGID
REVPERM=660
REVPSTR="rw-rw----"
fp_chmod $OLD_PER "rwxrwx--x" 771 "$FILEDIR"
elif $TEST "$FOURDIR" = "cache"; then
#cache directories, perms:771 owner:$UID:$GID
#cache files, perms:600 owner:$UID:GID
#cache directories, perms:771 owner:$LOCALUID:$LOCALGID
#cache files, perms:600 owner:$LOCALUID:$LOCALGID
REVPERM=600
REVPSTR="rw-------"
fp_chmod $OLD_PER "rwxrwx--x" 771 "$FILEDIR"
else
#other directories, perms:771 owner:$UID:$GID
#other directories, perms:771 owner:$LOCALUID:$LOCALGID
REVPERM=771
REVPSTR="rwxrwx--x"
fp_chmod $OLD_PER "rwxrwx--x" 771 "$FILEDIR"
@ -406,8 +406,8 @@ fp_package()
fp_chown_uid $OLD_UID 1000 "$FILEDIR"
fp_chown_gid $OLD_GID 1000 "$FILEDIR"
else
fp_chown_uid $OLD_UID $UID "$FILEDIR"
fp_chown_gid $OLD_GID $GID "$FILEDIR"
fp_chown_uid $OLD_UID $LOCALUID "$FILEDIR"
fp_chown_gid $OLD_GID $LOCALGID "$FILEDIR"
fi
#if any files exist in directory with improper permissions reset them