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 creds-dbus.cpp
18 * @author Radoslaw Bartosiak <r.bartosiak@samsung.com>
19 * @author Aleksander Zdyb <a.zdyb@partner.samsung.com>
20 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
22 * @brief Implementation of external libcynara-creds-dbus API
26 #include <attributes/attributes.h>
28 #include <creds-dbus-inner.h>
30 #include <cynara-client-error.h>
31 #include <cynara-creds-commons.h>
32 #include <cynara-creds-dbus.h>
35 int cynara_creds_dbus_get_client(DBusConnection *connection, const char *uniqueName,
36 enum cynara_client_creds method, char **client) {
37 if (connection == nullptr || uniqueName == nullptr || client == nullptr)
38 return CYNARA_API_INVALID_PARAM;
41 case cynara_client_creds::CLIENT_METHOD_SMACK:
42 return getClientSmackLabel(connection, uniqueName, client);
43 case cynara_client_creds::CLIENT_METHOD_PID:
44 return getClientPid(connection, uniqueName, client);
46 return CYNARA_API_METHOD_NOT_SUPPORTED;
51 int cynara_creds_dbus_get_user(DBusConnection *connection, const char *uniqueName,
52 enum cynara_user_creds method, char **user) {
53 if (connection == nullptr || uniqueName == nullptr || user == nullptr)
54 return CYNARA_API_INVALID_PARAM;
57 case cynara_user_creds::USER_METHOD_UID:
58 return getUserId(connection, uniqueName, user);
59 case cynara_user_creds::USER_METHOD_GID:
60 return getUserGid(connection, uniqueName, user);
62 return CYNARA_API_METHOD_NOT_SUPPORTED;
67 int cynara_creds_dbus_get_pid(DBusConnection *connection, const char *uniqueName, pid_t *pid) {
68 if (connection == nullptr || uniqueName == nullptr)
69 return CYNARA_API_INVALID_PARAM;
71 return getPid(connection, uniqueName, pid);