[Android Software Development] Deltadroid:
Permission fixes in gapps base packages

I was reviewing the gapps base installation scripts and I noticed that there are some permission problems that were carried over from the official gapps installation scripts. Lollipop now requires all subdirectories of /etc and /vendor to be root:shell permissions (except /etc/ppp which is root:root permissions), whereas Kitkat requires all subdirectories of /vendor to be root:shell permissions, but not the subdirectories of /etc like lollipop does.

I've uploaded new gapps packages that set the proper permissions to /etc and /vendor subdirecories in kitkat and lollipop.

Kitkat Base Gapps package for 4.4.4: gapps-444-base-20150531-1-signed.zip

Lollipop Base Gapps package for 5.0.2: gapps-502-base-20150531-1-signed.zip

Lollipop Base Gapps package for 5.1.1: gapps-511-base-20150531-1-signed.zip

diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-444-base-20150527-1-signed/META-INF/com/google/android/updater-script gapps-444-base-20150531-1-signed/META-INF/com/google/android/updater-script
--- gapps-444-base-20150527-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
+++ gapps-444-base-20150531-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
@@ -47,6 +47,12 @@
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/vendor/pittpatt", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.7", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.6", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/recognition", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");

ui_print("Unmounting system.");
run_program("/sbin/busybox", "umount", "/system");
diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-444-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh gapps-444-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh
--- gapps-444-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
+++ gapps-444-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
@@ -50,5 +50,11 @@
chmod 644 /system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.7/*
chmod 644 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.6/*
chmod 644 /system/vendor/pittpatt/models/recognition/*
+ chown 0:2000 /system/vendor/pittpatt
+ chown 0:2000 /system/vendor/pittpatt/models
+ chown 0:2000 /system/vendor/pittpatt/models/detection
+ chown 0:2000 /system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.7
+ chown 0:2000 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.6
+ chown 0:2000 /system/vendor/pittpatt/models/recognition
;;
esac

diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-502-base-20150527-1-signed/META-INF/com/google/android/updater-script gapps-502-base-20150531-1-signed/META-INF/com/google/android/updater-script
--- gapps-502-base-20150527-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
+++ gapps-502-base-20150531-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
@@ -1,5 +1,5 @@
ui_print("***********************************************");
-ui_print(" Google Apps Base for Android 5.0.x ");
+ui_print(" Google Apps Base for Android 5.0.2 ");
ui_print("***********************************************");

ui_print("Mounting system.");
@@ -38,12 +38,20 @@
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/etc/permissions", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/etc/preferred-apps", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/vendor/pittpatt", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/recognition", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");

ui_print("Unmounting system.");
run_program("/sbin/busybox", "umount", "/system");
diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-502-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh gapps-502-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh
--- gapps-502-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
+++ gapps-502-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
@@ -58,5 +58,11 @@
chmod 644 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/*
chmod 644 /system/vendor/pittpatt/models/recognition/*
ln -s /system/lib/libfacelock_jni.so /system/app/FaceLock/lib/arm/libfacelock_jni.so
+ chown 0:2000 /system/vendor/pittpatt
+ chown 0:2000 /system/vendor/pittpatt/models
+ chown 0:2000 /system/vendor/pittpatt/models/detection
+ chown 0:2000 /system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8
+ chown 0:2000 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1
+ chown 0:2000 /system/vendor/pittpatt/models/recognition
;;
esac
diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-502-base-20150527-1-signed/system/addon.d/70-gapps.sh gapps-502-base-20150531-1-signed/system/addon.d/70-gapps.sh
--- gapps-502-base-20150527-1-signed/system/addon.d/70-gapps.sh	2008-02-29 02:33:46.000000000 +0100
+++ gapps-502-base-20150531-1-signed/system/addon.d/70-gapps.sh	2008-02-29 02:33:46.000000000 +0100
@@ -117,5 +117,6 @@
chmod 755 /system/priv-app/SetupWizard
chmod 755 /system/usr/srec
chmod 755 /system/usr/srec/en-US
+ chown 0:2000 /system/etc/preferred-apps
;;
esac

diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-511-base-20150527-1-signed/META-INF/com/google/android/updater-script gapps-511-base-20150531-1-signed/META-INF/com/google/android/updater-script
--- gapps-511-base-20150527-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
+++ gapps-511-base-20150531-1-signed/META-INF/com/google/android/updater-script	2008-02-29 02:33:46.000000000 +0100
@@ -38,12 +38,20 @@
set_metadata_recursive("/system/app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/priv-app", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/permissions", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/etc/permissions", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/etc/preferred-apps", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/etc/preferred-apps", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/etc/g.prop", "uid", 0, "gid", 0, "mode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/framework", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/lib", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/usr/srec", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata_recursive("/system/vendor/pittpatt", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
+set_metadata("/system/vendor/pittpatt/models/recognition", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");

ui_print("Unmounting system.");
run_program("/sbin/busybox", "umount", "/system");
diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-511-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh gapps-511-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh
--- gapps-511-base-20150527-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
+++ gapps-511-base-20150531-1-signed/optional/face/addon.d/71-gapps-faceunlock.sh	2008-02-29 02:33:46.000000000 +0100
@@ -58,5 +58,11 @@
chmod 644 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1/*
chmod 644 /system/vendor/pittpatt/models/recognition/*
ln -s /system/lib/libfacelock_jni.so /system/app/FaceLock/lib/arm/libfacelock_jni.so
+ chown 0:2000 /system/vendor/pittpatt
+ chown 0:2000 /system/vendor/pittpatt/models
+ chown 0:2000 /system/vendor/pittpatt/models/detection
+ chown 0:2000 /system/vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.8
+ chown 0:2000 /system/vendor/pittpatt/models/detection/yaw_roll_face_detectors.7.1
+ chown 0:2000 /system/vendor/pittpatt/models/recognition
;;
esac
diff -ru '--exclude=CERT.RSA' '--exclude=CERT.SF' '--exclude=MANIFEST.MF' gapps-511-base-20150527-1-signed/system/addon.d/70-gapps.sh gapps-511-base-20150531-1-signed/system/addon.d/70-gapps.sh
--- gapps-511-base-20150527-1-signed/system/addon.d/70-gapps.sh	2008-02-29 02:33:46.000000000 +0100
+++ gapps-511-base-20150531-1-signed/system/addon.d/70-gapps.sh	2008-02-29 02:33:46.000000000 +0100
@@ -117,5 +117,6 @@
chmod 755 /system/priv-app/SetupWizard
chmod 755 /system/usr/srec
chmod 755 /system/usr/srec/en-US
+ chown 0:2000 /system/etc/preferred-apps
;;
esac