From: Jaewon Lim Date: Thu, 10 Nov 2016 01:52:39 +0000 (-0800) Subject: Revert "Revert "Merge plugin improvement commit"" X-Git-Tag: submit/tizen_3.0/20161111.022600~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fc8f357b8d134f439cb1e2581da491111ac9e07;p=sdk%2Ftarget%2Fsdbd.git Revert "Revert "Merge plugin improvement commit"" This reverts commit 84bfce8dd67d9d74febaf5ef3c0fe0cd6ec16382. Change-Id: I7d5ca566b67230ca712ec276f74ad2115b66e2ca --- diff --git a/src/default_plugin.h b/src/default_plugin.h index 800e495..0c8b5b9 100644 --- a/src/default_plugin.h +++ b/src/default_plugin.h @@ -26,6 +26,7 @@ int verify_peer_ip ( parameters* in, parameters* out ); 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 auth_support ( parameters* in, parameters* out ); int auth_get_key_file_paths ( parameters* in, parameters* out ); diff --git a/src/default_plugin_basic.c b/src/default_plugin_basic.c index 2072824..81f313c 100644 --- a/src/default_plugin_basic.c +++ b/src/default_plugin_basic.c @@ -198,3 +198,18 @@ int verify_root_cmd ( parameters* in, parameters* out ) return PLUGIN_CMD_SUCCESS; } + +int get_shell_env ( parameters* in, parameters* out ) +{ + if ( out == NULL ) { + D ( "Invalid argument\n" ); + return PLUGIN_CMD_FAIL; + } + + out->number_of_parameter = 1; + out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) ); + + make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", "" ); + return PLUGIN_CMD_SUCCESS; +} + diff --git a/src/default_plugin_main.c b/src/default_plugin_main.c index a118fe7..ea71971 100644 --- a/src/default_plugin_main.c +++ b/src/default_plugin_main.c @@ -58,6 +58,8 @@ int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out ) ret = auth_get_key_file_paths ( in, out ); } else if ( cmd == PLUGIN_SYNC_CMD_GET_LOCK_STATE ) { ret = get_lock_state ( in, out ); + } else if ( cmd == PLUGIN_SYNC_CMD_GET_SHELL_ENV ) { + ret = get_shell_env ( in, out ); } else { ret = PLUGIN_CMD_NOT_SUPPORT; } diff --git a/src/plugin.c b/src/plugin.c index ff9f19c..e8c70b9 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -326,11 +326,16 @@ int request_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, u int ret; parameters in, out; - in.number_of_parameter = 1; - in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) ); - in.array_of_parameter[0].type = type_string; - in.array_of_parameter[0].v_string.length = strlen ( in_buf ); - in.array_of_parameter[0].v_string.data = strdup ( in_buf ); + if ( in_buf != NULL ) { + in.number_of_parameter = 1; + in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) ); + in.array_of_parameter[0].type = type_string; + in.array_of_parameter[0].v_string.length = strlen ( in_buf ); + in.array_of_parameter[0].v_string.data = strdup ( in_buf ); + } else { + in.number_of_parameter = 0; + in.array_of_parameter = NULL; + } ret = request_sync_cmd ( cmd, &in, &out ); if ( ret == PLUGIN_CMD_SUCCESS ) { @@ -398,3 +403,4 @@ int request_appcmd_to_plugin ( const char* in_buf ) return fd; } + diff --git a/src/sdb.c b/src/sdb.c index e282ced..9a0d5cf 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1755,10 +1755,9 @@ static void init_capabilities(void) { // Target name of the launch possible - if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_CANLAUNCH, - g_capabilities.can_launch, + if(!request_capability_to_plugin(CAPABILITY_CAN_LAUNCH, g_capabilities.can_launch, sizeof(g_capabilities.can_launch))) { - D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_CANLAUNCH); + D("failed to request. (%d:%d) \n", PLUGIN_SYNC_CMD_CAPABILITY, CAPABILITY_CAN_LAUNCH); snprintf(g_capabilities.can_launch, sizeof(g_capabilities.can_launch), "%s", UNKNOWN); } diff --git a/src/sdbd_plugin.h b/src/sdbd_plugin.h index 5159928..2bfb450 100644 --- a/src/sdbd_plugin.h +++ b/src/sdbd_plugin.h @@ -33,6 +33,7 @@ #define PLUGIN_SYNC_CMD_AUTH_SUPPORT 1006 #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 // asynchronous command #define PLUGIN_ASYNC_CMD_AUTH_CONFIRM_PUBLIC 2000 diff --git a/src/services.c b/src/services.c index 5d40ce9..1c48905 100644 --- a/src/services.c +++ b/src/services.c @@ -54,6 +54,8 @@ #include "sdbd_plugin.h" #include "plugin.h" +#define ENV_BUF_MAX 4096 + typedef struct stinfo stinfo; struct stinfo { @@ -647,13 +649,14 @@ static int create_subproc_thread(const char *name, int lines, int columns) /* get environment variables from plugin */ char *envp_plugin = NULL; - envp_plugin = malloc(SDBD_PLUGIN_OUTBUF_MAX); + envp_plugin = malloc(ENV_BUF_MAX); if (envp_plugin == NULL) { D("Cannot allocate the shell commnad buffer."); return -1; } - memset(envp_plugin, 0, SDBD_PLUGIN_OUTBUF_MAX); - if (!request_plugin_cmd(SDBD_CMD_SHELL_ENVVAR, "", envp_plugin, SDBD_PLUGIN_OUTBUF_MAX)) { + memset(envp_plugin, 0, ENV_BUF_MAX); + if (!request_conversion_to_plugin(PLUGIN_SYNC_CMD_GET_SHELL_ENV, NULL, + envp_plugin, ENV_BUF_MAX)) { D("Failed to convert the shell command. (%s)\n", name); free(envp_plugin); return -1; diff --git a/src/transport_local.c b/src/transport_local.c index 849fe05..a6adb0b 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -38,6 +38,7 @@ #if !SDB_HOST #include "commandline_sdbd.h" #endif +#include "utils.h" #include "sdbd_plugin.h" #include "plugin.h"