efc36d7fe7dfba8d1d3a348804e2698c2b88a071
[platform/core/security/security-manager.git] / src / server / smack-check.cpp
1 #include <smack-check.h>
2
3 #include <stdlib.h>
4 #include <sys/smack.h>
5
6 #include <dpl/log/log.h>
7
8 namespace SecurityManager {
9
10 int smack_runtime_check(void)
11 {
12     static int smack_present = -1;
13     if (-1 == smack_present) {
14         if (NULL == smack_smackfs_path()) {
15             LogDebug("no smack found on device");
16             smack_present = 0;
17         } else {
18             LogDebug("found smack on device");
19             smack_present = 1;
20         }
21     }
22     return smack_present;
23 }
24
25 int smack_check(void)
26 {
27 #ifndef SMACK_ENABLED
28     return 0;
29 #else
30     return smack_runtime_check();
31 #endif
32 }
33
34 } // namespace SecurityManager