packages/apps/Superuser
Révision | ea0d23358d995d5d345b7ce1b62a61a4ea501f73 (tree) |
---|---|
l'heure | 2010-05-19 07:12:27 |
Auteur | ChainsDD <chainsdd@gmai...> |
Commiter | ChainsDD |
Add limited support for '-s' option.
@@ -37,6 +37,7 @@ static const char socket_path_template[PATH_MAX] = REQUESTOR_CACHE_PATH "/.socke | ||
37 | 37 | static char socket_path_buf[PATH_MAX]; |
38 | 38 | static char *socket_path = NULL; |
39 | 39 | static int socket_serv_fd = -1; |
40 | +static char shell[PATH_MAX]; | |
40 | 41 | static unsigned req_uid = 0; |
41 | 42 | |
42 | 43 | static sqlite3 *db = NULL; |
@@ -245,15 +246,20 @@ static void allow(void) | ||
245 | 246 | { |
246 | 247 | struct su_initiator *from = &su_from; |
247 | 248 | struct su_request *to = &su_to; |
249 | + char *exe = NULL; | |
248 | 250 | |
251 | + if (!strcmp(shell, "")) { | |
252 | + strcpy(shell , "/system/bin/sh"); | |
253 | + } | |
254 | + exe = strrchr (shell, '/') + 1; | |
249 | 255 | setgroups(0, NULL); |
250 | 256 | setresgid(to->uid, to->uid, to->uid); |
251 | 257 | setresuid(to->uid, to->uid, to->uid); |
252 | - LOGD("%u %s executing %u %s", from->uid, from->bin, to->uid, to->command); | |
258 | + LOGD("%u %s executing %u %s using shell %s : %s", from->uid, from->bin, to->uid, to->command, shell, exe); | |
253 | 259 | if (strcmp(to->command, DEFAULT_COMMAND)) { |
254 | - execl("/system/bin/sh", "sh", "-c", to->command, (char*)NULL); | |
260 | + execl(shell, exe, "-c", to->command, (char*)NULL); | |
255 | 261 | } else { |
256 | - execl("/system/bin/sh", "sh", "-", (char*)NULL); | |
262 | + execl(shell, exe, "-", (char*)NULL); | |
257 | 263 | } |
258 | 264 | PLOGE("exec"); |
259 | 265 | exit(-1); |
@@ -264,7 +270,6 @@ int main(int argc, char *argv[]) | ||
264 | 270 | struct stat st; |
265 | 271 | char buf[64], *result; |
266 | 272 | int i; |
267 | - int dballow; | |
268 | 273 | |
269 | 274 | for (i = 1; i < argc; i++) { |
270 | 275 | if (!strcmp(argv[i], "-c")) { |
@@ -273,6 +278,12 @@ int main(int argc, char *argv[]) | ||
273 | 278 | } else { |
274 | 279 | deny(); |
275 | 280 | } |
281 | + } else if (!strcmp(argv[i], "-s")) { | |
282 | + if (++i < argc) { | |
283 | + strcpy(shell, argv[i]); | |
284 | + } else { | |
285 | + deny(); | |
286 | + } | |
276 | 287 | } else if (!strcmp(argv[i], "-")) { |
277 | 288 | ++i; |
278 | 289 | break; |