enable dmcrypt feature 69/77169/2
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 29 Jun 2016 03:37:18 +0000 (12:37 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 30 Jun 2016 08:31:57 +0000 (17:31 +0900)
Change-Id: I3e35703905f523b727db2c5563bda23b5610ad07
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
CMakeLists.txt
inc/app2ext_interface.h
plugin/app2sd/CMakeLists.txt
plugin/app2sd/inc/app2sd_internals.h
plugin/app2sd/src/app2sd_interface.c
plugin/app2sd/src/app2sd_internals.c
test/src/test_app2ext.c

index d137387..111de35 100644 (file)
@@ -5,6 +5,8 @@ PROJECT(app2ext C)
 SET(VERSION_MAJOR 0)
 SET(VERSION "${VERSION_MAJOR}.4.2")
 
+ADD_DEFINITIONS("-DTIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION")
+
 #Add your submodule directory name
 ADD_SUBDIRECTORY(plugin/app2sd)
 
@@ -39,7 +41,6 @@ SET(libapp2ext_LDFLAGS " -L${LIB_INSTALL_DIR} -module -avoid-version -ldl ")
 SET(libapp2ext_CFLAGS  " ${CFLAGS} -fPIC ")
 
 ADD_DEFINITIONS("-DLIBPREFIX=\"${LIB_INSTALL_DIR}\"")
-#ADD_DEFINITIONS("-D_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION")
 
 ADD_LIBRARY(${APP2EXT} SHARED ${libapp2ext_SOURCES})
 SET_TARGET_PROPERTIES(${APP2EXT} PROPERTIES SOVERSION ${VERSION_MAJOR})
@@ -59,4 +60,3 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app2sd.pc DESTINATION ${LIB_INSTALL_DI
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/inc/app2ext_interface.h DESTINATION include)
 
 ADD_SUBDIRECTORY(test)
-
index 8811b8d..5d8853f 100644 (file)
@@ -156,7 +156,7 @@ typedef enum app2ext_error_t {
        APP2EXT_ERROR_OPERATION_NOT_PERMITTED,
        APP2EXT_ERROR_SAME_LOOPBACK_DEVICE_EXISTS,
        APP2EXT_ERROR_PKGMGR_ERROR,
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        APP2EXT_ERROR_SETUP_DMCRYPT_DEVICE,
        APP2EXT_ERROR_OPEN_DMCRYPT_DEVICE,
        APP2EXT_ERROR_CLOSE_DMCRYPT_DEVICE,
index 94c596f..1545c32 100644 (file)
@@ -33,8 +33,6 @@ SET(libapp2sd_SOURCES
 SET(libapp2sd_LDFLAGS " -L${LIB_INSTALL_DIR} -lcrypto -module -avoid-version ")
 SET(libapp2sd_CFLAGS  " ${CFLAGS} -fPIC ")
 
-#ADD_DEFINITIONS("-D_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION")
-
 ADD_LIBRARY(${APP2SD} SHARED ${libapp2sd_SOURCES})
 SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(${APP2SD} PROPERTIES VERSION ${VERSION})
index 2b9c2a3..9da353c 100644 (file)
@@ -174,7 +174,7 @@ int _app2sd_get_info_from_db(const char *filename, char **pkgid, uid_t *uid);
 int _app2sd_force_clean(const char *pkgid, const char *application_path,
                const char *loopback_device, uid_t uid);
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
 /*This function setup dmcrypt header in the app2sd file */
 int _app2sd_dmcrypt_setup_device(const char *pkgid,
                const char *loopback_device, bool is_dup, uid_t uid);
index be1ac65..7e52583 100644 (file)
@@ -47,7 +47,7 @@ int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid
        int ret = 0;
        int free_mmc_mem = 0;
        char *device_node = NULL;
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        char *devi = NULL;
 #endif
        char *result = NULL;
@@ -125,7 +125,7 @@ int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid
        ret = _app2sd_create_loopback_device(pkgid, loopback_device,
                (reqd_disk_size + PKG_BUF_SIZE));
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_setup_device(pkgid, loopback_device, false, uid);
        if (ret) {
                _E("dmcrypt setup device error");
@@ -185,7 +185,7 @@ int app2sd_usr_pre_app_install(const char *pkgid, GList *dir_list, int size, uid
 
 FINISH_OFF:
        if (device_node) {
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error(%d)", ret);
@@ -206,7 +206,7 @@ END:
                device_node = NULL;
        }
 
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        if (devi) {
                free(devi);
                devi = NULL;
@@ -261,7 +261,7 @@ int app2sd_usr_post_app_install(const char *pkgid,
        free(encoded_id);
 
        /* get the associated device node for SD card applicationer */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_name =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
        if (!device_name)
@@ -282,7 +282,7 @@ int app2sd_usr_post_app_install(const char *pkgid,
                return APP2EXT_ERROR_UNMOUNT;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret) {
                if (device_name) {
@@ -351,7 +351,7 @@ int app2sd_usr_on_demand_setup_init(const char *pkgid, uid_t uid)
        char loopback_device[FILENAME_MAX] = { 0, };
        char *encoded_id = NULL;
        char *device_node = NULL;
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        char *result = NULL;
 #endif
        FILE *fp = NULL;
@@ -396,7 +396,7 @@ int app2sd_usr_on_demand_setup_init(const char *pkgid, uid_t uid)
        }
        fclose(fp);
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_node =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
        if (device_node) {
@@ -503,7 +503,7 @@ int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid)
                return APP2EXT_ERROR_UNMOUNT;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error(%d)", ret);
@@ -571,7 +571,7 @@ int app2sd_usr_pre_app_uninstall(const char *pkgid, uid_t uid)
        fclose(fp);
 
        /* get the associated device node for SD card applicationer */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_node =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
 #else
@@ -579,7 +579,7 @@ int app2sd_usr_pre_app_uninstall(const char *pkgid, uid_t uid)
 #endif
        if (NULL == device_node) {
                /* do loopback setup */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
                ret = _app2sd_dmcrypt_open_device(pkgid, loopback_device,
                        false, uid, &device_node);
                if (ret) {
@@ -683,7 +683,7 @@ int app2sd_usr_post_app_uninstall(const char *pkgid, uid_t uid)
                goto END;
        }
        /* detach the loopback encryption setup for the application */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret) {
                _E("close dmcrypt device error(%d)", ret);
@@ -960,7 +960,7 @@ int app2sd_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
        }
 
        /* get the associated device node for SD card applicationer */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_node =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
 #else
@@ -968,7 +968,7 @@ int app2sd_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
 #endif
        if (NULL == device_node) {
                /* do loopback setup */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
                ret = _app2sd_dmcrypt_open_device(pkgid, loopback_device,
                        false, uid, &device_node);
                if (ret) {
@@ -1061,7 +1061,7 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
        free(encoded_id);
 
        /* get the associated device node for SD card applicationer */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_name =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
        if (!device_name) {
@@ -1085,7 +1085,7 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
                return APP2EXT_ERROR_UNMOUNT;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret) {
                if (device_name) {
index 92eb81a..83a8538 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "app2sd_internals.h"
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
 #define DMCRYPT_ITER_TIME      50
 #define DMCRYPT_KEY_LEN                128
 #endif
@@ -355,7 +355,7 @@ int _app2sd_remove_all_loopback_encryption_setups(const char *loopback_device)
        return ret;
 }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
 int _app2sd_dmcrypt_setup_device(const char *pkgid,
                const char *loopback_device, bool is_dup, uid_t uid)
 {
@@ -861,7 +861,7 @@ int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, uid_t uid)
        int reqd_size = 0;
        int reqd_disk_size = 0;
        char *device_node = NULL;
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        char *devi = NULL;
 #endif
        int free_mmc_mem = 0;
@@ -960,7 +960,7 @@ int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, uid_t uid)
                return ret;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_setup_device(pkgid, loopback_device, false, uid);
        if (ret) {
                _E("dmcrypt setup device error(%d)", ret);
@@ -1089,7 +1089,7 @@ int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, uid_t uid)
        if (ret)
                _E("unmount error (%d)", ret);
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error(%d)", ret);
@@ -1206,7 +1206,7 @@ int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list, uid_t uid)
                return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        device_node =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
 #else
@@ -1214,7 +1214,7 @@ int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list, uid_t uid)
 #endif
        if (NULL == device_node) {
                /* do loopback setup */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
                ret = _app2sd_dmcrypt_open_device(pkgid, loopback_device,
                        false, uid, &device_node);
                if (ret) {
@@ -1343,7 +1343,7 @@ int _app2sd_move_app_to_internal(const char *pkgid, GList *dir_list, uid_t uid)
                _E("unable to unmount SD directory for app (%s)",
                     pkgid);
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error(%d)", ret);
@@ -1465,7 +1465,7 @@ int _app2sd_duplicate_device(const char *pkgid,
 {
        int ret = 0;
        int err_res = 0;
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        char *devi = NULL;
        char *result = NULL;
        char *passwd = NULL;
@@ -1480,7 +1480,7 @@ int _app2sd_duplicate_device(const char *pkgid,
        }
 
        /* perform loopback encryption setup */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        dev_node = _app2sd_dmcrypt_duplicate_encryption_setup(pkgid,
                temp_loopback_device, uid);
        if (!dev_node) {
@@ -1556,7 +1556,7 @@ int _app2sd_duplicate_device(const char *pkgid,
                goto FINISH_OFF;
        }
 
-#if !defined(_APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
+#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION)
        if (devi) {
                free(devi);
                devi = NULL;
@@ -1567,7 +1567,7 @@ int _app2sd_duplicate_device(const char *pkgid,
 
 FINISH_OFF:
        if (dev_node) {
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
                ret = _app2sd_dmcrypt_close_device(temp_pkgid, uid);
                if (ret)
                        _E("close dmcrypt device error(%d)", ret);
@@ -1611,7 +1611,7 @@ int _app2sd_update_loopback_device_size(const char *pkgid,
        }
 
        /* get the associated device node for SD card applicatione */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        old_device_node =
                _app2sd_find_associated_dmcrypt_device_node(pkgid, uid);
 #else
@@ -1619,7 +1619,7 @@ int _app2sd_update_loopback_device_size(const char *pkgid,
 #endif
        if (NULL == old_device_node) {
                /* do loopback setup */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
                ret = _app2sd_dmcrypt_open_device(pkgid, loopback_device,
                        false, uid, &old_device_node);
                if (ret) {
@@ -1680,7 +1680,7 @@ int _app2sd_update_loopback_device_size(const char *pkgid,
                goto FINISH_OFF;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret) {
                _E("close dmcrypt device error(%d)", ret);
@@ -1738,7 +1738,7 @@ FINISH_OFF:
                old_device_node = NULL;
        }
 
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error(%d)", ret);
@@ -1777,7 +1777,7 @@ int _app2sd_force_clean(const char *pkgid, const char *application_path,
                _E("unable to unmount the app content (%d)", ret);
 
        /* detach the loopback encryption setup for the application */
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        ret = _app2sd_dmcrypt_close_device(pkgid, uid);
        if (ret)
                _E("close dmcrypt device error (%d)", ret);
index 93070d0..32861ad 100644 (file)
@@ -94,7 +94,7 @@ char error_list[COUNT_OF_ERROR_LIST][100] = {
        "APP2EXT_ERROR_OPERATION_NOT_PERMITTED",
        "APP2EXT_ERROR_SAME_LOOPBACK_DEVICE_EXISTS",
        "APP2EXT_ERROR_PKGMGR_ERROR",
-#ifdef _APPFW_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
        "APP2EXT_ERROR_SETUP_DMCRYPT_DEVICE",
        "APP2EXT_ERROR_OPEN_DMCRYPT_DEVICE",
        "APP2EXT_ERROR_CLOSE_DMCRYPT_DEVICE",