mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-18 23:48:29 +00:00
Reduce files relying on flags.h
This commit is contained in:
parent
db277c3e55
commit
db1f5b0397
@ -1,5 +1,4 @@
|
|||||||
#include <base.hpp>
|
#include <base.hpp>
|
||||||
#include <flags.h>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ struct EOCD {
|
|||||||
* This method extracts the first certificate of the first signer
|
* This method extracts the first certificate of the first signer
|
||||||
* within the APK v2 signature block.
|
* within the APK v2 signature block.
|
||||||
*/
|
*/
|
||||||
string read_certificate(int fd, bool check_version) {
|
string read_certificate(int fd, int version) {
|
||||||
uint32_t size4;
|
uint32_t size4;
|
||||||
uint64_t size8;
|
uint64_t size8;
|
||||||
|
|
||||||
@ -131,13 +130,13 @@ string read_certificate(int fd, bool check_version) {
|
|||||||
read(fd, ¢ral_dir_off, sizeof(central_dir_off));
|
read(fd, ¢ral_dir_off, sizeof(central_dir_off));
|
||||||
|
|
||||||
// Read comment
|
// Read comment
|
||||||
if (check_version) {
|
if (version >= 0) {
|
||||||
uint16_t comment_sz = 0;
|
uint16_t comment_sz = 0;
|
||||||
read(fd, &comment_sz, sizeof(comment_sz));
|
read(fd, &comment_sz, sizeof(comment_sz));
|
||||||
string comment;
|
string comment;
|
||||||
comment.resize(comment_sz);
|
comment.resize(comment_sz);
|
||||||
read(fd, comment.data(), comment_sz);
|
read(fd, comment.data(), comment_sz);
|
||||||
if (MAGISK_VER_CODE > parse_int(comment)) {
|
if (version > parse_int(comment)) {
|
||||||
// Older version of magisk app is not supported
|
// Older version of magisk app is not supported
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ void reboot();
|
|||||||
void start_log_daemon();
|
void start_log_daemon();
|
||||||
void setup_logfile(bool reset);
|
void setup_logfile(bool reset);
|
||||||
void magisk_logging();
|
void magisk_logging();
|
||||||
std::string read_certificate(int fd, bool check_version = false);
|
std::string read_certificate(int fd, int version = -1);
|
||||||
|
|
||||||
// Module stuffs
|
// Module stuffs
|
||||||
void handle_modules();
|
void handle_modules();
|
||||||
|
@ -105,7 +105,7 @@ int get_manager(int user_id, string *pkg, bool install) {
|
|||||||
int dyn = open(app_path, O_RDONLY | O_CLOEXEC);
|
int dyn = open(app_path, O_RDONLY | O_CLOEXEC);
|
||||||
if (dyn < 0)
|
if (dyn < 0)
|
||||||
return false;
|
return false;
|
||||||
bool mismatch = default_cert && read_certificate(dyn, true) != *default_cert;
|
bool mismatch = default_cert && read_certificate(dyn, MAGISK_VER_CODE) != *default_cert;
|
||||||
close(dyn);
|
close(dyn);
|
||||||
if (mismatch) {
|
if (mismatch) {
|
||||||
LOGE("pkg: dyn APK signature mismatch: %s\n", app_path);
|
LOGE("pkg: dyn APK signature mismatch: %s\n", app_path);
|
||||||
@ -226,7 +226,7 @@ int get_manager(int user_id, string *pkg, bool install) {
|
|||||||
#if ENFORCE_SIGNATURE
|
#if ENFORCE_SIGNATURE
|
||||||
string apk = find_apk_path(JAVA_PACKAGE_NAME);
|
string apk = find_apk_path(JAVA_PACKAGE_NAME);
|
||||||
int fd = xopen(apk.data(), O_RDONLY | O_CLOEXEC);
|
int fd = xopen(apk.data(), O_RDONLY | O_CLOEXEC);
|
||||||
string cert = read_certificate(fd, true);
|
string cert = read_certificate(fd, MAGISK_VER_CODE);
|
||||||
close(fd);
|
close(fd);
|
||||||
if (default_cert && cert != *default_cert) {
|
if (default_cert && cert != *default_cert) {
|
||||||
// Found APK with invalid signature, force replace with stub
|
// Found APK with invalid signature, force replace with stub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user