config root man

Current Path : /usr/local/lib/python2.5/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/local/lib/python2.5/rexec.pyc

hRc@sdZddkZddkZddkZddkZddkZdgZdfdYZdefdYZdZ	d	efd
YZ
deifdYZei
ZeiZdeifd
YZdZedjoeiendS(s9Restricted execution facilities.

The class RExec exports methods r_exec(), r_eval(), r_execfile(), and
r_import(), which correspond roughly to the built-in operations
exec, eval(), execfile() and import, but executing the code in an
environment that only exposes those built-in operations that are
deemed safe.  To this end, a modest collection of 'fake' modules is
created which mimics the standard modules by the same names.  It is a
policy decision which built-in modules and operations are made
available; this module provides a reasonable default, but derived
classes can change the policies e.g. by overriding or extending class
variables like ok_builtin_modules or methods like make_sys().

XXX To do:
- r_open should allow writing tmp dir
- r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?)

iNtRExectFileBasecBseZdZRS(
tfilenotflushtisattytreadtreadlinet	readlinestseekttelltwritet
writelinest
xreadlinest__iter__(sfilenosflushsisattysreadsreadlines	readlinessseekstellswrites
writeliness
xreadliness__iter__(t__name__t
__module__tok_file_methods(((s!/usr/local/lib/python2.5/rexec.pyRstFileWrappercBseZdZdZRS(cCsVxO|iD]D}t||o-t||ot||t||q
q
WdS(N(Rthasattrtsetattrtgetattr(tselftftm((s!/usr/local/lib/python2.5/rexec.pyt__init__(s
!cCs|idS(N(R(R((s!/usr/local/lib/python2.5/rexec.pytclose-s(RRRR(((s!/usr/local/lib/python2.5/rexec.pyR$s	sL
def %s(self, *args):
        return getattr(self.mod, self.name).%s(*args)
tFileDelegatecBs;eZdZx'eidD]ZeeefdUqWRS(cCs||_||_dS(N(tmodtname(RRR((s!/usr/local/lib/python2.5/rexec.pyR8s	RN(sclose(RRRRRRtTEMPLATE(((s!/usr/local/lib/python2.5/rexec.pyR6s	tRHookscBs}eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
cGsd}d}|o5t|dtdjo|d}|d }n|o,t|ddo|d}|d}n|o
tdntii||||_dS(Niit	__class__istoo many arguments(tNonettypeRt	TypeErrortihookstHooksRtrexec(RtargstverboseR%((s!/usr/local/lib/python2.5/rexec.pyRBs$


cCs
||_dS(N(R%(RR%((s!/usr/local/lib/python2.5/rexec.pyt	set_rexecSscCs
|iiS(N(R%tget_suffixes(R((s!/usr/local/lib/python2.5/rexec.pyR)WscCs|ii|S(N(R%t
is_builtin(RR((s!/usr/local/lib/python2.5/rexec.pyR*ZscCst|}|ii|dS(N((t
__import__R%tcopy_except(RRR((s!/usr/local/lib/python2.5/rexec.pytinit_builtin]scCs
tddS(Nsdon't use this(tSystemError(RR((s!/usr/local/lib/python2.5/rexec.pytinit_frozenascGs
tddS(Nsdon't use this(R.(RR&((s!/usr/local/lib/python2.5/rexec.pytload_sourcebscGs
tddS(Nsdon't use this(R.(RR&((s!/usr/local/lib/python2.5/rexec.pyt
load_compiledcscGs
tddS(Nsdon't use this(R.(RR&((s!/usr/local/lib/python2.5/rexec.pytload_packagedscCs|ii|||S(N(R%tload_dynamic(RRtfilenametfile((s!/usr/local/lib/python2.5/rexec.pyR3fscCs|ii|S(N(R%t
add_module(RR((s!/usr/local/lib/python2.5/rexec.pyR6iscCs
|iiS(N(R%tmodules(R((s!/usr/local/lib/python2.5/rexec.pytmodules_dictlscCs|iidiS(Ntsys(R%R7tpath(R((s!/usr/local/lib/python2.5/rexec.pytdefault_pathos(RRRR(R)R*R-R/R0R1R2R3R6R8R;(((s!/usr/local/lib/python2.5/rexec.pyR@s												cBseZdZeeiZdXZdYZdZZ	d[Z
eiei
fZd\d3d4Zd5Zd6Zd7Zd8Zd9Zd:Zd;Zd<Zd=Zd>Zd?Zd@ZdAZdBZdCZdDZ hhgdEZ!dFZ"dGZ#dHZ$dIZ%dJZ&dKZ'dLZ(d]hdMZ)dNZ*dOZ+dPZ,dQZ-dRZ.dSZ/dTdUdVZ0dWZ1RS(^sBasic restricted execution framework.

    Code executed in this restricted environment will only have access to
    modules and functions that are deemed safe; you can subclass RExec to
    add or remove capabilities as desired.

    The RExec class can prevent code from performing unsafe operations like
    reading or writing disk files, or using TCP/IP sockets.  However, it does
    not protect against code using extremely large amounts of memory or
    processor time.

    taudiooptarraytbinasciitcmathterrnotimageoptmarshaltmathtmd5toperatortparsertselecttshat_sretstroptstructttimet_weakrefterrortfstattlistdirtlstattreadlinktstatttimestunametgetpidtgetppidtgetcwdtgetuidtgetgidtgeteuidtgetegidt	byteordert	copyrighttexittgetdefaultencodingtgetrefcountt
hexversiontmaxintt
maxunicodetplatformtps1tps2tversiontversion_infotopenR5treloadR+icCstdtii|||p
t||_|ii|h|_|i|_	g}x2|iD]'}|t
ijo|i|qgqgWt
||_|i|i|i|it|i||_t|i||_dS(sReturns an instance of the RExec class.

        The hooks parameter is an instance of the RHooks class or a subclass
        of it.  If it is omitted or None, the default RHooks class is
        instantiated.

        Whenever the RExec module searches for a module (even a built-in one)
        or reads a module's code, it doesn't actually go out to the file
        system itself.  Rather, it calls methods of an RHooks instance that
        was passed to or created by its constructor.  (Actually, the RExec
        object doesn't make these calls --- they are made by a module loader
        object that's part of the RExec object.  This allows another level of
        flexibility, which can be useful when changing the mechanics of
        import within the restricted environment.)

        By providing an alternate RHooks object, we can control the file
        system accesses made to import a module, without changing the
        actual algorithm that controls the order in which those accesses are
        made.  For instance, we could substitute an RHooks object that
        passes all filesystem requests to a file server elsewhere, via some
        RPC mechanism such as ILU.  Grail's applet loader uses this to support
        importing applets from a URL for a directory.

        If the verbose parameter is true, additional debugging output may be
        sent to standard output.

        s/This code is not secure in Python 2.2 and laterN(tRuntimeErrorR#t_VerboseRRthooksR(R7tok_builtin_modulestok_dynamic_modulesR9tbuiltin_module_namestappendttupletset_trusted_pathtmake_builtintmake_initial_modulestmake_syst
RModuleLoadertloadertRModuleImportertimporter(RRnR'tlisttmname((s!/usr/local/lib/python2.5/rexec.pyRs$		




cCsttiiti|_dS(N(tfiltertosR:tisabsR9ttrusted_path(R((s!/usr/local/lib/python2.5/rexec.pyRtscCsm||ijotd|n|tijoti|}nti|||}|i|g}|S(Nsuntrusted dynamic module: %s(RptImportErrorR9R7timpR3R,(RRR4R5tsrctdst((s!/usr/local/lib/python2.5/rexec.pyR3scCs|i|idS(N(t	make_maintmake_osname(R((s!/usr/local/lib/python2.5/rexec.pyRvs
cCs=g}tiD]%}|d|ijo||qq~S(Ni(RR)t
ok_file_types(Rt_[1]titem((s!/usr/local/lib/python2.5/rexec.pyR)scCs
||ijS(N(Ro(RR}((s!/usr/local/lib/python2.5/rexec.pyR*scCsD|it|i}|i|_|i|_|i|_|_	dS(N(
R,t__builtin__tnok_builtin_namestr_importR+tr_reloadRktr_openRjR5(RR((s!/usr/local/lib/python2.5/rexec.pyRuscCs|id}dS(Nt__main__(R6(RR((s!/usr/local/lib/python2.5/rexec.pyRscCseti}t|}|i||i}h|_}x'tiiD]\}}|||<qGWdS(N(RRR+t	copy_onlytok_posix_namestenvirontitems(RtosnameRRtetkeytvalue((s!/usr/local/lib/python2.5/rexec.pyRs	
cCs|it|i}|i|_dg|_td|i|_|i	|_
|id}|iit|i
}|it||_dS(Nt
RESTRICTEDR9(RR9tok_sys_namesR7targvtmapR tok_pathR:t
r_exc_infotexc_infotkeysR|RotsortRsRq(RRtl((s!/usr/local/lib/python2.5/rexec.pyRws

c	Cs{|i|}x-t|D]}t||t||qWx5|D]-}yt||WqFtj
oqFXqFW|S(N(t	copy_nonetdirRRtdelattrtAttributeError(RRt
exceptionsRR((s!/usr/local/lib/python2.5/rexec.pyR,s
	cCs`|i|}xJ|D]B}yt||}Wntj
o
qnXt|||qW|S(N(RRRR(RRtnamesRRR((s!/usr/local/lib/python2.5/rexec.pyRscCs"|i|i}|i|_|S(N(R6Rt__doc__(RRR((s!/usr/local/lib/python2.5/rexec.pyR scCsT|ii|}|djo!|ii||i|<}n|id|_|S(NR(R7tgetR Rnt
new_modulet__builtins__(RR}R((s!/usr/local/lib/python2.5/rexec.pyR6's

!cBs|id}||iUdS(sExecute code within a restricted environment.

        The code parameter must either be a string containing one or more
        lines of Python code, or a compiled code object, which will be
        executed in the restricted environment's __main__ module.

        RN(R6t__dict__(RtcodeR((s!/usr/local/lib/python2.5/rexec.pytr_exec0scCs|id}t||iS(sFEvaluate code within a restricted environment.

        The code parameter must either be a string containing a Python
        expression, or a compiled code object, which will be evaluated in
        the restricted environment's __main__ module.  The value of the
        expression or code object will be returned.

        R(R6tevalR(RRR((s!/usr/local/lib/python2.5/rexec.pytr_eval;s	cCs#|id}t||idS(sfExecute the Python code in the file in the restricted
        environment's __main__ module.

        RN(R6texecfileR(RR5R((s!/usr/local/lib/python2.5/rexec.pyt
r_execfileGscCs|ii||||S(s=Import a module, raising an ImportError exception if the module
        is considered unsafe.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        (R{t
import_module(RR}tglobalstlocalstfromlist((s!/usr/local/lib/python2.5/rexec.pyROs	cCs|ii|S(sReload the module object, re-parsing and re-initializing it.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        (R{Rk(RR((s!/usr/local/lib/python2.5/rexec.pyRZscCs|ii|S(s@Unload the module.

        Removes it from the restricted environment's sys.modules dictionary.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        (R{tunload(RR((s!/usr/local/lib/python2.5/rexec.pytr_unloadds
cCs}|id}t|d|_t|d|_t|d|_tti|_tti	|_
tti|_dS(NR9tstdintstdouttstderr(
R7Rtdelegate_stdintdelegate_stdouttdelegate_stderrRR9Rtrestricted_stdinRtrestricted_stdoutRtrestricted_stderr(Rts((s!/usr/local/lib/python2.5/rexec.pytmake_delegate_filesrs
cCst|dp|int|dp|in|id}|i|_|i|_|i|_	|i
t_|it_|i
t_	dS(Nt
save_stdinRR9(Rt
save_filesRR7RRRRRRRR9RR(RR((s!/usr/local/lib/python2.5/rexec.pyt	set_files{s
cCs?|i|id}|i|_|i|_|i|_dS(NR9(t
restore_filesR7RRRRRR(RR((s!/usr/local/lib/python2.5/rexec.pytreset_filess


cCs(ti|_ti|_ti|_dS(N(R9RRRtsave_stdoutRtsave_stderr(R((s!/usr/local/lib/python2.5/rexec.pyRscCs(|it_|it_|it_dS(N(RR9RRRRR(R((s!/usr/local/lib/python2.5/rexec.pyRscCs9|iz|i|||}Wd|iX|S(N(RRR(RtfuncR&tkwtr((s!/usr/local/lib/python2.5/rexec.pyts_applys

cGs|i|i|S(sExecute code within a restricted environment.

        Similar to the r_exec() method, but the code will be granted access
        to restricted versions of the standard I/O streams sys.stdin,
        sys.stderr, and sys.stdout.

        The code parameter must either be a string containing one or more
        lines of Python code, or a compiled code object, which will be
        executed in the restricted environment's __main__ module.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyts_execscGs|i|i|S(sEvaluate code within a restricted environment.

        Similar to the r_eval() method, but the code will be granted access
        to restricted versions of the standard I/O streams sys.stdin,
        sys.stderr, and sys.stdout.

        The code parameter must either be a string containing a Python
        expression, or a compiled code object, which will be evaluated in
        the restricted environment's __main__ module.  The value of the
        expression or code object will be returned.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyts_evals
cGs|i|i|S(s!Execute the Python code in the file in the restricted
        environment's __main__ module.

        Similar to the r_execfile() method, but the code will be granted
        access to restricted versions of the standard I/O streams sys.stdin,
        sys.stderr, and sys.stdout.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyt
s_execfiles	cGs|i|i|S(sImport a module, raising an ImportError exception if the module
        is considered unsafe.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        Similar to the r_import() method, but has access to restricted
        versions of the standard I/O streams sys.stdin, sys.stderr, and
        sys.stdout.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyts_imports
cGs|i|i|S(sReload the module object, re-parsing and re-initializing it.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        Similar to the r_reload() method, but has access to restricted
        versions of the standard I/O streams sys.stdin, sys.stderr, and
        sys.stdout.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyts_reloadscGs|i|i|S(sUnload the module.

        Removes it from the restricted environment's sys.modules dictionary.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        Similar to the r_unload() method, but has access to restricted
        versions of the standard I/O streams sys.stdin, sys.stderr, and
        sys.stdout.

        (RR(RR&((s!/usr/local/lib/python2.5/rexec.pyts_unloadsRicCs6t|}|djo
tdnt|||S(sGMethod called when open() is called in the restricted environment.

        The arguments are identical to those of the open() function, and a
        file object (or a class instance compatible with file objects)
        should be returned.  RExec's default behaviour is allow opening
        any file for reading, but forbidding any attempt to write a file.

        This method is implicitly called by code executing in the
        restricted environment.  Overriding this method in a subclass is
        used to change the policies enforced by a restricted environment.

        Rtrbs/can't open files for writing in restricted mode(Rsrb(tstrtIOErrorRj(RR5tmodetbuf((s!/usr/local/lib/python2.5/rexec.pyRs


cCs(ti\}}}d}|||fS(N(R9RR (Rttytvattr((s!/usr/local/lib/python2.5/rexec.pyRs(R<sarrayR>R?serrnoRAsmarshalRCRDRERFRGRHs_sreRJRKRLRM(serrorsfstatslistdirslstatsreadlinksstatstimessunamesgetpidsgetppidsgetcwdsgetuidsgetgidsgeteuidsgetegid(
s	byteorders	copyrightsexitsgetdefaultencodingsgetrefcounts
hexversionsmaxints
maxunicodesplatformRfRgsversionsversion_info(sopensfilesreloads
__import__N((2RRRRsR9R:RRoRRRRtC_EXTENSIONt	PY_SOURCERR RRtR3RvR)R*RuRRRwR,RRR6RRRRRRRRRRRRRRRRRRRR(((s!/usr/local/lib/python2.5/rexec.pyRxsd3		
							
		
							
				
										csddk}ddk}|itidd\}}d}g}xM|D]E\}}|djo|d}n|djo|i|qJqJWtd||oit|_n|o>|id_idi	i
dti	i|dnidi	i
dd	ti
}|o_|dd
joNyt|d}Wqtj
o'}	dtid|dfGHdSqXn|ioyddk}
Wntj
onXddkdiffd
Y}y|idiiWqtj
o
}|SqXnm|i}
|it|
|id}yi|Wn-tj
o
}|Sn|idSnXdS(Niisvt:is-vs-tR'R9tt-s%s: can't open file %rtRestrictedConsolecseZfdZRS(cs4id|id<iii||fdS(NRR(R7RRtInteractiveConsoletruncode(Rtco(RR(s!/usr/local/lib/python2.5/rexec.pyR4s(RRR((RR(s!/usr/local/lib/python2.5/rexec.pyR3sRtexec(tgetoptt	tracebackR9RRrRRoRsR7R:tinsertRtdirnameRRjRRRRRRRtinteractt
SystemExitRRtcompileRRt	print_exc(RRtoptsR&R'ttrustedtotatfptmsgRRtnttexttc((RRs!/usr/local/lib/python2.5/rexec.pyttestsZ

.	

"


R(RR9RRR#Rt__all__RRRRR$RtFancyModuleLoaderRxtModuleImporterRzRmRRRR_(((s!/usr/local/lib/python2.5/rexec.pys<module>s$	
4			4


Man Man