Fix module prefs (#1813)
This commit is contained in:
parent
be722b2e2e
commit
be1bbf7b9b
|
|
@ -242,10 +242,10 @@ public class ConfigManager {
|
|||
miscPath = string;
|
||||
}
|
||||
try {
|
||||
Path p = Paths.get(miscPath);
|
||||
Path prefs = Paths.get(miscPath + "/prefs");
|
||||
var perms = PosixFilePermissions.fromString("rwx--x--x");
|
||||
Files.createDirectories(p, PosixFilePermissions.asFileAttribute(perms));
|
||||
walkFileTree(p, true, f -> SELinux.setFileContext(f.toString(), "u:object_r:magisk_file:s0"));
|
||||
Files.createDirectories(prefs, PosixFilePermissions.asFileAttribute(perms));
|
||||
walkFileTree(prefs, f -> SELinux.setFileContext(f.toString(), "u:object_r:magisk_file:s0"));
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
|
|
@ -975,14 +975,11 @@ public class ConfigManager {
|
|||
return module != null && module.appId == uid % PER_USER_RANGE;
|
||||
}
|
||||
|
||||
private void walkFileTree(Path rootDir, boolean skipRoot, Consumer<Path> action) throws IOException {
|
||||
private void walkFileTree(Path rootDir, Consumer<Path> action) throws IOException {
|
||||
if (Files.notExists(rootDir)) return;
|
||||
Files.walkFileTree(rootDir, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||
if (skipRoot && dir.equals(rootDir)) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
action.accept(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
|
@ -999,10 +996,11 @@ public class ConfigManager {
|
|||
if (packageName == null) return;
|
||||
var path = Paths.get(getPrefsPath(packageName, uid));
|
||||
try {
|
||||
Files.createDirectories(path);
|
||||
walkFileTree(path, false, p -> {
|
||||
var perms = PosixFilePermissions.fromString("rwx--x--x");
|
||||
Files.createDirectories(path, PosixFilePermissions.asFileAttribute(perms));
|
||||
walkFileTree(path, p -> {
|
||||
try {
|
||||
Os.chown(p.toString(), uid, 1000);
|
||||
Os.chown(p.toString(), uid, uid);
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue