Skip to content

Commit 73e06ac

Browse files
author
git-core
committed
Pass last parameter to send_intent() as pointer to the action name
1 parent 95fe237 commit 73e06ac

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

activity.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static const int VAL_INTEGER = 1;
4444

4545
static const int START_SUCCESS = 0;
4646

47-
int send_intent(struct su_context *ctx, const char *socket_path, int allow, int type)
47+
int send_intent(struct su_context *ctx,
48+
const char *socket_path, int allow, const char *action)
4849
{
4950
sp<IServiceManager> sm = defaultServiceManager();
5051
sp<IBinder> am = sm->checkService(String16("activity"));
@@ -56,11 +57,7 @@ int send_intent(struct su_context *ctx, const char *socket_path, int allow, int
5657
data.writeStrongBinder(NULL); /* caller */
5758

5859
/* intent */
59-
if (type == 0) {
60-
data.writeString16(String16("com.noshufou.android.su.REQUEST")); /* action */
61-
} else {
62-
data.writeString16(String16("com.noshufou.android.su.RESULT")); /* action */
63-
}
60+
data.writeString16(String16(action)); /* action */
6461
data.writeInt32(NULL_TYPE_ID); /* Uri - data */
6562
data.writeString16(NULL, 0); /* type */
6663
data.writeInt32(0); /* flags */

su.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void deny(struct su_context *ctx)
274274
{
275275
char *cmd = get_command(&ctx->to);
276276

277-
send_intent(ctx, "", 0, 1);
277+
send_intent(ctx, "", 0, ACTION_RESULT);
278278
LOGW("request rejected (%u->%u %s)", ctx->from.uid, ctx->to.uid, cmd);
279279
fprintf(stderr, "%s\n", strerror(EACCES));
280280
exit(EXIT_FAILURE);
@@ -286,7 +286,7 @@ static void allow(struct su_context *ctx)
286286
int argc, err;
287287

288288
umask(ctx->umask);
289-
send_intent(ctx, "", 1, 1);
289+
send_intent(ctx, "", 1, ACTION_RESULT);
290290

291291
arg0 = strrchr (ctx->to.shell, '/');
292292
arg0 = (arg0) ? arg0 + 1 : ctx->to.shell;
@@ -487,7 +487,7 @@ int main(int argc, char *argv[])
487487
signal(SIGABRT, cleanup_signal);
488488
atexit(cleanup);
489489

490-
if (send_intent(&ctx, socket_path, -1, 0) < 0) {
490+
if (send_intent(&ctx, socket_path, -1, ACTION_REQUEST) < 0) {
491491
deny(&ctx);
492492
}
493493

su.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#define REQUESTOR_DATABASES_PATH REQUESTOR_DATA_PATH "/databases"
2626
#define REQUESTOR_DATABASE_PATH REQUESTOR_DATABASES_PATH "/permissions.sqlite"
2727

28+
/* intent actions */
29+
#define ACTION_REQUEST REQUESTOR ".REQUEST"
30+
#define ACTION_RESULT REQUESTOR ".RESULT"
31+
2832
#define DEFAULT_SHELL "/system/bin/sh"
2933

3034
#ifdef SU_LEGACY_BUILD
@@ -71,7 +75,8 @@ enum {
7175

7276
extern int database_check(struct su_context *ctx);
7377

74-
extern int send_intent(struct su_context *ctx, const char *socket_path, int allow, int type);
78+
extern int send_intent(struct su_context *ctx,
79+
const char *socket_path, int allow, const char *action);
7580

7681
static inline char *get_command(struct su_request *to)
7782
{

0 commit comments

Comments
 (0)