summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>2014-09-10 12:22:22 +0200
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>2014-09-16 18:11:59 +0200
commita0d06ee82b4bba2887625578faaf334376686ca5 (patch)
treeab0d4644292b1a13a9a4dda6c4fcb5123de4ddc1
parenta40de8f8739e0e8ddc96fba1b884d4c692d9b8ae (diff)
downloadaul-1-sandbox/sdi2/backend.tar.gz
aul-1-sandbox/sdi2/backend.tar.bz2
aul-1-sandbox/sdi2/backend.zip
Fix applications management when a request is made by a process run as root.sandbox/sdi2/backend
When a request comes from ROOT User we switch from ROOT USER to default USER to allow launch etc... Change-Id: Ia5a2155351de6b3272569cb257eb04b5927a86d4 Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
-rwxr-xr-xam_daemon/amd_appinfo.c2
-rwxr-xr-xam_daemon/amd_request.c9
-rwxr-xr-xam_daemon/amd_request.h2
-rwxr-xr-xinclude/menu_db_util.h20
-rwxr-xr-xinclude/simple_util.h1
-rw-r--r--packaging/aul.spec1
-rwxr-xr-xsrc/mime.c4
7 files changed, 25 insertions, 14 deletions
diff --git a/am_daemon/amd_appinfo.c b/am_daemon/amd_appinfo.c
index 33ba9936..0e1b8629 100755
--- a/am_daemon/amd_appinfo.c
+++ b/am_daemon/amd_appinfo.c
@@ -372,7 +372,7 @@ int appinfo_init(struct appinfomgr **cf)
if (!_cf)
return -1;
- r = _read_pkg_info(_cf, getuid());
+ r = _read_pkg_info(_cf, GLOBAL_USER);
if (r != PMINFO_R_OK) {
_fini(_cf);
return -1;
diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c
index 882fffc4..349cfd35 100755
--- a/am_daemon/amd_request.c
+++ b/am_daemon/amd_request.c
@@ -301,8 +301,13 @@ 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_PKG_NAME);
- ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
-
+ if (cr.uid == 0) {
+ _E("Root user request to start app assumming this is done by system deamon... Please fix it...switch to DEFAULT_USER");
+ ret = _start_app(appid, kb, pkt->cmd, cr.pid, DEFAULT_USER, clifd);
+ }
+ else {
+ ret = _start_app(appid, kb, pkt->cmd, cr.pid, cr.uid, clifd);
+ }
if(ret > 0) {
item = calloc(1, sizeof(item_pkt_t));
item->pid = ret;
diff --git a/am_daemon/amd_request.h b/am_daemon/amd_request.h
index 3353c7e1..34e1376c 100755
--- a/am_daemon/amd_request.h
+++ b/am_daemon/amd_request.h
@@ -25,7 +25,5 @@
int _requset_init(struct amdmgr *amd);
-
-
#endif
diff --git a/include/menu_db_util.h b/include/menu_db_util.h
index f27067b6..1b0549cc 100755
--- a/include/menu_db_util.h
+++ b/include/menu_db_util.h
@@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdlib.h>
#include "simple_util.h"
-
#define MAX_PATH_LEN 1024
#define AUL_APP_INFO_FLD_PKG_NAME "package"
@@ -176,17 +175,21 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
return menu_info;
}
-static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data, uid_t uid)
{
app_info_from_db *menu_info = (app_info_from_db *)user_data;
char *package;
ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+ if(uid == 0) {
+ _E("Root user request to start app assumming this is done by system deamon... Please fix it...switch to DEFAULT_USER");
+ uid = DEFAULT_USER;
+ }
if (!menu_info)
return ret;
//is_admin is global
- if (getuid() != GLOBAL_USER)
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, getuid(), &package);
+ if (uid != GLOBAL_USER)
+ ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, uid, &package);
else
ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
if (package) {
@@ -205,7 +208,10 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath_user(
ail_filter_h filter;
ail_error_e ret;
int count;
-
+ if(uid == 0) {
+ _E("Root user request to start app assumming this is done by system deamon... Please fix it...switch to DEFAULT_USER");
+ uid = DEFAULT_USER;
+ }
if (apppath == NULL)
return NULL;
@@ -227,7 +233,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath_user(
}
if (uid != GLOBAL_USER)
- ret = ail_filter_count_usr_appinfo(filter, &count, getuid());
+ ret = ail_filter_count_usr_appinfo(filter, &count, uid);
else
ret = ail_filter_count_appinfo(filter, &count);
if (ret != AIL_ERROR_OK) {
@@ -242,7 +248,7 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath_user(
}
//is_admin is global
if (uid != GLOBAL_USER)
- ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, (void *)menu_info, getuid());
+ ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, (void *)menu_info, uid);
else
ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
diff --git a/include/simple_util.h b/include/simple_util.h
index f2ab683e..e0dc4c71 100755
--- a/include/simple_util.h
+++ b/include/simple_util.h
@@ -29,6 +29,7 @@
#include <tzplatform_config.h>
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define DEFAULT_USER tzplatform_getuid(TZ_SYS_DEFAULT_USER)
#undef LOG_TAG
#define LOG_TAG "AUL"
diff --git a/packaging/aul.spec b/packaging/aul.spec
index ae9b46ad..727d76c0 100644
--- a/packaging/aul.spec
+++ b/packaging/aul.spec
@@ -28,6 +28,7 @@ BuildRequires: pkgconfig(app-checker)
BuildRequires: pkgconfig(app-checker-server)
BuildRequires: pkgconfig(rua)
BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: libattr-devel
BuildRequires: pkgconfig(privacy-manager-client)
diff --git a/src/mime.c b/src/mime.c
index 9beb917b..0649e166 100755
--- a/src/mime.c
+++ b/src/mime.c
@@ -220,13 +220,13 @@ SLPAPI int aul_set_defapp_with_mime(const char *mimetype, const char *defapp)
}
static ail_cb_ret_e __defapp_with_mime_func(
- const ail_appinfo_h appinfo, void *user_data)
+ const ail_appinfo_h appinfo, void *user_data,uid_t uid)
{
char **package = (char **)user_data;
char *str;
//is_admin is_global
if (getuid() != GLOBAL_USER)
- ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, getuid(), &str);
+ ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, uid, &str);
else
ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
_D("defapp from desktop = %s", str);