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 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
61 } else if ( capability == CAPABILITY_SOCK_PROTOCOL ) {
62 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
63 } else if ( capability == CAPABILITY_ROOT_ONOFF ) {
64 if ( access ( "/bin/su", F_OK ) == 0 ) {
65 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
67 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_DISABLED );
69 } else if ( capability == CAPABILITY_CAN_LAUNCH ) {
70 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
71 } else if ( capability == CAPABILITY_PLUGIN_VER ) {
72 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
73 } else if ( capability == CAPABILITY_PRODUCT_VER ) {
74 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_UNKNOWN );
75 } else if ( capability == CAPABILITY_LOG_ENABLE ) {
76 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
77 } else if ( capability == CAPABILITY_LOG_PATH ) {
78 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", LOG_DIRECTORY );
79 } else if ( capability == CAPABILITY_APPCMD ) {
80 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", PLUGIN_RET_ENABLED );
82 out->number_of_parameter = 0;
83 free ( out->array_of_parameter );
84 out->array_of_parameter = NULL;
85 return PLUGIN_CMD_NOT_SUPPORT;
88 return PLUGIN_CMD_SUCCESS;
91 int verify_shell_cmd ( parameters* in, parameters* out )
93 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
94 || in->array_of_parameter[0].type != type_string ) {
95 D ( "Invalid argument\n" );
96 return PLUGIN_CMD_FAIL;
100 D ( "Invalid argument\n" );
101 return PLUGIN_CMD_FAIL;
104 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
106 out->number_of_parameter = 1;
107 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
108 out->array_of_parameter[0].type = type_int32;
109 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
111 return PLUGIN_CMD_SUCCESS;
114 int convert_shell_cmd ( parameters* in, parameters* out )
116 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
117 || in->array_of_parameter[0].type != type_string ) {
118 D ( "Invalid argument\n" );
119 return PLUGIN_CMD_FAIL;
123 D ( "Invalid argument\n" );
124 return PLUGIN_CMD_FAIL;
127 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
129 out->number_of_parameter = 1;
130 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
132 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", in->array_of_parameter[0].v_string.data );
133 return PLUGIN_CMD_SUCCESS;
136 int verify_peer_ip ( parameters* in, parameters* out )
138 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
139 || in->array_of_parameter[0].type != type_string ) {
140 D ( "Invalid argument\n" );
141 return PLUGIN_CMD_FAIL;
145 D ( "Invalid argument\n" );
146 return PLUGIN_CMD_FAIL;
149 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
151 out->number_of_parameter = 1;
152 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
153 out->array_of_parameter[0].type = type_int32;
154 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
156 return PLUGIN_CMD_SUCCESS;
159 int verify_sdbd_launch ( parameters* in, parameters* out )
162 D ( "Invalid argument\n" );
163 return PLUGIN_CMD_FAIL;
166 out->number_of_parameter = 1;
167 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
168 out->array_of_parameter[0].type = type_int32;
169 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
171 return PLUGIN_CMD_SUCCESS;
174 int verify_root_cmd ( parameters* in, parameters* out )
176 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
177 || in->array_of_parameter[0].type != type_string ) {
178 D ( "Invalid argument\n" );
179 return PLUGIN_CMD_FAIL;
183 D ( "Invalid argument\n" );
184 return PLUGIN_CMD_FAIL;
187 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
189 out->number_of_parameter = 1;
190 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
191 out->array_of_parameter[0].type = type_int32;
193 if ( verify_root_commands ( in->array_of_parameter[0].v_string.data ) ) {
194 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
196 out->array_of_parameter[0].v_int32 = PLUGIN_RET_INVALID;
199 return PLUGIN_CMD_SUCCESS;
202 int get_shell_env ( parameters* in, parameters* out )
205 D ( "Invalid argument\n" );
206 return PLUGIN_CMD_FAIL;
209 out->number_of_parameter = 1;
210 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
212 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", "" );
213 return PLUGIN_CMD_SUCCESS;