Consider caller uid when handling request 43/100543/2 accepted/tizen/3.0/common/20161129.102953 accepted/tizen/3.0/ivi/20161129.002023 accepted/tizen/3.0/mobile/20161129.001919 accepted/tizen/3.0/tv/20161129.001948 accepted/tizen/3.0/wearable/20161129.002000 submit/tizen_3.0/20161128.050643
authorSangyoon Jang <s89.jang@samsung.com>
Mon, 28 Nov 2016 10:42:24 +0000 (19:42 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Mon, 28 Nov 2016 10:50:24 +0000 (19:50 +0900)
Request for getsize now need caller uid to sending result signal,
so pkgmgr-server should pass caller uid to getsize process.

Submit with:
 - https://review.tizen.org/gerrit/100542
 - https://review.tizen.org/gerrit/100544

Change-Id: I3ec28b650d705257007ce250c91137116063aa01
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
include/queue.h
src/pkgmgr-server.c
src/queue.c
src/request.c
src/signal.c

index 5276ee6..27fd907 100644 (file)
@@ -21,7 +21,8 @@
 #include <sys/types.h>
 
 struct backend_job {
-       uid_t uid;
+       uid_t target_uid;
+       uid_t caller_uid;
        int req_type;
        char *req_id;
        char *pkgid;
@@ -33,8 +34,9 @@ struct backend_job {
 };
 
 int _is_queue_empty(int pos);
-int _push_queue(uid_t uid, const char *req_id, int req_type,
-               const char *queue_type, const char *pkgid, const char *args);
+int _push_queue(uid_t target_uid, uid_t caller_uid, const char *req_id,
+               int req_type, const char *queue_type, const char *pkgid,
+               const char *args);
 struct backend_job *_pop_queue(int pos);
 void _free_backend_job(struct backend_job *job);
 int _init_backend_queue(void);
index d5b59ee..e4c312f 100644 (file)
@@ -637,7 +637,7 @@ static int __process_install(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -i %s -u %d %s", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid, job->args);
+                       job->req_id, job->pkgid, (int)job->target_uid, job->args);
 
        argv = __generate_argv(args);
 
@@ -659,7 +659,7 @@ static int __process_mount_install(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -w %s -u %d %s", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid, job->args);
+                       job->req_id, job->pkgid, (int)job->target_uid, job->args);
 
        argv = __generate_argv(args);
 
@@ -681,7 +681,7 @@ static int __process_reinstall(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -r %s -u %d", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid);
+                       job->req_id, job->pkgid, (int)job->target_uid);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -703,7 +703,7 @@ static int __process_uninstall(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -d %s -u %d", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid);
+                       job->req_id, job->pkgid, (int)job->target_uid);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -725,7 +725,7 @@ static int __process_move(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -m %s -u %d -t %s", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid, job->args);
+                       job->req_id, job->pkgid, (int)job->target_uid, job->args);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -747,7 +747,7 @@ static int __process_enable_pkg(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -u %d -A %s", backend_cmd,
-                       job->req_id, (int)job->uid, job->pkgid);
+                       job->req_id, (int)job->target_uid, job->pkgid);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -769,7 +769,7 @@ static int __process_disable_pkg(struct backend_job *job)
                return -1;
 
        snprintf(args, sizeof(args), "%s -k %s -u %d -D %s", backend_cmd,
-                       job->req_id, (int)job->uid, job->pkgid);
+                       job->req_id, (int)job->target_uid, job->pkgid);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -787,32 +787,32 @@ static int __process_enable_app(struct backend_job *job)
        /* get actual pkgid and replace it to appid which is currently stored
         * at pkgid variable
         */
-       ret = __change_job_info(job, job->uid, &is_global);
+       ret = __change_job_info(job, job->target_uid, &is_global);
        if (ret != PMINFO_R_OK || strlen(job->appid) == 0) {
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_START_KEY_STR,
                                PKGMGR_INSTALLER_APP_ENABLE_EVENT_STR,
                                job->req_type);
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
                return ret;
        }
 
-       _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+       _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                        PKGMGR_INSTALLER_START_KEY_STR,
                        PKGMGR_INSTALLER_APP_ENABLE_EVENT_STR, job->req_type);
 
        ret = pkgmgr_parser_update_app_disable_info_in_usr_db(job->appid,
-                       job->uid, 0);
+                       job->target_uid, 0);
        if (ret != PMINFO_R_OK)
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        else
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_OK_EVENT_STR,
                                job->req_type);
