Current Path : /usr/lib/python2.7/dist-packages/landscape/ui/lib/ |
Current File : //usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyc |
ó ÍÿŠTc @ sc d d l Z d d l Z d d l Z d d l m Z d Z d e j j f d „ ƒ YZ d „ Z d S( iÿÿÿÿN( t GObjects/ com.canonical.LandscapeClientSettings.configuret PolicyKitMechanismc B sA e Z d Z e d d „ Z d „ Z d „ Z d „ Z d „ Z RS( sÉ L{PolicyKitMechanism} is a specialised L{dbus.service.Object} which provides PolicyKit authorization checks for a provided DBus bus name and object path. Subclasses must therefore call l{__init__} here with their object path, bus name and an error class to be raised when permission escalation fails. @type object_path: string @param object_path: The object path to register the subclass with. @type bus_name: dbus.service.BusName @param bus_name: The L{BusName} to the register the subclass with. @type permission_error: dbus.DBusException @param permission_error: A L{dbus.DBusException} to be raised when PolicyKit authorisation fails for the client. c C sD t t | ƒ j | | | ƒ | | _ d | _ d | _ | | _ d S( N( t superR t __init__t permission_errort Nonet dbus_infot polkitt bypass( t selft object_patht bus_nameR R t conn( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyR s c C s¼ | j r t d d f St j t j ƒ j d d t ƒ d ƒ } d i t j | d d ƒd 6t j d d d ƒd 6f } | } i d d 6} t j d ƒ } d } | j | | | | | d d ƒS( sô Check that the process with id L{pid} is allowed, by policy to utilise the L{privilege }. If the class was initialised with L{bypass}=True then just say it was authorised without checking (useful for testing). t Bypasss org.freedesktop.PolicyKit1s% /org/freedesktop/PolicyKit1/Authoritys$ org.freedesktop.PolicyKit1.Authoritys unix-processt variant_leveli t pidi s start-timet t timeouti N( R t TrueR t dbust Interfacet SystemBust get_objectt Falset UInt32t UInt64t CheckAuthorization( R R t privilegeR t subjectt action_idt detailst flagst cancellation_id( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt _get_polkit_authorization% s( c C sF | j d k r6 t j | j d d t ƒ d ƒ | _ n | j j | ƒ S( s6 Get the process ID of the L{sender}. s org.freedesktop.DBuss /org/freedesktop/DBus/BusN( R R R R R R t GetConnectionUnixProcessID( R t senderR ( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt _get_peer_pid@ s c C s | d k o | d k S( sX Check if this is a local call, implying it is within a secure context. N( R ( R R# R ( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt _is_local_callJ s c C s_ | j | | ƒ r t S| j | | ƒ } | j | | ƒ \ } } } | s[ | j | ƒ ‚ n t S( s@ Check if we are already in a secure context, and if not check if the policy associated with L{privilege} both exists and allows the peer to utilise it. As a side effect, if escalation of privileges is required then this will occur and a challenge will be generated if needs be. ( R% R R$ R! R ( R R# R R t peer_pidt is_autht _R ( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt _is_allowed_by_policyP s N( t __name__t __module__t __doc__R R R R! R$ R% R) ( ( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyR s c C s t j ƒ } | j ƒ d S( sG Invoke a L{gobject.MainLoop} to process incoming DBus events. N( R t MainLoopt run( t mainloop( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt listena s ( R t dbus.servicet dbus.glibt gi.repositoryR t POLICY_NAMEt servicet ObjectR R0 ( ( ( s; /usr/lib/python2.7/dist-packages/landscape/ui/lib/polkit.pyt <module> s V