imdZddlmZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddlZddlmZdZdZdZdZd Zd Zd Zd Zd ZdZdZeZdZdZdZdZ dZ!dZ"dZ#ej$%ej$&e'Z(GddZ)GddZ*GddZ+GddZ,da-dZ.dZ/Gdde0Z1Gdde1Z2Gd d!e1Z3d"Z4d#Z5dKd$Z6d%Z7d&Z8d'Z9d(Z:d)Z;dLd+Zd.Z?d/Z@d0ZAd1ZBd2ZCd3ZDd4ZEd5ZFd6ZGd7ZHd8ZId9ZJd:ZKd;ZLdMd<ZMdKd=ZNd>fd?ZOd@fdAZPeOePdBZQdNdGZRdHZSdddIdifdJZTdS)Oz?Installation utilities for Python ISAPI filters and extensions.) annotationsN)Mapping) GetObjectzIIS://LocalHost/W3SVC IIsWebServerIIsWebDirectoryIIsWebVirtualDir IIsFilters IIsFilterzDefault Web SitezX-Powered-By: PythonTFc8eZdZdZdZdZdZdZdZdZ dZ dZ dZ dS)FilterParametersNTc :|j|dSN__dict__updateselfkws ;C:\PYTHON\_runtimes\venv\Lib\site-packages\isapi/install.py__init__zFilterParameters.__init__; R     ) __name__ __module__ __qualname__Name DescriptionPathServerAddExtensionFileAddExtensionFile_EnabledAddExtensionFile_GroupIDAddExtensionFile_CanDeleteAddExtensionFile_Descriptionrrrrr/sU DK D F##!%#' !!!!!rrcpeZdZUdZdZeZeZdZ e Z e Z eZeZeZeZeZeZdZgZded<dZdZdZdZ dZ!dS)VirtualDirParametersNzlist[ScriptMapParams] ScriptMapsendc :|j|dSrrrs rrzVirtualDirParameters.__init__Rrrc<|\}}| o| S)zGThis virtual directory is a root directory if parent and name are blank) split_path)rparentnames ris_rootzVirtualDirParameters.is_rootUs$(( z&$h&rc*t|jSr)r.r)rs rr.zVirtualDirParameters.split_pathZs$)$$$r)"rrrrr_DEFAULT_PROTECTION AppProtection_DEFAULT_HEADERSHeadersr _IIS_WEBVIRTUALDIRType_DEFAULT_ACCESS_EXECUTE AccessExecute_DEFAULT_ACCESS_READ AccessRead_DEFAULT_ACCESS_WRITE AccessWrite_DEFAULT_ACCESS_SCRIPT AccessScript_DEFAULT_CONTENT_INDEXEDContentIndexed_DEFAULT_ENABLE_DIR_BROWSINGEnableDirBrowsing_DEFAULT_ENABLE_DEFAULT_DOCEnableDefaultDoc DefaultDocr*__annotations__ScriptMapUpdater!rr1r.r'rrr)r)?s DK'MG D D+M%J'K)L-N42J(*J****O F!!!''' %%%%%rr)c>eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dS)ScriptMapParamsNTc :|j|dSrrrs rrzScriptMapParams.__init__jrrc|j|j|jg}|jr||jd|D}d|S)z&Format this parameter suitable for IISc,g|]}t|Sr'str).0items r z+ScriptMapParams.__str__..ss---tT---r,) ExtensionModuleFlagsVerbsappendjoin)ritemss r__str__zScriptMapParams.__str__msUdj9 : % LL $ $ $--u---xxr)rrrrWrXrYrZr"r#r$r%r&rr^r'rrrKrK^sdI F E E##!%#' !!!rrKc6eZdZUeZgZded<gZded<dZdS)ISAPIParameterszlist[FilterParameters]Filterszlist[VirtualDirParameters] VirtualDirsc :|j|dSrrrs rrzISAPIParameters.__init__}rrN) rrr_DEFAULT_SERVER_NAME ServerNamerarHrbrr'rrr`r`wsL%J&(G((((.0K0000!!!!!rr`c>t|krt|dSdSr)verboseprint)levelwhats rlogrks$% d rc|j}|jr |jd}tj|tjkrtj|S)N)hresult excepinfowinerrorHRESULT_FACILITYFACILITY_WIN32 SCODE_CODE)com_exchrs r_GetWin32ErrorCodervsN B#  r " $$(???  r " ""rceZdZdS)InstallationErrorNrrrr'rrrxrxDrrxceZdZdS) ItemNotFoundNryr'rrr|r|rzrr|ceZdZdS)ConfigurationErrorNryr'rrr~r~rzrr~c|dr|S|r|ddkrd|z}t||dz|zS)Nziis://r/z/ROOT)lower startswith FindWebServer)optionsserverr0s rFindPathrs\ zz||x((?  DGsNN:DWf--7$>>rct|dks Jdtt}|}|D]fddD}||vr jcSd|z}t |)z Find an IIS web server whose name or comment matches the provided description (case-insensitive). >>> LocateWebServerPath('Default Web Site') # doctest: +SKIP or >>> LocateWebServerPath('1') #doctest: +SKIP rz"Server name or comment is requiredczg|]7}t|d8S)rM)getattrrstrip)rSattrsites rrUz'LocateWebServerPath..sM    D$ # # ) ) + + 1 1 3 3   r)r ServerCommentz'No web sites match the description '%s')lenr _IIS_OBJECTrrAdsPathr|) descriptioniissite_attributesmsgrs @rLocateWebServerPathrs {  q "F K C##%%++--K      1    / ) )<    * 3k AC s  rcJ|pd}t|}t|}|S)z Load the web server instance (COM object) for a given instance or description. If None is specified, the default website is retrieved (indicated by the identifier 1. 1)r LoadWebServer)rpathrs r GetWebServerrs-$K { + +D 4 F Mrc t|}nV#tj$rD}|j}|jr|jdr |jd}d|d|}t |d}~wwxYw|S)Nrz WebServer : )r pythoncom com_errorstrerrorror|)rrexcrs rrrs 4     l = #S]1- #-"C(4((3((3  MsA%?A  A%c|jp|}|r*t|ts|d}t |}|jS)z Legacy function to allow options to define a .server property to override the other parameter. Use GetWebServer instead. mbcs)r isinstancerRdecoderadsPath)r server_descrs rrrsU ./KK1:k3771!((00 + & &F >rcb|dsd|z}|ddS)a4 Get the parent path and basename. >>> split_path('/') ['', ''] >>> split_path('') ['', ''] >>> split_path('foo') ['', 'foo'] >>> split_path('/foo') ['', 'foo'] >>> split_path('/foo/bar') ['/foo', 'bar'] >>> split_path('foo/bar') ['/foo', 'bar'] rr)rrsplit)rs rr.r.s5. ??3  Tz ;;sA  rc |ds Jd|d|tdd|dn#tj$rYnwxYw||j|}tdd|d|jd |jp|j}||_ |j p|j }||_ n#t$rYnwxYw| |j |jr |j|_tdd |j|_|j|_|j|_|j|_|j|_|j|_|j|_|j |j|_||S) Nrmustn't delete the root!rMrzDeleted old directory ''zCreating new directory 'z' in z...zSetting directory options...)rDeleterkrrCreater8rrAppFriendlyNamer AttributeError AppCreate2r4r6HttpCustomHeadersr:r<r>r@rBrDrFrGSetInfo)iis_dirr0paramsnewDirfriendlyrs r_CreateDirectoryr s  zz#:: :::r4    A00001111       ^^FK . .F Bd B B B B BCCC!0V[H%F {*gl       f*+++~2#)>  )***!/F)F+F -F"1F%7F$5F $"- NN Ms$A A AA.C CCct|d||jstd|\}}t t ||j|}|st|||}t|j ||j t|d||tdd|j|S)N PreInstallz No Name param PostInstallrzConfigured Virtual Directory: ) _CallHookrr~r.rrr!r1rAssignScriptMapsr*rIrk)rrr/r0 target_dirs rCreateDirectoryr;s flG,,, ;2 111$$&&LFD8GV]FCCDDJ >>  @%j$?? V& F4JKKK fmWj999 9FK 9 9::: rreplacecd|z} t|}n"#t$rd|z}t|wxYwd|D}||||dS)aUpdates IIS with the supplied script map information. script_maps is a list of ScriptMapParameter objects target is an IIS Virtual Directory to assign the script maps to update is a string indicating how to update the maps, one of ('start', 'end', or 'replace') _AssignScriptMapsz#Unknown ScriptMapUpdate option '%s'c,g|]}t|Sr'rQ)rSss rrUz$AssignScriptMaps..^s///a3q66///rN) capitalizeeval NameErrorr~r) script_mapstargetrscript_map_funcrs rrrLs*F,=,=,?,??O&// &&&3f< %%%&0/;///KOFK((( NNs )Ac:tfd|DS)z:Return items in sequence that can't be found in reference.cg|]}|v| Sr'r')rSrT references rrUz$get_unique_items..fs#EEE4t9/D/D$/D/D/Dr)tuple)sequencers `rget_unique_itemsrds& EEEE8EEE F FFrc||_dSr)r*)rrs r_AssignScriptMapsReplaceris#FrcPt||j}|xj|z c_dSrrr*rrunique_new_mapss r_AssignScriptMapsEndrms.&{F4EFFO (rcNt||j}||jz|_dSrrrs r_AssignScriptMapsStartrrs*&{F4EFFO'&*;;Frct||j}t|d| t|dz}n#tj$r}t j|jt j ks't j |jt j krt|}| td}d|_|Yd}~nd}~wwxYw|jds Jd |t&|jt)dd|jd n#tj$rYnwxYw| t&|j}t)dd t*j|jsJ|j|_|j|_|d |jd D}|j|vrH||jd ||_|t|d ||t)dd|j|S)Nr/FiltersrarMrrrzDeleted old filter 'rzCreated new ISAPI filter...c:g|]}||Sr'rrSbs rrUz%CreateISAPIFilter..%MMM1M!''))MMMrrVrrzConfigured Filter: )rr!rrrrrprqrnrr HRESULT_CODEERROR_PATH_NOT_FOUNDr _IIS_FILTERSFilterLoadOrderrrrr _IIS_FILTERrkosrisfiler FilterPathrFilterDescriptionsplitr[r\) filterParamsrrfiltersr server_ob newFilter load_orders rCreateISAPIFilterrws} 7L$7 8 8F lL'222 FZ/00       %ck 2 2h6M M M$S[11X5RRR f%% ""<;;"$    " "3 ' 'CC)CCC ' {L$5666 A:l&7:::;;;;       {L,=>>I ())) 7>>,+ , ,,, ,',I".":I MMW%<%B%B3%G%GMMMJ **,+,,,"%((:"6"6 lM7I>>> 4!2 4 4555 s(;C( BC##C(9E EEct|d|t||j}|dz} t|}n1#tj$r}t dd|dYd}~dSd}~wwxYw |jds Jd| t|jt dd|jd nU#tj$rC}t|}|tj krt dd |jdYd}~nd}~wwxYwd |jd D}|j|vrH||jd ||_|t|d |t dd|jdS)N PreRemoverrzISAPI filter path 'z' did not exist.rrzDeleted ISAPI filter 'rzISAPI filter 'c:g|]}||Sr'rrs rrUz%DeleteISAPIFilter..rrrV PostRemoverzDeleted Filter: )rrr!rrrrkrrrrrvrprrrremover\r)rrrob_pathrdetailsrcrs rDeleteISAPIFilterrs  lK111 7L$7 8 8Fz!GG$$   A>W>>>???  E &&s++GG-GGG+{L$5666 A< (9<<<====  EEE  ( ( . . .  AC 1CCCDDDDDDDD E NMW%<%B%B3%G%GMMMJJ&&,+,,,"%((:"6"6 lL'222 1l/ 1 122222s.=A+ A&&A+/AC D9DDc<|jp|}|jp|} tt}|||j||j|tdd|d|ddS#tj tf$r!}tdd|d|Yd}~dSd}~wwxYw)NrzAdded extension file 'z' ()zFailed to add extension file '': ) r$r&rrr"r#r%rkrrr) module def_groupiddef_descrrgroup_iddescobrs r_AddExtensionFilers.=+H  . :(D F { # #    +   -      A:::4:::;;;;;   0FFF ADDD7DDEEEEEEEEEFsAA$$B:BBc 6i}|jD]H}|jD]>}|j|vr3|jr,t |j|j|j||d||j<?I|jD]>}|j|vr3|jr,t |j|j|j||d||j<?dS)zRegister the modules used by the filters/extensions as a trusted 'extension module' - required by the default IIS6 security settings.TN) rbr*rXr"rrrrar )rraddedvdsmpfds rAddExtensionFilesrs E ))= ) )Cz&&3+?&!#*bgr~sGTTT$(cj! ) n"" 7%  B$7  bgrwG L L L!E"'N""rc tt}||tdd|zdS#tjt f$r!}tdd|d|Yd}~dSd}~wwxYw)Nrz&Deleted extension file record for '%s'z!Failed to remove extension file 'r)rrDeleteExtensionFileRecordrkrrr)rrrrs r_DeleteExtensionFileRecordr sI { # # $$V,,, A7&@AAAAA   0III AG6GGgGGHHHHHHHHHIsz is up to date.) importlib machineryEXTENSION_SUFFIXESrrr\this_dirrr~statST_SIZEST_MTIMEOSErrorrkshutilcopyfilecopystat)dll_namesuffixtemplatesrc_stat dest_statsames rCheckLoaderModuler%sf!4!GGGTTRFw||H&6&?&&HIIH 7>>( # #Q !OX!O!O!OPPPwx  H GH%% T\ "i &= = D'9T]+CC   - A1811x11222(+++(+++++ A(+++,,,,,s C++ C:9C:cHt||d}|||f|z}||dSdSr)r)r hook_namer extra_argsfuncargss rrrs> 2y$ ' 'D G}z) d rct|d||jD]}t|||jD]}t ||t ||t|d|dS)Nrr)rrbrrarrrrrrs rInstallr-s flG,,, %%G$$$$n// *g....fg&&& fmW-----rc|rdS tt||j|j}nV#t j$rD}t|}|tj krtdd|jzd}Yd}~nd}~wwxYw| | n;#tj d}tdd|jd|YnxYw t|j}||j|jtdd|jdS#tj d}tdd|jd|YdSxYwdS) Nrz#VirtualDirectory '%s' did not existrzAppUnLoad() for z failed: zDeleted Virtual Directory: zFailed to remove directory r)r1rrr!rrrrvrprrk AppUnLoadsysexc_infoParentrClass)rr directoryrrexc_valr/s rRemoveDirectoryr6's ~~hw v{KKLL    ( ( . . .  A4v{BCCC   G    ! ! ! ! GlnnQ'G EfkEEGEE F F F F F Ky/00F MM)/9> : : : >>> ? ? ? ? ? KlnnQ'G IIIII J J J J J Js0(AB:BBB//6C'+A D996E2cD|\}}tt||j|}t |j}t t|jD]}||vr||||_| dS)z?Remove script maps from the already installed virtual directoryN) r.rrr!listr*maprRrr) vd_paramsrr/r0rinstalled_maps_maps rRemoveScriptMapsr=Cs''))LFD8GY-=vFFGGJ*/00NC-..(( > ! !  ! !$ ' ' '*Jrc^t|d|t|||jD]X}t|d|t|||rt ||t|d|Y|jD]}t||t|d|dS)Nrr)rrrbr6r1r=rarr,s r Uninstallr?Os fk7+++vw/// - -"k7+++G$$$ ::<< * R ) ) )"lG,,,,n// *g.... flG,,,,,rc|r1tj|st|d|jD]}|j||_|jD]}|jD]}|j||_dS)N does not exist) rrrr~rar rbr*rX)rrfile_must_existfdsms r_PatchParamsModulerFfsCw~~h'' C$%A%A%ABB B^ 6>AF  %%, % %By $  %%%rcttdrtj|\}}tj|\}}|dr |dd}tjtj||dz}ntj|\}}tj|\}}tjtj|d|zdz}|ttd }|rt||S)Nfrozenwrmr_) hasattrr0rrsplitextrendswithabspathr\r%)mod_name check_modulebaseextrrs rGetLoaderModuleNamerSus$sHLG$$X.. cW]]4(( d ==   9D7??27<<dVm#D#DEEG$$X.. cW]]4(( d7??27<<cDj66I#J#JKK"3111 $(### OrcdSrr'r*s rrVstrcFttdsPtj|}tj|st |dt|}t||t|||dddS)zInstall the extensionrHrArzInstallation complete.N) rKr0rrrNrr~rSrFr-conf_module_namerrrk loader_dlls r InstallModuler[s 3 ! !K7??+;<<w~~.// K$(8%I%I%IJJ J$%566Jvz*** FGC #$$$$$rcdSrr'rUs rrVrVsrct|d}t||dt|||dddS)zRemove the extensionFrzUninstallation complete.N)rSrFr?rXs rUninstallModuler^sM$%5u==Jvz5111 fgC %&&&&&r)installr handler_mapMapping[str, object]returnrRcd|}d|D}d|dd|zS)N|c0g|]\}}d|dd|jS) 10r)__doc__)rSarghandlers rrUzbuild_usage..s:   2>#wwW__-   rz%prog [options] [z ] commands:  )r\r])r` arg_namesliness r build_usagernsa%%I  BMBSBSBUBU   E 9y 8 8 8499U;K;K KKrcdS)zv Take an options object generated by the command line and merge the values into the IISParameters object. Nr')rrs rMergeStandardOptionsrps  Drr_cpddlm}|p tj}|sZtjd} t j|}n2#tj$r }tdd|d|Yd}~nd}~wwxYw| |d}n|}|sPt } | || t| | d | d |d d d ddd|dddddd|ddddt d||dd\} } t%| || ja| s|g} | D]} | | } | ||| tdS#t(t*f$rG}| jdkrt-jt1|jjd|Yd}~dSd}~wt6$r|d| zYdSwxYw)aPerform installation or removal of an ISAPI filter or extension. This module handles standard command-line options and configuration information, and installs, removes or updates the configuration of an ISAPI filter or extension. You must pass your configuration information in params - all other arguments are optional, and allow you to configure the installation process. r) OptionParserrz%Couldn't determine the long name for rNrM)usage uninstallrz-qz--quiet store_falsergTz%don't print status messages to stdout)actiondestdefaulthelpz-vz --verbositycountrz)increase the verbosity of status messagesz--serverstorez>Specifies the IIS server to install/uninstall on. Default is 'z/1')rvryzInvalid arg '%s')optparserrr0argvwin32apiGetLongPathNameerrorrk get_usagestandard_argumentscopyr set_usagern setdefault add_optionr parse_argsrprgr|rx traceback print_excrh __class__rKeyError)rr}rY default_arg opt_parsercustom_arg_handlersrrrparser all_handlersrr*rirjrs rHandleCommandLiners&&%%%%%  38D  8A;  '78HII  ~    S8HSScSS          B'''     4)..00 /000\22333Kh)?@@@    4     8   )#))) ''QRR11OWd&)))oG } / < rsEE#""""" ######%%%%%%   %   '  ))! $# 7??27??844 5 5 ! ! ! ! ! ! ! ! %%%%%%%%>2!!!!!!!!  ###             $        *   ???4       "8///d"0GGG $$$))) <<< &&&R333<FFF&""""III , , ,---4 . . .KKK8   ---. % % % %D:L9K % % % %