summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiwoong Im <jiwoong.im@samsung.com>2015-09-14 17:09:54 +0900
committerJiwoong Im <jiwoong.im@samsung.com>2015-10-16 12:47:57 +0900
commitb4bfcb9e574a091d2196699988986f0936728b0a (patch)
treec00ac48c9d5de79df3c26887a6dae868725ea167
parent5c4ef725ead2a88cdfa7cdc2331bfd8f42daf8fa (diff)
downloadaul-1-b4bfcb9e574a091d2196699988986f0936728b0a.tar.gz
aul-1-b4bfcb9e574a091d2196699988986f0936728b0a.tar.bz2
aul-1-b4bfcb9e574a091d2196699988986f0936728b0a.zip
- aul_launch_app_for_uid aul_launch_app_with_result_for_uid - amd gets TARGET_UID if launch request comes from root. If TARGET_UID's state is online, send launch request to amd_session_agent. - remove checking root uid in amd_session_agent. Change-Id: I1aaa599ef7d7717e73e579811b2fff7211b350f8 Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rw-r--r--am_daemon/amd_request.c47
-rw-r--r--am_session_agent/agent.c2
-rw-r--r--include/app_sock.h6
-rw-r--r--include/aul.h3
-rwxr-xr-xinclude/aul_svc.h14
-rw-r--r--include/launch.h2
-rw-r--r--include/simple_util.h1
-rw-r--r--packaging/aul.manifest2
-rw-r--r--src/app_sock.c32
-rw-r--r--src/launch.c27
-rwxr-xr-xsrc/service.c70
-rw-r--r--test/aul_test.c23
12 files changed, 171 insertions, 58 deletions
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c
index 179a81bf..4bd3720a 100644
--- a/am_daemon/amd_request.c
+++ b/am_daemon/amd_request.c
@@ -36,6 +36,7 @@
#include <cynara-client.h>
#include <cynara-creds-socket.h>
#include <cynara-session.h>
+#include <systemd/sd-login.h>
#include "amd_config.h"
#include "simple_util.h"
@@ -48,6 +49,7 @@
#include "amd_app_group.h"
#define INHOUSE_UID tzplatform_getuid(TZ_USER_NAME)
+#define REGULAR_UID_MIN 5000
#define PRIVILEGE_APPMANAGER_LAUNCH "http://tizen.org/privilege/appmanager.launch"
#define PRIVILEGE_APPMANAGER_KILL "http://tizen.org/privilege/appmanager.kill"
@@ -478,7 +480,10 @@ static gboolean __request_handler(gpointer data)
int ret = -1;
char *appid;
char *term_pid;
+ char *target_uid;
+ char *state;
int pid;
+ int t_uid;
bundle *kb = NULL;
item_pkt_t *item;
struct appinfo *ai;
@@ -489,15 +494,17 @@ static gboolean __request_handler(gpointer data)
return FALSE;
}
- privilege = __convert_cmd_to_privilege(pkt->cmd);
- if (privilege) {
- ret = __check_privilege_by_cynara(clifd, privilege);
- if (ret < 0) {
- _E("request has been denied by smack");
- ret = -EILLEGALACCESS;
- __real_send(clifd, ret);
- free(pkt);
- return TRUE;
+ if (cr.uid >= REGULAR_UID_MIN) {
+ privilege = __convert_cmd_to_privilege(pkt->cmd);
+ if (privilege) {
+ ret = __check_privilege_by_cynara(clifd, privilege);
+ if (ret < 0) {
+ _E("request has been denied by smack");
+ ret = -EILLEGALACCESS;
+ __real_send(clifd, ret);
+ free(pkt);
+ return TRUE;
+ }
}
}
@@ -508,9 +515,25 @@ static gboolean __request_handler(gpointer data)
case APP_START_RES:
kb = bundle_decode(pkt->data, pkt->len);
appid = (char *)bundle_get_val(kb, AUL_K_APPID);
- if (cr.uid == 0) {
- _E("request from root, treat as global user");
- ret = _start_app(appid, kb, pkt->cmd, cr.pid, GLOBAL_USER, clifd);
+ if (cr.uid < REGULAR_UID_MIN) {
+ target_uid = bundle_get_val(kb, AUL_K_TARGET_UID);
+ if (target_uid != NULL) {
+ t_uid = atoi(target_uid);
+ sd_uid_get_state(t_uid, &state);
+ if (strcmp(state, "offline") &&
+ strcmp(state, "closing")) {
+ ret = _start_app(appid, kb, pkt->cmd, cr.pid,
+ t_uid, clifd);
+ } else {
+ _E("uid:%d session is %s", t_uid, state);
+ __real_send(clifd, AUL_R_ERROR);
+ return FALSE;
+ }
+ } else {
+ _E("request from root, treat as global user");
+ ret = _start_app(appid, kb, pkt->cmd, cr.pid,
+ GLOBAL_USER, clifd);
+ }
} else {
ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
}
diff --git a/am_session_agent/agent.c b/am_session_agent/agent.c
index 866287d1..52790a84 100644
--- a/am_session_agent/agent.c
+++ b/am_session_agent/agent.c
@@ -637,7 +637,7 @@ _static_ void __agent_main_loop(struct pollfd pfds[])
_E("Invalid caller uid");
goto end;
}
- if ((uid != 0) && (uid != getuid())) {
+ if (uid != getuid()) {
_E("Invalid request coming from another user");
goto end;
}
diff --git a/include/app_sock.h b/include/app_sock.h
index be8ecb73..b26852d1 100644
--- a/include/app_sock.h
+++ b/include/app_sock.h
@@ -97,14 +97,18 @@ typedef struct _pkt_t {
} pkt_t;
int __create_server_sock(int pid);
-int __create_client_sock(int pid);
+int __create_client_sock(int pid, uid_t uid);
int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_with_noreply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen);
+int __app_send_raw_with_delay_reply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
int __app_agent_send_raw(int uid, int cmd, unsigned char *kb_data, int datalen);
int __app_agent_send_raw_with_noreply(int uid, int cmd, unsigned char *kb_data, int datalen);
app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr);
app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen);
+app_pkt_t *__app_send_cmd_with_result_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen);
int __create_agent_client_sock(int uid);
int __create_server_sock_by_path(char *path);
int __create_sock_activation(void);
diff --git a/include/aul.h b/include/aul.h
index 64ae43d7..64c69d2f 100644
--- a/include/aul.h
+++ b/include/aul.h
@@ -159,6 +159,8 @@ typedef enum _aul_type{
#define AUL_K_CALLER_UID "__AUL_CALLER_UID__"
/** AUL public key - added for multiuser mode */
#define AUL_K_CALLEE_UID "__AUL_CALLEE_UID__"
+/** AUL public key - added for multiuser mode */
+#define AUL_K_TARGET_UID "__AUL_TARGET_UID__"
/** AUL public key - To check caller's secuirty */
#define AUL_K_CALLER_APPID "__AUL_CALLER_APPID__"
@@ -439,6 +441,7 @@ int aul_launch_local(bundle *b);
* None
*/
int aul_launch_app(const char *appid, bundle *kb);
+int aul_launch_app_for_uid(const char *appid, bundle *kb, uid_t uid);
/**
* @par Description:
diff --git a/include/aul_svc.h b/include/aul_svc.h
index c008133a..5bff303d 100755
--- a/include/aul_svc.h
+++ b/include/aul_svc.h
@@ -482,7 +482,7 @@ int aul_svc_set_category(bundle *b, const char *category);
*
*/
int aul_svc_run_service(bundle *b, int request_code, aul_svc_res_fn cbfunc, void *data);
-int aul_svc_run_service_with_uid(bundle *b, int request_code,
+int aul_svc_run_service_for_uid(bundle *b, int request_code,
aul_svc_res_fn cbfunc, void *data, uid_t uid);
/**
@@ -531,7 +531,7 @@ static int iter_fn(const char* appid, void *data)
*
*/
int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn, void *data);
-int aul_svc_get_list_with_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
+int aul_svc_get_list_for_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
void *data, uid_t uid);
/**
@@ -571,7 +571,7 @@ static int iter_fn(const char* appid, void *data)
*
*/
int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn, void *data);
-int aul_svc_get_all_defapps_with_uid(aul_svc_info_iter_fn iter_fn,
+int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
void *data, uid_t uid);
/**
@@ -899,7 +899,7 @@ int aul_svc_send_result(bundle *b, aul_svc_result_val result);
*/
int aul_svc_set_defapp(const char *op, const char *mime_type, const char *uri,
const char *defapp);
-int aul_svc_set_defapp_with_uid(const char *op, const char *mime_type, const char *uri,
+int aul_svc_set_defapp_for_uid(const char *op, const char *mime_type, const char *uri,
const char *defapp, uid_t uid);
/**
@@ -928,7 +928,7 @@ int aul_svc_set_defapp_with_uid(const char *op, const char *mime_type, const cha
*
*/
int aul_svc_unset_defapp(const char *defapp);
-int aul_svc_unset_defapp_with_uid(const char *defapp, uid_t uid);
+int aul_svc_unset_defapp_for_uid(const char *defapp, uid_t uid);
/**
* @par Description:
@@ -955,7 +955,7 @@ int aul_svc_unset_defapp_with_uid(const char *defapp, uid_t uid);
*
*/
int aul_svc_unset_all_defapps();
-int aul_svc_unset_all_defapps_with_uid(uid_t uid);
+int aul_svc_unset_all_defapps_for_uid(uid_t uid);
/**
* @par Description:
@@ -988,7 +988,7 @@ int aul_svc_unset_all_defapps_with_uid(uid_t uid);
*
*/
int aul_svc_is_defapp(const char *appid);
-int aul_svc_is_defapp_with_uid(const char *pkg_name, uid_t uid);
+int aul_svc_is_defapp_for_uid(const char *pkg_name, uid_t uid);
/**
diff --git a/include/launch.h b/include/launch.h
index ca4954ab..c38f6bb5 100644
--- a/include/launch.h
+++ b/include/launch.h
@@ -34,8 +34,10 @@ int aul_make_bundle_from_argv(int argc, char **argv, bundle **kb);
int app_start(bundle *kb);
int app_send_cmd(int pid, int cmd, bundle *kb);
+int app_send_cmd_for_uid(int pid, uid_t uid, int cmd, bundle *kb);
int app_send_cmd_with_noreply(int pid, int cmd, bundle *kb);
int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb);
+int app_request_to_launchpad_for_uid(int cmd, const char *pkgname, bundle *kb, uid_t uid);
int _app_start_res_prepare(bundle *kb);
int app_result(int cmd, bundle *kb, int launched_pid);
diff --git a/include/simple_util.h b/include/simple_util.h
index cf744e03..f9758db2 100644
--- a/include/simple_util.h
+++ b/include/simple_util.h
@@ -50,6 +50,7 @@
#define MAX_LOCAL_BUFSZ 128
#define MAX_PID_STR_BUFSZ 20
+#define MAX_UID_STR_BUFSZ 20
#define _E(fmt, arg...) LOGE(fmt, ##arg)
#define _D(fmt, arg...) LOGD(fmt, ##arg)
diff --git a/packaging/aul.manifest b/packaging/aul.manifest
index 9ec5c37f..0eb19502 100644
--- a/packaging/aul.manifest
+++ b/packaging/aul.manifest
@@ -4,5 +4,7 @@
</request>
<assign>
<filesystem path="/usr/bin/app_launcher" exec_label="User" />
+ <filesystem path="/usr/bin/aul_test" exec_label="User" />
+ <filesystem path="/usr/bin/open_app" exec_label="User" />
</assign>
</manifest>
diff --git a/src/app_sock.c b/src/app_sock.c
index 9d0f28c6..cf661b10 100644
--- a/src/app_sock.c
+++ b/src/app_sock.c
@@ -245,7 +245,7 @@ int __create_agent_client_sock(int uid)
}
-int __create_client_sock(int pid)
+int __create_client_sock(int pid, uid_t uid)
{
int fd = -1;
struct sockaddr_un saddr = { 0, };
@@ -268,7 +268,7 @@ int __create_client_sock(int pid)
}
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d", getuid(), pid);
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "/run/user/%d/%d", uid, pid);
retry_con:
ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
100 * 1000);
@@ -351,6 +351,11 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
*/
int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
{
+ return __app_send_raw_for_uid(pid, getuid(), cmd, kb_data, datalen);
+}
+
+int __app_send_raw_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
int fd;
int len;
int sent = 0;
@@ -364,7 +369,7 @@ int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
_D("pid(%d) : cmd(%d)", pid, cmd);
- fd = __create_client_sock(pid);
+ fd = __create_client_sock(pid, uid);
if (fd < 0)
return -ECOMM;
@@ -521,6 +526,11 @@ int __app_agent_send_raw_with_noreply(int uid, int cmd, unsigned char *kb_data,
int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int datalen)
{
+ return __app_send_raw_with_noreply_for_uid(pid, getuid(), cmd, kb_data, datalen);
+}
+
+int __app_send_raw_with_noreply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
int fd;
int len;
int sent = 0;
@@ -534,7 +544,7 @@ int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int da
_D("pid(%d) : cmd(%d)", pid, cmd);
- fd = __create_client_sock(pid);
+ fd = __create_client_sock(pid, uid);
if (fd < 0)
return -ECOMM;
@@ -567,6 +577,11 @@ int __app_send_raw_with_noreply(int pid, int cmd, unsigned char *kb_data, int da
int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, int datalen)
{
+ return __app_send_raw_with_delay_reply_for_uid(pid, getuid(), cmd, kb_data, datalen);
+}
+
+int __app_send_raw_with_delay_reply_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
int fd;
int len;
int sent = 0;
@@ -579,7 +594,7 @@ int __app_send_raw_with_delay_reply(int pid, int cmd, unsigned char *kb_data, in
_D("pid(%d) : cmd(%d)", pid, cmd);
- fd = __create_client_sock(pid);
+ fd = __create_client_sock(pid, uid);
if (fd < 0)
return -ECOMM;
@@ -681,6 +696,11 @@ app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data, int datalen)
{
+ return (app_pkt_t *)__app_send_cmd_with_result_for_uid(pid, getuid(), cmd, kb_data, datalen);
+}
+
+app_pkt_t *__app_send_cmd_with_result_for_uid(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen)
+{
int fd;
int len;
int ret;
@@ -688,7 +708,7 @@ app_pkt_t *__app_send_cmd_with_result(int pid, int cmd, unsigned char *kb_data,
app_pkt_t *pkt = NULL;
unsigned char buf[AUL_SOCK_MAXBUFF];
- fd = __create_client_sock(pid);
+ fd = __create_client_sock(pid, uid);
if (fd < 0)
return NULL;
diff --git a/src/launch.c b/src/launch.c
index 62ce686a..0ff4b795 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -193,12 +193,17 @@ SLPAPI int app_agent_send_cmd_with_noreply(int uid, int cmd, bundle *kb)
*/
SLPAPI int app_send_cmd(int pid, int cmd, bundle *kb)
{
+ return app_send_cmd_for_uid(pid, getuid(), cmd, kb);
+}
+
+SLPAPI int app_send_cmd_for_uid(int pid, uid_t uid, int cmd, bundle *kb)
+{
int datalen;
bundle_raw *kb_data;
int res;
bundle_encode(kb, &kb_data, &datalen);
- if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+ if ((res = __app_send_raw_for_uid(pid, uid, cmd, kb_data, datalen)) < 0)
res = __get_aul_error(res);
free(kb_data);
@@ -279,6 +284,11 @@ static int __app_resume_local()
*/
int app_request_to_launchpad(int cmd, const char *appid, bundle *kb)
{
+ return app_request_to_launchpad_for_uid(cmd, appid, kb, getuid());
+}
+
+int app_request_to_launchpad_for_uid(int cmd, const char *appid, bundle *kb, uid_t uid)
+{
int must_free = 0;
int ret = 0;
@@ -291,7 +301,7 @@ int app_request_to_launchpad(int cmd, const char *appid, bundle *kb)
bundle_add(kb, AUL_K_APPID, appid);
__set_stime(kb);
- ret = app_send_cmd(AUL_UTIL_PID, cmd, kb);
+ ret = app_send_cmd_for_uid(AUL_UTIL_PID, uid, cmd, kb);
_D("launch request result : %d", ret);
if (ret == AUL_R_LOCAL) {
@@ -526,6 +536,19 @@ SLPAPI int aul_launch_app(const char *appid, bundle *kb)
return ret;
}
+SLPAPI int aul_launch_app_for_uid(const char *appid, bundle *kb, uid_t uid)
+{
+ int ret;
+ char buf[MAX_PID_STR_BUFSZ];
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+ snprintf(buf, MAX_UID_STR_BUFSZ, "%d", uid);
+ bundle_add(kb, AUL_K_TARGET_UID, buf);
+
+ ret = app_request_to_launchpad_for_uid(APP_START, appid, kb, uid);
+ return ret;
+}
+
SLPAPI int aul_open_app(const char *appid)
{
int ret;
diff --git a/src/service.c b/src/service.c
index 011b6180..3efd3557 100755
--- a/src/service.c
+++ b/src/service.c
@@ -74,7 +74,7 @@ static void __remove_rescb(aul_svc_cb_info_t *info);
static int __set_bundle(bundle *b, const char *key, const char *value);
static void __aul_cb(bundle *b, int is_cancel, void *data);
static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data);
+ aul_svc_res_fn cbfunc, void *data, uid_t uid);
static int __get_resolve_info(bundle *b, aul_svc_resolve_info_t *info);
static int __free_resolve_info_data(aul_svc_resolve_info_t *info);
@@ -199,7 +199,7 @@ static void __aul_cb(bundle *b, int is_cancel, void *data)
}
static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
- aul_svc_res_fn cbfunc, void *data)
+ aul_svc_res_fn cbfunc, void *data, uid_t uid)
{
aul_svc_cb_info_t *cb_info = NULL;
int ret = -1;
@@ -228,7 +228,8 @@ static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
SECURE_LOGD("pkg_name : %s - with result", pkgname);
cb_info = __create_rescb(request_code, cbfunc, data);
- ret = aul_launch_app_with_result(pkgname, b, __aul_cb, cb_info);
+ ret = aul_launch_app_with_result(pkgname, b, __aul_cb,
+ cb_info);
} else {
SECURE_LOGD("pkg_name : %s - no result", pkgname);
@@ -244,7 +245,7 @@ static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
ret = aul_launch_app(pkgname, b);
}
#else
- ret = aul_launch_app(pkgname, b);
+ ret = aul_launch_app_for_uid(pkgname, b, uid);
#endif
}
@@ -726,10 +727,10 @@ SLPAPI int aul_svc_run_service(bundle *b, int request_code,
aul_svc_res_fn cbfunc,
void *data)
{
- return aul_svc_run_service_with_uid(b, request_code, cbfunc, data, getuid());
+ return aul_svc_run_service_for_uid(b, request_code, cbfunc, data, getuid());
}
-SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
+SLPAPI int aul_svc_run_service_for_uid(bundle *b, int request_code,
aul_svc_res_fn cbfunc,
void *data, uid_t uid)
{
@@ -755,7 +756,8 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
if (pkgname) {
if (operation == NULL)
aul_svc_set_operation(b, AUL_SVC_OPERATION_DEFAULT);
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc,
+ data, uid);
return ret;
}
@@ -763,7 +765,8 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
if (operation && (strcmp(operation, AUL_SVC_OPERATION_SHARE) == 0
|| strcmp(operation, AUL_SVC_OPERATION_MULTI_SHARE) == 0
|| strcmp(operation, AUL_SVC_OPERATION_SHARE_TEXT) == 0)) {
- ret = __run_svc_with_pkgname(SHARE_PANEL, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(SHARE_PANEL, b, request_code,
+ cbfunc, data, uid);
return ret;
}
@@ -821,12 +824,14 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
if (pkg_count == 1) {
pkgname = (char *)pkg_list->data;
if (pkgname != NULL) {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
goto end;
}
} else {
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri);
- ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
+ cbfunc, data, uid);
goto end;
}
for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
@@ -837,7 +842,8 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
pkg_list = NULL;
}
} else {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
free(pkgname);
goto end;
}
@@ -875,12 +881,14 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
if (pkg_count == 1) {
pkgname = (char *)pkg_list->data;
if (pkgname != NULL) {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
goto end;
}
} else {
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.uri_r_info);
- ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
+ cbfunc, data, uid);
goto end;
}
}
@@ -891,7 +899,8 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
g_slist_free(pkg_list);
pkg_list = NULL;
} else {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
free(pkgname);
goto end;
}
@@ -925,14 +934,16 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
if (pkg_count == 1) {
pkgname = (char *)pkg_list->data;
if (pkgname != NULL) {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
}
} else if (pkg_count < 1) {
__free_resolve_info_data(&info);
return AUL_SVC_RET_ENOMATCH;
} else {
bundle_add(b, AUL_SVC_K_URI_R_INFO, info.scheme);
- ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code,
+ cbfunc, data, uid);
}
for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
@@ -941,7 +952,8 @@ SLPAPI int aul_svc_run_service_with_uid(bundle *b, int request_code,
}
g_slist_free(pkg_list);
} else {
- ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+ ret = __run_svc_with_pkgname(pkgname, b, request_code,
+ cbfunc, data, uid);
free(pkgname);
}
@@ -954,10 +966,10 @@ end:
SLPAPI int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn,
void *data)
{
- return aul_svc_get_list_with_uid(b, iter_fn, data, getuid());
+ return aul_svc_get_list_for_uid(b, iter_fn, data, getuid());
}
-SLPAPI int aul_svc_get_list_with_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
+SLPAPI int aul_svc_get_list_for_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
void *data, uid_t uid)
{
aul_svc_resolve_info_t info;
@@ -1040,10 +1052,10 @@ SLPAPI int aul_svc_get_list_with_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
SLPAPI int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn, void *data)
{
- return aul_svc_get_all_defapps_with_uid(iter_fn, data, getuid());
+ return aul_svc_get_all_defapps_for_uid(iter_fn, data, getuid());
}
-SLPAPI int aul_svc_get_all_defapps_with_uid(aul_svc_info_iter_fn iter_fn,
+SLPAPI int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
void *data, uid_t uid)
{
char *pkgname = NULL;
@@ -1177,10 +1189,10 @@ SLPAPI int aul_svc_set_defapp(const char *op, const char *mime_type,
const char *uri,
const char *defapp)
{
- return aul_svc_set_defapp_with_uid(op, mime_type, uri, defapp, getuid());
+ return aul_svc_set_defapp_for_uid(op, mime_type, uri, defapp, getuid());
}
-SLPAPI int aul_svc_set_defapp_with_uid(const char *op, const char *mime_type,
+SLPAPI int aul_svc_set_defapp_for_uid(const char *op, const char *mime_type,
const char *uri,
const char *defapp,
uid_t uid)
@@ -1206,10 +1218,10 @@ SLPAPI int aul_svc_set_defapp_with_uid(const char *op, const char *mime_type,
SLPAPI int aul_svc_unset_defapp(const char *defapp)
{
- return aul_svc_unset_defapp_with_uid(defapp, getuid());
+ return aul_svc_unset_defapp_for_uid(defapp, getuid());
}
-SLPAPI int aul_svc_unset_defapp_with_uid(const char *defapp, uid_t uid)
+SLPAPI int aul_svc_unset_defapp_for_uid(const char *defapp, uid_t uid)
{
int ret;
@@ -1232,10 +1244,10 @@ SLPAPI int aul_svc_unset_defapp_with_uid(const char *defapp, uid_t uid)
SLPAPI int aul_svc_unset_all_defapps()
{
- return aul_svc_unset_all_defapps_with_uid(getuid());
+ return aul_svc_unset_all_defapps_for_uid(getuid());
}
-SLPAPI int aul_svc_unset_all_defapps_with_uid(uid_t uid)
+SLPAPI int aul_svc_unset_all_defapps_for_uid(uid_t uid)
{
int ret;
@@ -1255,10 +1267,10 @@ SLPAPI int aul_svc_unset_all_defapps_with_uid(uid_t uid)
SLPAPI int aul_svc_is_defapp(const char *pkg_name)
{
- return aul_svc_is_defapp_with_uid(pkg_name, getuid());
+ return aul_svc_is_defapp_for_uid(pkg_name, getuid());
}
-SLPAPI int aul_svc_is_defapp_with_uid(const char *pkg_name, uid_t uid)
+SLPAPI int aul_svc_is_defapp_for_uid(const char *pkg_name, uid_t uid)
{
int ret;
diff --git a/test/aul_test.c b/test/aul_test.c
index f12b5d1b..e00c3615 100644
--- a/test/aul_test.c
+++ b/test/aul_test.c
@@ -85,6 +85,27 @@ int launch_test()
return ret;
}
+int launch_test_for_uid()
+{
+ static int num = 0;
+ int ret = 0;
+ bundle *kb = NULL;
+
+ kb = create_internal_bundle(3);
+ if (NULL == kb) {
+ return -1;
+ }
+ printf("[aul_launch_app %d test] %s \n", num++, gargv[2]);
+
+ ret = aul_launch_app_for_uid(gargv[2], kb, atoi(gargv[3]));
+
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return ret;
+}
+
int dbus_launch_test()
{
bundle *kb = NULL;
@@ -543,6 +564,8 @@ int reload_appinfo(void)
static test_func_t test_func[] = {
{"launch",launch_test,"aul_launch_app test",
"[usage] launch <pkgname> <key1> <val1> <key2> <val2> ..."},
+ {"launch_for_uid", launch_test_for_uid, "launch with uid test",
+ "[usage] launch_for_uid <appid> <uid>"},
{"open",open_test,"aul_open_app test",
"[usage] open <pkgname>" },
{"resume",resume_test,"aul_resume_app test",