2

Qt 5.2, Win 7

When I register a service QDBusConnection::registerService ( const QString & serviceName ), it fails ("false") with a system DBus connection (QDBusConnection::systemBus ()), but works with a session DBus connection and a peer connection.

This is how I start the server: dbus-daemon.exe --system --address=tcp:host=127.0.0.1,port=45000

As of QtService application cannot connect to system bus when running as a service I have tried (see here) changing the system.conf

<auth>ANONYMOUS</auth>
<allow_anonymous/>

I found another similar question here. Also I have tried the policy as described there.

Any hints how I can overcome the issue, or at least obtain precise error messages? The "false" of the method does not really help.

-- edit ---

Below code gives me an error message not connected to server for the connection. Does the method QDBusConnection::systemBus() not automatically connect (as with session, peer)?

            QDBusConnection con = QDBusConnection::systemBus();
            if (!con.registerService(ServiceName))
            {
                qCritical() << con.lastError().message();
                qFatal("Cannot register DBus service, server started? dbus-daemon.exe --system --address=tcp:host=192.168.0.133,port=45000");
            }

--- edit 2, commet of JB0x2D1 ----

I agree, also think it is related to the .conf file.

  1. The link you provided and the one above from me all lead to the same example . I have tried the .conf file as there (of course, changed service names accordingly my names)
  2. Found another interesting example: https://wiki.ubuntu.com/DebuggingDBus . Unfortunately no success

Hard to tell, whether the issue is Windows related, most examples are clearly Linux driven. Wonder, what the minimal conf for "allow everything to anybody" would be.

Community
  • 1
  • 1
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
  • 1
    Could have something to do with policy conf files in `/etc/dbus-1/` as described in the third post [here](http://developer.nokia.com/community/discussion/showthread.php/234938-QDBus-Cannot-register-Service-name-on-System-Bus). Not sure how that works on Windows. – JB0x2D1 Apr 12 '14 at 13:51
  • 1
    Maybe something in [this recent question](http://stackoverflow.com/q/23156941/1744123) could be useful for allowing everything to everybody. The author of that question tried allowing everything to all users during the course of troubleshooting that issue. Good luck – JB0x2D1 Apr 24 '14 at 01:14

1 Answers1

1

I found the answer at this link to be helpful.

From the answer provided at the link, you'll need to install dbus-launch on your running OS (Ubuntu: sudo apt-get install dbus-x11).

Running dbus-launch on terminal will startup the dbus session bus and will also print out a text of this nature on the terminal:

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-RKvgH2uzDI,guid=37cfdf614fe9c896cc8790160018b974

DBUS_SESSION_BUS_PID=18717

You will need to export the text printed on the terminal as environment variables before running your application that requires the session bus to carry out IPC.

Hope this helps.

kosmaz
  • 19
  • 1
  • 5
  • Please, do not rely on a link alone for your answer. Even if it mat be helpful at the time, it can become defunct and useless. Instead, include enough information to make your answer as self-contained as possible. – Ondrej K. Jul 21 '18 at 23:17
  • This answer only works for a very specific configuration. – Bill99 Feb 19 '23 at 20:22