Hi Ilya,

thank you for your feedback!

> While the patch seems to fix things, it's rather a dirty fix. First of
> all google uses the same sources for android adbd and for the host
> adb. Using ANDROID_SOCKET_NAMESPACE_ABSTRACT on the host could lead to
> problems if google would change abstract socket implementation in
> android or undefine all this stuff for the host builds. 

How this relevant for the host-only, Debian-specifc build?

> Anyway, the patch cuts off -H and -a options.

I don't see how -H is broken. The code path that now uses
socket_local_client() (previously socket_loopback_client()) was only
taken if the __adb_server_name was not set. It is set by -H:

$ strace -f adb -H 192.168.1.1 shell
[...]
9808  socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
9808  connect(3, {sa_family=AF_INET, sin_port=htons(5037), 
sin_addr=inet_addr("192.168.1.1")}, 16) = -1 ECONNREFUSED (Connection refused)
9808  close(3)                          = 0
[...]

Yes, "-a" is probably broken. I still consider that an improvement over
#694176 which I intended fix in the first place -- and which blocks the
package from reaching testing.

Having poked at the adb sources some more, I come to the conclusion that
upstream's intention is to provide two modes for setting up an adb
daemon:

(1) A "local" TCP socket (default wrong behavior, see #694176)
(2) A TCP socket on all interfaces (even less secure, but whatever...)

I don't see a way to specify one specific address for the listening
socket, the attached revised patch for should restore the "-a"
functionality.

Cheers,
-Hilko
Index: android-tools-4.2.2+git20130529/core/adb/adb.c
===================================================================
--- android-tools-4.2.2+git20130529.orig/core/adb/adb.c	2013-05-29 22:16:54.000000000 +0200
+++ android-tools-4.2.2+git20130529/core/adb/adb.c	2013-07-09 23:56:06.533608989 +0200
@@ -1154,7 +1154,11 @@
  */
 void build_local_name(char* target_str, size_t target_size, int server_port)
 {
-  snprintf(target_str, target_size, "tcp:%d", server_port);
+  if (gListenAll > 0) {
+    snprintf(target_str, target_size, "tcp:%d", server_port);
+  } else {
+    snprintf(target_str, target_size, "local:%d", server_port);
+  }
 }
 
 #if !ADB_HOST
Index: android-tools-4.2.2+git20130529/core/adb/adb_client.c
===================================================================
--- android-tools-4.2.2+git20130529.orig/core/adb/adb_client.c	2013-05-29 22:16:54.000000000 +0200
+++ android-tools-4.2.2+git20130529/core/adb/adb_client.c	2013-07-09 09:13:06.864543801 +0200
@@ -185,12 +185,12 @@
         strcpy(__adb_error, "service name too long");
         return -1;
     }
-    snprintf(tmp, sizeof tmp, "%04x", len);
+    snprintf(tmp, sizeof tmp, "%d", __adb_server_port);
 
     if (__adb_server_name)
         fd = socket_network_client(__adb_server_name, __adb_server_port, SOCK_STREAM);
     else
-        fd = socket_loopback_client(__adb_server_port, SOCK_STREAM);
+        fd = socket_local_client(tmp, ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
 
     if(fd < 0) {
         strcpy(__adb_error, "cannot connect to daemon");
@@ -201,6 +201,7 @@
         return -1;
     }
 
+    snprintf(tmp, sizeof tmp, "%04x", len);
     if(writex(fd, tmp, 4) || writex(fd, service, len)) {
         strcpy(__adb_error, "write failure during connection");
         adb_close(fd);

Reply via email to