Skip to content

Commit 4eb8017

Browse files
author
git-core
committed
Combine su_initiator and su_request into su_context
1 parent 418ec8b commit 4eb8017

File tree

4 files changed

+103
-102
lines changed

4 files changed

+103
-102
lines changed

activity.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static const int VAL_INTEGER = 1;
4646

4747
static const int START_SUCCESS = 0;
4848

49-
int send_intent(struct su_initiator *from, struct su_request *to, const char *socket_path, int allow, int type)
49+
int send_intent(struct su_context *ctx, const char *socket_path, int allow, int type)
5050
{
5151
char sdk_version_prop[PROPERTY_VALUE_MAX] = "0";
5252
property_get("ro.build.version.sdk", sdk_version_prop, "0");
@@ -95,25 +95,25 @@ int send_intent(struct su_initiator *from, struct su_request *to, const char *so
9595
data.writeInt32(VAL_STRING);
9696
data.writeString16(String16("caller_uid"));
9797
data.writeInt32(VAL_INTEGER);
98-
data.writeInt32(from->uid);
98+
data.writeInt32(ctx->from.uid);
9999

100100
data.writeInt32(VAL_STRING);
101101
data.writeString16(String16("caller_bin"));
102102
data.writeInt32(VAL_STRING);
103-
data.writeString16(String16(from->bin));
103+
data.writeString16(String16(ctx->from.bin));
104104

105105
data.writeInt32(VAL_STRING);
106106
data.writeString16(String16("desired_uid"));
107107
data.writeInt32(VAL_INTEGER);
108-
data.writeInt32(to->uid);
108+
data.writeInt32(ctx->to.uid);
109109

110110
data.writeInt32(VAL_STRING);
111111
data.writeString16(String16("desired_cmd"));
112112
data.writeInt32(VAL_STRING);
113-
if (to->command)
114-
data.writeString16(String16(to->command));
113+
if (ctx->to.command)
114+
data.writeString16(String16(ctx->to.command));
115115
else
116-
data.writeString16(String16(to->shell));
116+
data.writeString16(String16(ctx->to.shell));
117117

118118
data.writeInt32(VAL_STRING);
119119
data.writeString16(String16("socket"));

db.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static sqlite3 *db_init()
4141
return db;
4242
}
4343

44-
static int db_check(sqlite3 *db, struct su_initiator *from, struct su_request *to)
44+
static int db_check(sqlite3 *db, struct su_context *ctx)
4545
{
4646
char sql[4096];
4747
char *zErrmsg;
@@ -52,7 +52,7 @@ static int db_check(sqlite3 *db, struct su_initiator *from, struct su_request *t
5252
sqlite3_snprintf(
5353
sizeof(sql), sql,
5454
"SELECT _id,name,allow FROM apps WHERE uid=%u AND exec_uid=%u AND exec_cmd='%q';",
55-
(unsigned)from->uid, to->uid, (to->command) ? to->command : to->shell
55+
ctx->from.uid, ctx->to.uid, (ctx->to.command) ? ctx->to.command : ctx->to.shell
5656
);
5757

5858
if (strlen(sql) >= sizeof(sql)-1)
@@ -86,7 +86,7 @@ static int db_check(sqlite3 *db, struct su_initiator *from, struct su_request *t
8686
return allow;
8787
}
8888

89-
int database_check(struct su_initiator *from, struct su_request *to)
89+
int database_check(struct su_context *ctx)
9090
{
9191
sqlite3 *db;
9292
int dballow;
@@ -101,7 +101,7 @@ int database_check(struct su_initiator *from, struct su_request *to)
101101
}
102102

103103
LOGE("sudb - Database opened");
104-
dballow = db_check(db, from, to);
104+
dballow = db_check(db, ctx);
105105
// Close the database, we're done with it. If it stays open, it will cause problems
106106
sqlite3_close(db);
107107
LOGE("sudb - Database closed");

0 commit comments

Comments
 (0)