#define AUL_K_IS_SUBAPP "__AUL_IS_SUBAPP__"
/** AUL internal private key */
#define AUL_K_INSTANCE_ID "__AUL_INSTANCE_ID__"
+/** AUL internal private key */
+#define AUL_K_ORG_CALLER_UID "__AUL_ORG_CALLER_UID__"
/**
* @brief This is callback function for aul_launch_init
int aul_launch_app_with_result(const char *pkgname, bundle *kb,
void (*cbfunc) (bundle *, int, void *),
void *data);
+int aul_launch_app_with_result_for_uid(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data, uid_t uid);
int app_subapp_terminate_request(void);
int __call_aul_handler(aul_type type, bundle *kb);
gboolean __aul_glib_handler(gpointer data);
#define MAX_PAYLOAD_SIZE (1024 * 1024 * 1)
#define PATH_AMD_SOCK "/run/aul/daemons/.amd-sock"
-#ifdef TIZEN_FEATURE_DEFAULT_USER
#define REGULAR_UID_MIN 5000
+#ifdef TIZEN_FEATURE_DEFAULT_USER
static uid_t default_uid;
static int default_uid_initialized;
#endif
return 0;
}
+static void __create_socket_path(char *path_buf, int size, int pid, uid_t uid)
+{
+ if (uid < REGULAR_UID_MIN) {
+ snprintf(path_buf, size,
+ "/run/aul/daemons/%d/.app-sock-%d", uid, pid);
+ } else {
+ snprintf(path_buf, size,
+ "/run/aul/apps/%d/%d/.app-sock", uid, pid);
+ }
+}
+
API int aul_sock_create_server(int pid, uid_t uid)
{
struct sockaddr_un saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+
+ if (uid < REGULAR_UID_MIN) {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "/run/aul/daemons/%d", uid);
+
+ } else {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
"/run/aul/apps/%d/%d", uid, pid);
+ }
ret = mkdir(saddr.sun_path, 0700);
if (ret != 0) {
}
}
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "/run/aul/apps/%d/%d/.app-sock", uid, pid);
+ __create_socket_path(saddr.sun_path, sizeof(saddr.sun_path), pid, uid);
unlink(saddr.sun_path);
/* labeling to socket for SMACK */
int pgid;
pgid = getpgid(pid);
if (pgid > 1) {
- snprintf(p_saddr.sun_path, sizeof(p_saddr.sun_path),
- "/run/aul/apps/%d/%d/.app-sock",
- uid, pgid);
+ __create_socket_path(saddr.sun_path, sizeof(saddr.sun_path), pgid, uid);
if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
if (errno == EEXIST)
_D("pg path - already exists");
snprintf(saddr.sun_path, sizeof(saddr.sun_path),
"%s", PATH_AMD_SOCK);
} else {
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "/run/aul/apps/%d/%d/.app-sock", uid, pid);
+ __create_socket_path(saddr.sun_path, sizeof(saddr.sun_path), pid, uid);
}
retry_con:
ret = __recv_raw_with_fd(fd, pkt[i]->len, pkt[i]->data,
&recv_size);
- if (ret < 0 ) {
+ if (ret < 0) {
_E("recv error - %d", ret);
free(pkt[i]);
pkt[i] = NULL;
void (*cbfunc) (bundle *, int, void *),
void *data)
{
+ return aul_launch_app_with_result_for_uid(pkgname, kb, cbfunc, data, getuid());
+}
+
+API int aul_launch_app_with_result_for_uid(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data, uid_t uid)
+{
int ret;
char num_str[MAX_LOCAL_BUFSZ] = { 0, };
int num;
bundle_del(kb, AUL_K_SEQ_NUM);
bundle_add(kb, AUL_K_SEQ_NUM, num_str);
- ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
+ ret = app_request_to_launchpad_for_uid(APP_START_RES, pkgname, kb, uid);
if (ret > 0)
__add_resultcb(ret, cbfunc, data, num);
_D("%d %s %s", i++, key, val);
}
+static int __set_caller_info(bundle *kb)
+{
+ const char *caller_pid;
+ const char *caller_uid;
+
+ caller_pid = bundle_get_val(kb, AUL_K_CALLER_PID);
+ if (caller_pid == NULL) {
+ _E("Failed to get caller pid");
+ return AUL_R_EINVAL;
+ }
+
+ caller_uid = bundle_get_val(kb, AUL_K_CALLER_UID);
+ if (caller_uid == NULL) {
+ _E("Failed to get caller uid");
+ return AUL_R_EINVAL;
+ }
+
+ bundle_del(kb, AUL_K_ORG_CALLER_PID);
+ bundle_add(kb, AUL_K_ORG_CALLER_PID, caller_pid);
+ bundle_del(kb, AUL_K_ORG_CALLER_UID);
+ bundle_add(kb, AUL_K_ORG_CALLER_UID, caller_uid);
+
+ return AUL_R_OK;
+}
+
API int aul_forward_app(const char* pkgname, bundle *kb)
{
- char *caller;
int ret;
bundle *dupb;
bundle *outb;
if (pkgname == NULL || kb == NULL)
return AUL_R_EINVAL;
- caller = (char *)bundle_get_val(kb, AUL_K_CALLER_PID);
- if (caller == NULL) {
- _E("original msg doest not have caller pid");
+ if (__set_caller_info(kb) < 0)
return AUL_R_EINVAL;
- }
-
- bundle_del(kb, AUL_K_ORG_CALLER_PID);
- bundle_add(kb, AUL_K_ORG_CALLER_PID, caller);
dupb = bundle_dup(kb);
if (dupb == NULL) {
{
const char *pid_str;
const char *num_str;
+ const char *uid_str;
*outb = NULL;
_D("original msg is not msg with result");
}
+ uid_str = bundle_get_val(inb, AUL_K_ORG_CALLER_UID);
+ if (uid_str == NULL)
+ uid_str = bundle_get_val(inb, AUL_K_CALLER_UID);
+
+ if (uid_str == NULL) {
+ _E("Failed to find caller uid");
+ bundle_free(*outb);
+ *outb = NULL;
+ return AUL_R_EINVAL;
+ }
+ bundle_add(*outb, AUL_K_ORG_CALLER_UID, uid_str);
pid_str = bundle_get_val(inb, AUL_K_ORG_CALLER_PID);
if (pid_str) {
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_for_uid(pkgname, b, __aul_cb,
+ cb_info, uid);
} else {
SECURE_LOGD("pkg_name : %s - no result", pkgname);