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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user