Prepare security-manager for master-slave mode
[platform/core/security/security-manager.git] / src / common / include / protocols.h
index d9c092f..8360a26 100644 (file)
 #define _SECURITY_MANAGER_PROTOCOLS_
 
 #include <sys/types.h>
+#include <unistd.h>
 #include <vector>
 #include <string>
+#include <dpl/serialization.h>
+#include <security-manager.h>
 
 /**
  * \name Return Codes
@@ -109,9 +112,16 @@ struct app_inst_req {
     uid_t uid;
 };
 
+struct user_req {
+    uid_t uid;
+    int utype;
+};
+
 namespace SecurityManager {
 
 extern char const * const SERVICE_SOCKET;
+extern char const * const MASTER_SERVICE_SOCKET;
+extern char const * const SLAVE_SERVICE_SOCKET;
 
 enum class SecurityModuleCall
 {
@@ -119,8 +129,57 @@ enum class SecurityModuleCall
     APP_UNINSTALL,
     APP_GET_PKGID,
     APP_GET_GROUPS,
+    USER_ADD,
+    USER_DELETE,
+    POLICY_UPDATE,
+    GET_POLICY,
+    GET_CONF_POLICY_ADMIN,
+    GET_CONF_POLICY_SELF,
+    POLICY_GET_DESCRIPTIONS,
+    NOOP = 0x90,
 };
 
 } // namespace SecurityManager
 
+using namespace SecurityManager;
+
+struct policy_entry : ISerializable {
+    std::string user;           // uid converted to string
+    std::string appId;          // application identifier
+    std::string privilege;      // Cynara privilege
+    std::string currentLevel;   // current level of privielege, or level asked to be set in privacy manager bucket
+    std::string maxLevel;       // holds read maximum policy status or status to be set in admin bucket
+
+    policy_entry() : user(std::to_string(getuid())),
+                    appId(SECURITY_MANAGER_ANY),
+                    privilege(SECURITY_MANAGER_ANY),
+                    currentLevel(""),
+                    maxLevel("")
+    {}
+
+    policy_entry(IStream &stream) {
+        Deserialization::Deserialize(stream, user);
+        Deserialization::Deserialize(stream, appId);
+        Deserialization::Deserialize(stream, privilege);
+        Deserialization::Deserialize(stream, currentLevel);
+        Deserialization::Deserialize(stream, maxLevel);
+    }
+
+    virtual void Serialize(IStream &stream) const {
+        Serialization::Serialize(stream, user);
+        Serialization::Serialize(stream, appId);
+        Serialization::Serialize(stream, privilege);
+        Serialization::Serialize(stream, currentLevel);
+        Serialization::Serialize(stream, maxLevel);
+    }
+
+};
+typedef struct policy_entry policy_entry;
+
+
+struct policy_update_req {
+    std::vector<const policy_entry *> units;
+};
+
+
 #endif // _SECURITY_MANAGER_PROTOCOLS_