/
system_core.patch
210 lines (180 loc) · 6.21 KB
/
system_core.patch
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
From 9207102b0b8db520dc2dad681dba5fe353b818fb Mon Sep 17 00:00:00 2001
From: xc-racer99 <xc-racer2@live.ca>
Date: Thu, 25 Aug 2016 21:31:18 -0700
Subject: [PATCH 1/3] core: Don't try to flash recovery
Just don't. Would totally screw up the device if it succeeded...
---
rootdir/init.rc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 7dc9e5509..adc062b2d 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -656,6 +656,6 @@ on property:ro.debuggable=1
chmod 0773 /data/misc/trace
start console
-service flash_recovery /system/bin/install-recovery.sh
- class main
- oneshot
+#service flash_recovery /system/bin/install-recovery.sh
+# class main
+# oneshot
--
2.11.0
From af119e76f984cf28d0d8e1083669c6eda088da51 Mon Sep 17 00:00:00 2001
From: xc-racer99 <xc-racer2@live.ca>
Date: Fri, 30 Sep 2016 09:37:56 -0700
Subject: [PATCH 2/3] Revert "libnetutils: Add synchronization per socket full
operation"
Wreaks havoc with our data connection
This reverts commit cebcd450c6ca3de5106ef3d817d5b760f5d57fbe.
---
libnetutils/dhcptool.c | 7 ++-----
libnetutils/ifc_utils.c | 9 ---------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/libnetutils/dhcptool.c b/libnetutils/dhcptool.c
index d23afd3bd..5dfb3e8bf 100644
--- a/libnetutils/dhcptool.c
+++ b/libnetutils/dhcptool.c
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-#include <err.h>
#include <errno.h>
#include <error.h>
#include <stdbool.h>
@@ -31,14 +30,12 @@ int main(int argc, char* argv[]) {
char* interface = argv[1];
if (ifc_init()) {
- err(errno, "dhcptool %s: ifc_init failed", interface);
- ifc_close();
- return EXIT_FAILURE;
+ error(EXIT_FAILURE, errno, "dhcptool %s: ifc_init failed", interface);
}
int rc = do_dhcp(interface);
if (rc) {
- err(errno, "dhcptool %s: do_dhcp failed", interface);
+ error(0, errno, "dhcptool %s: do_dhcp failed", interface);
}
ifc_close();
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index eae32ce36..f9f62f8ce 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -19,7 +19,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
-#include <pthread.h>
#include <sys/socket.h>
#include <sys/select.h>
@@ -58,8 +57,6 @@
static int ifc_ctl_sock = -1;
static int ifc_ctl_sock6 = -1;
-static pthread_mutex_t ifc_sock_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-static pthread_mutex_t ifc_sock6_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
void printerr(char *fmt, ...);
#define DBG 0
@@ -125,8 +122,6 @@ int string_to_ip(const char *string, struct sockaddr_storage *ss) {
int ifc_init(void)
{
int ret;
-
- pthread_mutex_lock(&ifc_sock_mutex);
if (ifc_ctl_sock == -1) {
ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (ifc_ctl_sock < 0) {
@@ -141,7 +136,6 @@ int ifc_init(void)
int ifc_init6(void)
{
- pthread_mutex_lock(&ifc_sock6_mutex);
if (ifc_ctl_sock6 == -1) {
ifc_ctl_sock6 = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (ifc_ctl_sock6 < 0) {
@@ -158,7 +152,6 @@ void ifc_close(void)
(void)close(ifc_ctl_sock);
ifc_ctl_sock = -1;
}
- pthread_mutex_unlock(&ifc_sock_mutex);
}
void ifc_close6(void)
@@ -167,7 +160,6 @@ void ifc_close6(void)
(void)close(ifc_ctl_sock6);
ifc_ctl_sock6 = -1;
}
- pthread_mutex_unlock(&ifc_sock6_mutex);
}
static void ifc_init_ifr(const char *name, struct ifreq *ifr)
@@ -561,7 +553,6 @@ int ifc_act_on_ipv4_route(int action, const char *ifname, struct in_addr dst, in
ifc_init();
if (ifc_ctl_sock < 0) {
- ifc_close();
return -errno;
}
--
2.11.0
From a2835b74f13da15dd1ef59ef2a1e9dcfe3f6be9b Mon Sep 17 00:00:00 2001
From: Steve Kondik <steve@cyngn.com>
Date: Wed, 31 Aug 2016 02:31:13 -0700
Subject: [PATCH 3/3] adb: Check for alternate shell paths
* Check for persist.sys.adb.shell first
* Check for /sbin/sh (recovery)
Change-Id: I191b9289b176809ef754d7a8126acfd355ab009f
---
adb/shell_service.cpp | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp
index 104f39947..61b104e86 100644
--- a/adb/shell_service.cpp
+++ b/adb/shell_service.cpp
@@ -85,6 +85,7 @@
#include <pty.h>
#include <pwd.h>
#include <sys/select.h>
+#include <sys/stat.h>
#include <termios.h>
#include <memory>
@@ -103,6 +104,8 @@
#include "adb_utils.h"
#include "security_log_tags.h"
+#include "cutils/properties.h"
+
namespace {
void init_subproc_child()
@@ -228,6 +231,7 @@ bool Subprocess::ForkAndExec(std::string* error) {
ScopedFd child_stdinout_sfd, child_stderr_sfd;
ScopedFd parent_error_sfd, child_error_sfd;
char pts_name[PATH_MAX];
+ char propbuf[PATH_MAX];
if (command_.empty()) {
__android_log_security_bswrite(SEC_TAG_ADB_SHELL_INTERACTIVE, "");
@@ -334,12 +338,25 @@ bool Subprocess::ForkAndExec(std::string* error) {
parent_error_sfd.Reset();
close_on_exec(child_error_sfd.fd());
+ std::string shell_command;
+ struct stat st;
+ property_get("persist.sys.adb.shell", propbuf, "");
+ if (propbuf[0] != '\0' && stat(propbuf, &st) == 0) {
+ shell_command = propbuf;
+ } else if (stat(_PATH_BSHELL2, &st) == 0) {
+ shell_command = _PATH_BSHELL2;
+ } else {
+ shell_command = _PATH_BSHELL;
+ }
+
if (command_.empty()) {
- execle(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr, cenv.data());
+ execle(shell_command.c_str(), shell_command.c_str(), "-", nullptr, cenv.data());
} else {
- execle(_PATH_BSHELL, _PATH_BSHELL, "-c", command_.c_str(), nullptr, cenv.data());
+ execle(shell_command.c_str(), shell_command.c_str(), "-c", command_.c_str(), nullptr, cenv.data());
}
- WriteFdExactly(child_error_sfd.fd(), "exec '" _PATH_BSHELL "' failed: ");
+
+ std::string errmsg = "exec '" + shell_command + "' failed: ";
+ WriteFdExactly(child_error_sfd.fd(), errmsg.c_str());
WriteFdExactly(child_error_sfd.fd(), strerror(errno));
child_error_sfd.Reset();
_Exit(1);
--
2.11.0