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;
}
}
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) {
}
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) {
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);
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;
}
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);
_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;
}