Среда, 25.04.2018, 07:10
Приветствую Вас Гость | RSS
Мой сайт
Форма входа

Меню сайта

Категории раздела
Об ОС Windows [137]
В категории размещаются статьи, касающщиеся операционных систем от Microsoft.
Об ОС *Nix [198]
В данной категории собраны статьи об ОС семейства Unix/Linux/FreeBSD/...
Справочные материалы [351]
Справка по всему разделу.
Виртуализация и Облака [46]
Networks & Routing [86]
DataBases [22]

Наш опрос
Оцените мой сайт
Всего ответов: 197


Онлайн всего: 1
Гостей: 1
Пользователей: 0

Главная » Статьи » Системное администрирование » Об ОС *Nix

How can I make a fake "active session”



I've automated my Ubuntu installation - I've got
Python code that runs automatically (after a clean install, but before
the first user login - it's in a temporary /etc/init.d/ script) that
sets up everything from Apache & its configuration to my personal
Gnome preferences. It's the latter that's giving me trouble.

This worked fine in Ubuntu 8.04 (Hardy), but when I use this with
8.10 (Intrepid), the first time I try to access gconf, I get this

Failed to contact configuration server; some possible causes are that
you need to enable TCP/IP networking for ORBit, or you have stale NFS
locks due to a system crash. See http://www.gnome.org/projects/gconf/
for information. (Details - 1: Not running within active

Yes, right, there's no Gnome session when this is running, because
the user hasn't logged in yet - however, this worked before; this
appears to be new with Intrepid's Gnome (2.24?).

Short of modifying the gconf's XML files directly, is there a way to
make some sort of proxy Gnome session? Or, any other suggestions?

(More details: this is python code that runs as root, but setuid's
& setgid's to be me before setting my preferences using the "gconf"
module from the python-gconf package.)


3 Answers


I can reproduce this by installing
GConf 2.24 on my machine. GConf 2.22 works fine, but 2.24 breaks it.

GConf is failing to launch because D-Bus is not running. Manually
spawning D-Bus and the GConf daemon makes this work again.

I tried to spawn the D-Bus session bus by doing the following:

import dbus
= dbus.SessionBus()

...but got this:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.

Weird. Looks like it doesn't like to come up if X isn't running. To
work around that, start dbus-launch manually (IIRC use the os.system() call):

$ dbus-launch 

You'll need to parse the output somehow and inject them into
environment variables (you'll probably want to use os.putenv). For my testing, I just used the shell,
and set the environment vars manually with export
, etc.

Next, you need to launch gconftool-2 --spawn with those
environment variables you received from dbus-launch. This
will launch the GConf daemon. If the D-Bus environment vars are not set,
the daemon will not launch.

Then, run your GConf code. Provided you set the D-Bus session bus
environment variables for your own script, you will now be able to
communicate with the GConf daemon.

I know it's complicated.

gconftool-2 provides a --direct option that
enables you to set GConf variables without needing to communicate with
the server, but I haven't been able to find an equivalent option for the
Python bindings (short of outputting XML manually).

Edit: For future reference, if anybody wants to run dbus-launch
from within a normal bash script (as opposed to a Python
script, as this thread is discussing), it is quite easy to retrieve the
session bus address for use within the script:


eval `dbus-launch --sh-syntax`




Got the same issue, setting those
DBUS vars made gconf start again. Thanks!

For reference, problems started when evolution task list disappreared.
– iElectric Apr 13 at 8:38


Well, I think I understand the
question. Looks like your script just needs to start the dbus daemon, or
make sure its started. I believe "session" here refers to a dbus
session. (here is some evidence), not a Gnome session. Dbus
and gconf both run fine without Gnome.

Either way, faking an "active session" sounds like a pretty bad idea.
It would only look for it if it needed it.

Perhaps we could see the script in a pastebin? I should have really
seen it before making any comment.



Thanks, Ali & Jeremy - both
your answers were a big help. I'm still working on this (though I've
stopped for the evening).

First, I took the hint from Ali and was trying part of Jeremy's
suggestion: I was using dbus-launch to run "gconftool-2 --spawn". It
didn't work for me; I now understand why (thx, Jeremy) -- I was trying
to use gconf from within the same python program that was launching dbus
& gconftool, but its environment didn't have the environment
variables - duh.

I set that strategy aside when I noticed gconftool-2's --direct
option; internally, gconftool-2 is using API that isn't exposed by the
gconf python bindings. So, I modified python-gconf to expose the extra
method, and once that builds (I had some unrelated problems getting this
to work), we'll see if that fixes things - if it doesn't (and maybe if
it does, because building those bindings seems to build all of gnome!),
I'll find a better way to manage the environment variables in that first

(I'll add another answer here tomorrow either way)

And it's the next day: I ran into a little trouble with my modified
python-gconf, which inspired me to try Jeremy's simpler idea, which
worked fine - before doing the first gconf operation, I simply ran
"dbus-launch", parsed the resulting name-value pairs, and added them
directly to python's environment. Having done that, I ran "gconftool-2
--spawn". Problem solved.

Источник: http://stackoverflow.com/questions/257658/how-can-i-make-a-fake-active-session-for-gconf

Категория: Об ОС *Nix | Добавил: admin (24.05.2010)
Просмотров: 14589 | Комментарии: 1 | Рейтинг: 0.0/0
Всего комментариев: 1
In Houston, Texas: Jed's Wayne crowe (Jadeveon Clowney), defensive end front, university of south Carolina Has twice Su Tongchang will wait until your body in the best squad will to prepare to participate in team training. http://www.vipcheapjerseys.com/ - Wholesale nfl jerseys Despite the question the ability of Smith, namath said he never considered the jets will sign a choice in the 18th of the draft Johnny, hazel. NFL teams in the offseason to "team activities are in full swing, media reporters in the training of the cavalry scene saw an interesting scene: Peyton Manning - (Peyton Manning) and dmanisi, Thomas (Demaryius Thomas) each holding a green football in his hand. Congratulations, rookie fatigue has become this year's draft top! Congratulations texans also choose by the best rookie of the year, so far as to say he is one of the best rookie in recent ten years, he joined can let the texans defense burgeoning class, http://www.vipcheapjerseys.com/ - Cheap nfl jerseys the SEC double-digit contribution first round rookie. In front at the university of Missouri Sam is the defensive end but he 1 meter 88,

Имя *:
Email *:
Код *:

Друзья сайта
  • Официальный блог
  • Сообщество uCoz
  • FAQ по системе
  • Инструкции для uCoz

  • Copyright MyCorp © 2018