adb: fix exit of "adb root" when it is a no-op.
"adb root" creates a socket, then starts the service.
Socket creation should not set the exit_on_close when the service will be
a no-op.
Bug: 6259353
Change-Id: Ie526d2fad64f39a48051ed0ff6fb3405c2802ced
diff --git a/adb/sockets.c b/adb/sockets.c
index ce3c65e..72151b4 100644
--- a/adb/sockets.c
+++ b/adb/sockets.c
@@ -426,8 +426,9 @@
s = create_local_socket(fd);
D("LS(%d): bound to '%s' via %d\n", s->id, name, fd);
- if (!strcmp(name, "root:") || !strcmp(name, "usb:") ||
- !strcmp(name, "tcpip:")) {
+ if ((!strcmp(name, "root:") && getuid() != 0)
+ || !strcmp(name, "usb:")
+ || !strcmp(name, "tcpip:")) {
D("LS(%d): enabling exit_on_close\n", s->id);
s->exit_on_close = 1;
}