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

Service exits if exception during authentication. #158

Merged
merged 1 commit into from
Jan 25, 2022
Merged

Service exits if exception during authentication. #158

merged 1 commit into from
Jan 25, 2022

Conversation

brett-smith
Copy link
Contributor

We had a situation where a dbus client would lose connection to the EmbeddedDBusDaemon when coming out of hibernate. This happened on OS X, but presumably it's a possibility on other operating systems too.

For reference, here is the trace we got.

18 Jan 2022 07:01:48,123 [EmbeddedDBusDaemon-unix: {path=/tmp/dbus-DJVKKRECWC, guid=1a082ff10254aac4f742ad2bf2c68850, listen=true}] ERROR SASL  - Cannot create command.
java.io.IOException: Invalid Command BEGINl^A^A&^Dn^A^Ao^U/org/freedesktop/DBus^F^As^To
        at org.freedesktop.dbus.connections.SASL$Command.<init>(SASL.java:824)
        at org.freedesktop.dbus.connections.SASL.receive(SASL.java:243)
        at org.freedesktop.dbus.connections.SASL.auth(SASL.java:683)
        at org.freedesktop.dbus.connections.transports.AbstractTransport.authenticate(AbstractTransport.java:131)
        at org.freedesktop.dbus.connections.transports.AbstractTransport.connect(AbstractTransport.java:118)
        at org.freedesktop.dbus.bin.EmbeddedDBusDaemon.startListening(EmbeddedDBusDaemon.java:214)
        at org.freedesktop.dbus.bin.EmbeddedDBusDaemon.startInForeground(EmbeddedDBusDaemon.java:74)
        at java.base/java.lang.Thread.run(Thread.java:833)
18 Jan 2022 07:01:48,170 [DBusConnection] ERROR IncomingMessageThread  - FatalException in connection thread
org.freedesktop.dbus.exceptions.FatalDBusException: Underlying transport returned EOF (1)
        at org.freedesktop.dbus.connections.AbstractConnection.readIncoming(AbstractConnection.java:1154)
        at org.freedesktop.dbus.connections.IncomingMessageThread.run(IncomingMessageThread.java:40)
18 Jan 2022 07:01:48,171 [EmbeddedDBusDaemon-unix: {path=/tmp/dbus-DJVKKRECWC, guid=1a082ff10254aac4f742ad2bf2c68850, listen=true}] ERROR EmbeddedDBusDaemon  - Got uncaught exception
java.lang.NullPointerException: Cannot invoke "org.freedesktop.dbus.connections.SASL$SaslCommand.ordinal()" because the return value of "org.freedesktop.dbus.connections.SASL$Command.getCommand()" is null
        at org.freedesktop.dbus.connections.SASL.auth(SASL.java:684)
        at org.freedesktop.dbus.connections.transports.AbstractTransport.authenticate(AbstractTransport.java:131)
        at org.freedesktop.dbus.connections.transports.AbstractTransport.connect(AbstractTransport.java:118)
        at org.freedesktop.dbus.bin.EmbeddedDBusDaemon.startListening(EmbeddedDBusDaemon.java:214)
        at org.freedesktop.dbus.bin.EmbeddedDBusDaemon.startInForeground(EmbeddedDBusDaemon.java:74)
        at java.base/java.lang.Thread.run(Thread.java:833)
18 Jan 2022 07:01:48,172 [DBusConnection] INFO  Main  - Disconnected from Bus, retrying

The SASL chat was somehow getting corrupted, resulting in a failure in the accept loop on the server.

This PR now throws an exception if the SASL command is not valid. Also AuthenticationException is now caught higher up and the connection is also closed. This allows the loop to continue and accept more connections.

…ient, then no further clients may connect (the loop exits). Also ensure the connection is closed if any IOException occurs during authentication.
@hypfvieh hypfvieh merged commit d44ab69 into hypfvieh:master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants