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
f1b6c9f4
Commit
f1b6c9f4
authored
Sep 20, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refresh uid_map on package.xml change
parent
0ab31ab0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
4 deletions
+33
-4
core.hpp
native/jni/core/core.hpp
+0
-4
thread.cpp
native/jni/core/thread.cpp
+2
-0
daemon.hpp
native/jni/include/daemon.hpp
+5
-0
utils.cpp
native/jni/zygisk/deny/utils.cpp
+26
-0
No files found.
native/jni/core/core.hpp
View file @
f1b6c9f4
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <functional>
extern
bool
RECOVERY_MODE
;
extern
bool
RECOVERY_MODE
;
extern
int
DAEMON_STATE
;
extern
int
DAEMON_STATE
;
...
@@ -22,9 +21,6 @@ void start_log_daemon();
...
@@ -22,9 +21,6 @@ void start_log_daemon();
void
setup_logfile
(
bool
reset
);
void
setup_logfile
(
bool
reset
);
void
magisk_logging
();
void
magisk_logging
();
// Thread pool
void
exec_task
(
std
::
function
<
void
()
>
&&
task
);
// Module stuffs
// Module stuffs
void
handle_modules
();
void
handle_modules
();
void
magic_mount
();
void
magic_mount
();
...
...
native/jni/core/thread.cpp
View file @
f1b6c9f4
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
#include <utils.hpp>
#include <utils.hpp>
#include <daemon.hpp>
using
namespace
std
;
using
namespace
std
;
#define THREAD_IDLE_MAX_SEC 60
#define THREAD_IDLE_MAX_SEC 60
...
...
native/jni/include/daemon.hpp
View file @
f1b6c9f4
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <string>
#include <string>
#include <limits>
#include <limits>
#include <atomic>
#include <atomic>
#include <functional>
#include <socket.hpp>
#include <socket.hpp>
...
@@ -49,6 +50,10 @@ using poll_callback = void(*)(pollfd*);
...
@@ -49,6 +50,10 @@ using poll_callback = void(*)(pollfd*);
void
register_poll
(
const
pollfd
*
pfd
,
poll_callback
callback
);
void
register_poll
(
const
pollfd
*
pfd
,
poll_callback
callback
);
void
unregister_poll
(
int
fd
,
bool
auto_close
);
void
unregister_poll
(
int
fd
,
bool
auto_close
);
// Thread pool
void
exec_task
(
std
::
function
<
void
()
>
&&
task
);
// Logging
extern
std
::
atomic
<
int
>
logd_fd
;
extern
std
::
atomic
<
int
>
logd_fd
;
int
magisk_log
(
int
prio
,
const
char
*
fmt
,
va_list
ap
);
int
magisk_log
(
int
prio
,
const
char
*
fmt
,
va_list
ap
);
void
android_logging
();
void
android_logging
();
...
...
native/jni/zygisk/deny/utils.cpp
View file @
f1b6c9f4
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/inotify.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <fcntl.h>
#include <dirent.h>
#include <dirent.h>
...
@@ -15,6 +16,7 @@ using namespace std;
...
@@ -15,6 +16,7 @@ using namespace std;
static
set
<
pair
<
string
,
string
>>
*
deny_set
;
/* set of <pkg, process> pair */
static
set
<
pair
<
string
,
string
>>
*
deny_set
;
/* set of <pkg, process> pair */
static
map
<
int
,
vector
<
string_view
>>
*
uid_proc_map
;
/* uid -> list of process */
static
map
<
int
,
vector
<
string_view
>>
*
uid_proc_map
;
/* uid -> list of process */
static
int
inotify_fd
=
-
1
;
// Locks the variables above
// Locks the variables above
static
pthread_mutex_t
data_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
data_lock
=
PTHREAD_MUTEX_INITIALIZER
;
...
@@ -254,6 +256,20 @@ static void update_deny_config() {
...
@@ -254,6 +256,20 @@ static void update_deny_config() {
db_err
(
err
);
db_err
(
err
);
}
}
static
void
inotify_handler
(
pollfd
*
pfd
)
{
union
{
inotify_event
event
;
char
buf
[
512
];
}
u
{};
read
(
pfd
->
fd
,
u
.
buf
,
sizeof
(
u
.
buf
));
if
(
u
.
event
.
name
==
"packages.xml"
sv
)
{
exec_task
([]
{
mutex_guard
lock
(
data_lock
);
rebuild_uid_map
();
});
}
}
int
enable_deny
()
{
int
enable_deny
()
{
if
(
denylist_enabled
)
{
if
(
denylist_enabled
)
{
return
DAEMON_SUCCESS
;
return
DAEMON_SUCCESS
;
...
@@ -281,6 +297,14 @@ int enable_deny() {
...
@@ -281,6 +297,14 @@ int enable_deny() {
default_new
(
uid_proc_map
);
default_new
(
uid_proc_map
);
rebuild_uid_map
();
rebuild_uid_map
();
inotify_fd
=
xinotify_init1
(
IN_CLOEXEC
);
if
(
inotify_fd
>=
0
)
{
// Monitor packages.xml
inotify_add_watch
(
inotify_fd
,
"/data/system"
,
IN_CLOSE_WRITE
);
pollfd
inotify_pfd
=
{
inotify_fd
,
POLLIN
,
0
};
register_poll
(
&
inotify_pfd
,
inotify_handler
);
}
}
}
update_deny_config
();
update_deny_config
();
...
@@ -297,6 +321,8 @@ int disable_deny() {
...
@@ -297,6 +321,8 @@ int disable_deny() {
delete
deny_set
;
delete
deny_set
;
uid_proc_map
=
nullptr
;
uid_proc_map
=
nullptr
;
deny_set
=
nullptr
;
deny_set
=
nullptr
;
unregister_poll
(
inotify_fd
,
true
);
inotify_fd
=
-
1
;
}
}
update_deny_config
();
update_deny_config
();
return
DAEMON_SUCCESS
;
return
DAEMON_SUCCESS
;
...
...
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