2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #define TRACE_TAG TRACE_SDB
27 #include "parameter.h"
28 #include "sdbd_plugin.h"
31 #define LOG_DIRECTORY "/tmp"
33 int get_plugin_capability ( parameters* in, parameters* out )
37 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
38 || in->array_of_parameter[0].type != type_int32 ) {
39 D ( "Invalid argument\n" );
40 return PLUGIN_CMD_FAIL;
44 D ( "Invalid argument\n" );
45 return PLUGIN_CMD_FAIL;
48 out->number_of_parameter = 1;
49 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
51 capability = in->array_of_parameter[0].v_int32;
53 if ( capability == CAPABILITY_SECURE ) {
54 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED );
55 } else if ( capability == CAPABILITY_INTER_SHELL ) {
56 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
57 } else if ( capability == CAPABILITY_FILESYNC ) {
58 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_PUSHPULL );
59 } else if ( capability == CAPABILITY_USB_PROTOCOL ) {
60 if ( is_emulator() ) {
61 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED );
63 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
65 } else if ( capability == CAPABILITY_SOCK_PROTOCOL ) {
66 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
67 } else if ( capability == CAPABILITY_ROOT_ONOFF ) {
68 if ( access ( "/bin/su", F_OK ) == 0 ) {
69 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
71 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED );
73 } else if ( capability == CAPABILITY_CAN_LAUNCH ) {
74 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
75 } else if ( capability == CAPABILITY_PLUGIN_VER ) {
76 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
77 } else if ( capability == CAPABILITY_PRODUCT_VER ) {
78 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
79 } else if ( capability == CAPABILITY_LOG_ENABLE ) {
80 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED );
81 } else if ( capability == CAPABILITY_LOG_PATH ) {
82 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", LOG_DIRECTORY );
83 } else if ( capability == CAPABILITY_APPCMD ) {
84 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
86 out->number_of_parameter = 0;
87 free ( out->array_of_parameter );
88 out->array_of_parameter = NULL;
89 return PLUGIN_CMD_NOT_SUPPORT;
92 return PLUGIN_CMD_SUCCESS;
95 int verify_shell_cmd ( parameters* in, parameters* out )
97 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
98 || in->array_of_parameter[0].type != type_string ) {
99 D ( "Invalid argument\n" );
100 return PLUGIN_CMD_FAIL;
104 D ( "Invalid argument\n" );
105 return PLUGIN_CMD_FAIL;
108 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
110 out->number_of_parameter = 1;
111 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
112 out->array_of_parameter[0].type = type_int32;
113 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
115 return PLUGIN_CMD_SUCCESS;
118 int convert_shell_cmd ( parameters* in, parameters* out )
120 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
121 || in->array_of_parameter[0].type != type_string ) {
122 D ( "Invalid argument\n" );
123 return PLUGIN_CMD_FAIL;
127 D ( "Invalid argument\n" );
128 return PLUGIN_CMD_FAIL;
131 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
133 out->number_of_parameter = 1;
134 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
136 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", in->array_of_parameter[0].v_string.data );
137 return PLUGIN_CMD_SUCCESS;
140 int verify_peer_ip ( parameters* in, parameters* out )
142 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
143 || in->array_of_parameter[0].type != type_string ) {
144 D ( "Invalid argument\n" );
145 return PLUGIN_CMD_FAIL;
149 D ( "Invalid argument\n" );
150 return PLUGIN_CMD_FAIL;
153 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
155 out->number_of_parameter = 1;
156 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
157 out->array_of_parameter[0].type = type_int32;
158 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
160 return PLUGIN_CMD_SUCCESS;
163 int verify_sdbd_launch ( parameters* in, parameters* out )
166 D ( "Invalid argument\n" );
167 return PLUGIN_CMD_FAIL;
170 out->number_of_parameter = 1;
171 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
172 out->array_of_parameter[0].type = type_int32;
173 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
175 return PLUGIN_CMD_SUCCESS;
178 int verify_root_cmd ( parameters* in, parameters* out )
180 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
181 || in->array_of_parameter[0].type != type_string ) {
182 D ( "Invalid argument\n" );
183 return PLUGIN_CMD_FAIL;
187 D ( "Invalid argument\n" );
188 return PLUGIN_CMD_FAIL;
191 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
193 out->number_of_parameter = 1;
194 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
195 out->array_of_parameter[0].type = type_int32;
197 if ( verify_root_commands ( in->array_of_parameter[0].v_string.data ) ) {
198 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
200 out->array_of_parameter[0].v_int32 = PLUGIN_RET_INVALID;
203 return PLUGIN_CMD_SUCCESS;