^c@s=ddlZddlZddlZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdejfd YZd efd YZd efd YZdefdYZdejfdYZdZdZdZ da!dZ"ddCdYZ#dZ$dZ%dZ&dZ'da)dZ*de#fdYZ+de#fd YZ,d!e,fd"YZ-d#Z.dZ/d$Z0dZ1dZ2dZ3dZ4dZ5dZ6d%Z7d&Z8d'efd(YZ9d)efd*YZ:d+dDd,YZ;d-e;e+fd.YZ<d/e;e,fd0YZ=d1e;e-fd2YZ>d3e+fd4YZ?d5e,fd6YZ@d7e#fd8YZAd9dEd:YZBd;eBfd<YZCd=eBfd>YZDd?ZEd@ZFdAZGdBZHdS(FiNiiiiiitPackercBs,eZdZdZdZdZRS(cCs*|\}}|j||j|dS(N(t pack_enumt pack_opaque(tselftauthtflavortstuff((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_auth0s  cCsi|j||j||j||j||jt|x|D]}|j|qNWdS(N(t pack_uintt pack_stringtlen(Rtstampt machinenametuidtgidtgidsti((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_auth_unix5s     cCsl|j||jt|jt|j||j||j||j||j|dS(N(RRtCALLt RPCVERSIONR(Rtxidtprogtverstproctcredtverf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_callheader>s       cCsE|j||jt|jt|j||jtdS(N(RRtREPLYt MSG_ACCEPTEDRtSUCCESS(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_replyheaderIs     (t__name__t __module__RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s  t BadRPCFormatcBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR!Sst BadRPCVersioncBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR"Tst GarbageArgscBseZRS((RR (((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR#UstUnpackercBs#eZdZdZdZRS(cCs"|j}|j}||fS(N(t unpack_enumt unpack_opaque(RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unpack_authYs  cCs|j}|j}|tkr7td|fn|j}|tkrbtd|fn|j}|j}|j}|j}|j}||||||fS(Nsno CALL but %rsbad RPC version %r(t unpack_uintR%RR!RR"R'(RRttempRRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_callheader^s          cCs|j}|j}|tkr7td|fn|j}|tkr|j}|tkr|j}|j}td||ffn|tkr|j}td|fntd|fn|tkrtd|fn|j}|j}|t kr%tdn|t krb|j}|j}td||ffn|t krztdn|t krtd n|t krtd |fn||fS( Nsno REPLY but %rsMSG_DENIED: RPC_MISMATCH: %rsMSG_DENIED: AUTH_ERROR: %rsMSG_DENIED: %rs'Neither MSG_DENIED nor MSG_ACCEPTED: %rscall failed: PROG_UNAVAILscall failed: PROG_MISMATCH: %rscall failed: PROC_UNAVAILscall failed: GARBAGE_ARGSscall failed: %r(R(R%Rt RuntimeErrort MSG_DENIEDt RPC_MISMATCHt AUTH_ERRORRR't PROG_UNAVAILt PROG_MISMATCHt PROC_UNAVAILt GARBAGE_ARGSR(RRtmtypetstattlowthighR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_replyheadernsH                        (RR R'R*R7(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$Ws  cCsdS(Nt((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_nullscCs,t}|j||||||jS(N(RRtget_buf(tseedthostR Rtgroupstp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unixs cCsy,ddlm}m}|}|}Wntk rId}}nXddl}tt|jttj ||gS(Ni(tgetuidtgetgidi( tosR@RAt ImportErrorttimeR?tintt unix_epochtsockett gethostname(R@RAR RRD((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytmake_auth_unix_defaults    c CstdkrtSddl}|j}|j|}|j|}|j||j|}d \}}}}} } t| |d\}} t| |d\}} t||d\}}||}|j||||| | dddf adG|jtGHtS( s9Very painful calculation of when the Unix Epoch is. This is defined as the return value of time.time() on Jan 1st, 1970, 00:00:00 GMT. On a Unix system, this should always return 0.0. On a Mac, the calculations are needed -- and hard because of integer overflow and other limitations. iiNiii<is Unix epoch:(iiiiii(t _unix_epochRDt localtimetgmtimetmktimetdivmodtctime( RDtnowtlocalttgmttoffsettytmtdthhtmmtss((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRFs    *tClientcBsteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( cCsk||_||_||_||_|j|j|jd|_|jd|_ d|_ dS(Ni( R<RRtportt makesockett bindsockett connsockettlastxidt addpackerstNoneRR(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt__init__s          cCs|jjdS(N(tsocktclose(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRdscCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RctconnectR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs|jjddS(NR8i(R8i(Rctbind(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RtpackerR$tunpacker(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCsw|dkr$|dk r$tdn|j||rD||n|j|r`|}nd}|jj|S(Ns!non-null args with null pack_func(Rat TypeErrort start_calltdo_callRhtdone(RRtargst pack_funct unpack_functresult((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt make_calls      cCse|jd|_}|j}|j}|j}|j|j||j|j|||dS(Ni(R_tmkcredtmkverfRgtresetRRR(RRRRRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjs     cCs tddS(Nsdo_call not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkscCs+|jdkr$ttf|_n|jS(N(RRat AUTH_NULLR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRr scCs+|jdkr$ttf|_n|jS(N(RRaRuR9(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRsscCs|jddddS(Ni(RqRa(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_0s(RR RbRdR\R^R]R`RqRjRkRrRsRv(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs         cCst|}|r|dB}ntt|d?d@tt|d?d@tt|d?d@tt|d@}|j||dS(Nliiii(R tchrREtsend(Rctlasttfragtxtheader((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytsendfrags   ^cCst|d|dS(Ni(R}(Rctrecord((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt sendrecord"scCs|jd}t|dkr*tntt|dd>t|dd>Bt|dd>Bt|dB}|d @dk}t|d @}d }xH|dkr|j|}|stn|t|}||}qW||fS( NiiiiiiiiIiR8(trecvR tEOFErrortlongtordRE(RcR|R{RytnRztbuf((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrecvfrag%s L cCs9d}d}x&|s4t|\}}||}qW|S(NR8i(R(RcR~RyRz((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt recvrecord5s  cCsd\}}tdkr?ddl}||j||anxtt|t|tD]g}|ay|j||ftSWq\tjk r\}}|dkrtj||fqq\Xq\WtddS(NiXiiirscan't assign reserved port(iXi( tlast_resv_port_triedRaRBtgetpidtrangeRfRGterrorR+(RcR<tFIRSTtLASTRBRterrnotmsg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt bindresvportAs    t RawTCPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGtAF_INETt SOCK_STREAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\WscCs|jj}t|j|t|j}|j}|j||j\}}||jkr~t d||jfndS(Ns#wrong xid in reply %r instead of %r( RgR:RRcRRhRtR7R_R+(RtcalltreplytuRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkZs  (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRUs t RawUDPClientcBseZdZdZRS(cCstjtjtj|_dS(N(RGRt SOCK_DGRAMRc(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\ksc Cs`|jj}|jj|yddlm}Wntk rQdGHd}nXd}d}d}x|jggg}}}|r|||||\}}}n|j|kr|d}|dkrtdn|d kr|d }n|jj|qgn|jj|} |j } | j | | j \} } | |j krWqgnPqgWdS( Ni(tselects'WARNING: select not found, RPC may hangi iiittimeoutii( RgR:RcRxRRCRaR+RRhRtR7R_( RRRtBUFSIZERtcounttrtwR{RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRkns:  !     (RR R\Rk(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRis tRawBroadcastUDPClientcBs5eZdZdZdZdZdZRS(cCs/tj|||||d|_d|_dS(Ni(RRbRat reply_handlerR(Rt bcastaddrRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs cCs |jjtjtjddS(Ni(Rct setsockoptRGt SOL_SOCKETt SO_BROADCAST(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR^scCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytset_reply_handlerscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt set_timeoutscCs|dkr$|dk r$tdn|j||rD||n|jj}|jj||j|jfyddl m }Wnt k rdGHd}nXd}g}|dkrd} | }nx"|jggg} } } |rC|j dkr|| | | \} } } qC|| | | |j \} } } n|j| krVPn|jj |\} }|j }|j| |j\}}||jkrqn|} |j j|j| |f|jr|j| |qqW|S(Ns!non-null args with null pack_funci(Rs.WARNING: select not found, broadcast will hangi cSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytdummyR8(RaRiRjRgR:RctsendtoR<R[RRCRtrecvfromRhRtR7R_RltappendR(RRRmRnRoRRRtrepliesRRRR{RtfromaddrRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqsJ        $     (RR RbR^RRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     iioiitPortMapperPackercBs#eZdZdZdZRS(cCsJ|\}}}}|j||j||j||j|dS(N(R(RtmappingRRtprotR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_mappings    cCs|j||jdS(N(t pack_listR(Rtlist((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt pack_pmaplistscCsJ|\}}}}|j||j||j||j|dS(N(RR(RtcaRRRRm((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytpack_call_argss    (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPortMapperUnpackercBs#eZdZdZdZRS(cCs@|j}|j}|j}|j}||||fS(N(R((RRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_mappings     cCs|j|jS(N(t unpack_listR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_pmaplistscCs"|j}|j}||fS(N(R(R&(RR[tres((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytunpack_call_results  (RR RRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs  tPartialPortMapperClientcBs>eZdZdZdZdZdZdZRS(cCst|_td|_dS(NR8(RRgRRh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s cCs"|jt||jj|jjS(N(Rqt PMAPPROC_SETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytSets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_UNSETRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytUnsets  cCs"|jt||jj|jjS(N(RqtPMAPPROC_GETPORTRgRRhR((RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytGetports  cCs|jtdd|jjS(N(Rqt PMAPPROC_DUMPRaRhR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytDump!s cCs"|jt||jj|jjS(N(RqtPMAPPROC_CALLITRgRRhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytCallit&s  (RR R`RRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s      tTCPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbt PMAP_PROGt PMAP_VERSt PMAP_PORT(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb.s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR,stUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR<((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb5s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR3stBroadcastUDPPortMapperClientcBseZdZRS(cCstj||tttdS(N(RRbRRR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb=s (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR:st TCPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_TCPRdR+RRb(RR<RRtpmapR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbFs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRDst UDPClientcBseZdZRS(cCsft|}|j||tdf}|j|dkrItdntj|||||dS(Nisprogram not registered(RRt IPPROTO_UDPRdR+RRb(RR<RRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbQs     (RR Rb(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyROstBroadcastUDPClientcBs>eZdZdZdZdZdZdZRS(cCsKt||_|jj|j||_||_d|_|jdS(N( RRRtmy_reply_handlerRRRatuser_reply_handlerR`(RRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRb\s    cCs|jjdS(N(RRd(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRddscCs ||_dS(N(R(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRgscCs|jj|dS(N(RR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRjscCsq|\}}|jj||j}|jj|jj||f|jdk rm|j||ndS(N(RhRtRoRlRRRRa(RRRR[RRp((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRms   cCs|jj|r ||n|dkrAd}||_n ||_g|_|jj}|jj|j|j ||f}|jS(NcSsdS(N((((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR{R8( RgRtRaRoRR:RRRR(RRRmRnRoRt packed_argst dummy_replies((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRqvs        (RR RbRdRRRRq(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRZs      tServercBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCsa||_||_||_||_|j|j|jj\|_|_|jdS(N( R<RRR[R\R]Rct getsocknameR`(RR<RRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRbs      cCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytregisterscCsL|j|j|j|jf}t|j}|j|sHtdndS(Nsunregister failed(RRRR[RR<RR+(RRR>((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt unregistersc Cs|jj||jj|jj}|jj||jj}|tkr[dS|jjt|jj}|t kr|jjt |jjt |jjt |jjt |jj S|jjt |jjttf|jj}||jkr7|jjt|jj S|jj}||jkr|jjt|jj|j|jj|j|jj S|jj}dt|}yt||}Wn+tk r|jjt|jj SX|jj} |jj} y |Wn}ttfk r|jj|jj||jjt|jjt |jjttf|jjtnX|jj S(Nthandle_(RhRtRgR(RR%RRaRRR,R-R:RRRuR9RR/RR0treprtgetattrtAttributeErrorR1R'RR#R2( RRRR)RRRtmethnametmethRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandles\         cCs?y|jjWntk r*tnX|jjtdS(N(RhRlR+R#RgRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt turn_arounds   cCs|jdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_0scCs tddS(Nsmakesocket not defined(R+(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs |jj|j|jfdS(N(RcRfR<R[(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR]scCst|_td|_dS(NR8(RRgR$Rh(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR`s ( RR RbRRRRRR\R]R`(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   3    t TCPServercBs5eZdZdZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\scCs1|jjdx|j|jjqWdS(Ni(Rctlistentsessiontaccept(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytloopscCs|\}\}}xsyt|}Wn1tk r9Pn tjk rX}dG|GHPnX|j|}|dk rt||qqWdS(Ns socket error:(RRRGRRRaR(Rt connectionRcR<R[RRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs   cCs1|jjdx|j|jjqWdS(Ni(RcRt forksessionR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt forkingloopscCsddl}y#x|jdd\}}qWWn|jk rEnXd}z5|j}|rs|djdS|j|Wd|dkr|jdnXdS(Niii(RBtwaitpidRRatforkRdRt_exit(RRRBtpidtsts((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR s    (RR R\RRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRs     t UDPServercBs#eZdZdZdZRS(cCs(tjtjtj|_t|_dS(N(RGRRRcRR(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR\&scCsx|jqWdS(N(R(R((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR*scCsM|jjd\}}|j|}|dk rI|jj||ndS(Ni (RcRRRaR(RRt host_portR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR.s (RR R\RR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR$s  cCsztd}|j}|jxQ|D]I\}}}}|G|G|tkrVdGn|tkridGn|G|GHq)WdS(NR8ttcptudp(RRtsortRR(RRRRRR[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttest7s     cCs}ddl}|jdr)|jd}nd}d}t|}|j||jd|jddtdf}dS(Niis cSs#|\}}|dt|GHdS(Ns (R(RRR<R[((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytrhKs iii(tsystargvRRRRR(RRRRR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt testbcastEs      cCsdtfdY}|dddd}y|jWn tk r[}dG|GdGHnX|jd GHz|jWd|jd GHXdS( NtScBseZdZRS(cSs@|jj}|jdGt|GH|jj||dS(NsRPC function 1 called, arg(Rht unpack_stringRRRgR (Rtarg((s$/usr/lib64/python2.7/Demo/rpc/rpc.pythandle_1\s (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyR[sR8i iis RuntimeError:s (ignored)sService started...sService interrupted.(RRR+RR(RtsR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestsvrYs  cCs~ddl}|jdr)|jd}nd}dtfdY}||dd}dGH|jd}d Gt|GHdS( NiiR8tCcBseZdZRS(cSs"|jd||jj|jjS(Ni(RqRgR RhR(RR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pytcall_1vs  (RR R(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyRusi smaking call...shello, world, s call returned(RRRRR(RR<RtcR((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyttestcltps  ((((ItxdrRGRBRRRRut AUTH_UNIXt AUTH_SHORTtAUTH_DESRR,RR/R0R1R2R-R.t AUTH_BADCREDtAUTH_REJECTEDCREDt AUTH_BADVERFtAUTH_REJECTEDVERFt AUTH_TOOWEAKRt ExceptionR!R"R#R$R9R?RIRJRFRZR}RRRRaRRRRRRRRt PMAPPROC_NULLRRRRRRRRRRRRRRRRRRRRRRR(((s$/usr/lib64/python2.7/Demo/rpc/rpc.pyt s   %A    Q     '>     1c6