diff options
Diffstat (limited to 'adb/services.c')
-rw-r--r-- | adb/services.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/adb/services.c b/adb/services.c index e4ce0bc..bd210a8 100644 --- a/adb/services.c +++ b/adb/services.c @@ -82,6 +82,22 @@ void restart_root_service(int fd, void *cookie) } } +void restart_unroot_service(int fd, void *cookie) +{ + char buf[100]; + + if (getuid() != 0) { + snprintf(buf, sizeof(buf), "adbd not running as root\n"); + writex(fd, buf, strlen(buf)); + adb_close(fd); + } else { + property_set("service.adb.root", "0"); + snprintf(buf, sizeof(buf), "restarting adbd as non root\n"); + writex(fd, buf, strlen(buf)); + adb_close(fd); + } +} + void restart_tcp_service(int fd, void *cookie) { char buf[100]; @@ -437,6 +453,8 @@ int service_to_fd(const char *name) ret = create_service_thread(reboot_service, arg); } else if(!strncmp(name, "root:", 5)) { ret = create_service_thread(restart_root_service, NULL); + } else if(!strncmp(name, "unroot:", 7)) { + ret = create_service_thread(restart_unroot_service, NULL); } else if(!strncmp(name, "backup:", 7)) { char* arg = strdup(name + 7); if (arg == NULL) return -1; |