Update Certificate for TLS-PSK connection 93/233093/6
authorMukunth A <a.mukunth@samsung.com>
Mon, 11 May 2020 11:21:30 +0000 (16:51 +0530)
committerMukunth A <a.mukunth@samsung.com>
Thu, 14 May 2020 07:53:15 +0000 (13:23 +0530)
Change-Id: I0f1b91eac496ee8453263e8d1d50472dddbfcf04
Signed-off-by: Mukunth A <a.mukunth@samsung.com>
CMain/Makefile
CMain/inc/orchestration.h
CMain/lib/liborchestration.a
CMain/src/orchestration_dbus_server.c
CMain/src/orchestration_key.c
packaging/org.tizen.orchestration.conf

index f97b19cb0f3141f7467a016c42fbcb122ae9f206..eb83433ad97b5cff5c6d0829ecc892e5cab1269e 100644 (file)
@@ -7,7 +7,7 @@ BIN_DIR                 := bin
 LIB_DIR                        := lib
 INC_DIR                        := inc
 SRC_DIR                        := src
-LIBRARY_FILE   := orchestration
+LIBRARY_FILE           := orchestration
 BINARY_FILE            := edge-orchestration
 SRC_FILES              := \
                        $(SRC_DIR)/main.c \
@@ -30,4 +30,4 @@ clean:
        -rm -f $(OBJ_FILES) 
        -rm -f $(BIN_DIR)/$(BINARY_FILE)
 
-.PHONY: build clean
\ No newline at end of file
+.PHONY: build clean
index 8e73edb574fd499da4a2b2d0ce9e7955ccf48b5b..2ab46b3362b16b9067508fe0aef1aa990bdb23a3 100644 (file)
@@ -19,9 +19,9 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_;
 /* Start of preamble from import "C" comments.  */
 
 
-#line 32 "main_secured.go"
+#line 21 "main.go"
 /*******************************************************************************
- * Copyright 2019 Samsung Electronics All Rights Reserved.
+ * Copyright 2020 Samsung Electronics All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -145,10 +145,10 @@ extern int OrchestrationInit();
 
 extern ResponseService OrchestrationRequestService(char* p0, int p1, char* p2, RequestServiceInfo* p3, int p4);
 
-extern int PrintLog(char* p0);
-
 extern void SetPSKHandler(identityGetterFunc p0, keyGetterFunc p1);
 
+extern int PrintLog(char* p0);
+
 #ifdef __cplusplus
 }
 #endif
index 12235f20cc9a7b443f25f7131972ea92987fe4ca..d038993ec89c707f79db51dce846c22842a247ff 100644 (file)
Binary files a/CMain/lib/liborchestration.a and b/CMain/lib/liborchestration.a differ
index ec11fe0b4d84d500eb0e7a1afefde4de17761606..e6ef4e97c863789092ba1151d164ea916a5d3bfb 100644 (file)
@@ -74,12 +74,12 @@ static gchar introspection_xml[] =
     "          <arg type='i' name='client_pid' direction='in'/>"
     "          <arg type='i' name='return_value' direction='out'/>"
     "        </method>"
-       "        <method name='update_key_pair'>"
-       "          <arg type='s' name='id' direction='in'/>"
-       "          <arg type='s' name='key' direction='in'/>"
-       "          <arg type='i' name='client_pid' direction='in'/>"
-       "          <arg type='i' name='return_value' direction='out'/>"
-       "        </method>"
+    "        <method name='update_key_pair'>"
+    "          <arg type='s' name='id' direction='in'/>"
+    "          <arg type='s' name='key' direction='in'/>"
+    "          <arg type='i' name='client_pid' direction='in'/>"
+    "          <arg type='i' name='return_value' direction='out'/>"
+    "        </method>"
     "  </interface>"
     "  </node>";
 /* ---------------------------------------------------------------------------------------------------- */
@@ -364,63 +364,63 @@ static int _update_key_pair(GVariant *parameters, int origin_client_pid)
     g_variant_get(parameters, "(ssi)", &id, &key, &client_pid);
 
     DEBUG("[orchestration dbus_interface] _update_key_pair\n");
-    DEBUG("\t id = %s\n", id);
-    DEBUG("\t key = %s\n", key);
-    DEBUG("\t client_pid = %d\n", client_pid);
 
-    if (g_strcmp0(id, "") == 0 || g_strcmp0(key, "") == 0) {
+    if (id == NULL || key == NULL) {
         return ORCH_ERROR_INVALID_PARAMETER;
     }
 
+    DEBUG("\t id = %s\n", id);
+    DEBUG("\t key = %s\n", key);
+    DEBUG("\t client_pid = %d\n", client_pid);
+
     if (origin_client_pid != client_pid) {
         DEBUG("not matched clinet_pid from client and dbus, origin_client_pid(%d), client_pid(%d)\n", origin_client_pid, client_pid);
     }
 
     char process_name[128] = {0, };
-       const char unknown[] = "Unknown";
-       if (get_process_name_by_pid(process_name, origin_client_pid) != 0) {
-               DEBUG("could not get Process name");
-               strncpy(process_name, unknown, strlen(unknown));
-       }
+    const char unknown[] = "Unknown";
+    if (get_process_name_by_pid(process_name, origin_client_pid) != 0) {
+        DEBUG("could not get Process name");
+        strncpy(process_name, unknown, strlen(unknown));
+    }
 
-       result = _update_key_pair_cb(id, key, process_name);
+    result = _update_key_pair_cb(id, key, process_name);
 
     return result;
 }
 
