mirror of https://github.com/zulip/zulip.git
Use PyDNS instead of shelling out to `host`
On Debian systems, this is found in the `python-dns` package. On OS X and others, install "pydns" using your Python package manager. (imported from commit 17827d0a1d3d72b12945df5563295a1573bfa1ed)
This commit is contained in:
parent
9c8a9ac947
commit
368ace069c
|
@ -7,7 +7,7 @@ class zulip::app_frontend {
|
|||
$web_packages = [ "memcached", "python-pylibmc", "python-tornado", "python-django",
|
||||
"python-pygments", "python-flup", "python-psycopg2",
|
||||
"yui-compressor", "python-django-auth-openid",
|
||||
"python-django-statsd-mozilla",
|
||||
"python-django-statsd-mozilla", "python-dns",
|
||||
"build-essential", "libssl-dev", "python-ujson",
|
||||
"python-defusedxml", "python-twitter",
|
||||
"python-twisted", "python-markdown",
|
||||
|
|
|
@ -42,7 +42,7 @@ import confirmation.settings
|
|||
|
||||
from zerver import tornado_callbacks
|
||||
|
||||
import subprocess
|
||||
import DNS
|
||||
import ujson
|
||||
import time
|
||||
import traceback
|
||||
|
@ -165,17 +165,11 @@ def compute_mit_user_fullname(email):
|
|||
# Input is either e.g. starnine@mit.edu or user|CROSSREALM.INVALID@mit.edu
|
||||
match_user = re.match(r'^([a-zA-Z0-9_.-]+)(\|.+)?@mit\.edu$', email.lower())
|
||||
if match_user and match_user.group(2) is None:
|
||||
dns_query = "%s.passwd.ns.athena.mit.edu" % (match_user.group(1),)
|
||||
proc = subprocess.Popen(['host', '-t', 'TXT', dns_query],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
out, _err_unused = proc.communicate()
|
||||
if proc.returncode == 0:
|
||||
# Parse e.g. 'starnine:*:84233:101:Athena Consulting Exchange User,,,:/mit/starnine:/bin/bash'
|
||||
# for the 4th passwd entry field, aka the person's name.
|
||||
hesiod_name = out.split(':')[4].split(',')[0].strip()
|
||||
if hesiod_name == "":
|
||||
return email
|
||||
answer = DNS.dnslookup(
|
||||
"%s.passwd.ns.athena.mit.edu" % (match_user.group(1),),
|
||||
DNS.Type.TXT)
|
||||
hesiod_name = answer[0].split(':')[4].split(',')[0].strip()
|
||||
if hesiod_name != "":
|
||||
return hesiod_name
|
||||
elif match_user:
|
||||
return match_user.group(1).lower() + "@" + match_user.group(2).upper()[1:]
|
||||
|
|
Loading…
Reference in New Issue