+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlite3.h>
#include <tzplatform_config.h>
-#include <db-util.h>
#include "pkgmgr-info.h"
#include "pkgmgrinfo_debug.h"
if (fd == -1) {
_LOGE("FAIL : open %s : %s", dir,
strerror_r(errno, buf, sizeof(buf)));
+ free(fullpath);
return -1;
}
ret = fstat(fd, &sb);
_LOGE("FAIL : fstat %s : %s", dir,
strerror_r(errno, buf, sizeof(buf)));
close(fd);
+ free(fullpath);
return -1;
}
if (S_ISLNK(sb.st_mode)) {
_LOGE("FAIL : %s is symlink!", dir);
close(fd);
+ free(fullpath);
return -1;
}
ret = fchown(fd, uid, gid);
_LOGE("FAIL : fchown %s %d.%d, because %s", dir, uid,
gid, strerror_r(errno, buf, sizeof(buf)));
close(fd);
+ free(fullpath);
return -1;
}
close(fd);
tzplatform_reset_user();
}
/* just allow certain users to create the dbspace directory if needed. */
- if (uid_caller == ROOT_UID || uid_caller == APPFW_UID ||
- uid_caller == uid)
+ if (uid_caller == ROOT_UID || uid_caller == APPFW_UID)
_mkdir_for_user(db_path, uid, gid);
}
free(db_path);
API char *getUserPkgCertDBPath(void)
{
- return getUserPkgCertDBPathUID(_getuid());
-}
-
-API char *getUserPkgCertDBPathUID(uid_t uid)
-{
- char pkgmgr_cert_db[PATH_MAX];
- uid_t uid_caller = getuid();
- gid_t gid = ROOT_UID;
char *db_path;
+ char pkgmgr_cert_db[PATH_MAX];
- db_path = _get_db_path(uid);
- if (db_path == NULL) {
- _LOGE("Failed to get db path %d", uid);
- return NULL;
- }
+ db_path = _get_db_path(GLOBAL_USER);
snprintf(pkgmgr_cert_db, sizeof(pkgmgr_cert_db),
"%s/.pkgmgr_cert.db", db_path);
-
- if (uid != GLOBAL_USER && uid != ROOT_UID) {
- tzplatform_set_user(uid);
- gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
- tzplatform_reset_user();
- }
-
- /* just allow certain users to create the dbspace directory if needed. */
- if (uid_caller == ROOT_UID || uid_caller == APPFW_UID || uid_caller == uid)
- _mkdir_for_user(db_path, uid, gid);
-
free(db_path);
return strdup(pkgmgr_cert_db);
return PMINFO_R_ERROR;
}
- ret = db_util_open_with_options(db_path, &pkgmgr_parser_db,
- SQLITE_OPEN_READWRITE, NULL);
+ ret = __open_db(db_path, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE);
if (ret != SQLITE_OK) {
_LOGE("connect db failed!");
free(db_path);
/*Begin transaction*/
/* Setting Manifest DB */
- ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN DEFERRED", NULL, NULL, NULL);
tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Failed to begin transaction\n");
_LOGD("Transaction Begin\n");
ret = PMINFO_R_OK;
catch:
- sqlite3_close(pkgmgr_parser_db);
+ sqlite3_close_v2(pkgmgr_parser_db);
sqlite3_free(query);
return ret;
}