@@ -828,40 +828,40 @@ static int __process_disable_app(struct backend_job *job)
        /* get actual pkgid and replace it to appid which is currently stored
         * at pkgid variable
         */
-       ret = __change_job_info(job, job->uid, &is_global);
+       ret = __change_job_info(job, job->target_uid, &is_global);
        if (ret != PMINFO_R_OK || strlen(job->appid) == 0) {
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_START_KEY_STR,
                                PKGMGR_INSTALLER_APP_DISABLE_EVENT_STR,
                                job->req_type);
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
                return ret;
        }
 
-       _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+       _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                        PKGMGR_INSTALLER_START_KEY_STR,
                        PKGMGR_INSTALLER_APP_DISABLE_EVENT_STR, job->req_type);
 
-       ret = __kill_app(job->appid, job->uid);
+       ret = __kill_app(job->appid, job->target_uid);
        if (ret != 0) {
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        }
 
        ret = pkgmgr_parser_update_app_disable_info_in_usr_db(job->appid,
-                       job->uid, 1);
+                       job->target_uid, 1);
        if (ret != PMINFO_R_OK)
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        else
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_OK_EVENT_STR,
                                job->req_type);
@@ -877,33 +877,33 @@ static int __process_enable_global_app_for_uid(struct backend_job *job)
        /* get actual pkgid and replace it to appid which is currently stored
         * at pkgid variable
         */
-       ret = __change_job_info(job, job->uid, &is_global);
+       ret = __change_job_info(job, job->target_uid, &is_global);
        if (ret != PMINFO_R_OK || strlen(job->appid) == 0) {
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_START_KEY_STR,
                                PKGMGR_INSTALLER_GLOBAL_APP_ENABLE_FOR_UID,
                                job->req_type);
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
                return ret;
        }
 
-       _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+       _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                        PKGMGR_INSTALLER_START_KEY_STR,
                        PKGMGR_INSTALLER_GLOBAL_APP_ENABLE_FOR_UID,
                        job->req_type);
 
        ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(
-                       job->appid, job->uid, 0);
+                       job->appid, job->target_uid, 0);
        if (ret != PMINFO_R_OK)
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        else
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_OK_EVENT_STR,
                                job->req_type);
@@ -921,35 +921,35 @@ static int __process_disable_global_app_for_uid(struct backend_job *job)
         */
        ret = __change_job_info(job, GLOBAL_USER, &is_global);
        if (ret != PMINFO_R_OK || strlen(job->appid) == 0) {
-               _send_app_signal(job->uid, job->req_id,
+               _send_app_signal(job->target_uid, job->req_id,
                                job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_START_KEY_STR,
                                PKGMGR_INSTALLER_GLOBAL_APP_DISABLE_FOR_UID,
                                job->req_type);
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->pkgid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
                return ret;
        }
 
-       _send_app_signal(job->uid, job->req_id,
+       _send_app_signal(job->target_uid, job->req_id,
                        job->pkgid, job->appid,
                        PKGMGR_INSTALLER_START_KEY_STR,
                        PKGMGR_INSTALLER_GLOBAL_APP_DISABLE_FOR_UID,
                        job->req_type);
 
-       ret = __kill_app(job->appid, job->uid);
+       ret = __kill_app(job->appid, job->target_uid);
        ret = pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(
-                       job->appid, job->uid, 1);
+                       job->appid, job->target_uid, 1);
 
        if (ret != PMINFO_R_OK)
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        else
-               _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                                PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_OK_EVENT_STR,
                                job->req_type);
