Skip to content

Commit 15a620d

Browse files
committed
Change the way how to switch whitelist mode
1 parent 5abaa9f commit 15a620d

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ do
2828
done
2929

3030
pushd magisk
31-
for FILE in module.prop service.sh customize.sh verify.sh
31+
for FILE in module.prop service.sh customize.sh verify.sh sepolicy.rule
3232
do
3333
sumfile $FILE
3434
done

magisk/customize.sh

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ fi
5151

5252
extract "$ZIPFILE" 'module.prop' "$MODPATH"
5353
extract "$ZIPFILE" 'service.sh' "$MODPATH"
54+
extract "$ZIPFILE" 'sepolicy.rule' "$MODPATH"
5455

5556
ui_print "- Extracting zygisk libraries"
5657
if [ "$ARCH" = "arm" ] || [ "$ARCH" = "arm64" ] ; then

magisk/sepolicy.rule

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
allow zygote adb_data_file dir { search }
2+
allow zygote unlabeled file { getattr }

module/jni/module.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#include <cstdlib>
22
#include <string>
33
#include <android/log.h>
4-
#include <sys/system_properties.h>
4+
#include <sys/types.h>
5+
#include <sys/stat.h>
6+
#include <unistd.h>
57

68
#include "zygisk.hpp"
79
#include "module.h"
810

911
namespace denylist {
1012

13+
#define WHITELIST_FILE "/data/adb/modules/denylist_unmount/whitelist"
14+
1115
class DenylistUnmount : public zygisk::ModuleBase {
1216
public:
1317
void onLoad(zygisk::Api *api, JNIEnv *env) override {
@@ -38,12 +42,17 @@ class DenylistUnmount : public zygisk::ModuleBase {
3842

3943

4044
void preSpecialize(std::string process) {
41-
char whitelist[255];
42-
__system_property_get("persist.unmount.white",whitelist);
43-
44-
if (strcmp(whitelist,"true") == 0 && (api->getFlags() & zygisk::PROCESS_GRANTED_ROOT) == 0){
45-
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
46-
} else if ((api->getFlags() & zygisk::PROCESS_ON_DENYLIST) != 0) {
45+
struct stat whitelist;
46+
bool whitelist_mode = false;
47+
uint32_t flags = api->getFlags();
48+
49+
if (stat(WHITELIST_FILE, &whitelist) == 0) {
50+
whitelist_mode = true;
51+
LOGD("Whitelist mode");
52+
}
53+
54+
if ((flags & zygisk::PROCESS_ON_DENYLIST) != 0 ||
55+
(whitelist_mode && (flags & zygisk::PROCESS_GRANTED_ROOT) == 0)) {
4756
api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
4857
}
4958
api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);

0 commit comments

Comments
 (0)