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 );
84 out->number_of_parameter = 0;
85 free ( out->array_of_parameter );
86 out->array_of_parameter = NULL;
87 return PLUGIN_CMD_NOT_SUPPORT;
90 return PLUGIN_CMD_SUCCESS;
93 int verify_shell_cmd ( parameters* in, parameters* out )
95 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
96 || in->array_of_parameter[0].type != type_string ) {
97 D ( "Invalid argument\n" );
98 return PLUGIN_CMD_FAIL;
102 D ( "Invalid argument\n" );
103 return PLUGIN_CMD_FAIL;
106 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
108 out->number_of_parameter = 1;
109 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
110 out->array_of_parameter[0].type = type_int32;
111 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
113 return PLUGIN_CMD_SUCCESS;
116 int convert_shell_cmd ( parameters* in, parameters* out )
118 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
119 || in->array_of_parameter[0].type != type_string ) {
120 D ( "Invalid argument\n" );
121 return PLUGIN_CMD_FAIL;
125 D ( "Invalid argument\n" );
126 return PLUGIN_CMD_FAIL;
129 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
131 out->number_of_parameter = 1;
132 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
134 make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", in->array_of_parameter[0].v_string.data );
135 return PLUGIN_CMD_SUCCESS;
138 int verify_peer_ip ( parameters* in, parameters* out )
140 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
141 || in->array_of_parameter[0].type != type_string ) {
142 D ( "Invalid argument\n" );
143 return PLUGIN_CMD_FAIL;
147 D ( "Invalid argument\n" );
148 return PLUGIN_CMD_FAIL;
151 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
153 out->number_of_parameter = 1;
154 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
155 out->array_of_parameter[0].type = type_int32;
156 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
158 return PLUGIN_CMD_SUCCESS;
161 int verify_sdbd_launch ( parameters* in, parameters* out )
164 D ( "Invalid argument\n" );
165 return PLUGIN_CMD_FAIL;
168 out->number_of_parameter = 1;
169 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
170 out->array_of_parameter[0].type = type_int32;
171 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
173 return PLUGIN_CMD_SUCCESS;
176 int verify_root_cmd ( parameters* in, parameters* out )
178 if ( in == NULL || in->number_of_parameter != 1 || in->array_of_parameter == NULL
179 || in->array_of_parameter[0].type != type_string ) {
180 D ( "Invalid argument\n" );
181 return PLUGIN_CMD_FAIL;
185 D ( "Invalid argument\n" );
186 return PLUGIN_CMD_FAIL;
189 D ( "shell command : %s\n", in->array_of_parameter[0].v_string.data );
191 out->number_of_parameter = 1;
192 out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
193 out->array_of_parameter[0].type = type_int32;
195 if ( verify_root_commands ( in->array_of_parameter[0].v_string.data ) ) {
196 out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
198 out->array_of_parameter[0].v_int32 = PLUGIN_RET_INVALID;
201 return PLUGIN_CMD_SUCCESS;