Mini Shell
3
C��e� � @ sx d Z ddlZejdd� ddlmZ ddlZddlmZ ddlm Z G dd � d e
�ZG d
d� de�Zdd
� Z
dd� ZdS )z?Module providing thread-safe and mainloop-safe DBus operations.� N�Gioz2.0)r )�GError)�DEFAULT_DBUS_TIMEOUTc @ s e Zd ZdZdS )�
SafeDBusErrorz,Class for exceptions defined in this module.N)�__name__�
__module__�__qualname__�__doc__� r
r
�!/usr/lib64/python3.6/safe_dbus.pyr s r c @ s e Zd ZdZdS )�
DBusCallErrorz:Class for the errors related to calling methods over DBus.N)r r r r r
r
r
r r % s r c C s� d} dt jkr*t j� } t jtt jd �� zdy.tjjtjtj j
d�tjjtjj
B dd�}W n0 tk
r� } ztdj|���W Y dd}~X nX W d| dk r�t j| � X |j� r�td��|S )a�
Get a connection handle for the per-user-login-session message bus.
!!! RUN THIS EARLY !!! like, before any other threads start. Connections to
the session bus must be made with the effective UID of the login user,
which in live installs is not the UID of anaconda. This means we need to
call seteuid in this method, and doing that after threads have started will
probably do something weird.
Live installs use consolehelper to run as root, which sets the original
UID in $USERHELPER_UID.
:return: the session connection handle
:rtype: Gio.DBusConnection
:raise DBusCallError: if some DBus related error appears
:raise OSError: if unable to set the effective UID
NZUSERHELPER_UIDz$Unable to connect to session bus: {}zConnection is closed)�os�environ�geteuid�seteuid�intr ZDBusConnectionZnew_for_address_syncZdbus_address_get_for_bus_syncZBusTypeZSESSIONZDBusConnectionFlagsZAUTHENTICATION_CLIENTZMESSAGE_BUS_CONNECTIONr r �format� is_closed)Zold_euid�
connection�gerrr
r
r �get_new_session_connection+ s"