user_external icon indicating copy to clipboard operation
user_external copied to clipboard

Undefined offset: 1 at /var/www/html/custom_apps/user_external/lib/imap.php#84

Open almereyda opened this issue 4 years ago • 5 comments

Steps to reproduce

  1. enable IMAP login with 4 => true and 5 => true
  2. login with username without domain part
  3. find the error in nextcloud.log, see below

https://github.com/nextcloud/user_external/blob/8a4e57bfcddeee51448edb5233d6d58cda7ca68c/lib/imap.php#L84

Expected behaviour

No error is thrown when logging in without domain part.

Actual behaviour

Login works, but the error feels bad.

Affected Authentication backend

IMAP

Server configuration

User External App version: 1.0.0

Operating system: Ubuntu 20.04.1 aarch64

Web server: nginx

Database: Postgres

PHP version: 7.4.15 (bundled with Nextcloud Docker image)

Nextcloud version: 20.0.6.1

Updated from an older Nextcloud/ownCloud or fresh install: fresh

Where did you install Nextcloud from: Building from https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/imap/fpm-alpine/Dockerfile

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.6.0
  - activity: 2.13.4
  - announcementcenter: 4.0.1
  - bruteforcesettings: 2.0.1
  - calendar: 2.1.3
  - cloud_federation_api: 1.3.0
  - comments: 1.10.0
  - contacts: 3.4.3
  - contactsinteraction: 1.1.0
  - dashboard: 7.0.0
  - dav: 1.16.2
  - deck: 1.2.4
  - federatedfilesharing: 1.10.2
  - federation: 1.10.1
  - files: 1.15.0
  - files_pdfviewer: 2.0.1
  - files_rightclick: 0.17.0
  - files_sharing: 1.12.2
  - files_trashbin: 1.10.1
  - files_versions: 1.13.0
  - files_videoplayer: 1.9.0
  - firstrunwizard: 2.9.0
  - groupfolders: 8.2.0
  - logreader: 2.5.0
  - lookup_server_connector: 1.8.0
  - nextcloud_announcements: 1.9.0
  - notifications: 2.8.0
  - oauth2: 1.8.0
  - password_policy: 1.10.1
  - photos: 1.2.3
  - privacy: 1.4.0
  - provisioning_api: 1.10.0
  - recommendations: 0.8.0
  - serverinfo: 1.10.0
  - settings: 1.2.0
  - sharebymail: 1.10.0
  - spreed: 10.0.5
  - support: 1.3.0
  - survey_client: 1.8.0
  - systemtags: 1.10.0
  - text: 3.1.0
  - theming: 1.11.0
  - twofactor_backupcodes: 1.9.0
  - updatenotification: 1.10.0
  - user_external: 1.0.0
  - user_status: 1.0.1
  - viewer: 1.4.0
  - weather: 1.7.4
  - weather_status: 1.0.0
  - workflowengine: 2.2.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - keeweb
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "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
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpsecure": "tls",
        "mail_smtpauth": true,
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "garten.hof.pause",
            "garten.hackenow.de",
            "garten.outpost.chn.io"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "20.0.6.1",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_sendmailmode": "smtp",
        "user_backends": [
            {
                "class": "OC_User_IMAP",
                "arguments": [
                    "herse.uberspace.de",
                    143,
                    "tls",
                    "hackenow.de",
                    true,
                    true
                ]
            }
        ],
        "overwrite.cli.url": "https:\/\/garten.outpost.chn.io"
    }
}

Logs

Web server error log

Web server error log
web_1    | 172.19.0.1 - - [12/Feb/2021:22:36:50 +0000] "POST /login HTTP/1.1" 303 0 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" "10.10.10.241" 

Nextcloud log (data/nextcloud.log)

