#include "cryptsetup-engine.h"
#include "../../file-footer.h"
+#include "../../logger.h"
#include <cctype>
#include <algorithm>
#include <libcryptsetup.h>
#include <klay/exception.h>
-#include <klay/audit/logger.h>
namespace ode {
switch (level)
{
case CRYPT_LOG_ERROR:
- ERROR("[libcryptsetup] " + msgStr);
+ ERROR(SINK, "[libcryptsetup] " + msgStr);
break;
case CRYPT_LOG_VERBOSE:
- INFO("[libcryptsetup] " + msgStr);
+ INFO(SINK, "[libcryptsetup] " + msgStr);
break;
case CRYPT_LOG_DEBUG:
case CRYPT_LOG_NORMAL:
- DEBUG("[libcryptsetup] " + msgStr);
+ DEBUG(SINK, "[libcryptsetup] " + msgStr);
break;
default:
- ERROR("[libcryptsetup] Unsupported log level. Msg: " + msgStr);
+ ERROR(SINK, "[libcryptsetup] Unsupported log level. Msg: " + msgStr);
}
}
#endif
~Device()
{
if (0 != crypt_memory_lock(device, 0))
- ERROR("Failed to unlock memory");
+ ERROR(SINK, "Failed to unlock memory");
crypt_free(device);
}
#include <fcntl.h>
#include <errno.h>
-#include <klay/audit/logger.h>
#include <klay/error.h>
#include <klay/exception.h>
#include <klay/filesystem.h>
+#include "../../logger.h"
#include "../../file-footer.h"
#include "../../ext4-tool.h"
std::function<bool(blkcnt_t)> isTarget;
if (!(options & OPTION_INCLUDE_UNUSED_REGION)) {
- INFO("FastEncryption: Disabled");
+ INFO(SINK, "FastEncryption: Disabled");
isTarget = std::bind(&Ext4Tool::isUsedBlock, &ext4Source, _1);
} else {
- INFO("FastEncryption: Enabled");
+ INFO(SINK, "FastEncryption: Enabled");
isTarget = [](unsigned int n) {
return true;
};
std::function<bool(blkcnt_t)> isTarget;
if (!(options & OPTION_INCLUDE_UNUSED_REGION)) {
- INFO("FastEncryption: Disabled");
+ INFO(SINK, "FastEncryption: Disabled");
isTarget = std::bind(&Ext4Tool::isUsedBlock, &ext4CryptoBlkDev, _1);
} else {
- INFO("FastEncryption: Enabled");
+ INFO(SINK, "FastEncryption: Enabled");
isTarget = [](unsigned int n) {
return true;
};
#include <klay/error.h>
#include <klay/exception.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
#include "../../kernel-keyring.h"
#include "../../file-footer.h"
+#include "../../logger.h"
#include "ecryptfs-engine.h"
mountOption += ",ecryptfs_enable_filtering=" MEDIA_EXCLUSION_LIST;
}
- INFO("option = " + mountOption);
- INFO("source = " + source);
- INFO("dest = " + destination);
+ INFO(SINK, "option = " + mountOption);
+ INFO(SINK, "source = " + source);
+ INFO(SINK, "dest = " + destination);
if (::mount(source.c_str(), destination.c_str(), "ecryptfs", MS_NODEV,
mountOption.c_str()) != 0) {
#include <klay/error.h>
#include <klay/exception.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
+#include "../../logger.h"
#include "../../kernel-keyring.h"
#include "../../file-footer.h"
#include "../../key-manager/key-generator.h"
keyDescriptor = "ext4:" + convertToHex(generateKeyDescriptor(key));
if (KernelKeyRing::search(keyringId, EXT4_KEYRING_TYPE,
keyDescriptor, 0) >= 0) {
- INFO("Key with descriptor already exist");
+ INFO(SINK, "Key with descriptor already exist");
return;
}
#include <vconf.h>
#include <klay/filesystem.h>
#include <klay/exception.h>
-#include <klay/audit/logger.h>
+#include "logger.h"
#include "ext4-tool.h"
#include "block-device.h"
#include "mmc-engine.h"
#include <klay/filesystem.h>
#include <klay/process.h>
#include <klay/exception.h>
-#include <klay/audit/logger.h>
+#include "logger.h"
#include "ext4-tool.h"
namespace ode {
memcpy(bitmap.data() + (blkItr >> 3), block_bitmap.data(), (cnt + 7) >> 3);
} catch (runtime::Exception &e) {
- WARN("Block " + std::to_string(blk) + " is missing");
+ WARN(SINK, "Block " + std::to_string(blk) + " is missing");
memset(bitmap.data() + (blkItr >> 3), 0, (cnt + 7) >> 3);
}
blkItr += cnt;
#include <klay/file-user.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
#include <klay/dbus/variant.h>
#include <klay/dbus/connection.h>
+#include "logger.h"
#include "ext4-tool.h"
#include "engine/encryption/cryptsetup-engine.h"
#include "key-manager/key-manager.h"
void killDependedApplications(const std::string &mntPath)
{
for (pid_t pid : runtime::FileUser::getList(mntPath, true)) {
- INFO("Close process - " + std::to_string(pid));
+ INFO(SINK, "Close process - " + std::to_string(pid));
::kill(pid, SIGKILL);
}
}
{
std::string realMntPath = findMntPath(devPath);
if (!realMntPath.empty()) {
- INFO("Closing all applications using an SD card...");
+ INFO(SINK, "Closing all applications using an SD card...");
killDependedApplications(realMntPath);
int ret = ::umount(realMntPath.c_str());
if (ret != 0) {
- ERROR("The card is still mounted, umount failed with: "
+ ERROR(SINK, "The card is still mounted, umount failed with: "
+ std::to_string(ret));
return false;
}
std::unique_lock<std::mutex> stateLock(stateGuard);
if (getStatePriv() != State::Encrypted) {
- ERROR("Cannot mount, card not inserted or corrupted");
+ ERROR(SINK, "Cannot mount, card not inserted or corrupted");
return -1;
}
KeyManager keyManager(engine->getKeyMeta());
if (!keyManager.verifyPassword(pwData)) {
- ERROR("Wrong password passed.");
+ ERROR(SINK, "Wrong password passed.");
return -2;
}
if (isMounted()) {
- INFO("Already mounted");
+ INFO(SINK, "Already mounted");
return 0;
}
KeyManager::data mountKey = keyManager.getMasterKey(pwData);
- INFO("Mount extension storage...");
+ INFO(SINK, "Mount extension storage...");
if (!isOpened()) {
// Storaged will mount MAP automatically when it appears, let's prepare
currentReq = Request::MOUNT;
try {
- INFO("Open the MAP of an extension storage...");
+ INFO(SINK, "Open the MAP of an extension storage...");
engine->open(CryptsetupEngine::DeviceType::LUKS, EXTENSION_NAME, mountKey);
} catch (runtime::Exception &e) {
- ERROR("Open failed: " + std::string(e.what()));
+ ERROR(SINK, "Open failed: " + std::string(e.what()));
return -3;
}
- INFO("Wait for the storaged to mount the MAP automatically...");
+ INFO(SINK, "Wait for the storaged to mount the MAP automatically...");
if (!storagedCv.wait_for(stateLock, std::chrono::seconds(1), [this] {
return currentReq == Request::NONE;
})) {
- ERROR("Storaged timed out mounting the MAP.");
+ ERROR(SINK, "Storaged timed out mounting the MAP.");
return -3;
}
} else {
- INFO("Ask storaged to mount extension storage...");
+ INFO(SINK, "Ask storaged to mount extension storage...");
if (!storagedMount(stateLock)) {
return -3;
}
std::unique_lock<std::mutex> stateLock(stateGuard);
if (getStatePriv() != State::Encrypted) {
- ERROR("Cannot umount, card not inserted or corrupted.");
+ ERROR(SINK, "Cannot umount, card not inserted or corrupted.");
return -1;
}
if (!isMounted() && !isOpened()) {
- INFO("Already umounted.");
+ INFO(SINK, "Already umounted.");
return 0;
}
- INFO("Umount extension storage...");
+ INFO(SINK, "Umount extension storage...");
if (isMounted()) {
- INFO("Close all applications using extension storage...");
+ INFO(SINK, "Close all applications using extension storage...");
killDependedApplications(info[Device::MAP].mntPath);
- INFO("Ask storaged to umount extension storage...");
+ INFO(SINK, "Ask storaged to umount extension storage...");
if (!storagedUnmount(stateLock)) {
return -3;
}
}
if (isOpened()) {
- INFO("Close the MAP of an extension storage...");
+ INFO(SINK, "Close the MAP of an extension storage...");
try {
CryptsetupEngine::close(EXTENSION_NAME);
} catch (runtime::Exception &e) {
- ERROR("Close failed: " + std::string(e.what()));
+ ERROR(SINK, "Close failed: " + std::string(e.what()));
return -3;
}
}
std::unique_lock<std::mutex> stateLock(stateGuard);
if (!isInserted()) {
- ERROR("There is no card inserted.");
+ ERROR(SINK, "There is no card inserted.");
status = -1;
stateLock.unlock();
workerCv.notify_one();
}
if (isMounted() || isOpened()) {
- ERROR("The card is still mounted and/or opened, umount and close first.");
+ ERROR(SINK, "The card is still mounted and/or opened, umount and close first.");
status = -1;
stateLock.unlock();
workerCv.notify_one();
KeyManager keyManager(engine->getKeyMeta());
if (!keyManager.verifyPassword(pwData)) {
- ERROR("Wrong password passed.");
+ ERROR(SINK, "Wrong password passed.");
status = -2;
stateLock.unlock();
workerCv.notify_one();
if (!findKillAndUmount(EXTENSION_DEV_PATH))
return;
- INFO("Creating LUKS...");
+ INFO(SINK, "Creating LUKS...");
engine->format(CryptsetupEngine::DeviceType::LUKS, masterKey);
- INFO("Opening LUKS...");
+ INFO(SINK, "Opening LUKS...");
std::string mappingPath = engine->open(CryptsetupEngine::DeviceType::LUKS,
EXTENSION_NAME,
masterKey);
- INFO("Creating EXT4...");
+ INFO(SINK, "Creating EXT4...");
Ext4Tool::mkfs(mappingPath);
- INFO("Closing up the operation...");
+ INFO(SINK, "Closing up the operation...");
CryptsetupEngine::close(EXTENSION_NAME);
sync();
- INFO("Formatting completed");
+ INFO(SINK, "Formatting completed");
} catch (runtime::Exception &e) {
- ERROR("Formatting thread failed: " + std::string(e.what()));
+ ERROR(SINK, "Formatting thread failed: " + std::string(e.what()));
}
};
if(!workerCv.wait_for(stateLock, std::chrono::seconds(1), [&status] {
return status != 0;
})) {
- ERROR("Timed out waiting for format status.");
+ ERROR(SINK, "Timed out waiting for format status.");
return -4;
}
KeyManager keyManager(engine->getKeyMeta());
if (!keyManager.verifyPassword(pwData)) {
- ERROR("Wrong password passed.");
+ ERROR(SINK, "Wrong password passed.");
return -2;
}
KeyManager keyManager(engine->getKeyMeta());
if (!keyManager.verifyPassword(oldPwData)) {
- ERROR("Wrong password passed.");
+ ERROR(SINK, "Wrong password passed.");
return -2;
}
void ExtensionEncryption::logStoragedEvent(Operation op, Device d)
{
- DEBUG("Storaged event:");
+ DEBUG(SINK, "Storaged event:");
switch(op) {
case Operation::ADDED:
- DEBUG(" Operation: ADDED");
+ DEBUG(SINK, " Operation: ADDED");
break;
case Operation::CHANGED:
- DEBUG(" Operation: CHANGED");
+ DEBUG(SINK, " Operation: CHANGED");
break;
case Operation::REMOVED:
- DEBUG(" Operation: REMOVED");
+ DEBUG(SINK, " Operation: REMOVED");
break;
default:
break;
switch(d) {
case Device::MMC:
- DEBUG(" Device: MMC");
+ DEBUG(SINK, " Device: MMC");
break;
case Device::MAP:
- DEBUG(" Device: MAP");
+ DEBUG(SINK, " Device: MAP");
break;
default:
break;
}
- DEBUG(" Mnt Path: " + info[d].mntPath);
- DEBUG(" Fs Type: " + info[d].fsType);
- DEBUG(" Sys path: " + info[d].sysPath);
- DEBUG(" Mounted: " + std::to_string(info[d].mounted));
- DEBUG(" ID: " + std::to_string(info[d].storagedId));
+ DEBUG(SINK, " Mnt Path: " + info[d].mntPath);
+ DEBUG(SINK, " Fs Type: " + info[d].fsType);
+ DEBUG(SINK, " Sys path: " + info[d].sysPath);
+ DEBUG(SINK, " Mounted: " + std::to_string(info[d].mounted));
+ DEBUG(SINK, " ID: " + std::to_string(info[d].storagedId));
}
void ExtensionEncryption::handleDevice(Operation op,
} else if (std::string(strparams[0]) == EXTENSION_MAP_PATH && intparams[0] == 2) {
d = Device::MAP;
} else {
- DEBUG("Storaged event: neither extension MMC nor extension mapping, ignoring");
+ DEBUG(SINK, "Storaged event: neither extension MMC nor extension mapping, ignoring");
return;
}
(op == Operation::CHANGED &&
info[d].fsType != EXTENSION_FS_TYPE))) {
if (isMounted()) {
- INFO("MMC card removed while still mounted, umounting.");
+ INFO(SINK, "MMC card removed while still mounted, umounting.");
if (!findKillAndUmount(EXTENSION_MAP_PATH)) {
return;
}
}
if (isOpened()) {
- INFO("MMC card removed while LUKS is still opened, closing.");
+ INFO(SINK, "MMC card removed while LUKS is still opened, closing.");
try {
CryptsetupEngine::close(EXTENSION_NAME);
} catch (runtime::Exception &e) {
- ERROR("Closing failed: " + std::string(e.what()));
+ ERROR(SINK, "Closing failed: " + std::string(e.what()));
return;
}
}
void ExtensionEncryption::queryStoraged()
{
- INFO("Querying the storaged for devices...");
+ INFO(SINK, "Querying the storaged for devices...");
dbus::VariantIterator vi;
"(s)",
"all").get("(a(issssssisibii))", &vi);
} catch (runtime::Exception &e) {
- ERROR("Failed to query storaged: " + std::string(e.what()));
+ ERROR(SINK, "Failed to query storaged: " + std::string(e.what()));
}
std::vector<int> intparams(6);
info[Device::MAP].storagedId,
info[Device::MAP].mntPath.c_str()).get("(i)", &ret);
} catch (runtime::Exception &e) {
- ERROR("Failed to call mount in storaged: " + std::string(e.what()));
+ ERROR(SINK, "Failed to call mount in storaged: " + std::string(e.what()));
currentReq = Request::NONE;
return false;
}
if (ret != 0) {
- ERROR("Storaged failed to mount: " + std::to_string(ret));
+ ERROR(SINK, "Storaged failed to mount: " + std::to_string(ret));
currentReq = Request::NONE;
return false;
}
if (!storagedCv.wait_for(lock, std::chrono::seconds(1), [this] {
return currentReq == Request::NONE;
})) {
- ERROR("Storaged timed out mounting the MAP.");
+ ERROR(SINK, "Storaged timed out mounting the MAP.");
currentReq = Request::NONE;
return false;
}
info[Device::MAP].storagedId,
0).get("(i)", &ret);
} catch (runtime::Exception &e) {
- ERROR("Failed to call unmount in storaged: " + std::string(e.what()));
+ ERROR(SINK, "Failed to call unmount in storaged: " + std::string(e.what()));
currentReq = Request::NONE;
return false;
}
if (ret != 0) {
- ERROR("Storaged failed to unmount: " + std::to_string(ret));
+ ERROR(SINK, "Storaged failed to unmount: " + std::to_string(ret));
currentReq = Request::NONE;
return false;
}
if (!storagedCv.wait_for(lock, std::chrono::seconds(1), [this] {
return currentReq == Request::NONE;
})) {
- ERROR("Storaged timed out unmounting the MAP.");
+ ERROR(SINK, "Storaged timed out unmounting the MAP.");
currentReq = Request::NONE;
return false;
}
int ExtensionEncryption::getStatePriv() const
{
if (!isInserted()) {
- ERROR("Cannot check state, card not inserted");
+ ERROR(SINK, "Cannot check state, card not inserted");
return -1;
}
#include <klay/file-user.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.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 "progress-bar.h"
void killDependedApplications()
{
for (pid_t pid : runtime::FileUser::getList(EXTERNAL_PATH, true)) {
- INFO("Close process - " + std::to_string(pid));
+ INFO(SINK, "Close process - " + std::to_string(pid));
::kill(pid, SIGKILL);
}
}
// ExtensionEncryption in terms of how it detects and reacts to card events
if (intparams[0] != 1 || (std::string(strparams[3]) != "vfat" &&
std::string(strparams[3]) != "ext4")) {
- DEBUG("Storaged says it's not a regular SD card. Ignoring.");
+ DEBUG(SINK, "Storaged says it's not a regular SD card. Ignoring.");
return;
}
if(intparams[2] == 0) {
- INFO("Unmounted");
+ INFO(SINK, "Unmounted");
} else {
- INFO("Mounted");
+ INFO(SINK, "Mounted");
char *value = ::vconf_get_str(EXTERNAL_STATE_VCONF_KEY);
if (value != NULL) {
std::string valueStr(value);
free(value);
if (valueStr == "encrypted") {
try {
- INFO("Launch SD card password popup");
+ INFO(SINK, "Launch SD card password popup");
AppBundle bundle;
bundle.add("viewtype", "SD_CARD_PASSWORD");
Launchpad launchpad(::tzplatform_getuid(TZ_SYS_DEFAULT_USER));
launchpad.launch("org.tizen.ode", bundle);
} catch (runtime::Exception &e) {
- ERROR("Failed to launch SD card password popup");
+ ERROR(SINK, "Failed to launch SD card password popup");
}
}
}
}
if (engine->isMounted()) {
- INFO("Already mounted");
+ INFO(SINK, "Already mounted");
return 0;
}
}
if (!engine->isMounted()) {
- INFO("Already umounted");
+ INFO(SINK, "Already umounted");
return 0;
}
- INFO("Close all applications using external storage...");
+ INFO(SINK, "Close all applications using external storage...");
killDependedApplications();
- INFO("Umount external storage...");
+ INFO(SINK, "Umount external storage...");
engine->umount();
return 0;
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto encryptWorker = [MasterKey, options, this]() {
try {
- INFO("Close all applications using external storage...");
+ INFO(SINK, "Close all applications using external storage...");
killDependedApplications();
- INFO("Encryption started...");
+ INFO(SINK, "Encryption started...");
engine->encrypt(MasterKey, options);
setOptions(options & getSupportedOptions());
- INFO("Sync disk...");
+ INFO(SINK, "Sync disk...");
sync();
- INFO("Encryption completed");
+ INFO(SINK, "Encryption completed");
::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "encrypted");
context.notify("ExternalEncryption::mount");
} catch (runtime::Exception &e) {
::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- ERROR("Encryption failed - " + std::string(e.what()));
+ ERROR(SINK, "Encryption failed - " + std::string(e.what()));
}
};
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto decryptWorker = [MasterKey, this]() {
try {
- INFO("Close all applications using external storage...");
+ INFO(SINK, "Close all applications using external storage...");
killDependedApplications();
- INFO("Umount external storage...");
+ INFO(SINK, "Umount external storage...");
while (1) {
try {
engine->umount();
}
}
- INFO("Decryption started...");
+ INFO(SINK, "Decryption started...");
::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
engine->decrypt(MasterKey, getOptions());
- INFO("Sync disk...");
+ INFO(SINK, "Sync disk...");
sync();
- INFO("Decryption completed");
+ INFO(SINK, "Decryption completed");
::vconf_set_str(EXTERNAL_STATE_VCONF_KEY, "unencrypted");
} catch (runtime::Exception &e) {
- ERROR("Decryption failed - " + std::string(e.what()));
+ ERROR(SINK, "Decryption failed - " + std::string(e.what()));
}
};
#include <klay/exception.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
+#include "logger.h"
#include "file-footer.h"
#include "key-manager/key-generator.h"
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
data value(file.size());
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
{
std::string fileName(getFileName(key));
- INFO("Footer file : " + fileName);
+ INFO(SINK, "Footer file : " + fileName);
runtime::File file(fileName);
#include <klay/file-user.h>
#include <klay/filesystem.h>
#include <klay/dbus/connection.h>
-#include <klay/audit/logger.h>
#include "vconf.h"
+#include "logger.h"
#include "progress-bar.h"
#include "engine/encryption/dmcrypt-engine.h"
#include "key-manager/key-manager.h"
}
for (const std::string& service : userSessionServices) {
- INFO("Stop service - " + service);
+ INFO(SINK, "Stop service - " + service);
systemDBus.methodcall("org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
.get("(o)", &service);
servicesToStop.insert(service);
} catch (runtime::Exception &e) {
- INFO("Close process - " + std::to_string(pid));
+ INFO(SINK, "Close process - " + std::to_string(pid));
::kill(pid, SIGKILL);
}
}
for (const std::string& service : servicesToStop) {
- INFO("Close service - " + service);
+ INFO(SINK, "Close service - " + service);
systemDBus.methodcall("org.freedesktop.systemd1",
service,
"org.freedesktop.systemd1.Unit",
defaultElmConfigDir.copyTo(shareDirectory.getPath());
}
} catch (runtime::Exception &e) {
- ERROR("Failed to set up elm configuration");
+ ERROR(SINK, "Failed to set up elm configuration");
}
std::vector<std::string> args = {
}
if (engine->isMounted()) {
- INFO("Already mounted");
+ INFO(SINK, "Already mounted");
return 0;
}
}
if (!engine->isMounted()) {
- INFO("Already umounted");
+ INFO(SINK, "Already umounted");
return 0;
}
- INFO("Close all processes using internal storage...");
+ INFO(SINK, "Close all processes using internal storage...");
stopDependedSystemdServices();
- INFO("Umount internal storage...");
+ INFO(SINK, "Umount internal storage...");
engine->umount();
return 0;
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto encryptWorker = [MasterKey, options, this]() {
try {
- INFO("Close all user sessions...");
+ INFO(SINK, "Close all user sessions...");
stopSystemdUserSessions();
- INFO("Close all processes using internal storage...");
+ INFO(SINK, "Close all processes using internal storage...");
stopDependedSystemdServices();
- INFO("Umount internal storage...");
+ INFO(SINK, "Umount internal storage...");
while (::umount(INTERNAL_PATH) == -1) {
if (errno != EBUSY) {
throw runtime::Exception("Umount error - " + std::to_string(errno));
showProgressUI("Encrypting");
- INFO("Encryption started...");
+ INFO(SINK, "Encryption started...");
engine->encrypt(MasterKey, options);
setOptions(options & getSupportedOptions());
- INFO("Sync disk...");
+ INFO(SINK, "Sync disk...");
sync();
- INFO("Encryption completed");
+ INFO(SINK, "Encryption completed");
::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "encrypted");
context.notify("InternalEncryption::mount");
::reboot(RB_AUTOBOOT);
} catch (runtime::Exception &e) {
::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- ERROR("Encryption failed - " + std::string(e.what()));
+ ERROR(SINK, "Encryption failed - " + std::string(e.what()));
}
};
KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
auto decryptWorker = [MasterKey, this]() {
try {
- INFO("Close all user sessions...");
+ INFO(SINK, "Close all user sessions...");
stopSystemdUserSessions();
- INFO("Close all processes using internal storage...");
+ INFO(SINK, "Close all processes using internal storage...");
stopDependedSystemdServices();
- INFO("Umount internal storage...");
+ INFO(SINK, "Umount internal storage...");
while (1) {
try {
engine->umount();
showProgressUI("Decrypting");
- INFO("Decryption started...");
+ INFO(SINK, "Decryption started...");
engine->decrypt(MasterKey, getOptions());
- INFO("Sync disk...");
+ INFO(SINK, "Sync disk...");
sync();
- INFO("Decryption completed");
+ INFO(SINK, "Decryption completed");
::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "unencrypted");
::reboot(RB_AUTOBOOT);
} catch (runtime::Exception &e) {
::vconf_set_str(INTERNAL_STATE_VCONF_KEY, "error_partially_encrypted");
- ERROR("Decryption failed - " + std::string(e.what()));
+ ERROR(SINK, "Decryption failed - " + std::string(e.what()));
}
};
//TODO
runtime::Process proc(PROG_FACTORY_RESET, wipeCommand);
if (proc.execute() == -1) {
- ERROR("Failed to launch factory-reset");
+ ERROR(SINK, "Failed to launch factory-reset");
return -2;
}
#include <openssl/sha.h>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
+#include "../logger.h"
#include "key-generator.h"
#define PBKDF_DEFAULT_ITERATION 1000
#include <algorithm>
#include <klay/filesystem.h>
-#include <klay/audit/logger.h>
#include <klay/exception.h>
+#include "../logger.h"
#include "key-store.h"
#include "key-generator.h"
#include <aul.h>
#include <klay/exception.h>
-#include <klay/audit/logger.h>
+#include "logger.h"
#include "launchpad.h"
Launchpad::Launchpad(const uid_t uid) :
int pid = ::aul_app_get_pid_for_uid(appid.c_str(), user);
if (pid > 0) {
if (::aul_terminate_pid_for_uid(pid, user) < 0) {
- WARN("Failed to terminate app PID=" + std::to_string(pid));
+ WARN(SINK, "Failed to terminate app PID=" + std::to_string(pid));
::kill(pid, SIGKILL);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#ifndef __ODE_LOGGER_H__
+#define __ODE_LOGGER_H__
+
+#include <klay/audit/logger.h>
+
+extern audit::LogSink *SINK;
+
+#endif //__ODE_SERVER_H__
#include <cynara-client.h>
#include <cynara-session.h>
-#include <klay/audit/logger.h>
#include <klay/audit/dlog-sink.h>
+#include "logger.h"
#include "rmi/secure-erase.h"
#include "rmi/internal-encryption.h"
#include "rmi/external-encryption.h"
std::unique_ptr<ode::InternalEncryption> internalEncryption;
std::unique_ptr<ode::ExternalEncryption> externalEncryption;
std::unique_ptr<ode::ExtensionEncryption> extensionEncryption;
+std::unique_ptr<audit::DlogLogSink> _sink = nullptr;
} // namespace
+audit::LogSink *SINK = nullptr;
+
Server::Server()
{
- audit::Logger::setBackend(new audit::DlogLogSink());
- audit::Logger::setTag("ODE");
+ _sink.reset(new audit::DlogLogSink("ODE"));
+ SINK = dynamic_cast<audit::LogSink*>((_sink).get());
- INFO("ODE server starting.");
+ INFO(SINK, "ODE server starting.");
service.reset(new rmi::Service(ODE_MANAGER_ADDRESS));
}
if (::cynara_initialize(&p_cynara, NULL) != CYNARA_API_SUCCESS) {
- ERROR("Failure in cynara API");
+ ERROR(SINK, "Failure in cynara API");
return false;
}
std::to_string(cred.uid).c_str(),
privilege.c_str()) != CYNARA_API_ACCESS_ALLOWED) {
::cynara_finish(p_cynara);
- ERROR("Access denied: " + cred.security + " : " + privilege);
+ ERROR(SINK, "Access denied: " + cred.security + " : " + privilege);
return false;
}
runtime::FileDescriptor Server::registerNotificationSubscriber(const std::string& name)
{
- INFO("registerNotificationSubscriber");
- INFO(name);
+ INFO(SINK, "registerNotificationSubscriber");
+ INFO(SINK, name);
return runtime::FileDescriptor(service->subscribeNotification(name), true);
}
* limitations under the License
*/
#include <klay/testbench.h>
-#include <klay/audit/logger.h>
+#include <klay/audit/dlog-sink.h>
+
+#include "../server/logger.h"
+
+namespace {
+
+std::unique_ptr<audit::DlogLogSink> _sink = nullptr;
+
+} // namespace
+
+audit::LogSink *SINK = nullptr;
int main(int argc, char** argv)
{
- audit::Logger::setLogLevel(audit::LogLevel::Trace);
+ _sink.reset(new audit::DlogLogSink("ODE"));
+ SINK = dynamic_cast<audit::LogSink*>((_sink).get());
+
testbench::Testbench::runAllTestSuites();
return 0;