nextcloud / serverinfo

📊 A monitoring app which creates a server info dashboard for admins
GNU Affero General Public License v3.0
94 stars 58 forks source link

PG Database with dots in the name causes serverInfo to fail #556

Open jduquennoy opened 5 months ago

jduquennoy commented 5 months ago

Steps to reproduce

  1. Setup a nextcloud with a PG database, and a DBName that contains a dot in its name
  2. Access the serverInfo app

Expected behaviour

The server info page should display

Actual behaviour

An error is reported, with this message in the logs:

Trying to access array offset on value of type bool at /var/www/html/apps/serverinfo/lib/DatabaseStatistics.php#132

Quick analysis

See lib/DatabaseStatistics.php#L123 There is a split of the DB name on a . separator. Due to this, with my DB name of cloud.mydomain.fr, the next query will be

SELECT oid FROM pg_database WHERE datname = 'cloud'

instead of being

SELECT oid FROM pg_database WHERE datname = 'cloud.mydomain.fr'

This looks like a bug, since dbName with dots seems to be supported by the rest of nextCloud (all other features are working as expected)

Server configuration

Operating system: Nexcloud docker image nextcloud:27-apache

Web server: Nexcloud docker image nextcloud:27-apache

Database: PostgreSQL 16

PHP version: Nexcloud docker image nextcloud:27-apache

Nextcloud version: (see Nextcloud admin page) 27.1.5

Where did you install Nextcloud from: Nexcloud docker image nextcloud:27-apache

Nextcloud configuration:

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.duquennoy.fr"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "27.1.5.1",
        "overwrite.cli.url": "https:\/\/cloud.duquennoy.fr",
        "overwriteprotocol": "https",
        "dbname": "cloud.mydomain.fr",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "theme": "",
        "default_phone_region": "FR",
        "loglevel": 0,
        "maintenance": false,
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587"
    }
}

Logs

{
    "reqId": "5jzLOBvbgGJVziUvhA25",
    "level": 3,
    "time": "2024-01-22T15:48:22+00:00",
    "remoteAddr": "172.19.0.1",
    "user": "jerome",
    "app": "PHP",
    "method": "GET",
    "url": "/settings/admin/serverinfo",
    "message": "Trying to access array offset on value of type bool at /var/www/html/apps/serverinfo/lib/DatabaseStatistics.php#132",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0",
    "version": "27.1.5.1",
    "data":
    {
        "app": "PHP"
    }
}
joshtrichards commented 5 months ago

Dots in database names always inevitably trigger bugs like this in software so I'd avoid them. :-)

But, yes, we should probably handle this.

kesselb commented 5 months ago

I remember a bug report about database names with dots in nextcloud/server, but were unable to find it again.
Is the database size important for anyone?