From bab00bfab91f0e394386136361ee2e732666fdec Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 21 Aug 2015 14:35:37 +0900 Subject: [PATCH] Clean up repository, remove warnings remove ail, ail_vconf dependency remove po files remove unused tools remove old apis: pkgmgr_get_pkg_list pkgmgr_info_new pkgmgr_info_new_from_file pkgmgr_info_get_string pkgmgr_info_free Change-Id: I11fad0b2507f953b3ba6c30eeddc3b34fb40530e Signed-off-by: Sangyoon Jang --- client/CMakeLists.txt | 1 - client/include/package-manager.h | 75 ------- client/include/pkgmgr-internal.h | 2 +- client/src/pkgmgr-internal.c | 36 ++-- client/src/pkgmgr.c | 445 ++++++--------------------------------- comm/comm_client_gdbus.c | 10 +- comm/comm_pkg_mgr_server.c | 4 +- packaging/pkgmgr.spec | 16 +- server/CMakeLists.txt | 3 - server/po/CMakeLists.txt | 24 --- server/po/POTFILES.in | 2 - server/po/en_GB.po | 32 --- server/po/en_US.po | 32 --- server/po/ja_JP.po | 32 --- server/po/ko_KR.po | 32 --- server/po/package-manager.pot | 32 --- server/po/update-po.sh | 60 ------ server/po/zh_CN.po | 32 --- server/src/pkgmgr-server.c | 240 ++++++--------------- tool/CMakeLists.txt | 68 ++---- tool/pkg_cmd.c | 190 ++--------------- tool/pkg_createdb.c | 372 -------------------------------- tool/pkg_createdb_user.c | 310 --------------------------- tool/pkg_info.c | 22 +- tool/pkg_initdb.c | 22 +- tool/pkg_initdb_user.c | 192 ----------------- tool/pkg_install_ug.c | 1 - tool/pkg_privilege.c | 4 +- tool/pkg_syncdb.c | 196 ----------------- tool/pkg_syncdb_user.c | 181 ---------------- tool/stress_test.py | 36 ---- 31 files changed, 208 insertions(+), 2496 deletions(-) delete mode 100644 server/po/CMakeLists.txt delete mode 100644 server/po/POTFILES.in delete mode 100644 server/po/en_GB.po delete mode 100644 server/po/en_US.po delete mode 100644 server/po/ja_JP.po delete mode 100644 server/po/ko_KR.po delete mode 100644 server/po/package-manager.pot delete mode 100755 server/po/update-po.sh delete mode 100644 server/po/zh_CN.po delete mode 100644 tool/pkg_createdb.c delete mode 100644 tool/pkg_createdb_user.c delete mode 100644 tool/pkg_initdb_user.c delete mode 100644 tool/pkg_syncdb.c delete mode 100644 tool/pkg_syncdb_user.c delete mode 100755 tool/stress_test.py diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8c16544..09e13f9 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -5,7 +5,6 @@ SET(SRCS src/pkgmgr-internal.c src/pkgmgr.c) pkg_check_modules(CLIENT_DEPS REQUIRED dbus-glib-1 dlog - ail pkgmgr-parser pkgmgr-info iniparser diff --git a/client/include/package-manager.h b/client/include/package-manager.h index 6d756b0..576e192 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -671,81 +671,6 @@ int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid); */ int pkgmgr_client_clear_all_cache_dir(void); int pkgmgr_client_usr_clear_all_cache_dir(uid_t uid); - -/** - * @brief This API provides package list - * - * This API is for package-manager client application.\n - * - * @param[in] iter_fn iteration function for list - * @param[in] data user data - * @return 0 if success, error code(<0) if fail\n - * @retval PKGMGR_R_OK success - * @retval PKGMGR_R_EINVAL invalid argument - * @retval PKGMGR_R_ERROR internal error -*/ -int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid); -/** @} */ - -/** - * @defgroup pkg_list APIs to get package information - * @ingroup pkgmgr - * @brief - * API to get package information -*/ - -/** - * @addtogroup pkg_list - * @{ - */ - - -/** - * @brief This API gets the package's information. - * - * This API is for package-manager client application.\n - * - * @param[in] pkg_type package type for the package to get infomation - * @param[in] pkgid package id for the package to get infomation - * @param[in] uid the addressee user id of the instruction - * @return package entry pointer if success, NULL if fail\n -*/ -pkgmgr_info * pkgmgr_info_new(const char *pkg_type, const char *pkgid); -pkgmgr_info * pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, uid_t uid); - -/** - * @brief This API gets the package's information. - * - * This API is for package-manager client application.\n - * - * @param[in] pkg_type package type for the package to get infomation - * @param[in] pkg_path package file path to get infomation - * @return package entry pointer if success, NULL if fail\n -*/ -pkgmgr_info * pkgmgr_info_new_from_file(const char *pkg_type, - const char *pkg_path); - -/** - * @brief This API get package information value - * - * This API is for package-manager client application.\n - * - * @param[in] pkg_info pointer for package info entry - * @param[in] key key for package info field - * @return string value if success, NULL if fail\n -*/ -char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key); - -/** - * @brief This API get package information value - * - * This API is for package-manager client application.\n - * - * @param[in] pkg_info pointer for package info entry - * @return 0 if success, error code(<0) if fail\n -*/ -int pkgmgr_info_free(pkgmgr_info * pkg_info); - /** @} */ diff --git a/client/include/pkgmgr-internal.h b/client/include/pkgmgr-internal.h index 75d5722..7955c30 100644 --- a/client/include/pkgmgr-internal.h +++ b/client/include/pkgmgr-internal.h @@ -35,7 +35,7 @@ typedef package_manager_pkg_info_t package_manager_app_info_t; -char *_get_pkg_type_from_desktop_file(const char *pkgid, uid_t uid); +const char *_get_pkg_type(const char *pkgid, uid_t uid); package_manager_pkg_info_t *_pkg_malloc_appinfo(int num); diff --git a/client/src/pkgmgr-internal.c b/client/src/pkgmgr-internal.c index 762e1e7..f28e6ff 100644 --- a/client/src/pkgmgr-internal.c +++ b/client/src/pkgmgr-internal.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include "package-manager.h" @@ -261,35 +260,24 @@ int _get_mime_extension(const char *mimetype, char *ext, int len) return 0; } -char *_get_pkg_type_from_desktop_file(const char *pkgid, uid_t uid) +const char *_get_pkg_type(const char *pkgid, uid_t uid) { + int ret; + pkgmgrinfo_pkginfo_h pkginfo; + char *val; static char pkg_type[PKG_EXT_LEN_MAX]; - - ail_appinfo_h handle; - ail_error_e ret; - char *str; - if(uid != GLOBAL_USER) - { - ret = ail_package_get_usr_appinfo(pkgid, uid, &handle); - }else - { - ret = ail_package_get_appinfo(pkgid, &handle); - } - if (ret != AIL_ERROR_OK) { - return NULL; - } - ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str); - if (ret != AIL_ERROR_OK) { - ail_package_destroy_appinfo(handle); + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo); + if (ret != PMINFO_R_OK) return NULL; - } - snprintf(pkg_type, sizeof(pkg_type) - 1, str); - ret = ail_package_destroy_appinfo(handle); - if (ret != AIL_ERROR_OK) { + ret = pkgmgrinfo_pkginfo_get_type(pkginfo, &val); + if (ret != PMINFO_R_OK) return NULL; - } + + snprintf(pkg_type, sizeof(pkg_type), "%s", val); + + pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo); return pkg_type; } diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 680d605..61c81d6 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -33,8 +33,6 @@ #include #include -#include -#include #include #include /* For multi-user support */ @@ -258,25 +256,6 @@ static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key) return NULL; } -static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info) -{ - req_cb_info *tmp; - - if (pc == NULL || pc->info.request.rhead == NULL || info == NULL) - return; - - tmp = pc->info.request.rhead; - while (tmp) { - if (tmp->next == info) { - tmp->next = info->next; - free(info); - return; - } - tmp = tmp->next; - } -} - - static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id, pkgmgr_handler event_cb, void *data) { @@ -337,13 +316,6 @@ static void __operation_callback(void *cb_data, uid_t target_uid, cb_info->data); } - /*remove callback for last call - if (strcmp(key, "end") == 0) { - __remove_op_cbinfo(pc, cb_info); - DBG("__remove_op_cbinfo"); - } - */ - return; } @@ -448,61 +420,41 @@ err: return ret; } -static inline ail_cb_ret_e __appinfo_cb(const ail_appinfo_h appinfo, void *user_data) +static int __appinfo_cb(pkgmgrinfo_appinfo_h handle, void *user_data) { - char *package; - ail_cb_ret_e ret = AIL_CB_RET_CONTINUE; + char **appid = (char **)user_data; - ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package); - - if (package) { - (* (char **) user_data) = strdup(package); - ret = AIL_CB_RET_CANCEL; - } - - return ret; + return pkgmgrinfo_appinfo_get_appid(handle, appid); } static char *__get_app_info_from_db_by_apppath(const char *apppath, uid_t uid) { + int ret; char *caller_appid = NULL; - ail_filter_h filter; - ail_error_e ret; - int count; + pkgmgrinfo_appinfo_filter_h filter; if (apppath == NULL) return NULL; - ret = ail_filter_new(&filter); - if (ret != AIL_ERROR_OK) { + ret = pkgmgrinfo_appinfo_filter_create(&filter) != PMINFO_R_OK; + if (ret != PMINFO_R_OK) return NULL; - } - ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath); - if (ret != AIL_ERROR_OK) { - ail_filter_destroy(filter); + ret = pkgmgrinfo_appinfo_filter_add_string(filter, + PMINFO_APPINFO_PROP_APP_EXEC, apppath); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_filter_destroy(filter); return NULL; } - - if(uid != GLOBAL_USER) - ret = ail_filter_count_usr_appinfo(filter, &count, uid); - else - ret = ail_filter_count_appinfo(filter, &count); - if (ret != AIL_ERROR_OK) { - ail_filter_destroy(filter); - return NULL; - } - if (count < 1) { - ail_filter_destroy(filter); + ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(filter, + __appinfo_cb, &caller_appid, uid); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_filter_destroy(filter); return NULL; } - if(uid != GLOBAL_USER) - ail_filter_list_usr_appinfo_foreach(filter, __appinfo_cb, &caller_appid,uid); - else - ail_filter_list_appinfo_foreach(filter, __appinfo_cb, &caller_appid); - ail_filter_destroy(filter); + pkgmgrinfo_appinfo_filter_destroy(filter); return caller_appid; } @@ -568,7 +520,7 @@ static int __get_appid_bypid(int pid, char *pkgname, int len, uid_t uid) static char *__get_caller_pkgid(uid_t uid) { - char *caller_appid[PKG_STRING_LEN_MAX] = {0, }; + char caller_appid[PKG_STRING_LEN_MAX] = {0, }; char *caller_pkgid = NULL; if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid), uid) < 0) { @@ -621,52 +573,7 @@ static inline int __pkgmgr_find_pid_by_cmdline(const char *dname, return pid; } - -static int __pkgmgr_proc_iter_kill_cmdline(const char *apppath) -{ - DIR *dp; - struct dirent *dentry; - int pid; - int ret; - char buf[PKG_STRING_LEN_MAX]; - - dp = opendir("/proc"); - if (dp == NULL) { - return -1; - } - - while ((dentry = readdir(dp)) != NULL) { - if (!isdigit(dentry->d_name[0])) - continue; - - snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name); - ret = __pkgmgr_read_proc(buf, buf, sizeof(buf)); - if (ret <= 0) - continue; - - pid = __pkgmgr_find_pid_by_cmdline(dentry->d_name, buf, apppath); - - if (pid > 0) { - int pgid; - - pgid = getpgid(pid); - if (pgid <= 1) { - closedir(dp); - return -1; - } - - if (killpg(pgid, SIGKILL) < 0) { - closedir(dp); - return -1; - } - } - } - - closedir(dp); - return 0; -} - -static int __sync_process(char *req_key) +static int __sync_process(const char *req_key) { int ret; char info_file[PKG_STRING_LEN_MAX] = {'\0', }; @@ -682,13 +589,17 @@ static int __sync_process(char *req_key) if (access(info_file, F_OK) == 0) { fp = fopen(info_file, "r"); - if (fp == NULL){ + if (fp == NULL) { DBG("file is not generated yet.... wait\n"); usleep(100 * 1000); /* 100ms sleep*/ continue; } - fgets(buf, PKG_STRING_LEN_MAX, fp); + if (fgets(buf, PKG_STRING_LEN_MAX, fp) == NULL) { + ERR("failed to read info file"); + fclose(fp); + break; + } fclose(fp); DBG("info_file file is generated, result = %s. \n", buf); @@ -711,6 +622,7 @@ static int __sync_process(char *req_key) return result; } + static int __csc_process(const char *csc_path, char *result_path) { int ret = 0; @@ -864,7 +776,6 @@ catch: static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data) { char *req_key = NULL; - int req_id = 0; int ret =0; pkgmgrinfo_pkginfo_h handle; char *pkgtype = NULL; @@ -891,7 +802,6 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid, installer_path = _get_backend_path_with_type(pkgtype); req_key = __get_req_key(pkgid); - req_id = _get_request_id(); /* generate argv */ snprintf(buf, 128, "%d", move_type); @@ -952,8 +862,8 @@ catch: static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_client * pc, const char *pkgid, uid_t uid, void *data) { - const char *pkgtype; - char *req_key; + char *pkgtype; + char *req_key = NULL; int ret; pkgmgrinfo_pkginfo_h handle; int pid = -1; @@ -987,7 +897,8 @@ static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_ * (int *) data = pid; catch: - free(req_key); + if (req_key) + free(req_key); pkgmgrinfo_pkginfo_destroy_pkginfo(handle); return ret; @@ -1698,7 +1609,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type, return PKGMGR_R_EINVAL; if (pkg_type == NULL) { - pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid); + pkgtype = _get_pkg_type(pkgid, uid); if (pkgtype == NULL) return PKGMGR_R_EINVAL; } else @@ -1786,13 +1697,6 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type, return req_id; } -API int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type, - const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode, - pkgmgr_handler event_cb, void *data) -{ - return pkgmgr_client_move_usr_pkg(pc, pkg_type, pkgid, GLOBAL_USER, move_type, mode, event_cb, data); -} - API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type, const char *pkgid, uid_t uid, pkgmgr_move_type move_type, pkgmgr_mode mode, pkgmgr_handler event_cb, void *data) @@ -1909,10 +1813,11 @@ catch: return ret; } -API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, - const char *pkgid) +API int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type, + const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode, + pkgmgr_handler event_cb, void *data) { - return pkgmgr_client_usr_activate(pc, pkg_type, pkgid, GLOBAL_USER); + return pkgmgr_client_move_usr_pkg(pc, pkg_type, pkgid, GLOBAL_USER, move_type, mode, event_cb, data); } API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type, @@ -1934,7 +1839,7 @@ API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type, retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX "); if (pkg_type == NULL) { - pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid); + pkgtype = _get_pkg_type(pkgid, uid); retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL"); } else pkgtype = pkg_type; @@ -1954,10 +1859,10 @@ catch: return ret; } -API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, - const char *pkgid) +API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type, + const char *pkgid) { - return pkgmgr_client_usr_deactivate(pc, pkg_type, pkgid, GLOBAL_USER); + return pkgmgr_client_usr_activate(pc, pkg_type, pkgid, GLOBAL_USER); } API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type, @@ -1979,7 +1884,7 @@ API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type, retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX "); if (pkg_type == NULL) { - pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid); + pkgtype = _get_pkg_type(pkgid, uid); if (pkgtype == NULL) return PKGMGR_R_EINVAL; } else @@ -2000,9 +1905,10 @@ catch: return ret; } -API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid) +API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type, + const char *pkgid) { - return pkgmgr_client_usr_activate_app(pc,appid, GLOBAL_USER); + return pkgmgr_client_usr_deactivate(pc, pkg_type, pkgid, GLOBAL_USER); } API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, uid_t uid) @@ -2022,7 +1928,7 @@ API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, ui retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL"); retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX "); - pkgtype = _get_pkg_type_from_desktop_file(appid, uid); + pkgtype = _get_pkg_type(appid, uid); retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL"); /* 2. generate req_key */ @@ -2040,9 +1946,9 @@ catch: return ret; } -API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[]) +API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid) { - return pkgmgr_client_usr_activate_appv(pc, appid, argv, GLOBAL_USER); + return pkgmgr_client_usr_activate_app(pc,appid, GLOBAL_USER); } API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[], uid_t uid) @@ -2068,7 +1974,7 @@ API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, c retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL"); retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX "); - pkgtype = _get_pkg_type_from_desktop_file(appid, uid); + pkgtype = _get_pkg_type(appid, uid); retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL"); /* 2. generate req_key */ @@ -2125,10 +2031,9 @@ catch: return ret; } - -API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid) +API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[]) { - return pkgmgr_client_usr_deactivate_app(pc, appid, GLOBAL_USER); + return pkgmgr_client_usr_activate_appv(pc, appid, argv, GLOBAL_USER); } API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, uid_t uid) @@ -2148,7 +2053,7 @@ API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, u retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL"); retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX "); - pkgtype = _get_pkg_type_from_desktop_file(appid, uid); + pkgtype = _get_pkg_type(appid, uid); retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL"); /* 2. generate req_key */ @@ -2166,11 +2071,11 @@ catch: return ret; } -API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type, - const char *appid, pkgmgr_mode mode) +API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid) { - return pkgmgr_client_usr_clear_user_data(pc, pkg_type, appid,mode, GLOBAL_USER); + return pkgmgr_client_usr_deactivate_app(pc, appid, GLOBAL_USER); } + API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_type, const char *appid, pkgmgr_mode mode, uid_t uid) { @@ -2202,7 +2107,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ if (pkg_type == NULL) { - pkgtype = _get_pkg_type_from_desktop_file(appid, uid); + pkgtype = _get_pkg_type(appid, uid); if (pkgtype == NULL) return PKGMGR_R_EINVAL; } else @@ -2281,6 +2186,11 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ return PKGMGR_R_OK; } +API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type, + const char *appid, pkgmgr_mode mode) +{ + return pkgmgr_client_usr_clear_user_data(pc, pkg_type, appid,mode, GLOBAL_USER); +} API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type) { @@ -2385,27 +2295,6 @@ API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type, return PKGMGR_R_OK; } -API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path) -{ - return pkgmgr_info_new_from_file(NULL, pkg_path); -} - -API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info) -{ - if (pkg_info == NULL) - return PKGMGR_R_EINVAL; - - package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info; - - if (info->icon_buf) - free(info->icon_buf); - - free(info); - info = NULL; - - return PKGMGR_R_OK; -} - API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode, pkgmgr_client * pc, const char *pkg_type, const char *pkgid, const char *custom_info, pkgmgr_handler event_cb, void *data) @@ -2687,221 +2576,5 @@ API int pkgmgr_client_usr_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_ API int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb event_cb, void *user_data) { - return pkgmgr_client_usr_get_package_size_info(pc, PKG_SIZE_INFO_TOTAL, event_cb, user_data, GLOBAL_USER); -} - -#define __START_OF_OLD_API -ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data) -{ - char *type; - char *package; - char *version; - - iter_data *udata = (iter_data *) user_data; - - ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type); - if (type == NULL) - type = ""; - ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package); - if (package == NULL) - package = ""; - ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version); - if (version == NULL) - version = ""; - - if (udata->iter_fn(type, package, version, udata->data) != 0) - return AIL_CB_RET_CANCEL; - - return AIL_CB_RET_CONTINUE; -} - -API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid) -{ - int cnt = -1; - ail_filter_h filter; - ail_error_e ret; - - if (iter_fn == NULL) - return PKGMGR_R_EINVAL; - - ret = ail_filter_new(&filter); - if (ret != AIL_ERROR_OK) { - return PKGMGR_R_ERROR; - } - - ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application"); - if (ret != AIL_ERROR_OK) { - ail_filter_destroy(filter); - return PKGMGR_R_ERROR; - } - - ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true); - if (ret != AIL_ERROR_OK) { - ail_filter_destroy(filter); - return PKGMGR_R_ERROR; - } - - if(uid != GLOBAL_USER) - ret = ail_filter_count_usr_appinfo(filter, &cnt, uid); - else - ret = ail_filter_count_appinfo(filter, &cnt); - if (ret != AIL_ERROR_OK) { - ail_filter_destroy(filter); - return PKGMGR_R_ERROR; - } - - iter_data *udata = calloc(1, sizeof(iter_data)); - if (udata == NULL) { - ERR("calloc failed"); - ail_filter_destroy(filter); - - return PKGMGR_R_ERROR; - } - udata->iter_fn = iter_fn; - udata->data = data; - - if(uid != GLOBAL_USER) - ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, udata, uid); - else - ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata); - free(udata); - - ret = ail_filter_destroy(filter); - if (ret != AIL_ERROR_OK) { - return PKGMGR_R_ERROR; - } - - return PKGMGR_R_OK; -} - -API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid) -{ - return pkgmgr_info_usr_new(pkg_type, pkgid, GLOBAL_USER); -} -API pkgmgr_info *pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, uid_t uid) -{ - const char *pkgtype; - pkg_plugin_set *plugin_set = NULL; - package_manager_pkg_detail_info_t *pkg_detail_info = NULL; - - /* 1. check argument */ - if (pkgid == NULL) - return NULL; - - if (pkg_type == NULL) { - pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid); - if (pkgtype == NULL) - return NULL; - } else - pkgtype = pkg_type; - - if (strlen(pkgid) >= PKG_STRING_LEN_MAX) - return NULL; - - pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t)); - if (pkg_detail_info == NULL) { - ERR("*** Failed to alloc package_handler_info.\n"); - return NULL; - } - - plugin_set = _package_manager_load_library(pkgtype); - if (plugin_set == NULL) { - ERR("*** Failed to load library"); - free(pkg_detail_info); - return NULL; - } - - if (plugin_set->pkg_is_installed) { - if (plugin_set->pkg_is_installed(pkgid) != 0) { - ERR("*** Failed to call pkg_is_installed()"); - free(pkg_detail_info); - return NULL; - } - - if (plugin_set->get_pkg_detail_info) { - if (plugin_set->get_pkg_detail_info(pkgid, - pkg_detail_info) != 0) { - ERR("*** Failed to call get_pkg_detail_info()"); - free(pkg_detail_info); - return NULL; - } - } - } - - return (pkgmgr_info *) pkg_detail_info; -} - -API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key) -{ - package_manager_pkg_detail_info_t *pkg_detail_info; - - if (pkg_info == NULL) - return NULL; - if (key == NULL) - return NULL; - - pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info; - - return _get_info_string(key, pkg_detail_info); -} - -API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type, - const char *pkg_path) -{ - pkg_plugin_set *plugin_set = NULL; - package_manager_pkg_detail_info_t *pkg_detail_info = NULL; - char *pkgtype; - if (pkg_path == NULL) { - ERR("pkg_path is NULL\n"); - return NULL; - } - - if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) { - ERR("length of pkg_path is too long - %d.\n", - strlen(pkg_path)); - return NULL; - } - - pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t)); - if (pkg_detail_info == NULL) { - ERR("*** Failed to alloc package_handler_info.\n"); - return NULL; - } - - if (pkg_type == NULL) - pkgtype = __get_type_from_path(pkg_path); - else - pkgtype = strdup(pkg_type); - - plugin_set = _package_manager_load_library(pkgtype); - if (plugin_set == NULL) { - free(pkg_detail_info); - free(pkgtype); - return NULL; - } - - if (plugin_set->get_pkg_detail_info_from_package) { - if (plugin_set->get_pkg_detail_info_from_package(pkg_path, - pkg_detail_info) != 0) { - free(pkg_detail_info); - free(pkgtype); - return NULL; - } - } - - free(pkgtype); - return (pkgmgr_info *) pkg_detail_info; -} - -API int pkgmgr_info_free(pkgmgr_info * pkg_info) -{ - if (pkg_info == NULL) - return PKGMGR_R_EINVAL; - - free(pkg_info); - pkg_info = NULL; - - return 0; + return pkgmgr_client_usr_get_package_size_info(pc, PKG_SIZE_INFO_TOTAL, (pkgmgr_pkg_size_info_receive_cb)event_cb, user_data, GLOBAL_USER); } - -#define __END_OF_OLD_API diff --git a/comm/comm_client_gdbus.c b/comm/comm_client_gdbus.c index bf9f9dd..6d9503b 100644 --- a/comm/comm_client_gdbus.c +++ b/comm/comm_client_gdbus.c @@ -67,7 +67,7 @@ static int __retry_request(comm_client *cc, const gchar *args, uid_t uid, gint *ret) -{ +{ OrgTizenSlpPkgmgr *proxy; GError *error = NULL; int rc = 0; @@ -82,7 +82,7 @@ static int __retry_request(comm_client *cc, } rc = org_tizen_slp_pkgmgr_call_request_sync(proxy, - req_id, req_type, pkg_type, pkgid, args, uid, &ret, NULL, &error); + req_id, req_type, pkg_type, pkgid, args, uid, ret, NULL, &error); if (!rc) { ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message); return FALSE; @@ -211,7 +211,9 @@ comm_client *comm_client_new(void) comm_client *cc = NULL; /* Allocate memory for ADT:comm_client */ +#if !GLIB_CHECK_VERSION(2,35,0) g_type_init(); +#endif cc = calloc(1, sizeof(comm_client)); if (NULL == cc) { ERR("No memory"); @@ -338,10 +340,10 @@ int comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data) { int r = COMM_RET_ERROR; - char *ifc = NULL; + const char *ifc = NULL; if (NULL == cc) - return NULL; + return COMM_RET_ERROR; ifc = __get_interface(comm_status_type); if (ifc == NULL) { diff --git a/comm/comm_pkg_mgr_server.c b/comm/comm_pkg_mgr_server.c index 8caebb7..78aca13 100644 --- a/comm/comm_pkg_mgr_server.c +++ b/comm/comm_pkg_mgr_server.c @@ -27,6 +27,7 @@ #include "comm_config.h" #include #include +#include #include #include @@ -209,7 +210,8 @@ pkgmgr_request(PkgMgrObject *obj, break; } - r = cynara_creds_dbus_get_user(con, sender, USER_METHOD_DEFAULT, &user); + r = cynara_creds_dbus_get_user(con, sender, + USER_METHOD_DEFAULT, &user); if (r != CYNARA_API_SUCCESS) { cynara_strerror(r, buf, BUFMAX); ERR("cynara_creds_dbus_get_user failed: %s", buf); diff --git a/packaging/pkgmgr.spec b/packaging/pkgmgr.spec index 1518148..4d8e220 100644 --- a/packaging/pkgmgr.spec +++ b/packaging/pkgmgr.spec @@ -27,7 +27,6 @@ BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(iniparser) @@ -35,14 +34,11 @@ BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(security-manager) BuildRequires: pkgconfig(xdgmime) BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(libsmack) BuildRequires: pkgmgr-info-parser-devel BuildRequires: pkgmgr-info-parser -BuildRequires: libsmack BuildRequires: fdupes -## Work around for https://bugs.tizen.org/jira/browse/TC-2399 -BuildRequires: ail-vconf-devel - %description Packager Manager client library package for packaging @@ -129,8 +125,6 @@ chmod 755 %{buildroot}%{_sysconfdir}/package-manager/backend/clearcache mkdir -p %{buildroot}%{_sysconfdir}/package-manager/server -%find_lang package-manager - %fdupes %{buildroot} %post @@ -161,14 +155,8 @@ chsmack -a '*' %{TZ_SYS_RW_PACKAGES} %{_sysconfdir}/package-manager/backend/* %{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh %{_bindir}/pkgcmd -%attr(06755,root,root) %{_bindir}/pkg_createdb -%attr(755,root,root) %{_bindir}/pkg_createdb_user -%attr(06755,root,root) %{_bindir}/pkg_syncdb -%attr(755,root,root) %{_bindir}/pkg_syncdb_user -#obsolete tools %attr(06755,root,root) %{_bindir}/pkg_initdb %attr(755,root,root) %{_sysconfdir}/gumd/useradd.d/10_package-manager-add.post -%attr(755,root,root) %{_bindir}/pkg_initdb_user %{_bindir}/pkg_getsize %{_bindir}/pkg_clearcache %{_bindir}/pkg_privilege @@ -195,7 +183,7 @@ chsmack -a '*' %{TZ_SYS_RW_PACKAGES} %{_libdir}/pkgconfig/pkgmgr.pc %{_libdir}/libpkgmgr-client.so -%files server -f package-manager.lang +%files server %manifest %{name}-server.manifest %defattr(-,root,root,-) %{_datadir}/dbus-1/system-services/org.tizen.slp.pkgmgr.service diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index a146fa4..e9b5843 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -6,7 +6,6 @@ SET(SRCS src/pkgmgr-server.c src/pm-queue.c) pkg_check_modules(SERVER_DEPS REQUIRED cynara-client dlog - ail pkgmgr-parser pkgmgr-info libtzplatform-config) @@ -27,5 +26,3 @@ INSTALL(TARGETS ${PKGMGR_SERVER} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/queue_status DESTINATION ${SYSCONFDIR}/package-manager/server/) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.slp.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/system-services/) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.slp.pkgmgr.conf DESTINATION ${SYSCONFDIR}/dbus-1/system.d/) - -ADD_SUBDIRECTORY(po) diff --git a/server/po/CMakeLists.txt b/server/po/CMakeLists.txt deleted file mode 100644 index e3aebb4..0000000 --- a/server/po/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# for i18n - -SET(POFILES en_US.po en_GB.po ja_JP.po ko_KR.po zh_CN.po) - -SET(MSGFMT "/usr/bin/msgfmt") - -FOREACH(pofile ${POFILES}) - SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}) - MESSAGE("PO: ${pofile}") - GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE) - GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE) - SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo) - ADD_CUSTOM_COMMAND( - OUTPUT ${moFile} - COMMAND ${MSGFMT} -o ${moFile} ${absPofile} - DEPENDS ${absPofile} - ) - INSTALL(FILES ${moFile} - DESTINATION share/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo) - SET(moFiles ${moFiles} ${moFile}) -ENDFOREACH(pofile) - -MESSAGE(".mo files: ${moFiles}") -ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles}) diff --git a/server/po/POTFILES.in b/server/po/POTFILES.in deleted file mode 100644 index 110dfd2..0000000 --- a/server/po/POTFILES.in +++ /dev/null @@ -1,2 +0,0 @@ -# List of source files containing translatable strings. -src/pkgmgr-server.c diff --git a/server/po/en_GB.po b/server/po/en_GB.po deleted file mode 100644 index af3f93a..0000000 --- a/server/po/en_GB.po +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "" diff --git a/server/po/en_US.po b/server/po/en_US.po deleted file mode 100644 index af3f93a..0000000 --- a/server/po/en_US.po +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "" diff --git a/server/po/ja_JP.po b/server/po/ja_JP.po deleted file mode 100644 index 1d5f6e0..0000000 --- a/server/po/ja_JP.po +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "インストールしますか?" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "アンインストールしますか?" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "無効なリクエストです" diff --git a/server/po/ko_KR.po b/server/po/ko_KR.po deleted file mode 100644 index 3850a70..0000000 --- a/server/po/ko_KR.po +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "설치할까요?" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "삭제할까요?" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "요청이 바르지 않습니다" diff --git a/server/po/package-manager.pot b/server/po/package-manager.pot deleted file mode 100644 index e9f371b..0000000 --- a/server/po/package-manager.pot +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "" diff --git a/server/po/update-po.sh b/server/po/update-po.sh deleted file mode 100755 index 16fbdc1..0000000 --- a/server/po/update-po.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh - -PACKAGE=package-manager -SRCROOT=.. -POTFILES=POTFILES.in - -#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW -ALL_LINGUAS="en_US en_GB ja_JP ko_KR zh_CN" - -XGETTEXT=/usr/bin/xgettext -MSGMERGE=/usr/bin/msgmerge - -echo -n "Make ${PACKAGE}.pot " -if [ ! -e $POTFILES ] ; then - echo "$POTFILES not found" - exit 1 -fi - -$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \ - --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES -if [ $? -ne 0 ]; then - echo "xgettext error" - exit 1 -fi - -if [ ! -f ${PACKAGE}.po ]; then - echo "No such file: ${PACKAGE}.po" - exit 1 -fi - -rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot -echo "done" - -for LANG in $ALL_LINGUAS; do - echo "$LANG : " - - if [ ! -e $LANG.po ] ; then - sed 's/CHARSET/UTF-8/g' ${PACKAGE}.pot > ${LANG}.po - echo "${LANG}.po created" - else - if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then - if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then - rm -f ${LANG}.new.po - else - if mv -f ${LANG}.new.po ${LANG}.po; then - echo "" - else - echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2 - rm -f ${LANG}.new.po - exit 1 - fi - fi - else - echo "msgmerge for $LANG failed!" - rm -f ${LANG}.new.po - fi - fi - echo "" -done - diff --git a/server/po/zh_CN.po b/server/po/zh_CN.po deleted file mode 100644 index af3f93a..0000000 --- a/server/po/zh_CN.po +++ /dev/null @@ -1,32 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-14 19:06+0900\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: server/src/pkgmgr-server.c:251 -#, c-format -msgid "Install?" -msgstr "" - -#: server/src/pkgmgr-server.c:287 -#, c-format -msgid "Uninstall?" -msgstr "" - -#: server/src/pkgmgr-server.c:290 -#, c-format -msgid "Invalid request" -msgstr "" diff --git a/server/src/pkgmgr-server.c b/server/src/pkgmgr-server.c index 40d9022..cf04269 100644 --- a/server/src/pkgmgr-server.c +++ b/server/src/pkgmgr-server.c @@ -23,22 +23,22 @@ #include #include #include +#include #include +#include #include #include #include #include #include #include -#include #include -#include + +#include + #include #include - #include - -/* For multi-user support */ #include #include "pkgmgr_installer.h" @@ -51,6 +51,9 @@ #define BUFMAX 128 #define NO_MATCHING_FILE 11 +#define OWNER_ROOT 0 +#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) + static int backend_flag = 0; /* 0 means that backend process is not running */ typedef struct { @@ -107,13 +110,11 @@ typedef enum { PMSVC_SVC_APP }pkgmgr_svc_app_component; -static int __check_backend_status_for_exit(); -static int __check_queue_status_for_exit(); -static int __check_backend_mode(); +static int __check_backend_status_for_exit(void); +static int __check_queue_status_for_exit(void); static int __is_backend_busy(int position); static void __set_backend_busy(int position); static void __set_backend_free(int position); -static int __is_backend_mode_quiet(int position); static void __set_backend_mode(int position); static void __unset_backend_mode(int position); static void sighandler(int signo); @@ -139,11 +140,6 @@ static void __set_backend_free(int position) { backend_busy = backend_busy & ~(1<gid); - setuid(ctx->uid); + return -1;; + if (setgid(ctx->gid)) { + ERR("setgid failed: %d", errno); + return -1; + } + if (setuid(ctx->uid)) { + ERR("setuid failed: %d", errno); + return -1; + } env = ctx->env; //env variable ends by NULL element while (env[i]) { - if( putenv(env[i]) != 0 ) + if (putenv(env[i]) != 0) res = -1; i++; } @@ -1045,7 +967,7 @@ user_ctx* get_user_context(uid_t uid) * returned by getpwuid */ user_ctx *context_res; - char ** env; + char **env = NULL; struct passwd * pwd; int len; int ret = 0; @@ -1084,7 +1006,7 @@ user_ctx* get_user_context(uid_t uid) env[2] = NULL; } while (0); - if(ret == -1) { + if (ret == -1) { free(context_res); context_res = NULL; int i = 0; @@ -1310,26 +1232,8 @@ gboolean queue_job(void *data) perror("fail to activate/deactivte package"); exit(1); } - - ret = ail_desktop_appinfo_modify_usr_str(item->pkgid, - item->uid, - AIL_PROP_NAME_STR, - label, FALSE); - if (ret != AIL_ERROR_OK) { - perror("fail to activate/deactivte package"); - exit(1); - } free(label); } - - ret = ail_desktop_appinfo_modify_usr_bool(item->pkgid, - item->uid, - AIL_PROP_X_SLP_ENABLED_BOOL, - val, TRUE); - if (ret != AIL_ERROR_OK) { - perror("fail to activate/deactivte package"); - exit(1); - } } else { /* in case of package */ ERR("(De)activate PKG[pkgid=%s, val=%d]", item->pkgid, val); char *manifest = NULL; @@ -1348,11 +1252,6 @@ gboolean queue_job(void *data) if (ret < 0) { ERR("insert in db failed\n"); } - - ret = ail_usr_desktop_add(item->pkgid, item->uid); - if (ret != AIL_ERROR_OK) { - ERR("fail to ail_desktop_add"); - } } else { pkgmgrinfo_pkginfo_destroy_pkginfo(handle); } @@ -1362,15 +1261,6 @@ gboolean queue_job(void *data) perror("fail to activate/deactivte package"); exit(1); } - - ret = ail_desktop_appinfo_modify_usr_bool(item->pkgid, - item->uid, - AIL_PROP_X_SLP_ENABLED_BOOL, - val, TRUE); - if (ret != AIL_ERROR_OK) { - perror("fail to ail_desktop_appinfo"); - exit(1); - } } else ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, item->uid, NULL); @@ -1535,48 +1425,44 @@ int main(int argc, char *argv[]) DBG("server start"); - if (argv[1]) { - if (strcmp(argv[1], "init") == 0) { - /* if current status is "processing", - execute related backend with '-r' option */ - if (!(fp_status = fopen(STATUS_FILE, "r"))) - return 0; /*if file is not exist, terminated. */ - - fgets(buf, 32, fp_status); - /* if processing <-- unintended termination */ - if (strcmp(buf, "processing") == 0) { - pid = fork(); - - if (pid == 0) { /* child */ - fgets(buf, 32, fp_status); + if (argv[1] && (strcmp(argv[1], "init") == 0)) { + /* if current status is "processing", + execute related backend with '-r' option */ + if (!(fp_status = fopen(STATUS_FILE, "r"))) + return 0; /*if file is not exist, terminated. */ + /* if processing <-- unintended termination */ + if (fgets(buf, 32, fp_status) && + strcmp(buf, "processing") == 0) { + pid = fork(); + if (pid == 0) { /* child */ + if (fgets(buf, 32, fp_status)) backend_cmd = _get_backend_cmd(buf); - if (!backend_cmd) { /* if NULL, */ - DBG("fail to get" - " backend command"); - goto err; - } - backend_name = - strrchr(backend_cmd, '/'); - - execl(backend_cmd, backend_name, "-r", - NULL); - if (backend_cmd) - free(backend_cmd); - fprintf(fp_status, " "); - err: - fclose(fp_status); - exit(13); - } else if (pid < 0) { /* error */ - DBG("fork fail"); - fclose(fp_status); - return 0; - } else { /* parent */ - - DBG("parent end\n"); - fprintf(fp_status, " "); - fclose(fp_status); - return 0; + if (!backend_cmd) { /* if NULL, */ + DBG("fail to get" + " backend command"); + goto err; } + backend_name = + strrchr(backend_cmd, '/'); + + execl(backend_cmd, backend_name, "-r", + NULL); + if (backend_cmd) + free(backend_cmd); + fprintf(fp_status, " "); +err: + fclose(fp_status); + exit(13); + } else if (pid < 0) { /* error */ + DBG("fork fail"); + fclose(fp_status); + return 0; + } else { /* parent */ + + DBG("parent end\n"); + fprintf(fp_status, " "); + fclose(fp_status); + return 0; } } } @@ -1599,7 +1485,9 @@ int main(int argc, char *argv[]) return -1; } +#if !GLIB_CHECK_VERSION(2,35,0) g_type_init(); +#endif mainloop = g_main_loop_new(NULL, FALSE); if (!mainloop) { ERR("g_main_loop_new failed"); diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index a438096..aca28ff 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt @@ -6,13 +6,12 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs_initdb REQUIRED libsmack dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf pkgmgr-info libtzplatform-config) +pkg_check_modules(pkgs_initdb REQUIRED libsmack dbus-1 libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config) FOREACH(flag ${pkgs_initdb_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) - -pkg_check_modules(pkgs_test REQUIRED dbus-1 ail libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config security-manager) +pkg_check_modules(pkgs_test REQUIRED dlog dbus-1 libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config security-manager) FOREACH(flag ${pkgs_test_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) @@ -24,62 +23,37 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") -add_executable(pkgcmd - pkg_cmd.c) -target_link_libraries(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS}) +ADD_EXECUTABLE(pkgcmd pkg_cmd.c) +TARGET_LINK_LIBRARIES(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkgcmd DESTINATION bin) -add_executable(pkginfo - pkg_info.c) -target_link_libraries(pkginfo pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS}) +ADD_EXECUTABLE(pkginfo pkg_info.c) +TARGET_LINK_LIBRARIES(pkginfo pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkginfo DESTINATION bin) -add_executable(pkg_privilege - pkg_privilege.c) -target_link_libraries(pkg_privilege ${pkgs_test_LDFLAGS}) +ADD_EXECUTABLE(pkg_privilege pkg_privilege.c) +TARGET_LINK_LIBRARIES(pkg_privilege ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkg_privilege DESTINATION bin) -add_executable(pkg_install_ug - pkg_install_ug.c) -target_link_libraries(pkg_install_ug ${pkgs_test_LDFLAGS}) +ADD_EXECUTABLE(pkg_install_ug pkg_install_ug.c) +TARGET_LINK_LIBRARIES(pkg_install_ug ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkg_install_ug DESTINATION bin) -add_executable(pkg_getsize - pkg_getsize.c) -target_link_libraries(pkg_getsize pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS}) +ADD_EXECUTABLE(pkg_getsize pkg_getsize.c) +TARGET_LINK_LIBRARIES(pkg_getsize pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS}) INSTALL(TARGETS pkg_getsize DESTINATION bin) -add_executable(pkg_createdb pkg_createdb.c) -target_link_libraries(pkg_createdb ${pkgs_initdb_LDFLAGS}) -INSTALL(TARGETS pkg_createdb DESTINATION bin) - -add_executable(pkg_createdb_user pkg_createdb_user.c) -target_link_libraries(pkg_createdb_user ${pkgs_initdb_LDFLAGS}) -INSTALL(TARGETS pkg_createdb_user DESTINATION bin) - -add_executable(pkg_syncdb pkg_syncdb.c) -target_link_libraries(pkg_syncdb ${pkgs_initdb_LDFLAGS}) -INSTALL(TARGETS pkg_syncdb DESTINATION bin) +ADD_EXECUTABLE(pkg_clearcache pkg_clearcache.c) +TARGET_LINK_LIBRARIES(pkg_clearcache ${pkgs_test_LDFLAGS}) +INSTALL(TARGETS pkg_clearcache DESTINATION bin) -add_executable(pkg_syncdb_user pkg_syncdb_user.c) -target_link_libraries(pkg_syncdb_user ${pkgs_initdb_LDFLAGS}) -INSTALL(TARGETS pkg_syncdb_user DESTINATION bin) - -add_executable(pkg_clearcache pkg_clearcache.c) -target_link_libraries(pkg_clearcache ${pkgs_test_LDFLAGS}) -install(TARGETS pkg_clearcache DESTINATION bin) - -add_executable(pkg_initdb pkg_initdb.c) -target_link_libraries(pkg_initdb ${pkgs_initdb_LDFLAGS}) +ADD_EXECUTABLE(pkg_initdb pkg_initdb.c) +TARGET_LINK_LIBRARIES(pkg_initdb ${pkgs_initdb_LDFLAGS}) INSTALL(TARGETS pkg_initdb DESTINATION bin) INSTALL(FILES 10_package-manager-add.post DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/) -add_executable(pkg_initdb_user pkg_initdb_user.c) -target_link_libraries(pkg_initdb_user ${pkgs_initdb_LDFLAGS}) -INSTALL(TARGETS pkg_initdb_user DESTINATION bin) - -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/) -configure_file(pkgmgr.patch.sh.in pkgmgr.patch.sh @ONLY) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr.patch.sh DESTINATION ${SYSCONFDIR}/opt/upgrade/) +CONFIGURE_FILE(pkgmgr.patch.sh.in pkgmgr.patch.sh @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr.patch.sh DESTINATION ${SYSCONFDIR}/opt/upgrade/) diff --git a/tool/pkg_cmd.c b/tool/pkg_cmd.c index 9ebdc07..19c474c 100644 --- a/tool/pkg_cmd.c +++ b/tool/pkg_cmd.c @@ -33,12 +33,12 @@ #include #include #include +#include #include #include #include -#include #include /* For multi-user support */ #include @@ -50,10 +50,12 @@ #define APP_INSTALLATION_PATH_RW tzplatform_getenv(TZ_USER_APP) #define MAX_QUERY_LEN 4096 +#define OWNER_ROOT 0 +#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) + static int __process_request(uid_t uid); static void __print_usage(); static int __is_app_installed(char *pkgid, uid_t uid); -static void __print_pkg_info(pkgmgr_info * pkg_info); static int __return_cb(uid_t target_uid, int req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val, const void *pmsg, void *data); @@ -199,17 +201,16 @@ static int __return_cb(uid_t target_uid, int req_id, const char *pkg_type, const char *pkgid, const char *key, const char *val, const void *pmsg, void *priv_data) { - if (strncmp(key, "error", strlen("error")) == 0) { - int ret_val; - char delims[] = ":"; - char *extra_str = NULL; - char *ret_result = NULL; + int ret_val; + char delims[] = ":"; + char *extra_str = NULL; + char *ret_result = NULL; + if (strncmp(key, "error", strlen("error")) == 0) { ret_val = atoi(val); data.result = ret_val; - strtok(val, delims); - ret_result = strtok(NULL, delims); + ret_result = strstr((char *)val, delims); if (ret_result){ extra_str = strdup(ret_result); printf("__return_cb req_id[%d] pkg_type[%s] pkgid[%s] key[%s] val[%d] error message: %s\n", @@ -245,8 +246,7 @@ static int __convert_to_absolute_path(char *path) } strncpy(temp, path, PKG_NAME_STRING_LEN_MAX - 1); if (strchr(path, '/') == NULL) { - getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1); - if (abs[0] == '\0') { + if (getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1) == NULL) { printf("getcwd() failed\n"); return -1; } @@ -256,8 +256,7 @@ static int __convert_to_absolute_path(char *path) } if (strncmp(path, "./", 2) == 0) { ptr = temp; - getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1); - if (abs[0] == '\0') { + if (getcwd(abs, PKG_NAME_STRING_LEN_MAX - 1) == NULL) { printf("getcwd() failed\n"); return -1; } @@ -340,108 +339,6 @@ static void __print_usage() } -static void __print_pkg_info(pkgmgr_info *pkg_info) -{ - char *temp = NULL; - - temp = pkgmgr_info_get_string(pkg_info, "pkg_type"); - if (temp) { - printf("pkg_type : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "pkgid"); - if (temp) { - printf("pkgid : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "version"); - if (temp) { - printf("version : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "pkg_vendor"); - if (temp) { - printf("pkg_vendor : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "pkg_description"); - if (temp) { - printf("pkg_description : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "pkg_mimetype"); - if (temp) { - printf("pkg_mimetype : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "pkg_installed_path_package"); - if (temp) { - printf("pkg_installed_path_package : %s\n", temp); - free(temp); - } - - temp = - pkgmgr_info_get_string(pkg_info, "pkg_installed_path_descriptor"); - if (temp) { - printf("pkg_installed_path_descriptor : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "category"); - if (temp) { - printf("category : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "min_platform_version"); - if (temp) { - printf("min_platform_version : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "visible"); - if (temp) { - printf("visible : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "removable"); - if (temp) { - printf("removable : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "installed_size"); - if (temp) { - printf("installed_size : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "installed_time"); - if (temp) { - printf("installed_time : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "data_size"); - if (temp) { - printf("data_size : %s\n", temp); - free(temp); - } - - temp = pkgmgr_info_get_string(pkg_info, "optional_id"); - if (temp) { - printf("optional_id : %s\n", temp); - free(temp); - } -} - static int __pkgmgr_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data) { int ret = -1; @@ -449,11 +346,8 @@ static int __pkgmgr_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data) char *pkg_type = NULL; char *pkg_version = NULL; char *pkg_label = NULL; - char *icon_path = NULL; bool for_all_users = 0; - pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle; - ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); if (ret == -1) { printf("Failed to get pkgmgrinfo_pkginfo_get_pkgid\n"); @@ -483,10 +377,9 @@ static int __pkgmgr_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data) return ret; } -static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data, uid_t uid) +static int __pkg_list_cb(const pkgmgrinfo_pkginfo_h handle, void *user_data) { int ret = -1; - int size = 0; char *pkgid; pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle; @@ -514,6 +407,9 @@ static int __process_request(uid_t uid) pkgmgr_client *pc = NULL; char buf[1024] = {'\0'}; int pid = -1; +#if !GLIB_CHECK_VERSION(2,35,0) + g_type_init(); +#endif switch (data.request) { case INSTALL_REQ: if (data.pkg_type[0] == '\0' || data.pkg_path[0] == '\0') { @@ -522,7 +418,6 @@ static int __process_request(uid_t uid) data.result = PKGCMD_ERR_ARGUMENT_INVALID; break; } - g_type_init(); main_loop = g_main_loop_new(NULL, FALSE); pc = pkgmgr_client_new(PC_REQUEST); if (pc == NULL) { @@ -560,7 +455,6 @@ static int __process_request(uid_t uid) data.result = PKGCMD_ERR_ARGUMENT_INVALID; break; } - g_type_init(); main_loop = g_main_loop_new(NULL, FALSE); pc = pkgmgr_client_new(PC_REQUEST); if (pc == NULL) { @@ -595,7 +489,6 @@ static int __process_request(uid_t uid) data.result = PKGCMD_ERR_ARGUMENT_INVALID; break; } - g_type_init(); main_loop = g_main_loop_new(NULL, FALSE); pc = pkgmgr_client_new(PC_REQUEST); if (pc == NULL) { @@ -791,7 +684,7 @@ static int __process_request(uid_t uid) } if (data.request == KILLAPP_REQ) { - ret = pkgmgr_client_usr_request_service(PM_REQUEST_KILL_APP, NULL, pc, NULL, data.pkgid, uid, NULL, NULL, &pid); + ret = pkgmgr_client_usr_request_service(PM_REQUEST_KILL_APP, 0, pc, NULL, data.pkgid, uid, NULL, NULL, &pid); if (ret < 0){ data.result = PKGCMD_ERR_FATAL_ERROR; break; @@ -802,7 +695,7 @@ static int __process_request(uid_t uid) printf("Pkgid: %s is already Terminated\n", data.pkgid); } else if (data.request == CHECKAPP_REQ) { - ret = pkgmgr_client_usr_request_service(PM_REQUEST_CHECK_APP, NULL, pc, NULL, data.pkgid, uid, NULL, NULL, &pid); + ret = pkgmgr_client_usr_request_service(PM_REQUEST_CHECK_APP, 0, pc, NULL, data.pkgid, uid, NULL, NULL, &pid); if (ret < 0){ data.result = PKGCMD_ERR_FATAL_ERROR; break; @@ -852,52 +745,7 @@ static int __process_request(uid_t uid) } case SHOW_REQ: - if (data.pkgid[0] != '\0') { - pkgmgr_info *pkg_info = NULL; - pkgmgr_info *pkg_info_GLobal = NULL; - - if(uid != GLOBAL_USER) { - pkg_info = - pkgmgr_info_usr_new(data.pkg_type, data.pkgid, uid); - if ( pkg_info == NULL ) { - printf("Failed to get pkginfo handle in USER Apps, try in SYSTEM Apps\n"); - ret = -1; - } else { - printf("USER APPS \n"); - __print_pkg_info(pkg_info); - ret = pkgmgr_info_free(pkg_info); - break; - } - } - pkg_info_GLobal = - pkgmgr_info_new(data.pkg_type, data.pkgid); - if ( pkg_info_GLobal == NULL ) { - printf("Failed to get pkginfo handle\n"); - ret = -1; - break; - } - - printf("GLOBAL APPS \n"); - __print_pkg_info(pkg_info_GLobal); - if(pkg_info_GLobal) - ret = pkgmgr_info_free(pkg_info_GLobal); - - break; - } - if (data.pkg_path[0] != '\0') { - pkgmgr_info *pkg_info = - pkgmgr_info_new_from_file(data.pkg_type, - data.pkg_path); - if (pkg_info == NULL) { - printf("Failed to get pkginfo handle\n"); - ret = -1; - break; - } - __print_pkg_info(pkg_info); - ret = pkgmgr_info_free(pkg_info); - break; - } - printf("Either pkgid or pkgpath should be supplied\n"); + /* unsupported */ ret = -1; break; diff --git a/tool/pkg_createdb.c b/tool/pkg_createdb.c deleted file mode 100644 index 69ef8c2..0000000 --- a/tool/pkg_createdb.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * slp-pkgmgr - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * Copyright (C) 2013-2014 Intel Corporation. - * - * Contact: Sabera Djelti , - * Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 -#define BUFSZE 1024 -#define SYS_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES) -#define PACKAGE_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db") -#define PACKAGE_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal") - - -#define PKG_CERT_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db") -#define PKG_CERT_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db-journal") -#define PKG_INFO_DB_LABEL "*" -#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) - -#define QUERY_CREATE_TABLE_PARSER "create table if not exists package_info " \ - "(package text primary key not null, " \ - "package_type text DEFAULT 'rpm', " \ - "package_version text, " \ - "install_location text, " \ - "package_size text, " \ - "package_removable text DEFAULT 'true', " \ - "package_preload text DEFAULT 'false', " \ - "package_readonly text DEFAULT 'false', " \ - "package_update text DEFAULT 'false', " \ - "package_appsetting text DEFAULT 'false', " \ - "package_nodisplay text DEFAULT 'false', " \ - "package_system text DEFAULT 'false', " \ - "author_name text, " \ - "author_email text, " \ - "author_href text," \ - "installed_time text," \ - "installed_storage text," \ - "storeclient_id text," \ - "mainapp_id text," \ - "package_url text," \ - "root_path text," \ - "csc_path text );" \ - "create table if not exists package_localized_info " \ - "(package text not null, " \ - "package_locale text DEFAULT 'No Locale', " \ - "package_label text, " \ - "package_icon text, " \ - "package_description text, " \ - "package_license text, " \ - "package_author, " \ - "PRIMARY KEY(package, package_locale), " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_privilege_info " \ - "(package text not null, " \ - "privilege text not null, " \ - "PRIMARY KEY(package, privilege) " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_info " \ - "(app_id text primary key not null, " \ - "app_component text, " \ - "app_exec text, " \ - "app_nodisplay text DEFAULT 'false', " \ - "app_type text, " \ - "app_onboot text DEFAULT 'false', " \ - "app_multiple text DEFAULT 'false', " \ - "app_autorestart text DEFAULT 'false', " \ - "app_taskmanage text DEFAULT 'false', " \ - "app_enabled text DEFAULT 'true', " \ - "app_hwacceleration text DEFAULT 'use-system-setting', " \ - "app_screenreader text DEFAULT 'use-system-setting', " \ - "app_mainapp text, " \ - "app_recentimage text, " \ - "app_launchcondition text, " \ - "app_indicatordisplay text DEFAULT 'true', " \ - "app_portraitimg text, " \ - "app_landscapeimg text, " \ - "app_guestmodevisibility text DEFAULT 'true', " \ - "app_permissiontype text DEFAULT 'normal', " \ - "app_preload text DEFAULT 'false', " \ - "app_submode text DEFAULT 'false', " \ - "app_submode_mainid text, " \ - "component_type text, " \ - "package text not null, " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_localized_info " \ - "(app_id text not null, " \ - "app_locale text DEFAULT 'No Locale', " \ - "app_label text, " \ - "app_icon text, " \ - "PRIMARY KEY(app_id,app_locale) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_icon_section_info " \ - "(app_id text not null, " \ - "app_icon text, " \ - "app_icon_section text, " \ - "app_icon_resolution text, " \ - "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_image_info " \ - "(app_id text not null, " \ - "app_locale text DEFAULT 'No Locale', " \ - "app_image_section text, " \ - "app_image text, " \ - "PRIMARY KEY(app_id,app_image_section) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_control " \ - "(app_id text not null, " \ - "operation text not null, " \ - "uri_scheme text, " \ - "mime_type text, " \ - "subapp_name text, " \ - "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_svc " \ - "(app_id text not null, " \ - "operation text not null, " \ - "uri_scheme text, " \ - "mime_type text, " \ - "subapp_name text, " \ - "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_category " \ - "(app_id text not null, " \ - "category text not null, " \ - "PRIMARY KEY(app_id,category) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_metadata " \ - "(app_id text not null, " \ - "md_key text not null, " \ - "md_value text not null, " \ - "PRIMARY KEY(app_id, md_key, md_value) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_permission " \ - "(app_id text not null, " \ - "pm_type text not null, " \ - "pm_value text not null, " \ - "PRIMARY KEY(app_id, pm_type, pm_value) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_share_allowed " \ - "(app_id text not null, " \ - "data_share_path text not null, " \ - "data_share_allowed text not null, " \ - "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_share_request " \ - "(app_id text not null, " \ - "data_share_request text not null, " \ - "PRIMARY KEY(app_id,data_share_request) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE)" - -#define QUERY_CREATE_TABLE_CERT "create table if not exists package_cert_index_info " \ - "(cert_info text not null, " \ - "cert_id integer, " \ - "cert_ref_count integer, " \ - "PRIMARY KEY(cert_id)); " \ - "create table if not exists package_cert_info " \ - "(package text not null, " \ - "author_root_cert integer, " \ - "author_im_cert integer, " \ - "author_signer_cert integer, " \ - "dist_root_cert integer, " \ - "dist_im_cert integer, " \ - "dist_signer_cert integer, " \ - "dist2_root_cert integer, " \ - "dist2_im_cert integer, " \ - "dist2_signer_cert integer, " \ - "PRIMARY KEY(package)) " - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_CREATEDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_CREATEDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#define SET_DEFAULT_LABEL(x) \ - if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \ - else _D("chsmack -a \"*\" %s", x) - - -static int createdb_change_perm(const char *db_file) -{ - char buf[BUFSZE]; - char journal_file[BUFSZE]; - char *files[3]; - int ret, i; - - files[0] = (char *)db_file; - files[1] = journal_file; - files[2] = NULL; - - if(db_file == NULL) - return -1; - - snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal"); - - for (i = 0; files[i]; i++) { - ret = chown(files[i], GLOBAL_USER, OWNER_ROOT); - if (ret == -1) { - strerror_r(errno, buf, sizeof(buf)); - _E("FAIL : chown %s %d.%d, because %s", db_file, GLOBAL_USER, OWNER_ROOT, buf); - return -1; - } - - ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); - if (ret == -1) { - strerror_r(errno, buf, sizeof(buf)); - _E("FAIL : chmod %s 0664, because %s", db_file, buf); - return -1; - } - } - - return 0; -} - -static int __createdb_tables(sqlite3 **db_handle, const char *db_path, char *db_query) -{ - int ret = -1; - - ret = - db_util_open_with_options(db_path, &db_handle, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); - - if (ret != SQLITE_OK) { - _D("connect db [%s] failed!\n", db_path); - sqlite3_close(db_handle); - return -1; - } else { - char *error_message = NULL; - if (SQLITE_OK != - sqlite3_exec(db_handle, db_query, - NULL, NULL, &error_message)) { - _D("Don't execute query = %s error message = %s\n", - db_query, error_message); - sqlite3_free(error_message); - return -1; - } - sqlite3_free(error_message); - } - - return 0; -} - -static int __is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - - uid_t uid = getuid(); - uid_t euid = geteuid(); - //euid need to be root to allow smack label changes during initialization - if ((uid_t) OWNER_ROOT == uid) - return 1; - else - return 0; -} - - -int main(int argc, char *argv[]) -{ - int ret; - sqlite3 *parser_db; - sqlite3 *cert_db; - - if (!__is_authorized()) { - _E("You are not an authorized user!\n"); - return -1; - } else { - if(remove(PACKAGE_INFO_DB_FILE)) - _E(" %s is not removed",PACKAGE_INFO_DB_FILE); - if(remove(PACKAGE_INFO_DB_FILE_JOURNAL)) - _E(" %s is not removed",PACKAGE_INFO_DB_FILE_JOURNAL); - if(remove(PKG_CERT_DB_FILE)) - _E(" %s is not removed",PKG_CERT_DB_FILE); - if(remove(PKG_CERT_DB_FILE_JOURNAL)) - _E(" %s is not removed",PKG_CERT_DB_FILE_JOURNAL); - } - - setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT); - /* This is for AIL initializing */ - ret = setenv("INITDB", "1", 1); - _D("INITDB : %d", ret); - - ret = __createdb_tables(&parser_db, PACKAGE_INFO_DB_FILE, QUERY_CREATE_TABLE_PARSER); - _D("create DB %s", PACKAGE_INFO_DB_FILE); - if (ret) { - _D("Parser DB creation Failed\n"); - return -1; - } - ret = __createdb_tables(&cert_db, PKG_CERT_DB_FILE, QUERY_CREATE_TABLE_CERT); - _D("create DB %s", PKG_CERT_DB_FILE); - if (ret) { - _D("Parser DB creation Failed\n"); - return -1; - } - - setuid(OWNER_ROOT); - ret = createdb_change_perm(PACKAGE_INFO_DB_FILE); - if (ret == -1) { - _E("cannot chown."); - return -1; - } - SET_DEFAULT_LABEL(PACKAGE_INFO_DB_FILE); - SET_DEFAULT_LABEL(PACKAGE_INFO_DB_FILE_JOURNAL); - SET_DEFAULT_LABEL(PKG_CERT_DB_FILE); - SET_DEFAULT_LABEL(PKG_CERT_DB_FILE_JOURNAL); - - return 0; -} diff --git a/tool/pkg_createdb_user.c b/tool/pkg_createdb_user.c deleted file mode 100644 index c14aab6..0000000 --- a/tool/pkg_createdb_user.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * slp-pkgmgr - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Sabera Djelti , - * Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 - -#define QUERY_CREATE_TABLE_PARSER "create table if not exists package_info " \ - "(package text primary key not null, " \ - "package_type text DEFAULT 'rpm', " \ - "package_version text, " \ - "install_location text, " \ - "package_size text, " \ - "package_removable text DEFAULT 'true', " \ - "package_preload text DEFAULT 'false', " \ - "package_readonly text DEFAULT 'false', " \ - "package_update text DEFAULT 'false', " \ - "package_appsetting text DEFAULT 'false', " \ - "package_nodisplay text DEFAULT 'false', " \ - "package_system text DEFAULT 'false', " \ - "author_name text, " \ - "author_email text, " \ - "author_href text," \ - "installed_time text," \ - "installed_storage text," \ - "storeclient_id text," \ - "mainapp_id text," \ - "package_url text," \ - "root_path text," \ - "csc_path text );" \ - "create table if not exists package_localized_info " \ - "(package text not null, " \ - "package_locale text DEFAULT 'No Locale', " \ - "package_label text, " \ - "package_icon text, " \ - "package_description text, " \ - "package_license text, " \ - "package_author, " \ - "PRIMARY KEY(package, package_locale), " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_privilege_info " \ - "(package text not null, " \ - "privilege text not null, " \ - "PRIMARY KEY(package, privilege) " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_info " \ - "(app_id text primary key not null, " \ - "app_component text, " \ - "app_exec text, " \ - "app_nodisplay text DEFAULT 'false', " \ - "app_type text, " \ - "app_onboot text DEFAULT 'false', " \ - "app_multiple text DEFAULT 'false', " \ - "app_autorestart text DEFAULT 'false', " \ - "app_taskmanage text DEFAULT 'false', " \ - "app_enabled text DEFAULT 'true', " \ - "app_hwacceleration text DEFAULT 'use-system-setting', " \ - "app_screenreader text DEFAULT 'use-system-setting', " \ - "app_mainapp text, " \ - "app_recentimage text, " \ - "app_launchcondition text, " \ - "app_indicatordisplay text DEFAULT 'true', " \ - "app_portraitimg text, " \ - "app_landscapeimg text, " \ - "app_guestmodevisibility text DEFAULT 'true', " \ - "app_permissiontype text DEFAULT 'normal', " \ - "app_preload text DEFAULT 'false', " \ - "app_submode text DEFAULT 'false', " \ - "app_submode_mainid text, " \ - "component_type text, " \ - "package text not null, " \ - "FOREIGN KEY(package) " \ - "REFERENCES package_info(package) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_localized_info " \ - "(app_id text not null, " \ - "app_locale text DEFAULT 'No Locale', " \ - "app_label text, " \ - "app_icon text, " \ - "PRIMARY KEY(app_id,app_locale) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_icon_section_info " \ - "(app_id text not null, " \ - "app_icon text, " \ - "app_icon_section text, " \ - "app_icon_resolution text, " \ - "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_image_info " \ - "(app_id text not null, " \ - "app_locale text DEFAULT 'No Locale', " \ - "app_image_section text, " \ - "app_image text, " \ - "PRIMARY KEY(app_id,app_image_section) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_control " \ - "(app_id text not null, " \ - "operation text not null, " \ - "uri_scheme text, " \ - "mime_type text, " \ - "subapp_name text, " \ - "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_svc " \ - "(app_id text not null, " \ - "operation text not null, " \ - "uri_scheme text, " \ - "mime_type text, " \ - "subapp_name text, " \ - "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_category " \ - "(app_id text not null, " \ - "category text not null, " \ - "PRIMARY KEY(app_id,category) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_metadata " \ - "(app_id text not null, " \ - "md_key text not null, " \ - "md_value text not null, " \ - "PRIMARY KEY(app_id, md_key, md_value) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_app_permission " \ - "(app_id text not null, " \ - "pm_type text not null, " \ - "pm_value text not null, " \ - "PRIMARY KEY(app_id, pm_type, pm_value) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_share_allowed " \ - "(app_id text not null, " \ - "data_share_path text not null, " \ - "data_share_allowed text not null, " \ - "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE);" \ - "create table if not exists package_app_share_request " \ - "(app_id text not null, " \ - "data_share_request text not null, " \ - "PRIMARY KEY(app_id,data_share_request) " \ - "FOREIGN KEY(app_id) " \ - "REFERENCES package_app_info(app_id) " \ - "ON DELETE CASCADE)" - -#define QUERY_CREATE_TABLE_CERT "create table if not exists package_cert_index_info " \ - "(cert_info text not null, " \ - "cert_id integer, " \ - "cert_ref_count integer, " \ - "PRIMARY KEY(cert_id)); " \ - "create table if not exists package_cert_info " \ - "(package text not null, " \ - "author_root_cert integer, " \ - "author_im_cert integer, " \ - "author_signer_cert integer, " \ - "dist_root_cert integer, " \ - "dist_im_cert integer, " \ - "dist_signer_cert integer, " \ - "dist2_root_cert integer, " \ - "dist2_im_cert integer, " \ - "dist2_signer_cert integer, " \ - "PRIMARY KEY(package)) " - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_CREATEDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_CREATEDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -sqlite3 *parser_db; -sqlite3 *cert_db; - -static int __is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - - uid_t uid = getuid(); - if ((uid_t) OWNER_ROOT != uid) - return 1; - else - return 0; -} - -static int __createdb_user_tables(sqlite3 **db_handle, const char *db_path, char *db_query) -{ - int ret = -1; - - ret = - db_util_open_with_options(db_path, &db_handle, - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); - - if (ret != SQLITE_OK) { - _D("connect db [%s] failed!\n", db_path); - sqlite3_close(db_handle); - return -1; - } else { - char *error_message = NULL; - if (SQLITE_OK != - sqlite3_exec(db_handle, db_query, - NULL, NULL, &error_message)) { - _D("Don't execute query = %s error message = %s\n", - db_query, error_message); - sqlite3_free(error_message); - return -1; - } - sqlite3_free(error_message); - } - - return 0; -} - -int main(int argc, char *argv[]) -{ - int ret; - char *journal = NULL; - uid_t uid = getuid(); - - if (!__is_authorized()) { - _E("You are not an authorized user!\n"); - return -1; - } else { - if(remove(getUserPkgParserDBPathUID(uid))) - _E(" %s is not removed", getUserPkgParserDBPathUID(uid)); - asprintf(&journal, "%s-journal", getUserPkgParserDBPathUID(uid)); - if(remove(journal)) - _E(" %s is not removed", journal); - if(remove(getUserPkgCertDBPathUID(uid))) - _E(" %s is not removed", getUserPkgCertDBPathUID(uid)); - asprintf(&journal, "%s-journal", getUserPkgCertDBPathUID(uid)); - if(remove(journal)) - _E(" %s is not removed", journal); - } - /* This is for AIL initializing */ - ret = setenv("INITDB", "1", 1); - _D("INITDB : %d", ret); - - ret = __createdb_user_tables(&parser_db, getUserPkgParserDBPathUID(uid), QUERY_CREATE_TABLE_PARSER); - _D("create DB %s", getUserPkgParserDBPathUID(uid)); - if (ret) { - _D("Parser DB creation Failed\n"); - return -1; - } - ret = __createdb_user_tables(&cert_db, getUserPkgCertDBPathUID(uid), QUERY_CREATE_TABLE_CERT); - _D("create DB %s", getUserPkgCertDBPathUID(uid)); - if (ret) { - _D("Cert DB creation Failed\n"); - return -1; - } - - return 0; -} diff --git a/tool/pkg_info.c b/tool/pkg_info.c index 8b6dc25..04b699c 100644 --- a/tool/pkg_info.c +++ b/tool/pkg_info.c @@ -27,10 +27,8 @@ #include #include #include +#include -#include -//Work around for https://bugs.tizen.org/jira/browse/TC-2399 -#include #include #include @@ -208,9 +206,8 @@ static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *us } else printf("system: %d\n", system); - - return 0; } + int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data) { char *appid = NULL; @@ -1411,7 +1408,6 @@ static int __insert_manifest_in_db(char *manifest, uid_t uid) static int __fota_insert_manifest_in_db(char *manifest, uid_t uid) { int ret = 0; - char *temp[] = {"fota=true", NULL}; if (manifest == NULL) { printf("Manifest file is NULL\n"); @@ -1987,7 +1983,6 @@ static int __check_manifest_validation(char *manifest) int main(int argc, char *argv[]) { int ret = 0; - char *locale = NULL; long starttime; long endtime; struct timeval tv; @@ -1995,19 +1990,6 @@ int main(int argc, char *argv[]) gettimeofday(&tv, NULL); starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l; - locale = ail_vconf_get_str(VCONFKEY_LANGSET); - //Work around for https://bugs.tizen.org/jira/browse/TC-2399 - if (locale == NULL) { - printf("locale is NULL\n"); - ret = -1; - goto end; - } - else - printf("Locale is %s\n", locale); - - - free(locale); - locale = NULL; if (argc == 2) { if (strcmp(argv[1], "--listpkg") == 0) { ret = __get_pkg_list(getuid()); diff --git a/tool/pkg_initdb.c b/tool/pkg_initdb.c index 70253c9..c897dba 100644 --- a/tool/pkg_initdb.c +++ b/tool/pkg_initdb.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -93,14 +94,25 @@ static int _initdb_load_directory(uid_t uid, const char *directory) continue; } - setresuid(uid, uid, OWNER_ROOT); + if (setresuid(uid, uid, OWNER_ROOT)) { + _E("Failed to setresuid: %s", + strerror_r(errno, buf, sizeof(buf))); + return -1; + } snprintf(buf2, sizeof(buf2), "%s %s", PKGINFO_CMD, buf); - system(buf2); + if (system(buf2)) + _E("[%s %s] returns error", PKGINFO_CMD, buf); snprintf(buf2, sizeof(buf2), "%s %s", PKGINSTALLUG_CMD, buf); - system(buf2); + if (system(buf2)) + _E("[%s %s] returns error", PKGINSTALLUG_CMD, buf); snprintf(buf2, sizeof(buf2), "%s %s", PKGPRIVILEGE_CMD, buf); - system(buf2); - setresuid(OWNER_ROOT, OWNER_ROOT, OWNER_ROOT); + if (system(buf2)) + _E("[%s %s] returns error", PKGPRIVILEGE_CMD, buf); + if (setresuid(OWNER_ROOT, OWNER_ROOT, OWNER_ROOT)) { + _E("Failed to setresuid: %s", + strerror_r(errno, buf, sizeof(buf))); + return -1; + } } closedir(dir); diff --git a/tool/pkg_initdb_user.c b/tool/pkg_initdb_user.c deleted file mode 100644 index 040b072..0000000 --- a/tool/pkg_initdb_user.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * slp-pkgmgr - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 -#define GROUP_MENU 6010 -#define BUFSZE 1024 -#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) - - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#define SET_DEFAULT_LABEL(x) \ - if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \ - else _D("chsmack -a \"*\" %s", x) - -static int initdb_user_count_package(void) -{ - int total = 0; - - return total; -} - - -char* _manifest_to_package(const char* manifest) -{ - char *package; - - if(manifest == NULL) - return NULL; - - package = strdup(manifest); - if(package == NULL) - return NULL; - - - if (!strstr(package, ".xml")) { - _E("%s is not a manifest file", manifest); - free(package); - return NULL; - } - - return package; -} - - - -int initdb_user_load_directory(const char *directory) -{ - DIR *dir; - struct dirent entry, *result; - int ret; - char buf[BUFSZE]; - - // desktop file - dir = opendir(directory); - if (!dir) { - if (strerror_r(errno, buf, sizeof(buf)) == 0) - _E("Failed to access the [%s] because %s\n", directory, buf); - return -1; - } - - _D("Loading manifest files from %s\n", directory); - - for (ret = readdir_r(dir, &entry, &result); - ret == 0 && result != NULL; - ret = readdir_r(dir, &entry, &result)) { - char *manifest; - - if (entry.d_name[0] == '.') continue; - - manifest = _manifest_to_package(entry.d_name); - if (!manifest) { - _E("Failed to convert file to package[%s]\n", entry.d_name); - continue; - } - - snprintf(buf, sizeof(buf), "%s/%s", directory, manifest); - - fprintf(stderr, "pkg_initdb : manifest file %s\n", buf); - - ret = pkgmgr_parser_check_manifest_validation(buf); - if (ret < 0) { - _E("check manifest validation failed code[%d] %s\n", ret, buf); - fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf); - free(manifest); - continue; - } - - - /*temporarily fixed due to glib abort */ - // pkgmgr_parser_parse_manifest_for_installation(buf, NULL); - - char buf2[BUFSZE]; - snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf); - system(buf2); - - free(manifest); - } - - closedir(dir); - - return 0; -} - -static int __is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - - uid_t uid = getuid(); - if ((uid_t) OWNER_ROOT != uid) - return 1; - else - return 0; -} - - -int main(int argc, char *argv[]) -{ - int ret; - char *journal = NULL; - - if (!__is_authorized()) { - _E("You are not an authorized user!\n"); - return -1; - } else { - if(remove(getUserPkgParserDBPathUID(getuid()))) - _E(" %s is not removed", getUserPkgParserDBPathUID(getuid())); - asprintf(&journal, "%s-journal", getUserPkgParserDBPathUID(getuid())); - if(remove(journal)) - _E(" %s is not removed", journal); - } - - /* This is for AIL initializing */ - ret = setenv("INITDB", "1", 1); - _D("INITDB : %d", ret); - - ret = initdb_user_count_package(); - if (ret > 0) { - _D("Some Packages in the Package Info DB."); - return 0; - } - ret = initdb_user_load_directory(getUserManifestPath(getuid())); - if (ret == -1) { - _E("cannot load opt manifest directory."); - } - - return 0; -} diff --git a/tool/pkg_install_ug.c b/tool/pkg_install_ug.c index 63c0b4e..37d2bbd 100644 --- a/tool/pkg_install_ug.c +++ b/tool/pkg_install_ug.c @@ -15,7 +15,6 @@ static int _install_ug(const char *manifest) { manifest_x *mfx; uiapplication_x *tmp; - const char *exec; int ret; mfx = pkgmgr_parser_process_manifest_xml(manifest); diff --git a/tool/pkg_privilege.c b/tool/pkg_privilege.c index 9ff04ca..fea5002 100644 --- a/tool/pkg_privilege.c +++ b/tool/pkg_privilege.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -28,7 +29,7 @@ static const char *_get_path(const char *pkgid, const char *appid, uid_t uid) static app_inst_req *_prepare_request(manifest_x *mfx, uid_t uid) { app_inst_req *req; - char *path; + const char *path; struct uiapplication_x *uiapp; struct serviceapplication_x *svcapp; @@ -100,7 +101,6 @@ static int _remove_privilege(char *manifest, uid_t uid) int ret; app_inst_req *req; manifest_x *mfx; - privilege_x *priv; mfx = pkgmgr_parser_process_manifest_xml(manifest); if (mfx == NULL) { diff --git a/tool/pkg_syncdb.c b/tool/pkg_syncdb.c deleted file mode 100644 index 882c2a6..0000000 --- a/tool/pkg_syncdb.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * slp-pkgmgr - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Sabera Djelti , - * Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 -#define BUFSZE 1024 -#define SYS_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES) -#define PACKAGE_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db") -#define PACKAGE_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal") - - -#define PKG_CERT_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db") -#define PKG_CERT_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db-journal") -#define PKG_INFO_DB_LABEL "*" -#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) - - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_SYNCDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_SYNCDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#define SET_DEFAULT_LABEL(x) \ - if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \ - else _D("chsmack -a \"*\" %s", x) - -static int syncdb_count_package(void) -{ - int total = 0; - - return total; -} - -char* _manifest_to_package(const char* manifest) -{ - char *package; - - if(manifest == NULL) - return NULL; - - package = strdup(manifest); - if(package == NULL) - return NULL; - - - if (!strstr(package, ".xml")) { - _E("%s is not a manifest file", manifest); - free(package); - return NULL; - } - - return package; -} - - - -int syncdb_load_directory(const char *directory) -{ - DIR *dir; - struct dirent entry, *result; - int ret; - char buf[BUFSZE]; - - // desktop file - dir = opendir(directory); - if (!dir) { - if (strerror_r(errno, buf, sizeof(buf)) == 0) - _E("Failed to access the [%s] because %s\n", directory, buf); - return -1; - } - - _D("Loading manifest files from %s\n", directory); - - for (ret = readdir_r(dir, &entry, &result); - ret == 0 && result != NULL; - ret = readdir_r(dir, &entry, &result)) { - char *manifest; - - if (entry.d_name[0] == '.') continue; - - manifest = _manifest_to_package(entry.d_name); - if (!manifest) { - _E("Failed to convert file to package[%s]\n", entry.d_name); - continue; - } - - snprintf(buf, sizeof(buf), "%s/%s", directory, manifest); - - fprintf(stderr, "pkg_initdb : manifest file %s\n", buf); - - ret = pkgmgr_parser_check_manifest_validation(buf); - if (ret < 0) { - _E("check manifest validation failed code[%d] %s\n", ret, buf); - fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf); - free(manifest); - continue; - } - - - /*temporarily fixed due to glib abort */ - // pkgmgr_parser_parse_manifest_for_installation(buf, NULL); - - char buf2[BUFSZE]; - snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf); - system(buf2); - - free(manifest); - } - - closedir(dir); - - return 0; -} - - -static int __is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - - uid_t uid = getuid(); - uid_t euid = geteuid(); - //euid need to be root to allow smack label changes during initialization - if ((uid_t) OWNER_ROOT == uid) - return 1; - else - return 0; -} - - -int main(int argc, char *argv[]) -{ - int ret; - - if (!__is_authorized()) { - _E("You are not an authorized user!\n"); - return -1; - } - - setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT); - /* This is for AIL initializing */ - ret = setenv("INITDB", "1", 1); - _D("INITDB : %d", ret); - - ret = syncdb_count_package(); - if (ret > 0) { - _D("Some Packages in the Package Info DB."); - return 0; - } - ret = syncdb_load_directory(SYS_MANIFEST_DIRECTORY); - if (ret == -1) { - _E("cannot load opt manifest directory."); - } - - return 0; -} diff --git a/tool/pkg_syncdb_user.c b/tool/pkg_syncdb_user.c deleted file mode 100644 index 87b8b39..0000000 --- a/tool/pkg_syncdb_user.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * slp-pkgmgr - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Sabera Djelti , - * Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 -#define BUFSZE 1024 - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_SYNCDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_SYNCDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); - - -static int syncdb_user_count_package(void) -{ - int total = 0; - - return total; -} - - -char* _manifest_to_package(const char* manifest) -{ - char *package; - - if(manifest == NULL) - return NULL; - - package = strdup(manifest); - if(package == NULL) - return NULL; - - - if (!strstr(package, ".xml")) { - _E("%s is not a manifest file", manifest); - free(package); - return NULL; - } - - return package; -} - - - -int syncdb_user_load_directory(const char *directory) -{ - DIR *dir; - struct dirent entry, *result; - int ret; - char buf[BUFSZE]; - - // desktop file - dir = opendir(directory); - if (!dir) { - if (strerror_r(errno, buf, sizeof(buf)) == 0) - _E("Failed to access the [%s] because %s\n", directory, buf); - return -1; - } - - _D("Loading manifest files from %s\n", directory); - - for (ret = readdir_r(dir, &entry, &result); - ret == 0 && result != NULL; - ret = readdir_r(dir, &entry, &result)) { - char *manifest; - - if (entry.d_name[0] == '.') continue; - - manifest = _manifest_to_package(entry.d_name); - if (!manifest) { - _E("Failed to convert file to package[%s]\n", entry.d_name); - continue; - } - - snprintf(buf, sizeof(buf), "%s/%s", directory, manifest); - - fprintf(stderr, "pkg_initdb : manifest file %s\n", buf); - - ret = pkgmgr_parser_check_manifest_validation(buf); - if (ret < 0) { - _E("check manifest validation failed code[%d] %s\n", ret, buf); - fprintf(stderr, "check manifest validation failed code[%d] %s\n", ret, buf); - free(manifest); - continue; - } - - - /*temporarily fixed due to glib abort */ - // pkgmgr_parser_parse_manifest_for_installation(buf, NULL); - - char buf2[BUFSZE]; - snprintf(buf2, sizeof(buf2), "/usr/bin/pkginfo --imd %s", buf); - system(buf2); - - free(manifest); - } - - closedir(dir); - - return 0; -} - -static int __is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - - uid_t uid = getuid(); - if ((uid_t) OWNER_ROOT != uid) - return 1; - else - return 0; -} - - -int main(int argc, char *argv[]) -{ - int ret; - char *journal = NULL; - - if (!__is_authorized()) { - _E("You are not an authorized user!\n"); - return -1; - } - - /* This is for AIL initializing */ - ret = setenv("INITDB", "1", 1); - _D("INITDB : %d", ret); - - ret = syncdb_user_count_package(); - if (ret > 0) { - _D("Some Packages in the Package Info DB."); - return 0; - } - ret = syncdb_user_load_directory(getUserManifestPath(getuid())); - if (ret == -1) { - _E("cannot load opt manifest directory."); - } - - return 0; -} diff --git a/tool/stress_test.py b/tool/stress_test.py deleted file mode 100755 index 66ab6ae..0000000 --- a/tool/stress_test.py +++ /dev/null @@ -1,36 +0,0 @@ -#/usr/bin/python -import sys, subprocess - -num_try = 1 -frontends = {} - -if __name__ == "__main__": - - # Run frontends - for i in range(num_try): - p = subprocess.Popen("pkgmgr_frontend_test -n 2>/dev/null 1>/dev/null".split()) - frontends[i] = p - print("Run %d/%d frontend"%(i, num_try)) - - - # wait frontends to be end - done = {} - seq = [] - while True: - for i in frontends: - if not done.has_key(i): - p = frontends[i] - ret = p.poll() - if not None == ret: - print("Frontend #%d is terminated. Returns: %d"%(i, -ret)) - done[i] = -ret - seq.append(i) - if num_try == len(done): - break - - print("Test done.") - for i in frontends: - print("Return code of frontend #%d = %d"%(i, done[i])) - #print("Terminate seq:") - #print(seq) - -- 2.7.4