Fix data control api.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 17 May 2013 12:06:14 +0000 (14:06 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:09:36 +0000 (17:09 +0100)
Data control must return SUCCESS on images without smack.

[Issue#]   SSDWSSP-277
[Bug]      security-server_app_give_access returns error on image
           without smack.
[Cause]    On image without smack user passed "" as a client label.
           "" is not acceptable smack label.
[Solution] Function security_server_app_give_access returns SUCCESS
           when smack is turn off.

[Verification] Build. Run all tests. No changes in result should be
               noticed on smack image.

Change-Id: I0c740ecda07e3ed97f1d409c8e597bc3b1f0b773

src/client/security-server-client.c
src/util/smack-check.c

index 8c3bc42..4fa8957 100644 (file)
@@ -1151,6 +1151,9 @@ int security_server_app_give_access(const char *customer_label, int customer_pid
     int sockfd = -1, retval;
     response_header hdr;
 
+    if (1 != smack_check())
+        return SECURITY_SERVER_SUCCESS;
+
     retval = connect_to_server(&sockfd);
     if(retval != SECURITY_SERVER_SUCCESS)
     {
index 61aaf41..02b5613 100644 (file)
@@ -1,7 +1,4 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include <sys/smack.h>
 
 #include <security-server-common.h>
 #include <smack-check.h>
@@ -10,13 +7,11 @@ int smack_runtime_check(void)
 {
     static int smack_present = -1;
     if (-1 == smack_present) {
-        int fd = open("/smack/load2", O_WRONLY);
-        if (-1 == fd) {
+        if (NULL == smack_smackfs_path()) {
             SEC_SVR_DBG("%s","security-server: no smack found on device");
             smack_present = 0;
         } else {
             SEC_SVR_DBG("%s","security-server: found smack on device");
-            close(fd);
             smack_present = 1;
         }
     }