From: Krzysztof Jackiewicz Date: Wed, 8 Mar 2017 12:40:17 +0000 (+0100) Subject: Add cache dropping after application exit X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c8e43fb3b45d70a9c05832dedd73a6679115ca1;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Add cache dropping after application exit Change-Id: I646ff6b8ee064878e4d086f9b965a5e8ce056c09 --- diff --git a/test/app_encryption/encryption_setting.cpp b/test/app_encryption/encryption_setting.cpp index a548a484..7f75a9fb 100644 --- a/test/app_encryption/encryption_setting.cpp +++ b/test/app_encryption/encryption_setting.cpp @@ -142,8 +142,6 @@ int main(int argc, char* argv[]) return 1; } - // TODO drop cache - std::cout << "Password successfully changed" << std::endl; return 0; } diff --git a/test/app_encryption/launcher.cpp b/test/app_encryption/launcher.cpp index 4ad5b49f..8fe5b32a 100644 --- a/test/app_encryption/launcher.cpp +++ b/test/app_encryption/launcher.cpp @@ -20,14 +20,16 @@ */ #include +#include #include #include +#include #include -#include -#include #include #include +#include +#include #include #include @@ -36,13 +38,14 @@ const cap_value_t ADMIN[] = { CAP_SETGID, CAP_DAC_OVERRIDE, CAP_SYS_ADMIN, CAP_MAC_OVERRIDE, CAP_MAC_ADMIN }; const cap_value_t LIMITED[] = { CAP_SETGID }; +const char* CACHE_DROP = "/proc/sys/vm/drop_caches"; int main(int argc, char* argv[]) { pid_t pid = fork(); if (pid < 0) { std::cerr << "fork() failed" << std::endl; - return 1; + exit(1); } if (pid > 0) { @@ -51,7 +54,24 @@ int main(int argc, char* argv[]) do child = waitpid(pid, &status, 0); while (child != pid); - return 0; + + try { + sync(); + + std::ofstream of(CACHE_DROP); + if (!of) { + std::cerr << "Failed to open " << CACHE_DROP << std:: endl; + return 1; + } + + of << 2 << std::endl;; + } catch (const std::exception& e) { + std::cerr << e.what() << std::endl; + return 1; + } catch (...) { + std::cerr << "Unknown exception" << std::endl; + return 1; + } } else { // prevent capabilities drop if (0 != prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) { @@ -136,4 +156,5 @@ int main(int argc, char* argv[]) free(user_argv[0]); return 1; } + return 0; }