Changeset 2757 for trunk/server/common
- Timestamp:
- Feb 26, 2016, 2:48:37 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/whoisd/whoisd.tac
r2756 r2757 3 3 from twisted.protocols import basic 4 4 import ldap, ldap.filter 5 import p wd5 import posixpath 6 6 7 7 class WhoisProtocol(basic.LineReceiver): … … 32 32 # return vhost + ".mit.edu" 33 33 def searchLDAP(self, vhost): 34 attrlist = ('scriptsVhostName', 'homeDirectory', 'scriptsVhostDirectory', 'uid') 34 35 results = self.ldap.search_st(self.ldap_base, ldap.SCOPE_SUBTREE, 35 36 ldap.filter.filter_format( 36 '(|( apacheServername=%s)(apacheServerAlias=%s))', (vhost,)*2),37 timeout=5)37 '(|(scriptsVhostName=%s)(scriptsVhostAlias=%s))', (vhost,)*2), 38 attrlist=attrlist, timeout=5) 38 39 if len(results) >= 1: 39 40 result = results[0] 40 41 attrs = result[1] 41 for attr in ('apacheServerName','apacheDocumentRoot', 'apacheSuexecUid', 'apacheSuexecGid'):42 for attr in attrlist: 42 43 attrs[attr] = attrs[attr][0] 43 user = pwd.getpwuid(int(attrs['apacheSuexecUid']))44 if user:45 attrs['locker'] = user.pw_name46 else:47 attrs['locker'] = None48 44 return attrs 49 45 else: … … 63 59 if info: 64 60 ret = "Hostname: %s\nAlias: %s\nLocker: %s\nDocument Root: %s" % \ 65 (info['apacheServerName'], vhost, info['locker'], info['apacheDocumentRoot']) 61 (info['scriptsVhostName'], vhost, info['uid'], 62 posixpath.join(info['homeDirectory'], 'web_scripts', info['scriptsVhostDirectory'])) 66 63 elif tries == 3: 67 64 ret = "The whois server is experiencing problems looking up LDAP records.\nPlease contact scripts@mit.edu for help if this problem persists."
Note: See TracChangeset
for help on using the changeset viewer.