resource-monitor: Use pass_resource_monitor_set_resource_flag to make the resource... 08/280608/4 accepted/tizen/unified/20220902.020139 submit/tizen/20220901.084153
authorSung-hun Kim <sfoon.kim@samsung.com>
Mon, 29 Aug 2022 07:32:33 +0000 (16:32 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Thu, 1 Sep 2022 07:37:52 +0000 (16:37 +0900)
Some information should be protected from public users.
So the users of capi only can access to attirbutes
which have PUBLIC visibility. By using the added
libpass function, we can enforce the user of capi to
only access PUBLIC attributes. If the user tries to
access PRIVATE attributes, the set attribute function
will return RESOURCE_MONITOR_ERROR_PERMISSION_DENIED
error.

Change-Id: If7f40a7cf4e2c0987fa3594a6e3e3f0839c0aded
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
src/resource-monitor.c

index 6bcaf354a2bb2a0fd9ae8903e92a1d3614c24e1b..d304ddda834a9a22edff4847ad4962bfa45f3613 100644 (file)
@@ -39,7 +39,16 @@ int resource_monitor_get_resource_count(int monitor_id, resource_monitor_type_e
 
 int resource_monitor_create_resource(int monitor_id, resource_monitor_type_e resource_type)
 {
-       return pass_resource_monitor_create_resource(monitor_id, resource_type);
+       int ret;
+       int resource_id = pass_resource_monitor_create_resource(monitor_id, resource_type);
+
+       if (resource_id < 0)
+               return resource_id;
+
+       ret = pass_resource_monitor_set_resource_flag(monitor_id, resource_id, RESOURCE_FLAG_PUBLIC);
+       if (ret < 0)
+               return ret;
+       return resource_id;
 }
 
 int resource_monitor_delete_resource(int monitor_id, int resource_id)