*
* Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Yong Yeon Kim <yy9875.kim@samsung.com>
- *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
#include <media-util-cynara.h>
#include <media-util-dbg.h>
#include <media-util-err.h>
-#include <media-util-internal.h>
#include <cynara-client.h>
#include <cynara-session.h>
ret = cynara_creds_socket_get_client(sockfd, CLIENT_METHOD_SMACK, &(credentials->smack));
if (ret != 0) {
MSAPI_DBG_ERR("[CYNARA]Failed to get smack");
- MS_SAFE_FREE(credentials->uid);
+ if (credentials->uid) {
+ free(credentials->uid);
+ credentials->uid = NULL;
+ }
return MS_MEDIA_ERR_INTERNAL;
}
return MS_MEDIA_ERR_NONE;
}
-int ms_cynara_receive_untrusted_message_thumb(int sockfd, thumbMsg *recv_msg, ms_peer_credentials *credentials)
-{
- int ret = 0;
- unsigned int header_size = 0;
- int recv_msg_size = 0;
- unsigned char *buf = NULL;
-
- if (!recv_msg || !credentials)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- header_size = sizeof(thumbMsg) - sizeof(unsigned char *);
- buf = g_malloc0(header_size);
-
- if ((recv_msg_size = recv(sockfd, buf, header_size, 0)) < 0) {
- MSAPI_DBG_STRERROR("recv failed");
- g_free(buf);
- return MS_MEDIA_ERR_IPC;
- }
-
- memcpy(recv_msg, buf, header_size);
- MS_SAFE_FREE(buf);
-
- /* Can be null (kill server msg) */
- if (strlen(recv_msg->org_path) >= MAX_FILEPATH_LEN) {
- MSAPI_DBG_ERR("org_path size is invlid[%zu]", strlen(recv_msg->org_path));
- return MS_MEDIA_ERR_IPC;
- }
-
- /* Can be null (raw request case) */
- if (strlen(recv_msg->dst_path) >= MAX_FILEPATH_LEN) {
- MSAPI_DBG_ERR("dst_path size is invlid[%zu]", strlen(recv_msg->dst_path));
- return MS_MEDIA_ERR_IPC;
- }
-
- ret = cynara_creds_socket_get_pid(sockfd, &(credentials->pid));
- MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "[CYNARA]Failed to get pid");
-
- ret = cynara_creds_socket_get_user(sockfd, USER_METHOD_UID, &(credentials->uid));
- MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "[CYNARA]Failed to get uid");
-
- ret = cynara_creds_socket_get_client(sockfd, CLIENT_METHOD_SMACK, &(credentials->smack));
- MSAPI_RETVM_IF(ret != 0, MS_MEDIA_ERR_INTERNAL, "[CYNARA]Failed to get smack");
-
- return MS_MEDIA_ERR_NONE;
-}
-
int ms_cynara_check(const ms_peer_credentials *creds, const char *privilege)
{
- int result;
- char *session;
+ int result = 0;
+ char *session = NULL;
if (!creds || !privilege)
return MS_MEDIA_ERR_INVALID_PARAMETER;
if (result != CYNARA_API_ACCESS_ALLOWED)
ms_cynara_dbg_err("cynara_check", result);
- MS_SAFE_FREE(session);
+ if (session)
+ free(session);
+
return result == CYNARA_API_ACCESS_ALLOWED ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_PERMISSION_DENIED;
}
return MS_MEDIA_ERR_NONE;
}
-