cloudstream icon indicating copy to clipboard operation
cloudstream copied to clipboard

PluginManager writing on internal storage

Open diogob003 opened this issue 3 months ago • 4 comments

Steps to reproduce

Use app

Expected behavior

PluginManager shouldn't write on internal storage, only on app data folder 📂

Actual behavior

PluginManager is writing on internal storage /storage/emulated/0/Cloudstream3/plugins

Cloudstream version and commit hash

4.6.1 9295795

Android version

Logcat

PluginManager: Files in '/storage/emulated/0/Cloudstream3/plugins' folder: 0

Other details

No response

Acknowledgements

  • [x] I am sure my issue is related to the app and NOT some extension.
  • [x] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • [x] I have written a short but informative title.
  • [x] I have updated the app to pre-release version Latest.
  • [x] I will fill out all of the requested information in this form.

diogob003 avatar Oct 26 '25 15:10 diogob003

This is intentional only to retain backwards compatibility. Modern android doesn't allow reading dex files from there so I did a patch to automatically copy them to the internal folder and do setReadOnly but to maintain backwards compatibility it also supports the other folder and copies them to the internal one.

Luna712 avatar Oct 26 '25 16:10 Luna712

It is acceptable to load from a folder created by a user that contains plug-ins. If the folder doesn't exist or I deleted it, avoid creating unnecessary unwanted folders in internal storage 📂 as there will be only a few users using it. My opinion.

diogob003 avatar Oct 26 '25 17:10 diogob003

I'll look into this over the next couple days and get back IIRC there was some reason I did it like this other than just backcompat alsk. This was done like this in #1477

Luna712 avatar Oct 26 '25 23:10 Luna712

On Android 16 QPR0, it firsts reads the plugins from /storage/emulated/0/Cloudstream3/plugins, then copies it to /storage/emulated/0/Android/data/com.lagradost.cloudstream3.prerelease/files/plugins

https://github.com/recloudstream/cloudstream/blob/a3a7b7067b8afc87e6b1e979b78b58d4717c7db1/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt#L535-L569

and calls setReadOnly() on it (which does not show any sign of failing in the log)

https://github.com/recloudstream/cloudstream/blob/a3a7b7067b8afc87e6b1e979b78b58d4717c7db1/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt#L601-L609

and tries to load it from there which throws the Exception:

E PluginManager: Failed to load `/storage/emulated/0/Android/data/com.lagradost.cloudstream3.prerelease/files/plugins/Testing.cs3: java.lang.SecurityException: Writable dex file '/storage/emulated/0/Android/data/com.lagradost.cloudstream3.prerelease/files/plugins/Testing.cs3' is not allowed.

I think it should actually copy the plugin to /data/data/com.lagradost.cloudstream3.prerelease/files/plugins to fix this issue.

itsyourap avatar Nov 22 '25 11:11 itsyourap