Add API for identifying application from Cynara client 57/88357/3
authorZofia Abramowska <z.abramowska@samsung.com>
Fri, 16 Sep 2016 09:57:35 +0000 (11:57 +0200)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 20 Sep 2016 11:37:09 +0000 (04:37 -0700)
Change-Id: I1f906cb2200fc38e99f5225b951b596ff2d5c507

src/client/client-security-manager.cpp
src/include/app-runtime.h

index e8e854a..d903574 100644 (file)
@@ -1341,6 +1341,21 @@ int security_manager_identify_app_from_pid(pid_t pid, char **pkg_name, char **ap
 }
 
 SECURITY_MANAGER_API
+int security_manager_identify_app_from_cynara_client(const char *client, char **pkg_name,
+                                                     char **app_name)
+{
+    return try_catch([&] {
+        LogDebug(__PRETTY_FUNCTION__ << " called");
+
+        if (pkg_name == NULL && app_name == NULL) {
+            LogError("Both pkg_name and app_name are NULL");
+            return SECURITY_MANAGER_ERROR_INPUT_PARAM;
+        }
+        return get_app_and_pkg_id_from_smack_label(client, pkg_name, app_name);
+    });
+}
+
+SECURITY_MANAGER_API
 int security_manager_app_has_privilege(const char *app_name, const char *privilege,
                                        uid_t uid, int *result)
 {
index 3303523..1d7028c 100644 (file)
@@ -162,6 +162,24 @@ int security_manager_identify_app_from_socket(int sockfd, char **pkg_id, char **
 int security_manager_identify_app_from_pid(pid_t pid, char **pkg_id, char **app_id);
 
 /**
+ * Get package and application id of an application with given process Cynara client identifier
+ *
+ * On successful call pkg_id and app_id should be freed when caller is done with them.
+ * Both pkg_id and app_id are allocated with malloc() so they should be freed with free() function.
+ * Either app_id or pkg_id may be NULL. NULL-ed argument will be ignored.
+ * If both app_id and pkg_id are NULL then SECURITY_MANAGER_ERROR_INPUT_PARAM will be returned.
+ * When process identifier is incorrect or not related to any package, this function will
+ * return SECURITY_MANAGER_ERROR_NO_SUCH_OBJECT.
+ *
+ *
+ * \param[in]   client  Application Cynara client identifier
+ * \param[out]  pkg_id  Package id of the application
+ * \param[out]  app_id  Application id of the application
+ * \return API return code or error code
+ */
+int security_manager_identify_app_from_cynara_client(const char *client, char **pkg_id,
+                                                     char **app_id);
+/**
  * Check whether an application would have access to a privilege
  *
  * This enables queries for application's privileges when there is no application