Mender-connect dbus errors that "AuthenticationManager was not provided"

Hey,
I just upgraded mender to the latest dunfell release to test mender-connect. I configured the bare minimum which is setting the client user to a non-root user.
The last two log messages are:

Jan 27 20:23:53 CI-570A7 mender-connect[261]: time="2021-01-27T20:23:53Z" level=warning msg="call to GetJWTToken on the Mender D-Bus API failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name io.mender.AuthenticationManager was not provided by any .service files"
Jan 27 20:23:53 CI-570A7 mender-connect[261]: time="2021-01-27T20:23:53Z" level=info msg="waiting for JWT token (waitForJWTToken)"

Any ideas what the error message indicates?

I’ve not seen anything like that myself. @kacf any ideas?

Do you mean that you modified the mender-client.service file to run the mender client under a different UID, or that you set the User field in the mender-connect.conf to a different user?

If it was the former, then I think DBus communication will not work out of the box, because you need root permissions to query the endpoint (mender-connect is querying mender-client for authentication information). Something along these lines in a mender-client_%.bbappend file should fix it:

do_install_append() {
    sed -i -e 's/<policy user="root">/<policy user="myuser">/' ${D}/${datadir}/dbus-1/system.d/io.mender.AuthenticationManager.conf
}

I didn’t test that, but hopefully you get the idea.

Also note that mender-connect will need to be run under the same UID.

Thanks for the hint. I tried using a non-root user but dropped back to root as the mender-connect user to avoid permission issues. Still, the error persists.

This is my mender-connect_%.bbappend:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI_append = " \
    file://mender-connect.conf \
"

do_install_append() {
    install -m 600 ${WORKDIR}/mender-connect.conf ${D}${sysconfdir}/mender/mender-connect.conf
}

where mender-connect.conf is:

{
    "ClientProtocol": "https",
    "ServerURL": "https://hosted.mender.io",
    "User": "root",
    "Terminal": {
        "Height": 24,
        "Width": 128
    },
    "Sessions": {
      "StopExpired": false,
      "ExpireAfter": 255,
      "ExpireAfterIdle": 16,
      "MaxPerUser": 4
    }
}

mender-client works fine.
The error stated above is followed by:

Jan 01 01:41:07 6D86AA69 mender-connect[251]: time="1970-01-01T01:41:07Z" level=info msg="waiting for JWT token (waitForJWTToken)"

which sounds to me like the client is working. Still, the remote terminal is not available at hosted.mender. Am I missing something?

I noticed that the year in your log message is 1970. Is the time not set correctly on the device? The client will not be able to connect if the clock is wrong, because the certificate is only valid within a given time period.

I just revisited the problem. Turned out that I had pending client authentications. After I dismissed older ones the remote client worked using the exact configuration and recipe above.

Sorry if I’m hi-jacking this thread, but I’m having the same problems, and is not fixed by the above suggestions.

It seems to be a race condition, since the mender-connect.service is started conditionally when the mender-client starts, but it seems like the mender-client doesn’t have time to get the dbus API up in time.

Manually restarting mender-connect.service works every time.

Relevant logs:
Mar 26 06:54:47 apalis-imx6 systemd[1]: Started Mender Connect service.
Mar 26 06:54:48 apalis-imx6 mender-connect[639]: time=“2021-03-26T06:54:48Z” level=info msg=“Loaded configuration file: /etc/mender/mender-connect.conf”
Mar 26 06:54:48 apalis-imx6 mender-connect[639]: time=“2021-03-26T06:54:48Z” level=warning msg=“call to GetJWTToken on the Mender D-Bus API failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name io.mender.AuthenticationManager was not provided by any .service files”
Mar 26 06:54:48 apalis-imx6 mender-connect[639]: time=“2021-03-26T06:54:48Z” level=info msg=“waiting for JWT token (waitForJWTToken)”
Mar 26 06:54:49 apalis-imx6 mender-connect[639]: time=“2021-03-26T06:54:49Z” level=warning msg=“The server certificate cannot be loaded: no file provided”
Mar 26 06:55:29 apalis-imx6 systemd[1]: Stopping Mender Connect service…
Mar 26 06:55:29 apalis-imx6 systemd[1]: mender-connect.service: Succeeded.
Mar 26 06:55:29 apalis-imx6 systemd[1]: Stopped Mender Connect service.
Mar 26 06:55:29 apalis-imx6 systemd[1]: Started Mender Connect service.
Mar 26 06:55:29 apalis-imx6 mender-connect[830]: time=“2021-03-26T06:55:29Z” level=info msg=“Loaded configuration file: /etc/mender/mender-connect.conf”
Mar 26 06:55:30 apalis-imx6 mender-connect[830]: time=“2021-03-26T06:55:30Z” level=warning msg=“The server certificate cannot be loaded: no file provided”

Hmm, I might have been wrong, the mender-connect outputs “waiting for jwt token” and then seems to successfully (but quietly) succeed, so now I can connect using the web UI. Must have been something else.