-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG? Cannot read /storage: permission denied - Android 11 #1926
Comments
This is not a bug. System directories are being locked down as really shouldn't be viewable by regular apps. Least privilege principle, which is being enforced on modern Android. |
Use If /sdcard somehow became unreadable (permission denial), then revoke and grant again storage permission. |
how does one detect uids of multiple sdcard-like devices or other forms of external storage then? EDIT: example, if i have an actual micro sdcard connected AND an external SSD drive for instance... |
External sdcard mount path can be detected as path component of In future Termux versions, with updated SDK level to 30+, support of external storage will be dropped as it literally useless even with write access to application private directory (files placed in it cannot be moved elsewhere or even accessed with external file manager app). |
thanks for clarification |
@xeffyr Have you completed your In practice (support will be dropped) this means: all relevant project data must be copied with the fileApp to a location under path: t ( Everything (relevant) is then stored at least twice on the device. Most of my real devices are equipped with 16Gb (of which a maximum of 5Gb free) and "sufficient" external storage in which media/downloads (project data ~20Gb) are already managed. |
If you read my messages on Gitter about it, then you will know that yes and it works. You need to grant a special permission to get it working: Settings -> Applications -> Special access -> Access all files permission. You can store files in Termux directories and in /storage/emulated/0. On external storage, you can continue to use app private directory as writable location but you will not be able to move files anywhere else (Android/data/com.termux can be accessed only by Termux or ADB). |
@nathaneltitane Perhaps a way to get UUIDs is still present. Access to |
The files created in external storage by users for termux-only usage like |
@agnostic-apollo Is this same when MANAGE_EXTERNAL_STORAGE is in effect? Target API 30, of course. As I know, scoped storage works only if application doesn't has permission for all files access.
and |
Can't reproduce behaviour (all app-specific files deleted when uninstalling app) with manifest flags as in #1926 (comment) |
So I was a mistaken, that flag shouldn't affect any files under Edit: Edit 2: Just incrementing compileSdk version instead of targetSdk version has fixed the warning. Edit 3: I have created a
True, although possibly other android 11 restrictions like not being able to access private directories of other apps
We haven't opted out of scoped storage either, since
Anyways, with the The flag would have been added because since app devs are being pushed to write data to their own private app data directories on external storage instead of random directories, so android provided a way for data to be preserved on uninstall. Internal detailsIf you ask the dialog to preserve the data, then Apologies for the misinformation. |
everything you've all just mentioned is very nice but, does it change anything to what @xeffyr gave to me as the final answer? also, one must also consider the use case where no adb console can be accessed, as the Android device is used as the main PC (I.e.: my use case) |
@nathaneltitane No as long as you use the Termux artifact with targetSDK=28 :) |
I don't delve into versioning of termux - I simply use the version available on PlayStore like most people would. Guess I'll rewrite the detection script to find the mounts under /storage using /proc/mounts like @xeffyr suggested. I just hope that it'll stay accessible throughout Thanks |
last play store version is v101 (Nov. 2020) the current ones are published in F-Droid and are currently at v107 - in "Notificatons" above, annoying messages can be suppressed.
Yes read @xeffyr! you have pushed i asked checked if so where (emulator) and with which artifact (branch android-10)? |
So here are the two storage units of intterest:
As mentioned above, i was able to trace back the SDCard 3211-BCAD to /sdcard and or /mnt/sdcard |
@nathaneltitane Storage properties are clarified in https://wiki.termux.com/wiki/Internal_and_external_storage. You can have full access only to internal and shared storage. Only applications using Storage Access Framework APIs are able to write to external storage. Termux command line tools, like bash or coreutils, are not using Android APIs and in general not part of Android OS runtime. They are executed by Linux kernel and are subject for restrictions implied by DAC (chmod/chown) and MAC (SELinux). |
Problem description
Previously, using 'termux-setup-storage' to enable storage permissions and accessing /storage for reading or listing was permitted.
I use that method to provide access to my external microSD card and link it to whaterver Termux/CHROOT location i desire.
Now that I have upgraded my device to Android 11, after enabling storage permissions (by script or manually, an error results after attempting to read /storage:
example error output:
ˋˋˋ$ ls /storage
ls: cannot open directory '/storage': Permission denied
$ˋˋˋ
Steps to reproduce
open up a fresh/clean instance of termux
run ˋtermux-setup-storageˋ manually or programatically
allow permissions
attempt reading /storage directory contents manually or programatically (i.e.: ˋls storageˋ
error
Expected behavior
If storage permissions are allowed for tha app to access and manipulate storage, no error hould be triggered when attempting to access previously unauthorized or restricted storage directories (as was the behavior prior to Android 11 in my case)
Additional information
The text was updated successfully, but these errors were encountered: