403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/landscape/manager/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyc
ó
}9Rc@sêdZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZddlmZdd	lmZmZdd
lmZddlmZddlmZmZm Z e!ƒZ"d
Z#dZ$dZ%de&fd„ƒYZ'dd„Z)de&fd„ƒYZ*de&fd„ƒYZ+de&fd„ƒYZ,de!fd„ƒYZ-dee-fd„ƒYZ.defd„ƒYZ/defd „ƒYZ0dS(!su
Functionality for running arbitrary shell scripts.

@var ALL_USERS: A token indicating all users should be allowed.
iÿÿÿÿN(tProcessProtocol(tDeferredtfailtinlineCallbackstreturnValuetsucceed(tProcessDone(tVERSION(tUBUNTU_PATH(tbuild_script(tfetch_asynct
HTTPCodeError(tPersist(tencode_if_needed(t
ManagerPlugint	SUCCEEDEDtFAILEDifigihtUnknownUserErrorcBseZRS((t__name__t
__module__(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR scCs§d}d}d}|dk	ršt|ƒ}ytj|ƒ}Wn!tk
r`td|ƒ‚nX|j}|j}|j}t	j
j|ƒsšd}qšn|||fS(NuUnknown user '%s't/(tNoneR
tpwdtgetpwnamtKeyErrorRtpw_uidtpw_gidtpw_dirtostpathtexists(tusernametuidtgidRtusername_strtinfo((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt
get_user_info$s
			tProcessTimeLimitReachedErrorcBseZdZd„ZRS(s™
    Raised when a process has been running for too long.

    @ivar data: The data that the process printed before reaching the time
        limit.
    cCs
||_dS(N(tdata(tselfR&((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt__init__>s(RRt__doc__R((((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR%6stProcessFailedErrorcBseZdZd„ZRS(s“Raised when a process exits with a non-0 exit code.

    @ivar data: The data that the process printed before reaching the time
        limit.
    cCs||_||_dS(N(R&t	exit_code(R'R&R+((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR(Is	(RRR)R((((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR*BstUnknownInterpreterErrorcBs eZdZd„Zd„ZRS(sˆRaised when the interpreter specified to run a script is invalid.

    @ivar interpreter: the interpreter specified for the script.
    cCs#||_tj||jƒƒdS(N(tinterpretert	ExceptionR(t_get_message(R'R-((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR(Ts	cCsd|jS(NsUnknown interpreter: '%s'(R-(R'((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR/Xs(RRR)R(R/(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR,Ns	tScriptRunnerMixincBs5eZdZdd„Zd„Zd„Zd„ZRS(sb
    @param process_factory: The L{IReactorProcess} provider to run the
        process with.
    cCs,|dkrddlm}n||_dS(Niÿÿÿÿ(treactor(Rttwisted.internetR1tprocess_factory(R'R3((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR(bscCs(|jjjƒ}|tkp'||kS(N(tregistrytconfigtget_allowed_script_userst	ALL_USERS(R'tusert
allowed_users((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pytis_user_allowedgscCsVtj|dƒ|dk	r2tj|||ƒn|jt||ƒƒ|jƒdS(NiÀ(RtchmodRtchowntwriteR	tclose(R'tscript_filetfilenametshelltcodeR R!((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pytwrite_script_fileks
cCsœ|tjƒkrd}n|tjƒkr6d}nt|jj|jƒ}|jj	||d|d|d|d|ƒ|dk	r•|j
|ƒn|jS(NR R!Rtenv(RtgetuidRtgetgidtProcessAccumulationProtocolR4R1t
size_limitR3tspawnProcesstschedule_canceltresult_deferred(R'R@R R!RRDt
time_limittpp((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt_run_scriptws			"N(RRR)RR(R:RCRN(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR0\s
		tScriptExecutionPlugincBszeZdZdZd„Zdd„Zd„Zd„Zd„Z	d„Z
ed„ƒZddddd	„Z
d
„ZRS(sA plugin which allows execution of arbitrary shell scripts.

    @ivar size_limit: The number of bytes at which to truncate process output.
    i ¡cCs-tt|ƒj|ƒ|jd|jƒdS(Nsexecute-script(tsuperROtregistertregister_messaget_handle_execute_script(R'R4((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRQscCsot|tƒs$|jddƒ}nidd6|d6|d6|d6}|rY||d<n|jjj|tƒS(	Nsutf-8treplacesoperation-resultttypetstatussresult-textsoperation-idsresult-code(t
isinstancetunicodetdecodeR4tbrokertsend_messagetTrue(R'RVR&topidtresult_codetmessage((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt_respond”s


cCsð|d}y­|d}|j|ƒs@|jtd|f|ƒS|jddƒ}|j|d|dd|dd	|d
|d
d|ƒ}|j|j|ƒ|j|j	|ƒ|SWn2t
k
rë}|jt|j|ƒ|ƒ‚nXdS(Nsoperation-idRu!Scripts cannot be run as user %s.RDR-RBRLs
time-limitR8tattachmentstserver_supplied_env(R:R`RtgetRt
run_scripttaddCallbackt_respond_successt
addErrbackt_respond_failureR.t_format_exception(R'R_R]R8Rbtdte((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRS¡s&



	cCsd|jj|jdfS(Nu%s: %si(t	__class__Rtargs(R'Rk((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRi·scCs|jt||ƒS(N(R`R(R'R&R]((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRfºscCs¯d}|jtƒrt}nL|jtƒr6t}n4|jtƒrjt}|jt	t
|jƒ|tƒS|dk	r’|jt	|jj||ƒS|jt	t
|ƒ|ƒSdS(N(
RtcheckR%tTIMEOUT_RESULTR*tPROCESS_FAILED_RESULTRtFETCH_ATTACHMENTS_FAILED_RESULTR`RtstrtvalueR&(R'tfailureR]RB((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRh½s		c
csg|jjjjddƒdd}tjƒ}idtd6dd6|d	6}xÖ|jƒD]È\}}	t|	t	ƒrŠ|	}
t
dƒVn,td
||	fd|jjj
d|ƒV}
tjj||ƒ}t|d
ƒ}tj|dƒ|dk	rtj|||ƒn|j|
ƒ|jƒq[Wtj|dƒ|dk	rYtj|||ƒnt|ƒdS(NRiis/attachment/slandscape-client/%ss
User-Agentsapplication/octet-streamsContent-Types
X-Computer-IDs%s%dtcainfotheaderstwbi€iÀ(R4R5turltrsplitttempfiletmkdtempRtitemsRWRrRRR
tssl_public_keyRRtjointfileR;R<R=R>R(
R'RaR R!tcomputer_idt	root_pathtattachment_dirRvR@t
attachment_idR&t
full_filenamet
attachment((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt_save_attachmentsÎs0#


c	s†tjj|jƒdƒs,tt|ƒƒSt|ƒ\‰‰‰tjƒ\}‰tj	|dƒ}ˆj
|ˆ||ˆˆƒitd6|p”dd6ˆp¡dd6‰|r¾ˆj|ƒntj
dƒ}	|r3tdtjjˆjjjd	ƒƒ}
|
jd
ƒ}
|
jdƒ}ˆj|ˆˆ|ƒ}ntd
ƒ}‡‡‡‡‡‡‡fd†}
|j|
ƒ|jˆjˆˆ|	ƒS(s8
        Run a script based on a shell and the code.

        A file will be written with #!<shell> as the first line, as executable,
        and run as the given user.

        XXX: Handle the 'reboot' and 'killall landscape-client' commands
        gracefully.

        @param shell: The interpreter to use.
        @param code: The code to run.
        @param user: The username to run the process as.
        @param time_limit: The number of seconds to allow the process to run
            before killing it and failing the returned Deferred with a
            L{ProcessTimeLimitReachedError}.
        @param attachments: C{dict} of filename/data attached to the script.

        @return: A deferred that will fire with the data printed by the process
            or fail with a L{ProcessTimeLimitReachedError}.
        itwtPATHttUSERtHOMEiR@sbroker.bpickletregistrations	secure-idcs5|dk	r|ˆd<nˆjˆˆˆˆˆˆƒS(NtLANDSCAPE_ATTACHMENTS(RRN(R‚(RLR R'R@R!RDR(sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pytprepare_scripts
N(RRRtsplitRR,R$RztmkstemptfdopenRCRtupdatetumaskRR~R4R5t	data_pathtroot_atRcR†RRRetaddBotht_cleanup(R'RARBR8RLRaRbtfdR?t	old_umasktpersistR€RjRŽ((RLR R'R@R!RDRsE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRdës.
'!
cCsZytj|ƒWnnXd|krIytj|dƒWqIqIXntj|ƒ|S(NR(RtunlinktshutiltrmtreeR“(R'tresultR@RDR™((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR—&s
N(RRR)RHRQRR`RSRiRfRhRR†RdR—(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRO‡s	
				:RGcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sxA ProcessProtocol which accumulates output.

    @ivar size_limit: The number of bytes at which to truncate output.
    cCs=g|_tƒ|_t|_||_||_d|_dS(N(	R&RRKtFalset
_cancelledRHR1Rt_scheduled_cancel(R'R1RH((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR(:s				cCs|jj||jƒ|_dS(N(R1t
call_latert_cancelR¡(R'RL((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRJBs	cCs@ttjtt|jƒdƒ}|jj||j| ƒdS(s‰Some data was received from the child.

        Add it to our buffer, as long as it doesn't go over L{size_limit}
        bytes.
        iN(treducetoperatortaddtmaptlenR&tappendRH(R'R˜R&tcurrent_size((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pytchildDataReceivedFs!cCs³|jj}dj|jƒ}|jr@|jjt|ƒƒno|jdk	rt|j}d|_|j
j|ƒn|jt
ƒr–|jj|ƒn|jjt||ƒƒdS(sFire back the deferred.

        The deferred will be fired with the string of data received from the
        subprocess, or if the subprocess was cancelled, a
        L{ProcessTimeLimitReachedError} will be fired with data accumulated so
        far.
        R‰N(RstexitCodeR~R&R RKterrbackR%R¡RR1tcancel_callRnRtcallbackR*(R'treasonR+R&t	scheduled((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pytprocessEndedOs			cCs>xdD]}|jj|ƒqW|jjdƒt|_dS(s—
        Close filedescriptors, kill the process, and indicate that a
        L{ProcessTimeLimitReachedError} should be fired on the deferred.
        iiitKILLN(iii(t	transporttcloseChildFDt
signalProcessR\R (R'ti((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR£gs

(RRR)R(RJR«R²R£(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRG4s					tScriptExecutioncBs,eZdZd„Zd„Zed„ZRS(sK
    Meta-plugin wrapping ScriptExecutionPlugin and CustomGraphPlugin.
    cCs,ddlm}tƒ|_|ƒ|_dS(Niÿÿÿÿ(tCustomGraphPlugin(tlandscape.manager.customgraphR¹ROt_script_executiont
_custom_graph(R'R¹((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR(|scCs:tt|ƒj|ƒ|jj|ƒ|jj|ƒdS(N(RPR¸RQR»R¼(R'R4((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyRQscCs|jj|ƒdS(N(R¼texchange(R'turgent((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR½†s(RRR)R(RQRŸR½(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyR¸ws		(1R)RRRzR¥Rœttwisted.internet.protocolRttwisted.internet.deferRRRRRttwisted.internet.errorRt	landscapeRtlandscape.constantsRtlandscape.lib.scriptcontentR	tlandscape.lib.fetchR
Rtlandscape.lib.persistRtlandscape.lib.encodingR
tlandscape.manager.pluginRRRtobjectR7RoRpRqR.RRR$R%R*R,R0RORGR¸(((sE/usr/lib/python2.7/dist-packages/landscape/manager/scriptexecution.pyt<module>s8(	+­C

Youez - 2016 - github.com/yon3zu
LinuXploit