Revert "App home directories are now 0700 for targetSdkVersion > 17"

This reverts commit 7f5c84a0b2.

Bug: 7966399
Bug: 7208882
Change-Id: I9fb13cf06c0f6605f3d992525346b14fe3259c66
This commit is contained in:
Nick Kralevich 2013-01-09 16:00:35 -08:00 committed by The Android Automerger
parent e0486f1503
commit e9dbe75aa7
4 changed files with 15 additions and 29 deletions

View File

@ -11,8 +11,9 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
$(common_src_files) $(common_src_files)
LOCAL_CFLAGS := -std=gnu99
LOCAL_MODULE := libinstalld LOCAL_MODULE := libinstalld
LOCAL_MODULE_TAGS := eng tests LOCAL_MODULE_TAGS := eng tests
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
@ -35,7 +36,7 @@ LOCAL_STATIC_LIBRARIES := \
libdiskusage libdiskusage
LOCAL_MODULE := installd LOCAL_MODULE := installd
LOCAL_CFLAGS := -std=gnu99
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View File

@ -28,15 +28,13 @@ dir_rec_t android_app_lib_dir;
dir_rec_t android_media_dir; dir_rec_t android_media_dir;
dir_rec_array_t android_system_dirs; dir_rec_array_t android_system_dirs;
int install(const char *pkgname, uid_t uid, gid_t gid, bool restrictHomeDir) int install(const char *pkgname, uid_t uid, gid_t gid)
{ {
char pkgdir[PKG_PATH_MAX]; char pkgdir[PKG_PATH_MAX];
char libsymlink[PKG_PATH_MAX]; char libsymlink[PKG_PATH_MAX];
char applibdir[PKG_PATH_MAX]; char applibdir[PKG_PATH_MAX];
struct stat libStat; struct stat libStat;
mode_t defaultMode = restrictHomeDir ? 0700 : 0751;
if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) { if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
ALOGE("invalid uid/gid: %d %d\n", uid, gid); ALOGE("invalid uid/gid: %d %d\n", uid, gid);
return -1; return -1;
@ -57,11 +55,11 @@ int install(const char *pkgname, uid_t uid, gid_t gid, bool restrictHomeDir)
return -1; return -1;
} }
if (mkdir(pkgdir, defaultMode) < 0) { if (mkdir(pkgdir, 0751) < 0) {
ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno)); ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
return -1; return -1;
} }
if (chmod(pkgdir, defaultMode) < 0) { if (chmod(pkgdir, 0751) < 0) {
ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno)); ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
unlink(pkgdir); unlink(pkgdir);
return -1; return -1;
@ -186,15 +184,13 @@ int delete_user_data(const char *pkgname, uid_t persona)
return delete_dir_contents(pkgdir, 0, "lib"); return delete_dir_contents(pkgdir, 0, "lib");
} }
int make_user_data(const char *pkgname, uid_t uid, uid_t persona, bool restrictHomeDir) int make_user_data(const char *pkgname, uid_t uid, uid_t persona)
{ {
char pkgdir[PKG_PATH_MAX]; char pkgdir[PKG_PATH_MAX];
char applibdir[PKG_PATH_MAX]; char applibdir[PKG_PATH_MAX];
char libsymlink[PKG_PATH_MAX]; char libsymlink[PKG_PATH_MAX];
struct stat libStat; struct stat libStat;
mode_t defaultMode = restrictHomeDir ? 0700 : 0751;
// Create the data dir for the package // Create the data dir for the package
if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, persona)) { if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, persona)) {
return -1; return -1;
@ -208,11 +204,11 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona, bool restrictH
return -1; return -1;
} }
if (mkdir(pkgdir, defaultMode) < 0) { if (mkdir(pkgdir, 0751) < 0) {
ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno)); ALOGE("cannot create dir '%s': %s\n", pkgdir, strerror(errno));
return -errno; return -errno;
} }
if (chmod(pkgdir, defaultMode) < 0) { if (chmod(pkgdir, 0751) < 0) {
ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno)); ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
unlink(pkgdir); unlink(pkgdir);
return -errno; return -errno;

