Fix for internal encryption bug/failure 98/147498/4
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 4 Sep 2017 13:03:28 +0000 (15:03 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 11 Sep 2017 11:26:20 +0000 (13:26 +0200)
Stop TLM service so the user session will not restart eliminating the
race between ODE and userdata mount triggered by said user session.

Change-Id: I3f940489dca525de0feceeee204c9860f0ec010f

server/internal-encryption.cpp

index 897a6fd..023b9e0 100644 (file)
@@ -64,8 +64,8 @@ namespace {
 std::unique_ptr<INTERNAL_ENGINE> engine;
 KeyManager::data mountKey;
 
-void stopSystemdUserSessions() {
-       std::vector<std::string> userSessionServices;
+void stopKnownSystemdServices() {
+       std::vector<std::string> knownSystemdServices;
        dbus::Connection& systemDBus = dbus::Connection::getSystem();
        dbus::VariantIterator iter;
 
@@ -91,12 +91,14 @@ void stopSystemdUserSessions() {
                }
 
                std::string service(dataStr[0]);
-               if (service.compare(0, 5, "user@") == 0) {
-                       userSessionServices.push_back(service);
+               if (service.compare(0, 5, "user@") == 0 ||
+                       service == "tlm.service" ||
+                       service == "resourced.service") {
+                       knownSystemdServices.push_back(service);
                }
        }
 
-       for (const std::string& service : userSessionServices) {
+       for (const std::string& service : knownSystemdServices) {
                INFO(SINK, "Stop service - " + service);
                systemDBus.methodcall("org.freedesktop.systemd1",
                                                                "/org/freedesktop/systemd1",
@@ -316,8 +318,8 @@ int InternalEncryption::encrypt(const std::string& password, unsigned int option
        KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
        auto encryptWorker = [MasterKey, options, this]() {
                try {
-                       INFO(SINK, "Close all user sessions...");
-                       stopSystemdUserSessions();
+                       INFO(SINK, "Close all known systemd services that might be using internal storage...");
+                       stopKnownSystemdServices();
                        INFO(SINK, "Close all processes using internal storage...");
                        stopDependedSystemdServices();
                        INFO(SINK, "Umount internal storage...");
@@ -368,8 +370,8 @@ int InternalEncryption::decrypt(const std::string& password)
        KeyManager::data MasterKey = keyManager.getMasterKey(pwData);
        auto decryptWorker = [MasterKey, this]() {
                try {
-                       INFO(SINK, "Close all user sessions...");
-                       stopSystemdUserSessions();
+                       INFO(SINK, "Close all known systemd services that might be using internal storage...");
+                       stopKnownSystemdServices();
                        INFO(SINK, "Close all processes using internal storage...");
                        stopDependedSystemdServices();
                        INFO(SINK, "Umount internal storage...");