• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Superuser


Commit MetaInfo

Révisionea0d23358d995d5d345b7ce1b62a61a4ea501f73 (tree)
l'heure2010-05-19 07:12:27
AuteurChainsDD <chainsdd@gmai...>
CommiterChainsDD

Message de Log

Add limited support for '-s' option.

Change Summary

Modification

--- a/su.c
+++ b/su.c
@@ -37,6 +37,7 @@ static const char socket_path_template[PATH_MAX] = REQUESTOR_CACHE_PATH "/.socke
3737 static char socket_path_buf[PATH_MAX];
3838 static char *socket_path = NULL;
3939 static int socket_serv_fd = -1;
40+static char shell[PATH_MAX];
4041 static unsigned req_uid = 0;
4142
4243 static sqlite3 *db = NULL;
@@ -245,15 +246,20 @@ static void allow(void)
245246 {
246247 struct su_initiator *from = &su_from;
247248 struct su_request *to = &su_to;
249+ char *exe = NULL;
248250
251+ if (!strcmp(shell, "")) {
252+ strcpy(shell , "/system/bin/sh");
253+ }
254+ exe = strrchr (shell, '/') + 1;
249255 setgroups(0, NULL);
250256 setresgid(to->uid, to->uid, to->uid);
251257 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);
253259 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);
255261 } else {
256- execl("/system/bin/sh", "sh", "-", (char*)NULL);
262+ execl(shell, exe, "-", (char*)NULL);
257263 }
258264 PLOGE("exec");
259265 exit(-1);
@@ -264,7 +270,6 @@ int main(int argc, char *argv[])
264270 struct stat st;
265271 char buf[64], *result;
266272 int i;
267- int dballow;
268273
269274 for (i = 1; i < argc; i++) {
270275 if (!strcmp(argv[i], "-c")) {
@@ -273,6 +278,12 @@ int main(int argc, char *argv[])
273278 } else {
274279 deny();
275280 }
281+ } else if (!strcmp(argv[i], "-s")) {
282+ if (++i < argc) {
283+ strcpy(shell, argv[i]);
284+ } else {
285+ deny();
286+ }
276287 } else if (!strcmp(argv[i], "-")) {
277288 ++i;
278289 break;