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);
free_user_context(user_context);
/* Execute backend !!! */
+
int ret = execv(cmd, argv);
/* Code below: exec failure. Should not be happened! */
{
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;
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);
" <arg type='u' name='uid' direction='in'/>"
" <arg type='s' name='pkgtype' direction='in'/>"
" <arg type='s' name='pkgpath' direction='in'/>"
+ " <arg type='as' name='args' direction='in'/>"
" <arg type='i' name='ret' direction='out'/>"
" <arg type='s' name='reqkey' direction='out'/>"
" </method>"
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,