From: jk7744.park Date: Sun, 1 Feb 2015 04:33:44 +0000 (+0900) Subject: tizen 2.3 release X-Git-Tag: submit/tizen_2.3/20150202.061249^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_2.3;p=framework%2Fappfw%2Fapp2sd.git tizen 2.3 release --- diff --git a/packaging/app2sd.spec b/packaging/app2sd.spec index a517556..1d4db72 100755 --- a/packaging/app2sd.spec +++ b/packaging/app2sd.spec @@ -1,6 +1,6 @@ Name: app2sd Summary: Application installation on external memory -Version: 0.5.34 +Version: 0.5.36 Release: 1 Group: Application Framework/Application Installer License: Apache-2.0 diff --git a/plugin/app2sd/CMakeLists.txt b/plugin/app2sd/CMakeLists.txt index f9e3ea3..920c369 100755 --- a/plugin/app2sd/CMakeLists.txt +++ b/plugin/app2sd/CMakeLists.txt @@ -3,13 +3,13 @@ PROJECT(app2sd C) ### Required packages INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf) +pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf libprivilege-control) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf) +pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util pkgmgr-info vconf libprivilege-control) FOREACH(flag ${libpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/app2sd/inc/app2sd_internals.h b/plugin/app2sd/inc/app2sd_internals.h index 4992334..c422d8b 100755 --- a/plugin/app2sd/inc/app2sd_internals.h +++ b/plugin/app2sd/inc/app2sd_internals.h @@ -186,10 +186,6 @@ int _app2sd_remove_password_from_db(const char *pkgid); int _app2sd_set_password_in_db(const char *pkgid, const char *passwd); -/* This functions setup path for smack */ -int _app2sd_setup_path(const char *pkgid, const char *dirpath, - int apppathtype, const char *groupid); - /* This functions make result file */ void _app2sd_make_result_info_file(char *pkgid, int size); diff --git a/plugin/app2sd/src/app2sd_interface.c b/plugin/app2sd/src/app2sd_interface.c index ef749f5..5961cb9 100755 --- a/plugin/app2sd/src/app2sd_interface.c +++ b/plugin/app2sd/src/app2sd_interface.c @@ -217,23 +217,10 @@ int app2sd_post_app_install(const char *pkgid, } else { /*If the status is success, then update installed storage to pkgmgr_parser db*/ int rt = 0; - pkgmgrinfo_pkgdbinfo_h handle = NULL; - rt = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle); - if (rt < 0) { - app2ext_print("pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid); - } - rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL); + rt = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL); if (rt < 0) { app2ext_print("fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL); } - rt =pkgmgrinfo_save_pkgdbinfo(handle); - if (rt < 0) { - app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid); - } - rt =pkgmgrinfo_destroy_pkgdbinfo(handle); - if (rt < 0) { - app2ext_print("pkgmgrinfo_destroy_pkgdbinfo[%s] failed\n", pkgid); - } } return ret; } @@ -436,7 +423,7 @@ int app2sd_pre_app_uninstall(const char *pkgid) END: if (ret != APP2EXT_SUCCESS) app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret); - return APP2EXT_SUCCESS; + return ret; } /* @@ -512,7 +499,7 @@ int app2sd_post_app_uninstall(const char *pkgid) END: if (ret != APP2EXT_SUCCESS) app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret); - return APP2EXT_SUCCESS; + return ret; } int app2sd_move_installed_app(const char *pkgid, GList* dir_list, @@ -560,32 +547,17 @@ int app2sd_move_installed_app(const char *pkgid, GList* dir_list, } /*If move is completed, then update installed storage to pkgmgr_parser db*/ - pkgmgrinfo_pkgdbinfo_h handle = NULL; - pkgmgrinfo_ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle); - if (pkgmgrinfo_ret < 0) { - app2ext_print("App2Sd Error : pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid); - } - if (move_type == APP2EXT_MOVE_TO_EXT) { - pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL); + pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL); if (pkgmgrinfo_ret < 0) { app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL); } } else { - pkgmgrinfo_ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL); + pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_INTERNAL); if (pkgmgrinfo_ret < 0) { app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL); } } - pkgmgrinfo_ret =pkgmgrinfo_save_pkgdbinfo(handle); - if (pkgmgrinfo_ret < 0) { - app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid); - } - pkgmgrinfo_ret =pkgmgrinfo_destroy_pkgdbinfo(handle); - if (pkgmgrinfo_ret < 0) { - app2ext_print("pkgmgrinfo_destroy_pkgdbinfo failed\n"); - } - END: // vconf_set_int(VCONFKEY_PKGMGR_STATUS, ret); diff --git a/plugin/app2sd/src/app2sd_internals.c b/plugin/app2sd/src/app2sd_internals.c index 58809b5..72efc28 100755 --- a/plugin/app2sd/src/app2sd_internals.c +++ b/plugin/app2sd/src/app2sd_internals.c @@ -37,17 +37,26 @@ #include #include #include +#include /* ########### Internal APIs ################## */ -enum path_type { - PATH_PRIVATE, - PATH_GROUP_RW, - PATH_PUBLIC_RO, - PATH_SETTINGS_RW, - PATH_ANY_LABEL -}; +static int _app2sd_setup_path(const char *pkgid, const char *dirpath, + int apppathtype, const char *groupid) +{ + int ret = 0; + + if (groupid == NULL) { + ret = perm_app_setup_path(pkgid, dirpath, apppathtype); + app2ext_print( "[smack] app_setup_path(), result = [%d]", ret); + } else { + ret = perm_app_setup_path(pkgid, dirpath, apppathtype, groupid); + app2ext_print( "[smack] app_setup_path(), result = [%d]", ret); + } + + return ret; +} static int _app2sd_apply_app_smack(const char *pkgid, GList* dir_list, const char *groupid) { @@ -62,7 +71,7 @@ static int _app2sd_apply_app_smack(const char *pkgid, GList* dir_list, const cha if (dir_detail && dir_detail->name && dir_detail->type == APP2EXT_DIR_RO) { snprintf(path, FILENAME_MAX, "%s%s/%s",APP_INSTALLATION_PATH, pkgid, dir_detail->name); - ret = _app2sd_setup_path(pkgid, path, PATH_ANY_LABEL, groupid); + ret = _app2sd_setup_path(pkgid, path, PERM_APP_PATH_ANY_LABEL, groupid); if (ret) { app2ext_print ("App2Sd Error : unable to smack %s\n", path); return APP2EXT_ERROR_MOVE; @@ -88,7 +97,7 @@ static int _app2sd_apply_mmc_smack(const char *pkgid, GList* dir_list, const cha && dir_detail->type == APP2EXT_DIR_RO) { snprintf(path, FILENAME_MAX, "%s%s/.mmc/%s",APP_INSTALLATION_PATH, pkgid, dir_detail->name); - ret = _app2sd_setup_path(pkgid, path, PATH_ANY_LABEL, groupid); + ret = _app2sd_setup_path(pkgid, path, PERM_APP_PATH_ANY_LABEL, groupid); if (ret) { app2ext_print ("App2Sd Error : unable to smack %s\n", path); return APP2EXT_ERROR_MOVE; @@ -520,7 +529,13 @@ static int _app2sd_create_dir_with_link(const char *pkgid, } } - ret = _app2sd_setup_path(pkgid, app_dir_path, PATH_ANY_LABEL, pkgid); + ret = _app2sd_setup_path(pkgid, app_dir_path, PERM_APP_PATH_ANY_LABEL, pkgid); + if (ret) { + app2ext_print ("App2Sd Error : unable to smack %s\n", app_dir_path); + return APP2EXT_ERROR_MOVE; + } + + ret = _app2sd_setup_path(pkgid, app_dir_mmc_path, PERM_APP_PATH_ANY_LABEL, pkgid); if (ret) { app2ext_print ("App2Sd Error : unable to smack %s\n", app_dir_mmc_path); return APP2EXT_ERROR_MOVE; diff --git a/plugin/app2sd/src/app2sd_internals_utils.c b/plugin/app2sd/src/app2sd_internals_utils.c index 1c3d046..744f07b 100755 --- a/plugin/app2sd/src/app2sd_internals_utils.c +++ b/plugin/app2sd/src/app2sd_internals_utils.c @@ -35,11 +35,9 @@ #include #include #include -#include #define PASSWD_LEN 8 #define ASCII_PASSWD_CHAR 93 -#define LIB_PRIVILEGE_CONTROL "libprivilege-control.so.0" /* ########### Internal APIs ################## @@ -58,7 +56,9 @@ int _xsystem(const char *argv[]) return -1; case 0: /* child */ - execvp(argv[0], (char *const *)argv); + if (execvp(argv[0], (char *const *)argv) < 0) { + fprintf(stderr, "execvp failed %d....%s\n", errno, strerror(errno)); /*Don't use d_msg_app2sd */ + } _exit(-1); default: /* parent */ @@ -329,11 +329,13 @@ char *_app2sd_encrypt_device(const char *device, const char *pkgid, result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } if (execvp(argv[0], (char *const *)argv) < 0) { @@ -384,11 +386,13 @@ char *_app2sd_detach_loop_device(const char *device) result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } if (execvp(argv[0], (char *const *)argv) < 0) { @@ -440,11 +444,13 @@ char *_app2sd_find_associated_device(const char *mmc_app_path) result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } if (execvp(argv[0], (char *const *)argv) < 0) { @@ -496,11 +502,13 @@ char *_app2sd_find_free_device(void) result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } result = dup(my_pipe[1]); if (result < 0) { fprintf(stderr, "dup failed %d....%s\n", errno, strerror(errno)); + close(result); _exit(-1); } if (execvp(argv[0], (char *const *)argv) < 0) { @@ -564,47 +572,3 @@ char *_app2sd_generate_password(const char *pkgid) memcpy(ret_result, passwd, PASSWD_LEN+1); return ret_result; } - -/*@_app2sd_setup_path -* change smack label given groupid -* return: On success, it will return the password, else NULL. -*/ -int _app2sd_setup_path(const char *pkgid, const char *dirpath, - int apppathtype, const char *groupid) -{ - int ret = 0; - void *handle = NULL; - char *errmsg = NULL; - int (*app_setup_path)(const char*, const char*, int, ...) = NULL; - - if (pkgid == NULL || dirpath == NULL) - return -1; - - handle = dlopen(LIB_PRIVILEGE_CONTROL, RTLD_LAZY | RTLD_GLOBAL); - if (!handle) { - app2ext_print( "setup path: dlopen() failed. [%s]", dlerror()); - return -1; - } - - app_setup_path = dlsym(handle, "app_setup_path"); - errmsg = dlerror(); - if ((errmsg != NULL) || (app_setup_path == NULL)) { - app2ext_print( "setup path: dlsym() failed. [%s]", errmsg); - dlclose(handle); - return -1; - } - - if (groupid == NULL) { - app2ext_print( "[smack] app_setup_path(%s, %s, %d)", pkgid, dirpath, apppathtype); - ret = app_setup_path(pkgid, dirpath, apppathtype); - app2ext_print( "[smack] app_setup_path(), result = [%d]", ret); - } else { - app2ext_print( "[smack] app_setup_path(%s, %s, %d, %s)", pkgid, dirpath, apppathtype, groupid); - ret = app_setup_path(pkgid, dirpath, apppathtype, groupid); - app2ext_print( "[smack] app_setup_path(), result = [%d]", ret); - } - - dlclose(handle); - return ret; -} -