From: seolheui kim Date: Tue, 26 Jun 2018 06:29:16 +0000 (+0900) Subject: Add flag file to check ode progress for mount unit X-Git-Tag: submit/tizen_4.0/20180626.081405^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2aa2f307a008e9dc1ad0e4b5e329ab0476dbcd53;p=platform%2Fcore%2Fsecurity%2Fode.git Add flag file to check ode progress for mount unit - create & remove "/opt/etc/.odeprogress" file - fix to use klay filesystem for flag files Change-Id: Id0188a59468bc8a4aeb94f058cdf0bdec2916e66 Signed-off-by: seolheui kim --- diff --git a/server/internal-encryption.cpp b/server/internal-encryption.cpp index aaeb9e2..0c310f0 100644 --- a/server/internal-encryption.cpp +++ b/server/internal-encryption.cpp @@ -424,6 +424,9 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int showProgressUI("encrypt"); ::sleep(1); + runtime::File file("/opt/etc/.odeprogress"); + file.create(0640); + INFO(SINK, "Closing all known systemd services that might be using internal storage."); stopKnownSystemdUnits(); @@ -447,6 +450,8 @@ int InternalEncryptionServer::encrypt(const std::string& password, unsigned int ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "encrypted"); server.notify("InternalEncryptionServer::mount"); + file.remove(); + INFO(SINK, "Syncing disk and rebooting."); ::sync(); ::reboot(RB_AUTOBOOT); @@ -478,6 +483,9 @@ int InternalEncryptionServer::decrypt(const std::string& password) showProgressUI("decrypt"); ::sleep(1); + runtime::File file("/opt/etc/.odeprogress"); + file.create(0640); + if (engine->isMounted()) { INFO(SINK, "Closing all known systemd services that might be using internal storage."); stopKnownSystemdUnits(); @@ -502,6 +510,8 @@ int InternalEncryptionServer::decrypt(const std::string& password) INFO(SINK, "Decryption complete."); ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "unencrypted"); + file.remove(); + INFO(SINK, "Syncing disk and rebooting."); ::sync(); ::reboot(RB_AUTOBOOT); @@ -523,12 +533,8 @@ int InternalEncryptionServer::recovery() if (state == State::Unencrypted) return error::NoSuchDevice; - if (state == State::Corrupted) - Ext4Tool::mkfs(engine->getSource()); - - std::fstream fs; - fs.open("/opt/.factoryreset", std::ios::out); - fs.close(); + runtime::File file("/opt/.factoryreset"); + file.create(0640); ::sync(); try {