Skip to content

[Bug]: sftp based external share has no default port, generating error while upgrading from version 32 to 33 #58833

@plouflechien

Description

@plouflechien

⚠️ This issue respects the following points: ⚠️

Bug description

When migrating from nextcloud v32 to nextcloud v33, a new port parameter seems to be required from nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SSH2.php (line 1309). If this value was not previously setup, no default is given, then the ssh2.php script halt, because of null(string) value given instead of an integer.


With the new admin page about external shares, It's seem that sftp shares has an option to add "port" on ssh/sftp server. If the port was not previously setup (I don't think it was possible with nextcloud v32), the SSH2.php crash; because of port missing.
A default port should be set when migrating or something to disable this king of external shares as lo,ng as the port is not set and verified.

Steps to reproduce

2.migrate from nc 32 to nc 33 with sftp external shares
3.

Expected behavior

temporaly disable sftp shares while port is not set; default port value instead of null, ?

Nextcloud Server version

33

Operating system

Other

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

PostgreSQL

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

Upgraded to a MAJOR version (ex. 31 to 32)

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

{
    "system": {
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.[redacted].fr"
        ],
        "dbtype": "pgsql",
        "trashbin_retention_obligation": "30,60",
        "version": "33.0.0.16",
        "default_language": "fr",
        "defaultapp": "files,contacts,calendar",
        "overwrite.cli.url": "https:\/\/cloud.[redacted].fr",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "versions_retention_obligation": "30,60",
        "default_phone_region": "FR",
        "loglevel": 0,
        "debugMode": false,
        "maintenance": false,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpport": "25",
        "theme": "",
        "maintenance_window_start": 1,
        "force_language": "fr",
        "default_locale": "fr_FR",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        }
    }
}

List of activated Apps

Enabled:
  - activity: 6.0.0-dev.0
  - app_api: 33.0.0
  - bruteforcesettings: 6.0.0-dev.0
  - circles: 33.0.0
  - cloud_federation_api: 1.17.0
  - comments: 1.23.0
  - dav: 1.36.0
  - federatedfilesharing: 1.23.0
  - files: 2.5.0
  - files_downloadlimit: 5.1.0-dev.0
  - files_external: 1.25.1
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - files_versions: 1.26.0
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - notifications: 6.0.0
  - oauth2: 1.21.0
  - password_policy: 5.0.0-dev.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - related_resources: 4.0.0-dev.0
  - serverinfo: 5.0.0-dev.0
  - settings: 1.16.0
  - sharebymail: 1.23.0
  - survey_client: 5.0.0-dev.0
  - systemtags: 1.23.0
  - text: 7.0.0-dev.3
  - theming: 2.8.0
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0-dev.0
  - updatenotification: 1.23.0
  - user_status: 1.13.0
  - viewer: 6.0.0-dev.0
  - weather_status: 1.13.0
  - webhook_listeners: 1.5.0
  - workflowengine: 2.15.0
Disabled:
  - admin_audit: 1.23.0 (installed 1.20.0)
  - contactsinteraction: 1.14.1 (installed 1.5.0)
  - dashboard: 7.13.0 (installed 7.1.0)
  - encryption: 2.21.0
  - federation: 1.23.0 (installed 1.8.0)
  - files_pdfviewer: 6.0.0-dev.0 (installed 2.1.0)
  - files_reminders: 1.6.0 (installed 1.3.0)
  - firstrunwizard: 6.0.0-dev.0 (installed 2.12.0)
  - nextcloud_announcements: 5.0.0 (installed 2.0.0)
  - photos: 6.0.0-dev.0 (installed 1.0.0)
  - privacy: 5.0.0-dev.0 (installed 1.7.0)
  - recommendations: 6.0.0-dev.0 (installed 1.2.0)
  - support: 5.0.0 (installed 2.0.0)
  - suspicious_login: 11.0.0-dev.0
  - twofactor_nextcloud_notification: 7.0.0
  - user_ldap: 1.24.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Starting scan for user 1 out of 9 (redacted)
An unhandled exception has been thrown:
TypeError: fsockopen(): Argument #2 ($port) must be of type int, string given in /usr/local/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SSH2.php:1309
Stack trace:
#0 /usr/local/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SSH2.php(1309): fsockopen('localhost', '', NULL, NULL, 10)
#1 /usr/local/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SSH2.php(5217): phpseclib\Net\SSH2->_connect()
#2 /usr/local/www/nextcloud/apps/files_external/lib/Lib/Storage/SFTP.php(117): phpseclib\Net\SSH2->getServerPublicHostKey()
#3 /usr/local/www/nextcloud/apps/files_external/lib/Lib/Storage/SFTP.php(498): OCA\Files_External\Lib\Storage\SFTP->getConnection()

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap33-feedbackbug

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions