Ecryptfs: Change not to remain temporary directory after encryption 30/114630/2
authorSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 14 Feb 2017 02:05:26 +0000 (11:05 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 14 Feb 2017 09:03:54 +0000 (01:03 -0800)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: Idb1960af26e916dc6703224e41f0da99e46f0944

server/engine/encryption/ecryptfs-engine.cpp

index ece06ad..9eaef01 100644 (file)
@@ -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);