Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2770802
  • 博文数量: 154
  • 博客积分: 7136
  • 博客等级: 准将
  • 技术积分: 1428
  • 用 户 组: 管理员
  • 注册时间: 2010-02-21 11:26
文章分类

全部博文(154)

文章存档

2016年(2)

2014年(2)

2013年(4)

2012年(16)

2011年(51)

2010年(68)

2009年(3)

2006年(3)

2005年(5)

分类: LINUX

2011-02-12 19:55:21

在root环境下使用gedit,报错

(gedit:5973): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported

**
GLib-GIO:ERROR:gdbusconnection.c:2270:initable_init: assertion failed: (connection->initialization_error == NULL)
Aborted (core dumped)


百度到的解决方案是:

http://blog.163.com/seven_7_one/blog/static/162606412201092204444260/

The explanation of the problem is the following:

When you su to root from a terminal where you are logged in as another user the new "su-ed" user gonna inherit the environment variables from the parent shell user.

Example: let's say that for the user jack the DBUS_SESSION_BUS_ADDRESS environment variable is set to: "unix:abstract=/tmp/dbus-l5SiTFzmR8,guid=1af28c9d83400a896ef6268d4a7af59f"
Now if you open a terminal as jack and make a su to root the DBUS_SESSION_BUS_ADDRESS variable shall remain
as for the user jack. And here is the problem, exactly this specific env. variable (DBUS_SESSION_BUS_ADDRESS) generates that problem.
Gnome programs like gedit, nautilus . . . use the dbus protocol to communicate with gconf where application specific configurations are stored, and not just.
A program executed as root uses a different D-Bus session bus address compared when you execute that program as the jack user for instance. So the problem is that you switch to root, but the DBUS_SESSION_BUS_ADDRESS variable still points the the jack's dbus session bus address.

Solution:
The root user has a separate dbus session address too (located in /root/.dbus/session-bus/. . .)
So to use the root's dbus address when you are in a terminal and "su-ed" to root just clear the DBUS_SESSION_BUS_ADDRESS variable. like: export DBUS_SESSION_BUS_ADDRESS=""
A program that needs dbus communication with gconf for instance, checks that environment variable, and if it is empty it reads the dbus address from the users ~/.dbus/session-bus/ directory (the right place).
To make this permanent add the following line to the root users .bashrc file:
export DBUS_SESSION_BUS_ADDRESS=""
This means that every time when you su to root and the terminal is not a login shell (the case when you are logged in as jack and opened a terminal and executed su) the DBUS_SESSION_BUS_ADDRESS variable is cleared, so the applications gonna read the dbus address from the right place.

by the way you do not need to start a new dbus session with dbus-launch. Even if you do so but the applications still read the dbus address from the wrong place, the problem will persist.

就是在管理员用户的 .bashrc 文件尾部添加:

export DBUS_SESSION_BUS_ADDRESS=""

例如,编辑 /root/.bashrc 文件,添加一行 export DBUS_SESSION_BUS_ADDRESS=“”

另外就是使用 su - root 代替su,sudo

其区别是su sudo 使用当前用户的环境变量,su - root会使用root用户的环境变量。

另外一个:
http://yelinsen.javaeye.com/blog/811373

  1. 1. (gedit:6556): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported
  2.    2.
  3.    3. **
  4.    4. GLib-GIO:ERROR:/build/buildd/glib2.0-2.26.0/gio/gdbusconnection.c:2270:initable_init: assertion failed: (connection->initialization_error == NULL)

  5. (gedit:6556): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported

  6. **
  7. GLib-GIO:ERROR:/build/buildd/glib2.0-2.26.0/gio/gdbusconnection.c:2270:initable_init: assertion failed: (connection->initialization_error == NULL)


原因:su与su -命令的差别:

su   只能切换到管理员用户权限,不使用管理员的登陆脚本和搜索路径
su - 不但能切换到管理员权限而且使用管理员登陆脚本和搜索路径

实例:

$pwd
/home/Yewanth (当前用户目录)
$su #pwd                  (再次查看路径)
/home/Yewanth (还是当前用户目录)

但是如果换成su -的话结果如下:
$pwd
/home/Yewanth (当前用户目录)
$su - #pwd                    (再次查看路径)
/root                   (切换到超级用户目录)
阅读(3652) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

send_linux2011-11-04 15:06:52

unixlinuxsys: [ibm@thinkpad ~]$ dbus-launch gedit /abcd/defg即可.....
谢谢了,呵呵

unixlinuxsys2011-11-01 22:23:57

[ibm@thinkpad ~]$ dbus-launch gedit /abcd/defg即可