@@ -959,15 +959,16 @@ static int __process_disable_global_app_for_uid(struct backend_job *job)
 
 static int __process_getsize(struct backend_job *job)
 {
-       static const char *backend_cmd = "/usr/bin/pkg_getsize";
+       static const char backend_cmd[] = "/usr/bin/pkg_getsize";
        char **argv;
        char args[MAX_PKG_ARGS_LEN];
        int pid;
 
-       snprintf(args, sizeof(args), "%s %s %s -k %s", backend_cmd, job->pkgid,
-                       job->args, job->req_id);
+       snprintf(args, sizeof(args), "%s %s %s %d -k %s -u %d",
+                       backend_cmd, job->pkgid, job->args, job->caller_uid,
+                       job->req_id, job->target_uid);
        argv = __generate_argv(args);
-       pid = __fork_and_exec_with_args(argv, job->uid);
+       pid = __fork_and_exec_with_args(argv, APPFW_UID);
 
        g_strfreev(argv);
 
@@ -987,7 +988,7 @@ static int __process_cleardata(struct backend_job *job)
 
        /* TODO: set movetype */
        snprintf(args, sizeof(args), "%s -k %s -c %s -u %d", backend_cmd,
-                       job->req_id, job->pkgid, (int)job->uid);
+                       job->req_id, job->pkgid, (int)job->target_uid);
        argv = __generate_argv(args);
 
        pid = __fork_and_exec_with_args(argv, APPFW_UID);
@@ -1006,7 +1007,7 @@ static int __process_clearcache(struct backend_job *job)
 
        snprintf(args, sizeof(args), "%s %s", backend_cmd, job->pkgid);
        argv = __generate_argv(args);
-       pid = __fork_and_exec_with_args(argv, job->uid);
+       pid = __fork_and_exec_with_args(argv, job->target_uid);
 
        g_strfreev(argv);
 
@@ -1019,7 +1020,7 @@ static int __process_kill(struct backend_job *job)
        pkgmgrinfo_pkginfo_h handle;
        pkgcmd_data *pdata;
 
-       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(job->pkgid, job->uid,
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(job->pkgid, job->target_uid,
                        &handle);
        if (ret < 0) {
                ERR("Failed to get handle");
@@ -1043,9 +1044,9 @@ static int __process_kill(struct backend_job *job)
                free(pdata);
                return -1;
        }
-       pdata->uid = job->uid;
+       pdata->uid = job->target_uid;
        ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP,
-                       __pkgcmd_app_cb, pdata, job->uid);
+                       __pkgcmd_app_cb, pdata, job->target_uid);
 
        _return_value_to_caller(job->req_id,
                        g_variant_new("(ii)", PKGMGR_R_OK, pdata->pid));
@@ -1067,7 +1068,7 @@ static int __process_check(struct backend_job *job)
        pkgmgrinfo_pkginfo_h handle;
        pkgcmd_data *pdata;
 
-       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(job->pkgid, job->uid,
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(job->pkgid, job->target_uid,
                        &handle);
        if (ret < 0) {
                ERR("Failed to get handle");
@@ -1091,9 +1092,9 @@ static int __process_check(struct backend_job *job)
                free(pdata);
                return -1;
        }
-       pdata->uid = job->uid;
+       pdata->uid = job->target_uid;
        ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP,
-                       __pkgcmd_app_cb, pdata, job->uid);
+                       __pkgcmd_app_cb, pdata, job->target_uid);
 
        _return_value_to_caller(job->req_id,
                        g_variant_new("(ii)", PKGMGR_R_OK, pdata->pid));
@@ -1190,27 +1191,27 @@ static int __process_update_app_splash_screen(struct backend_job *job, int flag)
        bool is_global = false;
        const char *val;
 
-       ret = __change_job_info(job, job->uid, &is_global);
+       ret = __change_job_info(job, job->target_uid, &is_global);
        if (ret != PMINFO_R_OK || strlen(job->appid) == 0)
                return -1;
 
        val = flag ? PKGMGR_INSTALLER_APP_ENABLE_SPLASH_SCREEN_EVENT_STR :
                PKGMGR_INSTALLER_APP_DISABLE_SPLASH_SCREEN_EVENT_STR;
-       _send_app_signal(job->uid, job->req_id, job->pkgid, job->appid,
+       _send_app_signal(job->target_uid, job->req_id, job->pkgid, job->appid,
                        PKGMGR_INSTALLER_START_KEY_STR, val, job->req_type);
 
        if (is_global)
-               ret = pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(job->appid, job->uid, flag);
+               ret = pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(job->appid, job->target_uid, flag);
        else
                ret = pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(
-                       job->appid, job->uid, flag);
+                       job->appid, job->target_uid, flag);
        if (ret != PMINFO_R_OK)
-               _send_app_signal(job->uid, job->req_id, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid,
                                job->appid, PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_FAIL_EVENT_STR,
                                job->req_type);
        else
