nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.32k stars 1.78k forks source link

"Permission Denied" error when uploading from Android Client (but fine from Windows and iOS Clients) #6570

Open jmone1 opened 4 years ago

jmone1 commented 4 years ago

I was asked to create this ticket from the Help Desk Post - https://help.nextcloud.com/t/permission-denied-when-uploading-from-android-client-but-fine-using-windows-client/83696

Steps to reproduce

When trying to upload from an Android Phone, I get the following error:

Thu Jun 04 23:02:28.952824 2020] [core:crit] [pid 597] (13)Permission denied: [client xxx.xxx.xxx.xxx:12345] AH00529: /home/me/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/me/public_html/' is executable

In initial testing, I've found:

If further testing I found:

I have tried to some basic troubleshooting but have been unable to change the behaviour

Expected behaviour

Actual behaviour

Can you reproduce this problem on https://try.nextcloud.com?

Environment data

Android version: 10 - Kernel 4.14.117

Device model: LG V50 (can test on others)

Stock or customized system: Stock

Nextcloud app version: 3.12.1

Nextcloud server version: 18.0.5, 19.0.0, 19.0.1 Operating system and version: Linux 3.10.0-1062.18.1.el7.x86_64 x86_64 Apache or nginx version : ?? PHP version: 7.3.18

Reverse proxy: unsure

Logs - Will need to provide these later

AndyScherzinger commented 4 years ago

@tobiasKaminsky I asked @jmone1 to open an issue since from the description (also posted on the forum) I think this needs some further debugging (since it works with other clients)

jmone1 commented 4 years ago

Happy to test, try changes, provide logs, even provide an account on the site if you need.

tobiasKaminsky commented 4 years ago

Thu Jun 04 23:02:28.952824 2020] [core:crit] [pid 597] (13)Permission denied: [client xxx.xxx.xxx.xxx:12345] AH00529: /home/me/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/me/public_html/' is executable

This is output of web server, or?

jmone1 commented 4 years ago

Apologies, If I'm flying blind to get you the correct info. That error (and others like it) are from CPanel's Error Log for the Web Server. I get a few of these most days but I'm unsure if they are related to the upload issue from the android client as I don't see other errors being reported in CPanel or the Next Cloud Log.

For example, I just tried uploading another file from my android client (a couple of times) and kept an eye on both the NextCloud Log (Admin / Logging) and also the Web Server log. Both times they failed to upload but neither log reported any new issues with the failure.

The only "recent" errors in the Nextcloud Log are as follows (and the last one was 3 days ago): `[PHP] Error: session_start(): A session had already been started - ignoring at /home/bray/public_html/nextcloud/lib/private/Session/Internal.php#209

GET /nextcloud/ocs/v1.php/cloud/user?format=json from xx.xx.xx at 2020-08-03T07:18:54+00:00`

jmone1 commented 4 years ago

I also re-tested uploading by adding a file in my Nextcloud Windows Directory and it syned up fine to the server.

jmone1 commented 4 years ago

Updated to 19.02 still failed

tobiasKaminsky commented 4 years ago

Is this happening both, for small and big files? Background is that we have two different approaches. Can you test it with <500kb and >10Mb?

jmone1 commented 4 years ago

Tested on a 70K and a 30MB file. Both failed the same way.

tobiasKaminsky commented 4 years ago

Can you create us a test account, test if the problem occurs also there and if so send the credentials to tobias at nextcloud dot com with a reference to this issue?

jmone1 commented 4 years ago

Thanks Tobias - E-Mail sent.

tobiasKaminsky commented 4 years ago

do you have any kind of rate limiting? I logged in, uploaded a file, tried it again and now I cannot connect anymore.

As far as I could see this seems to be a server problem, as you cannot upload a file, but this fails on server side.

jmone1 commented 4 years ago

Sent an e-mail

tobiasKaminsky commented 4 years ago

Still does not work…

jmone1 commented 4 years ago

e-mail sent

tobiasKaminsky commented 4 years ago

I tried it again. And now I see that I get a http nc error html page back when trying to do a webdav put. So this is clearly a problem on server, probably with http redirect / rewrite.

stale[bot] commented 4 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

brandon2e commented 4 years ago

