Security/Tizen 2.X privilege-checker

From Tizen Wiki
Jump to: navigation, search

Overview

Privilege-checker provides Core and Web privilege database, internal APIs to manage or check privileges, and language files for privilege user notification. Privilege-checker module roughly classify its functions into privilege-manager, privilege-checker, privilege-db-manager, and privilege-info.

Privilege Manager

In usual, installer invokes following APIs to check privilege list of application package to be installed.

Enumeration Types

  • enum privilege_manager_package_type_e
    Enumerations of application package type. Privilege checker is not used for checking privilege list of Web application so that there's no enum for Web application package.
    Required header:
    <privilege_manager.h>
    Enumerator:
    PRVMGR_PACKAGE_TYPE_CORE core application
    PRVMGR_PACKAGE_TYPE_NATIVE (not used in 2.3)

  • enum privilege_manager_visibility_e
    Enumerator of privilege visibility level
    Required header:
    <privilege_manager.h>
    Enumerator:
    PRVMGR_PACKAGE_VISIBILITY_PUBLIC Public-level privilege
    PRVMGR_PACKAGE_VISIBILITY_PARTNER Partner-level privilege
    PRVMGR_PACKAGE_VISIBILITY_PLATFORM Platform-level privilege

  • enum privilege_manager_error_e
    Enumerator of error code for privilege manager
    Required header:
    <privilege_manager.h>
    Enumerator:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_INVALID_PARAMETER Invalid function parameter
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INTERNAL_ERROR Internal error
    PRVMGR_ERR_NO_DATA No data
    PRVMGR_ERR_NO_EXIST_PRIVILEGE Not existing privilege
    PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL Mismatched privilege level

APIs

  • int privilege_manager_verify_privilege_list(privilege_manager_package_type_e package_type, GList* privilege_list, privilege_manager_visibility_e visibility, char** error_privilege_name);
    Verify privilege name and level in the privilege list.
    Required header:
    <privilege_manager.h>
    Remarks:
    privilege_list must be released with free() by you.
    error_privilege_name must be released with free() by you.
    Parameters:
    [in] package_type The privilege_manager_package_type_e
    [in] privilege_list The privilege_list
    [in] visibility The privilege_manager_visibility_e
    [out] error_privilege_name The error_privilege_name's value is assigned when PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL and PRVMGR_ERR_NO_EXIST_PRIVILEGE are returned, otherwise null is assigned.
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL privilege level is higher than visibility. Error_privilege_name'value is assigned.
    PRVMGR_ERR_NO_EXIST_PRIVILEGE privilege don't exist. Error_privilege_name'value is assigned.
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
    PRVMGR_ERR_INTERNAL_ERROR Internal error

  • int privilege_manager_verify_privilege_name(privilege_manager_package_type_e package_type, GList* privilege_list, GList** error_privilege_name_list);
    Verify privilege name in the privilege list.
    Required header:
    <privilege_manager.h>
    Remarks:
    privilege_list must be released with free() by you.
    error_privilege_name_list must be released with free() by you.
    Parameters:
    [in] package_type The privilege_manager_package_type_e
    [in] privilege_list The privilege_list
    [out] error_privilege_name_list The error_privilege_name_list's value is assigned when PRVMGR_ERR_NO_EXIST_PRIVILEGE is returned, otherwise null is assigned.
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_NO_EXIST_PRIVILEGE privilege don't exist. Error_privilege_name'value is assigned.
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
    PRVMGR_ERR_INTERNAL_ERROR Internal error

  • int privilege_manager_verify_privilege_level(privilege_manager_package_type_e package_type, GList* privilege_list, privilege_manager_visibility_e visibility, GList** error_privilege_name_list, GList** error_privilege_level_list);
    Verify privilege name and level in the privilege list.
    Required header:
    <privilege_manager.h>
    Remarks:
    privilege_list must be released with free() by you.
    error_privilege_name_list must be released with free() by you.
    error_privilege_level_list must be released with free() by you.
    Parameters:
    [in] package_type The privilege_manager_package_type_e
    [in] privilege_list The privilege_list
    [in] visibility The privilege_manager_visibility_e
    [out] error_privilege_name_list The error_privilege_name_list's value is assigned when PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL is returned, otherwise null is assigned.
    [out] error_privilege_level_list The error_privilege_level_list's value is assigned when PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL is returned, otherwise null is assigned.
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_MISMACHED_PRIVILEGE_LEVEL privilege level is higher than visibility. Error_privilege_name_list and error_privilege_level_list value is assigned.
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
    PRVMGR_ERR_INTERNAL_ERROR Internal error

