blob: 1d18d47ec314d7af0998248e8241bb7aef67a2cf [file] [log] [blame]
Andrew Geisslerfc113ea2023-03-31 09:59:46 -05001From 5de85f8273c7284aa93e35c40f025d4d43d42df9 Mon Sep 17 00:00:00 2001
2From: Etienne Cordonnier <ecordonnier@snap.com>
3Date: Thu, 16 Mar 2023 18:59:35 +0100
4Subject: [PATCH] Fixes for yocto build
5
6Signed-off-by: JJ Robertson <jrobertson@snapchat.com>
7[rebased on version 29]
8Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
9
10---
Andrew Geissler220dafd2023-10-04 10:18:08 -050011Upstream-Status: Pending
12
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050013 system/core/adb/daemon/file_sync_service.cpp | 4 ++--
14 system/core/adb/daemon/framebuffer_service.h | 2 --
15 system/core/adb/daemon/main.cpp | 5 +++--
16 system/core/adb/daemon/restart_service.h | 2 --
17 system/core/adb/daemon/services.cpp | 6 ++----
18 system/core/adb/daemon/shell_service.cpp | 5 ++++-
19 system/core/adb/types.h | 1 +
20 7 files changed, 12 insertions(+), 13 deletions(-)
21
22diff --git a/system/core/adb/daemon/file_sync_service.cpp b/system/core/adb/daemon/file_sync_service.cpp
23index d6af7087..92e7087a 100644
24--- a/system/core/adb/daemon/file_sync_service.cpp
25+++ b/system/core/adb/daemon/file_sync_service.cpp
26@@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) {
27 partial_path += path_component;
28
29 if (should_use_fs_config(partial_path)) {
30- fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
31+ // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
32 }
33 if (adb_mkdir(partial_path.c_str(), mode) == -1) {
34 if (errno != EEXIST) {
35@@ -469,7 +469,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) {
36 uint64_t capabilities = 0;
37 if (should_use_fs_config(path)) {
38 unsigned int broken_api_hack = mode;
39- fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities);
40+ // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities);
41 mode = broken_api_hack;
42 }
43
44diff --git a/system/core/adb/daemon/framebuffer_service.h b/system/core/adb/daemon/framebuffer_service.h
45index bab44be3..264da597 100644
46--- a/system/core/adb/daemon/framebuffer_service.h
47+++ b/system/core/adb/daemon/framebuffer_service.h
48@@ -18,6 +18,4 @@
49
50 #include "adb_unique_fd.h"
51
52-#if defined(__ANDROID__)
53 void framebuffer_service(unique_fd fd);
54-#endif
55diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp
56index 3322574c..e807d13d 100644
57--- a/system/core/adb/daemon/main.cpp
58+++ b/system/core/adb/daemon/main.cpp
59@@ -208,6 +208,9 @@ int adbd_main(int server_port) {
60 umask(0);
61
62 signal(SIGPIPE, SIG_IGN);
63+ signal(SIGINT, SIG_DFL);
64+ signal(SIGQUIT, SIG_DFL);
65+
66
67 #if defined(__BIONIC__)
68 auto fdsan_level = android_fdsan_get_error_level();
69@@ -254,13 +257,11 @@ int adbd_main(int server_port) {
70
71 bool is_usb = false;
72
73-#if defined(__ANDROID__)
74 if (access(USB_FFS_ADB_EP0, F_OK) == 0) {
75 // Listen on USB.
76 usb_init();
77 is_usb = true;
78 }
79-#endif
80
81 // If one of these properties is set, also listen on that port.
82 // If one of the properties isn't set and we couldn't listen on usb, listen
83diff --git a/system/core/adb/daemon/restart_service.h b/system/core/adb/daemon/restart_service.h
84index 19840bd5..7a97614b 100644
85--- a/system/core/adb/daemon/restart_service.h
86+++ b/system/core/adb/daemon/restart_service.h
87@@ -18,9 +18,7 @@
88
89 #include "adb_unique_fd.h"
90
91-#if defined(__ANDROID__)
92 void restart_root_service(unique_fd fd);
93 void restart_unroot_service(unique_fd fd);
94 void restart_tcp_service(unique_fd fd, int port);
95 void restart_usb_service(unique_fd fd);
96-#endif
97diff --git a/system/core/adb/daemon/services.cpp b/system/core/adb/daemon/services.cpp
98index 4ec90d27..d8541c23 100644
99--- a/system/core/adb/daemon/services.cpp
100+++ b/system/core/adb/daemon/services.cpp
101@@ -156,7 +156,7 @@ static void spin_service(unique_fd fd) {
102 }
103 #endif
104 // Fall through
105- std::string cmd = "/system/bin/reboot ";
106+ std::string cmd = "/sbin/reboot ";
107 cmd += name;
108 return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
109 }
110@@ -265,11 +265,10 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) {
111 }
112 #endif
113
114-#if defined(__ANDROID__)
115 if (name.starts_with("framebuffer:")) {
116 return create_service_thread("fb", framebuffer_service);
117 } else if (android::base::ConsumePrefix(&name, "remount:")) {
118- std::string cmd = "/system/bin/remount ";
119+ std::string cmd = "/sbin/remount ";
120 cmd += name;
121 return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
122 } else if (android::base::ConsumePrefix(&name, "reboot:")) {
123@@ -303,7 +302,6 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) {
124 } else if (name.starts_with("usb:")) {
125 return create_service_thread("usb", restart_usb_service);
126 }
127-#endif
128
129 if (android::base::ConsumePrefix(&name, "dev:")) {
130 return unique_fd{unix_open(name, O_RDWR | O_CLOEXEC)};
131diff --git a/system/core/adb/daemon/shell_service.cpp b/system/core/adb/daemon/shell_service.cpp
132index f62032d0..ebcfe18d 100644
133--- a/system/core/adb/daemon/shell_service.cpp
134+++ b/system/core/adb/daemon/shell_service.cpp
135@@ -273,13 +273,16 @@ bool Subprocess::ForkAndExec(std::string* error) {
136 env["HOSTNAME"] = GetHostName();
137 env["LOGNAME"] = pw->pw_name;
138 env["SHELL"] = pw->pw_shell;
139- env["TMPDIR"] = "/data/local/tmp";
140 env["USER"] = pw->pw_name;
141 }
142
143 if (!terminal_type_.empty()) {
144 env["TERM"] = terminal_type_;
145 }
146+ if (env.find("PS1") == env.end()) {
147+ env["PS1"] = "\\h:\\w\\$ ";
148+ }
149+
150
151 std::vector<std::string> joined_env;
152 for (const auto& it : env) {
153diff --git a/system/core/adb/types.h b/system/core/adb/types.h
154index c619fffc..f8e0f521 100644
155--- a/system/core/adb/types.h
156+++ b/system/core/adb/types.h
157@@ -22,6 +22,7 @@
158 #include <memory>
159 #include <utility>
160 #include <vector>
161+#include <string.h>
162
163 #include <android-base/logging.h>
164