-
 static int get_process_name_by_pid(char* process_name, int pid) {
-       char fname[1024] = {0, };
-       char line[1024] = {0, };
-       ssize_t fname_len = snprintf(NULL, 0, "/proc/%d/status", pid);
-
-       snprintf(fname, fname_len + 1, "/proc/%d/status", pid);
-       FILE *fp = fopen(fname, "r");
-       if (fp == NULL) {
-               DEBUG("%d Process not found!!!\n", pid);
-               return -1;
-       }
-       while (!feof(fp)) {
-               fgets(line, 1024, fp);
-               if (strstr(line, "Name:") != NULL) {
-                       int index = 0;
-                       char *ptr = strchr(line, ':');
-                       while (1) {
-                               ptr++;
-                               if (*ptr == '\n' || *ptr == '\0')
-                                       break;
-                               if (*ptr != ' ' && *ptr != '\t')
-                                       process_name[index++] = *ptr;
-                       }
-                       process_name[index] = '\0';
-                       printf("process_name = %s\n", process_name);
-                       fclose(fp);
-                       return 0;
-               }
-       }
-       printf("%d Process status have no Process name!!\n", pid);
-       fclose(fp);
-       return -1;
+    char fname[1024] = {0, };
+    char line[1024] = {0, };
+    ssize_t fname_len = snprintf(NULL, 0, "/proc/%d/status", pid);
+
+    snprintf(fname, fname_len + 1, "/proc/%d/status", pid);
+    FILE *fp = fopen(fname, "r");
+    if (fp == NULL) {
+        DEBUG("%d Process not found!!!\n", pid);
+        return -1;
+    }
+    while (!feof(fp)) {
+        fgets(line, 1024, fp);
+        if (strstr(line, "Name:") != NULL) {
+            int index = 0;
+            char *ptr = strchr(line, ':');
+            while (1) {
+                ptr++;
+                if (*ptr == '\n' || *ptr == '\0')
+                    break;
+                if (*ptr != ' ' && *ptr != '\t')
+                    process_name[index++] = *ptr;
+            }
+            process_name[index] = '\0';
+            printf("process_name = %s\n", process_name);
+            fclose(fp);
+            return 0;
+        }
+    }
+    printf("%d Process status have no Process name!!\n", pid);
+    fclose(fp);
+    return -1;
 }
 
 static int get_pid_with_connection(const gchar* sender) {
index 2d00093171daecd71f3939313be848f10dc4de8c..ea0498414d924f691252e4956a525f60aef5cee0 100644 (file)
 
 #include "orchestration_type.h"
 
-#define MAX_KEY_SIZE 256
+#define MAX_KEY_SIZE 2048
 
 static char id[MAX_KEY_SIZE];
 static char key[MAX_KEY_SIZE];
 
 int updateKeyPair(char* _id,char* _key) {
-       if (strlen(_id) > MAX_KEY_SIZE) {
-               DEBUG("invalid id size: %u/n", strlen(_id));
-               return -1;
-       }
-       else if (strlen(_key) > MAX_KEY_SIZE) {
-               DEBUG("invalid key size: %u/n", strlen(_key));
-               return -1;
-       }
-       strncpy(id, _id, strlen(_id));
-       strncpy(key, _key, strlen(_key));
-
-       return 0;
+    if (strlen(_id) > MAX_KEY_SIZE) {
+        DEBUG("invalid id size: %u/n", strlen(_id));
+        return -1;
+    }
+    else if (strlen(_key) > MAX_KEY_SIZE) {
+        DEBUG("invalid key size: %u/n", strlen(_key));
+        return -1;
+    }
+
+    strncpy(id, _id, strlen(_id));
+    id[strlen(_id)] = '\0';
+    strncpy(key, _key, strlen(_key));
+    key[strlen(_key)] = '\0';
+
+    return 0;
 }
 
 char* identityGetter() {
-       return id;
+    return id;
 }
 char* keyGetter(char* id) {
-       return key;
+    return key;
 }
index 4b0099b0f3f771213c99760b2bff4552cf44b844..82b9377aca2bbbccd84caefcc4cb7e374af8c490 100644 (file)
@@ -18,6 +18,8 @@
                <allow send_destination="org.tizen.orchestration" send_interface="org.tizen.orchestration.agent"/>
                <check send_destination="org.tizen.orchestration" send_interface="org.tizen.orchestration.agent"
                        send_member="request_service" privilege="http://tizen.org/privilege/appmanager.launch"/>
+               <check send_destination="org.tizen.orchestration" send_interface="org.tizen.orchestration.agent"
+                       send_member="update_key_pair" privilege="http://tizen.org/privilege/appmanager.launch"/>
        </policy>
        <policy context="default">
                <deny own="org.tizen.orchestration"/>