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
c9286624
Commit
c9286624
authored
Jun 08, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add namespace mode support
parent
1ddd7468
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
db.c
db.c
+3
-0
su.h
su.h
+9
-2
su_daemon.c
su_daemon.c
+19
-0
No files found.
db.c
View file @
c9286624
...
@@ -46,6 +46,8 @@ static int settings_callback(void *v, int argc, char **argv, char **azColName) {
...
@@ -46,6 +46,8 @@ static int settings_callback(void *v, int argc, char **argv, char **azColName) {
target
=
&
ctx
->
info
->
root_access
;
target
=
&
ctx
->
info
->
root_access
;
else
if
(
strcmp
(
argv
[
i
],
MULTIUSER_MODE_ENTRY
)
==
0
)
else
if
(
strcmp
(
argv
[
i
],
MULTIUSER_MODE_ENTRY
)
==
0
)
target
=
&
ctx
->
info
->
multiuser_mode
;
target
=
&
ctx
->
info
->
multiuser_mode
;
else
if
(
strcmp
(
argv
[
i
],
NAMESPACE_MODE_ENTRY
)
==
0
)
target
=
&
ctx
->
info
->
mnt_ns
;
entry
=
argv
[
i
];
entry
=
argv
[
i
];
}
else
if
(
strcmp
(
azColName
[
i
],
"value"
)
==
0
)
{
}
else
if
(
strcmp
(
azColName
[
i
],
"value"
)
==
0
)
{
value
=
atoi
(
argv
[
i
]);
value
=
atoi
(
argv
[
i
]);
...
@@ -62,6 +64,7 @@ void database_check(struct su_context *ctx) {
...
@@ -62,6 +64,7 @@ void database_check(struct su_context *ctx) {
// Set default values
// Set default values
ctx
->
info
->
root_access
=
ROOT_ACCESS_APPS_AND_ADB
;
ctx
->
info
->
root_access
=
ROOT_ACCESS_APPS_AND_ADB
;
ctx
->
info
->
multiuser_mode
=
MULTIUSER_MODE_OWNER_ONLY
;
ctx
->
info
->
multiuser_mode
=
MULTIUSER_MODE_OWNER_ONLY
;
ctx
->
info
->
mnt_ns
=
NAMESPACE_MODE_REQUESTER
;
ctx
->
info
->
policy
=
QUERY
;
ctx
->
info
->
policy
=
QUERY
;
// Check if file is readable
// Check if file is readable
...
...
su.h
View file @
c9286624
...
@@ -11,19 +11,25 @@
...
@@ -11,19 +11,25 @@
#define MAGISKSU_VER_STR xstr(MAGISK_VERSION) ":MAGISKSU (topjohnwu)"
#define MAGISKSU_VER_STR xstr(MAGISK_VERSION) ":MAGISKSU (topjohnwu)"
//
Property check
for root access
//
DB settings
for root access
#define ROOT_ACCESS_ENTRY "root_access"
#define ROOT_ACCESS_ENTRY "root_access"
#define ROOT_ACCESS_DISABLED 0
#define ROOT_ACCESS_DISABLED 0
#define ROOT_ACCESS_APPS_ONLY 1
#define ROOT_ACCESS_APPS_ONLY 1
#define ROOT_ACCESS_ADB_ONLY 2
#define ROOT_ACCESS_ADB_ONLY 2
#define ROOT_ACCESS_APPS_AND_ADB 3
#define ROOT_ACCESS_APPS_AND_ADB 3
//
Property
for multiuser
//
DB settings
for multiuser
#define MULTIUSER_MODE_ENTRY "multiuser_mode"
#define MULTIUSER_MODE_ENTRY "multiuser_mode"
#define MULTIUSER_MODE_OWNER_ONLY 0
#define MULTIUSER_MODE_OWNER_ONLY 0
#define MULTIUSER_MODE_OWNER_MANAGED 1
#define MULTIUSER_MODE_OWNER_MANAGED 1
#define MULTIUSER_MODE_USER 2
#define MULTIUSER_MODE_USER 2
// DB settings for namespace seperation
#define NAMESPACE_MODE_ENTRY "mnt_ns"
#define NAMESPACE_MODE_GLOBAL 0
#define NAMESPACE_MODE_REQUESTER 1
#define NAMESPACE_MODE_ISOLATE 2
// DO NOT CHANGE LINE BELOW, java package name will always be the same
// DO NOT CHANGE LINE BELOW, java package name will always be the same
#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
#define JAVA_PACKAGE_NAME "com.topjohnwu.magisk"
...
@@ -59,6 +65,7 @@ struct su_info {
...
@@ -59,6 +65,7 @@ struct su_info {
int
clock
;
int
clock
;
int
multiuser_mode
;
int
multiuser_mode
;
int
root_access
;
int
root_access
;
int
mnt_ns
;
struct
list_head
pos
;
struct
list_head
pos
;
};
};
...
...
su_daemon.c
View file @
c9286624
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <fcntl.h>
#include <fcntl.h>
#include <string.h>
#include <string.h>
#include <signal.h>
#include <signal.h>
#include <sched.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
...
@@ -260,6 +261,24 @@ void su_daemon_receiver(int client) {
...
@@ -260,6 +261,24 @@ void su_daemon_receiver(int client) {
// Become session leader
// Become session leader
xsetsid
();
xsetsid
();
// Handle namespaces
switch
(
info
->
mnt_ns
)
{
case
NAMESPACE_MODE_GLOBAL
:
LOGD
(
"su: use global namespace
\n
"
);
break
;
case
NAMESPACE_MODE_REQUESTER
:
LOGD
(
"su: use namespace of pid=[%d]
\n
"
,
su_ctx
->
pid
);
if
(
switch_mnt_ns
(
su_ctx
->
pid
))
{
LOGD
(
"su: setns failed, fallback to isolated
\n
"
);
unshare
(
CLONE_NEWNS
);
}
break
;
case
NAMESPACE_MODE_ISOLATE
:
LOGD
(
"su: use new isolated namespace
\n
"
);
unshare
(
CLONE_NEWNS
);
break
;
}
// Let's read some info from the socket
// Let's read some info from the socket
int
argc
=
read_int
(
client
);
int
argc
=
read_int
(
client
);
if
(
argc
<
0
||
argc
>
512
)
{
if
(
argc
<
0
||
argc
>
512
)
{
...
...
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