Session dbus from root
-
Hi, I'm trying to use a QContactManager from a daemon on Maemo, which fails.
I have been told I have to make sure the session dbus are initialized to use the user's session dbus, but how do I do that ?
I have read I have to set the environment variable DBUS_SESSION_BUS_ADDRESS to the address on the user's session dbus, and I'm fairly sure it is set to the value found in /tmp/session_bus_address.user (I'm logging the value from my program and it looks right) but still my program fails the moment I try to access the address book.
The following are logged in syslog :
GLIB WARNING ** mc-client - Unrecognized presence
online' GLIB MESSAGE libosso-abook - osso-abook-aggregator.c:2220: EBook error 8 on file:///root/.osso-abook/db GLIB WARNING ** GLib-GObject - invalid (NULL) pointer instance GLIB CRITICAL ** GLib-GObject - g_signal_connect_data: assertion
G_TYPE_CHECK_INSTANCE (instance)' failed
GLIB CRITICAL ** Gdk - gdk_pango_context_get_for_screen: assertionGDK_IS_SCREEN (screen)' failed GLIB CRITICAL ** Pango - pango_context_set_font_description: assertion
context != NULL' failedCan anyone tell me how to initialize the session dbus correctly ?
Thanks.
Kim
-
Hi Kim,
It looks like osso-abook-aggregator.c is trying to open the file /root/.osso-abook/db, whereas it probably should open the file /home/user/.osso-abook/db (if the normal user is named "user"). Although I might be wrong. Are you able to set $HOME to /home/user temporarily? Or maybe there's a better way to do it -- but I don't think that the problem you're seeing is related to DBUS specifically (maybe I'm wrong).
Cheers,
Chris. -
Hi Chris
Unfortunately that didn't do anything :
Log from my program (started as root) :
DBUS_SESSION_BUS_ADDRESS = unix:abstract=/tmp/dbus-iYWiqWAGpx,guid=36b2abf727d8f3e6044e57590000000f
PATH = /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
HOME = /home/userLog from my program (started as user) :
DBUS_SESSION_BUS_ADDRESS = unix:abstract=/tmp/dbus-iYWiqWAGpx,guid=36b2abf727d8f3e6044e57590000000f
PATH = /usr/bin:/bin
HOME = /home/userAnd still the program exits the moment I try to create an instance of QContactManager as root, syslog :
@
callloggerd[3243]: GLIB WARNING ** mc-client - Unrecognized presence `online'
e-addressbook-factory[1096]: GLIB WARNING ** eds/file - e_book_backend_file_setup_db_env at e-book-backend-file.c:1814: cannot create dir '/root/.osso-abook/db': Permission denied
e-addressbook-factory[1096]: GLIB WARNING ** eds/file - e_book_backend_file_load_source at e-book-backend-file.c:2010: cannot setup db_env to /root/.osso-abook/db
callloggerd[3243]: GLIB MESSAGE libosso-abook - osso-abook-aggregator.c:2220: EBook error 20 on file:///root/.osso-abook/db
callloggerd[3243]: GLIB WARNING ** GLib-GObject - invalid (NULL) pointer instance
@
and so on ...Kim
[edit: syslog output fixed / Denis Kormalev]
-
Hi Kim,
Yeah, I'm not sure how to work around this issue. The problem appears to be as I said: the platform libraries are attempting to open up (or create) a contact database in the /root/ directory instead of /home/user/. I can only imagine that it is using some environment variable for that, but I'm not entirely certain. If it wasn't $HOME then perhaps something else?
So in short, I don't know what the solution is, but the problem is clear - the lower level platform is detecting that the current user is root, and detecting the home directory of root to be something other than what you specified in $HOME environment variable, it seems. If you can work around that problem somehow (by figuring out how it detects the home directory of the user, and spoofing that to be the normal user) then you should have solved the problem.
Cheers,
Chris. -
Hi Chris
Thanks for your input, it did push me in the right direction.
First I changed my program to dump the entire environment to the log file, and ran it from root and user, and found that the environments had almost nothing in common !
It couldn't be true I had to reconstruct everything to run as a daemon, so I went back to the old drawing board.
Maybe the solution was to somehow run the daemon in 'user space' (funny enough this is where everything started, until someone over at maemo.org suggested the dbus to be my problem).
After a lot of reading on the 'net, I found the solution.
In my event.d script I changed the start script to :
su -c 'my daemon' -l user
And now everything is working like a dream ;)
Thanks a lot.
Kim