[Issue#] N/A
[Feature] More reliable checking whether Smack is available in runtime.
[Cause] Code reuse.
[Solution] Use function provided in libsmack to check usability of smackfs.
[Verification] Run tests from security-tests.
Change-Id: Ib237a0a6ddbcdd966daac35bc8c416338c501af2
static int have_smack = -1;
if (-1 == have_smack) {
- int fd = open("/smack/load2", O_WRONLY);
- if (-1 == fd) {
+ if (NULL == smack_smackfs_path()) {
C_LOGD("Libprivilage-control: no smack found on phone");
have_smack = 0;
} else {
C_LOGD("Libprivilege-control: found smack on phone");
- close(fd);
have_smack = 1;
}
}