Remove media-util-internal.h
[platform/core/multimedia/media-server.git] / lib / media-util-cynara.c
old mode 100755 (executable)
new mode 100644 (file)
index 78244c5..f0f4c9c
@@ -3,8 +3,6 @@
  *
  * 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
@@ -34,7 +32,6 @@
 #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>
@@ -120,7 +117,10 @@ int ms_cynara_receive_untrusted_message(int sockfd, ms_comm_msg_s *recv_msg, ms_
        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;
        }
@@ -128,45 +128,10 @@ int ms_cynara_receive_untrusted_message(int sockfd, ms_comm_msg_s *recv_msg, ms_
        return MS_MEDIA_ERR_NONE;
 }
 
-int ms_cynara_receive_untrusted_message_thumb(int sockfd, thumbMsg *recv_msg, ms_peer_credentials *credentials)
-{
-       int ret = 0;
-
-       if (!recv_msg || !credentials)
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-
-       if (recv(sockfd, recv_msg, sizeof(thumbMsg), 0) < 0) {
-               MSAPI_DBG_STRERROR("recv failed");
-               return MS_MEDIA_ERR_IPC;
-       }
-
-       /* Can be null (kill server msg) */
-       if (strlen(recv_msg->org_path) >= MAX_FILEPATH_LEN) {
-               MSAPI_DBG_ERR("org_path size is invalid[%zu]", strlen(recv_msg->org_path));
-               return MS_MEDIA_ERR_IPC;
-       }
-
-       if (strlen(recv_msg->dst_path) >= MAX_FILEPATH_LEN) {
-               MSAPI_DBG_ERR("dst_path size is invalid[%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;
@@ -181,7 +146,9 @@ int ms_cynara_check(const ms_peer_credentials *creds, const char *privilege)
        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;
 }