From fccbca5bfa4ed86ac026b5055773976d6a4648bb Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Fri, 22 Jul 2016 11:51:10 +0900 Subject: [PATCH] fix problems in case both global and local are installed/removed - bugfix deleting entire app directory. - use composite primary key of app2sd_info table to save both local and global app. - always overwrite same extimg file. Change-Id: I25b70cc88188a96b729cd16982722efe66a4b5a0 Signed-off-by: jongmyeongko --- common/src/app2ext_utils.c | 3 --- plugin/app2sd/src/app2sd_interface.c | 18 ++++++++---------- plugin/app2sd/src/app2sd_internals.c | 19 +++++++++++-------- plugin/app2sd/src/app2sd_internals_registry.c | 4 ++-- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/common/src/app2ext_utils.c b/common/src/app2ext_utils.c index d8c0845..54d54dc 100644 --- a/common/src/app2ext_utils.c +++ b/common/src/app2ext_utils.c @@ -41,12 +41,9 @@ char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid) checksum = g_checksum_new(G_CHECKSUM_MD5); g_checksum_update(checksum, (const guchar *)source_name, strlen(source_name)); temp_string = (char *)g_checksum_get_string(checksum); - _D("temp_string(%s)", temp_string); new_name = strdup(temp_string); g_checksum_free(checksum); - _D("new_name(%s)", new_name); - return new_name; } diff --git a/plugin/app2sd/src/app2sd_interface.c b/plugin/app2sd/src/app2sd_interface.c index 1e3c217..e769a9d 100644 --- a/plugin/app2sd/src/app2sd_interface.c +++ b/plugin/app2sd/src/app2sd_interface.c @@ -51,7 +51,6 @@ int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid #if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION) char *devi = NULL; #endif - char *result = NULL; char application_path[FILENAME_MAX] = { 0, }; char loopback_device[FILENAME_MAX] = { 0, }; char *encoded_id = NULL; @@ -115,13 +114,6 @@ int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid return ret; } - /* check same loopback_device existence */ - result = (char *)_app2sd_find_associated_device(loopback_device); - if (result != NULL) { - _E("there is same associated File (%s)", loopback_device); - return APP2EXT_ERROR_SAME_LOOPBACK_DEVICE_EXISTS; - } - /* create a loopback device */ ret = _app2sd_create_loopback_device(pkgid, loopback_device, (reqd_disk_size + PKG_BUF_SIZE)); @@ -222,6 +214,7 @@ int app2sd_usr_post_app_install(const char *pkgid, { char *device_name = NULL; char application_path[FILENAME_MAX] = { 0, }; + char application_mmc_path[FILENAME_MAX] = { 0, }; char loopback_device[FILENAME_MAX] = { 0, }; char *encoded_id = NULL; int ret = APP2EXT_SUCCESS; @@ -260,6 +253,8 @@ int app2sd_usr_post_app_install(const char *pkgid, tzplatform_reset_user(); } free(encoded_id); + snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc", + application_path); /* get the associated device node for SD card applicationer */ #ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION @@ -325,7 +320,7 @@ int app2sd_usr_post_app_install(const char *pkgid, if (ret) _E("unable to delete info"); - ret = _app2sd_delete_directory(application_path); + ret = _app2sd_delete_directory(application_mmc_path); if (ret) _E("unable to delete the directory (%s)", application_path); } else { @@ -702,6 +697,7 @@ END: int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid) { char application_path[FILENAME_MAX] = { 0, }; + char application_mmc_path[FILENAME_MAX] = { 0, }; char loopback_device[FILENAME_MAX] = { 0, }; char *encoded_id = NULL; int ret = APP2EXT_SUCCESS; @@ -739,6 +735,8 @@ int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid) tzplatform_reset_user(); } free(encoded_id); + snprintf(application_mmc_path, FILENAME_MAX - 1, "%s/.mmc", + application_path); /* unmount the loopback encrypted pseudo device from * the application installation path @@ -775,7 +773,7 @@ int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid) goto END; } - ret = _app2sd_delete_directory(application_path); + ret = _app2sd_delete_directory(application_mmc_path); if (ret) { _E("unable to delete the directory (%s)", application_path); diff --git a/plugin/app2sd/src/app2sd_internals.c b/plugin/app2sd/src/app2sd_internals.c index a4aa897..4b90113 100644 --- a/plugin/app2sd/src/app2sd_internals.c +++ b/plugin/app2sd/src/app2sd_internals.c @@ -43,7 +43,7 @@ static int _app2sd_make_directory(const char *path, uid_t uid) ret = _app2sd_delete_directory(path); if (ret) { - _E("unable to delete (%s)", path); + _E("unable to delete (%s), errno(%d)", path, errno); return APP2EXT_ERROR_DELETE_DIRECTORY; } @@ -794,13 +794,16 @@ int _app2sd_mount_app_content(const char *application_path, const char *pkgid, pkgid, dir_list, uid); } - /* change lost+found permission */ - snprintf(temp_path, FILENAME_MAX - 1, "%s/lost+found", - application_mmc_path); - ret = _app2sd_make_directory(temp_path, uid); - if (ret) { - _E("create directory(%s) failed", temp_path); - return APP2EXT_ERROR_CREATE_DIRECTORY; + if (mount_type != MOUNT_TYPE_RD && + mount_type != MOUNT_TYPE_RD_REMOUNT) { + /* change lost+found permission */ + snprintf(temp_path, FILENAME_MAX - 1, "%s/lost+found", + application_mmc_path); + ret = _app2sd_make_directory(temp_path, uid); + if (ret) { + _E("create directory(%s) failed", temp_path); + return APP2EXT_ERROR_CREATE_DIRECTORY; + } } return ret; diff --git a/plugin/app2sd/src/app2sd_internals_registry.c b/plugin/app2sd/src/app2sd_internals_registry.c index b94dd9f..846d121 100644 --- a/plugin/app2sd/src/app2sd_internals_registry.c +++ b/plugin/app2sd/src/app2sd_internals_registry.c @@ -37,8 +37,8 @@ #define APP2SD_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".app2sd.db") sqlite3 *app2sd_db; #define QUERY_CREATE_TABLE_APP2SD "CREATE TABLE IF NOT EXISTS app2sd_info " \ - "(pkgid TEXT PRIMARY KEY NOT NULL, password TEXT NOT NULL, " \ - "filename TEXT NOT NULL, uid INTEGER)" + "(pkgid TEXT NOT NULL, password TEXT NOT NULL, " \ + "filename TEXT NOT NULL, uid INTEGER, PRIMARY KEY(pkgid, uid))" int _app2sd_initialize_db() { -- 2.7.4