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
0b4baad7
Commit
0b4baad7
authored
Jun 08, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mount namespace mode
parent
201e32d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
10 deletions
+21
-10
MagiskManager
MagiskManager
+1
-1
hide_daemon.c
jni/magiskhide/hide_daemon.c
+2
-8
su
jni/su
+1
-1
misc.c
jni/utils/misc.c
+16
-0
utils.h
jni/utils/utils.h
+1
-0
No files found.
MagiskManager
@
d3ff482c
Subproject commit
bc576a9659651703dc4cd4eaebaa9293381a2ac8
Subproject commit
d3ff482c9b46f58626fdcb6289ffa0cefbf2afcc
jni/magiskhide/hide_daemon.c
View file @
0b4baad7
...
@@ -56,7 +56,6 @@ int hide_daemon() {
...
@@ -56,7 +56,6 @@ int hide_daemon() {
// When an error occurs, report its failure to main process
// When an error occurs, report its failure to main process
err_handler
=
hide_daemon_err
;
err_handler
=
hide_daemon_err
;
int
fd
;
char
buffer
[
4096
],
cache_block
[
256
],
*
line
;
char
buffer
[
4096
],
cache_block
[
256
],
*
line
;
struct
vector
mount_list
;
struct
vector
mount_list
;
...
@@ -73,13 +72,8 @@ int hide_daemon() {
...
@@ -73,13 +72,8 @@ int hide_daemon() {
manage_selinux
();
manage_selinux
();
relink_sbin
();
relink_sbin
();
snprintf
(
buffer
,
sizeof
(
buffer
),
"/proc/%d/ns/mnt"
,
pid
);
if
(
switch_mnt_ns
(
pid
))
if
(
access
(
buffer
,
F_OK
)
==
-
1
)
continue
;
// Maybe process died..
continue
;
fd
=
xopen
(
buffer
,
O_RDONLY
);
// Switch to its namespace
xsetns
(
fd
,
0
);
close
(
fd
);
snprintf
(
buffer
,
sizeof
(
buffer
),
"/proc/%d/mounts"
,
pid
);
snprintf
(
buffer
,
sizeof
(
buffer
),
"/proc/%d/mounts"
,
pid
);
vec_init
(
&
mount_list
);
vec_init
(
&
mount_list
);
...
...
su
@
1bbf96a0
Subproject commit
38cc9dfec88bca246725d79157657e43e9363425
Subproject commit
1bbf96a0a7a942798df58883a376b8024d0fae7f
jni/utils/misc.c
View file @
0b4baad7
/* misc.c - Store all functions that are unable to be catagorized clearly
/* misc.c - Store all functions that are unable to be catagorized clearly
*/
*/
#define _GNU_SOURCE
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -10,6 +11,7 @@
...
@@ -10,6 +11,7 @@
#include <pwd.h>
#include <pwd.h>
#include <signal.h>
#include <signal.h>
#include <errno.h>
#include <errno.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/mount.h>
...
@@ -457,3 +459,17 @@ int resize_img(const char *img, int size) {
...
@@ -457,3 +459,17 @@ int resize_img(const char *img, int size) {
snprintf
(
buffer
,
PATH_MAX
,
"e2fsck -yf %s; resize2fs %s %dM;"
,
img
,
img
,
size
);
snprintf
(
buffer
,
PATH_MAX
,
"e2fsck -yf %s; resize2fs %s %dM;"
,
img
,
img
,
size
);
return
system
(
buffer
);
return
system
(
buffer
);
}
}
int
switch_mnt_ns
(
int
pid
)
{
char
mnt
[
32
];
snprintf
(
mnt
,
sizeof
(
mnt
),
"/proc/%d/ns/mnt"
,
pid
);
if
(
access
(
mnt
,
R_OK
)
==
-
1
)
return
1
;
// Maybe process died..
int
fd
,
ret
;
fd
=
xopen
(
mnt
,
O_RDONLY
);
if
(
fd
<
0
)
return
1
;
// Switch to its namespace
ret
=
setns
(
fd
,
0
);
close
(
fd
);
return
ret
;
}
jni/utils/utils.h
View file @
0b4baad7
...
@@ -94,5 +94,6 @@ void get_client_cred(int fd, struct ucred *cred);
...
@@ -94,5 +94,6 @@ void get_client_cred(int fd, struct ucred *cred);
int
create_img
(
const
char
*
img
,
int
size
);
int
create_img
(
const
char
*
img
,
int
size
);
int
get_img_size
(
const
char
*
img
,
int
*
used
,
int
*
total
);
int
get_img_size
(
const
char
*
img
,
int
*
used
,
int
*
total
);
int
resize_img
(
const
char
*
img
,
int
size
);
int
resize_img
(
const
char
*
img
,
int
size
);
int
switch_mnt_ns
(
int
pid
);
#endif
#endif
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