Robustness changes 31/27631/1 accepted/tizen/common/20140917.103347 submit/tizen_common/20140916.181156 submit/tizen_common/20140916.203010
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 12 Sep 2014 15:30:00 +0000 (17:30 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Tue, 16 Sep 2014 17:49:02 +0000 (19:49 +0200)
As Root user has no databases:
- getUserPkgCertDBPathUID()
-getUserPkgParserDBPathUID()
- getIconPath()
should fail if they call by root user

Change-Id: I3661d77c079d28d4fd3c7d14093183695a92489d
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
src/pkgmgr-info.c

index 8a6a6df..0a0c339 100755 (executable)
@@ -513,6 +513,10 @@ API char *getIconPath(uid_t uid)
        char * dir = NULL;
        struct passwd *userinfo = getpwuid(uid);
 
+       if (uid == 0) {
+               _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
+               return NULL;
+       }
        if (uid != GLOBAL_USER) {
                if (userinfo == NULL) {
                        _LOGE("getpwuid(%d) returns NULL !", uid);
@@ -559,6 +563,10 @@ API char *getUserPkgParserDBPathUID(uid_t uid)
        char * dir = NULL;
        struct passwd *userinfo = getpwuid(uid);
 
+       if (uid == 0) {
+               _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
+               return NULL;
+       }
        if (uid != GLOBAL_USER) {
                if (userinfo == NULL) {
                        _LOGE("getpwuid(%d) returns NULL !", uid);
@@ -616,8 +624,11 @@ API char *getUserPkgCertDBPathUID(uid_t uid)
        char * dir = NULL;
        struct passwd *userinfo = getpwuid(uid);
 
+       if (uid == 0) {
+               _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
+               return NULL;
+       }
        if (uid != GLOBAL_USER) {
-
                if (userinfo == NULL) {
                        _LOGE("getpwuid(%d) returns NULL !", uid);
                        return NULL;
@@ -668,8 +679,11 @@ API const char* getUserDesktopPath(uid_t uid)
        char * dir = NULL;
        struct passwd *userinfo = getpwuid(uid);
 
+       if (uid == 0) {
+               _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
+               return NULL;
+       }
        if (uid != GLOBAL_USER) {
-
                if (userinfo == NULL) {
                        _LOGE("getpwuid(%d) returns NULL !", uid);
                        return NULL;
@@ -709,8 +723,11 @@ API const char* getUserManifestPath(uid_t uid)
        char * dir = NULL;
        struct passwd *userinfo = getpwuid(uid);
 
+       if (uid == 0) {
+               _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
+               return NULL;
+       }
        if (uid != GLOBAL_USER) {
-
                if (userinfo == NULL) {
                        _LOGE("getpwuid(%d) returns NULL !", uid);
                        return NULL;