Privilege Checker

Privilege checker provides APIs to check whether a package has certain privilege or not.

APIs

  • int privilege_checker_check_package_privilege(const char* package_id, const char* privilege);
    Check whether given package has given privilege.
    Required header:
    <privilege_checker.h>
    Parameters:
    [in] package_id The ID of package to be checked
    [in] privilege The privilege to check
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRIV_CHECKER_ERR_NONE Successful. Package has given privilege.
    PRIV_CHECKER_ERR_OUT_OF_MEMORY Out of memory
    PRIV_CHECKER_ERR_INVALID_PARAMETER Invalid parameter
    PRIV_CHECKER_ERR_INTERNAL_ERROR Internal error
    PRIV_CHECKER_ERR_INVALID_PRIVILEGE Invalid privilege, package doesn't have such privilege.

Privilege Info

Privilege checker provides APIs to retrieve privilege information but these APIs are not opened as Core-API. In Core-API level, privilege-info provides such APIs.

Enumeration Types

  • enum privilege_checker_error_e
    Enumerator of error code for privilege checker
    Required header:
    <privilege_checker.h>
    Enumerator:
    PRIV_CHECKER_ERR_NONE Successful
    PRIV_CHECKER_ERR_INVALID_PARAMETER Invalid function parameter
    PRIV_CHECKER_ERR_OUT_OF_MEMORY Out of memory
    PRIV_CHECKER_ERR_INTERNAL_ERROR Unknown error
    PRIV_CHECKER_ERR_NO_DATA No data
    PRIV_CHECKER_ERR_INVALID_PRIVILEGE Invalid privilege level

APIs

  • int privilege_info_get_privilege_group_display_name(const char* privilege_group, char** name);
    Gets the display name of privilege group with the given privilege.
    Required header:
    <privilege_info.h>
    Remarks:
    name must be released with free() by you.
    Parameters:
    [in] privilege_group The privilege group
    [out] name The display name of the privilege group
    Returns:
    return 0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter

  • int privilege_info_get_privilege_display_name(const char* privilege, char** name);
    Gets the display name of privilege with the given privilege.
    Required header:
    <privilege_info.h>
    Remarks:
    name must be released with free() by you.
    Parameters:
    [in] privilege The privilege
    [out] name The display name of the privilege
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter

  • int privilege_info_get_privilege_description(const char* privilege, char** description);
    Gets the description of privilege with the given privilege.
    Required header:
    <privilege_info.h>
    Remarks:
    description must be released with free() by you.
    Parameters:
    [in] privilege The privilege
    [out] description The description of the privilege
    Returns:
    0 on success, otherwise a negative error value.
    Return values:
    PRVMGR_ERR_NONE Successful
    PRVMGR_ERR_OUT_OF_MEMORY Out of memory
    PRVMGR_ERR_INVALID_PARAMETER Invalid parameter

Privilege DBs

Privilege-checker has two DBs(core_privilege_info.db and wrt_privilege_info.db) to store Core and Web privilege information. Information stored in DBs are used for:

  • User notification of privileges used by applications
  • Checking privilege list of native application package

The following shows DB schema of core_privilege_info.db/wrt_privilege_info.db. For more information, see Native Privileges and Web Privileges.

  • Table PRIVILEGE_INFO:
    • PROFILE
      Target profile.
      • common
      • mobile
      • wearable
      Common profile means the privilege can be used for both mobile and wearable target.
    • PACKAGE_TYPE
      Indicates whether the privilege is for native application or Web application.
      • core
      • wrt
    • PRIVILEGE_LEVEL
      Privilege level.
      • platform
      • partner
      • public
    • API_VERSION_ISSUED
      Privilege issued version. In form of x.y when x and y are integer. ex) 2.3
    • API_VERSION_EXPIRED
      Privilege deprecated version. In form of x.y when x and y are integer. ex) 2.3
    • PRIVILEGE_NAME
      Name of privilege. ex) http://tizen.org/privilege/account.write
    • PRIVILEGE_DISPLAY
      Display name of privilege.
    • PRIVILEGE_DESCRIPTION
      Description of privilege.
    • PRIVLEGE_GROUP
      Group of privilege.
      • Location
      • Hardware controls
      • Personal information
      • Network connections
      • Paid services
      • Other privileges