2 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
17 * @file src/include/cynara-creds-commons.h
18 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
19 * @author Radoslaw Bartosiak <r.bartosiak@samsung.com>
20 * @author Aleksander Zdyb <a.zdyb@samsung.com>
22 * @brief This file contains common APIs for Cynara credentials helper.
26 #ifndef CYNARA_CREDS_COMMONS_H
27 #define CYNARA_CREDS_COMMONS_H
29 #include <cynara-error.h>
31 enum cynara_client_creds {
36 enum cynara_user_creds {
47 * Gets the system default method value for client feature used in cynara-creds.
50 * Functions cynara_creds_dbus_get_client() and cynara_creds_socket_get_client() take a method
51 * parameter, which determines a kind of process feature (i.e PID, SMACK label) returned by them.
52 * The described function provides implementation for obtaining a system default value
55 * \par Typical use case:
56 * The function might be called before cynara_creds_dbus_get_client()
57 * and cynara_creds_socket_get_client(), when functions shall be invoked with system default
58 * value of method parameter.
60 * \par Method of function operation:
61 * When this function is called for the first time it reads and returns the value of client_default
62 * parameter from /etc/cynara/creds.conf file (the path is determined by CYNARA_CONFIGURATION_DIR).
63 * Returned value is cached so subsequent calls will not consult file again but use cached value.
64 * This also means that after the initial call any changes in the file will be ignored for the
65 * remaining lifetime of the process.
67 * \par Sync (or) Async:
68 * This is a synchronous API.
71 * This function is thread-safe.
73 * \param[out] method Placeholder for system default client feature
74 * (like CLIENT_METHOD_SMACK, CLIENT_METHOD_PID)
76 * \return CYNARA_API_SUCCESS on success
77 * CYNARA_API_CONFIGURATION_ERROR if the configuration file can not be opened or
78 * there are errors in configuration file.
79 * CYNARA_API_OUT_OF_MEMORY if there is error in memory allocation.
80 * CYNARA_API_UNKNOWN_ERROR if there is other error.
83 int cynara_creds_get_default_client_method(enum cynara_client_creds *method);
87 * Gets the system default method value for user feature used in cynara-creds.
90 * Functions cynara_creds_dbus_get_user() and cynara_creds_socket_get_user() take a method
91 * parameter, which determines a kind of process feature (i.e UID, GID) returned by them.
92 * The described function provides implementation for obtaining a system default value
95 * \par Typical use case:
96 * The function might be called before cynara_creds_dbus_get_user()
97 * and cynara_creds_socket_get_user() when functions shall be invoked with system default
98 * value of method parameter.
100 * \par Method of function operation:
101 * When this function is called for the first time it reads and returns the value of user_default
102 * parameter from /etc/cynara/creds.conf file (the path is determined by CYNARA_CONFIGURATION_DIR).
103 * Returned value is cached so subsequent calls will not consult file again but use cached value.
104 * This also means that after the initial call any changes in the file will be ignored for the
105 * remaining lifetime of the process.
107 * \par Sync (or) Async:
108 * This is a synchronous API.
110 * \par Thread safety:
111 * This function is thread-safe.
113 * \param[out] method Placeholder for system default user feature
114 * (like USER_METHOD_UID, USER_METHOD_GID)
116 * \return CYNARA_API_SUCCESS on success
117 * CYNARA_API_CONFIGURATION_ERROR if the configuration file can not be opened or
118 * there are errors in configuration file.
119 * CYNARA_API_OUT_OF_MEMORY if there is error in memory allocation.
120 * CYNARA_API_UNKNOWN_ERROR if there is other error.
122 int cynara_creds_get_default_user_method(enum cynara_user_creds *method);
128 #endif /* CYNARA_CREDS_COMMONS_H */