#include <vconf.h>
#include <tzplatform_config.h>
-
#include <klay/file-user.h>
#include <klay/filesystem.h>
#include <klay/dbus/variant.h>
#include <klay/dbus/connection.h>
-#include "vconf.h"
#include "logger.h"
#include "launchpad.h"
#include "app-bundle.h"
#include "rmi/external-encryption.h"
-#define EXTERNAL_ENGINE EcryptfsEngine
#define EXTERNAL_PATH "/opt/media/SDCardA1"
#define EXTERNAL_STATE_VCONF_KEY VCONFKEY_SDE_CRYPTO_STATE
#define EXTERNAL_OPTION_ONLY_NEW_FILE_VCONF_KEY VCONFKEY_SDE_ENCRYPT_NEWFILE
namespace {
+typedef EcryptfsEngine EXTERNAL_ENGINE;
+
std::unique_ptr<EXTERNAL_ENGINE> engine;
KeyManager::data mountKey;
bool isBootCompleted = false;
*/
#include <set>
#include <algorithm>
+#include <memory>
#include <fcntl.h>
#include <signal.h>
#include <klay/filesystem.h>
#include <klay/dbus/connection.h>
-#include "vconf.h"
#include "logger.h"
#include "progress-bar.h"
#include "engine/encryption/dmcrypt-engine.h"
#include "rmi/internal-encryption.h"
-#define INTERNAL_ENGINE DMCryptEngine
-#define INTERNAL_DEV_PATH "/dev/disk/by-partlabel"
-#define INTERNAL_DEV_NAME "USER"
-#define INTERNAL_PATH "/opt/usr"
-#define INTERNAL_STATE_VCONF_KEY VCONFKEY_ODE_CRYPTO_STATE
-#define INTERNAL_OPTION_ONLY_USED_REGION_VCONF_KEY VCONFKEY_ODE_FAST_ENCRYPTION
+namespace ode {
+
+namespace {
+
+typedef DMCryptEngine INTERNAL_ENGINE;
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
+const char *INTERNAL_DEV_PATH = "/dev/disk/by-partlabel";
+const char *INTERNAL_DEV_NAME = "USER";
+const char *INTERNAL_PATH = "/opt/usr";
+const char *PRIVILEGE_PLATFORM = "http://tizen.org/privilege/internal/default/platform";
+
+// TODO: see recovery()
const std::string PROG_FACTORY_RESET = "/usr/bin/dbus-send";
const std::vector<std::string> wipeCommand = {
PROG_FACTORY_RESET,
"com.samsung.factoryreset.start.setting"
};
-namespace ode {
-
-namespace {
+std::unique_ptr<INTERNAL_ENGINE> engine;
+KeyManager::data mountKey;
std::string findDevPath()
{
- std::string source = INTERNAL_DEV_PATH "/" INTERNAL_DEV_NAME;
+ std::string source = INTERNAL_DEV_PATH + std::string("/") + INTERNAL_DEV_NAME;
try {
runtime::DirectoryIterator iter(INTERNAL_DEV_PATH), end;
return ret;
}
-std::unique_ptr<INTERNAL_ENGINE> engine;
-KeyManager::data mountKey;
-
void stopKnownSystemdServices() {
std::vector<std::string> knownSystemdServices;
dbus::Connection& systemDBus = dbus::Connection::getSystem();
int value;
value = 0;
- ::vconf_get_bool(INTERNAL_OPTION_ONLY_USED_REGION_VCONF_KEY, &value);
+ ::vconf_get_bool(VCONFKEY_ODE_FAST_ENCRYPTION, &value);
if (value) {
result |= InternalEncryption::Option::IncludeUnusedRegion;
}
} else {
value = false;
}
- ::vconf_set_bool(INTERNAL_OPTION_ONLY_USED_REGION_VCONF_KEY, value);
+ ::vconf_set_bool(VCONFKEY_ODE_FAST_ENCRYPTION, value);
}
}
setOptions(options & getSupportedOptions());
INFO(SINK, "Encryption completed");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "encrypted");
+ ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "encrypted");
context.notify("InternalEncryption::mount");
INFO(SINK, "Syncing disk and rebooting...");
::sync();
::reboot(RB_AUTOBOOT);
} catch (runtime::Exception &e) {
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "error_partially_encrypted");
ERROR(SINK, "Encryption failed - " + std::string(e.what()));
}
};
engine->decrypt(MasterKey, getOptions());
INFO(SINK, "Decryption completed");
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "unencrypted");
+ ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "unencrypted");
INFO(SINK, "Syncing disk and rebooting...");
::sync();
::reboot(RB_AUTOBOOT);
} catch (runtime::Exception &e) {
- ::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
+ ::vconf_set_str(VCONFKEY_ODE_CRYPTO_STATE, "error_partially_encrypted");
ERROR(SINK, "Decryption failed - " + std::string(e.what()));
}
};
int InternalEncryption::getState()
{
- char *value = ::vconf_get_str(INTERNAL_STATE_VCONF_KEY);
+ char *value = ::vconf_get_str(VCONFKEY_ODE_CRYPTO_STATE);
if (value == NULL) {
throw runtime::Exception("Failed to get vconf value");
}