Fixing some security-server cookie service functions to work on smack disabled.
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Mon, 28 Oct 2013 07:08:49 +0000 (08:08 +0100)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:23 +0000 (17:13 +0100)
[Issue#]        SSDWSSP-603
[Bug/Feature]   Nosmack security-server client tests fail due to incorrect
                security-server implementation for smack disabled.
[Cause]         Security-server cookie service generates incorrect label for
                nosmack and privilegeByCookieRequest does not check for smack.
[Solution]      Changing label to empty string and adding smack_check().
[Verification]  Running nosmack security-server client tests. Test
                tc05_check_privilege_by_cookie_nosmack and
                tc_security_server_get_smacklabel_cookie_nosmack should pass.

Change-Id: Ibf1ea7976d9442c56f718f8e4ca11939391cc8cd

src/server2/service/cookie-jar.cpp
src/server2/service/cookie.cpp

index 6a0a474..2e0e42b 100644 (file)
@@ -107,7 +107,7 @@ const Cookie * CookieJar::GenerateCookie(int pid)
         }
         newCookie.smackLabel = label;
     } else
-        newCookie.smackLabel = "smack_disabled";
+        newCookie.smackLabel = "";
 
 
     //get GID list
index 2f12794..29c1b03 100644 (file)
@@ -29,6 +29,7 @@
 #include <security-server.h>
 #include <security-server-common.h>
 #include <cookie.h>
+#include <smack-check.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/smack.h>
@@ -308,12 +309,16 @@ bool CookieService::privilegeByCookieRequest(MessageBuffer &buffer, MessageBuffe
     const Cookie *searchResult = m_cookieJar.SearchCookie(searchPattern, CompareType::COOKIE_ID);
 
     if (searchResult != NULL) {
-        subject = searchResult->smackLabel;
-
-        if (smack_have_access(subject.c_str(), object.c_str(), access.c_str()) == 1)
+        if (!smack_check()) {
             Serialization::Serialize(send, (int)SECURITY_SERVER_API_SUCCESS);
-        else
-            Serialization::Serialize(send, (int)SECURITY_SERVER_API_ERROR_ACCESS_DENIED);
+        } else {
+            subject = searchResult->smackLabel;
+
+            if (smack_have_access(subject.c_str(), object.c_str(), access.c_str()) == 1)
+                Serialization::Serialize(send, (int)SECURITY_SERVER_API_SUCCESS);
+            else
+                Serialization::Serialize(send, (int)SECURITY_SERVER_API_ERROR_ACCESS_DENIED);
+        }
     } else {
         Serialization::Serialize(send, (int)SECURITY_SERVER_API_ERROR_NO_SUCH_COOKIE);
     }