![无法设置共享文件夹](https://linux22.com/image/1128391/%E6%97%A0%E6%B3%95%E8%AE%BE%E7%BD%AE%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6%E5%A4%B9.png)
我在 Xubuntu 14.04.2 LTS 上运行。尝试通过 shares-admin 和 system-config-samba 应用程序在网络上共享文件夹,但它们给出了错误。
命令
sudo 共享-管理员
输出:
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
(shares-admin:11220): Gtk-WARNING **: cannot open display:
命令
sudo 系统配置-samba
输出:
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/share/system-config-samba/mainWindow.py:62: Warning: invalid (NULL) pointer instance
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: Warning: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: GtkWarning: IA__gtk_settings_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: Warning: g_object_get: assertion 'G_IS_OBJECT (object)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: GtkWarning: IA__gdk_pango_context_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_context_set_font_description: assertion 'context != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_context_set_base_dir: assertion 'context != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_context_set_language: assertion 'context != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_layout_new: assertion 'context != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_layout_set_attributes: assertion 'layout != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_layout_set_text: assertion 'layout != NULL' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: PangoWarning: pango_layout_get_unknown_glyphs_count: assertion 'PANGO_IS_LAYOUT (layout)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: Warning: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: Warning: value "TRUE" of type 'gboolean' is invalid or out of range for property 'visible' of type 'gboolean'
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: GtkWarning: IA__gdk_screen_get_display: assertion 'GDK_IS_SCREEN (screen)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
/usr/share/system-config-samba/mainWindow.py:62: GtkWarning: IA__gdk_keymap_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
self.xml = gtk.glade.XML ("/usr/share/system-config-samba/system-config-samba.glade", domain="system-config-samba")
知道哪里出了问题吗?
答案1
经过一些谷歌搜索后我找到了这个解决方案:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY shares-admin
它将所需的环境变量传递给新的隔离环境。由于 root 在其环境中没有 DISPLAY 和 XAUTHORITY 变量,因此用户必须在 root 使用任何依赖于 GUI 的应用程序之前传递它。
(现在我开始思考当 sudo 调用时如何使它们永久存在......)
答案2
另一个解决方案是
sudo apt-get install gksu
gksu-properties
将身份验证模式设置为 sudo 并将抓取模式设置为启用