Skip to content

Commit de0050d

Browse files
committed
Fix for apps that use multiple commands
1 parent 779707b commit de0050d

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

activity.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ int send_intent(struct su_context *ctx, allow_t allow, const char *action)
8888
char command[ARG_MAX];
8989

9090
snprintf(command, sizeof(command),
91-
"exec /system/bin/am broadcast -a %s --es socket '%s' "
92-
"--ei caller_uid %d --ei allow %d "
93-
"--ei version_code %d",
94-
action, socket_path, uid, allow, VERSION_CODE);
91+
"exec /system/bin/am broadcast --user %d -a %s --es socket '%s' "
92+
"--ei caller_uid %d --ei allow %d --es desired_cmd '%s' "
93+
"--ei all %d --ei version_code %d",
94+
ctx->from.user, action, socket_path, uid, allow, get_command(&ctx->to),
95+
ctx->to.all, VERSION_CODE);
9596
char *args[] = { "sh", "-c", command, NULL, };
9697

9798
/*

db.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "su.h"
2222

23-
int database_check(const struct su_context *ctx)
23+
int database_check(struct su_context *ctx)
2424
{
2525
FILE *fp;
2626
char filename[PATH_MAX];
@@ -47,6 +47,10 @@ int database_check(const struct su_context *ctx)
4747
LOGD("Comparing '%s' to '%s'", cmd, get_command(&ctx->to));
4848
if (strcmp(cmd, get_command(&ctx->to)) == 0)
4949
break;
50+
else if (strcmp(cmd, "any") == 0) {
51+
ctx->to.all = 1;
52+
break;
53+
}
5054
else
5155
strcpy(allow, "prompt");
5256
}

su.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct su_request {
6464
char **argv;
6565
int argc;
6666
int optind;
67+
int appId;
68+
int all;
6769
};
6870

6971
struct su_context {
@@ -80,7 +82,7 @@ typedef enum {
8082
ALLOW = 1,
8183
} allow_t;
8284

83-
extern allow_t database_check(const struct su_context *ctx);
85+
extern allow_t database_check(struct su_context *ctx);
8486
extern void set_identity(unsigned int uid);
8587
extern int send_intent(struct su_context *ctx,
8688
allow_t allow, const char *action);

0 commit comments

Comments
 (0)