Preparation for dynamic tmpfs path

This commit is contained in:
topjohnwu
2020-04-12 05:34:56 -07:00
parent d739dcac2b
commit e0a281583d
13 changed files with 289 additions and 258 deletions

View File

@@ -81,20 +81,17 @@ void restorecon() {
}
void restore_rootcon() {
setfilecon("/sbin", ROOT_CON);
setfilecon(MAGISKTMP, ROOT_CON);
setfilecon(MIRRDIR, ROOT_CON);
setfilecon(BLOCKDIR, ROOT_CON);
setfilecon(MAGISKTMP.data(), ROOT_CON);
auto dir = xopen_dir("/sbin");
auto dir = xopen_dir(MAGISKTMP.data());
int dfd = dirfd(dir.get());
for (dirent *entry; (entry = xreaddir(dir.get()));) {
if (entry->d_name == "."sv || entry->d_name == ".."sv)
continue;
setfilecon_at(dfd, entry->d_name, ROOT_CON);
if (entry->d_name == "magisk"sv || entry->d_name == "magiskinit"sv)
setfilecon_at(dfd, entry->d_name, MAGISK_CON);
else
setfilecon_at(dfd, entry->d_name, ROOT_CON);
}
setfilecon("/sbin/magisk", MAGISK_CON);
setfilecon("/sbin/magiskinit", MAGISK_CON);
}