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