INFO("Close all applications using external storage...");
killDependedApplications();
- INFO("Umount internal storage...");
+ INFO("Umount external storage...");
engine.umount();
return 0;
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto encryptWorker = [&MasterKey, options, this]() {
- INFO("Close all applications using external storage...");
- killDependedApplications();
- INFO("Encryption started...");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- engine.encrypt(MasterKey, options);
- setOptions(options & getSupportedOptions());
- INFO("Sync disk...");
- sync();
- INFO("Encryption completed");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
+ try {
+ INFO("Close all applications using external storage...");
+ killDependedApplications();
+ INFO("Encryption started...");
+ ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ engine.encrypt(MasterKey, options);
+ setOptions(options & getSupportedOptions());
+ INFO("Sync disk...");
+ sync();
+ INFO("Encryption completed");
+ ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
+ } catch (runtime::Exception &e) {
+ ERROR("Encryption failed - " + std::string(e.what()));
+ }
};
std::thread asyncWork(encryptWorker);
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto decryptWorker = [MasterKey, this]() {
- INFO("Close all applications using external storage...");
- killDependedApplications();
- INFO("Umount internal storage...");
try {
- engine.umount();
- } catch (runtime::Exception &e) {}
-
- INFO("Decryption started...");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- engine.decrypt(MasterKey, getOptions());
- INFO("Sync disk...");
- sync();
- INFO("Decryption completed");
- ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "unencrypted");
+ INFO("Close all applications using external storage...");
+ killDependedApplications();
+ INFO("Umount external storage...");
+ while (1) {
+ try {
+ engine.umount();
+ break;
+ } catch (runtime::Exception &e) {
+ killDependedApplications();
+ }
+ }
+
+ INFO("Decryption started...");
+ ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ engine.decrypt(MasterKey, getOptions());
+ INFO("Sync disk...");
+ sync();
+ INFO("Decryption completed");
+ ::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "unencrypted");
+ } catch (runtime::Exception &e) {
+ ERROR("Decryption failed - " + std::string(e.what()));
+ }
};
std::thread asyncWork(decryptWorker);
return 0;
}
-
-
int ExternalEncryption::getState()
{
char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto encryptWorker = [&MasterKey, options, this]() {
- showProgressUI("Encrypting");
-
- INFO("Close all processes using internal storage...");
- stopDependedSystemdServices();
- INFO("Umount internal storage...");
- while (::umount(INTERNAL_STORAGE_PATH) == -1) {
- if (errno != EBUSY) {
- break;
+ try {
+ showProgressUI("Encrypting");
+
+ INFO("Close all processes using internal storage...");
+ stopDependedSystemdServices();
+ INFO("Umount internal storage...");
+ while (::umount(INTERNAL_STORAGE_PATH) == -1) {
+ if (errno != EBUSY) {
+ throw runtime::Exception("Umount error - " + std::to_string(errno));
+ }
+ stopDependedSystemdServices();
}
- }
- INFO("Encryption started...");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- engine.encrypt(MasterKey, options);
- setOptions(options & getSupportedOptions());
- INFO("Sync disk...");
- sync();
- INFO("Encryption completed");
+ INFO("Encryption started...");
+ ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ engine.encrypt(MasterKey, options);
+ setOptions(options & getSupportedOptions());
+ INFO("Sync disk...");
+ sync();
+ INFO("Encryption completed");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "encrypted");
+ ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "encrypted");
+ } catch (runtime::Exception &e) {
+ ERROR("Encryption failed - " + std::string(e.what()));
+ }
::reboot(RB_AUTOBOOT);
};
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto decryptWorker = [MasterKey, this]() {
- showProgressUI("Decrypting");
-
- INFO("Close all processes using internal storage...");
- stopDependedSystemdServices();
- INFO("Umount internal storage...");
try {
- engine.umount();
- } catch (runtime::Exception& e) {}
+ showProgressUI("Decrypting");
+
+ INFO("Close all processes using internal storage...");
+ stopDependedSystemdServices();
+ INFO("Umount internal storage...");
+ while (1) {
+ try {
+ engine.umount();
+ break;
+ } catch (runtime::Exception& e) {
+ stopDependedSystemdServices();
+ }
+ }
- INFO("Decryption started...");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- engine.decrypt(MasterKey, getOptions());
- INFO("Sync disk...");
- sync();
- INFO("Decryption completed");
+ INFO("Decryption started...");
+ ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ engine.decrypt(MasterKey, getOptions());
+ INFO("Sync disk...");
+ sync();
+ INFO("Decryption completed");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "unencrypted");
+ ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "unencrypted");
+ } catch (runtime::Exception &e) {
+ ERROR("Decryption failed - " + std::string(e.what()));
+ }
::reboot(RB_AUTOBOOT);
};
return 0;
}
-
-
int InternalEncryption::getState()
{
char *value = ::vconf_get_str(INTERNAL_STATE_VCONF_KEY);