Enforce dyn APK signature in stub app

This commit is contained in:
topjohnwu
2022-05-24 05:21:36 -07:00
parent afa364cfc3
commit 2a252d13b8
3 changed files with 48 additions and 5 deletions

View File

@@ -152,8 +152,8 @@ void exec_module_scripts(const char *stage, const vector<string_view> &modules)
constexpr char install_script[] = R"EOF(
APK=%s
log -t Magisk "apk_install: $APK"
log -t Magisk "apk_install: $(pm install -r $APK 2>&1)"
log -t Magisk "pm_install: $APK"
log -t Magisk "pm_install: $(pm install -r $APK 2>&1)"
rm -f $APK
)EOF";
@@ -169,8 +169,8 @@ void install_apk(const char *apk) {
constexpr char uninstall_script[] = R"EOF(
PKG=%s
log -t Magisk "apk_uninstall: $PKG"
log -t Magisk "apk_uninstall: $(pm uninstall $PKG 2>&1)"
log -t Magisk "pm_uninstall: $PKG"
log -t Magisk "pm_uninstall: $(pm uninstall $PKG 2>&1)"
)EOF";
void uninstall_pkg(const char *pkg) {
@@ -182,6 +182,22 @@ void uninstall_pkg(const char *pkg) {
exec_command_sync(exec, "/system/bin/sh", "-c", cmds);
}
constexpr char clear_script[] = R"EOF(
PKG=%s
USER=%d
log -t Magisk "pm_clear: $PKG (user=$USER)"
log -t Magisk "pm_clear: $(pm clear --user $USER $PKG 2>&1)"
)EOF";
void clear_pkg(const char *pkg, int user_id) {
exec_t exec {
.fork = fork_no_orphan
};
char cmds[sizeof(clear_script) + 288];
snprintf(cmds, sizeof(cmds), clear_script, pkg, user_id);
exec_command_sync(exec, "/system/bin/sh", "-c", cmds);
}
[[noreturn]] __printflike(2, 3)
static void abort(FILE *fp, const char *fmt, ...) {
va_list valist;