pkg_check_modules(CLIENT_DEPS REQUIRED
dbus-glib-1
dlog
- ail
pkgmgr-parser
pkgmgr-info
iniparser
*/
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);
-
/** @} */
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);
#include <unistd.h>
#include <dlfcn.h>
#include <sys/time.h>
-#include <ail.h>
#include <tzplatform_config.h>
#include "package-manager.h"
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;
}
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <ail.h>
-#include <db-util.h>
#include <pkgmgr-info.h>
#include <iniparser.h>
/* For multi-user support */
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)
{
cb_info->data);
}
- /*remove callback for last call
- if (strcmp(key, "end") == 0) {
- __remove_op_cbinfo(pc, cb_info);
- DBG("__remove_op_cbinfo");
- }
- */
-
return;
}
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;
}
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) {
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', };
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);
return result;
}
+
static int __csc_process(const char *csc_path, char *result_path)
{
int ret = 0;
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;
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);
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;
* (int *) data = pid;
catch:
- free(req_key);
+ if (req_key)
+ free(req_key);
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
return ret;
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
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)
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,
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;
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,
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
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)
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 */
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)
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 */
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)
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 */
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)
{
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
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)
{
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)
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
const gchar *args,
uid_t uid,
gint *ret)
-{
+{
OrgTizenSlpPkgmgr *proxy;
GError *error = NULL;
int rc = 0;
}
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;
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");
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) {
#include "comm_config.h"
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
#include <stdlib.h>
#include <unistd.h>
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);
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)
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
mkdir -p %{buildroot}%{_sysconfdir}/package-manager/server
-%find_lang package-manager
-
%fdupes %{buildroot}
%post
%{_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
%{_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
pkg_check_modules(SERVER_DEPS REQUIRED
cynara-client
dlog
- ail
pkgmgr-parser
pkgmgr-info
libtzplatform-config)
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)
+++ /dev/null
-# 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})
+++ /dev/null
-# List of source files containing translatable strings.
-src/pkgmgr-server.c
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 ""
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 ""
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 "無効なリクエストです"
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 "요청이 바르지 않습니다"
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 ""
+++ /dev/null
-#!/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
-
+++ /dev/null
-# 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\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 ""
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <unistd.h>
+#include <pwd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <glib.h>
#include <signal.h>
-#include <ail.h>
+
+#include <glib.h>
+
#include <pkgmgr-info.h>
#include <pkgmgr/pkgmgr_parser.h>
-
#include <cynara-client.h>
-
-/* For multi-user support */
#include <tzplatform_config.h>
#include "pkgmgr_installer.h"
#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 {
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);
{
backend_busy = backend_busy & ~(1<<position);
}
-/* To check whether a particular backend is running in quiet mode*/
-static int __is_backend_mode_quiet(int position)
-{
- return backend_mode & 1<<position;
-}
/*To set a particular backend mode as quiet*/
static void __set_backend_mode(int position)
{
path = tzplatform_getenv(__is_global(uid)
? TZ_SYS_RW_PACKAGES : TZ_USER_PACKAGES);
- tzplatform_reset_user(uid);
+ tzplatform_reset_user();
return path;
}
return ret;
}
-#if 0
-static char *__get_exe_path(const char *pkgid)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
- char *exe_path;
-
- ret = ail_package_get_appinfo(pkgid, &handle);
- if (ret != AIL_ERROR_OK) {
- ERR("ail_package_get_appinfo() failed");
- return NULL;
- }
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &str);
- if (ret != AIL_ERROR_OK) {
- ERR("ail_appinfo_get_str() failed");
- ail_package_destroy_appinfo(handle);
- return NULL;
- }
-
- exe_path = strdup(str);
- if (exe_path == NULL) {
- ERR("strdup() failed");
- ail_package_destroy_appinfo(handle);
- return NULL;
- }
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- ERR("ail_package_destroy_appinfo() failed");
- free(exe_path);
- return NULL;
- }
-
- return exe_path;
-}
-#endif
-
static void send_fail_signal(char *pname, char *ptype, char *args)
{
DBG("send_fail_signal start\n");
}
return;
}
-
-static int __check_backend_mode()
-{
- int i = 0;
- for(i = 0; i < num_of_backends; i++)
- {
- if (__is_backend_mode_quiet(i))
- continue;
- else
- return 0;
- }
- return 1;
-}
-static int __check_backend_status_for_exit()
+static int __check_backend_status_for_exit(void)
{
int i = 0;
for(i = 0; i < num_of_backends; i++)
return 1;
}
-static int __check_queue_status_for_exit()
+static int __check_queue_status_for_exit(void)
{
pm_queue_data *head[MAX_QUEUE_NUM] = {NULL,};
queue_info_map *ptr = NULL;
return TRUE;
}
-int __app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
-{
- int ret = 0;
- char *appid = NULL;
- int *data = (int *)user_data;
-
- ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
- if (ret != PMINFO_R_OK) {
- perror("fail to activate/deactivte package");
- exit(1);
- }
-
- ret = pkgmgrinfo_appinfo_set_state_enabled(appid, (*data));
- if (ret != PMINFO_R_OK) {
- perror("fail to activate/deactivte package");
- exit(1);
- }
-
- ret = ail_desktop_appinfo_modify_bool(appid,
- AIL_PROP_X_SLP_ENABLED_BOOL,
- (*data), TRUE);
- if (ret != AIL_ERROR_OK) {
- perror("fail to activate/deactivte package");
- exit(1);
- }
- return 0;
-}
-
static int __pkgcmd_read_proc(const char *path, char *buf, int size)
{
int fd;
free(ctx);
}
-int set_environement(user_ctx* ctx)
+int set_environement(user_ctx *ctx)
{
int i = 0;
int res = 0;
char **env = NULL;
if (!ctx)
- return;
- setgid(ctx->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++;
}
* returned by getpwuid
*/
user_ctx *context_res;
- char ** env;
+ char **env = NULL;
struct passwd * pwd;
int len;
int ret = 0;
env[2] = NULL;
} while (0);
- if(ret == -1) {
+ if (ret == -1) {
free(context_res);
context_res = NULL;
int i = 0;
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;
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);
}
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);
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;
}
}
}
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");
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)
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/)
#include <fcntl.h>
#include <dlfcn.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <glib.h>
#include <glib-object.h>
#include <sqlite3.h>
-#include <ail.h>
#include <pkgmgr-info.h>
/* For multi-user support */
#include <tzplatform_config.h>
#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);
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",
}
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;
}
}
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;
}
}
-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;
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");
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;
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') {
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) {
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) {
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) {
}
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;
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;
}
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;
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- * Copyright (C) 2013-2014 Intel Corporation.
- *
- * Contact: Sabera Djelti <sabera.djelti@open.eurogiciel.org>,
- * Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <sqlite3.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#include <sys/smack.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#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;
-}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sabera Djelti <sabera.djelti@open.eurogiciel.org>,
- * Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <sqlite3.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#include <sys/smack.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#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;
-}
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/time.h>
-#include <vconf.h>
-//Work around for https://bugs.tizen.org/jira/browse/TC-2399
-#include <ail_vconf.h>
#include <pkgmgr_parser.h>
#include <pkgmgr-info.h>
}
else
printf("system: %d\n", system);
-
- return 0;
}
+
int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
{
char *appid = NULL;
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");
int main(int argc, char *argv[])
{
int ret = 0;
- char *locale = NULL;
long starttime;
long endtime;
struct timeval tv;
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());
#include <errno.h>
#include <pkgmgr_parser.h>
+#include <pkgmgr_parser_db.h>
#include <pkgmgr-info.h>
#include <sys/smack.h>
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);
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#include <sys/smack.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#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;
-}
{
manifest_x *mfx;
uiapplication_x *tmp;
- const char *exec;
int ret;
mfx = pkgmgr_parser_process_manifest_xml(manifest);
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <sys/types.h>
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;
int ret;
app_inst_req *req;
manifest_x *mfx;
- privilege_x *priv;
mfx = pkgmgr_parser_process_manifest_xml(manifest);
if (mfx == NULL) {
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sabera Djelti <sabera.djelti@open.eurogiciel.org>,
- * Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#include <sys/smack.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#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;
-}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Sabera Djelti <sabera.djelti@open.eurogiciel.org>,
- * Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <pkgmgr_parser.h>
-#include <pkgmgr-info.h>
-
-#include <sys/smack.h>
-/* For multi-user support */
-#include <tzplatform_config.h>
-
-#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;
-}
+++ /dev/null
-#/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)
-