Session Bus vs. System Bus

Jehne, Dennis jehne at 4com.de
Wed Jul 12 07:40:03 PDT 2006


 
Please forget the attachment from my last mail. This was included during my debugging of todays problems as I thought it might be helpful together with my description. But I found it by myself.
Thank you and regards,
Dennis Jehne

-----Ursprüngliche Nachricht-----
Von: dbus-bounces at lists.freedesktop.org [mailto:dbus-bounces at lists.freedesktop.org] Im Auftrag von Jehne, Dennis
Gesendet: Mittwoch, 12. Juli 2006 16:36
An: Havoc Pennington
Cc: dbus at lists.freedesktop.org
Betreff: AW: Session Bus vs. System Bus

 
Hello all, hello Havoc,
Many thanks for the rebuild hint.
I´ve done that and the error is gone. 
But as you wrote, I got another error now unfortunately and I would like to explain this as some strange stuff happens.
	
After starting the system bus
[root at localhost tools]# dbus-daemon-1 --system) I start dbus-monitor again (in a different shell/session) and get the error

[root at localhost tools]# ./dbus-monitor --system Failed to open connection to system message bus: No reply within specified time

I have found a mail in the archive (http://lists.freedesktop.org/archives/dbus/2006-June/005052.html) and I have tried this out.

I have executed in my shell the first line "dbus-daemon --system --print-address >/tmp/output 2>&1 &" and did a tail on the output file.
Then I have set the "DBUS_SESSION_BUS_ADDRESS=[above address] bash" in the same shell where I have started the system bus and started dbus-monitor in a different shell which was already open. 
Guess what, dbus-monitor started and printed out first infos. 

As I have started in my first attempt "dbus-daemon-1 --system" instead of "dbus-daemon --system" as written in the mail, I guess my problem lies in the "..daemon-1". This seems to be the daemon coming with the rpm/dep as far as I underastand it. And as this daemon uses a different conf file, I believe this explains the error. Here is my output:

[root at localhost tools]# ps aux | grep bus
root      2643  0.0  0.1  4616  620 pts/0    R+   14:02   0:00 grep bus
[root at localhost tools]# dbus-daemon --system --print-address >/tmp/output 2>&1 & [1] 2644 [root at localhost tools]# tail /tmp/output unix:path=/var/run/dbus/system_bus_socket,guid=0be5b444d9a6cb253819a379a8daa900
[1]+  Done                    dbus-daemon --system --print-address >/tmp/output 2>&1
[root at localhost tools]# ps aux | grep bus
501       2645  0.0  0.2  3168  948 ?        Ss   14:03   0:00 dbus-daemon --system --print-address
root      2648  0.0  0.1  5276  620 pts/0    R+   14:03   0:00 grep bus
[root at localhost tools]# DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket,guid=0be5b444d9a6cb253819a379a8daa900 bash [root at localhost tools]# [root at localhost tools]# echo $DBUS_SESSION_BUS_ADDRESS unix:path=/var/run/dbus/system_bus_socket,guid=0be5b444d9a6cb253819a379a8daa900
[root at localhost tools]#
[root at localhost tools]# ./dbus-monitor --system signal sender=org.freedesktop.DBus -> dest=:1.0 interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.0"
......
This tells me that is seems to be crucial to set and export (?) the env var DBUS_SESSION_BUS_ADDRESS after the system bus has started. Is that right? 

Then I went to lunch and tried this stuff exactly again and now I wasn´t able to connect dbus_monitor again to the system bus. I got again the "No reply within specified time" error. Well I have searched if there was anything I made different but could not find something. What I have tried then was, I did change the <user> entry in the session.conf from "messagebus" to "root" and it works again. 

But I´m wondering why it was working in the first attempt with the messagebus user 501. I have also started the monitor as root. (see above) Can you explain this? What did I wrong?

If setting the env var DBUS_SESSION_BUS_ADDRESS is so important, is there a script doing all this alltogether during startup? I have found dbus-launch but haven´t tried it out yet. Is that maybe a way where I just start it and it does all I do at the mometn step by step? Or do I need to write one myself? I also get the info that the message.pid still excists adn I need to kill it. This would be also a step to automate.

Ok, so then I have started my testapp which calls "dbus_details->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);" and I get the following:

[root at localhost debug]# ./dbusPing
Syntax: dbus-Ping [name msgSize Msg]
[root at localhost debug]# ./dbusPing test.dj.bus 500 hello Read the following: argc <4> Name <test.dj.bus> MsgSize <500> Msg<hello>
DBus: dbus_bus_get OK
Name Error (Connection ":1.1" is not allowed to own the service "test.dj.bus" due to security policies in the configuration file)
DBus: dbus_bus_request_name NOT OK
MAIN - NACH get_bus
exit in get_bus
[root at localhost debug]# ./dbusPing org.freedesktop.DBus 500 hello           
Read the following: argc <4>
Name <org.freedesktop.DBus>
MsgSize <500>
Msg<hello>
DBus: dbus_bus_get OK
Name Error (Connection ":1.2" is not allowed to own the service "org.freedesktop.DBus" due to security policies in the configuration file)
DBus: dbus_bus_request_name NOT OK
MAIN - NACH get_bus
exit in get_bus
[root at localhost debug]#


The system bus uses the /usr/local/etc/dbus-1/system.conf per default. I have found another thread which says that one should replace the policy part of the system.conf with the one in the session.conf first of all to allow everything. It seems to be some policy issue. Ok, I did that and my app could connect to the system bus so far.

But what do I need to specify in the policy that my testapps are allowed to own selfmade services?
The policy out of the session.conf allows everything, so I might start "firewalling" from scratch and try out different policy entries. Or do you have a better way for me?

Thanks a lot for your help in advance and best regards, Dennis Jehne



-----Ursprüngliche Nachricht-----
Von: Havoc Pennington [mailto:hp at redhat.com]
Gesendet: Mittwoch, 12. Juli 2006 07:14
An: Jehne, Dennis
Cc: dbus at lists.freedesktop.org
Betreff: Re: Session Bus vs. System Bus

Jehne, Dennis wrote:
> [root at localhost tools]# ./dbus-monitor --system Failed to open 
> connection to system message bus: Failed to connect to socket
> /usr/local/var/run/dbus/system_bus_socket: No such file or directory

If you fully rebuilt dbus with --localstatedir=/var there's no way you'll get this error... if you're still getting it after that, then something is not rebuilt, or not reinstalled, or not restarted, or not deleted.

If you're getting a different error now then let us know what it is.

Replacing the system bus on a system that already has an rpm/deb packaged system bus I would consider a plenty advanced thing to do though... it's not something I'd mess with if you can help it. If possible, replacing the rpm/deb with a new one would be a lot better than trying to somehow overwrite the rpm/deb stuff with a tarball build.

Havoc
_______________________________________________
dbus mailing list
dbus at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus


More information about the dbus mailing list