plugin: add verify_path to check valid path for push 73/162473/3 accepted/tizen/unified/20180129.073430 submit/tizen/20171227.092455 submit/tizen/20180124.035009
authorjounsun.beak <jounsun.beak@samsung.com>
Fri, 1 Dec 2017 12:35:29 +0000 (21:35 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 27 Dec 2017 09:24:30 +0000 (09:24 +0000)
Change-Id: I0ae896d25fc4fb9c8bbf89fee16f3f04b3f70160
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 0c8b5b9..9420d7c 100644 (file)
@@ -27,6 +27,7 @@ int verify_sdbd_launch ( parameters* in, parameters* out );
 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 auth_support ( parameters* in, parameters* out );
 int auth_get_key_file_paths ( parameters* in, parameters* out );
index 0354377..18fed8a 100644 (file)
@@ -250,3 +250,27 @@ int get_shell_env ( parameters* in, parameters* out )
     return PLUGIN_CMD_SUCCESS;
 }
 
+int verify_push ( 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 ) {
+        D ( "Invalid argument\n" );
+        return PLUGIN_CMD_FAIL;
+    }
+
+    if ( out == NULL ) {
+        D ( "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) {
+        D("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;
+}
\ No newline at end of file
index 37e5f54..9195449 100644 (file)
@@ -58,6 +58,8 @@ 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 ) {
+        ret = verify_push ( in, out );
     } else {
         ret = PLUGIN_CMD_NOT_SUPPORT;
     }
index f2da4c1..ec03f03 100644 (file)
@@ -38,6 +38,7 @@
 #include "sdktools.h"
 #include "sdbd_plugin.h"
 #include "utils.h"
+#include "plugin.h"
 
 #define SYNC_TIMEOUT 15
 
@@ -467,6 +468,11 @@ 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)) {
+        fail_message(s, "You cannot push files to this path.");
+        return -1;
+    }
+
     tmp = strrchr(path,',');
     if(tmp) {
         *tmp = 0;
index 0a9287a..d8cb702 100644 (file)
@@ -34,6 +34,7 @@
 #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_SEC_INIT                    1100
 #define PLUGIN_SYNC_CMD_SEC_DEINIT                  1101