Skip to content
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

Setting non-standard port from GUI broken for FTP #32773

Open
5 of 8 tasks
phibbs7 opened this issue Jun 9, 2022 · 5 comments
Open
5 of 8 tasks

Setting non-standard port from GUI broken for FTP #32773

phibbs7 opened this issue Jun 9, 2022 · 5 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug feature: external storage

Comments

@phibbs7
Copy link

phibbs7 commented Jun 9, 2022

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Attempting to use an external FTP storage with a non-standard port fails. This is due to FtpConnection:__construct() getting the port to use from the GUI as part of the hostname argument and using the raw value as is. While PHP's ftp connect functions expect the hostname and port to be separate arguments.

This can also be seen in the cli:
$sudo php ./occ files_external:config mount id hostname
example.com:1234
$sudo php ./occ files_external:config mount id port
null
$

This will cause the debug log to get a PHP error from either ftp_ssl_connect() or ftp_connect(): getaddrinfo failed: Name or service not known

Steps to reproduce

  1. Enable external storage support.
  2. Add a new FTP or FTPS external storage configuration.
  3. Specify the non-standard port in the host box as per the instructions in the admin manual.
  4. Attempt to test the connection.

Expected behavior

FTP connection test to succeed and the external storage to be usable.

Installation method

Manual installation

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Updated from a minor version (ex. 22.2.3 to 22.2.4)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

Enabled:
  - accessibility: 1.9.0
  - activity: 2.15.0
  - bruteforcesettings: 2.4.0
  - calendar: 3.3.1
  - circles: 23.1.1
  - cloud_federation_api: 1.6.0
  - comments: 1.13.0
  - contacts: 4.1.1
  - contactsinteraction: 1.4.0
  - dashboard: 7.3.0
  - dav: 1.21.0
  - deck: 1.6.1
  - federatedfilesharing: 1.13.0
  - federation: 1.13.0
  - files: 1.18.0
  - files_accesscontrol: 1.13.0
  - files_automatedtagging: 1.13.0
  - files_external: 1.15.0
  - files_pdfviewer: 2.4.0
  - files_rightclick: 1.2.0
  - files_sharing: 1.15.0
  - files_trashbin: 1.13.0
  - files_versions: 1.16.0
  - files_videoplayer: 1.12.0
  - firstrunwizard: 2.12.0
  - groupfolders: 11.1.4
  - impersonate: 1.10.0
  - logreader: 2.8.0
  - lookup_server_connector: 1.11.0
  - mail: 1.13.1
  - nextcloud_announcements: 1.12.0
  - notifications: 2.11.1
  - oauth2: 1.11.0
  - password_policy: 1.13.0
  - photos: 1.5.0
  - privacy: 1.7.0
  - provisioning_api: 1.13.0
  - recommendations: 1.2.0
  - richdocuments: 5.0.5
  - richdocumentscode: 21.11.402
  - serverinfo: 1.13.0
  - settings: 1.5.0
  - sharebymail: 1.13.0
  - support: 1.6.0
  - survey_client: 1.11.0
  - systemtags: 1.13.0
  - text: 3.4.1
  - theming: 1.14.0
  - twofactor_backupcodes: 1.12.0
  - updatenotification: 1.13.0
  - user_ldap: 1.13.1
  - user_status: 1.3.1
  - viewer: 1.7.0
  - weather_status: 1.3.0
  - workflowengine: 2.5.0
Disabled:
  - admin_audit
  - encryption
  - spreed: 13.0.4

Nextcloud Signing status

No response

Nextcloud Logs

