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 f589196..d8ac7f9 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 4d4fdb5..5a3d317 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 f6f1f71..1491934 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 fc9056e..6ebbd0b 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 64c25db..2b5ba45 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