Merge "Correct LOCAL_LDLIBS of adb"
diff --git a/adb/adb.c b/adb/adb.c
index b3283de..4c3364f 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -46,6 +46,7 @@
#endif
int HOST = 0;
+int gListenAll = 0;
static int auth_enabled = 0;
@@ -701,7 +702,13 @@
if(!strncmp("tcp:", name, 4)){
int ret;
port = atoi(name + 4);
- ret = socket_loopback_server(port, SOCK_STREAM);
+
+ if (gListenAll > 0) {
+ ret = socket_inaddr_any_server(port, SOCK_STREAM);
+ } else {
+ ret = socket_loopback_server(port, SOCK_STREAM);
+ }
+
return ret;
}
#ifndef HAVE_WIN32_IPC /* no Unix-domain sockets on Win32 */
@@ -1079,8 +1086,10 @@
dup2(fd[1], STDERR_FILENO);
adb_close(fd[1]);
+ char str_port[30];
+ snprintf(str_port, sizeof(str_port), "%d", server_port);
// child process
- int result = execl(path, "adb", "fork-server", "server", NULL);
+ int result = execl(path, "adb", "-P", str_port, "fork-server", "server", NULL);
// this should not return
fprintf(stderr, "OOPS! execl returned %d, errno: %d\n", result, errno);
} else {
diff --git a/adb/adb_client.c b/adb/adb_client.c
index 9a812f0..8340738 100644
--- a/adb/adb_client.c
+++ b/adb/adb_client.c
@@ -17,6 +17,7 @@
static const char* __adb_serial = NULL;
static int __adb_server_port = DEFAULT_ADB_PORT;
+static const char* __adb_server_name = NULL;
void adb_set_transport(transport_type type, const char* serial)
{
@@ -29,6 +30,11 @@
__adb_server_port = server_port;
}
+void adb_set_tcp_name(const char* hostname)
+{
+ __adb_server_name = hostname;
+}
+
int adb_get_emulator_console_port(void)
{
const char* serial = __adb_serial;
@@ -181,7 +187,11 @@
}
snprintf(tmp, sizeof tmp, "%04x", len);
- fd = socket_loopback_client(__adb_server_port, SOCK_STREAM);
+ 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);
+
if(fd < 0) {
strcpy(__adb_error, "cannot connect to daemon");
return -2;
@@ -212,7 +222,10 @@
int fd = _adb_connect("host:version");
D("adb_connect: service %s\n", service);
- if(fd == -2) {
+ if(fd == -2 && __adb_server_name) {
+ fprintf(stderr,"** Cannot start server on remote host\n");
+ return fd;
+ } else if(fd == -2) {
fprintf(stdout,"* daemon not running. starting it now on port %d *\n",
__adb_server_port);
start_server:
@@ -266,7 +279,7 @@
fd = _adb_connect(service);
if(fd == -2) {
- fprintf(stderr,"** daemon still not running");
+ fprintf(stderr,"** daemon still not running\n");
}
D("adb_connect: return fd %d\n", fd);
diff --git a/adb/adb_client.h b/adb/adb_client.h
index 40ab189..0ec47ca 100644
--- a/adb/adb_client.h
+++ b/adb/adb_client.h
@@ -29,6 +29,10 @@
*/
void adb_set_tcp_specifics(int server_port);
+/* Set TCP Hostname of the transport to use
+*/
+void adb_set_tcp_name(const char* hostname);
+
/* Return the console port of the currently connected emulator (if any)
* of -1 if there is no emulator, and -2 if there is more than one.
* assumes adb_set_transport() was alled previously...
diff --git a/adb/commandline.c b/adb/commandline.c
index a4c2f40..cbe4616 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -46,6 +46,7 @@
int uninstall_app(transport_type transport, char* serial, int argc, char** argv);
static const char *gProductOutPath = NULL;
+extern int gListenAll;
static char *product_file(const char *extra)
{
@@ -80,6 +81,7 @@
fprintf(stderr,
"\n"
+ " -a - directs adb to listen on all interfaces for a connection\n"
" -d - directs command to the only connected USB device\n"
" returns an error if more than one USB device is present.\n"
" -e - directs command to the only running emulator.\n"
@@ -93,6 +95,8 @@
" If -p is not specified, the ANDROID_PRODUCT_OUT\n"
" environment variable is used, which must\n"
" be an absolute path.\n"
+ " -H - Name of adb server host (default: localhost)\n"
+ " -P - Port of adb server (default: 5037)\n"
" devices [-l] - list all connected devices\n"
" ('-l' will also list device qualifiers)\n"
" connect <host>[:<port>] - connect to a device via TCP/IP\n"
@@ -946,9 +950,9 @@
int server_port = DEFAULT_ADB_PORT;
if (server_port_str && strlen(server_port_str) > 0) {
server_port = (int) strtol(server_port_str, NULL, 0);
- if (server_port <= 0) {
+ if (server_port <= 0 || server_port > 65535) {
fprintf(stderr,
- "adb: Env var ANDROID_ADB_SERVER_PORT must be a positive number. Got \"%s\"\n",
+ "adb: Env var ANDROID_ADB_SERVER_PORT must be a positive number less than 65535. Got \"%s\"\n",
server_port_str);
return usage();
}
@@ -994,6 +998,42 @@
ttype = kTransportUsb;
} else if (!strcmp(argv[0],"-e")) {
ttype = kTransportLocal;
+ } else if (!strcmp(argv[0],"-a")) {
+ gListenAll = 1;
+ } else if(!strncmp(argv[0], "-H", 2)) {
+ const char *hostname = NULL;
+ if (argv[0][2] == '\0') {
+ if (argc < 2) return usage();
+ hostname = argv[1];
+ argc--;
+ argv++;
+ } else {
+ hostname = argv[0] + 2;
+ }
+ adb_set_tcp_name(hostname);
+
+ } else if(!strncmp(argv[0], "-P", 2)) {
+ if (argv[0][2] == '\0') {
+ if (argc < 2) return usage();
+ server_port_str = argv[1];
+ argc--;
+ argv++;
+ } else {
+ server_port_str = argv[0] + 2;
+ }
+ if (strlen(server_port_str) > 0) {
+ server_port = (int) strtol(server_port_str, NULL, 0);
+ if (server_port <= 0 || server_port > 65535) {
+ fprintf(stderr,
+ "adb: port number must be a positive number less than 65536. Got \"%s\"\n",
+ server_port_str);
+ return usage();
+ }
+ } else {
+ fprintf(stderr,
+ "adb: port number must be a positive number less than 65536. Got empty string.\n");
+ return usage();
+ }
} else {
/* out of recognized modifiers and flags */
break;
diff --git a/debuggerd/tombstone.c b/debuggerd/tombstone.c
index 98016c3..e8b3e24 100644
--- a/debuggerd/tombstone.c
+++ b/debuggerd/tombstone.c
@@ -350,6 +350,18 @@
}
}
+static void dump_map(log_t* log, map_info_t* m, const char* what) {
+ if (m != NULL) {
+ _LOG(log, false, " %08x-%08x %c%c%c %s\n", m->start, m->end,
+ m->is_readable ? 'r' : '-',
+ m->is_writable ? 'w' : '-',
+ m->is_executable ? 'x' : '-',
+ m->name);
+ } else {
+ _LOG(log, false, " (no %s)\n", what);
+ }
+}
+
static void dump_nearby_maps(const ptrace_context_t* context, log_t* log, pid_t tid) {
siginfo_t si;
memset(&si, 0, sizeof(si));
@@ -396,21 +408,9 @@
* Show "next" then "match" then "prev" so that the addresses appear in
* ascending order (like /proc/pid/maps).
*/
- if (next != NULL) {
- _LOG(log, false, " %08x-%08x %s\n", next->start, next->end, next->name);
- } else {
- _LOG(log, false, " (no map below)\n");
- }
- if (map != NULL) {
- _LOG(log, false, " %08x-%08x %s\n", map->start, map->end, map->name);
- } else {
- _LOG(log, false, " (no map for address)\n");
- }
- if (prev != NULL) {
- _LOG(log, false, " %08x-%08x %s\n", prev->start, prev->end, prev->name);
- } else {
- _LOG(log, false, " (no map above)\n");
- }
+ dump_map(log, next, "map below");
+ dump_map(log, map, "map for address");
+ dump_map(log, prev, "map above");
}
static void dump_thread(const ptrace_context_t* context, log_t* log, pid_t tid, bool at_fault,
diff --git a/include/corkscrew/map_info.h b/include/corkscrew/map_info.h
index ea1d35f..c9b241d 100644
--- a/include/corkscrew/map_info.h
+++ b/include/corkscrew/map_info.h
@@ -32,6 +32,7 @@
uintptr_t start;
uintptr_t end;
bool is_readable;
+ bool is_writable;
bool is_executable;
void* data; // arbitrary data associated with the map by the user, initially NULL
char name[];
@@ -46,9 +47,10 @@
/* Finds the memory map that contains the specified address. */
const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
-/* Returns true if the addr is in an readable map. */
+/* Returns true if the addr is in a readable map. */
bool is_readable_map(const map_info_t* milist, uintptr_t addr);
-
+/* Returns true if the addr is in a writable map. */
+bool is_writable_map(const map_info_t* milist, uintptr_t addr);
/* Returns true if the addr is in an executable map. */
bool is_executable_map(const map_info_t* milist, uintptr_t addr);
diff --git a/init/devices.c b/init/devices.c
index dd875d6..b07a1a6 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -881,8 +881,8 @@
sehandle = selinux_android_file_context_handle();
}
- /* is 64K enough? udev uses 16MB! */
- device_fd = uevent_open_socket(64*1024, true);
+ /* is 256K enough? udev uses 16MB! */
+ device_fd = uevent_open_socket(256*1024, true);
if(device_fd < 0)
return;
diff --git a/libcorkscrew/map_info.c b/libcorkscrew/map_info.c
index 3c52854..6a27664 100644
--- a/libcorkscrew/map_info.c
+++ b/libcorkscrew/map_info.c
@@ -57,13 +57,15 @@
mi->start = start;
mi->end = end;
mi->is_readable = strlen(permissions) == 4 && permissions[0] == 'r';
+ mi->is_writable = strlen(permissions) == 4 && permissions[1] == 'w';
mi->is_executable = strlen(permissions) == 4 && permissions[2] == 'x';
mi->data = NULL;
memcpy(mi->name, name, name_len);
mi->name[name_len] = '\0';
ALOGV("Parsed map: start=0x%08x, end=0x%08x, "
- "is_readable=%d, is_executable=%d, name=%s",
- mi->start, mi->end, mi->is_readable, mi->is_executable, mi->name);
+ "is_readable=%d, is_writable=%d, is_executable=%d, name=%s",
+ mi->start, mi->end,
+ mi->is_readable, mi->is_writable, mi->is_executable, mi->name);
}
return mi;
}
@@ -110,6 +112,11 @@
return mi && mi->is_readable;
}
+bool is_writable_map(const map_info_t* milist, uintptr_t addr) {
+ const map_info_t* mi = find_map_info(milist, addr);
+ return mi && mi->is_writable;
+}
+
bool is_executable_map(const map_info_t* milist, uintptr_t addr) {
const map_info_t* mi = find_map_info(milist, addr);
return mi && mi->is_executable;
diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c
index d0ca90a..b4caaf9 100644
--- a/libnetutils/dhcp_utils.c
+++ b/libnetutils/dhcp_utils.c
@@ -211,7 +211,7 @@
p2p_interface, DHCP_CONFIG_PATH, prop_value, interface);
else
snprintf(daemon_cmd, sizeof(daemon_cmd), "%s_%s:-f %s %s", DAEMON_NAME,
- DHCP_CONFIG_PATH, p2p_interface, interface);
+ p2p_interface, DHCP_CONFIG_PATH, interface);
memset(prop_value, '\0', PROPERTY_VALUE_MAX);
property_set(ctrl_prop, daemon_cmd);
if (wait_for_property(daemon_prop_name, desired_status, 10) < 0) {
diff --git a/rootdir/init.rc b/rootdir/init.rc
index a76602c..5205200 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -120,6 +120,12 @@
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
+# qtaguid will limit access to specific data based on group memberships.
+# net_bw_acct grants impersonation of socket owners.
+# net_bw_stats grants access to other apps' detailed tagged-socket stats.
+ chown root net_bw_acct /proc/net/xt_qtaguid/ctrl
+ chown root net_bw_stats /proc/net/xt_qtaguid/stats
+
# Allow everybody to read the xt_qtaguid resource tracking misc dev.
# This is needed by any process that uses socket tagging.
chmod 0644 /dev/xt_qtaguid