Stop units with the same pid and pgid 75/197575/6
authorseolheui, kim <s414.kim@samsung.com>
Mon, 14 Jan 2019 07:37:54 +0000 (16:37 +0900)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 23 Jan 2019 09:11:54 +0000 (09:11 +0000)
Change-Id: I4ddba0760664ebb5424d623c93a9bd26d83951c6
Signed-off-by: seolheui, kim <s414.kim@samsung.com>
server/internal-encryption.cpp

index b2de48a..d27fda9 100644 (file)
@@ -208,6 +208,12 @@ void stopSystemdUnits()
        }
 
        for (pid_t pid : runtime::FileUser::getList(INTERNAL_PATH, true)) {
+               auto pgid = ::getpgid(pid);
+               if (pgid > 0 && pid != pgid) {
+                       WARN(SINK, "PGID doesn't match - pgid : " + std::to_string(pgid) + ", pid : " + std::to_string(pid));
+                       continue;
+               }
+
                try {
                        char *unit = nullptr;
                        systemDBus.methodcall("org.freedesktop.systemd1",
@@ -227,8 +233,7 @@ void stopSystemdUnits()
                        std::string unescapedName(tmp);
                        free(tmp);
 
-                       if (unescapedName.find("dbus", 0, 4) == std::string::npos)
-                               unitsToStop.insert(unescapedName);
+                       unitsToStop.insert(unescapedName);
                } catch (runtime::Exception &e) {
                        ERROR(SINK, "Killing process: " + std::to_string(pid));
                        ::kill(pid, SIGKILL);