Commenting to add what helped me since there was little online about this;

  1. Files I added to Nextcloud/data somehow had the wrong owner, not www-data but my main Linux user name. chown the whole folder to be sure and could upload from the Android client

  2. I had some TWRP files (Android backup utility) I couldn't delete from the Android client but that seemed to be specific to those files, no idea why because I could delete other files. Removed the from terminal in Linux and good to go.

jmone1 commented 4 years ago

Thanks - I don't even have a user or group called www-data.

Happyfeet01 commented 4 years ago

I have the same error.

Strange is that all picture from the DCIM Folder on my android Device can't be uploaded, but the upload from Screenshots from an other folder working. I have no error messages in Nextcloud and Nginx. Maybe an Smartphone problem?

Have nextcloud 20.1 installed Screenshot_20201108_083415_com nextcloud client

tobiasKaminsky commented 4 years ago

Hm, might be. Where are those images stored? Is it an external sdcard?

Happyfeet01 commented 4 years ago

No internal

tobiasKaminsky commented 4 years ago

When you try to upload the exact same file to the same remote folder manually, does this then work?

stale[bot] commented 3 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

cristian-milea commented 3 years ago

Still having this issue on Android. Cannot upload. tested on 3 android phones. Is this issue tracked anywhere or being worked on?

mathieujobin commented 2 years ago

I am still having this issue, it works for a while... then stop working, and I'm not sure, maybe I should turn off automatic upload and wait a week? its no longer uploading anything...

mathieujobin commented 2 years ago

please reopen this issue @github-actions

tobiasKaminsky commented 2 years ago

Can you provide us additional infos via logcat? https://github.com/nextcloud/android/blob/master/README.md#getting-debug-info-via-logcat

mathieujobin commented 2 years ago

@tobiasKaminsky I just tried that. I have USB debugging enabled, but adb cannot see my device.

$ adb shell ps
error: no devices/emulators found

I had ~20GB auto-uploaded and suddenly permission error. is there a server setting that I can check?

mathieujobin commented 2 years ago

Ok, I changed cable/port and I can fetch the logs now.

01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation: Existence check for https://cloud.EXAMPLE.net/next/remote.php/dav/files/example//InstantUpload/Camera/IMG_20220110_075009.jpg targeting for  existence : Socket timeout exception
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation: java.net.SocketTimeoutException: failed to connect to cloud.EXAMPLE.net/7x.1xx.2xx.2xx (port 443) from /192.168.yy.xx (port 40863) after 50000ms: isConnected failed: ETIMEDOUT (Connection timed out)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at libcore.io.IoBridge.isConnected(IoBridge.java:283)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at libcore.io.IoBridge.connectErrno(IoBridge.java:192)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at libcore.io.IoBridge.connect(IoBridge.java:134)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at java.net.Socket.connect(Socket.java:621)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.google.android.gms.org.conscrypt.AbstractConscryptSocket.connect(:com.google.android.gms@214815037@21.48.15 (150400-414534850):4)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.createSocket(AdvancedSslSocketFactory.java:184)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:200)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:171)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation.run(ExistenceCheckRemoteOperation.java:95)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.operations.UploadFileOperation.existsFile(UploadFileOperation.java:1152)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.operations.UploadFileOperation.checkNameCollision(UploadFileOperation.java:941)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.operations.UploadFileOperation.normalUpload(UploadFileOperation.java:760)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.operations.UploadFileOperation.run(UploadFileOperation.java:448)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.files.services.FileUploader.uploadFile(FileUploader.java:640)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at com.owncloud.android.files.services.FileUploader$ServiceHandler.handleMessage(FileUploader.java:1415)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at android.os.Handler.dispatchMessage(Handler.java:106)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at android.os.Looper.loop(Looper.java:237)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at android.os.HandlerThread.run(HandlerThread.java:67)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation: Caused by: android.system.ErrnoException: isConnected failed: ETIMEDOUT (Connection timed out)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         at libcore.io.IoBridge.isConnected(IoBridge.java:274)
01-11 13:01:04.356 19026 10828 E ExistenceCheckRemoteOperation:         ... 30 more

found this stack trace, do you need more information ?

mathieujobin commented 2 years ago

also ...

