KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/22697/root/usr/share/system-config-services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/22697/root/usr/share/system-config-services/servicemethods.pyo
m
sKc@sdZdkZdkZdklZlZlZdkZdkZdZ	dZ
dZdZdZ
dfd	YZd
efdYZdfd
YZdS(shThe servicemethods module handles all the backend processing for the system-config-services application.N(t_sN_scatcCstid|d}tii|g|}||}|i
}|djo
d}n|ddjo|d }n||fS(s4Return (status, output) of executing cmd in a shell.s
{ %s ; } 2>&1triis
N(
tostpopentcmdtpipetnonblockingreadertReadertruntcallbacktoutputttexttclosetstatustNone(RR	R
RRR
((t3/usr/share/system-config-services/servicemethods.pytgetstatusoutputs


iiiitServicecBstZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZddZ
d
ZdZdZdZdZdZdZdZRS(s:Represents a service with start script in /etc/init.d
    cCs||_||_||_||_|i|_d|_d|_	g|_
t|_d|_
g|_g|_g|_t|_|it|_dS(Nt(tnametselft	runlevelst
_runlevelst_runlevels_oldtservicest
uicallbackRt	startpriotstoppriotdefaultrunlevelstFalsethidetdescriptiontprocessnamestconfigfilestpidfilestprobet_read_script_filet_dirty(RRRR((Rt__init__6s 		
										
cCsU|djo;|i\|_|_|djo|iSqQ|iSn
t|dS(NR
tstatus_message(sstatussstatus_message(RRt
get_statusR
R'tAttributeError(RR((Rt__getattr__Ks

cCstS(N(R(R((Rtis_xinetd_serviceVscCs|iS(N(RR(R((Rt
get_runlevels[scCs|iptSn|i|id}xctt|iD]L}||ijo|i|otSqq<|i||jotSq<q<WtS(sreturn if service is configured as suggested with defaultsrunlevels
        This is either service is off in all runlevels or on on exatctly
        the defaultrunlevels
        iN(	RRRRtontxrangetlentrunleveltTrue(RR-R0((Rt
is_default`s
cCs|i|idS(sg
        Return if service is enabled in the default runlevels
        Assumes .is_default() == True!!!iN(RRR(R((Rt
is_default_onsscCst}y%td|id|id}WntdfSnX|iddjo
t}n|iddjo
t	}n||fS(	slExecute /sbin/service name status
        return (status of the service, the output of the command)
        sLC_ALL=C /sbin/service s statusiRtrunningitstoppedN(
tUNKNOWNR
RRRRtmessagetfindtRUNNINGtSTOPPED(RR
R7((RR({s%

cCsd|iS(Ns/etc/init.d/(RR(R((Rtget_script_filescCs!|itjo
t|_ndS(s#Tell that a config file got changedN(RtstateR:R1R%(R((Rt	set_dirtyscCs|iS(s7Are there still changes not realized by the service yetN(RR%(R((Rtis_dirtysicCsOt|to
|g}nx|D]}||i|<q$W|ii|dS(schanged if service is started in the given runlevels
        runlevels may be an int or sequence of ints
        changes are not written to disk. Use .save_changes()N(	t
isinstancetediting_runlevelstintR0R-RRRt_service_changed(RR-R@R0((Rtset_in_runlevelss
cCsId|}y$td||i|f|iWntj
onXdS(s@calls chkconfig --level editing_runlevel on if on, off if not onR-toffs)LC_ALL=C /sbin/chkconfig --level %s %s %sN(sonRD(R-tchkconfig_actionRR@RRRtIOError(RR-R@RE((Rt_set_in_runlevelss$cCs5x|iD]}||i|<q
W|ii|dS(s5Change is service is started in the default runlevelsN(RRR0R-RRRB(RR-R0((Rtsets

cCs?x8t|i|iD]!\}}||jotSqqWtS(sTAre there any changes to runlevel behaviour that
        are not yet written to diskN(tzipRRRtnewtoldR1R(RRKRJ((Rt
is_changeds
cCsrt}d}xRt|i|iD];\}}||Ao|i	||t
}n|d7}q"W|i|_|S(s4when this method is used it saves the change to diskiiN(RtchangedR0RIRRRRJRKRGR1(RRMRKR0RJ((Rtsave_changess

cCstd|i|f|i\}}|djoD|djot|_||_ndtd|i|ffSnC|i	\|_|_
t|_dd	|i|ftd
fSdS(
sMExecute /sbin/service servicename action.
        return (errorcode, message)s/sbin/service %s %sitstarttrestarttreloadtcondrestartis%s failed. The error was: %ss%s %ss successfulN(sstartRPsreloadRR(
RRRtactionRR
R7tERRORRR(R'RR%(RRSR
R7((RRSs

	
!	cCs`yt|i}Wntj
odSnXdddddddd	g}g}d}x|D]}|d
djoPn|di
}|pVtid
|}|o9|i
d|jo#|i
d}||i}qn|og|ido|i|d i
qX|i|i
|i|di|d}g}qaqaWdS(s?Gets the description for the given initscript or xinet.d scriptNt	chkconfigRtprocessnametconfigtpidfileR#Rtdefaultit#is
^\s*(\w+):s\it (topenRR;tfdRFt	tag_namestdataRttagtlinetstriptretmatchtgrouptendtendswithtappendt_process_initscript_tagtjoin(RR_R`R]R^RaRd((RR$s2	cCs|djotid|}|o~|iddjo4x1|idD]}|iit	|qLWnt	|id|_
t	|id|_qn|djo.|idd	jo|iid
qn|djo
||_
n|djo|ii|n|d
jo|ii|nt|djo|ii|nS|djo|idd	j|_n*|djo|idd	j|_ndS(sused by _read_script_file onlyRUs\s*(\d+|-)\s*(\d+)\s*(\d+)it-iiRYR-iiRRVRWRXR#ttrueRN(RRcRdtvalueRetcharRRRhRARRR8RR R!R"R#R(RRRmRnRd((RRis2
 







cCsti|i|_dS(N(tcopyRRR(R((Rtrevert,s(t__name__t
__module__t__doc__R&R*R+R,R2R3R(R;R=R>RCRGRHRLRNRSR$RiRp(((RR2s(										
	
					$	t
XinetdServicecBs8tZdZdZdZddZdZRS(NcCstS(N(R1(R((RR+3scCs8|iidd}|o|iSntdfSdS(NtxinetdR(RRtgetRRuR(R6(RRu((RR(6scCsd|iS(Ns/etc/xinetd.d/(RR(R((RR;=scCsFd|}y!td|i|f|iWntj
onXdS(scalls chkconfig on/offR-RDsLC_ALL=C /sbin/chkconfig %s %sN(sonsoff(R-RERRRRRF(RR-R@RE((RRGBscCs|iiidd	}|o|itjodtd|i	fSn|i
d\}}|djo)dtd|i	td|fSqdtd|i	fSndtd|i	fSd	S(
sxstarts, stops, and restarts the service. Returns the error
        if the service failed in any of the actions.
        Ruis$xinetd must be enabled for %s to runRQisxinetd failed to reload for s. The error was: sxinetd reloaded %s successfullyN(
RRt	_servicesRvRRuR
R9RRRSterrorR
(RRSRuRxR
((RRSMs
)(RqRrR+R(R;RRGRS(((RRt1s
			tServicescBstZdZedZdZdZdZdZdZ	dZ
dZd	Zd
dZ
dZd
ZdZdZdZRS(sIncludes methods used to find services, and information about them such
    as the description, whether or not it is configured etc.cCs(||_h|_h|_h|_dS(N(RRRwt_xinetd_servicest_changed(RR((RR&is			cCs!|ii|dp|i|S(N(RRwRvRRRz(RR((Rt__getitem__qscCs#|ii|p|ii|S(N(RRwthas_keyRRz(RR((RR}vsccs9|ii}|ix|D]}|i|Vq WdS(s!Iter over all non xinetd servicesN(RRwtkeystsorttkey(RR~R((Rt__iter__|s
ccs9|ii}|ix|D]}|i|Vq WdS(s(return iterator over all xinetd servicesN(RRzR~RR(RR~R((Rtxinetd_servicess
cCs&td|i\}}t|dS(s1returns the current runlevel, uses /sbin/runlevels/sbin/runleveliN(RRRR
R
RA(RR
R
((Rtget_runlevelscCsDtd||i\}}|djo|i|n||fS(s!calls chkconfig --add servicenames!LC_ALL=C /sbin/chkconfig --add %siN(RtservicenameRRR
R
tupdate(RRR
R
((Rtadd_services

cCs'td||i}|i||S(s!calls chkconfig --del servicenames!LC_ALL=C /sbin/chkconfig --del %sN(RRRRtresultR(RRR((Rtdelete_services


cCs|i}|pdSn|id}g}|D]}||iq5~}|dido|dd }n|d}|djodSn|d}g}|D] }||idddjq~}||fS(	sparse one line of chkconfig --list output
        return (name, runlevels as list of bools)
               or None if not a valid lines	it:isxinetd based servicesiR-N(
RaRbRtsplittentriest_[1]tentryRgRR(RRaRRRRR((Rt_service_from_chkconfigs'


4RcCsh|_h|_td||id}|i}x|D]}|i	|}|djoq?n|\}}t|djo#t|||}||i|<q?t|||}||i|<q?W|o|io|idndS(ssread in data about services in the system. 
        if servicename is given only get data for this service
        s.LC_ALL=C /sbin/chkconfig --list %s 2>/dev/nulliRuN(RRwRzRRRtchkconfig_listt
splitlinesRaRtserviceRRRR/RtRR(RRRRRRaR((Rtget_service_listss&		

cCstd||i\}}|djo|i|}|dj	oi|\}}t|djo#t|||}||i
|<n t|||}||i|<dSqn|i
i|d|ii|ddS(sURead status of service from disk. If service got removed
        remove from ourselfss LC_ALL=C /sbin/chkconfig --list iiN(RRRRR
R
RRRRRR/RtRzRRwtpop(RRR
RRRR
((RRs



cCs
t|iS(sQRunlevel behaviour of any service got changed
        but not yet written to diskN(tboolRR{(R((RRLscCs5|iod|i|<n|ii|ddS(s$Called by a service that got changediN(RRLRR{RR(RR((RRBs
cCsx!|iiD]}|iqWt}x0|iiD]}|i}|p|}q:W|ot	d|i
nh|_dS(s4when this method is used it saves the change to disks/sbin/service xinetd reloadN(RRwt
itervaluesRRNRt
reload_xinetdRzRMRRR{(RRRMR((RRNscCsLx!|iiD]}|iqWx!|iiD]}|iq4WdS(N(RRwRRRpRz(RR((RRps(RqRrRsRR&R|R}RRRRRRRRRLRBRNRp(((RRyes 								
						
	(RsRcRtrhpl.translateRtN_tcatRoRRR6R9R:RTRRtRy(RRRTR6RtRRcR9R:RRyRRoRR((Rt?s			4

Anon7 - 2021