#define __AIL_H__
#include <stdbool.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <tzplatform_config.h>
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
+#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
+#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
+#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
+#define APP_INFO_DB_LABEL "ail::db"
#ifdef __cplusplus
extern "C" {
#include "ail.h"
#include "ail_private.h"
-#define OWNER_ROOT 0
-#define GROUP_MENU 6010
-#define BUFSZE 1024
-#define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
-#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
-#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
-#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
-#define APP_INFO_DB_LABEL "ail::db"
#ifdef _E
#undef _E
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
- _D("You are not an authorized user!\n");
- return AIL_ERROR_FAIL;
- }
+ _D("You are not root user!\n");
+ }
+ else {
const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
xsystem(argv_rm);
const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
xsystem(argv_rmjn);
-
+ }
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
_E("cannot load usr desktop directory.");
}
+
+#ifdef WRT_SMACK_ENABLED
+if (__is_authorized()) {
ret = initdb_change_perm(APP_INFO_DB_FILE);
if (ret == AIL_ERROR_FAIL) {
_E("cannot chown.");
}
-#ifdef WRT_SMACK_ENABLED
const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
xsystem(argv_smack);
const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
xsystem(argv_smackjn);
+}
#endif
return AIL_ERROR_OK;
}
.dbrw = NULL
};
+static char* getUserAppDB(void)
+{
+ if(getuid())
+ return tzplatform_mkpath(TZ_USER_HOME, ".applications/dbspace/.app_info.db");
+ else
+ return APP_INFO_DB_FILE;
+}
static ail_error_e db_do_prepare(sqlite3 *db, const char *query, sqlite3_stmt **stmt)
{
if(mode & DB_OPEN_RO) {
if (!db_info.dbro) {
//ret = db_util_open_with_options(APP_INFO_DB, &db_info.dbro, SQLITE_OPEN_READONLY, NULL);
- ret = db_util_open(APP_INFO_DB, &db_info.dbro, 0);
+ ret = db_util_open(getUserAppDB(), &db_info.dbro, 0);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
}
}
if(mode & DB_OPEN_RW) {
if (!db_info.dbrw) {
- ret = db_util_open(APP_INFO_DB, &db_info.dbrw, 0);
+ ret = db_util_open(getUserAppDB(), &db_info.dbrw, 0);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
}
}
#include "ail_sql.h"
#include "ail.h"
-#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
-#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
#define BUFSZE 4096
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
return count;
}
-
-
char *_pkgname_to_desktop(const char *package)
{
char *desktop;
+ char *desktop_path;
int size;
retv_if(!package, NULL);
- size = strlen(OPT_DESKTOP_DIRECTORY) + strlen(package) + 10;
+ if(getuid() > 0)
+ {
+ desktop_path = tzplatform_mkpath(TZ_USER_HOME, ".applications/desktop");
+ }
+ else
+ {
+ desktop_path = tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP);
+ }
+
+ size = strlen(desktop_path) + strlen(package) + 10;
desktop = malloc(size);
retv_if(!desktop, NULL);
- snprintf(desktop, size, OPT_DESKTOP_DIRECTORY"/%s.desktop", package);
-
- if (access(desktop, R_OK) == 0)
- return desktop;
+ snprintf(desktop, size, "%s/%s.desktop", desktop_path, package);
- snprintf(desktop, size, USR_DESKTOP_DIRECTORY"/%s.desktop", package);
+ _D("uid: %d / desktop: [%s]\n", getuid(), desktop);
return desktop;
}
return 0;
}
-
-
/* Manipulating desktop_info functions */
static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package)
{
static int is_initdb = -1;
+ _D("package - [%s].", package);
+
if(is_initdb == -1)
is_initdb = __is_ail_initdb();
info->desktop = _pkgname_to_desktop(package);
retv_if(!info->desktop, AIL_ERROR_FAIL);
+ _D("desktop - [%s].", info->desktop);
+
return AIL_ERROR_OK;
}
return AIL_ERROR_OK;
}
-
static ail_error_e _send_db_done_noti(noti_type type, const char *package)
{
char *type_string, *noti_string;
return AIL_ERROR_FAIL;
}
- size = strlen(package) + 8;
- noti_string = calloc(1, size);
+ size = snprintf(NULL, 0, "%s:%s:%u", type_string, package, getuid());
+ noti_string = (char*) calloc(size + 1, sizeof(char));
retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
- snprintf(noti_string, size, "%s:%s", type_string, package);
+ snprintf(noti_string, size + 1, "%s:%s:%u", type_string, package, getuid());
vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
_D("Noti : %s", noti_string);
int count;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- if (!__is_authorized()) {
- _E("You are not an authorized user on adding!\n");
- return -1;
- }
count = _count_all();
if (count <= 0) {
_D("Cannot create a table. Maybe there is already a table.");
}
}
-
ret = _init_desktop_info(&info, appid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ail_error_e ret;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- if (!__is_authorized()) {
- _E("You are not an authorized user on updating!\n");
- return -1;
- }
ret = _init_desktop_info(&info, appid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ail_error_e ret;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- if (!__is_authorized()) {
- _E("You are not an authorized user on removing!\n");
- return -1;
- }
ret = _remove_package(appid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
ail_error_e ret;
retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
- if (!__is_authorized()) {
- _E("You are not an authorized user on removing!\n");
- return -1;
- }
_D("ail_desktop_clean=%s",pkgid);
int count;
retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
- if (!__is_authorized()) {
- _E("You are not an authorized user on adding!\n");
- return -1;
- }
count = _count_all();
if (count <= 0) {
#include "ail.h"
#include "ail_private.h"
-#define OWNER_ROOT 0
-#define GROUP_MENU 6010
-#define BUFSZE 1024
-#define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
-#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
-#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
-#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
-#define APP_INFO_DB_LABEL "ail::db"
-
#ifdef _E
#undef _E
#endif
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
- _D("You are not an authorized user!\n");
- return AIL_ERROR_FAIL;
- }
-
+ _D("You are not root user!\n");
+ }
+ else {
const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
xsystem(argv_rm);
const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
xsystem(argv_rmjn);
-
+ }
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
_E("cannot load usr desktop directory.");
}
- ret = initdb_change_perm(APP_INFO_DB_FILE);
- if (ret == AIL_ERROR_FAIL) {
- _E("cannot chown.");
+ if (__is_authorized()) {
+ ret = initdb_change_perm(APP_INFO_DB_FILE);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot chown.");
+ }
+ const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+ xsystem(argv_smack);
+ const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_smackjn);
}
-
-#ifdef WRT_SMACK_ENABLED
- const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
- xsystem(argv_smack);
- const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
- xsystem(argv_smackjn);
-#endif
return AIL_ERROR_OK;
}
#include "ail.h"
#include "ail_private.h"
-#define OWNER_ROOT 0
-#define GROUP_MENU 6010
-#define BUFSZE 1024
-#define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
-#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
-#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
-#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
-#define APP_INFO_DB_LABEL "ail::db"
#ifdef _E
#undef _E
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
- _D("You are not an authorized user!\n");
- return AIL_ERROR_FAIL;
- }
-
+ _D("You are not root user!\n");
+ }
+ else {
const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
xsystem(argv_rm);
const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
xsystem(argv_rmjn);
+ }
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
_E("cannot load usr desktop directory.");
}
- ret = initdb_change_perm(APP_INFO_DB_FILE);
- if (ret == AIL_ERROR_FAIL) {
- _E("cannot chown.");
+ if (__is_authorized()) {
+ ret = initdb_change_perm(APP_INFO_DB_FILE);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot chown.");
+ }
+ const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+ xsystem(argv_smack);
+ const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_smackjn);
}
-
-#ifdef WRT_SMACK_ENABLED
- const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
- xsystem(argv_smack);
- const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
- xsystem(argv_smackjn);
-#endif
return AIL_ERROR_OK;
}