mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 08:47:38 +00:00
Later check persistent_properties
`daemon_entry` calls `getprop` which initializes sysprop impl and checks whether we need to load persistent property file. On FDE devices, magiskd starts before /data is actually decrypted, and the check always fails. Thus `persist_getprop("persist.sys.safemode")` will always fail.
This commit is contained in:
parent
6077c989a7
commit
8423dc8d63
@ -75,8 +75,6 @@ PB_BIND(PersistentProperties_PersistentPropertyRecord, PersistentProperties_Pers
|
|||||||
* End of auto generated code
|
* End of auto generated code
|
||||||
* ***************************/
|
* ***************************/
|
||||||
|
|
||||||
bool use_pb = false;
|
|
||||||
|
|
||||||
static bool name_decode(pb_istream_t *stream, const pb_field_t *field, void **arg) {
|
static bool name_decode(pb_istream_t *stream, const pb_field_t *field, void **arg) {
|
||||||
string &name = *static_cast<string *>(*arg);
|
string &name = *static_cast<string *>(*arg);
|
||||||
name.resize(stream->bytes_left);
|
name.resize(stream->bytes_left);
|
||||||
@ -154,8 +152,18 @@ static bool file_getprop(const char *name, char *value) {
|
|||||||
return value[0] != '\0';
|
return value[0] != '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool check_pb() {
|
||||||
|
static bool checked = false;
|
||||||
|
static bool use_pb = false;
|
||||||
|
if (!checked) {
|
||||||
|
checked = true;
|
||||||
|
use_pb = access(PERSISTENT_PROPERTY_DIR "/persistent_properties", R_OK) == 0;
|
||||||
|
}
|
||||||
|
return use_pb;
|
||||||
|
}
|
||||||
|
|
||||||
void persist_getprops(prop_cb *prop_cb) {
|
void persist_getprops(prop_cb *prop_cb) {
|
||||||
if (use_pb) {
|
if (check_pb()) {
|
||||||
pb_getprop(prop_cb);
|
pb_getprop(prop_cb);
|
||||||
} else {
|
} else {
|
||||||
auto dir = open_dir(PERSISTENT_PROPERTY_DIR);
|
auto dir = open_dir(PERSISTENT_PROPERTY_DIR);
|
||||||
@ -180,7 +188,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
string persist_getprop(const char *name) {
|
string persist_getprop(const char *name) {
|
||||||
if (use_pb) {
|
if (check_pb()) {
|
||||||
auto prop = match_prop_name(name);
|
auto prop = match_prop_name(name);
|
||||||
pb_getprop(&prop);
|
pb_getprop(&prop);
|
||||||
if (prop.value[0]) {
|
if (prop.value[0]) {
|
||||||
@ -199,7 +207,7 @@ string persist_getprop(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool persist_deleteprop(const char *name) {
|
bool persist_deleteprop(const char *name) {
|
||||||
if (use_pb) {
|
if (check_pb()) {
|
||||||
prop_list list;
|
prop_list list;
|
||||||
prop_collector collector(list);
|
prop_collector collector(list);
|
||||||
persist_getprops(&collector);
|
persist_getprops(&collector);
|
||||||
|
@ -16,8 +16,6 @@ struct prop_cb {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool use_pb;
|
|
||||||
|
|
||||||
using prop_list = std::map<std::string, std::string>;
|
using prop_list = std::map<std::string, std::string>;
|
||||||
|
|
||||||
struct prop_collector : prop_cb {
|
struct prop_collector : prop_cb {
|
||||||
|
@ -238,7 +238,6 @@ struct resetprop : public sysprop {
|
|||||||
static sysprop_stub *get_impl() {
|
static sysprop_stub *get_impl() {
|
||||||
static sysprop_stub *impl = nullptr;
|
static sysprop_stub *impl = nullptr;
|
||||||
if (impl == nullptr) {
|
if (impl == nullptr) {
|
||||||
use_pb = access(PERSISTENT_PROPERTY_DIR "/persistent_properties", R_OK) == 0;
|
|
||||||
#ifdef APPLET_STUB_MAIN
|
#ifdef APPLET_STUB_MAIN
|
||||||
if (__system_properties_init()) {
|
if (__system_properties_init()) {
|
||||||
LOGE("resetprop: __system_properties_init error\n");
|
LOGE("resetprop: __system_properties_init error\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user