01-11 13:00:20.809 19026 10828 D OwnCloudClient #0: REQUEST MOVE /next/remote.php/dav/uploads/username/a8d96f95f667976aaf6ccfc9cdcf0888/.file
01-11 13:00:21.320 19026 10828 E UploadFileOperation: Upload of /storage/emulated/0/DCIM/Camera/IMG_20220110_083559.jpg to /InstantUpload/Camera/IMG_20220110_083559.jpg: Operation finished with HTTP status code 403 (fail)
01-11 13:00:21.320 19026 10828 D UploadsStorageManager: updateDatabaseUploadResult uploadResult: RemoteOperationResult(mSuccess=false, mHttpCode=403, mHttpPhrase=Forbidden, mException=null, mCode=FORBIDDEN, message=null, getLogMessage=Operation finished with HTTP status code 403 (fail)) upload: com.owncloud.android.operations.UploadFileOperation@cc94360
01-11 13:00:21.322 19026 10828 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220110_083559.jpg with status:UPLOAD_FAILED and result:PRIVILEGES_ERROR (old:/storage/emulated/0/DCIM/Camera/IMG_20220110_083559.jpg status:UPLOAD_IN_PROGRESS result:-1)
01-11 13:00:21.322 19026 10828 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220110_083559.jpg with status=UPLOAD_FAILED
01-11 13:00:21.326 19026 10828 D UploadsStorageManager: updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/Camera/IMG_20220110_083559.jpg
01-11 13:00:21.326 19026 10828 D UploadsStorageManager: notifyObserversNow
01-11 13:00:21.326 19026 10828 D FileUploader: NotifyUploadResult with resultCode: FORBIDDEN
01-11 13:00:21.331 19026 10828 D FileUploader: Stopping command after id 1
01-11 13:00:21.436 19026 10828 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220110_075013.jpg with status:UPLOAD_IN_PROGRESS and result:UNKNOWN (old:/storage/emulated/0/DCIM/Camera/IMG_20220110_075013.jpg status:UPLOAD_IN_PROGRESS result:-1)
tobiasKaminsky commented 2 years ago

This sounds like a network issue… can you access the cloud via browser in the moment this happens?

Aharper9917 commented 2 years ago

I had a similar issue where I couldn't upload files to a local external drive I setup in Nextcloud. My comment might be irrelevant to this issue, if so please disregard. However, I hope someone finds this useful.

I noticed my nextcloud uses the user www-data. Later I checked the permissions for the directory I mounted for my local external drive and they were: drwxrwxr-x. I did a quick chmod -R 777 <PATH_TO_DIR> to allow write privileges for all other users, and I was able to upload files to that folder. In my case I was okay with give all users r/w privileges.

github-actions[bot] commented 2 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

mathieujobin commented 2 years ago

it is not a unix file permission issue. I have double check that... but recently, its happening much less. maybe a recent software update improve things, I'll report back when it happens again

skjnldsv commented 2 years ago

I can also reproduce the issue. All permissions are correct and checked multiple times (chown and chmod ran again just in case) It seems to randomly misbehave.

Clicking restart in the android app works fine. Meaning it was indeed not a permission issue on the server side.

skjnldsv commented 2 years ago

Logcat:

