1
+ /*
2
+ ** Copyright 2010, Adam Shanks (@ChainsDD)
3
+ ** Copyright 2008, Zinx Verituse (@zinxv)
4
+ **
5
+ ** Licensed under the Apache License, Version 2.0 (the "License");
6
+ ** you may not use this file except in compliance with the License.
7
+ ** You may obtain a copy of the License at
8
+ **
9
+ ** http://www.apache.org/licenses/LICENSE-2.0
10
+ **
11
+ ** Unless required by applicable law or agreed to in writing, software
12
+ ** distributed under the License is distributed on an "AS IS" BASIS,
13
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ ** See the License for the specific language governing permissions and
15
+ ** limitations under the License.
16
+ */
17
+
1
18
#include < unistd.h>
2
19
#include < android_runtime/ActivityManager.h>
3
20
#include < binder/IBinder.h>
@@ -23,7 +40,7 @@ static const int VAL_INTEGER = 1;
23
40
24
41
static const int START_SUCCESS = 0 ;
25
42
26
- int send_intent (struct su_initiator *from, struct su_request *to, const char *socket_path, int type)
43
+ int send_intent (struct su_initiator *from, struct su_request *to, const char *socket_path, int allow, int type)
27
44
{
28
45
char sdk_version_prop[PROPERTY_VALUE_MAX] = " 0" ;
29
46
property_get (" ro.build.version.sdk" , sdk_version_prop, " 0" );
@@ -43,7 +60,7 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
43
60
if (type == 0 ) {
44
61
data.writeString16 (String16 (" com.noshufou.android.su.REQUEST" )); /* action */
45
62
} else {
46
- data.writeString16 (String16 (" com.noshufou.android.su.NOTIFICATION " )); /* action */
63
+ data.writeString16 (String16 (" com.noshufou.android.su.RESULT " )); /* action */
47
64
}
48
65
data.writeInt32 (NULL_TYPE_ID); /* Uri - data */
49
66
data.writeString16 (NULL , 0 ); /* type */
@@ -63,13 +80,18 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
63
80
int oldPos = data.dataPosition ();
64
81
data.writeInt32 (0x4C444E42 ); // 'B' 'N' 'D' 'L'
65
82
{ /* writeMapInternal */
66
- data.writeInt32 (4 ); /* writeMapInternal - size */
83
+ data.writeInt32 (7 ); /* writeMapInternal - size */
67
84
68
85
data.writeInt32 (VAL_STRING);
69
86
data.writeString16 (String16 (" caller_uid" ));
70
87
data.writeInt32 (VAL_INTEGER);
71
88
data.writeInt32 (from->uid );
72
89
90
+ data.writeInt32 (VAL_STRING);
91
+ data.writeString16 (String16 (" caller_bin" ));
92
+ data.writeInt32 (VAL_STRING);
93
+ data.writeString16 (String16 (from->bin ));
94
+
73
95
data.writeInt32 (VAL_STRING);
74
96
data.writeString16 (String16 (" desired_uid" ));
75
97
data.writeInt32 (VAL_INTEGER);
@@ -84,6 +106,16 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
84
106
data.writeString16 (String16 (" socket" ));
85
107
data.writeInt32 (VAL_STRING);
86
108
data.writeString16 (String16 (socket_path));
109
+
110
+ data.writeInt32 (VAL_STRING);
111
+ data.writeString16 (String16 (" allow" ));
112
+ data.writeInt32 (VAL_INTEGER);
113
+ data.writeInt32 (allow);
114
+
115
+ data.writeInt32 (VAL_STRING);
116
+ data.writeString16 (String16 (" version_code" ));
117
+ data.writeInt32 (VAL_INTEGER);
118
+ data.writeInt32 (VERSION_CODE);
87
119
}
88
120
int newPos = data.dataPosition ();
89
121
data.setDataPosition (oldPos - 4 );
0 commit comments