4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd All Rights Reserved
6 * Contact: Bumjin Im <bj.im@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License
22 #ifndef SECURITY_SERVER_H
23 #define SECURITY_SERVER_H
25 #include <sys/types.h>
26 #include <privilege-control.h>
29 * @file security-server.h
31 * @brief This file contains APIs of the Security Server
35 * @defgroup SecurityFW
38 * @defgroup SECURITY_SERVER Security Server
40 * @brief Security Server client library functions
45 * @addtogroup SECURITY_SERVER
50 * ====================================================================================================
55 * -- Company Name -- | Modification Date | Description of Changes
56 * -----------------------------------------------------------------------
57 * --- Samsung ------ | --- 2010-07-25 -- | First created
64 * exported by the foundation API.
65 * result codes begin with the start error code and extend into negative direction.
68 #define SECURITY_SERVER_API_SUCCESS 0
69 /*! \brief indicating the result of the one specific API is successful */
70 #define SECURITY_SERVER_API_ERROR_SOCKET -1
72 /*! \brief indicating the socket between client and Security Server has been failed */
73 #define SECURITY_SERVER_API_ERROR_BAD_REQUEST -2
75 /*! \brief indicating the response from Security Server is malformed */
76 #define SECURITY_SERVER_API_ERROR_BAD_RESPONSE -3
78 /*! \brief indicating the transmitting request has been failed */
79 #define SECURITY_SERVER_API_ERROR_SEND_FAILED -4
81 /*! \brief indicating the receiving response has been failed */
82 #define SECURITY_SERVER_API_ERROR_RECV_FAILED -5
84 /*! \brief indicating requesting object is not exist */
85 #define SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT -6
87 /*! \brief indicating the authentication between client and server has been failed */
88 #define SECURITY_SERVER_API_ERROR_AUTHENTICATION_FAILED -7
90 /*! \brief indicating the API's input parameter is malformed */
91 #define SECURITY_SERVER_API_ERROR_INPUT_PARAM -8
93 /*! \brief indicating the output buffer size which is passed as parameter is too small */
94 #define SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL -9
96 /*! \brief indicating system is running out of memory state */
97 #define SECURITY_SERVER_API_ERROR_OUT_OF_MEMORY -10
99 /*! \brief indicating the access has been denied by Security Server */
100 #define SECURITY_SERVER_API_ERROR_ACCESS_DENIED -11
102 /*! \brief indicating Security Server has been failed for some reason */
103 #define SECURITY_SERVER_API_ERROR_SERVER_ERROR -12
105 /*! \brief indicating given cookie is not exist in the database */
106 #define SECURITY_SERVER_API_ERROR_NO_SUCH_COOKIE -13
108 /*! \brief indicating there is no phone password set */
109 #define SECURITY_SERVER_API_ERROR_NO_PASSWORD -14
111 /*! \brief indicating password exists in system */
112 #define SECURITY_SERVER_API_ERROR_PASSWORD_EXIST -15
114 /*! \brief indicating password mismatch */
115 #define SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH -16
117 /*! \brief indicating password retry timeout is not occurred yet */
118 #define SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER -17
120 /*! \brief indicating password retry timeout is not occurred yet */
121 #define SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED -18
123 /*! \brief indicating password retry timeout is not occurred yet */
124 #define SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED -19
126 /*! \brief indicating password retry timeout is not occurred yet */
127 #define SECURITY_SERVER_API_ERROR_PASSWORD_REUSED -20
129 /*! \brief indicating getting smack label from socket failed */
130 #define SECURITY_SERVER_API_ERROR_GETTING_SOCKET_LABEL_FAILED -21
132 /*! \brief indicating the error with unknown reason */
133 #define SECURITY_SERVER_API_ERROR_UNKNOWN -255
145 * Retreives Linux group ID from object name which is passed by parameter
148 * This API may be used before security_server_check_privilege() API by middleware daemon to get group ID of a specific object.
150 * \par Typical use case:
151 * In middleware daemon, before checking privilege of a service the daemon need to know the GID of the service. This API support the functionality.
153 * \par Method of function operation:
154 * Opens /etc/group file and searches the object name as group name. If there is matching result, returns GID as integer
156 * \par Sync (or) Async:
157 * This is a Synchronous API.
159 * \par Important notes:
160 * - This API is only allowed to be called by pre-defined middleware daemon
162 * \param[in] object Name of the object which is kwnown by the caller.
164 * \return matching gid (positive integer) on success, or negative error code on error.
166 * \par Prospective clients:
169 * \par Known issues/bugs:
177 * security_server_get_object_name(), security_server_check_privilege()
183 * #include <security-server.h>
187 * // You have to make sure that the input param '*object' is defined in the platform
188 * retval = security_server_get_gid("telephony_makecall");
191 * printf("%s", "Error has occurred\n");
197 * Access to this function requires SMACK rule: "<app_label> security-server::api-get-gid w"
199 int security_server_get_gid(const char *object);
205 * Retreives object name as mull terminated string from Linux group ID which is passed by parameter
208 * This API may be used to get object name if the caller process only knows GID of the object.
210 * \par Typical use case:
211 * In middleware daemon, by some reason, need to know object name from the Linux group ID, then call this API to retrieve object name as string
213 * \par Method of function operation:
214 * Opens /etc/group file and searches matching gid. If there is matching result, returns name of the group as null terminated string
216 * \par Sync (or) Async:
217 * This is a Synchronous API.
219 * \par Important notes:
220 * - This API is only allowed to be called by pre-defined middleware daemon
222 * \param[in] gid Linux group ID which needed to be retrieved as object name.
223 * \param[out] object Place holder for matching object name for gid.
224 * \param[in] max_object_size Allocated byte size of parameter "object".
226 * \return 0 on success, or negative error code on error.
228 * \par Prospective clients:
229 * Inhouse middleware.
231 * \par Known issues/bugs:
234 * \pre output parameter object must be malloced before calling this API not to make memory curruption
239 * security_server_get_gid()
245 * #include <security-server.h>
248 * char objectname[20];
251 * retval = security_server_get_object_name(6005, objectname, sizeof(objectname));
254 * printf("%s", "Error has occurred\n");
260 * Access to this function requires SMACK rule: "<app_label> security-server::api-get-object-name w"
262 int security_server_get_object_name(gid_t gid, char *object, size_t max_object_size);
268 * Request cookie to the Security Server. Cookie is a random bit stream which is used as ticket for user space object.
271 * This API may be used by application and client middleware process to get access to middleware daemons.
273 * \par Typical use case:
274 * When an application process wants to get access to some middleware object, first call this API to get cookie value. Then it calls the service API to get service with the cookie value.
276 * \par Method of function operation:
277 * Caller process just send request message. Security Server checks proc file system to get list of gIDs the caller belongs, then create a random cookie and responds to caller.
279 * \par Sync (or) Async:
280 * This is a Synchronous API.
282 * \par Important notes:
283 * Cookie needs to be stored relatively secure.
285 * \param[out] cookie Place holder for cookie value.
286 * \param[in] max_cookie Allocated byte size of parameter "cookie".
288 * \return 0 on success, or negative error code on error.
290 * \par Prospective clients:
293 * \par Known issues/bugs:
296 * \pre output parameter cookie must be malloced before calling this API not to make memory curruption
297 * Size of the cookie can be retrieved by security_server_get_cookie_size() API.
301 * \see security_server_check_privilege(), security_server_get_cookie_size()
307 * #include <security-server.h>
310 * size_t cookie_size;
311 * cookie_size = security_server_get_cookie_size();
312 * unsigned char cookie[cookie_size];
315 * retval = security_server_request_cookie(cookie, cookie_size);
318 * printf("%s", "Error has occurred\n");
324 * Access to this function not requires SMACK rule
326 int security_server_request_cookie(char *cookie, size_t bufferSize);
332 * This API gets the cookie's byte size which is issued by Security Server.
335 * This API may be used by application and middleware process to get size of cookie before getting and storing cookie value.
337 * \par Typical use case:
338 * When an application process wants to get access to some middleware object, first call this API to get cookie value. Then it calls the service API to get service with the cookie value.
340 * \par Method of function operation:
341 * This API just returns pre-defined integer value as cookie size.
343 * \par Sync (or) Async:
344 * This is a Synchronous API.
346 * \par Important notes:
349 * \return Always returns byte size of the cookie.
351 * \par Prospective clients:
354 * \par Known issues/bugs:
361 * \see security_server_request_cookie()
367 * #include <security-server.h>
370 * size_t cookie_size;
373 * cookie_size = security_server_get_cookie_size();
374 * unsigned char cookie[cookie_size];
376 * char objectname[20];
377 * retval = security_server_request_cookie(cookie, cookie_size);
380 * printf("%s", "Error has occurred\n");
386 * Access to this function not requires SMACK rule
388 int security_server_get_cookie_size(void);
394 * This API checks the cookie is allowed to access to given object.
397 * This API may be used by middleware process to ask the client application has privilege for the given object.
399 * \par Typical use case:
400 * When middleware server receives request message from client application process with cookie value, it calls this API to ask to Security Server that the client application has privilege to access the service. If yes, then the middleware daemon can continue service, if not, it can return error to client application.
402 * \par Method of function operation:
403 * When Security Server receives this request, it searches cookie database and check the cookie is there, if there is matching cookie, then it checks the cookie has the privilege. It returns success if there is match, if not, it returns error.
405 * \par Sync (or) Async:
406 * This is a Synchronous API.
408 * \par Important notes:
409 * Cookie value needs to be stored relatively secure\n
410 * Privilege should be pre-defined by Platform design.
412 * \param[in] cookie Received cookie value from client application
413 * \param[in] privilege Object group ID which the client application wants to access
415 * \return 0 on success, or negative error code on error.
417 * \par Prospective clients:
418 * Only pre-defiend middleware daemons
420 * \par Known issues/bugs:
426 * \see security_server_request_cookie(), security_server_get_gid(), security_server_get_cookie_size()
432 * #include <security-server.h>
435 * size_t cookie_size;
437 * cookie_size = security_server_get_cookie_size();
438 * unsigned char recved_cookie[cookie_size];
440 * ... // Receiving request with cookie
442 * call_gid = security_server_get_gid("telephony_makecall");
443 * retval = security_server_check_privilege(recved_cookie, (gid_t)call_gid);
446 * if(retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
448 * printf("%s", "access has been denied\n");
451 * printf("%s", "Error has occurred\n");
457 * Access to this function requires SMACK rule: "<app_label> security-server::api-cookie-check w"
459 int security_server_check_privilege(const char *cookie, gid_t privilege);
461 int security_server_check_privilege_by_cookie(const char *cookie,
463 const char *access_rights);
465 int security_server_check_privilege_by_sockfd(int sockfd,
467 const char *access_rights);
471 * This API searchs a cookie value and returns PID of the given cookie.
474 * This API may be used by middleware process to ask the client application has privilege for the given object.
476 * \par Typical use case:
477 * In some cases, a middleware server wants to know PID of the application process. But if the middleware server uses non-direct IPC such as dbus, it's nearly impossible to know and guarantee peer PID. By using this API, the middleware server can retrieve a PID of the requesting process.
479 * \par Method of function operation:
480 * When Security Server receives this request, it searches cookie database and check the cookie is there, if there is matching cookie, then it returns corresponding PID for the cookie.
482 * \par Sync (or) Async:
483 * This is a Synchronous API.
485 * \par Important notes:
486 * Cookie value needs to be stored relatively secure\n
487 * This API is abled to be called only by pre-defined middleware servers.
489 * \param[in] cookie Received cookie value from client application. Cookie is not a null terminated human readable string. Make sure you're code doesn't have any string related process on the cookie.
491 * \return positive integer on success meaning the PID, 0 means the cookie is for root process, negative integer error code on error.
493 * \par Prospective clients:
494 * Only pre-defiend middleware daemons
496 * \par Known issues/bugs:
503 * \see security_server_request_cookie(), security_server_get_cookie_size()
505 * \remarks the cookie is not a null terminated string. Cookie is a BINARY byte stream of such length which can be retrieved by security_server_get_cookie_size() API.
506 * Therefore, please do not use strcpy() family to process cookie value. You MUST use memcpy() function to process cookie value.
507 * You also have to know that the cookie value doesn't carry any null terminator. So you don't need to allocate 1 more byte of the cookie size.
511 * #include <security-server.h>
514 * size_t cookie_size;
516 * cookie_size = security_server_get_cookie_size();
517 * unsigned char recved_cookie[cookie_size];
519 * ... // Receiving request with cookie
521 * peerpid = security_server_get_cookie_pid(recved_cookie);
524 * printf("%s", "Error has occurred\n");
530 * Access to this function requires SMACK rule: "<app_label> security-server::api-cookie-check w"
532 int security_server_get_cookie_pid(const char *cookie);
538 * This API checks phone validity of password, to check existance, expiration, remaining attempts.
541 * This API should be used by applications which needs phone password check. Caller application should behave properly after this API call.
543 * \par Typical use case:
544 * Lock screen can call this API before it shows unlock screen, if there is password, lock screen can show password input UI, if not, lock screen can show just unlock screen
546 * \par Method of function operation:
547 * Sends a validate request to security server and security server replies with password information.
549 * \par Sync (or) Async:
550 * This is a Synchronous API.
552 * \par Important notes:
553 * Password file should be stored safely. The password file will be stored by security server and only allowed itself to read/write, and data is will be securely hashed\n
555 * \param[out] current_attempts Number of password check missed attempts.
556 * \param[out] max_attempts Number of maximum attempts that the password locks. 0 means infinite
557 * \param[out] valid_secs Remaining time in second which represents this password will be expired. 0xFFFFFFFF means infinite
559 * \return 0 if there is no password set, other negative integer error code on error.
561 * \par Prospective clients:
562 * Applications which can unlock UI
564 * \par Known issues/bugs:
571 * \see security_server_set_pwd(), security_server_chk_pwd()
573 * \remarks If password file is currupted or accitentally deleted, this API may not synchronized with security-server, but security-server will check file status on next request.
577 * #include <security-server.h>
580 * unsigned int attempt, max_attempt, expire_sec;
582 * ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
583 * if(is_pwd_set == SECURITY_SERVER_API_ERROR_NO_PASSWORD)
585 * printf("%s", "There is no password exists\n");
587 * else if(is_pwd_set == SECURITY_SERVER_SUCCESS && expire_sec > 0 && attempt < max_attempts)
589 * printf("%s", "Password is valid by now\n");
593 * printf("%s", "Something wrong\n");
599 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-check w"
601 int security_server_is_pwd_valid(unsigned int *current_attempts,
602 unsigned int *max_attempts,
603 unsigned int *valid_secs);
609 * This API sets phone password only if current password matches.
612 * This API should be used by setting application when the user changes his/her phone password.
614 * \par Typical use case:
615 * Setting application calls this API to change phone password. Caller needs current password to grant the change.
617 * \par Method of function operation:
618 * Sends current password with new password to security-server, security-server checks current password and set new password to current only when current password is correct. Caller application can determine maximum number of attempts and expiration time in days
620 * \par Sync (or) Async:
621 * This is a Synchronous API.
623 * \par Important notes:
624 * There is retry timer on this API to limit replay attack. You will get error if you called this API too often.\n
626 * \param[in] cur_pwd Null terminated current password string. It can be NULL pointer if there is no password set yet - by calling security_server_is_pwd_empty()
627 * \param[in] new_pwd Null terminated new password string. It must not a NULL pointer.
628 * \param[in] max_challenge Maximum number of attempts that user can try to check the password without success in serial. 0 means infinity.
629 * \param[in] valid_period_in_days. Number of days that this password is valid. 0 means infinity
631 * \return 0 on seccuess, negative integer error code on error.
633 * \par Prospective clients:
634 * Platform's THE ONLY setting application and some dedicated privileged processes
636 * \par Known issues/bugs:
643 * \see security_server_is_pwd_valid(), security_server_chk_pwd(), security_server_reset_pwd()
645 * \remarks Only setting application can call this API. The password file will be acces controlled and securely hashed. Security-server will remain previous password file to recover unexpected password file curruption.
646 * \remarks If current password exists and it's expired, or max attempts reached, you cannot call this API. You have to call security_server_reset_pwd() API.
650 * #include <security-server.h>
653 * unsigned int attempt, max_attempt, expire_sec;
655 * ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec);
656 * if(is_pwd_set == SECURITY_SERVER_API_ERROR_NO_PASSWORD)
658 * printf("%s", "There is no password exists\n");
659 * ret = security_server_set_pwd(NULL, "this_is_new_pwd", 20, 365);
660 * if(ret != SECURITY_SERVER_API_SUCCESS)
662 * printf("%s", "we have error\n");
666 * else if(is_pwd_set == SECURITY_SERVER_SUCCESS && expire_sec > 0 && attempt < max_attempts)
668 * printf("%s", "Password is valid by now\n");
669 * ret = security_server_set_pwd("this_is_current_pwd", "this_is_new_pwd", 20, 365);
670 * if(ret != SECURITY_SERVER_API_SUCCESS)
672 * printf("%s", "we have error\n");
678 * printf("%s", "Something wrong\n");
684 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-set w"
686 int security_server_set_pwd(const char *cur_pwd,
688 const unsigned int max_challenge,
689 const unsigned int valid_period_in_days);
694 * This API sets validity period for currently setup password.
697 * This API should be used by Enterprise authorities to modify password policy. To be used only with valid password setup.
699 * \par Typical use case:
700 * Authorized application calls this API to change current passwords validity when password policy needs to be changed.
702 * \par Method of function operation:
703 * Function attempts to find currently set password and changes its current validity to passed number of days. Retry counter for the password is reset to zero.
704 * If there is no password set, function returns proper error code.
706 * \par Sync (or) Async:
707 * This is a Synchronous API.
708 * \param[in] valid_period_in_days. Number of days that this password is valid. 0 means infinity
710 * \return 0 on success, negative integer error code on error.
712 * \par Prospective clients:
713 * Platform's THE ONLY setting application and some dedicated privileged processes
715 * \par Known issues/bugs:
716 * Identifying calling peer is not ready yet, should be based on SMACK somehow.
718 * \see security_server_is_pwd_valid(), security_server_chk_pwd(), security_server_reset_pwd()
720 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-set w"
722 int security_server_set_pwd_validity(const unsigned int valid_period_in_days);
727 * This API sets maximum number of attempts for currently setup password.
730 * This API should be used by Enterprise authorities to modify password policy. To be used only with valid password setup.
732 * \par Typical use case:
733 * Authorized application calls this API to change current passwords max attempt number when password policy needs to be changed.
735 * \par Method of function operation:
736 * Function attempts to find currently set password and changes its max attempt number to passed one. Retry counter for the password is reset to zero.
737 * If there is no password set, function returns proper error code.
739 * \par Sync (or) Async:
740 * This is a Synchronous API.
741 * \param[in] max_challenge Maximum number of attempts that user can try to check the password without success in serial. 0 means infinity.
743 * \return 0 on success, negative integer error code on error.
745 * \par Prospective clients:
746 * Platform's THE ONLY setting application and some dedicated privileged processes
748 * \par Known issues/bugs:
749 * Identifying calling peer is not ready yet, should be based on SMACK somehow.
751 * \see security_server_is_pwd_valid(), security_server_chk_pwd(), security_server_reset_pwd()
753 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-set w"
755 int security_server_set_pwd_max_challenge(const unsigned int max_challenge);
759 * This API sets phone password only if current password is invalid or user forgot the password.
762 * This API should be used by setting application or dedicated processes when the user changes his/her phone password.
764 * \par Typical use case:
765 * User forgots the password. He calls emergency manager(auto or manual) for reset password. Emergency manager calls this API and reset phone password.
767 * \par Method of function operation:
768 * Resetting phone password with input string without any matching current password.
770 * \par Sync (or) Async:
771 * This is a Synchronous API.
773 * \par Important notes:
774 * There is retry timer on this API to limit replay attack. You will get error if you called this API too often.\n
776 * \param[in] new_pwd Null terminated new password string. It must not a NULL pointer.
777 * \param[in] max_challenge Maximum number of attempts that user can try to check the password without success in serial. 0 means infinity.
778 * \param[in] valid_period_in_days. Number of days that this password is valid. 0 means infinity
780 * \return 0 on seccuess, negative integer error code on error.
782 * \par Prospective clients:
783 * Platform's THE ONLY setting application and some dedicated privileged processes
785 * \par Known issues/bugs:
792 * \see security_server_is_pwd_valid(), security_server_chk_pwd(), security_server_set_pwd()
794 * \remarks Only dedicated applications can call this API. The password file will be acces controlled and securely hashed. Security-server will remain previous password file to recover unexpected password file curruption.
798 * #include <security-server.h>
801 * unsigned int attempt, max_attempt, expire_sec;
803 * ret = security_server_set_pwd("this_is_new_pwd", 20, 365);
804 * if(retval != SECURITY_SERVER_API_SUCCESS)
806 * printf("%s", "we have error\n");
813 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-set w"
815 int security_server_reset_pwd(const char *new_pwd,
816 const unsigned int max_challenge,
817 const unsigned int valid_period_in_days);
821 * This API compares stored phone password with challenged input value.
824 * This API should be used by applications which has phone UI lock capability.
826 * \par Typical use case:
827 * Lock screen calls this API after user typed phone password and pressed okay.
829 * \par Method of function operation:
830 * Sends challenged password to security-server, security-server compares hashed current password and hashed challenged password.
832 * \par Sync (or) Async:
833 * This is a Synchronous API.
835 * \par Important notes:
836 * There is retry timer on this API to limit replay attack. You will get error if you called this API too often.\n
838 * \param[in] challenge Null terminated challenged password string. It must not a NULL pointer.
839 * \param[out] current_attempts Number of password check missed attempts.
840 * \param[out] max_attempts Number of maximum attempts that the password locks. 0 means infinite
841 * \param[out] valid_secs Remaining time in second which represents this password will be expired. 0xFFFFFFFF means infinite
843 * \return 0 on seccuess, negative integer error code on error.
845 * \par Prospective clients:
846 * Applications which has phone UI lock feature.
848 * \par Known issues/bugs:
855 * \see security_server_is_pwd_valid(), security_server_set_pwd()
857 * \remarks The password file will be acces controlled and securely hashed. Security-server will remain previous password file to recover unexpected password file curruption.
861 * #include <security-server.h>
864 * unsigned int attempt, max_attempt, expire_sec;
866 * retval = security_server_chk_pwd("is_this_password", &attmpt, &max_attempt, &expire_sec);
867 * if(retval == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH)
869 * printf("%s", "Oh you typed wrong password\n");
872 * else if(retval == SECURITY_SERVER_API_SUCCESS)
874 * printf("%s", "You remember your password.\n");
881 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-check w"
883 int security_server_chk_pwd(const char *challenge,
884 unsigned int *current_attempt,
885 unsigned int *max_attempt,
886 unsigned int *valid_secs);
891 * This API set the number of password history which should be maintained. Once this number set, user cannot reuse recent number of passwords which is described in this history value
894 * This API should be used only by dedicated process in the platform.
896 * \par Typical use case:
897 * Enterprise manager calls this API when the enterprise wants to enforce harder password policy.
899 * \par Method of function operation:
900 * When enterprise manager (MDM) is trying to change the security policy for phone password, it calls this API background to change the history policy.
902 * \par Sync (or) Async:
903 * This is a Synchronous API.
905 * \par Important notes:
906 * There is retry timer on this API to limit replay attack. You will get error if you called this API too often.\n
908 * \param[in] number_of_history Number of history to be checked when user tries to change password. Maximum is currently 50
910 * \return 0 on seccuess, negative integer error code on error.
912 * \par Prospective clients:
913 * MDM client, Enterprise manager.
915 * \par Known issues/bugs:
922 * \see security_server_set_pwd()
924 * \remarks The password file will be acces controlled and securely hashed. Security-server will remain previous password file to recover unexpected password file curruption.
928 * #include <security-server.h>
932 * ret = security_server_set_pwd_history(100);
933 * if(ret != SECURITY_SERVER_API_SUCCESS)
935 * printf("%s", "You have error\n");
942 * Access to this function requires SMACK rule: "<app_label> security-server::api-password-set w"
944 int security_server_set_pwd_history(int number_of_history);
947 * This function allows to get process SMACK label by passing cookie assigned
948 * to process. Function returns pointer to allocated buffer with label.
949 * User has to free the buffer after using.
951 * \param[in] Pointer to cookie
953 * \return Pointer to SMACK label or NULL
955 * \par For free label use free(), label allocated by calloc()
956 * User responsibility is to free resource.
958 * Access to this function requires SMACK rule: "<app_label> security-server::api-cookie-check w"
960 char *security_server_get_smacklabel_cookie(const char *cookie);
963 * This function allows to get process SMACK label by passing socket descriptor.
964 * Function returns pointer to allocated buffer with label.
965 * User has to free the buffer after using.
967 * \param[in] Socket descriptor
969 * \return Pointer to SMACK label or NULL
971 * \par For free label use free(), label allocated by calloc().
972 * User responsibility is to free resource.
974 * Access to this function not requires SMACK rule
976 char *security_server_get_smacklabel_sockfd(int fd);
979 * This function will give permissions "rwxat" from
980 * (subject) customer_label to caller process (object).
981 * Object label will be extracted from socket.
983 * Access to this function requires SMACK rule: "<app_label> security-server::api-data-share w"
985 int security_server_app_give_access(const char *customer_label, int customer_pid);
988 * This function allows middleware to check priviliges of process with specified PID.
989 * Service is able to check proces acces to the specified object label with specified
992 * \param[in] PID number of process to be checked
993 * \param[in] SMACK object label
994 * \param[in] SMACK access rights to be checked
996 * \return Privilege confirm or error code
997 * SECURITY_SERVER_SUCCESS - on succes
999 * Access to this function requires SMACK rule: "<app_label> security-server::api-privilege-by-pid w"
1001 int security_server_check_privilege_by_pid(int pid, const char *object, const char *access_rights);
1004 * This function allows middleware to enable permissions for specified app_id.
1006 * \param[in] Application ID
1007 * \param[in] Application type definet in enum at the beginning of this file
1008 * \param[in] Permissions list
1009 * \param[in] Persistent
1011 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1013 * Access to this function requires SMACK rule: "<app_label> security-server::api-app-permissions w"
1015 int security_server_app_enable_permissions(const char *app_id, app_type_t app_type, const char **perm_list, int persistent);
1018 * This function allows middleware to disable permissions for specified app_id.
1020 * \param[in] Application ID
1021 * \param[in] Application type definet in enum at the beginning of this file
1022 * \param[in] Permissions list
1024 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1026 * Access to this function requires SMACK rule: "<app_label> security-server::api-app-permissions w"
1028 int security_server_app_disable_permissions(const char *app_id, app_type_t app_type, const char **perm_list);
1031 * This function allows middleware to get UID assigned to cookie
1034 * \param[out] Handler to store UID
1036 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1038 * Access to this function requires SMACK rule: "<app_label> security-server::api-cookie-check w"
1040 int security_server_get_uid_by_cookie(const char *cookie, uid_t *uid);
1043 * This function allows middleware to check if an app has the specified privilege
1046 * \param[in] Application ID
1047 * \param[in] Application type
1048 * \param[in] Privilege name
1049 * \param[out] Handler to store the result. It is set to 1 (true) if privilege is enabled, 0 (false) otherwise
1051 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1053 * Access to this function requires SMACK rule: "<app_label> security-server::api-app-privilege-by-name w"
1055 int security_server_app_has_privilege(const char *app_id,
1056 app_type_t app_type,
1057 const char *privilege_name,
1061 * This function allows middleware to check if caller app has the specified privilege
1062 * enabled. Security Server gets caller app smack label from the IPC socket.
1064 * \param[in] Application type
1065 * \param[in] Privilege name
1066 * \param[out] Handler to store the result. It is set to 1 (true) if privilege is enabled, 0 (false) otherwise
1068 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1070 * Access to this function requires SMACK rule: "<app_label> security-server::api-app-privilege-by-name w"
1072 int security_server_app_caller_has_privilege(app_type_t app_type,
1073 const char *privilege_name,
1077 * This function allows middleware to get GID assigned to cookie
1080 * \param[out] Handler to store GID
1082 * \return SECURITY_SERVER_SUCCESS on success or error code on fail
1084 * Access to this function requires SMACK rule: "<app_label> security-server::api-cookie-check w"
1086 int security_server_get_gid_by_cookie(const char *cookie, gid_t *gid);