03-22 16:53:25.508 10282 12262 D UploadFileOperation: Checking name collision in server
03-22 16:53:25.509 10282 12262 D OwnCloudClient #0: REQUEST HEAD /remote.php/dav/files/john//InstantUpload/2022/03/IMG_20220322_165119451.jpg
03-22 16:53:26.362 10282 12262 D ExistenceCheckRemoteOperation: Existence check for https://nc.john.cloud/remote.php/dav/files/john//InstantUpload/2022/03/IMG_20220322_165119451.jpg targeting for  existence finished with HTTP status 404(FAIL)
03-22 16:53:26.365 10282 12262 D UploadsStorageManager: QUERY: null ROWID: -1
03-22 16:53:26.383 10282 12262 V UploadsStorageManager: getUploads() got 20 rows from page 0, 20 rows total so far, last ID 92
03-22 16:53:26.383 10282 12262 D UploadsStorageManager: QUERY: _id < ? ROWID: 92
03-22 16:53:26.391 10282 12262 V UploadsStorageManager: getUploads() got 0 rows from page 1, 20 rows total so far, last ID 92
03-22 16:53:26.391 10282 12262 V UploadsStorageManager: getUploads() returning 20 (20) rows after reading 2 pages
03-22 16:53:26.391 10282 12262 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg with status=UPLOAD_IN_PROGRESS
03-22 16:53:26.485 10282 12262 D UploadsStorageManager: updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg
03-22 16:53:26.485 10282 12262 D UploadsStorageManager: notifyObserversNow
03-22 16:53:26.490 10282 12262 D OwnCloudClient #0: REQUEST MKCOL /remote.php/dav/uploads/john/6987194117a29446789ecb4bde15fa1f
03-22 16:53:26.669 10282 12262 D OwnCloudClient #0: REQUEST PROPFIND /remote.php/dav/uploads/john/6987194117a29446789ecb4bde15fa1f
03-22 16:53:26.670 10282 12262 D AdvancedSslSocketFactory: Creating SSL Socket with remote nc.john.cloud:443, local null:0, params: org.apache.commons.httpclient.params.HttpConnectionParams@164ef8
03-22 16:53:26.670 10282 12262 D AdvancedSslSocketFactory:  ... with connection timeout 60000 and socket timeout 60000
03-22 16:53:26.678 10282 12262 I ServerNameIndicator: SSLSocket implementation: com.google.android.gms.org.conscrypt.Java8FileDescriptorSocket
03-22 16:53:26.678 10282 12262 I ServerNameIndicator: SNI done, hostname: nc.john.cloud
03-22 16:53:27.086 10282 12262 D OwnCloudClient #0: REQUEST PUT /remote.php/dav/uploads/john/6987194117a29446789ecb4bde15fa1f/0000000000000000-0000000005939002
03-22 16:53:30.024 10282 12262 D ChunkedFileUploadRemoteOperation: Upload of /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg to /InstantUpload/2022/03/IMG_20220322_165119451.jpg, chunk from 0000000000000000 to 0000000005939002 size: 5939003, HTTP result status 201
03-22 16:53:30.024 10282 12262 D OwnCloudClient #0: REQUEST MOVE /remote.php/dav/uploads/john/6987194117a29446789ecb4bde15fa1f/.file
03-22 16:53:31.275 10282 12262 E UploadFileOperation: Upload of /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg to /InstantUpload/2022/03/IMG_20220322_165119451.jpg: Operation finished with HTTP status code 403 (fail)
03-22 16:53:31.670 10282 12262 D UploadsStorageManager: updateDatabaseUploadResult uploadResult: RemoteOperationResult(mSuccess=false, mHttpCode=403, mHttpPhrase=Forbidden, mException=null, mCode=FORBIDDEN, message=null, getLogMessage=Operation finished with HTTP status code 403 (fail)) upload: com.owncloud.android.operations.UploadFileOperation@b29280d
03-22 16:53:31.683 10282 12262 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg with status:UPLOAD_FAILED and result:PRIVILEGES_ERROR (old:/storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg status:UPLOAD_IN_PROGRESS result:-1)
03-22 16:53:31.683 10282 12262 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg with status=UPLOAD_FAILED
03-22 16:53:34.134 10282 12262 D UploadsStorageManager: updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/Camera/IMG_20220322_165119451.jpg
03-22 16:53:34.134 10282 12262 D UploadsStorageManager: notifyObserversNow
03-22 16:53:34.141 10282 12262 D FileUploader: NotifyUploadResult with resultCode: FORBIDDEN
03-22 16:53:34.168 10282 12262 D FileUploader: Stopping command after id 4
03-22 16:53:34.191 10282 12262 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220322_165118143.jpg with status:UPLOAD_IN_PROGRESS and result:UNKNOWN (old:/storage/emulated/0/DCIM/Camera/IMG_20220322_165118143.jpg status:UPLOAD_IN_PROGRESS result:-1)
03-22 16:53:34.191 10282 12262 V UploadsStorageManager: Updating /storage/emulated/0/DCIM/Camera/IMG_20220322_165118143.jpg with status=UPLOAD_IN_PROGRESS
03-22 16:53:34.224 10282 12262 D UploadsStorageManager: updateUpload returns with: 1 for file: /storage/emulated/0/DCIM/Camera/IMG_20220322_165118143.jpg
03-22 16:53:34.225 10282 12262 D UploadsStorageManager: notifyObserversNow
03-22 16:53:34.255 10282 12262 D UploadsStorageManager: QUERY: null ROWID: -1
03-22 16:53:34.274 10282 12262 V UploadsStorageManager: getUploads() got 20 rows from page 0, 20 rows total so far, last ID 92
github-actions[bot] commented 2 years ago

This bug report did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

psychedelicu commented 2 months ago

Almost 2025 and I still have this issue. How can i fix it? This is happening only when my Android upload videos.