diff options
author | Mike Lockwood <lockwood@android.com> | 2010-08-06 09:15:25 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-08-06 09:19:58 -0400 |
commit | 90960e87ecae696f73ae18e46c2f003fc3f592cc (patch) | |
tree | ad3b05725b98e20cc9b6b7d49a62f702740ef9fb /core | |
parent | 90d5e8c08ba0b3fd86fa8077bf90c88133f82382 (diff) | |
download | frameworks_base-90960e87ecae696f73ae18e46c2f003fc3f592cc.zip frameworks_base-90960e87ecae696f73ae18e46c2f003fc3f592cc.tar.gz frameworks_base-90960e87ecae696f73ae18e46c2f003fc3f592cc.tar.bz2 |
Set umask of system server to 0077
This matches the previous behavior of java.io.File file and directory creation.
BUG: 2898660
Change-Id: Ie8978a3fc44abfd22f8046e66742e715354220a8
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/FileUtils.java | 2 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 4 | ||||
-rw-r--r-- | core/jni/android_os_FileUtils.cpp | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index a17b7fe..72e21de 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -85,6 +85,8 @@ public class FileUtils public static native int getPermissions(String file, int[] outPermissions); + public static native int setUMask(int mask); + /** returns the FAT file system volume ID for the volume mounted * at the given mount point, or -1 for failure * @param mount point for FAT volume diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index f8a77a1..9c84e0e 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -22,6 +22,7 @@ import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.net.LocalServerSocket; import android.os.Debug; +import android.os.FileUtils; import android.os.SystemClock; import android.os.SystemProperties; import android.util.Config; @@ -506,6 +507,9 @@ public class ZygoteInit { closeServerSocket(); + // set umask to 0077 so new files and directories will default to owner-only permissions. + FileUtils.setUMask(FileUtils.S_IRWXG | FileUtils.S_IRWXO); + /* * Pass the remaining arguments to SystemServer. * "--nice-name=system_server com.android.server.SystemServer" diff --git a/core/jni/android_os_FileUtils.cpp b/core/jni/android_os_FileUtils.cpp index 21cb919..d3faa2f 100644 --- a/core/jni/android_os_FileUtils.cpp +++ b/core/jni/android_os_FileUtils.cpp @@ -113,6 +113,11 @@ jint android_os_FileUtils_getPermissions(JNIEnv* env, jobject clazz, #endif } +jint android_os_FileUtils_setUMask(JNIEnv* env, jobject clazz, jint mask) +{ + return umask(mask); +} + jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring path) { #if HAVE_ANDROID_OS @@ -170,6 +175,7 @@ jboolean android_os_FileUtils_getFileStatus(JNIEnv* env, jobject clazz, jstring static const JNINativeMethod methods[] = { {"setPermissions", "(Ljava/lang/String;III)I", (void*)android_os_FileUtils_setPermissions}, {"getPermissions", "(Ljava/lang/String;[I)I", (void*)android_os_FileUtils_getPermissions}, + {"setUMask", "(I)I", (void*)android_os_FileUtils_setUMask}, {"getFatVolumeId", "(Ljava/lang/String;)I", (void*)android_os_FileUtils_getFatVolumeId}, {"getFileStatus", "(Ljava/lang/String;Landroid/os/FileUtils$FileStatus;)Z", (void*)android_os_FileUtils_getFileStatus}, }; |