{"reqId":"NsjKBrLbJjZB15Pp3E28","level":3,"time":"2022-06-09T02:01:43+00:00","remoteAddr":"192.168.1.3","user":"27743958-36BD-4C10-9F27-FD772916DFCC","app":"PHP","method":"GET","url":"/index.php/apps/files_external/globalstorages/5?testOnly=true","message":"ftp_ssl_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known at /local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php#35","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36","version":"23.0.5.1","exception":{"Exception":"Error","Message":"ftp_ssl_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known at /local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php#35","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php","line":35,"function":"ftp_ssl_connect"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FTP.php","line":81,"function":"__construct","class":"OCA\\Files_External\\Lib\\Storage\\FtpConnection","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FTP.php","line":189,"function":"getConnection","class":"OCA\\Files_External\\Lib\\Storage\\FTP","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/MountConfig.php","line":130,"function":"test","class":"OCA\\Files_External\\Lib\\Storage\\FTP","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":288,"function":"getBackendStatus","class":"OCA\\Files_External\\MountConfig","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":363,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"show","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"62a1548869b19"}

Additional info

As a workaround, manually setting the port for the external storage via the occ command on the CLI will allow the connection to work.
E.x.
$sudo php ./occ files_external:config mount_id host example.com
$sudo php ./occ files_external:config mount_id port 1234

@phibbs7 phibbs7 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jun 9, 2022
@gyurmogyuri
Copy link

I have same

@szaimen
Copy link
Contributor

szaimen commented Jan 23, 2023

Hi, please update to 24.0.9 or better 25.0.3 and report back if it fixes the issue. Thank you!

My goal is to add a label like e.g. 25-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!

If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+

@phibbs7
Copy link
Author

phibbs7 commented Jan 24, 2023

OK, updated to NextCloud 25.0.3. (In addition to updating php to 8.1.) The issue is still present:

PHP engine version

PHP 8.1

Nextcloud Logs

"reqId":"Ci9Db4rRSEcChigEpcsr","level":3,"time":"2023-01-24T09:51:31+00:00","remoteAddr":"192.168.2.103","user":"27743958-36BD-4C10-9F27-FD772916DFCC","app":"PHP","method":"PUT","url":"/index.php/apps/files_external/globalstorages/8","message":"ftp_ssl_connect(): php_network_getaddresses: getaddrinfo for ftp.codenet:2121 failed: Name or service not known at /local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php#35","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","version":"25.0.3.2","exception":{"Exception":"Error","Message":"ftp_ssl_connect(): php_network_getaddresses: getaddrinfo for ftp.codenet:2121 failed: Name or service not known at /local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php#35","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FtpConnection.php","line":35,"function":"ftp_ssl_connect"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FTP.php","line":81,"function":"__construct","class":"OCA\\Files_External\\Lib\\Storage\\FtpConnection","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Lib/Storage/FTP.php","line":189,"function":"getConnection","class":"OCA\\Files_External\\Lib\\Storage\\FTP","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/MountConfig.php","line":131,"function":"test","class":"OCA\\Files_External\\Lib\\Storage\\FTP","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Controller/StoragesController.php","line":288,"function":"getBackendStatus","class":"OCA\\Files_External\\MountConfig","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/apps/files_external/lib/Controller/GlobalStoragesController.php","line":201,"function":"updateStorageStatus","class":"OCA\\Files_External\\Controller\\StoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"update","class":"OCA\\Files_External\\Controller\\GlobalStoragesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/local_data/Manually_Installed/Web_Applications/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/local_data/Manually_Installed/Web_Applications/nextcloud/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"id":"63cfaa27bbf50"}

@kathibeepboop
Copy link

Additional Workaround if you dont have access to the occ command (maybe users or so)

  1. Open the Settings
  2. Rightclick on the "host" input field
  3. Click on "Inspect" to open the Developer Tools
  4. Click on the "input" HTML Element and select "Edit as HTML"
    image
  5. Copy the whole line
  6. Change "data-parameter" to "port"
    It should look like that
    image
  7. Set the Port in the ui in the second "Host" field
    image
  8. Click on "Save" - Tada

That worked for me
I got some errors while uploading so i´ve set the "Remote Subfolder" to the root / home directory of the user.

After that, it worked :)

@itsthejb
Copy link

itsthejb commented Jun 9, 2023

Nice workaround @phibbs7. Thanks!

Note that the documentation (e.g. https://docs.nextcloud.com/server/26/admin_manual/configuration_files/external_storage/sftp.html) suggests that you can use colon syntax, e.g. ftp.host.com:1234. However this appears to be false

@joshtrichards joshtrichards changed the title [Bug]: OCA\Files_External\Lib\Storage\FtpConnection does not get port setting from GUI. Setting non-standard port from GUI broken for FTP Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug feature: external storage
Projects
None yet
Development

No branches or pull requests

6 participants