-               _send_app_signal(job->uid, job->req_id, job->pkgid,
+               _send_app_signal(job->target_uid, job->req_id, job->pkgid,
                                job->appid, PKGMGR_INSTALLER_END_KEY_STR,
                                PKGMGR_INSTALLER_OK_EVENT_STR,
                                job->req_type);
@@ -1224,7 +1225,7 @@ static int __process_set_restriction_mode(struct backend_job *job)
        int mode;
 
        mode = atoi(job->args);
-       ret = _set_restriction_mode(job->uid, job->pkgid, mode);
+       ret = _set_restriction_mode(job->target_uid, job->pkgid, mode);
 
        _return_value_to_caller(job->req_id,
                        g_variant_new("(i)", ret));
@@ -1238,7 +1239,7 @@ static int __process_unset_restriction_mode(struct backend_job *job)
        int mode;
 
        mode = atoi(job->args);
-       ret = _unset_restriction_mode(job->uid, job->pkgid, mode);
+       ret = _unset_restriction_mode(job->target_uid, job->pkgid, mode);
 
        _return_value_to_caller(job->req_id,
                        g_variant_new("(i)", ret));
@@ -1251,7 +1252,7 @@ static int __process_get_restriction_mode(struct backend_job *job)
        int ret;
        int mode = -1;
 
-       ret = _get_restriction_mode(job->uid, job->pkgid, &mode);
+       ret = _get_restriction_mode(job->target_uid, job->pkgid, &mode);
 
        _return_value_to_caller(job->req_id,
                        g_variant_new("(ii)", mode, ret));
index 2d741ae..11e6ace 100644 (file)
@@ -84,8 +84,9 @@ struct backend_job *_pop_queue(int pos)
        return job;
 }
 
