summaryrefslogtreecommitdiffstats
path: root/recipes/adbd/files/adbd.patch
blob: 110b021757e754307850c22b8ba84f4a76376143 (plain)
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
diff --git a/adb/adb.c b/adb/adb.c
index 07bfbe5..c8f37ff 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -141,7 +141,7 @@ void  adb_trace_init(void)
     }
 }
 
-#if !ADB_HOST
+#if !ADB_HOST && ADB_QEMU
 /*
  * Implements ADB tracing inside the emulator.
  */
@@ -282,6 +282,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
@@ -1056,31 +1072,7 @@ static int should_drop_privileges() {
 #ifndef ALLOW_ADBD_ROOT
     return 1;
 #else /* ALLOW_ADBD_ROOT */
-    int secure = 0;
-    char value[PROPERTY_VALUE_MAX];
-
-   /* run adbd in secure mode if ro.secure is set and
-    ** we are not in the emulator
-    */
-    property_get("ro.kernel.qemu", value, "");
-    if (strcmp(value, "1") != 0) {
-        property_get("ro.secure", value, "1");
-        if (strcmp(value, "1") == 0) {
-            // don't run as root if ro.secure is set...
-            secure = 1;
-
-            // ... except we allow running as root in userdebug builds if the
-            // service.adb.root property has been set by the "adb root" command
-            property_get("ro.debuggable", value, "");
-            if (strcmp(value, "1") == 0) {
-                property_get("service.adb.root", value, "");
-                if (strcmp(value, "1") == 0) {
-                    secure = 0;
-                }
-            }
-        }
-    }
-    return secure;
+    return 0;
 #endif /* ALLOW_ADBD_ROOT */
 }
 #endif /* !ADB_HOST */
@@ -1543,7 +1535,9 @@ 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. */
+#if ADB_QEMU
     adb_qemu_trace_init();
+#endif
     if((argc > 1) && (!strcmp(argv[1],"recovery"))) {
         adb_device_banner = "recovery";
         recovery_mode = 1;
diff --git a/adb/adb.h b/adb/adb.h
index 9da8af8..ae3dd31 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -363,7 +363,7 @@ typedef enum {
 
 #if ADB_TRACE
 
-#if !ADB_HOST
+#if !ADB_HOST && ADB_QEMU
 /*
  * When running inside the emulator, guest's adbd can connect to 'adb-debug'
  * qemud service that can display adb trace messages (on condition that emulator
diff --git a/adb/remount_service.c b/adb/remount_service.c
index 4cb41e7..6cfc2c6 100644
--- a/adb/remount_service.c
+++ b/adb/remount_service.c
@@ -77,12 +77,12 @@ static int remount_system()
         return 0;
     }
 
-    dev = find_mount("/system");
+    dev = find_mount("/");
 
     if (!dev)
         return -1;
 
-    system_ro = mount(dev, "/system", "none", MS_REMOUNT, NULL);
+    system_ro = mount(dev, "/", "none", MS_REMOUNT, NULL);
 
     free(dev);
 
diff --git a/adb/services.c b/adb/services.c
index 495a083..eb895ae 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -33,7 +33,7 @@
 #    include <sys/ioctl.h>
 #  endif
 #else
-#  include <cutils/android_reboot.h>
+#  include <linux/reboot.h>
 #endif
 
 typedef struct stinfo stinfo;
@@ -182,7 +182,7 @@ void reboot_service(int fd, void *arg)
         waitpid(pid, &ret, 0);
     }
 
-    ret = android_reboot(ANDROID_RB_RESTART2, 0, (char *) arg);
+    ret = reboot(LINUX_REBOOT_CMD_RESTART2, 0, (char *) arg);
     if (ret < 0) {
         snprintf(buf, sizeof(buf), "reboot failed: %s\n", strerror(errno));
         writex(fd, buf, strlen(buf));
@@ -334,7 +334,7 @@ static int create_subprocess(const char *cmd, const char *arg0, const char *arg1
 #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 96a24ba..51c85fc 100644
--- a/adb/transport_local.c
+++ b/adb/transport_local.c
@@ -186,7 +186,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.
@@ -304,7 +304,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/adb/transport_usb.c b/adb/transport_usb.c
index ee6b637..c5e1408 100644
--- a/adb/transport_usb.c
+++ b/adb/transport_usb.c
@@ -18,7 +18,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <sysdeps.h>
+#include "sysdeps.h"
 
 #define  TRACE_TAG  TRACE_TRANSPORT
 #include "adb.h"