diff options
Diffstat (limited to 'cmds/installd')
-rw-r--r-- | cmds/installd/Android.mk | 9 | ||||
-rw-r--r-- | cmds/installd/commands.c | 27 | ||||
-rw-r--r-- | cmds/installd/installd.c | 11 | ||||
-rw-r--r-- | cmds/installd/installd.h | 4 | ||||
-rw-r--r-- | cmds/installd/tests/Android.mk | 11 |
5 files changed, 22 insertions, 40 deletions
diff --git a/cmds/installd/Android.mk b/cmds/installd/Android.mk index 3e722ea..1dd4ee5 100644 --- a/cmds/installd/Android.mk +++ b/cmds/installd/Android.mk @@ -29,17 +29,12 @@ LOCAL_SRC_FILES := \ $(common_src_files) LOCAL_SHARED_LIBRARIES := \ - libcutils + libcutils \ + libselinux LOCAL_STATIC_LIBRARIES := \ libdiskusage -ifeq ($(HAVE_SELINUX),true) -LOCAL_C_INCLUDES += external/libselinux/include -LOCAL_SHARED_LIBRARIES += libselinux -LOCAL_CFLAGS := -DHAVE_SELINUX -endif # HAVE_SELINUX - LOCAL_MODULE := installd LOCAL_MODULE_TAGS := optional diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c index 387f33d..09d6f89 100644 --- a/cmds/installd/commands.c +++ b/cmds/installd/commands.c @@ -14,13 +14,10 @@ ** limitations under the License. */ -#include <linux/capability.h> +#include <sys/capability.h> #include "installd.h" #include <diskusage/dirsize.h> - -#ifdef HAVE_SELINUX #include <selinux/android.h> -#endif /* Directory records that are used in execution of commands. */ dir_rec_t android_data_dir; @@ -31,7 +28,7 @@ dir_rec_t android_app_lib_dir; dir_rec_t android_media_dir; dir_rec_array_t android_system_dirs; -int install(const char *pkgname, uid_t uid, gid_t gid) +int install(const char *pkgname, uid_t uid, gid_t gid, const char *seinfo) { char pkgdir[PKG_PATH_MAX]; char libsymlink[PKG_PATH_MAX]; @@ -94,14 +91,12 @@ int install(const char *pkgname, uid_t uid, gid_t gid) return -1; } -#ifdef HAVE_SELINUX - if (selinux_android_setfilecon(pkgdir, pkgname, uid) < 0) { + if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) { ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno)); unlink(libsymlink); unlink(pkgdir); - return -1; + return -errno; } -#endif if (chown(pkgdir, uid, gid) < 0) { ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno)); @@ -189,7 +184,7 @@ int delete_user_data(const char *pkgname, uid_t persona) return delete_dir_contents(pkgdir, 0, "lib"); } -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, const char* seinfo) { char pkgdir[PKG_PATH_MAX]; char applibdir[PKG_PATH_MAX]; @@ -250,21 +245,19 @@ int make_user_data(const char *pkgname, uid_t uid, uid_t persona) return -1; } - if (chown(pkgdir, uid, uid) < 0) { - ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno)); + if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) { + ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno)); unlink(libsymlink); unlink(pkgdir); return -errno; } -#ifdef HAVE_SELINUX - if (selinux_android_setfilecon(pkgdir, pkgname, uid) < 0) { - ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno)); + if (chown(pkgdir, uid, uid) < 0) { + ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno)); unlink(libsymlink); unlink(pkgdir); return -errno; } -#endif return 0; } @@ -324,7 +317,7 @@ int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy) uid = (uid_t) s.st_uid % PER_USER_RANGE; /* Create the directory for the target */ make_user_data(name, uid + target_persona * PER_USER_RANGE, - target_persona); + target_persona, NULL); } } closedir(d); diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c index 21d674a..281aaab 100644 --- a/cmds/installd/installd.c +++ b/cmds/installd/installd.c @@ -14,7 +14,7 @@ ** limitations under the License. */ -#include <linux/capability.h> +#include <sys/capability.h> #include <linux/prctl.h> #include "installd.h" @@ -31,7 +31,7 @@ static int do_ping(char **arg, char reply[REPLY_MAX]) static int do_install(char **arg, char reply[REPLY_MAX]) { - return install(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, gid */ + return install(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]); /* pkgname, uid, gid, seinfo */ } static int do_dexopt(char **arg, char reply[REPLY_MAX]) @@ -103,7 +103,8 @@ static int do_rm_user_data(char **arg, char reply[REPLY_MAX]) static int do_mk_user_data(char **arg, char reply[REPLY_MAX]) { - return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, userid */ + return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]); + /* pkgname, uid, userid, seinfo */ } static int do_rm_user(char **arg, char reply[REPLY_MAX]) @@ -134,7 +135,7 @@ struct cmdinfo { struct cmdinfo cmds[] = { { "ping", 0, do_ping }, - { "install", 3, do_install }, + { "install", 4, do_install }, { "dexopt", 3, do_dexopt }, { "movedex", 2, do_move_dex }, { "rmdex", 1, do_rm_dex }, @@ -147,7 +148,7 @@ struct cmdinfo cmds[] = { { "rmuserdata", 2, do_rm_user_data }, { "movefiles", 0, do_movefiles }, { "linklib", 3, do_linklib }, - { "mkuserdata", 3, do_mk_user_data }, + { "mkuserdata", 4, do_mk_user_data }, { "rmuser", 1, do_rm_user }, { "cloneuserdata", 3, do_clone_user_data }, }; diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 0500c23..04498ef 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -192,12 +192,12 @@ int ensure_media_user_dirs(userid_t userid); /* commands.c */ -int install(const char *pkgname, uid_t uid, gid_t gid); +int install(const char *pkgname, uid_t uid, gid_t gid, const char *seinfo); int uninstall(const char *pkgname, uid_t persona); int renamepkg(const char *oldpkgname, const char *newpkgname); int fix_uid(const char *pkgname, uid_t uid, gid_t gid); 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, const char* seinfo); int delete_persona(uid_t persona); int clone_persona_data(uid_t src_persona, uid_t target_persona, int copy); int delete_cache(const char *pkgname, uid_t persona); diff --git a/cmds/installd/tests/Android.mk b/cmds/installd/tests/Android.mk index 315acdb..c0192f4 100644 --- a/cmds/installd/tests/Android.mk +++ b/cmds/installd/tests/Android.mk @@ -18,13 +18,7 @@ static_libraries := \ libgtest_main c_includes := \ - frameworks/base/cmds/installd \ - bionic \ - bionic/libstdc++/include \ - external/gtest/include \ - external/stlport/stlport - -module_tags := eng tests + frameworks/base/cmds/installd $(foreach file,$(test_src_files), \ $(eval include $(CLEAR_VARS)) \ @@ -33,6 +27,5 @@ $(foreach file,$(test_src_files), \ $(eval LOCAL_SRC_FILES := $(file)) \ $(eval LOCAL_C_INCLUDES := $(c_includes)) \ $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ - $(eval LOCAL_MODULE_TAGS := $(module_tags)) \ - $(eval include $(BUILD_EXECUTABLE)) \ + $(eval include $(BUILD_NATIVE_TEST)) \ ) |