From f2b5166ac0aaf652f275d8b56c6ad22ab0fb9099 Mon Sep 17 00:00:00 2001 From: Sungbae Yoo Date: Tue, 14 Feb 2017 11:05:26 +0900 Subject: [PATCH] Ecryptfs: Change not to remain temporary directory after encryption Signed-off-by: Sungbae Yoo Change-Id: Idb1960af26e916dc6703224e41f0da99e46f0944 --- server/engine/encryption/ecryptfs-engine.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/engine/encryption/ecryptfs-engine.cpp b/server/engine/encryption/ecryptfs-engine.cpp index ece06ad..9eaef01 100644 --- a/server/engine/encryption/ecryptfs-engine.cpp +++ b/server/engine/encryption/ecryptfs-engine.cpp @@ -37,7 +37,7 @@ #define MEDIA_EXCLUSION_LIST "temp_video/Camera/DCIM:mp3|mpga|m4a|mp4|wav|amr|awb|wma|ogg|oga|aac|mka|flac|3gp|3ga|mid|midi|xmf|rtttl|rtx|ota|smf|spm|imy|mpeg|m4v|3gp|3gpp|3g2|3gpp2|wmv|asf|mkv|webm|ts|avi|jpg|jpeg|gif|png|bmp|wbmp|divx|flv|ac3|mov|tiff|f4v|mpeg3|voice" #define CIPHER_MODE "aes" -#define ENCRYPTION_CHECKER_NAME ".ecryptfs_encrypted" +#define ENCRYPTION_TMP_DIR ".ecryptfs_encrypted" #define ECRYPTFS_VERSION_MAJOR 0x00 @@ -348,7 +348,11 @@ void EcryptfsEngine::encrypt(const data &key, unsigned int options) try { unsigned long long totalSize = getAvailableSpace(source), current; - runtime::File tempDir(destination + "/" ENCRYPTION_CHECKER_NAME); + runtime::File tempDir(destination + "/" ENCRYPTION_TMP_DIR); + + if (tempDir.exists()) { + tempDir.remove(true); + } tempDir.makeDirectory(); if (!(options & OPTION_ONLY_NEW_FILE)) { @@ -383,9 +387,11 @@ void EcryptfsEngine::decrypt(const data &key, unsigned int options) try { unsigned long long totalSize = getAvailableSpace(source), current; - runtime::File tempDir(source + "/" ENCRYPTION_CHECKER_NAME); + runtime::File tempDir(source + "/" ENCRYPTION_TMP_DIR); runtime::File tempMountpoint(tempDir.getPath() + "/mount"); + tempDir.makeDirectory(); + tempMountpoint.makeDirectory(); ecryptfsMount(source, tempMountpoint.getPath(), key, 0); -- 2.34.1