plugin: add verify_path to check valid path for pull 95/195795/1 accepted/tizen/unified/20181218.152422 submit/tizen/20181218.090642
authorjounsun.beak <jounsun.beak@samsung.com>
Tue, 18 Dec 2018 05:39:30 +0000 (14:39 +0900)
committerjounsun.beak <jounsun.beak@samsung.com>
Tue, 18 Dec 2018 05:39:30 +0000 (14:39 +0900)
Change-Id: I63f9baa959b812ff3d07884522ea001a37e7348f
Signed-off-by: jounsun.beak <jounsun.beak@samsung.com>
src/default_plugin.h
src/default_plugin_basic.c
src/default_plugin_main.c
src/file_sync_service.c
src/sdbd_plugin.h

index f5891968674f60bd9f0907549c02195e3253597c..d8ac7f9703bb9be9e8b16b01fb562aa996e527a9 100644 (file)
@@ -28,6 +28,7 @@ int verify_root_cmd ( parameters* in, parameters* out );
 int get_lock_state ( parameters* in, parameters* out );
 int get_shell_env ( parameters* in, parameters* out );
 int verify_push ( parameters* in, parameters* out );
+int verify_pull ( parameters* in, parameters* out );
 
 int auth_support ( parameters* in, parameters* out );
 int auth_get_key_file_paths ( parameters* in, parameters* out );
index 4d4fdb5c58fdad6438273aa1b9b557174d6b796f..5a3d31764ce9c1c362fe09e79c6a19421ca06959 100644 (file)
@@ -303,6 +303,31 @@ int verify_push ( parameters* in, parameters* out )
     return PLUGIN_CMD_SUCCESS;
 }
 
+int verify_pull ( parameters* in, parameters* out )
+{
+    if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
+            || in->array_of_parameter[0].type != type_string ) {
+        E ( "Invalid argument\n" );
+        return PLUGIN_CMD_FAIL;
+    }
+
+    if ( out == NULL ) {
+        E ( "Invalid argument\n" );
+        return PLUGIN_CMD_FAIL;
+    }
+
+    out->number_of_parameter = 1;
+    out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+    if (out->array_of_parameter == NULL) {
+        E("failed to allocate memory for the parameter\n");
+        return PLUGIN_CMD_FAIL;
+    }
+    out->array_of_parameter[0].type = type_int32;
+    out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
+
+    return PLUGIN_CMD_SUCCESS;
+}
+
 int verify_handle_by_plugin ( parameters* in, parameters* out )
 {
     if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
index f6f1f71eed594dc45b7c171cd658f7f27369eba0..14919340ae9e1e26bc4ac9abe5b604e921596025 100644 (file)
@@ -60,8 +60,10 @@ int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out )
         ret = get_lock_state ( in, out );
     } else if ( cmd == PLUGIN_SYNC_CMD_GET_SHELL_ENV ) {
         ret = get_shell_env ( in, out );
-    } else if ( cmd == PLUGIN_SYNC_CMD_VERITY_PUSH ) {
+    } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_PUSH ) {
         ret = verify_push ( in, out );
+    } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_PULL ) {
+        ret = verify_pull ( in, out );
     } else if ( cmd == PLUGIN_SYNC_CMD_HANDLE_BY_PLUGIN ) {
         ret = verify_handle_by_plugin ( in, out );
     } else {
index fc9056e15933fdb227076955746de51a469fdb3d..6ebbd0b43f946b95eb76d320162a1cc857ffe87f 100644 (file)
@@ -469,7 +469,7 @@ static int do_send(int s, int noti_fd, char *path, char *buffer)
         return -1;
     }
 
-    if (!request_validity_to_plugin(PLUGIN_SYNC_CMD_VERITY_PUSH, path)) {
+    if (!request_validity_to_plugin(PLUGIN_SYNC_CMD_VERIFY_PUSH, path)) {
         fail_message(s, "You cannot push files to this path.");
         return -1;
     }
@@ -534,6 +534,11 @@ static int do_recv(int s, const char *path, char *buffer)
         return -1;
     }
 
+    if (!request_validity_to_plugin(PLUGIN_SYNC_CMD_VERIFY_PULL, path)) {
+        fail_message(s, "You cannot pull files from this path.");
+        return -1;
+    }
+
     fd = sdb_open(path, O_RDONLY);
     if(fd < 0) {
         if(fail_errno(s, errno)) return -1;
index 64c25db650e1691c344b1aec7bea2a6395245f40..2b5ba45c600b0bc1499a562277aec78693186bd7 100644 (file)
 #define PLUGIN_SYNC_CMD_AUTH_GET_KEY_FILEPATHS      1007
 #define PLUGIN_SYNC_CMD_GET_LOCK_STATE              1008
 #define PLUGIN_SYNC_CMD_GET_SHELL_ENV               1009
-#define PLUGIN_SYNC_CMD_VERITY_PUSH                 1010
+#define PLUGIN_SYNC_CMD_VERIFY_PUSH                 1010
 #define PLUGIN_SYNC_CMD_VERIFY_PEERIPV6             1011
 #define PLUGIN_SYNC_CMD_HANDLE_BY_PLUGIN            1012
+#define PLUGIN_SYNC_CMD_VERIFY_PULL                 1013
 
 #define PLUGIN_SYNC_CMD_SEC_INIT                    1100
 #define PLUGIN_SYNC_CMD_SEC_DEINIT                  1101