Add dummy support for apply/drop sharing rules in Master 37/58337/11
authorZofia Abramowska <z.abramowska@samsung.com>
Wed, 27 Jan 2016 11:59:18 +0000 (12:59 +0100)
committerZofia Abramowska <z.abramowska@samsung.com>
Mon, 1 Feb 2016 20:09:06 +0000 (21:09 +0100)
Add new MasterReq functions for sending Smack rules request
to Master service and dummy handling on Master service side.

Change-Id: I638be66e61f06686a1ffc7d6c15c3e3bcfe991ae

src/common/include/master-req.h
src/common/include/protocols.h
src/common/master-req.cpp
src/server/service/include/master-service.h
src/server/service/master-service.cpp

index 316dc27..8cbf759 100644 (file)
@@ -145,6 +145,48 @@ int GetPolicy(const policy_entry &filter, uid_t uid, pid_t pid, const std::strin
  */
 int PolicyGetDesc(std::vector<std::string> &descriptions);
 
+/**
+ * Forwards Smack rules applying for private sharing to Master service.
+ *
+ * @param[in]  ownerPkgId         App id of path owner application
+ * @param[in]  pkgContents        Vector of applications belonging to the same package as path owner
+ * @param[in]  targetAppId        App id of sharing path target application
+ * @param[in]  path               Path being shared
+ * @param[in]  ownerTargetCount   Count of saved owner with target sharing
+ * @param[in]  pathSharingCount          Count of saved path sharing
+ *
+ * @return API return code, as defined in protocols.h
+ *
+ * @see ServiceImpl::applyPrivateSharing
+ */
+int SmackApplyPrivateSharingRules(const std::string &ownerPkgId,
+                                  const std::vector<std::string> &pkgContents,
+                                  const std::string &targetAppId,
+                                  const std::string &path,
+                                  int ownerTargetCount,
+                                  int pathSharingCount);
+
+/**
+ * Forwards Smack rules applying for private sharing to Master service.
+ *
+ * @param[in]  ownerPkgId         Package id of path owner application
+ * @param[in]  pkgContents        Vector of applications belonging to the same package as path owner
+ * @param[in]  targetAppId        App id of sharing path target application
+ * @param[in]  path               Path being shared
+ * @param[in]  ownerTargetCount   Count of saved owner with target sharing
+ * @param[in]  pathSharingCount          Count of saved path sharing
+ *
+ * @return API return code, as defined in protocols.h
+ *
+ * @see ServiceImpl::dropPrivateSharing
+ */
+int SmackDropPrivateSharingRules(const std::string &ownerPkgId,
+                                 const std::vector<std::string> &pkgContents,
+                                 const std::string &targetAppId,
+                                 const std::string &path,
+                                 int ownerTargetCount,
+                                 int pathSharingCount);
+
 } // namespace MasterReq
 } // namespace SecurityManager
 
index 7107b29..828eb89 100644 (file)
@@ -163,6 +163,8 @@ enum class MasterSecurityModuleCall
     POLICY_GET_DESC,
     SMACK_INSTALL_RULES,
     SMACK_UNINSTALL_RULES,
+    SMACK_APPLY_PRIVATE_SHARING_RULES,
+    SMACK_DROP_PRIVATE_SHARING_RULES
 };
 
 } // namespace SecurityManager
index 1be4b35..3d4d071 100644 (file)
@@ -203,5 +203,59 @@ int PolicyGetDesc(std::vector<std::string> &descriptions)
     return ret;
 }
 
+int SmackApplyPrivateSharingRules(const std::string &ownerPkgId,
+                                  const std::vector<std::string> &pkgContents,
+                                  const std::string &targetAppId,
+                                  const std::string &path,
+                                  int ownerTargetCount,
+                                  int pathCount)
+{
+    int ret;
+    MessageBuffer sendBuf, retBuf;
+
+    Serialization::Serialize(sendBuf,
+        static_cast<int>(MasterSecurityModuleCall::SMACK_APPLY_PRIVATE_SHARING_RULES));
+    Serialization::Serialize(sendBuf, ownerPkgId);
+    Serialization::Serialize(sendBuf, pkgContents);
+    Serialization::Serialize(sendBuf, targetAppId);
+    Serialization::Serialize(sendBuf, path);
+    Serialization::Serialize(sendBuf, ownerTargetCount);
+    Serialization::Serialize(sendBuf, pathCount);
+
+    ret = sendToServer(MASTER_SERVICE_SOCKET, sendBuf.Pop(), retBuf);
+    if (ret == SECURITY_MANAGER_API_SUCCESS) {
+        Deserialization::Deserialize(retBuf, ret);
+    }
+
+    return ret;
+}
+
+int SmackDropPrivateSharingRules(const std::string &ownerPkgId,
+                                 const std::vector<std::string> &pkgContents,
+                                 const std::string &targetAppId,
+                                 const std::string &path,
+                                 int ownerTargetCount,
+                                 int pathCount)
+{
+    int ret;
+    MessageBuffer sendBuf, retBuf;
+
+    Serialization::Serialize(sendBuf,
+        static_cast<int>(MasterSecurityModuleCall::SMACK_DROP_PRIVATE_SHARING_RULES));
+    Serialization::Serialize(sendBuf, ownerPkgId);
+    Serialization::Serialize(sendBuf, pkgContents);
+    Serialization::Serialize(sendBuf, targetAppId);
+    Serialization::Serialize(sendBuf, path);
+    Serialization::Serialize(sendBuf, ownerTargetCount);
+    Serialization::Serialize(sendBuf, pathCount);
+
+    ret = sendToServer(MASTER_SERVICE_SOCKET, sendBuf.Pop(), retBuf);
+    if (ret == SECURITY_MANAGER_API_SUCCESS) {
+        Deserialization::Deserialize(retBuf, ret);
+    }
+
+    return ret;
+}
+
 } // namespace MasterReq
 } // namespace SecurityManager
