|
26 | 26 |
|
27 | 27 | int send_intent(struct su_context *ctx, allow_t allow, const char *action)
|
28 | 28 | {
|
| 29 | + const char *socket_path; |
| 30 | + unsigned int uid = ctx->from.uid; |
| 31 | + |
29 | 32 | if (ctx->child) {
|
30 | 33 | LOGE("child %d already running", ctx->child);
|
31 | 34 | return -1;
|
32 | 35 | }
|
| 36 | + if (allow == INTERACTIVE) { |
| 37 | + socket_path = ctx->sock_path; |
| 38 | + } else { |
| 39 | + socket_path = ""; |
| 40 | + } |
33 | 41 |
|
34 | 42 | pid_t pid = fork();
|
35 | 43 | /* Child */
|
36 | 44 | if (!pid) {
|
37 |
| - const char *socket_path = (allow == INTERACTIVE) ? ctx->sock_path : ""; |
38 | 45 | char command[ARG_MAX];
|
39 | 46 |
|
40 | 47 | snprintf(command, sizeof(command),
|
41 | 48 | "exec /system/bin/am broadcast -a %s --es socket '%s' "
|
42 | 49 | "--ei caller_uid %d --ei allow %d "
|
43 | 50 | "--ei version_code %d",
|
44 |
| - action, socket_path, ctx->from.uid, allow, VERSION_CODE); |
| 51 | + action, socket_path, uid, allow, VERSION_CODE); |
45 | 52 | char *args[] = { "sh", "-c", command, NULL, };
|
46 | 53 |
|
47 | 54 | /*
|
48 | 55 | * before sending the intent, make sure the effective uid/gid match
|
49 | 56 | * the real uid/gid, otherwise LD_LIBRARY_PATH is wiped
|
50 | 57 | * in Android 4.0+.
|
51 | 58 | */
|
52 |
| - set_identity(ctx->from.uid); |
| 59 | + set_identity(uid); |
53 | 60 | int zero = open("/dev/zero", O_RDONLY | O_CLOEXEC);
|
54 | 61 | dup2(zero, 0);
|
55 | 62 | int null = open("/dev/null", O_WRONLY | O_CLOEXEC);
|
|
0 commit comments