1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
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 <cutils/properties.h>
-#include <private/android_filesystem_config.h>
#include <sys/capability.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <getopt.h>
-#include <selinux/selinux.h>
#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 <errno.h>
#include <private/android_filesystem_config.h>
-#include <selinux/android.h>
#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 <sys/ioctl.h>
# endif
#else
-# include <cutils/android_reboot.h>
+# include <sys/reboot.h>
# include <cutils/properties.h>
#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 <sys/cdefs.h>
#include <stddef.h>
-#include <sys/system_properties.h>
-#include <stdint.h>
+
+#define PROP_NAME_MAX 32
+#define PROP_VALUE_MAX 92
#ifdef __cplusplus
extern "C" {
|