-int _push_queue(uid_t uid, const char *req_id, int req_type,
-               const char *queue_type, const char *pkgid, const char *args)
+int _push_queue(uid_t target_uid, uid_t caller_uid, const char *req_id,
+               int req_type, const char *queue_type, const char *pkgid,
+               const char *args)
 {
        struct backend_queue *queue;
        struct backend_job *job;
@@ -98,7 +99,8 @@ int _push_queue(uid_t uid, const char *req_id, int req_type,
        }
 
        job = calloc(1, sizeof(struct backend_job));
-       job->uid = uid;
+       job->target_uid = target_uid;
+       job->caller_uid = caller_uid;
        if (req_id)
                job->req_id = strdup(req_id);
        job->req_type = req_type;
index 4698da9..3269b24 100644 (file)
@@ -268,7 +268,7 @@ static int __check_caller_permission(uid_t uid,
        return 0;
 }
 
-static int __handle_request_install(uid_t uid,
+static int __handle_request_install(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -327,8 +327,8 @@ static int __handle_request_install(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_INSTALL, pkgtype,
-                               pkgpath, args)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_INSTALL,
+                               pkgtype, pkgpath, args)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -353,7 +353,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_mount_install(uid_t uid,
+static int __handle_request_mount_install(uid_t caller_uid,
        GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -412,7 +412,8 @@ static int __handle_request_mount_install(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_MOUNT_INSTALL,
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_MOUNT_INSTALL,
                                pkgtype, pkgpath, args)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
@@ -437,7 +438,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_reinstall(uid_t uid,
+static int __handle_request_reinstall(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -466,8 +467,8 @@ static int __handle_request_reinstall(uid_t uid,
                free(pkgtype);
                return -1;
        }
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_REINSTALL, pkgtype,
-                               pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_REINSTALL,
+                               pkgtype, pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
@@ -483,7 +484,7 @@ static int __handle_request_reinstall(uid_t uid,
        return 0;
 }
 
-static int __handle_request_uninstall(uid_t uid,
+static int __handle_request_uninstall(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -512,8 +513,8 @@ static int __handle_request_uninstall(uid_t uid,
                free(pkgtype);
                return -1;
        }
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_UNINSTALL, pkgtype,
-                               pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_UNINSTALL,
+                               pkgtype, pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
@@ -529,7 +530,7 @@ static int __handle_request_uninstall(uid_t uid,
        return 0;
 }
 
-static int __handle_request_move(uid_t uid,
+static int __handle_request_move(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -562,8 +563,8 @@ static int __handle_request_move(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", move_type);
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_MOVE, pkgtype,
-                               pkgid, buf)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_MOVE,
+                               pkgtype, pkgid, buf)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
@@ -579,7 +580,7 @@ static int __handle_request_move(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_pkgs(uid_t uid,
+static int __handle_request_enable_pkgs(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -611,7 +612,8 @@ static int __handle_request_enable_pkgs(uid_t uid,
                        free(reqkey);
                        return -1;
                }
-               if (_push_queue(target_uid, reqkey, REQUEST_TYPE_ENABLE_PKG,
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_ENABLE_PKG,
                                        pkgtype, pkgid, NULL)) {
                        g_dbus_method_invocation_return_value(invocation,
                                        g_variant_new("(is)",
@@ -630,7 +632,7 @@ static int __handle_request_enable_pkgs(uid_t uid,
        return 0;
 }
 
-static int __handle_request_disable_pkgs(uid_t uid,
+static int __handle_request_disable_pkgs(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -662,7 +664,8 @@ static int __handle_request_disable_pkgs(uid_t uid,
                        free(reqkey);
                        return -1;
                }
-               if (_push_queue(target_uid, reqkey, REQUEST_TYPE_DISABLE_PKG,
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_DISABLE_PKG,
                                        pkgtype, pkgid, NULL)) {
                        g_dbus_method_invocation_return_value(invocation,
                                        g_variant_new("(is)",
@@ -681,7 +684,7 @@ static int __handle_request_disable_pkgs(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_app(uid_t uid,
+static int __handle_request_enable_app(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -704,7 +707,8 @@ static int __handle_request_enable_app(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_ENABLE_APP, "default",
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_ENABLE_APP, "default",
                                appid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
@@ -724,7 +728,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_disable_app(uid_t uid,
+static int __handle_request_disable_app(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -747,7 +751,8 @@ static int __handle_request_disable_app(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_DISABLE_APP, "default",
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_DISABLE_APP, "default",
                                appid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
@@ -767,7 +772,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_enable_global_app_for_uid(uid_t uid,
+static int __handle_request_enable_global_app_for_uid(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -790,7 +795,7 @@ static int __handle_request_enable_global_app_for_uid(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID,
                                "default", appid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -811,7 +816,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_disable_global_app_for_uid(uid_t uid,
+static int __handle_request_disable_global_app_for_uid(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -834,7 +839,7 @@ static int __handle_request_disable_global_app_for_uid(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_DISABLE_GLOBAL_APP_FOR_UID,
                                "default", appid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -855,7 +860,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_getsize(uid_t uid,
+static int __handle_request_getsize(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -879,8 +884,8 @@ static int __handle_request_getsize(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", get_type);
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_GETSIZE, "pkgtool",
-                               pkgid, buf)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_GETSIZE,
+                               "pkgtool", pkgid, buf)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
@@ -894,7 +899,7 @@ static int __handle_request_getsize(uid_t uid,
        return 0;
 }
 
-static int __handle_request_cleardata(uid_t uid,
+static int __handle_request_cleardata(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -924,8 +929,8 @@ static int __handle_request_cleardata(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_CLEARDATA, pkgtype,
-                               pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_CLEARDATA,
+                               pkgtype, pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -942,7 +947,7 @@ static int __handle_request_cleardata(uid_t uid,
        return 0;
 }
 
-static int __handle_request_clearcache(uid_t uid,
+static int __handle_request_clearcache(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -955,7 +960,7 @@ static int __handle_request_clearcache(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, NULL, REQUEST_TYPE_CLEARCACHE,
+       if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARCACHE,
                                "pkgtool",  pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
@@ -968,7 +973,7 @@ static int __handle_request_clearcache(uid_t uid,
        return 0;
 }
 
-static int __handle_request_kill(uid_t uid,
+static int __handle_request_kill(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -989,7 +994,7 @@ static int __handle_request_kill(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_KILL,
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_KILL,
                                "default", pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(ii)", PKGMGR_R_ESYSTEM, 0));
@@ -1004,7 +1009,7 @@ static int __handle_request_kill(uid_t uid,
        return 0;
 }
 
-static int __handle_request_check(uid_t uid,
+static int __handle_request_check(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1025,7 +1030,7 @@ static int __handle_request_check(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_CHECK,
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_CHECK,
                                "default", pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(ii)", PKGMGR_R_ESYSTEM, 0));
@@ -1040,7 +1045,7 @@ static int __handle_request_check(uid_t uid,
        return 0;
 }
 
-static int __handle_request_generate_license_request(uid_t uid,
+static int __handle_request_generate_license_request(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -1061,7 +1066,7 @@ static int __handle_request_generate_license_request(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey,
+       if (_push_queue(caller_uid, caller_uid, reqkey,
                                REQUEST_TYPE_GENERATE_LICENSE_REQUEST,
                                "default", NULL, resp_data)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -1078,7 +1083,7 @@ static int __handle_request_generate_license_request(uid_t uid,
        return 0;
 }
 
-static int __handle_request_register_license(uid_t uid,
+static int __handle_request_register_license(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -1098,7 +1103,8 @@ static int __handle_request_register_license(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey, REQUEST_TYPE_REGISTER_LICENSE,
+       if (_push_queue(caller_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_REGISTER_LICENSE,
                                "default", NULL, resp_data)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
@@ -1113,7 +1119,7 @@ static int __handle_request_register_license(uid_t uid,
        return 0;
 }
 
-static int __handle_request_decrypt_package(uid_t uid,
+static int __handle_request_decrypt_package(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -1135,7 +1141,8 @@ static int __handle_request_decrypt_package(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey, REQUEST_TYPE_DECRYPT_PACKAGE,
+       if (_push_queue(caller_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_DECRYPT_PACKAGE,
                                "default", drm_file_path,
                                decrypted_file_path)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -1151,7 +1158,7 @@ static int __handle_request_decrypt_package(uid_t uid,
        return 0;
 }
 
-static int __update_app_splash_screen(uid_t uid,
+static int __update_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters,
                int req_type)
 {
@@ -1175,7 +1182,7 @@ static int __update_app_splash_screen(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, req_type, "default",
+       if (_push_queue(target_uid, caller_uid, reqkey, req_type, "default",
                                appid, NULL)) {
                ERR("Failed to push request");
                g_dbus_method_invocation_return_value(invocation,
@@ -1193,21 +1200,21 @@ static int __update_app_splash_screen(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_app_splash_screen(uid_t uid,
+static int __handle_request_enable_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
-       return __update_app_splash_screen(uid, invocation, parameters,
+       return __update_app_splash_screen(caller_uid, invocation, parameters,
                        REQUEST_TYPE_ENABLE_APP_SPLASH_SCREEN);
 }
 
-static int __handle_request_disable_app_splash_screen(uid_t uid,
+static int __handle_request_disable_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
-       return __update_app_splash_screen(uid, invocation, parameters,
+       return __update_app_splash_screen(caller_uid, invocation, parameters,
                        REQUEST_TYPE_DISABLE_APP_SPLASH_SCREEN);
 }
 
-static int __handle_request_set_restriction_mode(uid_t uid,
+static int __handle_request_set_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1231,7 +1238,7 @@ static int __handle_request_set_restriction_mode(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", mode);
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_SET_RESTRICTION_MODE,
                                "default", pkgid, buf)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -1247,7 +1254,7 @@ static int __handle_request_set_restriction_mode(uid_t uid,
        return 0;
 }
 
-static int __handle_request_unset_restriction_mode(uid_t uid,
+static int __handle_request_unset_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1271,7 +1278,7 @@ static int __handle_request_unset_restriction_mode(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", mode);
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_UNSET_RESTRICTION_MODE,
                                "default", pkgid, buf)) {
                g_dbus_method_invocation_return_value(invocation,
@@ -1287,7 +1294,7 @@ static int __handle_request_unset_restriction_mode(uid_t uid,
        return 0;
 }
 
-static int __handle_request_get_restriction_mode(uid_t uid,
+static int __handle_request_get_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1308,7 +1315,7 @@ static int __handle_request_get_restriction_mode(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_GET_RESTRICTION_MODE,
                                "default", pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
index f6ad233..b7891aa 100644 (file)
@@ -153,7 +153,7 @@ void _send_fail_signal(struct backend_job *job)
        pkgmgr_installer_set_request_type(pi, req_type);
        pkgmgr_installer_send_signal(pi, job->backend_type, job->pkgid,
                        "end", "fail");
-       n = __get_uid_list(job->uid, &uids);
+       n = __get_uid_list(job->target_uid, &uids);
        for (i = 0; i < n; i++)
                pkgmgr_installer_send_signal_for_uid(pi, uids[i],
                                job->backend_type, job->pkgid, "end", "fail");