Skip to content

Commit 5bbd487

Browse files
author
git-core
committed
Set effective uid/gid back, unlink fails otherwise
1 parent c6ef3cc commit 5bbd487

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

activity.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
int send_intent(const struct su_context *ctx,
2424
const char *socket_path, int allow, const char *action)
2525
{
26-
char command[PATH_MAX];
26+
char command[PATH_MAX];
27+
pid_t euid;
28+
gid_t egid;
29+
int rc;
2730

2831
sprintf(command, "/system/bin/am broadcast -a '%s' --es socket '%s' --ei caller_uid '%d' --ei allow '%d' --ei version_code '%d' > /dev/null",
2932
action, socket_path, ctx->from.uid, allow, VERSION_CODE);
@@ -71,7 +74,13 @@ int send_intent(const struct su_context *ctx,
7174

7275
// sane value so "am" works
7376
setenv("LD_LIBRARY_PATH", "/vendor/lib:/system/lib", 1);
77+
euid = geteuid();
78+
egid = getegid();
7479
setegid(getgid());
7580
seteuid(getuid());
76-
return system(command);
81+
rc = system(command);
82+
seteuid(0);
83+
setegid(egid);
84+
seteuid(euid);
85+
return rc;
7786
}

0 commit comments

Comments
 (0)