Skip to content

Commit b9a7e7b

Browse files
committed
Bring legacy up to date with master
1 parent e925f91 commit b9a7e7b

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

activity.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,18 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
8080
int oldPos = data.dataPosition();
8181
data.writeInt32(0x4C444E42); // 'B' 'N' 'D' 'L'
8282
{ /* writeMapInternal */
83-
data.writeInt32(6); /* writeMapInternal - size */
83+
data.writeInt32(7); /* writeMapInternal - size */
8484

8585
data.writeInt32(VAL_STRING);
8686
data.writeString16(String16("caller_uid"));
8787
data.writeInt32(VAL_INTEGER);
8888
data.writeInt32(from->uid);
8989

90+
data.writeInt32(VAL_STRING);
91+
data.writeString16(String16("caller_bin"));
92+
data.writeInt32(VAL_STRING);
93+
data.writeString16(String16(from->bin));
94+
9095
data.writeInt32(VAL_STRING);
9196
data.writeString16(String16("desired_uid"));
9297
data.writeInt32(VAL_INTEGER);

su.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern char* _mktemp(char*); /* mktemp doesn't link right. Don't ask me why. */
4848
extern sqlite3 *database_init();
4949
extern int database_check(sqlite3*, struct su_initiator*, struct su_request*);
5050

51-
/* Not lazy anymore, just need these in too many places */
51+
/* Still lazt, will fix this */
5252
static char *socket_path = NULL;
5353
static sqlite3 *db = NULL;
5454

@@ -318,7 +318,8 @@ int main(int argc, char *argv[])
318318
}
319319
} else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--shell")) {
320320
if (++i < argc) {
321-
strcpy(shell, argv[i]);
321+
strncpy(shell, argv[i], sizeof(shell));
322+
shell[sizeof(shell) - 1] = 0;
322323
} else {
323324
usage();
324325
}
@@ -351,9 +352,11 @@ int main(int argc, char *argv[])
351352
}
352353
}
353354

354-
from_init(&su_from);
355+
if (from_init(&su_from) < 0) {
356+
deny();
357+
}
355358

356-
if (su_from.uid == AID_ROOT)
359+
if (su_from.uid == AID_ROOT || su_from.uid == AID_SHELL)
357360
allow(shell);
358361

359362
if (stat(REQUESTOR_DATA_PATH, &st) < 0) {
@@ -370,14 +373,14 @@ int main(int argc, char *argv[])
370373

371374
req_uid = st.st_uid;
372375

373-
if (from_init(&su_from) < 0) {
374-
deny();
375-
}
376-
377376
if (mkdir(REQUESTOR_CACHE_PATH, 0771) >= 0) {
378377
chown(REQUESTOR_CACHE_PATH, req_uid, req_uid);
379378
}
380379

380+
setgroups(0, NULL);
381+
setegid(st.st_gid);
382+
seteuid(st.st_uid);
383+
381384
LOGE("sudb - Opening database");
382385
db = database_init();
383386
if (!db) {
@@ -391,14 +394,15 @@ int main(int argc, char *argv[])
391394
// Close the database, we're done with it. If it stays open,
392395
// it will cause problems
393396
sqlite3_close(db);
397+
db = NULL;
394398
LOGE("sudb - Database closed");
395399
}
396400

397401
switch (dballow) {
398-
case DB_DENY: LOGE("denying"); deny();
399-
case DB_ALLOW: LOGE("allowing"); allow(shell);
400-
case DB_INTERACTIVE: LOGE("asking"); break;
401-
default: LOGE("default, denying"); deny();
402+
case DB_DENY: deny();
403+
case DB_ALLOW: allow(shell);
404+
case DB_INTERACTIVE: break;
405+
default: deny();
402406
}
403407

404408
socket_serv_fd = socket_create_temp(req_uid);

su.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
#define SOCKET_PATH_TEMPLATE REQUESTOR_CACHE_PATH "/.socketXXXXXX"
3434

35-
#define VERSION "3.0l"
36-
#define VERSION_CODE 11
35+
#define VERSION "3.0.1l"
36+
#define VERSION_CODE 12
3737

3838
#define DATABASE_VERSION 6
3939

0 commit comments

Comments
 (0)