Fix compilation errors of security.c 61/137061/1
authoru.harbuz <u.harbuz@samsung.com>
Fri, 23 Jun 2017 10:12:05 +0000 (12:12 +0200)
committerLukasz Kostyra <l.kostyra@samsung.com>
Tue, 4 Jul 2017 08:27:40 +0000 (10:27 +0200)
Change-Id: I22da6c5a9cd564dd81ee70cba1da2ee56e663cb2

simulatordaemon/inc/security.h
simulatordaemon/src/security.c

index b8153ca..8481bf0 100644 (file)
@@ -29,6 +29,7 @@
 
 #define MAX_PATH_LENGTH 100
 #define MAX_TA_NAME_LENGTH 36
+#define MAX_OPENED_FD 20
 
 #define FILE_WAS_FOUND 1 
 
 extern "C" {
 #endif
 
-/* TODO: */
-const char* system_ta_paths[]= {
-    "/usr/lib/optee_armtz/",
-}
 #define N_SYS_TA_PATHS 1
 
 bool ca_has_access_to_ta(int ca_fd, const char* ta_name);
index 7ae3958..ea225ac 100644 (file)
 /* This variable is for nftw searching of ta */
 static const char* g_ta_name = NULL;
 
+static const char* system_ta_paths[N_SYS_TA_PATHS]= {
+    "/usr/lib/optee_armtz/",
+};
+
 
 static bool file_exists(const char* fname){
     struct stat st;
@@ -46,7 +50,7 @@ static bool get_ca_full_path_from_socket(int fd, char* path){
         return false;
     }
 
-    ret = cynara_creds_socket_get_pid(ca_fd, &ca_pid);
+    ret = cynara_creds_socket_get_pid(fd, &ca_pid);
     if(ret != CYNARA_API_SUCCESS){
         EMSG("Couldn't get pid of the client. Error code: %d", ret);
         cynara_finish(cynara);
@@ -74,7 +78,7 @@ static int cmp_ta_name(const char *fpath, const struct stat *sb,
 {
     if(tflag == FTW_D){
         char ta_full_path[MAX_PATH_LENGTH] = {0};
-        snprintf(ta_full_name, MAX_PATH_LENGTH, "%s/%s", fpath, g_ta_name);
+        snprintf(ta_full_path, MAX_PATH_LENGTH, "%s/%s", fpath, g_ta_name);
 
         if(file_exists(ta_full_path)){
             return FILE_WAS_FOUND;
@@ -101,7 +105,7 @@ bool ca_has_access_to_ta(int ca_fd, const char* ta_name){
         for(int i = 0; i < N_SYS_TA_PATHS; ++i){
             snprintf(ta_full_path, MAX_PATH_LENGTH, "%s/%s", system_ta_paths[i], ta_name);
 
-            if(file_exists(ta_full_name)){
+            if(file_exists(ta_full_path)){
                 return true;
             }
 
@@ -117,7 +121,7 @@ bool ca_has_access_to_ta(int ca_fd, const char* ta_name){
     }
 
     char ca_pkg_path[MAX_PATH_LENGTH];
-    if(!get_full_ca_path_from_socket(ca_fd, ca_pkg_path)){
+    if(!get_ca_full_path_from_socket(ca_fd, ca_pkg_path)){
         EMSG("Error while loading client's path");
         free(pkg_id_ca);
         return false;