MaterialFiles icon indicating copy to clipboard operation
MaterialFiles copied to clipboard

Root doesn't work on non-main profile

Open ZenerDeveloper opened this issue 3 years ago • 27 comments

It appears that the app only works on the main profile. It seems to be able to "see" and create files in others as, if you create a folder, them create the same folder, it will give the file exists error. I tried it in the secure folder (profile 150) and the work profile (profile 13). It can go to sub-directories(The pre-determined ones in the sidebar like Download), but they also don't have files. I feel it worked before the update to android 11, though I can't be certain. I have already tried restarting my phone and both still don't work.

Information about my phone: Samsung Galaxy s10+ (SM-G975U1) Oneui3(android 11) February 1st security patch March 1st Google Play system update(I don't use google play) If you need more information, I will be glad to share it.

ZenerDeveloper avatar Apr 01 '21 17:04 ZenerDeveloper

I think it's likely a limitation on Android 11. Do other file managers work in work profiles?

zhanghai avatar Apr 02 '21 06:04 zhanghai

The samsung file manager works in the work profile, also if I hit add external storage and hit "Use this folder" (In the internal storage) that seems to work properly.

ZenerDeveloper avatar Apr 02 '21 13:04 ZenerDeveloper

Simple file manager also appears to work properly so I think it could be a bug.

ZenerDeveloper avatar Apr 02 '21 13:04 ZenerDeveloper

I have done some more testing, it appears to work under the Pixel 4XL api 30 emulator (Both profiles), so it may be exclusive to this device or Samsung phones. I realize that makes it rather difficult to find out what is causing it, and as I can't install the debug apk into the work profile for some unapparent reason, I tried to use logcat with the normal f-Droid release. The output when loading the folder is:

2021-04-02 10:07:21.577 28669-28726/? W/System.err: java8.nio.file.NoSuchFileException: /storage/emulated/13/DCIM: getgrgid: No such file or directory
2021-04-02 10:07:21.577 28669-28726/? W/System.err:     at me.zhanghai.android.files.provider.root.RootablePosixFileAttributeView$a.n(:1)
2021-04-02 10:07:21.577 28669-28726/? W/System.err:     at me.zhanghai.android.files.provider.root.RootablePosixFileAttributeView.m(Unknown Source:4)
2021-04-02 10:07:21.577 28669-28726/? W/System.err:     at me.zhanghai.android.files.provider.root.RootablePosixFileAttributeView.a(Unknown Source:4)
2021-04-02 10:07:21.577 28669-28726/? W/System.err: Caused by: me.zhanghai.android.files.provider.linux.syscall.SyscallException: getgrgid: No such file or directory
2021-04-02 10:07:21.577 28669-28726/? W/System.err:     at me.zhanghai.android.files.provider.linux.syscall.Syscalls.getgrgid(Native Method)

And that repeats for all of the subfolders. It also appears to be exclusive to Material files, as I tried 9 other file managers from f-Droid, and none of them had this issue.

ZenerDeveloper avatar Apr 02 '21 14:04 ZenerDeveloper

@zhanghai I have same problem with Samsung A70. I can't access Mateiral Files in my Work Profile (although it works in the main profile).

lamyergeier avatar Apr 14 '21 07:04 lamyergeier

This is interesting - didn't expect getgrgid() to fail. Will take a look recently.

zhanghai avatar Apr 15 '21 07:04 zhanghai

Is this fixed? I still can't access /storage/emulated on Android 11.

linsui avatar Aug 14 '21 11:08 linsui

I believe it's fixed in version 1.3.0+, and the app works fine for me in work profile on Android 12.

zhanghai avatar Feb 07 '22 08:02 zhanghai

I'm using 1.3.1 on Android 11 and I can't access /storage/emulated with root access. It gives me a NoSuchFileException error.

linsui avatar Feb 07 '22 12:02 linsui

Oh you are using root. I guess it may be related to mount namespace. If you can build the code on master, the app now uses master mount namespace so maybe this can be fixed.

zhanghai avatar Feb 07 '22 21:02 zhanghai

Or you may also try by installing Sui, which is said to always use master mount namespace for the root process.

zhanghai avatar Feb 07 '22 21:02 zhanghai

Oh you are using root. I guess it may be related to mount namespace. If you can build the code on master, the app now uses master mount namespace so maybe this can be fixed.

I get the same error.

linsui avatar Feb 08 '22 04:02 linsui

I tried root access in work profile with Magisk 20.4 on Androdd 9.0. After changing the multi-user setting in Magisk Manager I can see the root request dialog and allow it. I can also observe in the log that the root process is started. However, the app in work profile never received the binder from the root process and timed out waiting for it. Are you observing the same thing?

zhanghai avatar Feb 08 '22 08:02 zhanghai

I just confirmed with John and he said libsu indeed missed multi-user support. I've opened an issue for libsu at topjohnwu/libsu#95.

For now if you want root access in work profile, you can instal Sui which properly supports multi-user, and Material Files will switch to Sui if it's available.

zhanghai avatar Feb 08 '22 08:02 zhanghai

Re-opening this to track upgrading libsu once John fixes the issue.

zhanghai avatar Feb 08 '22 08:02 zhanghai

I just install Sui and tested again. But I got the same error. I installed MaterialFiles in main profile. I enabled Zygisk and installed Zygisk Sui. MaterialFiles required the root access from Sui. Then I entered the /storage/emulated and got the same error. I also installed it in work profile and got the same error.

linsui avatar Feb 08 '22 09:02 linsui

libsu worked fine for me in primary user and I can access /storage/emulated just fine. I haven't tested Sui though.

zhanghai avatar Feb 08 '22 09:02 zhanghai

And what is the exact error you are seeing in your last comment?

zhanghai avatar Feb 08 '22 09:02 zhanghai

I got java8.nio.filr.NoSuchFileException: /storage/emulated: opnedir: No such file or sirectory. I tested libsu and Sui in main user and work user and got the same error.

linsui avatar Feb 08 '22 09:02 linsui

@linsui Tested with Android 12 emulator, Sui + MaterialFiles works fine.

image

RikkaW avatar Feb 08 '22 09:02 RikkaW

@linsui I can reproduce your situation by setting "Root access mode" to "Normal access only".

image image

RikkaW avatar Feb 08 '22 09:02 RikkaW

I tested with root first and root only but got the same error. It's a clean install so every setting is the default one.

linsui avatar Feb 08 '22 09:02 linsui

I fetched more log. Tested with Sui Zygisk. Maybe it's helpful.

02-23 20:21:50.745 27093 27109 I i.android.file: WaitForGcToComplete blocked RunEmptyCheckpoint on ProfileSaver for 21.783ms
02-23 20:22:31.732 27093 27203 I ShizukuApplication: attachApplication
02-23 20:22:31.709 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24213): avc: denied { read } for comm=4173796E635461736B202336 name="/" dev="sde43" ino=2 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:31.769 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24215): avc: denied { getattr } for comm=4173796E635461736B202336 path="/init.recovery.qcom.rc" dev="sde43" ino=27 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0 app=me.zhanghai.android.files
02-23 20:22:31.779 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24216): avc: denied { getattr } for comm=4173796E635461736B202336 path="/linkerconfig" dev="tmpfs" ino=12127 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:linkerconfig_file:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:31.783 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24217): avc: denied { getattr } for comm=4173796E635461736B202336 path="/data_mirror" dev="tmpfs" ino=3250 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:mirror_data_file:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.173 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24224): avc: denied { read } for comm=4173796E635461736B202339 name="/" dev="sde43" ino=2 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.173 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24225): avc: denied { read } for comm=4173796E635461736B202336 name="/" dev="sde43" ino=2 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.179 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24226): avc: denied { getattr } for comm=4173796E635461736B202339 path="/init.recovery.qcom.rc" dev="sde43" ino=27 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.186 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24227): avc: denied { getattr } for comm=4173796E635461736B202339 path="/linkerconfig" dev="tmpfs" ino=12127 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:linkerconfig_file:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.189 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24228): avc: denied { getattr } for comm=4173796E635461736B202339 path="/data_mirror" dev="tmpfs" ino=3250 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:mirror_data_file:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.203 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24229): avc: denied { getattr } for comm=4173796E635461736B202339 path="/postinstall" dev="sde43" ino=43 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:postinstall_mnt_dir:s0 tclass=dir permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.213 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24230): avc: denied { getattr } for comm=4173796E635461736B202339 path="/init" dev="sde43" ino=25 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:init_exec:s0 tclass=lnk_file permissive=0 app=me.zhanghai.android.files
02-23 20:22:40.226 27093 27093 W me.zhanghai.android.files: type=1400 audit(0.0:24231): avc: denied { getattr } for comm=4173796E635461736B202339 path="/init.environ.rc" dev="sde43" ino=26 scontext=u:r:untrusted_app_29:s0:c139,c256,c512,c768 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0 app=me.zhanghai.android.files
02-23 20:22:59.365 27093 27093 W System.err: java8.nio.file.NoSuchFileException: /storage/emulated: opendir: No such file or directory
02-23 20:22:59.371 27093 27093 W System.err: 	at ra.h.s(Unknown Source:46)
02-23 20:22:59.371 27093 27093 W System.err: 	at ua.i$l.q(:1)
02-23 20:22:59.371 27093 27093 W System.err: 	at ua.k.a(Unknown Source:63)
02-23 20:22:59.371 27093 27093 W System.err: 	at ua.i.s(:1)
02-23 20:22:59.371 27093 27093 W System.err: 	at b7.i.e(:2)
02-23 20:22:59.371 27093 27093 W System.err: 	at e9.r0.V(Unknown Source:5)
02-23 20:22:59.371 27093 27093 W System.err: 	at y9.u.call(:1)
02-23 20:22:59.371 27093 27093 W System.err: 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
02-23 20:22:59.371 27093 27093 W System.err: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
02-23 20:22:59.371 27093 27093 W System.err: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
02-23 20:22:59.371 27093 27093 W System.err: 	at java.lang.Thread.run(Thread.java:923)
02-23 20:22:59.372 27093 27093 W System.err: Caused by: me.zhanghai.android.files.provider.linux.syscall.SyscallException: opendir: No such file or directory
02-23 20:22:59.372 27093 27093 W System.err: 	at me.zhanghai.android.files.provider.linux.syscall.Syscalls.opendir(Native Method)
02-23 20:22:59.372 27093 27093 W System.err: 	at ra.h.s(Unknown Source:30)
02-23 20:22:59.372 27093 27093 W System.err: 	... 10 more

linsui avatar Feb 23 '22 12:02 linsui

Should have been fixed in v1.4.0 with new version of libsu.

zhanghai avatar Mar 08 '22 06:03 zhanghai

I tested with master and got the same error.

linsui avatar Mar 08 '22 08:03 linsui

That's strange - I can't reproduce it though.

zhanghai avatar Mar 08 '22 09:03 zhanghai

~I have the same problem with just the default settings. For some reason the app just doesn't ask for file permissions like other apps do. I use Android 12.~ Solved by setting access on "All Files Access" under Apps/Special App Access.

Shatur avatar Jan 07 '24 11:01 Shatur