wolpi / prim-ftpd

FTP server app for android
Other
627 stars 77 forks source link

SD-card read-only #255

Open ole-tange opened 2 years ago

ole-tange commented 2 years ago

In my Android filemanager I can go to the SD-card (/storage/0F74-0C3F/) and both create folders and remove files.

But if I go there with prim-ftpd, the folder is read-only. The internal storage (/storage/emulated/0/), however, is read-write.

How can I get write permissions on /storage/0F74-0C3F?

wolpi commented 2 years ago

That is the old story of Google considering filesystem access a security issue. Google introduced SAF for that. If you cannot access some dir with this app, it is Android blocking it.

ole-tange commented 2 years ago

I can access it with a file manager - both read/write.

However, not all file managers(!?)

Is there some sort of permission the app can request? Because I may have given permission to one of them.

wolpi commented 2 years ago

I'm not aware of a permission or similar. Don't know how a filemanager can access sd-card writable without SAF.

CodingJavaDuck commented 2 years ago

Up to which Android version is it the case that p-ftp is not able to access the storage card?

I am currently trying to use an old phone as a kitchen mp3 player and would like to ftp-sync my music to a really big storage card. I could flash any desired lineage to it, it that helps.

Thank you!

wolpi commented 2 years ago

I think Google started with SAF and SD-card being read-only with Android 3.

But when looking at user feedback in all these issues here, it seems that many device vendors and custom roms did not and still do not implement this restriction as Google specifies it.

You can try recent lineage and see if it works.

timg11 commented 2 years ago

@wolpi, I'm running into similar issues trying to get R/W access to the full sdcard and internal file system on Android 12.
Google appears to have anticipated the need for certain programs (File Managers, Backup, etc) to have full access. This article describes how the app can request that type of access.

"An app can request All files access from the user by doing the following:

Declare the MANAGE_EXTERNAL_STORAGE permission in the manifest.
Use the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app: Allow access to manage all files.

To determine whether your app has been granted the MANAGE_EXTERNAL_STORAGE permission, call Environment.isExternalStorageManager()."

Has Primitive fptd implemented these permissions and intents?

wolpi commented 2 years ago

Permission MANAGE_EXTERNAL_STORAGE is declared. But ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION is currently not used. I'll have to check that. It will take some weeks.

timg11 commented 2 years ago

@wolpi, thank you! If I want to test the commit d8f669b for this issue, do I need to build from source? Or are there any compiled builds available for testing?

wolpi commented 2 years ago

Currently builds form continuous integration can not be downloaded. Contributions would be welcome :wink: Did you build it on our own already? Otherwise I would upload a snapshot build here.

wolpi commented 2 years ago

primitiveFTPd-6.12-SNAPSHOT.zip Here is a snapshot build, just rename it to .apk

timg11 commented 2 years ago

primitiveFTPd-6.12-SNAPSHOT.zip Here is a snapshot build, just rename it to .apk

@wolpi, thank you for the snapshot. I installed and tested. I have the same result. If I remove the exclude filter and let the client scan the files in the mobilesheetspro folder, primitiveFTPd stops responding. I'm not sure the logging is working as expected, or I'm not seeing the failure in the log file. What is the process to flush the logs after an event? Turn of logging? Exit the app? Both? Is it necessary to force close primFTPd, or is closing (flicking away) from recent apps list enough? What is the time in the logfile name prim-ftpd-log-2022-06-18-15-57-06.csv referenced to? Is it the time the logfile was created? Is it UTC or local time for the device? Likewise does primitiveFTPd provide timestamps in UTC or device time to the FTP client? The logfile with name prim-ftpd-log-2022-06-18-15-57-06.csv has a timestamp in the FTP client of 2022-06-19 11:38.

wolpi commented 2 years ago

Interesting would be the ls command used by snapshot version.

Regarding logs: To force flushing of log file it is necessary to stop the app with android system mechanisms. The timestamp in filename is file creation time. All timestamps should be in timezone of the android device. There is no code to do special timezone handling just plain Java APIs are used. Usually that means device local time.