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+
118#include < unistd.h>
219#include < android_runtime/ActivityManager.h>
320#include < binder/IBinder.h>
@@ -23,7 +40,7 @@ static const int VAL_INTEGER = 1;
2340
2441static const int START_SUCCESS = 0 ;
2542
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)
2744{
2845 char sdk_version_prop[PROPERTY_VALUE_MAX] = " 0" ;
2946 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
4360 if (type == 0 ) {
4461 data.writeString16 (String16 (" com.noshufou.android.su.REQUEST" )); /* action */
4562 } else {
46- data.writeString16 (String16 (" com.noshufou.android.su.NOTIFICATION " )); /* action */
63+ data.writeString16 (String16 (" com.noshufou.android.su.RESULT " )); /* action */
4764 }
4865 data.writeInt32 (NULL_TYPE_ID); /* Uri - data */
4966 data.writeString16 (NULL , 0 ); /* type */
@@ -63,13 +80,18 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
6380 int oldPos = data.dataPosition ();
6481 data.writeInt32 (0x4C444E42 ); // 'B' 'N' 'D' 'L'
6582 { /* writeMapInternal */
66- data.writeInt32 (4 ); /* writeMapInternal - size */
83+ data.writeInt32 (7 ); /* writeMapInternal - size */
6784
6885 data.writeInt32 (VAL_STRING);
6986 data.writeString16 (String16 (" caller_uid" ));
7087 data.writeInt32 (VAL_INTEGER);
7188 data.writeInt32 (from->uid );
7289
90+ data.writeInt32 (VAL_STRING);
91+ data.writeString16 (String16 (" caller_bin" ));
92+ data.writeInt32 (VAL_STRING);
93+ data.writeString16 (String16 (from->bin ));
94+
7395 data.writeInt32 (VAL_STRING);
7496 data.writeString16 (String16 (" desired_uid" ));
7597 data.writeInt32 (VAL_INTEGER);
@@ -84,6 +106,16 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
84106 data.writeString16 (String16 (" socket" ));
85107 data.writeInt32 (VAL_STRING);
86108 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);
87119 }
88120 int newPos = data.dataPosition ();
89121 data.setDataPosition (oldPos - 4 );
0 commit comments