Nextcloud log
{
  "reqId": "UkDs6lPBMOaF5YZQ9iz4",
  "level": 3,
  "time": "2021-02-12T22:36:40+00:00",
  "remoteAddr": "10.10.10.241",
  "user": "--",
  "app": "PHP",
  "method": "POST",
  "url": "/login",
  "message": {
    "Exception": "Error",
    "Message": "Undefined offset: 1 at /var/www/html/custom_apps/user_external/lib/imap.php#84",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/custom_apps/user_external/lib/imap.php",
        "line": 84,
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          8,
          "Undefined offset: 1",
          "/var/www/html/custom_apps/user_external/lib/imap.php",
          84,
          {
            "uid": "*** sensitive parameter replaced ***",
            "password": "*** sensitive parameter replaced ***",
            "pieces": ["*** sensitive parameter replaced ***"],
            "username": "[email protected]",
            "groups": []
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Manager.php",
        "line": 227,
        "function": "checkPassword",
        "class": "OC_User_IMAP",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/UidLoginCommand.php",
        "line": 49,
        "function": "checkPasswordNoLogging",
        "class": "OC\\User\\Manager",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 40,
        "function": "process",
        "class": "OC\\Authentication\\Login\\UidLoginCommand",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/UserDisabledCheckCommand.php",
        "line": 57,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\Authentication\\Login\\ALoginCommand",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/ALoginCommand.php",
        "line": 40,
        "function": "process",
        "class": "OC\\Authentication\\Login\\UserDisabledCheckCommand",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/PreLoginHookCommand.php",
        "line": 53,
        "function": "processNextOrFinishSuccessfully",
        "class": "OC\\Authentication\\Login\\ALoginCommand",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/lib/private/Authentication/Login/Chain.php",
        "line": 108,
        "function": "process",
        "class": "OC\\Authentication\\Login\\PreLoginHookCommand",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/core/Controller/LoginController.php",
        "line": 310,
        "function": "process",
        "class": "OC\\Authentication\\Login\\Chain",
        "type": "->",
        "args": [{ "__class__": "OC\\Authentication\\Login\\LoginData" }]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 169,
        "function": "tryLogin",
        "class": "OC\\Core\\Controller\\LoginController",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 100,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          { "__class__": "OC\\Core\\Controller\\LoginController" },
          "tryLogin"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 152,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          { "__class__": "OC\\Core\\Controller\\LoginController" },
          "tryLogin"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 309,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OC\\Core\\Controller\\LoginController",
          "tryLogin",
          { "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer" },
          { "_route": "core.login.tryLogin" }
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1008,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": ["/login"]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/Log/ErrorHandler.php",
    "Line": 91,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0",
  "version": "20.0.6.1"
}

Browser log

Browser log
moment is deprecated: please ship your own, this will be removed in Nextcloud 20
$ is deprecated: The global jQuery is deprecated. It will be updated to v3.x in Nextcloud 21. In later versions of Nextcloud it might be removed completely. Please ship your own.

almereyda avatar Feb 12 '21 22:02 almereyda

This is also triggered when using the Mail app:

grep /apps/mail nextcloud/data/nextcloud.log | grep 'Undefined offset' | jq --slurp '.[0]'
{
  "reqId": "CXNLRg91iJB3rjAXR8Cu",
  "level": 3,
  "time": "2021-02-19T16:16:11+00:00",
  "remoteAddr": "172.18.0.1",
  "user": "jon",
  "app": "PHP",
  "method": "GET",
  "url": "/apps/mail/api/messages?mailboxId=6&filter=is:pi-other&limit=20",
  "message": {
    "Exception": "Error",
    "Message": "Undefined offset: 1 at /var/www/html/custom_apps/user_external/lib/imap.php#84",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/custom_apps/user_external/lib/imap.php",
        "line": 84,
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          8,
          "Undefined offset: 1",
          "/var/www/html/custom_apps/user_external/lib/imap.php",
          84,
          {
            "uid": "*** sensitive parameter replaced ***",
            "password": "*** sensitive parameter replaced ***",
            "pieces": [
              "*** sensitive parameter replaced ***"
            ],
            "username": "[email protected]",
            "groups": []
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Manager.php",
        "line": 227,
        "function": "checkPassword",
        "class": "OC_User_IMAP",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Manager.php",
        "line": 204,
        "function": "checkPasswordNoLogging",
        "class": "OC\\User\\Manager",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Session.php",
        "line": 762,
        "function": "checkPassword",
        "class": "OC\\User\\Manager",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Session.php",
        "line": 796,
        "function": "checkTokenCredentials",
        "class": "OC\\User\\Session",
        "type": "->",
        "args": [
          {
            "id": 49,
            "__class__": "OC\\Authentication\\Token\\PublicKeyToken"
          },
          "*** sensitive parameter replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Session.php",
        "line": 269,
        "function": "validateToken",
        "class": "OC\\User\\Session",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/User/Session.php",
        "line": 244,
        "function": "validateSession",
        "class": "OC\\User\\Session",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/legacy/OC_App.php",
        "line": 374,
        "function": "getUser",
        "class": "OC\\User\\Session",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/legacy/OC_App.php",
        "line": 117,
        "function": "getEnabledApps",
        "class": "OC_App",
        "type": "::",
        "args": []
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 986,
        "function": "loadApps",
        "class": "OC_App",
        "type": "::",
        "args": [
          [
            "authentication"
          ]
        ]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/Log/ErrorHandler.php",
    "Line": 91,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0",
  "version": "20.0.7.1"
}

almereyda avatar Feb 19 '21 16:02 almereyda

Exactly the same problem over here, will there be a 1.0.1 release to fix this for NC < 21?

prismopensource avatar Apr 24 '21 11:04 prismopensource

i have the problem too with OPs scenario on nextcloud 21 0 3 plugin External user authentication 2.0.0

log is spammed with the above error

MparkG avatar Jul 13 '21 10:07 MparkG

Same here on NC 21.0.5. Also using IMAP auth.

stefanhorning avatar Oct 21 '21 08:10 stefanhorning

Probably replacing $pieces[1] with isset($pieces[1]) should fix the issue you face. Could some of those who experience the issue test it locally and report back?

mejo- avatar Dec 30 '21 23:12 mejo-