Change implementation of have_smack()
authorRafal Krypa <r.krypa@samsung.com>
Fri, 12 Apr 2013 16:31:04 +0000 (18:31 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 17 Apr 2013 19:36:03 +0000 (21:36 +0200)
[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

src/privilege-control.c

index 0752c33..a525187 100644 (file)
@@ -211,13 +211,11 @@ static inline int have_smack(void)
        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;
                }
        }