* See the License for the specific language governing permissions and
* limitations under the License
*/
+#include <signal.h>
#include <unistd.h>
#include <sys/mount.h>
+#include <tzplatform_config.h>
+#include <klay/file-user.h>
#include <klay/filesystem.h>
#include <klay/audit/logger.h>
#include "rmi/external-encryption.h"
#define EXTERNAL_STORAGE_PATH "/opt/media/SDCardA1"
+#define DEFAULT_USER "owner"
namespace ode {
void killDependedApplications()
{
+ for (pid_t pid : runtime::FileUser::getList(EXTERNAL_STORAGE_PATH, true)) {
+ INFO("Close process - " + std::to_string(pid));
+ ::kill(pid, SIGKILL);
+ }
}
}
try {
engine.umount();
} catch (runtime::Exception& e) {}
+
INFO("Decryption started...");
engine.decrypt(DEK);
INFO("Sync disk...");
* See the License for the specific language governing permissions and
* limitations under the License
*/
+#include <set>
+
+#include <signal.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/reboot.h>
+#include <klay/file-user.h>
#include <klay/filesystem.h>
#include <klay/dbus/connection.h>
#include <klay/audit/logger.h>
KeyManager keyManager(INTERNAL_STORAGE_PATH);
DMCryptEngine engine("/dev/mmcblk0p25", INTERNAL_STORAGE_PATH);
-std::vector<std::string> dependedSystemdServices = {
- "resourced.service",
- "msg-server.service",
- "mtp-responder.service",
-};
-
void stopDependedSystemdServices()
{
- std::vector<std::string> servicesToStop(dependedSystemdServices);
dbus::Connection& systemDBus = dbus::Connection::getSystem();
- dbus::VariantIterator iter;
-
- systemDBus.methodcall("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "ListUnits",
- -1, "(a(ssssssouso))", "")
- .get("(a(ssssssouso))", &iter);
-
- while(1) {
- unsigned int dataUint;
- char *dataStr[9];
- int ret;
-
- ret = iter.get("(ssssssouso)", dataStr, dataStr + 1, dataStr + 2,
- dataStr + 3, dataStr + 4, dataStr + 5,
- dataStr + 6, &dataUint, dataStr + 7,
- dataStr + 8);
-
- if (!ret) {
- break;
- }
+ std::set<std::string> servicesToStop;
- std::string service(dataStr[0]);
- if (service.compare(0, 5, "user@") == 0) {
- servicesToStop.push_back(service);
+ for (pid_t pid : runtime::FileUser::getList(INTERNAL_STORAGE_PATH, true)) {
+ try {
+ char *service;
+ systemDBus.methodcall("org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ "GetUnitByPID",
+ -1, "(o)", "(u)", (unsigned int)pid)
+ .get("(o)", &service);
+ servicesToStop.insert(service);
+ } catch (runtime::Exception &e) {
+ INFO("Close process - " + std::to_string(pid));
+ ::kill(pid, SIGKILL);
}
}
-
- //TODO : get other services that are using INTERNAL_STORAGE_PATH
-
for (const std::string& service : servicesToStop) {
- INFO("Stop service - " + service);
+ INFO("Close service - " + service);
systemDBus.methodcall("org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager",
- "StopUnit",
- -1, "", "(ss)", service.c_str(), "flush");
+ service,
+ "org.freedesktop.systemd1.Unit",
+ "Stop",
+ -1, "", "(s)", "flush");
}
}