View File

@ -31,11 +31,7 @@ static int do_ping(char **arg, char reply[REPLY_MAX])
static int do_install(char **arg, char reply[REPLY_MAX]) static int do_install(char **arg, char reply[REPLY_MAX])
{ {
bool restrictHomeDir = (strncmp(arg[3], "false", 6) != 0); return install(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, gid */
return install(arg[0], /* pkgname */
atoi(arg[1]), /* uid */
atoi(arg[2]), /* gid */
restrictHomeDir); /* restrictHomeDir */
} }
static int do_dexopt(char **arg, char reply[REPLY_MAX]) static int do_dexopt(char **arg, char reply[REPLY_MAX])
@ -107,11 +103,7 @@ static int do_rm_user_data(char **arg, char reply[REPLY_MAX])
static int do_mk_user_data(char **arg, char reply[REPLY_MAX]) static int do_mk_user_data(char **arg, char reply[REPLY_MAX])
{ {
bool restrictHomeDir = (strncmp(arg[3], "false", 6) != 0); return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, userid */
return make_user_data(arg[0], /* pkgname */
atoi(arg[1]), /* uid */
atoi(arg[2]), /* userid */
restrictHomeDir); /* restrictHomeDir */
} }
static int do_rm_user(char **arg, char reply[REPLY_MAX]) static int do_rm_user(char **arg, char reply[REPLY_MAX])
@ -137,7 +129,7 @@ struct cmdinfo {
struct cmdinfo cmds[] = { struct cmdinfo cmds[] = {
{ "ping", 0, do_ping }, { "ping", 0, do_ping },
{ "install", 4, do_install }, { "install", 3, do_install },
{ "dexopt", 3, do_dexopt }, { "dexopt", 3, do_dexopt },
{ "movedex", 2, do_move_dex }, { "movedex", 2, do_move_dex },
{ "rmdex", 1, do_rm_dex }, { "rmdex", 1, do_rm_dex },
@ -150,7 +142,7 @@ struct cmdinfo cmds[] = {
{ "rmuserdata", 2, do_rm_user_data }, { "rmuserdata", 2, do_rm_user_data },
{ "movefiles", 0, do_movefiles }, { "movefiles", 0, do_movefiles },
{ "linklib", 3, do_linklib }, { "linklib", 3, do_linklib },
{ "mkuserdata", 4, do_mk_user_data }, { "mkuserdata", 3, do_mk_user_data },
{ "rmuser", 1, do_rm_user }, { "rmuser", 1, do_rm_user },
}; };

View File

@ -20,7 +20,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
@ -193,14 +192,12 @@ int ensure_media_user_dirs(userid_t userid);
/* commands.c */ /* commands.c */
int install(const char *pkgname, uid_t uid, gid_t gid, int install(const char *pkgname, uid_t uid, gid_t gid);
bool restrictHomeDirectory);
int uninstall(const char *pkgname, uid_t persona); int uninstall(const char *pkgname, uid_t persona);
int renamepkg(const char *oldpkgname, const char *newpkgname); int renamepkg(const char *oldpkgname, const char *newpkgname);
int fix_uid(const char *pkgname, uid_t uid, gid_t gid); int fix_uid(const char *pkgname, uid_t uid, gid_t gid);
int delete_user_data(const char *pkgname, uid_t persona); int delete_user_data(const char *pkgname, uid_t persona);
int make_user_data(const char *pkgname, uid_t uid, uid_t persona, int make_user_data(const char *pkgname, uid_t uid, uid_t persona);
bool restrictHomeDirectory);
int delete_persona(uid_t persona); int delete_persona(uid_t persona);
int delete_cache(const char *pkgname, uid_t persona); int delete_cache(const char *pkgname, uid_t persona);
int move_dex(const char *src, const char *dst); int move_dex(const char *src, const char *dst);