2 * Copyright (c) 2014 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/helpers/creds-socket/creds-socket.cpp
18 * @author Radoslaw Bartosiak <r.bartosiak@samsung.com>
19 * @author Aleksander Zdyb <a.zdyb@samsung.com>
20 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
22 * @brief Implementation of external libcynara-creds-socket API
25 #include <sys/socket.h>
26 #include <sys/types.h>
28 #include <attributes/attributes.h>
30 #include <creds-socket-inner.h>
32 #include <cynara-client-error.h>
33 #include <cynara-creds-commons.h>
34 #include <cynara-creds-socket.h>
37 int cynara_creds_socket_get_client(int socket_fd, enum cynara_client_creds method, char **client) {
38 if (client == nullptr)
39 return CYNARA_API_INVALID_PARAM;
42 case cynara_client_creds::CLIENT_METHOD_SMACK:
43 return getClientSmackLabel(socket_fd, client);
44 case cynara_client_creds::CLIENT_METHOD_PID:
45 return getClientPid(socket_fd, client);
47 return CYNARA_API_METHOD_NOT_SUPPORTED;
52 int cynara_creds_socket_get_user(int socket_fd, enum cynara_user_creds method, char **user) {
54 return CYNARA_API_INVALID_PARAM;
57 case cynara_user_creds::USER_METHOD_UID:
58 return getUserId(socket_fd, user);
59 case cynara_user_creds::USER_METHOD_GID:
60 return getUserGid(socket_fd, user);
62 return CYNARA_API_METHOD_NOT_SUPPORTED;
67 int cynara_creds_socket_get_pid(int socket_fd, pid_t *pid) {
68 return getPid(socket_fd, pid);