index 177b5a9..3d63064 100644 (file)
@@ -134,6 +134,25 @@ private:
      */
     void processSmackUninstallRules(MessageBuffer &buffer, MessageBuffer &send,
                                     const std::string &zoneId);
+
+    /**
+     * Process SMACK rules apply private path sharing
+     *
+     * @param  buffer Raw received data buffer
+     * @param  send   Raw data buffer to be sent
+     * @param  zoneId ID of zone which requested the call
+     */
+    void processSmackApplySharingRules(MessageBuffer &buffer, MessageBuffer &send,
+                                    const std::string &zoneId);
+    /**
+     * Process SMACK rules drop private path sharing
+     *
+     * @param  buffer Raw received data buffer
+     * @param  send   Raw data buffer to be sent
+     * @param  zoneId ID of zone which requested the call
+     */
+    void processSmackDropSharingRules(MessageBuffer &buffer, MessageBuffer &send,
+                                    const std::string &zoneId);
 };
 
 } // namespace SecurityManager
index f982c03..d462afa 100644 (file)
@@ -133,6 +133,12 @@ bool MasterService::processOne(const ConnectionID &conn, MessageBuffer &buffer,
                     LogDebug("call type MasterSecurityModuleCall::SMACK_UNINSTALL_RULES");
                     processSmackUninstallRules(buffer, send, vsmZoneId);
                     break;
+                case MasterSecurityModuleCall::SMACK_APPLY_PRIVATE_SHARING_RULES:
+                    processSmackApplySharingRules(buffer, send, vsmZoneId);
+                    break;
+                case MasterSecurityModuleCall::SMACK_DROP_PRIVATE_SHARING_RULES:
+                    processSmackDropSharingRules(buffer, send, vsmZoneId);
+                    break;
                 default:
                     LogError("Invalid call: " << call_type_int);
                     Throw(MasterServiceException::InvalidAction);
@@ -417,4 +423,42 @@ void MasterService::processSmackUninstallRules(MessageBuffer &buffer, MessageBuf
     Serialization::Serialize(send, SECURITY_MANAGER_API_SUCCESS);
 }
 
+void MasterService::processSmackApplySharingRules(MessageBuffer &buffer, MessageBuffer &send,
+                                const std::string &zoneId)
+{
+    std::string ownerPkgId, targetAppId, path;
+    std::vector<std::string> pkgContents;
+    int ownerTargetCount, pathCount;
+
+    Deserialization::Deserialize(buffer, ownerPkgId);
+    Deserialization::Deserialize(buffer, pkgContents);
+    Deserialization::Deserialize(buffer, targetAppId);
+    Deserialization::Deserialize(buffer, path);
+    Deserialization::Deserialize(buffer, ownerTargetCount);
+    Deserialization::Deserialize(buffer, pathCount);
+
+    (void)zoneId;
+
+    Serialization::Serialize(send, SECURITY_MANAGER_API_SUCCESS);
+}
+
+void MasterService::processSmackDropSharingRules(MessageBuffer &buffer, MessageBuffer &send,
+                                const std::string &zoneId)
+{
+    std::string ownerPkgId, targetAppId, path;
+    std::vector<std::string> pkgContents;
+    int ownerTargetCount, pathCount;
+
+    Deserialization::Deserialize(buffer, ownerPkgId);
+    Deserialization::Deserialize(buffer, pkgContents);
+    Deserialization::Deserialize(buffer, targetAppId);
+    Deserialization::Deserialize(buffer, path);
+    Deserialization::Deserialize(buffer, ownerTargetCount);
+    Deserialization::Deserialize(buffer, pathCount);
+
+    (void)zoneId;
+
+    Serialization::Serialize(send, SECURITY_MANAGER_API_SUCCESS);
+}
+
 } // namespace SecurityManager