ó J¡Vc@s¾ddlZddlZddlZddlTddlTddlmZmZddlm Z ddl Z ddl Z e rddl mZn ddlZddlZejdeƒde jfd „ƒYZd e jfd „ƒYZd e jfd „ƒYZdZdZd„Zdd„Zdefd„ƒYZde jjfd„ƒYZ ej!e"j#ddƒƒr‰de fd„ƒYZ$ndefd„ƒYZ%e&e'e(d„Z)d„Z*dS(iÿÿÿÿNi(t*(tutilstpassword(t pluginhandler(t_gobjecttignoretAccessDeniedExceptioncBseZdZRS(s"com.hp.hplip.AccessDeniedException(t__name__t __module__t_dbus_error_name(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR0stUnsupportedExceptioncBseZdZRS(s!com.hp.hplip.UnsupportedException(RRR (((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR 3st UsageErrorcBseZdZRS(scom.hp.hplip.UsageError(RRR (((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR 6ss com.hp.hplipscom.hp.hplip.installplugincCs tjƒS(N(tdbust SystemBus(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytget_service_bus>scCs@|stƒ}n|jtjdƒ}tj|tjƒ}|S(Nt/(Rt get_objecttBackendServicet SERVICE_NAMER t InterfacetINTERFACE_NAME(tbustservice((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyt get_serviceBs  tPolicyKitAuthenticationcBsSeZd„Zdd„Zdd„Zd„ZeeƒZd„Z ee ƒZ RS(cCs)tt|ƒjƒd|_d|_dS(N(tsuperRt__init__tNonetpkittauth(tself((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRLs cCsc|dkrtjƒ}ntj|ƒ}|jj||tƒ}tj d||fƒ|dkS(Nsis_authorized(%s) = %rtyes( RtostgetpidR tUInt32t policy_kittIsProcessAuthorizedtFalsetlogtdebug(Rt action_idtpidt authorized((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyt is_authorizedRs  cCs|j|ƒrtS|r+|jƒjjp.d}tj|ƒtjtjƒƒ}}|j j |||ƒ}t j d||fƒt |ƒS(Nisobtain_authorization(%s) = %r(R+tTruet get_topleveltwindowtxidR R"R R!t auth_agenttObtainAuthorizationR&R'tbool(RR(twidgetR/R)tgranted((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytobtain_authorization^s%cCsD|jr|jStjƒjddƒ}tj|dƒ|_|jS(Nsorg.freedesktop.PolicyKitR(RR R RR(RR((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytget_policy_kitks  cCs2|jr|jStjƒjddƒ|_|jS(Ns-org.freedesktop.PolicyKit.AuthenticationAgentR(RR t SessionBusR(R((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytget_auth_agentvs   N( RRRRR+R5R6tpropertyR#R8R0(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRKs    tPolicyKitServicecBs eZed„Zed„ZRS(c CsG|s"tjdƒtdƒ‚nyÉtƒ}tjƒ}|jddƒ}tj|dƒ}tj|j |ƒƒ}|j ||ƒ}|sªtjdƒtdƒ‚n|j j ||t ƒ}|dkrêtjdƒtdƒ‚nWnUtk rtjdƒ‚n5tjk rB}tjd|ƒt|jƒ‚nXdS( Ns#Session not authorized by PolicyKitsorg.freedesktop.DBusRs#Process not authorized by PolicyKitRs-Session not authorized by PolicyKit version 0RsAccessDeniedException %r(R&terrorRRR R RRR"tGetConnectionUnixProcessIDR+R#tIsSystemBusNameAuthorizedR%twarningt DBusExceptiontmessage( Rtsendertactiont policy_authRt dbus_objectR)R4tex((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytcheck_permission_v0ƒs2          c Csë| s| r*tjdƒtdƒ‚ntjƒ}|jdddƒ}tj|dƒ}ditj|ddƒd6f}id d 6}tjdƒ} d } |j |||| | ƒ\} } }| sçtjd ƒtdƒ‚n| S( Ns#Session not authorized by PolicyKitsorg.freedesktop.PolicyKit1s%/org/freedesktop/PolicyKit1/Authoritys$org.freedesktop.PolicyKit1.Authorityssystem-bus-namet variant_levelitnamets-Session not authorized by PolicyKit version 1( R&R;RR R RRtStringR"tCheckAuthorization( RRAt connectionRBt system_bustobjR#tsubjecttdetailstflagst cancel_idtoktnotused((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytcheck_permission_v1¦s,       (RRtPOLICY_KIT_ACTIONRFRU(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR:‚s #t configures policy-kitRc Bs§eZdZdZddd„Zdd„Zejj deddddd d d d ƒddd „ƒZ ejj deddddd d d d ƒddd„ƒZ RS(s com.hp.hplipRcCsu|dkrtƒ}ntt|ƒj||ƒtjj|j|ƒ|_ t j ƒ|_ d|_ tjdƒdS(NiR'(RRRRRR RtBusNameRRHtgobjecttMainLooptlooptversionR&t set_level(RRLtpath((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRËs   cCs`|dkr5tƒ}|dkr5tjdƒdSn||_tjd|ƒ|jjƒdS(Ns/Unable to determine installed PolicyKit versions+Starting back-end service loop (version %d)(Rtpolicykit_versionR&R;R\R'R[trun(RR\((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR`Ös     tdbus_interfacet in_signaturetst out_signaturetbtsender_keywordRAtconnection_keywordRLcCs |jdkrNy|j|tƒWq‘tk rJ}tjd|ƒtSXnC|jdkry|j||tƒs‘tSntjd|jƒtStjd|ƒyddl m }Wn!t k rÙ}tjdƒtSX|j ƒ}|j |ƒstjd ƒtStS( Nis3installPlugin: Failed due to permission error [%s]is+installPlugin: invalid PolicyKit version %ds#installPlugin: installing from '%s'iÿÿÿÿ(RsFailed to Import pluginhandlersPlugin installation failed(R\RFtINSTALL_PLUGIN_ACTIONRR&R;R%RUR't installerRt ImportErrort PluginHandlet copyFilesR,(Rtsrc_dirRARLteRt pluginObj((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyt installPluginãs0     cCstjdƒ|jjƒtS(NsStopping backend service(R&R'R[tquitR,(RtargRARL((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytshutdowns  N( RRRRRRR`R RtmethodRpRs(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRÇs  ! t PolicyKitcBs&eZdd„Zd„Zd„ZRS(cCs„|dkr5tƒ}|dkr5tjdƒdSntjƒ|_|jjtdƒ|_ tj |j dtƒ|_ ||_ dS(Ns/Unable to determine installed PolicyKit versionRRa( RR_R&R'R R RRRVRNRtifaceR\(RR\((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRs    cCs|jdkr@tƒ}|jtƒs@|jtƒs=dSq@ny|jj|ƒ}|SWn.tj k rŠ}t j dt |ƒƒt SXdS(NisinstallPlugin: %s(R\RR+RhR5RRvRpR R?R&R'tstrR%(RRmRRSRn((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRp!s  cCs|jdkr@tƒ}|jtƒs@|jtƒs=dSq@ny|jjdƒ}|SWn.tj k rŠ}t j dt |ƒƒt SXdS(NiRIs shutdown: %s(R\RR+RhR5RRvRsR R?R&R'RwR%(RRRSRn((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRs0s  N(RRRRRpRs(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyRus c Csätjtjddƒƒrny&tƒ}d}t}tjdƒWqntj k rj}tj d|ƒqnXnd}|sƒd}ntj dƒr›d}nd }d |||f} tjd| ƒt j | ƒ} | d ktfS( NRWs policy-kits%ss"Using PolicyKit for authentications5PolicyKit NOT installed when configured for use. [%s]s --requireds --optionals hp-pluginspython ./plugin.pys%s -u %s --reason %si(Rtto_booltsys_conftgetRuR%R&R'R R?R;twhichtos_utilstexecuteR,( trequiredt plugin_reasontModeRNtsu_sudot need_sudoREtreqtp_pathtcmdtstatus((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pytrun_plugin_commandBs$   cCs4tjjdƒrdStjjdƒr,dSdSdS(Ns/usr/share/polkit-1is/usr/share/PolicyKiti(R R^tisdirR(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyR_]s (+R tos.pathtsystgtcodesRIRRRiRR t dbus.servicetPY3tgiRRYtwarningst simplefiltertDeprecationWarningR?RR R RVRhRRRtobjectRRtObjectR:RxRyRzRRuR,tPLUGIN_REASON_NONEtGUI_MODER‡R_(((sY/builds/ul11u3sru-gate/components/hplip/build/prototype/i386/usr/share/hplip/base/pkit.pyts6           7DM.