summaryrefslogtreecommitdiff
path: root/src/manager/common/smack-check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/manager/common/smack-check.cpp')
-rw-r--r--src/manager/common/smack-check.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/manager/common/smack-check.cpp b/src/manager/common/smack-check.cpp
new file mode 100644
index 00000000..f6f6f303
--- /dev/null
+++ b/src/manager/common/smack-check.cpp
@@ -0,0 +1,34 @@
+#include <smack-check.h>
+
+#include <stdlib.h>
+#include <sys/smack.h>
+
+#include <dpl/log/log.h>
+
+namespace CentralKeyManager {
+
+int smack_runtime_check(void)
+{
+ static int smack_present = -1;
+ if (-1 == smack_present) {
+ if (NULL == smack_smackfs_path()) {
+ LogDebug("no smack found on device");
+ smack_present = 0;
+ } else {
+ LogDebug("found smack on device");
+ smack_present = 1;
+ }
+ }
+ return smack_present;
+}
+
+int smack_check(void)
+{
+#ifndef SMACK_ENABLED
+ return 0;
+#else
+ return smack_runtime_check();
+#endif
+}
+
+} // namespace CentralKeyManager