2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Rafal Krypa <r.krypa@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
18 * Security Manager library header
21 * @file security-manager.h
22 * @author Pawel Polawski (p.polawski@samsung.com)
24 * @brief This file contains header of security-manager API
27 #ifndef SECURITY_MANAGER_H_
28 #define SECURITY_MANAGER_H_
30 #include <sys/types.h>
36 /*! \brief return code of API functions */
38 SECURITY_MANAGER_SUCCESS,
39 SECURITY_MANAGER_ERROR_UNKNOWN,
40 SECURITY_MANAGER_ERROR_INPUT_PARAM,
41 SECURITY_MANAGER_ERROR_MEMORY,
42 SECURITY_MANAGER_ERROR_REQ_NOT_COMPLETE,
43 SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED,
44 SECURITY_MANAGER_ERROR_ACCESS_DENIED,
47 /*! \brief accesses types for application installation paths*/
48 enum app_install_path_type {
49 //accessible read-write only for applications with same package id
50 SECURITY_MANAGER_PATH_PRIVATE,
51 //read-write access for all applications
52 SECURITY_MANAGER_PATH_PUBLIC,
53 //read only access for all applications
54 SECURITY_MANAGER_PATH_PUBLIC_RO,
55 //accessible for writing to all apps within its package
56 SECURITY_MANAGER_PATH_RW,
57 //accessible to apps for reading
58 SECURITY_MANAGER_PATH_RO,
59 //this is only for range limit
60 SECURITY_MANAGER_ENUM_END
64 * This enum has values equivalent to gumd user type.
65 * The gum-utils help states that
66 * "usertype can be system(1), admin(2), guest(3), normal(4)."
68 enum security_manager_user_type {
69 SM_USER_TYPE_NONE = 0,/*<-this should not be used, if it is used, there will be an error returned by SM*/
70 SM_USER_TYPE_SYSTEM = 1,
71 SM_USER_TYPE_ADMIN = 2,
72 SM_USER_TYPE_GUEST = 3,
73 SM_USER_TYPE_NORMAL = 4,
74 SM_USER_TYPE_ANY = 5,/*<-this value may be used only for setting policies and not during user adding*/
77 typedef enum security_manager_user_type security_manager_user_type;
79 /*! \brief data structure responsible for handling informations
80 * required to install / uninstall application */
82 typedef struct app_inst_req app_inst_req;
84 /*! \brief data structure responsible for handling informations
85 * required to manage users */
87 typedef struct user_req user_req;
89 /*! \brief data structure responsible for handling policy updates
90 * required to manage users' and applications' permissions */
91 struct policy_update_req;
92 typedef struct policy_update_req policy_update_req;
94 /*! \brief data structure responsible for handling single policy entry*/
96 typedef struct policy_entry policy_entry;
98 /*! \brief wildcard to be used in requests to match all possible values of given field.
99 * Use it, for example when it is desired to list or apply policy change for all
100 * users or all apps for selected user.
102 #define SECURITY_MANAGER_ANY "#"
104 /*! \brief value denoting delete operation on specific policy. It can only be used
105 * in update policy operation, passed to either security_manager_policy_entry_admin_set_level
106 * or security_manager_policy_entry_set_level.
108 #define SECURITY_MANAGER_DELETE "DELETE"
111 * This function translates lib_retcode error codes to strings describing
113 * @param[in] rc error code of lib_retcode type
114 * @return string describing error for error code
116 const char *security_manager_strerror(enum lib_retcode rc);
119 * This function is responsible for initialize app_inst_req data structure
120 * It uses dynamic allocation inside and user responsibility is to call
121 * app_inst_req_free() for freeing allocated resources
123 * \param[in] Address of pointer for handle app_inst_req structure
124 * \return API return code or error code
126 int security_manager_app_inst_req_new(app_inst_req **pp_req);
129 * This function is used to free resources allocated by calling app_inst_req_new()
130 * \param[in] Pointer handling allocated app_inst_req structure
132 void security_manager_app_inst_req_free(app_inst_req *p_req);
135 * This function is used to set up application identifier in app_inst_req structure
137 * \param[in] Pointer handling app_inst_req structure
138 * \param[in] Application identifier
139 * \return API return code or error code
141 int security_manager_app_inst_req_set_app_id(app_inst_req *p_req, const char *app_id);
144 * This function is used to set up package identifier in app_inst_req structure
146 * \param[in] Pointer handling app_inst_req structure
147 * \param[in] Package identifier
148 * \return API return code or error code
150 int security_manager_app_inst_req_set_pkg_id(app_inst_req *p_req, const char *pkg_id);
153 * This function is used to add privilege to app_inst_req structure,
154 * it can be called multiple times
156 * \param[in] Pointer handling app_inst_req structure
157 * \param[in] Application privilager
158 * \return API return code or error code
160 int security_manager_app_inst_req_add_privilege(app_inst_req *p_req, const char *privilege);
163 * This function is used to add application path to app_inst_req structure,
164 * it can be called multiple times
166 * \param[in] Pointer handling app_inst_req structure
167 * \param[in] Application path
168 * \param[in] Application path type
169 * \return API return code or error code
171 int security_manager_app_inst_req_add_path(app_inst_req *p_req, const char *path, const int path_type);
174 * This function is used to set up user identifier in app_inst_req structure.
175 * This field simplifies support for online and offline modes.
177 * \param[in] Pointer handling app_inst_req structure
178 * \param[in] User identifier (UID)
179 * \return API return code or error code
181 int security_manager_app_inst_req_set_uid(app_inst_req *p_req,
185 * This function is used to install application based on
186 * using filled up app_inst_req data structure
188 * \param[in] Pointer handling app_inst_req structure
189 * \return API return code or error code: it would be
190 * - SECURITY_MANAGER_SUCCESS on success,
191 * - SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED when user does not
192 * have rights to install requested directories,
193 * - SECURITY_MANAGER_ERROR_UNKNOWN on other errors.
195 int security_manager_app_install(const app_inst_req *p_req);
198 * This function is used to uninstall application based on
199 * using filled up app_inst_req data structure
201 * \param[in] Pointer handling app_inst_req structure
202 * \return API return code or error code
204 int security_manager_app_uninstall(const app_inst_req *p_req);
207 * Get package id of a given application
209 * On successful call pkg_id should be freed by the caller using free() function
211 * \param[out] Pointer to package identifier string
212 * \param[in] Application identifier
213 * \return API return code or error code
215 int security_manager_get_app_pkgid(char **pkg_id, const char *app_id);
218 * Compute smack label for given application id and set it for
219 * currently running process
221 * \param[in] Application identifier
222 * \return API return code or error code
224 int security_manager_set_process_label_from_appid(const char *app_id);
227 * For given app_id and current user, calculate allowed privileges that give
228 * direct access to file system resources. Then add current process to
229 * supplementary groups that are assigned to these resources.
231 * In Tizen some sensitive resources are being accessed by applications directly.
232 * The resources, being file system objects, are owned by dedicated GIDs and only
233 * processes in those UNIX groups can access them. This function is used for
234 * adding application process to all permitted groups that are assigned to such
237 * \param[in] Application identifier
238 * \return API return code or error code
240 int security_manager_set_process_groups_from_appid(const char *app_id);
243 * The above launcher functions, manipulating process Smack label and group,
244 * require elevated privileges. Since they will be called by launcher after fork,
245 * in the process for the application, privileges should be dropped before
246 * running an actual application. This function is a helper for that purpose -
247 * it drops capabilities from the process.
249 * \return API return code or error code
251 int security_manager_drop_process_privileges(void);
254 * A convenience function for launchers for preparing security context for an
255 * application process. It should be called after fork in the new process, before
256 * running the application in it.
257 * It is aimed to cover most common cases and will internally call other, more
258 * specialized security-manager functions for launchers.
259 * Currently it just calls:
260 * - security_manager_set_process_label_from_appid
261 * - security_manager_set_process_groups_from_appid
262 * - security_manager_drop_process_privileges
264 * \param[in] Application identifier
265 * \return API return code or error code
267 int security_manager_prepare_app(const char *app_id);
270 * This function is responsible for initialization of user_req data structure.
271 * It uses dynamic allocation inside and user responsibility is to call
272 * security_manager_user_req_free() for freeing allocated resources.
274 * @param[in] Address of pointer for handle user_req structure
275 * @return API return code or error code
277 int security_manager_user_req_new(user_req **pp_req);
280 * This function is used to free resources allocated by
281 * security_manager_user_req_new()
283 * @param[in] Pointer handling allocated user_req structure
285 void security_manager_user_req_free(user_req *p_req);
288 * This function is used to set up user identifier in user_req structure.
290 * @param p_req Structure containing user data filled during this function call
291 * @param uid User identifier to be set
292 * @return API return code or error code
294 int security_manager_user_req_set_uid(user_req *p_req, uid_t uid);
297 * This function is used to set up user type in user_req structure.
299 * @param p_req Structure containing user data filled during this function call
300 * @param utype User type to be set
301 * @return API return code or error code
303 int security_manager_user_req_set_user_type(user_req *p_req, security_manager_user_type utype);
306 * This function should be called to inform security-manager about adding new user.
307 * This function succeeds only when is called by privileged user.
308 * Otherwise it just returns SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED and does nothing.
310 * It adds all required privileges to a newly created user.
311 * User data are passed through pointer 'p_req'.
312 * @param p_req Structure containing user data filled before calling this
313 * uid and user type needs to be filled in p_req structure,
314 * otherwise SECURITY_MANAGER_ERROR_INPUT_PARAM will be returned.
315 * @return API return code or error code.
317 int security_manager_user_add(const user_req *p_req);
320 * This function should be called to inform security-manager about removing a user.
321 * This function succeeds only when is called by privileged user.
322 * Otherwise it just returns SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED and does nothing.
324 * It removes all privileges granted to a user that has been granted previously by
325 * security_manager_user_add.
327 * @param p_req Structure containing user data filled before calling this.
328 * uid of user needs to be filled in p_req structure,
329 * otherwise SECURITY_MANAGER_ERROR_INPUT_PARAM will be returned.
330 * @return API return code or error code
332 int security_manager_user_delete(const user_req *p_req);
335 * \brief This function is responsible for initializing policy_update_req data structure.
337 * It uses dynamic allocation inside and user responsibility is to call
338 * policy_update_req_free() for freeing allocated resources.
340 * \param[out] pp_req Address of pointer for handle policy_update_req structure
341 * \return API return code or error code
343 int security_manager_policy_update_req_new(policy_update_req **pp_req);
346 * \brief This function is used to free resources allocated by calling policy_update_req_new().
347 * \param[in] p_req Pointer handling allocated policy_update_req structure
349 void security_manager_policy_update_req_free(policy_update_req *p_req);
352 * \brief This function is responsible for initializing policy_entry data structure.
354 * It uses dynamic allocation inside and user responsibility is to call
355 * policy_policy_entry_free() for freeing allocated resources.
357 * \note application and privilege fields default to SECURITY_MANAGER_ANY wildcard,
358 * user field defaults to calling user's UID, whereas the current and max level
359 * values, default to empty string "".
361 * \param[out] pp_entry Address of pointer for handle policy_entry structure
362 * \return API return code or error code
364 int security_manager_policy_entry_new(policy_entry **pp_entry);
367 * \brief This function is used to free resources allocated by calling
368 * policy_entry_req_new().
369 * \param[in] p_entry Pointer handling allocated policy_entry structure
371 void security_manager_policy_entry_free(policy_entry *p_entry);
374 * This function is used to set up application identifier in p_entry structure
376 * \param[in] p_entry Pointer handling policy_entry structure
377 * \param[in] app_id Application identifier to be set
378 * \return API return code or error code
380 int security_manager_policy_entry_set_application(policy_entry *p_entry, const char *app_id);
383 * This function is used to set up user identifier in p_entry structure
384 * Calling this function may be omitted if user wants to set policies for himself
385 * \param[in] p_entry Pointer handling policy_entry structure
386 * \param[in] user_id User identifier to be set
387 * \return API return code or error code
389 int security_manager_policy_entry_set_user(policy_entry *p_entry, const char *user_id);
392 * This function is used to set up privilege in p_entry structure
394 * \param[in] p_entry Pointer handling policy_entry structure
395 * \param[in] privilege Privilege to be set
396 * \return API return code or error code
398 int security_manager_policy_entry_set_privilege(policy_entry *p_entry, const char *privilege);
401 * This function is used to set up privilege level in p_entry structure.
402 * This api is intended to be used to decrease user's own level of privilege.
404 * \param[in] p_entry Pointer handling policy_entry structure
405 * \param[in] policy_level Policy level to be set. The level of privilege may
406 * be one of strings returned by @ref security_manager_policy_levels_get.
407 * If it is not, then error code SECURITY_MANAGER_ERROR_INPUT_PARAM is returned.
408 * Two predefined values are always valid here:
410 * "Allow", which means that user allows some app (setup by calling function
411 * @ref security_manager_policy_entry_set_application) to run with some privilege
412 * (setup by @ref security_manager_policy_entry_set_privilege).
413 * Note, that this not necessarily mean, that this privilege will really be granted.
414 * Final decision of granting privilege also depends on app's manifests,
415 * predefined policy and administrator's or manufacturer's settings.
416 * If all of those policy sources also allows granting privilege for that app,
417 * then (and only then) it will be granted.
419 * "Deny", which means that user disallows some app (setup by calling function
420 * @ref security_manager_policy_entry_set_application) to run with some privilege
421 * (setup by @ref security_manager_policy_entry_set_privilege).
422 * Note, that this denies privilege irrespective of privilege levels granted
423 * to app by other policy sources: app's manifests, predefined policy
424 * and administrator's or manufacturer's settings.
426 * Other levels may be also valid, if returned by security_manager_policy_levels_get.
427 * They represent other policy levels configured in system, which security-manager
428 * does support. The other levels are always something between "Allow" and "Deny"
429 * (like "Allow only once").
431 * Irrespective of a meaning of those values security-manager will always treat
432 * policy set by security_manager_policy_entry_set_level as a mean to
433 * decrease user's own rights. This will never increase overall policy.
435 * \return API return code or error code
437 int security_manager_policy_entry_set_level(policy_entry *p_entry, const char *policy_level);
440 * This function is used to set up privilege level for admin policy entries
441 * in p_entry structure.
443 * This function is intended to be used by admin to change level of privilege.
444 * If it is used by user that has no http://tizen.org/privilege/systemsettings.admin
445 * privilege, then security_manager_policy_update_send will return error code.
447 * \param[in] p_entry Pointer handling policy_entry structure
448 * \param[in] policy_level Policy level to be set. This may be one of strings
449 * returned by @ref security_manager_policy_levels_get. If it is not, then error
450 * code is returned (SECURITY_MANAGER_ERROR_INPUT_PARAM).
451 * Two predefined values are always valid here:
453 * "Allow", which means that admin allows some user's app to
454 * get privilege irrespective of predefined policy settings for that user.
455 * Note, that this not necessarily mean, that this privilege will really be granted.
456 * Final decision of granting privilege also depends on app's manifests,
457 * user's own policy (set up by @ref security_manager_policy_entry_set_level)
458 * or manufacturer's settings.
459 * If all of those policy sources also allows granting privilege for that app,
460 * then (and only then) it will be granted.
462 * "Deny", which means that admin disallows some user's app to get privilege
463 * irrespective of predefined policy settings for that user.
464 * Note, that this denies privilege app's manifests, user's own policy
465 * (set up by @ref security_manager_policy_entry_set_level) or manufacturer's
468 * Other levels may be also valid, if returned by security_manager_policy_levels_get.
469 * They represent other policy levels configured in system, which security-manager
470 * does support. The other levels are always something between "Allow" and "Deny"
471 * (like "Allow only once").
473 * Irrespective of a meaning of those values security-manager will always treat
474 * policy set by security_manager_policy_entry_admin_set_level as a mean for admin
475 * to change user's rights, but will not alter user's own privilege level set up
476 * by @ref security_manager_policy_entry_set_level.
478 * \return API return code or error code
480 int security_manager_policy_entry_admin_set_level(policy_entry *p_entry, const char *policy_level);
483 * This function is used to add policy entry to policy update request.
485 * Note, that this function does not make a copy of object pointed to by p_entry
486 * and does not change owner of this handler.
487 * User is responsible to keep p_entry untouched until @ref security_manager_policy_update_send
488 * is called on p_req. After that p_entry still needs to be freed.
489 * (see examples in documentation of @ref security_manager_policy_update_send)
491 * \param[in] p_req Pointer handling allocated policy_update_req structure
492 * \param[in] p_entry Pointer handling policy_entry structure
493 * \return API return code or error code
495 int security_manager_policy_update_req_add_entry(policy_update_req *p_req, const policy_entry *p_entry);
498 * This function is used to obtain user ID from p_entry structure
500 * \param[in] p_entry Pointer handling policy_entry structure
501 * \attention Warning: returned pointer to user ID is valid as long as p_entry is valid.
506 const char *security_manager_policy_entry_get_user(policy_entry *p_entry);
508 * This function is used to obtain application name from p_entry structure
510 * \param[in] p_entry Pointer handling policy_entry structure
511 * \attention Warning: returned pointer to application name is valid as long as p_entry is valid.
513 * \return application name
516 const char *security_manager_policy_entry_get_application(policy_entry *p_entry);
518 * This function is used to obtain privilege name from p_entry structure
520 * \param[in] p_entry Pointer handling policy_entry structure
521 * \attention Warning: returned pointer to privilege name is valid as long as p_entry is valid.
523 * \return privilege name
525 const char *security_manager_policy_entry_get_privilege(policy_entry *p_entry);
527 * This function is used to obtain current policy level from p_entry structure
529 * \param[in] p_entry Pointer handling policy_entry structure
530 * \attention Warning: returned pointer to policy level is valid as long as p_entry is valid.
532 * \return Current policy level
534 const char *security_manager_policy_entry_get_level(policy_entry *p_entry);
537 * This function is used to obtain maximal policy level from p_entry structure
539 * \param[in] p_entry Pointer handling policy_entry structure.
540 * \attention Warning: returned pointer to maximal policy level is valid as long as p_entry is valid.
542 * \return Maximal policy level
544 const char *security_manager_policy_entry_get_max_level(policy_entry *p_entry);
547 * \brief This function is used to send the prepared policy update request using privacy manager
548 * entry point. The request should contain at least one policy update unit, otherwise
549 * the SECURITY_MANAGER_ERROR_INPUT_PARAM is returned.
551 * \note 1. If user field in policy_entry is empty, then uid of the calling user is assumed
552 * 2. If privilege or app field in policy_entry is empty, then SECURITY_MANAGER_API_BAD_REQUEST
554 * 3. For user's personal policy: wildcards usage in application or privilege field of policy_entry
557 * \param[in] p_req Pointer handling allocated policy_update_req structure
558 * \return API return code or error code
561 * (warning: checking return codes are omitted in examples just for visibility reasons)
563 * - to update policy for user by himself:
564 * (Deny access from app MyApp1 to privilege http://tizen.org/privilege/systemsettings,
565 * deny access from app MyApp2 to privilege http://tizen.org/privilege/systemsettings,
566 * deny access from app MyApp3 to privilege http://tizen.org/privilege/notificationmanager)
568 * policy_update_req *policy_update_request;
569 * policy_entry *entry1;
570 * policy_entry *entry2;
571 * policy_entry *entry3;
573 * security_manager_policy_update_req_new(&policy_update_request);
574 * security_manager_policy_entry_new(&entry1);
575 * security_manager_policy_entry_new(&entry2);
576 * security_manager_policy_entry_new(&entry3);
578 * security_manager_policy_entry_set_application(entry1, "MyApp1");
579 * security_manager_policy_entry_set_privilege(entry1, "http://tizen.org/privilege/systemsettings");
580 * security_manager_policy_entry_set_level(entry1, "Deny");
582 * security_manager_policy_entry_set_application(entry2, "MyApp2");
583 * security_manager_policy_entry_set_privilege(entry2, "http://tizen.org/privilege/systemsettings");
584 * security_manager_policy_entry_set_level(entry2, "Deny");
586 * security_manager_policy_entry_set_application(entry3, "MyApp3");
587 * security_manager_policy_entry_set_privilege(entry3, "http://tizen.org/privilege/notificationmanager");
588 * security_manager_policy_entry_set_level(entry3, "Deny");
590 * security_manager_policy_update_req_add_entry(policy_update_request, entry1);
591 * security_manager_policy_update_req_add_entry(policy_update_request, entry2);
592 * security_manager_policy_update_req_add_entry(policy_update_request, entry3);
594 * //do not change entry1, entry2 or entry3!
596 * security_manager_policy_update_send(policy_update_request);
598 * security_manager_policy_entry_free(entry1);
599 * security_manager_policy_entry_free(entry2);
600 * security_manager_policy_entry_free(entry3);
601 * security_manager_policy_update_free(policy_update_request);
603 * - to update policy by administrator for some user:
604 * (Deny access of user of uid 2001 from any app to privilege http://tizen.org/privilege/vibrator,
605 * (allow access of user of uid 2002 using app "App1" to privilege http://tizen.org/privilege/email.admin)
607 * policy_update_req *policy_update_request;
609 * security_manager_policy_update_req_new(&policy_update_request);
611 * policy_entry *entry1;
612 * policy_entry *entry2;
613 * char *adminswife = "2001";
614 * char *adminsfriend = "2002";
616 * security_manager_policy_entry_new(&entry1);
617 * security_manager_policy_entry_new(&entry2);
619 * security_manager_policy_entry_set_user(entry1, adminswife);
620 * security_manager_policy_entry_set_application(entry1, SECURITY_MANAGER_ANY);
621 * security_manager_policy_entry_set_privilege(entry1, "http://tizen.org/privilege/vibrator");
622 * security_manager_policy_entry_admin_set_level(entry1, "Deny");
624 * security_manager_policy_entry_set_user(entry2, adminsfriend);
625 * security_manager_policy_entry_set_application(entry2, "App1");
626 * security_manager_policy_entry_set_privilege(entry2, "http://tizen.org/privilege/email.admin");
627 * security_manager_policy_entry_admin_set_level(entry2, "Allow");
629 * security_manager_policy_update_req_add_entry(policy_update_request, entry1);
630 * security_manager_policy_update_req_add_entry(policy_update_request, entry2);
632 * //do not change entry1 or entry2!
634 * security_manager_policy_update_send(policy_update_request);
636 * security_manager_policy_entry_free(entry1);
637 * security_manager_policy_entry_free(entry2);
638 * security_manager_policy_update_free(policy_update_request);
641 int security_manager_policy_update_send(policy_update_req *p_req);
644 * \brief Function fetches all privileges enforced by admin user.
645 * The result is stored in the policy_entry structures array.
647 * \note It should be called by user with http://tizen.org/privilege/systemsettings.admin privilege.
648 * Normal users may list their personal policy entries using
649 * security_manager_get_configured_policy_for_self() API function.
651 * \attention Developer is responsible for calling security_manager_policy_entries_free()
652 * for freeing allocated resources.
654 * \param[in] p_filter Pointer to filter struct
655 * \param[out] ppp_privs_policy Pointer handling allocated policy_entry structures array
656 * \param[out] p_size Pointer where the size of allocated array will be stored
657 * \return API return code or error code
659 int security_manager_get_configured_policy_for_admin(
660 policy_entry *p_filter,
661 policy_entry ***ppp_privs_policy,
665 * \brief Function fetches all privileges that are configured by user in his/her
666 * privacy manager. The result is stored in the policy_entry structures array.
667 * User may only fetch privileges for his/her own UID.
669 * \attention Developer is responsible for calling security_manager_policy_entries_free()
670 * for freeing allocated resources.
672 * \param[in] p_filter Pointer to filter struct
673 * \param[out] ppp_privs_policy Pointer handling allocated policy_entry structures array
674 * \param[out] p_size Pointer where the size of allocated array will be stored
675 * \return API return code or error code
677 int security_manager_get_configured_policy_for_self(
678 policy_entry *p_filter,
679 policy_entry ***ppp_privs_policy,
683 * \brief Function gets the whole policy for all users, their applications and privileges
684 * based on the provided filter. The result is stored in the policy_entry array.
686 * \note If this call is performed by user with http://tizen.org/privilege/systemsettings.admin
687 * privilege, then it's possible to list policies for all users.
688 * Normal users may only list privileges for their own UID.
690 * \attention Developer is responsible for calling security_manager_policy_entries_free()
691 * for freeing allocated resources.
693 * \param[in] p_filter Pointer to filter struct
694 * \param[out] ppp_privs_policy Pointer handling allocated policy_entry structures array
695 * \param[out] p_size Pointer where the size of allocated array will be stored
696 * \return API return code or error code
698 int security_manager_get_policy(
699 policy_entry *p_filter,
700 policy_entry ***ppp_privs_policy,
704 * \brief This function is used to free resources allocated in policy_entry structures array.
705 * \param[in] p_entries Pointer handling allocated policy status array
706 * \param[in] size Size of the array
708 void security_manager_policy_entries_free(policy_entry *p_entries, const size_t size);
711 * This function returns array of available policy levels in form of simple
712 * text descriptions. List is sorted using internal policy level value,
713 * from lowest value to highest and starts with "Deny".
715 * Caller needs to free memory allocated for the list using
716 * security_manager_policy_levels_free().
718 * @param levels pointer to array of strings.
719 * @param levels_count number of strings in levels array.
720 * @return API return code or error code.
722 int security_manager_policy_levels_get(char ***levels, size_t *levels_count);
725 * This function free memory allocated by security_manager_policy_levels_get()
728 * @param levels array of strings returned by
729 * security_manager_policy_levels_get() function.
730 * @return API return code or error code.
732 void security_manager_policy_levels_free(char **levels, size_t levels_count);
735 * This function returns mapping of MULTIPLE privileges from one version to the other.
736 * List of privileges is a union of mappings of every single given privilege.
738 * Caller needs to free memory allocated for the list using
739 * security_manager_privilege_mapping_free().
741 * @param[in] from_version Version of passed privilege
742 * @param[in] to_version Version of requested mapping, if NULL default one will be used
743 * @param[in] privileges Names of privileges to be mapped
744 * @param[in] privileges_count Number of privileges to be mapped
745 * @param[out] privilege_mapping Pointer to list of sum of privileges which given privileges maps to
746 * @param[out] mapping_count
747 * @return API return code or error code
749 int security_manager_get_privileges_mapping(const char *from_version,
750 const char *to_version,
751 char const * const *privileges,
752 size_t privileges_count,
753 char ***privileges_mappings,
754 size_t *mappings_count);
756 * This function frees memory allocated by security_manager_get_privilege_mapping() and
757 * security_manager_get_privileges_mapping().
759 * @param[in] privilege_mapping List of privileges
760 * @param[in] mapping_count Number of privileges
762 void security_manager_privilege_mapping_free(char **privileges_mappings, size_t mappings_count);
765 * This function returns array of groups bound to privileges of file resources.
767 * Caller needs to free memory allocated for the list using
768 * security_manager_groups_free().
770 * @param[out] groups pointer to array of strings.
771 * @param[out] groups_count number of strings in levels array.
772 * @return API return code or error code.
774 int security_manager_groups_get(char ***groups, size_t *groups_count);
777 * This function frees memory allocated by security_manager_groups_get()
780 * @param[in] groups array of strings returned by security_manager_groups_get() function.
781 * @param[in] groups_count size of the groups array
783 void security_manager_groups_free(char **groups, size_t groups_count);
789 #endif /* SECURITY_MANAGER_H_ */