remove CAP_MAC_OVERRIDE from app2sd-server
[platform/core/appfw/app2sd.git] / plugin / app2sd / src / app2sd_interface.c
index 7e52583..d7144fd 100644 (file)
@@ -734,8 +734,8 @@ END:
        return ret;
 }
 
-int app2sd_usr_move_installed_app(const char *pkgid, GList *dir_list,
-               app2ext_move_type move_type, uid_t uid)
+int app2sd_usr_pre_move_installed_app(const char *pkgid,
+               GList *dir_list, app2ext_move_type move_type, uid_t uid)
 {
        int ret = 0;
        int pkgmgr_ret = 0;
@@ -810,6 +810,67 @@ int app2sd_usr_move_installed_app(const char *pkgid, GList *dir_list,
        return APP2EXT_SUCCESS;
 }
 
+int app2sd_usr_post_move_installed_app(const char *pkgid,
+               app2ext_move_type move_type, uid_t uid)
+{
+       int ret = 0;
+       char application_path[FILENAME_MAX] = { 0, };
+       char loopback_device[FILENAME_MAX] = { 0, };
+       char *encoded_id = NULL;
+
+       /* validate function arguments */
+       if (pkgid == NULL || move_type < APP2EXT_MOVE_TO_EXT
+               || move_type > APP2EXT_MOVE_TO_PHONE) {
+               _E("invalid function arguments");
+               return APP2EXT_ERROR_INVALID_ARGUMENTS;
+       }
+
+       if (move_type == APP2EXT_MOVE_TO_PHONE)
+               return APP2EXT_SUCCESS;
+
+       /* check whether MMC is present or not */
+       ret = _app2sd_check_mmc_status();
+       if (ret) {
+               _E("MMC not preset OR Not ready(%d)", ret);
+               return APP2EXT_ERROR_MMC_STATUS;
+       }
+
+       encoded_id = _app2sd_get_encoded_name(pkgid, uid);
+       if (encoded_id == NULL)
+               return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+
+       snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
+                       APP2SD_PATH, encoded_id);
+       free(encoded_id);
+       if (_is_global(uid)) {
+               snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
+                       tzplatform_getenv(TZ_SYS_RW_APP), pkgid);
+       } else {
+               tzplatform_set_user(uid);
+               snprintf(application_path, FILENAME_MAX - 1, "%s/%s",
+                       tzplatform_getenv(TZ_USER_APP), pkgid);
+               tzplatform_reset_user();
+       }
+
+       ret = _app2sd_unmount_app_content(application_path);
+       if (ret)
+               _E("unmount error (%d)", ret);
+
+#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION
+       ret = _app2sd_dmcrypt_close_device(pkgid, uid);
+       if (ret)
+               _E("close dmcrypt device error(%d)", ret);
+#else
+       ret = _app2sd_remove_loopback_encryption_setup(loopback_device);
+       if (ret)
+               _E("unable to detach loopback setup for (%s)",
+                       loopback_device);
+#endif
+
+       sync();
+       return APP2EXT_SUCCESS;
+}
+
 int app2sd_usr_pre_app_upgrade(const char *pkgid, GList *dir_list,
                int size, uid_t uid)
 {