Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
54827cac
Commit
54827cac
authored
Jan 24, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve communication with app
parent
e3a4a165
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
49 deletions
+21
-49
activity.c
activity.c
+17
-26
daemon.c
daemon.c
+1
-1
su.c
su.c
+3
-20
su.h
su.h
+0
-2
No files found.
activity.c
View file @
54827cac
...
...
@@ -87,8 +87,11 @@ int send_result(struct su_context *ctx, policy_t policy) {
char
uid
[
256
];
sprintf
(
uid
,
"%d"
,
ctx
->
from
.
uid
);
char
desired_uid
[
256
];
sprintf
(
desired_uid
,
"%d"
,
ctx
->
to
.
uid
);
char
toUid
[
256
];
sprintf
(
toUid
,
"%d"
,
ctx
->
to
.
uid
);
char
pid
[
256
];
sprintf
(
pid
,
"%d"
,
ctx
->
from
.
pid
);
char
user
[
64
];
get_owner_login_user_args
(
ctx
,
user
,
sizeof
(
user
));
...
...
@@ -101,20 +104,14 @@ int send_result(struct su_context *ctx, policy_t policy) {
AM_PATH
,
ACTION_RESULT
,
"--ei"
,
"binary_version"
,
binary_version
,
"--es"
,
"from_name"
,
ctx
->
from
.
name
,
"--es"
,
"desired_name"
,
ctx
->
to
.
name
,
"--ei"
,
"uid"
,
"from.uid"
,
uid
,
"--ei"
,
"desired_uid"
,
desired_uid
,
"to.uid"
,
toUid
,
"--ei"
,
"pid"
,
pid
,
"--es"
,
"command"
,
get_command
(
&
ctx
->
to
),
...
...
@@ -132,20 +129,14 @@ int send_result(struct su_context *ctx, policy_t policy) {
AM_PATH
,
ACTION_RESULT
,
"--ei"
,
"binary_version"
,
binary_version
,
"--es"
,
"from_name"
,
ctx
->
from
.
name
,
"--es"
,
"desired_name"
,
ctx
->
to
.
name
,
"--ei"
,
"uid"
,
"from.uid"
,
uid
,
"--ei"
,
"desired_uid"
,
desired_uid
,
"to.uid"
,
toUid
,
"--ei"
,
"pid"
,
pid
,
"--es"
,
"command"
,
get_command
(
&
ctx
->
to
),
...
...
daemon.c
View file @
54827cac
...
...
@@ -289,7 +289,7 @@ static int daemon_accept(int fd) {
LOGD
(
"remote req pid: %d"
,
daemon_from_pid
);
struct
ucred
credentials
;
in
t
ucred_length
=
sizeof
(
struct
ucred
);
socklen_
t
ucred_length
=
sizeof
(
struct
ucred
);
/* fill in the user data structure */
if
(
getsockopt
(
fd
,
SOL_SOCKET
,
SO_PEERCRED
,
&
credentials
,
&
ucred_length
))
{
LOGE
(
"could obtain credentials from unix domain socket"
);
...
...
su.c
View file @
54827cac
...
...
@@ -198,12 +198,6 @@ static int from_init(struct su_initiator *from) {
strncpy
(
from
->
bin
,
argv0
,
sizeof
(
from
->
bin
));
from
->
bin
[
sizeof
(
from
->
bin
)
-
1
]
=
'\0'
;
struct
passwd
*
pw
;
pw
=
getpwuid
(
from
->
uid
);
if
(
pw
&&
pw
->
pw_name
)
{
strncpy
(
from
->
name
,
pw
->
pw_name
,
sizeof
(
from
->
name
));
}
return
0
;
}
...
...
@@ -417,16 +411,9 @@ do { \
} while (0)
static
int
socket_send_request
(
int
fd
,
const
struct
su_context
*
ctx
)
{
write_token
(
fd
,
"version"
,
PROTO_VERSION
);
write_token
(
fd
,
"binary.version"
,
VERSION_CODE
);
write_token
(
fd
,
"pid"
,
ctx
->
from
.
pid
);
write_string_data
(
fd
,
"from.name"
,
ctx
->
from
.
name
);
write_string_data
(
fd
,
"to.name"
,
ctx
->
to
.
name
);
write_token
(
fd
,
"from.uid"
,
ctx
->
from
.
uid
);
write_token
(
fd
,
"to.uid"
,
ctx
->
to
.
uid
);
write_string_data
(
fd
,
"from.bin"
,
ctx
->
from
.
bin
);
// TODO: Fix issue where not using -c does not result a in a command
write_string_data
(
fd
,
"command"
,
get_command
(
&
ctx
->
to
));
write_string_data
(
fd
,
"version"
,
VERSION
);
write_token
(
fd
,
"versionCode"
,
VERSION_CODE
);
write_token
(
fd
,
"uid"
,
ctx
->
from
.
uid
);
write_token
(
fd
,
"eof"
,
PROTO_VERSION
);
return
0
;
}
...
...
@@ -683,7 +670,6 @@ int su_main_nodaemon(int argc, char **argv) {
.
uid
=
0
,
.
bin
=
""
,
.
args
=
""
,
.
name
=
""
,
},
.
to
=
{
.
uid
=
AID_ROOT
,
...
...
@@ -695,7 +681,6 @@ int su_main_nodaemon(int argc, char **argv) {
.
argv
=
argv
,
.
argc
=
argc
,
.
optind
=
0
,
.
name
=
""
,
},
.
user
=
{
.
android_user_id
=
0
,
...
...
@@ -791,8 +776,6 @@ int su_main_nodaemon(int argc, char **argv) {
}
}
else
{
ctx
.
to
.
uid
=
pw
->
pw_uid
;
if
(
pw
->
pw_name
)
strncpy
(
ctx
.
to
.
name
,
pw
->
pw_name
,
sizeof
(
ctx
.
to
.
name
));
}
optind
++
;
}
...
...
su.h
View file @
54827cac
...
...
@@ -86,14 +86,12 @@ struct su_initiator {
pid_t
pid
;
unsigned
uid
;
unsigned
user
;
char
name
[
64
];
char
bin
[
PATH_MAX
];
char
args
[
4096
];
};
struct
su_request
{
unsigned
uid
;
char
name
[
64
];
int
login
;
int
keepenv
;
char
*
shell
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment