Changeset 343

Show
Ignore:
Timestamp:
09/01/06 14:24:45 (2 years ago)
Author:
mj
Message:

Implement attachment port password configurations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • z3wingdbg/trunk/TODO.txt

    r342 r343  
    1111---------------- 
    1212 
    13 - Implement connection accepting 
    1413- Raise exceptions with message ids 
    1514 
     
    2625- Add a configuration view to the wing debugger management views 
    2726- Show server url in status screen 
     27- Show attachment port status in status screen 
    2828- Deal with import errors from wing 
  • z3wingdbg/trunk/debugger/networkdebugger.py

    r329 r343  
    33 
    44import logging 
     5import os 
    56 
    67from zope import component, interface 
     8from zope.i18n import MessageFactory 
    79 
    810from z3wingdbg.interfaces import INetworkDebugger, INetworkDebuggerFactory 
    9 from z3wingdbg.interfaces import IWingPathInformation 
     11from z3wingdbg.interfaces import IWingPathInformation, DebugServerStartError 
     12from z3wingdbg.interfaces import PWD_PROFILE, PWD_PATH, PWD_MANUAL 
    1013from netservermodule import INetServerModule 
     14 
     15_ = MessageFactory('z3wingdbg') 
    1116 
    1217class LogWrapper(object): 
     
    4348    _networkserver = None 
    4449     
    45     def __init__(self, wing_home, host, port, attachport): 
     50    def __init__(self, wing_home, host, port, attachport, pwsource=PWD_PROFILE, 
     51                 pwpath=None, pw=None): 
    4652        pathinfo = component.getUtility(IWingPathInformation) 
    4753        nsmodule = component.getUtility(INetServerModule) 
     
    5460                'supports one active debugger per process.') 
    5561         
    56         attach = (attachport is None) and -1 or attachport 
    57          
     62        attach = -1 
     63        pwdir = (netserver.abstract.kPWFilePathUserProfileDir,) 
     64        pwfile = '.wingdebugpw' 
     65        if attachport is not None: 
     66            attach = attachport 
     67            if pwsource == PWD_PATH: 
     68                if not os.path.exists(pwpath or ''): 
     69                    raise DebugServerStartError( 
     70                        _(u'No valid password source path specified')) 
     71                if os.path.isfile(pwpath): 
     72                    pwpath, pwfile = os.path.split(pwpath) 
     73                pwdir = (pwpath,) 
     74             
    5875        logger = netserver.abstract.CErrStream((LogWrapper(),)) 
    5976        server = netserver.CNetworkServer( 
    60             host, port, attach, logger, 
    61             pwfile_path=(netserver.abstract.kPWFilePathUserProfileDir,)) 
     77            host, port, attach, logger, pwfile_path=pwdir, pwfile_name=pwfile) 
    6278         
    63         # netserver insists we set a non-empty string, but securechannel  
    64         # ignores it completely when the channel is set to NoEncryption 
    65         if attachport is None: 
     79        if attachport is None or pwsource == PWD_MANUAL: 
     80            # netserver insists we set a non-empty string, but only uses 
     81            # the password for verifying incoming attachment requests. 
     82            password = (pwsource != PWD_MANUAL) and 'ignored' or pw 
    6683            server.SetSecurityInfo( 
    67                 netserver.abstract.securechannel.kNoEncryption, 'ignored') 
    68          
     84                netserver.abstract.securechannel.kNoEncryption, password) 
     85             
     86        if attachport is not None and not server.IsSecurityInfoValid(): 
     87            raise DebugServerStartError( 
     88                _(u'No valid password source was provided, please check your ' 
     89                  u'configuration')) 
     90             
    6991        # We set our own sockethook later 
    7092        server.SetUseSocketHooksOnImport(False) 
     
    96118def createDebugger(config): 
    97119    return NetworkDebugger(config.wingHome, config.ideHost, config.idePort, 
    98                            config.attachPort) 
     120                           config.attachPort, config.attachPasswordSource, 
     121                           config.attachPasswordPath, config.attachPassword) 
    99122 
    100123factory = component.factory.Factory(