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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/landscape/watchdog.pyc

}9Rc@sdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZmZddlmZddlmZdd	lmZmZdd
lmZddlmZmZddlm Z dd
l!m"Z"ddl#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3dZ4dZ5dZ6dZ7de8fdYZ9de8fdYZ:de8fdYZ;de<fdYZ=de=fd YZ>d!e=fd"YZ?d#e=fd$YZ@d%efd&YZAd'e<fd(YZBd)efd*YZCd+ZDd,efd-YZEe$e&d.d/d0d1e&d2d/d0d1e&d3d/d0d1e&d4d/d0d1e&d5d/d0d1e&d6d/d0d1e&d7d/d0d8e&d9d/d0d1e&d:d/d0d1e%d;d/d0d<g
ZFd=ZGejHdd>ZJdS(?sSee L{WatchDog}.

The WatchDog must run as root, because it spawns the Landscape Manager.

The main C{landscape-client} program uses this watchdog.
iN(twarningtinfoterror(t	setrlimitt
RLIMIT_NOFILE(treactor(tDeferredtsucceed(tProcessProtocol(tProcessExitedAlready(tServicetApplication(tstartApplication(tinit_loggingt
Configuration(tgather_results(tlog_failure(t
BootstrapListt
BootstrapFiletBootstrapDirectory(trotate_logs(tRemoteBrokerConnectortRemoteMonitorConnectortRemoteManagerConnector(tLandscapeReactor(tdiscover_server(t#fetch_base64_ssl_public_certificatet$decode_base64_ssl_public_certificatei
iitDaemonErrorcBseZdZRS(s(One of the daemons could not be started.(t__name__t
__module__t__doc__(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR,stTimeoutErrorcBseZdZRS(sSomething took too long.(RRR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR 0stExecutableNotFoundErrorcBseZdZRS(sAn executable was not found.(RRR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR!4stDaemoncBseZdZdZdZdZdZee	ddZ
dZdZdZ
dZd	Zd
ZdZdZd
ZdZdZRS(sqA Landscape daemon which can be started and tracked.

    This class should be subclassed to specify individual daemon.

    @cvar program: The name of the executable program that will start this
        daemon.
    @cvar username: The name of the user to switch to, by default.
    @cvar service: The DBus service name that the program will be expected to
        listen on.
    @cvar max_retries: The maximum number of retries before giving up when
        trying to connect to the watched daemon.
    @cvar factor: The factor by which the delay between subsequent connection
        attempts will increase.

    @param connector: The L{ComponentConnector} of the daemon.
    @param reactor: The reactor used to spawn the process and schedule timed
        calls.
    @param verbose: Optionally, report more information when running this
        program.  Defaults to False.
    t	landscapeig?c	Cs'||_||_tjj|_tj}|dkrtj|j	}|j
}|j}||krx||_n	d|_|tjkr||_n	d|_|j|jd<|j	|jd<|j	|jd<nd|_d|_||_||_d|_d|_d|_t|_dS(NitHOMEtUSERtLOGNAME(t
_connectort_reactortostenvirontcopyt_envtgetuidtpwdtgetpwnamtusernametpw_uidtpw_gidt_uidtNonetgetgidt_gidtpw_dirt_verboset_configt_processt
_last_startedt
_quick_startstTruet_allow_restart(	tselft	connectorRtverbosetconfigtmy_uidtpwd_infot
target_uidt
target_gid((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt__init__Ss2													cCsitjjtjjtjd}tjj||j}tjj|set	d|fn|S(sFind the fully-qualified path to the executable.

        If the executable can't be found, L{ExecutableNotFoundError} will be
        raised.
        is%s doesn't exist(
R)tpathtdirnametabspathtsystargvtjointprogramtexistsR!(R?RIt
executable((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytfind_executablets
%cCs<d|_tj}|jt|krk|jd7_|jtkrttd|j|j	j
dSn	d|_||_t||_|j}|dg}|j
s|jdn|jr|jd|jgn|jdk	r|j|jn|j	j|j|d|d	|jd
|jd|jdS(sStart this daemon.isCan't keep %s running. Exiting.Nis--ignore-sigints--quiets-ctargstenvtuidtgid(R4R:ttimeR;tRESTART_BURST_DELAYR<tMAXIMUM_CONSECUTIVE_RESTARTSRRNR(tstoptWatchedProcessProtocolRQR8tappendR9textendtoptionstspawnProcessR,R3R6(R?tnowtexeRR((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytstarts*	
				cCs |jstdS|jjS(sStop this daemon.N(R:RR4tkill(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRYs	
csgfd}jjjjdt}|jfd|j||jd|S(sConnect to the remote daemon over AMP and perform the given command.

        @param name: The name of the command to perform.
        @param args: Arguments list to be passed to the connect method
        @param kwargs: Keywords arguments to pass to the connect method.
        @return: A L{Deferred} resulting in C{True} if the command was
            successful or C{False} otherwise.
        @see: L{RemoteLandscapeComponentCreator.connect}.
        csjjtS(N(R't
disconnectR=(tignored(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRcs
tquietcst|S(N(tgetattr(tremote(tname(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt<lambda>scSstS(N(tFalse(tx((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRis(R'tconnecttmax_retriestfactorR=taddCallbackt
addErrback(R?RhRRtkwargsRct	connected((RhR?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt_connect_and_calls	
cCs
|jdS(Ntexit(Rs(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytrequest_exitscCs
|jdS(Ntping(Rs(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
is_runningscCs |jstdS|jjS(sN
        Return a Deferred which will fire when the process has died.
        N(R:RR4twait(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRxs	
cCs |jstdS|jjS(s
        Wait for the process to die for C{GRACEFUL_WAIT_PERIOD}. If it hasn't
        died by that point, send it a SIGTERM. If it doesn't die for
        C{SIGKILL_DELAY},
        N(R:RR4twait_or_die(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRys	
cCs
t|_dS(sCalled by the watchdog when starting to shut us down.

        It will prevent our L{WatchedProcessProtocol} to restart the process
        when it exits.
        N(RjR>(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytprepare_for_shutdownscCs|jS(s>Return a boolean indicating if the daemon should be restarted.(R>(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
allow_restartscCs|jjdS(N(R:R(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRsN(RRRR0RmRnR4R]RRjRGRQRaRYRsRuRwRxRyRzR{R(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR"8s$ 								
		tBrokercBseZdZRS(slandscape-broker(RRRN(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR|stMonitorcBseZdZRS(slandscape-monitor(RRRN(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR}stManagercBseZdZdZRS(slandscape-managertroot(RRRNR0(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR~sRZcBsqeZdZeZdZdZedZdZdZ	dZ
dZdZd	Z
d
ZRS(su
    A process-watching protocol which sends any of its output to the log file
    and restarts it when it dies.
    cCs(||_d|_d|_d|_dS(N(tdaemonR4t_wait_resultt_delayed_really_killt_delayed_terminate(R?R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRGs			cCs|j|jS(N(t
_terminateRx(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRbs
cCs|jdk	r{|r/td|jjfny|jjtjWntk
rYq{Xt	j
t|j}||_
ndS(Ns%s didn't exit. Sending SIGTERM(t	transportR4RRRNt
signalProcesstsignaltSIGTERMR	Rt	callLatert
SIGKILL_DELAYt_really_killR(R?twarntdelayed((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs
cCsLy|jjtjWntk
r*nXtd|jjd|_	dS(Ns %s didn't die.  Sending SIGKILL.(
RRRtSIGKILLR	RRRNR4R(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs
cCsA|jdk	r=y|jjtjWq=tk
r9q=XndS(N(RR4RRtSIGUSR1R	(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs

cCs/|jjdkrtdSt|_|jS(N(RtpidR4RRR(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRx s
cCs(tjt|jdt|_|jS(NR(RRtGRACEFUL_WAIT_PERIODRR=RRx(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRy&s	cCstjj|dS(N(RKtstdouttwrite(R?tdata((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytoutReceived+scCstjj|dS(N(RKtstderrR(R?R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyterrReceived/scCs|jdk	r|jjn|jdk	rM|jjrM|jjn|jdk	ro|jjdn|jjr|jj	ndS(s"The process has ended; restart it.N(
RR4tcancelRtactiveRtcallbackRR{Ra(R?treason((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytprocessEnded2s(RRRRjt_killedRGRbRRRRxRyRRR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRZs									tWatchDogcBskeZdZeed	d	d	d	d	dZdZdZdZ	dZ
dZdZdZ
RS(
sj
    The Landscape WatchDog starts all other landscape daemons and ensures that
    they are working.
    c	st}|dkr'tttg}n|dkrft|krftt||d|d|j}n|dkrt|krtt||d|d|j}n|dkrt|krtt||d|d|j}n|_	|_
|_tdj	j
jg_
_d_t_tjtjfd|dk	r|jdkrdt|jdt|jg}	xj
D]}
|	|
_qWni_dS(NRARBcsjjS(N(tcallFromThreadt_notify_rotate_logs(Rtframe(R?R(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRiasis--cloness--start-clones-over(RR4R|R}R~RRBRRtbrokertmonitortmanagertfiltertdaemonsRt	_checkingRjt	_stoppingRRtcloneststrtstart_clones_overR]t_ping_failures(R?RRARBRRRtenabled_daemonstlandscape_reactorR]R((R?Rs6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRGEs>				$			cCsbg}x=|jD]2}|j}|j|d|j|qWd}t|j|S(s6Return a list of any daemons that are already running.cSs
||fS(N((Rwtd((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRisscSs%g|D]}|dr|d^qS(Nii((trRk((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytgot_all_resultsvs(RRwRoR[R(R?tresultsRtresultR((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
check_runningks	cCs,x|jD]}|jq
W|jdS(sm
        Start all daemons. The broker will be started first, and no other
        daemons will be started before it is running and responding to DBUS
        messages.

        @return: A deferred which fires when all services have successfully
            started. If a daemon could not be started, the deferred will fail
            with L{DaemonError}.
        N(RRatstart_monitoring(R?R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRazs
cCs|jjd|j|_dS(s;Start monitoring processes which have already been started.iN(RRt_checkR(R?((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRscs|rjrtdjfjkrDdj<njcd7<jdkrtdjfj}fd}|j||Sn
dj<dS(Ns%s failed to respond to a ping.iiis%s died! Restarting.csjdj<dS(Ni(RaR(Rd(RR?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytstoppeds
(RRRNRRYtaddBoth(R?RwRtstoppingR((RR?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt_restart_if_not_runnings
cslg}x=jD]2}|j}|jj||j|qWfd}t|j|dS(Ncsjjdj_dS(Ni(RRRR(Rd(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
reschedules(RRwRoRR[RR(R?tall_runningRRwR((R?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRscsjdk	r.jjr.jjnt_xjD]}|jqAWfd}jj	}|j
|S(Ncsa|r+gjD]}|j^q}n,tdgjD]}|j^q?}t|S(NsFCouldn't request that broker gracefully shut down; killing forcefully.(RRyRRYR(tbroker_stoppedRRRk(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytterminate_processess
%
"(RR4RRR=RRRzRRuRo(R?RRR((R?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRus	cCs)x|jD]}|jq
WtdS(N(RR(R?R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRsN(RRRRRjR4RGRRaRRRRuR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR?s		$						tWatchDogConfigurationcBseZdZdZRS(cCsdtt|j}|jddddd|jddddd	|jd
dddd|S(Ns--daemontactiont
store_truethelpsFork and run in the background.s
--pid-filettypeRsThe file to write the PID to.s--monitor-onlysbDon't enable management features. This is useful if you want to run the client as a non-root user.(tsuperRtmake_parsert
add_option(R?tparser((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRscCs)ttg}|js%|jtn|S(N(R|R}tmonitor_onlyR[R~(R?R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytget_enabled_daemonss	(RRRR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs	cCstjrtjdntjtjrBtjdntjdtjdtj}xVtdD]H}ytj||Wqqt	k
r}|j
t
jkrqqqXqqWtj|dS(Nii?s	/dev/nulli(
R)tforkt_exittsetsidtumasktopentO_RDWRtrangetdup2tOSErrorterrnotEBADFtclose(tnulltite((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt	daemonizes

tWatchDogServicecBs>eZdZdZdZdZdZdZRS(cCs>||_td|jd|d|j|_d|_dS(NRARBRi(R9RRRtwatchdogt	exit_code(R?RB((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRGs
	csQfd}d}tjjjj}|j||j||S(sR
        Autodiscover called if config setting config.server_autodiscover is
        True. This method allows the watchdog to attempt server autodiscovery,
        fetch the discovered landscape server's custom CA certificate, and
        write both the certificate and the updated config file with the
        discovered values.
        cs|dkrtdntd|tj_d|j_d|j_jjst	|dtdt}|r|j_t
jqnjj|S(NsMAutodiscovery returned empty hostname string. Reverting to previous settings.sJAutodiscovery found landscape server at %s. Updating configuration values.shttps://%s/message-systemshttp://%s/pington_infoton_error(R4RRRjR9tserver_autodiscoverturltping_urltssl_public_keyRRR(thostnameR(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
update_configs

cSstddS(Ns6Autodiscovery failed.  Reverting to previous settings.(R(R((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytdiscovery_errors(RR9tautodiscover_srv_query_stringtautodiscover_a_query_stringRoRp(R?RRtlookup_deferred((R?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytautodiscovers		

csXtjtjdjjdjjjjdkrtt	jjdjjdfddl
m}d|_xQt
jjD]:}d	|}tjdjj|djj|qWntd}jjr|jfd
n|jfdfd}fd
}|j||j||S(Nt	data_pathtlog_diriidii(tMethodCallSenderi,s	-clone-%dcs
jS(N(R(t_(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRi<scs
jjS(N(RR(R(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRi=scs_|r>tddjd|Dd_tjdSjtdjjS(Ns4ERROR: The following daemons are already running: %ss, css|]}|jVqdS(N(RN(t.0Rk((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pys	<genexpr>BsisWatchdog watching for daemons.(	RRMRRtcrasht
_daemonizeRRRa(trunning_daemons(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytstart_if_not_running?s	


cs$t|dd_tjdS(NsUnknown error occurred!i(RRRR(tfailure(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytdieJs
	(R
tstartServicetbootstrap_listt	bootstrapR9RRRRRtlandscape.lib.ampRttimeoutRRR4RRoRp(R?RRtsuffixRRR((R?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyR#s,

	
	

cCsa|jjr]t|jjr]t|jjd}|jttj|j	q]ndS(Ntw(
R9RRtpid_fileRRRR)tgetpidR(R?tstream((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRRscsVtdtjtjtjtjjj}|jfd|S(NsStopping client...cs
jS(N(t_remove_pid(R(R?(s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRics(	RR
tstopServiceRtSIGINTtSIG_IGNRRuR(R?tdone((R?s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRZs

cCs~|jj}|dk	rztj|tjrzt|}|j}|j|t	tj
krztj|qzndS(N(R9RR4R)taccesstW_OKRtreadRRRtunlink(R?RRR((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRfs!
(RRRGRRRRR(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs		'	/		s
$data_pathR#Ris$data_path/packages$data_path/package/hash-ids$data_path/package/binariess$data_path/package/upgrade-tools$data_path/messagess$data_path/socketsis$data_path/custom-graph-scriptss$log_dirs$data_path/package/databaseicCsFx?tjjD].}|jds1|dkrtj|=qqWdS(sHUnset dangerous environment variables.

    In particular unset all variables beginning with DEBIAN_ or DEBCONF_,
    to avoid any problems when landscape-client is invoked from its
    postinst script.  Some environment variables may be set which would affect
    *other* maintainer scripts which landscape-client invokes.
    tDEBIAN_tDEBCONF_tLANDSCAPE_ATTACHMENTStMAILN(RR	(R
R(R)R*tkeyst
startswith(tkey((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pytclean_environmentscCstt}|j|ytjdj}Wntk
rStjdnXt	j
d|fkr|tjdnt|dtd}t
|}|j||d	krddlm}n|jdt|t|j|jS(
sStart the watchdog.

    This is the topmost function that kicks off the Landscape client.  It
    cleans up the environment, loads the configuration, and starts the
    reactor.

    @param args: Command line arguments, including the program name as the
        first element.
    @param reactor: The reactor to use.  If none is specified, the global
        reactor is used.
    @raise SystemExit: if command line arguments are bad, or when landscape-
        client is not running as 'root' or 'landscape'.
    R#s#The 'landscape' user doesn't exist!is:landscape-client can only be run as 'root' or 'landscape'.Rslandscape-clienti(RN(RRtloadR.R/R1tKeyErrorRKRtR)R-R
RRtsetServiceParentR4ttwisted.internetRRRRjtrunR(RRRRBt
landscape_uidtapplicationtwatchdog_service((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs$	




(KRR)RRKR.RRVtloggingRRRtresourceRRRRttwisted.internet.deferRRttwisted.internet.protocolRttwisted.internet.errorR	ttwisted.application.serviceR
Rttwisted.application.appRtlandscape.deploymentR
Rtlandscape.lib.twisted_utilRtlandscape.lib.logRtlandscape.lib.bootstrapRRRt
landscape.logRtlandscape.broker.ampRRRtlandscape.reactorRtlandscape.lib.dnsRtlandscape.configurationRRRRXRWRt	ExceptionRR R!tobjectR"R|R}R~RZRRRRRRRLR4R(((s6/usr/lib/python2.7/dist-packages/landscape/watchdog.pyt<module>spO	}	

Youez - 2016 - github.com/yon3zu
LinuXploit