|
|
|
@ -5,14 +5,14 @@ This module contains functions for registering new members, registering |
|
|
|
|
members for terms, searching for members, and other member-related |
|
|
|
|
functions. |
|
|
|
|
|
|
|
|
|
Transactions are used in each method that modifies the database. |
|
|
|
|
Transactions are used in each method that modifies the database. |
|
|
|
|
Future changes to the members database that need to be atomic |
|
|
|
|
must also be moved into this module. |
|
|
|
|
""" |
|
|
|
|
import os, re, subprocess, ldap, socket |
|
|
|
|
from ceo import conf, ldapi, terms, remote, ceo_pb2 |
|
|
|
|
from ceo.excep import InvalidArgument |
|
|
|
|
|
|
|
|
|
import dns.resolver |
|
|
|
|
|
|
|
|
|
### Configuration ### |
|
|
|
|
|
|
|
|
@ -179,11 +179,16 @@ def check_email(email): |
|
|
|
|
if c in ('"', "'", ',', '|', '$', '/', '#', ':'): |
|
|
|
|
return 'Invalid character in address: %s' % c |
|
|
|
|
|
|
|
|
|
# Start by searching for host record |
|
|
|
|
host = match.group(1) |
|
|
|
|
try: |
|
|
|
|
ip = socket.gethostbyname(host) |
|
|
|
|
ip = socket.getaddrinfo(host, None) |
|
|
|
|
except: |
|
|
|
|
return 'Invalid host: %s' % host |
|
|
|
|
# Check for MX record |
|
|
|
|
try: |
|
|
|
|
dns.resolver.query(host, 'MX') |
|
|
|
|
except: |
|
|
|
|
return 'Invalid host: %s' % host |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def current_email(username): |
|
|
|
@ -433,7 +438,7 @@ def set_shell(userid, shell): |
|
|
|
|
def create_club(username, name): |
|
|
|
|
""" |
|
|
|
|
Creates a UNIX user account with options tailored to CSC-hosted clubs. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parameters: |
|
|
|
|
username - the desired UNIX username |
|
|
|
|
name - the club name |
|
|
|
@ -449,7 +454,7 @@ def create_club(username, name): |
|
|
|
|
# check username format |
|
|
|
|
if not username or not re.match(cfg['username_regex'], username): |
|
|
|
|
raise InvalidArgument("username", username, "expected format %s" % repr(cfg['username_regex'])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
request = ceo_pb2.AddUser() |
|
|
|
|
request.type = ceo_pb2.AddUser.CLUB |
|
|
|
|