From 22b76b196ef6233af9d1a93512f324276667adc6 Mon Sep 17 00:00:00 2001 From: VBS Date: Tue, 3 Nov 2015 20:32:33 +0900 Subject: [PATCH] implement TEP install, update [app-installer][pkgmgr-info][pkgmgr-server][pkgmgr-tool][slp-pkgmgr] Signed-off-by: VBS Change-Id: Ie376dd71bb487229d165e36592f20987a6ed5128 --- src/pkgmgr-server.c | 10 +++++--- src/request.c | 67 ++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 14 deletions(-) diff --git a/src/pkgmgr-server.c b/src/pkgmgr-server.c index 350cb0e..bc1b2c8 100644 --- a/src/pkgmgr-server.c +++ b/src/pkgmgr-server.c @@ -691,6 +691,7 @@ static char **__generate_argv(const char *args) static void __exec_with_arg_vector(const char *cmd, char **argv, uid_t uid) { user_ctx* user_context = get_user_context(uid); + if(!user_context) { DBG("Failed to getenv for the user : %d", uid); exit(1); @@ -702,6 +703,7 @@ static void __exec_with_arg_vector(const char *cmd, char **argv, uid_t uid) free_user_context(user_context); /* Execute backend !!! */ + int ret = execv(cmd, argv); /* Code below: exec failure. Should not be happened! */ @@ -719,14 +721,15 @@ static void __process_install(pm_dbus_msg *item) { char *backend_cmd; char **args_vector; - char args[MAX_PKG_ARGS_LEN]; + char args[MAX_PKG_ARGS_LEN] = {'\0', }; backend_cmd = _get_backend_cmd(item->pkg_type); if (backend_cmd == NULL) return; - snprintf(args, sizeof(args), "%s -k %s -i %s", backend_cmd, - item->req_id, item->pkgid); + snprintf(args, sizeof(args), "%s -k %s -i %s %s", backend_cmd, + item->req_id, item->pkgid, item->args); + args_vector = __generate_argv(args); args_vector[0] = backend_cmd; @@ -908,6 +911,7 @@ gboolean queue_job(void *data) strncpy(ptr->pkgtype, item->pkg_type, MAX_PKG_TYPE_LEN-1); strncpy(ptr->pkgid, item->pkgid, MAX_PKG_NAME_LEN-1); strncpy(ptr->args, item->args, MAX_PKG_ARGS_LEN-1); + ptr->uid = item->uid; ptr->pid = fork(); DBG("child forked [%d] for request type [%d]", ptr->pid, item->req_type); diff --git a/src/request.c b/src/request.c index 7b1d8d4..9e59939 100644 --- a/src/request.c +++ b/src/request.c @@ -17,6 +17,7 @@ static const char instropection_xml[] = " " " " " " + " " " " " " " " @@ -124,31 +125,75 @@ static int __handle_request_install(uid_t uid, uid_t target_uid = (uid_t)-1; char *pkgtype = NULL; char *pkgpath = NULL; - char *reqkey; + char *args = NULL; + char *reqkey = NULL; + gchar **tmp_args = NULL; + gsize args_count; + int ret = -1; + GVariant *value; + gchar *str; + int i = 0; + int len = 0; + + g_variant_get(parameters, "(u&s&s@as)", &target_uid, &pkgtype, &pkgpath, &value); + tmp_args = (gchar **)g_variant_get_strv(value, &args_count); + + for (i = 0; i < args_count; i++) + len = len + strlen(tmp_args[i]) + 1; + + args = (char *)calloc(len, sizeof(char)); + if (args == NULL) { + ERR("calloc failed"); + ret = -1; + goto catch; + } + + for (i = 0; i < args_count; i++) { + strncat(args, tmp_args[i], strlen(tmp_args[i])); + strncat(args, " ", strlen(" ")); + } - g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgpath); - if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgpath == NULL) { + if (target_uid == (uid_t)-1 || pkgtype == NULL) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(is)", PKGMGR_R_ECOMM, "")); - return -1; + ret = -1; + goto catch; + } + + if (pkgpath == NULL) { + g_dbus_method_invocation_return_value(invocation, + g_variant_new("(is)", PKGMGR_R_ECOMM, "")); + ret = -1; + goto catch; } reqkey = __generate_reqkey(pkgpath); - if (reqkey == NULL) - return -1; + if (reqkey == NULL) { + ret = -1; + goto catch; + } + if (_pm_queue_push(target_uid, reqkey, PKGMGR_REQUEST_TYPE_INSTALL, pkgtype, - pkgpath, "")) { + pkgpath, args)) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(is)", PKGMGR_R_ESYSTEM, "")); - free(reqkey); - return -1; + ret = -1; + goto catch; } g_dbus_method_invocation_return_value(invocation, g_variant_new("(is)", PKGMGR_R_OK, reqkey)); - free(reqkey); - return 0; + ret = 0; + +catch: + if (reqkey) + free(reqkey); + + if (args) + free(args); + + return ret; } static int __handle_request_reinstall(uid_t uid, -- 2.7.4