add free variables sandbox/sdi2/multiuseruid
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 3 Oct 2014 09:58:44 +0000 (11:58 +0200)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 3 Oct 2014 16:34:04 +0000 (18:34 +0200)
Change-Id: I512ab22c2e7e7dbffc18c6bbebb6372e067e38e3
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
src/ail_db.c
src/ail_desktop.c
tool/src/initdb_user.c

index 060d0ca..b5f69c3 100755 (executable)
@@ -102,6 +102,8 @@ static int ail_db_change_perm(const char *db_file, uid_t uid)
                if (ret == -1) {
                        strerror_r(errno, buf, sizeof(buf));
                        _E("FAIL : chown %s %d.%d, because %s", db_file, uid, userinfo->pw_gid, buf);
+                       if(journal_file)
+                               free(journal_file);
                        return AIL_ERROR_FAIL;
                }
 
@@ -144,7 +146,7 @@ char* ail_get_icon_path(uid_t uid)
                }
                asprintf(&result, "%s/.applications/icons/", userinfo->pw_dir);
        } else {
-               result = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
+               result = strdup(tzplatform_mkpath(TZ_SYS_RW_ICONS, "/"));
        }
        int ret = mkdir(result, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
        if (ret == -1 && errno != EEXIST) {
@@ -253,7 +255,7 @@ char* al_get_desktop_path(uid_t uid)
                }
                asprintf(&result, "%s/.applications/desktop/", userinfo->pw_dir);
        } else {
-               result = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
+               result = strdup(tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/"));
        }
                int ret = mkdir(result, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
                if (ret == -1 && errno != EEXIST) {
index bcfb253..cb14501 100755 (executable)
@@ -789,7 +789,7 @@ char *_pkgname_to_desktop(const char *package, uid_t uid)
 
        retv_if(!package, NULL);
 
-  desktop_path = al_get_desktop_path(uid);
+       desktop_path = al_get_desktop_path(uid);
 
        size = strlen(desktop_path) + strlen(package) + 10;
        desktop = malloc(size);
@@ -798,7 +798,8 @@ char *_pkgname_to_desktop(const char *package, uid_t uid)
   snprintf(desktop, size, "%s/%s.desktop", desktop_path, package);
 
   _D("uid: %d / desktop: [%s]\n",  uid, desktop);
-
+  if(desktop_path)
+               free(desktop_path);
        return desktop;
 }
 
index d6b102a..5c7dabf 100755 (executable)
@@ -169,16 +169,19 @@ static int __is_authorized()
 int main(int argc, char *argv[])
 {
        int ret;
+       char * db_path = ail_get_app_DB(getuid());
+       char * dbjournal_path = ail_get_app_DB_journal(getuid());
+       char * desktop_path = al_get_desktop_path(getuid());
 
        if (!__is_authorized()) {
                fprintf(stderr, "You are not an authorized user!\n");
                _D("You are root user! Please switch to a regular user\n");
        }
        else {
-               if(remove(ail_get_app_DB(getuid())))
-                       _E(" %s is not removed", ail_get_app_DB(getuid()));
-               if(remove(ail_get_app_DB_journal(getuid())))
-                       _E(" %s is not removed", ail_get_app_DB_journal(getuid()));
+               if(remove(db_path))
+                       _E(" %s is not removed", db_path);
+               if(remove(dbjournal_path))
+                       _E(" %s is not removed", dbjournal_path);
        }
        ret = setenv("AIL_INITDB", "1", 1);
        _D("AIL_INITDB : %d", ret);
@@ -187,11 +190,17 @@ int main(int argc, char *argv[])
                _D("Some Apps in the App Info DB.");
        }
 
-       ret = initdb_user_load_directory(al_get_desktop_path(getuid()));
+       ret = initdb_user_load_directory(desktop_path);
        if (ret == AIL_ERROR_FAIL) {
                _E("cannot load usr desktop directory.");
        }
 
+       if(db_path)
+               free(db_path);
+       if(dbjournal_path)
+               free(dbjournal_path);
+       if(desktop_path)
+               free(desktop_path);
        return AIL_ERROR_OK;
 }