From ba45ddf37cf4543143af6b2e27fc1214f3dbe892 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 27 Apr 2015 18:39:27 -0700 Subject: Stop using adb_strtok, and check argument validity. Change-Id: I323ffda71b82cc939aed446f9c9fb86ca78df153 --- minadbd/services.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index a83256796..dd1fd7c4b 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -43,15 +43,16 @@ void* service_bootstrap_func(void* x) { return 0; } -static void sideload_host_service(int sfd, void* cookie) { - char* saveptr; - const char* s = adb_strtok_r(reinterpret_cast(cookie), ":", &saveptr); - uint64_t file_size = strtoull(s, NULL, 10); - s = adb_strtok_r(NULL, ":", &saveptr); - uint32_t block_size = strtoul(s, NULL, 10); - - printf("sideload-host file size %" PRIu64 " block size %" PRIu32 "\n", - file_size, block_size); +static void sideload_host_service(int sfd, void* data) { + const char* args = reinterpret_cast(data); + int file_size; + int block_size; + if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) { + printf("bad sideload-host arguments: %s\n", args); + exit(1); + } + + printf("sideload-host file size %d block size %d\n", file_size, block_size); int result = run_adb_fuse(sfd, file_size, block_size); -- cgit v1.2.3 From 4039933c62f52dda06e6f355cf42ac9b392d0888 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 1 May 2015 17:07:44 -0700 Subject: Move minadb over to new API. Change-Id: I889bcf2222245c7665287513669cae8831e37081 --- minadbd/Android.mk | 3 ++- minadbd/fuse_adb_provider.cpp | 21 ++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index cbfd76e4e..8398cefe4 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -20,6 +20,7 @@ LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_CONLY_FLAGS := -Wimplicit-function-declaration LOCAL_C_INCLUDES := bootable/recovery system/core/adb LOCAL_WHOLE_STATIC_LIBRARIES := libadbd +LOCAL_STATIC_LIBRARIES := libbase include $(BUILD_STATIC_LIBRARY) @@ -31,6 +32,6 @@ LOCAL_SRC_FILES := fuse_adb_provider_test.cpp LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_C_INCLUDES := $(LOCAL_PATH) system/core/adb LOCAL_STATIC_LIBRARIES := libminadbd -LOCAL_SHARED_LIBRARIES := liblog +LOCAL_SHARED_LIBRARIES := liblog libbase include $(BUILD_NATIVE_TEST) diff --git a/minadbd/fuse_adb_provider.cpp b/minadbd/fuse_adb_provider.cpp index 5da7fd76c..d71807dfb 100644 --- a/minadbd/fuse_adb_provider.cpp +++ b/minadbd/fuse_adb_provider.cpp @@ -26,13 +26,10 @@ #include "fuse_adb_provider.h" #include "fuse_sideload.h" -int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer, - uint32_t fetch_size) { - struct adb_data* ad = (struct adb_data*)cookie; +int read_block_adb(void* data, uint32_t block, uint8_t* buffer, uint32_t fetch_size) { + adb_data* ad = reinterpret_cast(data); - char buf[10]; - snprintf(buf, sizeof(buf), "%08u", block); - if (!WriteStringFully(ad->sfd, buf)) { + if (!WriteFdFmt(ad->sfd, "%08u", block)) { fprintf(stderr, "failed to write to adb host: %s\n", strerror(errno)); return -EIO; } @@ -45,20 +42,18 @@ int read_block_adb(void* cookie, uint32_t block, uint8_t* buffer, return 0; } -static void close_adb(void* cookie) { - struct adb_data* ad = (struct adb_data*)cookie; - - WriteStringFully(ad->sfd, "DONEDONE"); +static void close_adb(void* data) { + adb_data* ad = reinterpret_cast(data); + WriteFdExactly(ad->sfd, "DONEDONE"); } int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size) { - struct adb_data ad; - struct provider_vtab vtab; - + adb_data ad; ad.sfd = sfd; ad.file_size = file_size; ad.block_size = block_size; + provider_vtab vtab; vtab.read_block = read_block_adb; vtab.close = close_adb; -- cgit v1.2.3 From dbb20c48633e63c7c244e84f3fea76e083e225d7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 1 May 2015 22:29:01 -0700 Subject: Fix mips64 minadbd_test build. Looks like the mips64 linker isn't as good as the others at GCing unused stuff, which means it needs libcutils. Change-Id: I5f768e44514350fb81e5360351db3e9cc4201702 --- minadbd/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index 8398cefe4..a7a3e087d 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -32,6 +32,6 @@ LOCAL_SRC_FILES := fuse_adb_provider_test.cpp LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_C_INCLUDES := $(LOCAL_PATH) system/core/adb LOCAL_STATIC_LIBRARIES := libminadbd -LOCAL_SHARED_LIBRARIES := liblog libbase +LOCAL_SHARED_LIBRARIES := liblog libbase libcutils include $(BUILD_NATIVE_TEST) -- cgit v1.2.3 From 921431ffc0dbb3e3277db1215990c693be405276 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 5 May 2015 14:37:53 -0700 Subject: Track adb_thread_create API change. Change-Id: Ia3f30f3ba85c0246d4b667fb7723cfcdce299d4a --- minadbd/services.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index dd1fd7c4b..859463caf 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -61,8 +61,7 @@ static void sideload_host_service(int sfd, void* data) { exit(result == 0 ? 0 : 1); } -static int create_service_thread(void (*func)(int, void *), void *cookie) -{ +static int create_service_thread(void (*func)(int, void *), void *cookie) { int s[2]; if(adb_socketpair(s)) { printf("cannot create service socket pair\n"); @@ -75,8 +74,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) sti->cookie = cookie; sti->fd = s[1]; - adb_thread_t t; - if (adb_thread_create( &t, service_bootstrap_func, sti)){ + if (!adb_thread_create(service_bootstrap_func, sti)) { free(sti); adb_close(s[0]); adb_close(s[1]); -- cgit v1.2.3 From cc08a90cab4b8e1a039ce96ff6d0124cd2c8824a Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 8 May 2015 10:39:33 -0700 Subject: Fix build following adb change. Change-Id: I2e0fb7e880e205b0bca324ff53ffdb5df9e34baf --- minadbd/adb_main.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'minadbd') diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp index f6e240108..0e65386c4 100644 --- a/minadbd/adb_main.cpp +++ b/minadbd/adb_main.cpp @@ -26,13 +26,9 @@ #include "adb.h" #include "transport.h" -int adb_main(int is_daemon, int server_port) -{ - atexit(usb_cleanup); - +int adb_main(int is_daemon, int server_port) { adb_device_banner = "sideload"; - // No SIGCHLD. Let the service subproc handle its children. signal(SIGPIPE, SIG_IGN); init_transport_registration(); -- cgit v1.2.3 From 80e46e08de5f65702fa7f7cd3ef83f905d919bbc Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 3 Jun 2015 10:49:29 -0700 Subject: recovery: Switch to clang And a few trival fixes to suppress warnings. Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65 --- minadbd/Android.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'minadbd') diff --git a/minadbd/Android.mk b/minadbd/Android.mk index a7a3e087d..3db3b4114 100644 --- a/minadbd/Android.mk +++ b/minadbd/Android.mk @@ -15,6 +15,7 @@ LOCAL_SRC_FILES := \ fuse_adb_provider.cpp \ services.cpp \ +LOCAL_CLANG := true LOCAL_MODULE := libminadbd LOCAL_CFLAGS := $(minadbd_cflags) LOCAL_CONLY_FLAGS := -Wimplicit-function-declaration -- cgit v1.2.3 From 9813f5ba57fe7d90d45cb1c2b6f65920ce580e72 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 23 Jun 2015 11:12:58 -0700 Subject: Allow sideloading without authentication. Bug: http://b/22025550 Change-Id: I20f09ae442536f924f19ede0abf6a2bcc0a5cedf --- minadbd/adb_main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp index 0e65386c4..724f39c1d 100644 --- a/minadbd/adb_main.cpp +++ b/minadbd/adb_main.cpp @@ -19,11 +19,12 @@ #include #include -#define TRACE_TAG TRACE_ADB +#define TRACE_TAG TRACE_ADB #include "sysdeps.h" #include "adb.h" +#include "adb_auth.h" #include "transport.h" int adb_main(int is_daemon, int server_port) { @@ -31,6 +32,9 @@ int adb_main(int is_daemon, int server_port) { signal(SIGPIPE, SIG_IGN); + // We can't require authentication for sideloading. http://b/22025550. + auth_required = false; + init_transport_registration(); usb_init(); -- cgit v1.2.3 From faa75006af4f5ff5b189a80c8a6666ff88787e42 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 7 Aug 2015 13:21:06 -0700 Subject: Fix recovery image build. A recent adb cleanup changed the signature of adb_main. Change-Id: I98d084f999966f1a7aa94c63e9ed996b3375096d --- minadbd/adb_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp index 724f39c1d..514f19699 100644 --- a/minadbd/adb_main.cpp +++ b/minadbd/adb_main.cpp @@ -27,7 +27,7 @@ #include "adb_auth.h" #include "transport.h" -int adb_main(int is_daemon, int server_port) { +int adb_main(int is_daemon, int server_port, int /* reply_fd */) { adb_device_banner = "sideload"; signal(SIGPIPE, SIG_IGN); -- cgit v1.2.3 From c3d4d535466eb939607651e12a490f92e9936763 Mon Sep 17 00:00:00 2001 From: David Pursell Date: Tue, 25 Aug 2015 12:50:47 -0700 Subject: minadbd: update service_to_fd() signature. No functional change, just matching the signature to an adb change. See https://android-review.googlesource.com/#/c/169601/. Change-Id: Ic826864e126054849b3a4d193ded8acc5ee5269c --- minadbd/services.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index 859463caf..5c1d35614 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -86,7 +86,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) { return s[0]; } -int service_to_fd(const char* name) { +int service_to_fd(const char* name, const atransport* transport) { int ret = -1; if (!strncmp(name, "sideload:", 9)) { -- cgit v1.2.3 From 7c913e5faa1f3aa226c8de61cdc24e9be26ac422 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 23 Sep 2015 16:03:11 -0700 Subject: minadbd: move from D() to VLOG(). Change-Id: I542e2ae8f5ef18b2d6b3dbc1888b3ce1e02a7404 --- minadbd/adb_main.cpp | 4 +--- minadbd/services.cpp | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'minadbd') diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp index 514f19699..c968204b2 100644 --- a/minadbd/adb_main.cpp +++ b/minadbd/adb_main.cpp @@ -19,8 +19,6 @@ #include #include -#define TRACE_TAG TRACE_ADB - #include "sysdeps.h" #include "adb.h" @@ -38,7 +36,7 @@ int adb_main(int is_daemon, int server_port, int /* reply_fd */) { init_transport_registration(); usb_init(); - D("Event loop starting\n"); + VLOG(ADB) << "Event loop starting"; fdevent_loop(); return 0; diff --git a/minadbd/services.cpp b/minadbd/services.cpp index 5c1d35614..2a3027bd8 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -23,7 +23,6 @@ #include "sysdeps.h" -#define TRACE_TAG TRACE_SERVICES #include "adb.h" #include "fdevent.h" #include "fuse_adb_provider.h" @@ -82,7 +81,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie) { return -1; } - D("service thread started, %d:%d\n",s[0], s[1]); + VLOG(SERVICES) << "service thread started, " << s[0] << ":" << s[1]; return s[0]; } -- cgit v1.2.3 From c8a3c80603d4a78ff1f3c87dbf4206ac4306b150 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Tue, 29 Sep 2015 18:05:30 -0700 Subject: minadbd: use strdup() to create argument for sideload thread. So sideload thread will not use argument which is to be freed in the main thread. Bug: 23968770 Change-Id: I9d6dadc6c33cfbe4b5759382a80fe14cd0d54355 --- minadbd/services.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index 2a3027bd8..d25648fb4 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -43,13 +43,14 @@ void* service_bootstrap_func(void* x) { } static void sideload_host_service(int sfd, void* data) { - const char* args = reinterpret_cast(data); + char* args = reinterpret_cast(data); int file_size; int block_size; if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) { printf("bad sideload-host arguments: %s\n", args); exit(1); } + free(args); printf("sideload-host file size %d block size %d\n", file_size, block_size); @@ -94,7 +95,8 @@ int service_to_fd(const char* name, const atransport* transport) { // sideload-host). exit(3); } else if (!strncmp(name, "sideload-host:", 14)) { - ret = create_service_thread(sideload_host_service, (void*)(name + 14)); + char* arg = strdup(name + 14); + ret = create_service_thread(sideload_host_service, arg); } if (ret >= 0) { close_on_exec(ret); -- cgit v1.2.3 From 9f4fdb3def9264a80e05e473ac67ddc19c1a6ef2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 20 Nov 2015 13:03:24 -0800 Subject: Track name change from adb_main to adb_server_main. Change-Id: I835805348a9817c81639ad8471e3b49cae93c107 --- minadbd/adb_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minadbd') diff --git a/minadbd/adb_main.cpp b/minadbd/adb_main.cpp index c968204b2..0694280cb 100644 --- a/minadbd/adb_main.cpp +++ b/minadbd/adb_main.cpp @@ -25,7 +25,7 @@ #include "adb_auth.h" #include "transport.h" -int adb_main(int is_daemon, int server_port, int /* reply_fd */) { +int adb_server_main(int is_daemon, int server_port, int /* reply_fd */) { adb_device_banner = "sideload"; signal(SIGPIPE, SIG_IGN); -- cgit v1.2.3 From cd324766ab2a73af4106f65cd53dc0a91de5e2e9 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Fri, 12 Feb 2016 15:00:52 -0800 Subject: minadbd: update for adb_thread_create signature change. Change-Id: Ifa0b4d8c1cf0bb39abac61984ff165e82e41222c (cherry picked from commit cc07b3556510d03e389a8994a8e5dbed3f3bbbb4) --- minadbd/services.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'minadbd') diff --git a/minadbd/services.cpp b/minadbd/services.cpp index d25648fb4..658a43f36 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -35,11 +35,10 @@ struct stinfo { void *cookie; }; -void* service_bootstrap_func(void* x) { +void service_bootstrap_func(void* x) { stinfo* sti = reinterpret_cast(x); sti->func(sti->fd, sti->cookie); free(sti); - return 0; } static void sideload_host_service(int sfd, void* data) { -- cgit v1.2.3