diff --git a/adb/adb.c b/adb/adb.c index 10a1e0d..99fca49 100644 --- a/adb/adb.c +++ b/adb/adb.c @@ -35,12 +35,10 @@ #if !ADB_HOST #include -#include #include #include #include #include -#include #else #include "usb_vendors.h" #endif @@ -147,7 +145,7 @@ void adb_trace_init(void) } } -#if !ADB_HOST +#if !ADB_HOST && ADB_QEMU /* * Implements ADB tracing inside the emulator. */ @@ -288,6 +286,22 @@ static void send_close(unsigned local, unsigned remote, atransport *t) send_packet(p, t); } +int property_set(const char *key, const char *value) +{ + return 0; +} + +int property_get(const char *key, char *value, const char *fallback) +{ + if (fallback) { + strncpy(value, fallback, PROPERTY_VALUE_MAX-1); + return strlen(fallback); + } else { + value[0] = 0; + return 0; + } +} + static size_t fill_connect_data(char *buf, size_t bufsize) { #if ADB_HOST @@ -1344,50 +1358,11 @@ int adb_main(int is_daemon, int server_port) " unchanged.\n"); } - /* add extra groups: - ** AID_ADB to access the USB driver - ** AID_LOG to read system logs (adb logcat) - ** AID_INPUT to diagnose input issues (getevent) - ** AID_INET to diagnose network issues (netcfg, ping) - ** AID_GRAPHICS to access the frame buffer - ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump) - ** AID_SDCARD_R to allow reading from the SD card - ** AID_SDCARD_RW to allow writing to the SD card - ** AID_NET_BW_STATS to read out qtaguid statistics - */ - gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS, - AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW, - AID_NET_BW_STATS }; - if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) { - exit(1); - } - - /* don't listen on a port (default 5037) if running in secure mode */ - /* don't run as root if we are running in secure mode */ - if (should_drop_privileges()) { - drop_capabilities_bounding_set_if_needed(); - /* then switch user and group to "shell" */ - if (setgid(AID_SHELL) != 0) { - exit(1); - } - if (setuid(AID_SHELL) != 0) { - exit(1); - } - - D("Local port disabled\n"); - } else { - char local_name[30]; - if ((root_seclabel != NULL) && (is_selinux_enabled() > 0)) { - // b/12587913: fix setcon to allow const pointers - if (setcon((char *)root_seclabel) < 0) { - exit(1); - } - } - build_local_name(local_name, sizeof(local_name), server_port); - if(install_listener(local_name, "*smartsocket*", NULL, 0)) { - exit(1); - } + char local_name[30]; + build_local_name(local_name, sizeof(local_name), server_port); + if(install_listener(local_name, "*smartsocket*", NULL, 0)) { + exit(1); } int usb = 0; @@ -1408,10 +1383,9 @@ int adb_main(int is_daemon, int server_port) printf("using port=%d\n", port); // listen on TCP port specified by service.adb.tcp.port property local_init(port); - } else if (!usb) { - // listen on default port - local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); } + // listen on default port + local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT); D("adb_main(): pre init_jdwp()\n"); init_jdwp(); @@ -1695,7 +1669,6 @@ int main(int argc, char **argv) #else /* If adbd runs inside the emulator this will enable adb tracing via * adb-debug qemud service in the emulator. */ - adb_qemu_trace_init(); while(1) { int c; int option_index = 0; diff --git a/adb/adb_trace.h b/adb/adb_trace.h index 8a5d9f8..01c4c06 100644 --- a/adb/adb_trace.h +++ b/adb/adb_trace.h @@ -22,7 +22,7 @@ #endif /* define ADB_TRACE to 1 to enable tracing support, or 0 to disable it */ -#define ADB_TRACE 1 +#define ADB_TRACE 0 /* IMPORTANT: if you change the following list, don't * forget to update the corresponding 'tags' table in diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c index 7933858..3cbd0cd 100644 --- a/adb/file_sync_service.c +++ b/adb/file_sync_service.c @@ -26,7 +26,6 @@ #include #include -#include #include "sysdeps.h" #define TRACE_TAG TRACE_SYNC @@ -73,7 +72,6 @@ static int mkdirs(char *name) *x = '/'; return ret; } - selinux_android_restorecon(name, 0); } *x++ = '/'; } @@ -251,7 +249,6 @@ static int handle_send_file(int s, char *path, uid_t uid, if(fd >= 0) { struct utimbuf u; adb_close(fd); - selinux_android_restorecon(path, 0); u.actime = timestamp; u.modtime = timestamp; utime(path, &u); diff --git a/adb/remount_service.c b/adb/remount_service.c index 72d15a1..df64799 100644 --- a/adb/remount_service.c +++ b/adb/remount_service.c @@ -28,7 +28,7 @@ #include "adb.h" -static int system_ro = 1; +static int system_ro = 0; static int vendor_ro = 1; /* Returns the device used to mount a directory in /proc/mounts */ @@ -84,7 +84,7 @@ static int remount(const char* dir, int* dir_ro) int fd; int OFF = 0; - if (dir_ro == 0) { + if (*dir_ro == 0) { return 0; } @@ -132,7 +132,6 @@ void remount_service(int fd, void *cookie) else { write_string(fd, "remount failed\n"); } - adb_close(fd); } diff --git a/adb/services.c b/adb/services.c index e61371a..8d4e2b5 100644 --- a/adb/services.c +++ b/adb/services.c @@ -34,7 +34,7 @@ # include # endif #else -# include +# include # include #endif @@ -127,7 +127,7 @@ void reboot_service(int fd, void *arg) goto cleanup; } - ret = property_set(ANDROID_RB_PROPERTY, property_val); + ret = reboot(RB_AUTOBOOT); if (ret < 0) { snprintf(buf, sizeof(buf), "reboot failed: %d\n", ret); writex(fd, buf, strlen(buf)); @@ -302,7 +302,7 @@ static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg #if ADB_HOST #define SHELL_COMMAND "/bin/sh" #else -#define SHELL_COMMAND "/system/bin/sh" +#define SHELL_COMMAND "/bin/sh" #endif #if !ADB_HOST diff --git a/adb/transport_local.c b/adb/transport_local.c index 948cc15..d6d0a3a 100644 --- a/adb/transport_local.c +++ b/adb/transport_local.c @@ -189,7 +189,7 @@ static void *server_socket_thread(void * arg) } /* This is relevant only for ADB daemon running inside the emulator. */ -#if !ADB_HOST +#if !ADB_HOST && ADB_QEMU /* * Redefine open and write for qemu_pipe.h that contains inlined references * to those routines. We will redifine them back after qemu_pipe.h inclusion. @@ -307,7 +307,7 @@ void local_init(int port) if(HOST) { func = client_socket_thread; } else { -#if ADB_HOST +#if ADB_HOST || !ADB_QEMU func = server_socket_thread; #else /* For the adbd daemon in the system image we need to distinguish diff --git a/include/cutils/properties.h b/include/cutils/properties.h index 798db8b..c86f312 100644 --- a/include/cutils/properties.h +++ b/include/cutils/properties.h @@ -19,8 +19,9 @@ #include #include -#include -#include + +#define PROP_NAME_MAX 32 +#define PROP_VALUE_MAX 92 #ifdef __cplusplus extern "C" {