2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
5 * @file security_server_tests_clean_env.cpp
6 * @author Zbigniew Jasinski (z.jasinski@samsung.com)
8 * @brief Functions to prepare clean env for tests.
15 #include <ckm/ckm-control.h>
17 #include <dbus_access.h>
18 #include <clean-env.h>
20 int restart_security_server() {
21 DBusAccess dbusAccess("/org/freedesktop/systemd1/unit/security_2dserver_2eservice");
28 static int nftw_rmdir_contents(const char *fpath, const struct stat * /*sb*/,
29 int tflag, struct FTW *ftwbuf)
33 else if (tflag == FTW_DP && ftwbuf->level != 0)
40 * This function should be called at the begining of every SS test, so all the tests
41 * are independent of each other.
43 int reset_security_server()
45 const char* path = "/opt/data/security-server/";
46 const int max_descriptors = 10; //max number of open file descriptors by nftw function
48 // Clear /opt/data/security-server/ directory
49 if (access(path, F_OK) == 0) {
50 if (nftw(path, &nftw_rmdir_contents, max_descriptors, FTW_DEPTH) == -1) {
56 restart_security_server();
57 auto control = CKM::Control::create();
60 control->lockUserKey(5000);
61 control->removeUserData(5000);
62 control->unlockUserKey(5000, "");