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
2e51fe20
Commit
2e51fe20
authored
May 30, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move things to the correct location
parent
c29636c4
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
20 deletions
+16
-20
misc.hpp
native/jni/base/misc.hpp
+0
-6
daemon.cpp
native/jni/core/daemon.cpp
+3
-3
daemon.hpp
native/jni/include/daemon.hpp
+5
-0
connect.cpp
native/jni/su/connect.cpp
+0
-1
su.cpp
native/jni/su/su.cpp
+0
-1
su.hpp
native/jni/su/su.hpp
+2
-1
su_daemon.cpp
native/jni/su/su_daemon.cpp
+6
-8
No files found.
native/jni/base/misc.hpp
View file @
2e51fe20
...
...
@@ -6,16 +6,10 @@
#include <string_view>
#include <bitset>
#define UID_ROOT 0
#define UID_SHELL 2000
#define DISALLOW_COPY_AND_MOVE(clazz) \
clazz(const clazz &) = delete; \
clazz(clazz &&) = delete;
#define to_app_id(uid) (uid % 100000)
#define to_user_id(uid) (uid / 100000)
class
mutex_guard
{
DISALLOW_COPY_AND_MOVE
(
mutex_guard
)
public
:
...
...
native/jni/core/daemon.cpp
View file @
2e51fe20
...
...
@@ -220,7 +220,7 @@ static void handle_request(pollfd *pfd) {
// Client died
goto
done
;
}
is_root
=
cred
.
uid
==
U
ID_ROOT
;
is_root
=
cred
.
uid
==
A
ID_ROOT
;
is_zygote
=
cred
.
context
==
"u:r:zygote:s0"
;
if
(
!
is_root
&&
!
is_zygote
&&
!
is_client
(
cred
.
pid
))
{
...
...
@@ -251,7 +251,7 @@ static void handle_request(pollfd *pfd) {
}
break
;
case
MainRequest
:
:
REMOVE_MODULES
:
if
(
!
is_root
&&
cred
.
uid
!=
U
ID_SHELL
)
{
if
(
!
is_root
&&
cred
.
uid
!=
A
ID_SHELL
)
{
write_int
(
client
,
MainResponse
::
ACCESS_DENIED
);
goto
done
;
}
...
...
@@ -414,7 +414,7 @@ int connect_daemon(int req, bool create) {
socklen_t
len
=
setup_sockaddr
(
&
sun
,
MAIN_SOCKET
);
int
fd
=
xsocket
(
AF_UNIX
,
SOCK_STREAM
|
SOCK_CLOEXEC
,
0
);
if
(
connect
(
fd
,
(
sockaddr
*
)
&
sun
,
len
))
{
if
(
!
create
||
getuid
()
!=
U
ID_ROOT
)
{
if
(
!
create
||
getuid
()
!=
A
ID_ROOT
)
{
LOGE
(
"No daemon is currently running!
\n
"
);
close
(
fd
);
return
-
1
;
...
...
native/jni/include/daemon.hpp
View file @
2e51fe20
...
...
@@ -9,10 +9,15 @@
#include <socket.hpp>
#define AID_ROOT 0
#define AID_SHELL 2000
#define AID_APP_START 10000
#define AID_APP_END 19999
#define AID_USER_OFFSET 100000
#define to_app_id(uid) (uid % AID_USER_OFFSET)
#define to_user_id(uid) (uid / AID_USER_OFFSET)
// Daemon command codes
namespace
MainRequest
{
enum
:
int
{
...
...
native/jni/su/connect.cpp
View file @
2e51fe20
...
...
@@ -5,7 +5,6 @@
#include <selinux.hpp>
#include "su.hpp"
#include "daemon.hpp"
extern
int
SDK_INT
;
...
...
native/jni/su/su.cpp
View file @
2e51fe20
...
...
@@ -14,7 +14,6 @@
#include <sys/stat.h>
#include <magisk.hpp>
#include <daemon.hpp>
#include <base.hpp>
#include <flags.h>
...
...
native/jni/su/su.hpp
View file @
2e51fe20
...
...
@@ -5,6 +5,7 @@
#include <memory>
#include <db.hpp>
#include <daemon.hpp>
#define DEFAULT_SHELL "/system/bin/sh"
...
...
@@ -41,7 +42,7 @@ private:
};
struct
su_req_base
{
int
uid
=
U
ID_ROOT
;
int
uid
=
A
ID_ROOT
;
bool
login
=
false
;
bool
keepenv
=
false
;
bool
mount_master
=
false
;
...
...
native/jni/su/su_daemon.cpp
View file @
2e51fe20
...
...
@@ -5,11 +5,9 @@
#include <sys/wait.h>
#include <sys/mount.h>
#include <daemon.hpp>
#include <magisk.hpp>
#include <base.hpp>
#include <selinux.hpp>
#include <db.hpp>
#include "su.hpp"
#include "pts.hpp"
...
...
@@ -88,7 +86,7 @@ void su_info::check_db() {
}
bool
uid_granted_root
(
int
uid
)
{
if
(
uid
==
U
ID_ROOT
)
if
(
uid
==
A
ID_ROOT
)
return
true
;
db_settings
cfg
;
...
...
@@ -99,11 +97,11 @@ bool uid_granted_root(int uid) {
case
ROOT_ACCESS_DISABLED
:
return
false
;
case
ROOT_ACCESS_APPS_ONLY
:
if
(
uid
==
U
ID_SHELL
)
if
(
uid
==
A
ID_SHELL
)
return
false
;
break
;
case
ROOT_ACCESS_ADB_ONLY
:
if
(
uid
!=
U
ID_SHELL
)
if
(
uid
!=
A
ID_SHELL
)
return
false
;
break
;
case
ROOT_ACCESS_APPS_AND_ADB
:
...
...
@@ -186,7 +184,7 @@ static shared_ptr<su_info> get_su_info(unsigned uid) {
info
->
check_db
();
// If it's root or the manager, allow it silently
if
(
info
->
uid
==
U
ID_ROOT
||
to_app_id
(
info
->
uid
)
==
to_app_id
(
info
->
mgr_uid
))
{
if
(
info
->
uid
==
A
ID_ROOT
||
to_app_id
(
info
->
uid
)
==
to_app_id
(
info
->
mgr_uid
))
{
info
->
access
=
SILENT_SU_ACCESS
;
return
info
;
}
...
...
@@ -198,13 +196,13 @@ static shared_ptr<su_info> get_su_info(unsigned uid) {
info
->
access
=
NO_SU_ACCESS
;
break
;
case
ROOT_ACCESS_ADB_ONLY
:
if
(
info
->
uid
!=
U
ID_SHELL
)
{
if
(
info
->
uid
!=
A
ID_SHELL
)
{
LOGW
(
"Root access limited to ADB only!
\n
"
);
info
->
access
=
NO_SU_ACCESS
;
}
break
;
case
ROOT_ACCESS_APPS_ONLY
:
if
(
info
->
uid
==
U
ID_SHELL
)
{
if
(
info
->
uid
==
A
ID_SHELL
)
{
LOGW
(
"Root access is disabled for ADB!
\n
"
);
info
->
access
=
NO_SU_ACCESS
;
}
...
...
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