Changeset 2756 for trunk/server/common


Ignore:
Timestamp:
Feb 26, 2016, 2:48:34 AM (9 years ago)
Author:
andersk
Message:
whoisd: Ignore Apache configuration files

There is no relevant information there as of r2731.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/whoisd/whoisd.tac

    r1742 r2756  
    33from twisted.protocols import basic
    44import ldap, ldap.filter
    5 import os, sys, pwd, glob
     5import pwd
    66
    77class WhoisProtocol(basic.LineReceiver):
     
    1919class WhoisFactory(protocol.ServerFactory):
    2020    protocol = WhoisProtocol
    21     def __init__(self, vhostDir, ldap_URL, ldap_base, keyFile):
    22         self.vhostDir = vhostDir
     21    def __init__(self, ldap_URL, ldap_base, keyFile):
    2322        self.ldap_URL = ldap_URL
    2423        self.ldap = ldap.initialize(self.ldap_URL)
    2524        self.ldap_base = ldap_base
    26         self.vhosts = {}
    27         if vhostDir:
    28             self.rescanVhosts()
    2925        self.key = file(keyFile).read()
    30     def rescanVhosts(self):
    31         newVhosts = {}
    32         for f in glob.iglob(os.path.join(self.vhostDir, "*.conf")):
    33             locker = os.path.splitext(os.path.basename(f))[0]
    34             newVhosts.update(self.parseApacheConf(file(f)))
    35         self.vhosts = newVhosts
    36         self.vhostTime = os.stat(self.vhostDir).st_mtime
    37     def parseApacheConf(self, f):
    38         vhosts = {}
    39         hostnames = []
    40         locker = None
    41         docroot = None
    42         for l in f:
    43             parts = l.split()
    44             if not parts: continue
    45             command = parts.pop(0)
    46             if command in ("ServerName", "ServerAlias"):
    47                 hostnames.extend(parts)
    48             elif command in ("SuExecUserGroup",):
    49                 locker = parts[0]
    50             elif command in ("DocumentRoot",):
    51                 docroot = parts[0]
    52             elif command == "</VirtualHost>":
    53                 d = {'locker': locker, 'apacheDocumentRoot': docroot, 'apacheServerName': hostnames[0]}
    54                 for h in hostnames: vhosts[h] = d
    55                 hostnames = []
    56                 locker = None
    57                 docroot = None
    58         return vhosts
    5926    def canonicalize(self, vhost):
    6027        vhost = vhost.lower().rstrip(".")
     
    8451    def getWhois(self, vhost):
    8552        vhost = self.canonicalize(vhost)
    86         info = self.vhosts.get(vhost)
     53        info = None
    8754        tries = 0
    8855        while (tries < 3) and not info:
     
    10471
    10572application = service.Application('whois', uid=99, gid=99)
    106 factory = WhoisFactory(None,
     73factory = WhoisFactory(
    10774    "ldap://localhost", "ou=VirtualHosts,dc=scripts,dc=mit,dc=edu", "/etc/whoisd-password")
    10875internet.TCPServer(43, factory).setServiceParent(
Note: See TracChangeset for help on using the changeset viewer.