Browse Source

Linted Files To a great extent without having to refactor major chuncks (#25)

* Linted useradm to be slightly more pep8

* Linted rbaccount

* Linted rbconfig

* Linted rberror

* Linted rbopt

* Linted rbuser.py

* Linted rbuserdb.py

* Linted sever.py
pull/26/head
greenday 4 years ago
committed by Cian Butler
parent
commit
1ecead5e96
8 changed files with 905 additions and 723 deletions
  1. +12
    -10
      useradm/rbaccount.py
  2. +91
    -81
      useradm/rbconfig.py
  3. +3
    -0
      useradm/rberror.py
  4. +1
    -0
      useradm/rbopt.py
  5. +8
    -7
      useradm/rbuser.py
  6. +28
    -27
      useradm/rbuserdb.py
  7. +9
    -6
      useradm/server.py
  8. +753
    -592
      useradm/useradm.py

+ 12
- 10
useradm/rbaccount.py View File

@@ -27,6 +27,7 @@ __author__ = 'Cillian Sharkey'
# CLASSES #
#-----------------------------------------------------------------------------#


class RBAccount:
"""Class to interface with Unix accounts."""

@@ -55,7 +56,7 @@ class RBAccount:
self.cmd('%s -Rp %s %s' % (rbconfig.command_cp, rbconfig.dir_skel, usr.homeDirectory))
self.wrapper(os.chmod, usr.homeDirectory, 0o711)
self.wrapper(os.symlink, webtree, os.path.join(usr.homeDirectory, 'public_html'))
#symlink vuln fix
# symlink vuln fix
try:
self.wrapper(os.chown, os.path.join(usr.homeDirectory, 'public_html'),
usr.uidNumber, usr.gidNumber)
@@ -128,7 +129,7 @@ class RBAccount:

"""

# XXX Should check this before we rename user in ldap, have a
# fixme Should check this before we rename user in ldap, have a
# rbaccount.check_userfree? There should never be a file or
# directory in /home or /webtree that doesn't belong to an
# existing user.
@@ -181,7 +182,7 @@ class RBAccount:
except OSError as err:
raise RBFatalError("Could not rename '%s' to '%s' [%s]" % (oldf, newf, err))

# XXX
# fixme
# Rename their subscription to announce lists in case an email
# alias isn't put in for them or is later removed.
#
@@ -198,14 +199,14 @@ class RBAccount:

# Do supplementary group shit in rbuserdb.
#
#if rbconfig.convert_primary_groups.has_key(usertype):
# if rbconfig.convert_primary_groups.has_key(usertype):
# group = rbconfig.convert_primary_groups[usertype]
#else:
# else:
# group = usertype

#if rbconfig.convert_extra_groups.has_key(usertype):
# if rbconfig.convert_extra_groups.has_key(usertype):
# groups = '-G ' + rbconfig.convert_extra_groups[usertype]
#else:
# else:
# groups = ''

if newusr.usertype == 'committe' and oldusr.usertype not in ('member', 'staff', 'committe'):
@@ -225,7 +226,7 @@ class RBAccount:
#
try:
self.wrapper(os.rename, oldusr.homeDirectory, newusr.homeDirectory)
except:
except BaseException:
raise RBFatalError("Could not rename home directory")

# Change the home directory and webtree ownership to the new
@@ -254,13 +255,14 @@ class RBAccount:
"""Disable an account with optional automatic re-enabling after
given period."""

#TODO
# fixme

def reuser(self, username):
"""Re-enable an account."""

#TODO
# fixme

# This need to be made and object and passed. To be done with refactoring
def quota_set(self, username, filesystem, bqs, bqh, iqs, iqh):
"""Set given quota for given username on given filesystem.
Format for quota values is the same as that used for quotas


+ 91
- 81
useradm/rbconfig.py View File

@@ -7,6 +7,8 @@
# System modules

import os
import random
import string

#---------------------------------------------------------------------#
# DATA #
@@ -17,44 +19,44 @@ __author__ = 'Cillian Sharkey'

# Find out where the rrs directory is.

dir_rrs = (os.path.dirname(__file__) or '.') + os.sep
DIR_RRS = (os.path.dirname(__file__) or '.') + os.sep

# Maximum length of usernames and groups.

maxlen_uname = 8
maxlen_group = 8
MAXLEN_UNAME = 8
MAXLEN_GROUP = 8

# Default LDAP account attribute values.

ldap_default_objectClass = ['posixAccount', 'top', 'shadowAccount']
ldap_default_hosts = ['paphos', 'metharme']
LDAP_DEFAULT_OBJECTCLASS = ['posixAccount', 'top', 'shadowAccount']
LDAP_DEFAULT_HOSTS = ['paphos', 'metharme']

# RedBrick LDAP settings.

ldap_uri = 'ldap://ldap.internal'
ldap_root_dn = 'cn=root,ou=ldap,o=redbrick'
ldap_rootpw_file = '/etc/ldap.secret'
ldap_tree = 'o=redbrick'
ldap_accounts_tree = 'ou=accounts,o=redbrick'
ldap_group_tree = 'ou=groups,o=redbrick'
ldap_reserved_tree = 'ou=reserved,o=redbrick'
LDAP_URI = 'ldap://ldap.internal'
LDAP_ROOT_DN = 'cn=root,ou=ldap,o=redbrick'
LDAP_ROOTPW_FILE = '/etc/ldap.secret'
LDAP_TREE = 'o=redbrick'
LDAP_ACCOUNTS_TREE = 'ou=accounts,o=redbrick'
LDAP_GROUP_TREE = 'ou=groups,o=redbrick'
LDAP_RESERVED_TREE = 'ou=reserved,o=redbrick'

# DCU LDAP settings.

ldap_dcu_uri = 'ldap://ad.dcu.ie'
ldap_dcu_tree = 'o=ad,o=dcu,o=ie'
ldap_dcu_rbdn = 'CN=rblookup,OU=Service Accounts,DC=ad,DC=dcu,DC=ie'
ldap_dcu_rbpw = '/etc/dcu_ldap.secret'
ldap_dcu_students_tree = 'OU=Students,DC=ad,DC=dcu,DC=ie'
LDAP_DCU_URI = 'ldap://ad.dcu.ie'
LDAP_DCU_TREE = 'o=ad,o=dcu,o=ie'
LDAP_DCU_RBDN = 'CN=rblookup,OU=Service Accounts,DC=ad,DC=dcu,DC=ie'
LDAP_DCU_RBPW = '/etc/dcu_ldap.secret'
LDAP_DCU_STUDENTS_TREE = 'OU=Students,DC=ad,DC=dcu,DC=ie'
#'ou=students,dc=ad,dc=dcu,dc=ie'
ldap_dcu_staff_tree = 'OU=Staff,DC=ad,DC=dcu,DC=ie'
LDAP_DCU_STAFF_TREE = 'OU=Staff,DC=ad,DC=dcu,DC=ie'
#'ou=staff,dc=ad,dc=dcu,dc=ie'
ldap_dcu_alumni_tree = 'OU=Alumni,DC=ad,DC=dcu,DC=ie'
LDAP_DCU_ALUMNI_TREE = 'OU=Alumni,DC=ad,DC=dcu,DC=ie'
#'ou=alumni,o=dcu'

# DNS zones RedBrick is authorative for.

dns_zones = (
DCU_ZONES = (
'redbrick.dcu.ie',
'club.dcu.ie',
'soc.dcu.ie',
@@ -62,104 +64,105 @@ dns_zones = (

# Mailman list suffixes.

mailman_list_suffixes = ("-admin", "-bounces", "-confirm", "-join", "-leave", "-owner", "-request", "-subscribe", "-unsubscribe")
MAILMAN_LIST_SUFFIXES = ("-admin", "-bounces", "-confirm", "-join", "-leave",
"-owner", "-request", "-subscribe", "-unsubscribe")

# Directory pathnames.

dir_home = '/home'
dir_webtree = '/webtree'
dir_signaway_state = '/local/share/agreement/statedir'
dir_daft = '/local/share/daft'
dir_skel = '/etc/skel'
dir_mailman = '/var/lib/mailman'
DIR_HOME = '/home'
DIR_WEBTREE = '/webtree'
DIR_SIGNAWAY_STATE = '/local/share/agreement/statedir'
DIR_DAFT = '/local/share/daft'
DIR_SKEL = '/etc/skel'
DIR_MAILMAN = '/var/lib/mailman'

# Filenames.

file_uidNumber = dir_rrs + 'uidNumber.txt'
file_pre_sync = dir_rrs + 'presync.txt'
file_rrslog = dir_rrs + 'rrs.log'
file_shells = '/etc/shells'
file_backup_passwd = '/var/backups/passwd.pre-expired'
shell_default = '/usr/local/shells/zsh'
shell_expired = '/usr/local/shells/expired'
FILE_UIDNUMBER = DIR_RRS + 'uidNumber.txt'
FILE_PRE_SYNC = DIR_RRS + 'presync.txt'
FILE_RRSLOG = DIR_RRS + 'rrs.log'
FILE_SHELLS = '/etc/shells'
FILE_BACKUP_PASSWD = '/var/backups/passwd.pre-expired'
SHELL_DEFAULT = '/usr/local/shells/zsh'
SHELL_EXPIRED = '/usr/local/shells/expired'

# Unix group files: (group file, hostname) pairs.

files_group = (
FILES_GROUP = (
('/etc/group', 'Deathray'),
('/local/share/var/carbon/group', 'Carbon')
)

# host files: (host file, hostname) pairs.

files_host = (
FILES_HOST = (
('/etc/hosts', 'Deathray'),
('/local/share/var/carbon/hosts', 'Carbon')
)

# Email alias files.

files_alias = (
FILES_ALIAS = (
('/etc/mail/exim_aliases.txt', 'Mail alias'),
)

# Commands.

command_setquota = '/usr/sbin/setquota'
command_chown = '/bin/chown'
command_chgrp = '/bin/chgrp'
command_cp = '/bin/cp'
command_sendmail = '/usr/sbin/sendmail'
COMMAND_SETQUOTA = '/usr/sbin/setquota'
COMMAND_CHOWN = '/bin/chown'
COMMAND_CHGRP = '/bin/chgrp'
COMMAND_CP = '/bin/cp'
COMMAND_SENDMAIL = '/usr/sbin/sendmail'

# Valid account usertypes and descriptions.
# Valid account USERTYPES and descriptions.
#
usertypes = {
'founders': 'RedBrick founder',
'member': 'Normal member',
'associat': 'Graduate/associate member',
'staff': 'DCU staff member',
'society': 'DCU society',
'club': 'DCU club',
'projects': 'RedBrick/DCU/Course project account',
'guest': 'Guest account',
'intersoc': 'Account for society from another college',
'committe': 'Committee member or a position account',
'redbrick': 'RedBrick related account',
'dcu': 'DCU related account'
USERTYPES = {
'founders': 'RedBrick founder',
'member': 'Normal member',
'associat': 'Graduate/associate member',
'staff': 'DCU staff member',
'society': 'DCU society',
'club': 'DCU club',
'projects': 'RedBrick/DCU/Course project account',
'guest': 'Guest account',
'intersoc': 'Account for society from another college',
'committe': 'Committee member or a position account',
'redbrick': 'RedBrick related account',
'dcu': 'DCU related account'
}

# "Ordered" list of usertypes for listing with the exception of founders.
# "Ordered" list of USERTYPES for listing with the exception of founders.
#
usertypes_list = (
USERTYPES_LIST = (
'member', 'associat', 'staff', 'committe',
'society', 'club', 'dcu',
'projects', 'redbrick', 'intersoc', 'guest'
)

# List of paying usertypes.
# List of paying USERTYPES.
#
usertypes_paying = ('member', 'associat', 'staff', 'committe', 'guest')
USERTYPES_PAYING = ('member', 'associat', 'staff', 'committe', 'guest')

# List of dcu usertypes (i.e. require a id number)
# List of dcu USERTYPES (i.e. require a id number)
#
usertypes_dcu = ('member', 'associat', 'staff', 'committe')
USERTYPES_DCU = ('member', 'associat', 'staff', 'committe')

# Pseudo usertypes for conversion to committee positions.
# Pseudo USERTYPES for conversion to committee positions.
#
convert_usertypes = {
'admin': 'Elected admin',
'webmaster': 'Elected webmaster',
'helpdesk': 'Elected helpdesk'
CONVERT_USERTYPES = {
'admin': 'Elected admin',
'webmaster': 'Elected webmaster',
'helpdesk': 'Elected helpdesk'
}

# Supplementary groups when converting an account to given usertype.
#
# Format: 'usertype': 'a string of comma seperated groups with no spaces'
#
convert_extra_groups = {
'admin': 'root,log',
'webmaster': 'root,log,webgroup',
'helpdesk': 'helpdesk'
CONVERT_EXTRA_GROUPS = {
'admin': 'root,log',
'webmaster': 'root,log,webgroup',
'helpdesk': 'helpdesk'
}

# Actual primary group to use when converting an account to given usertype
@@ -167,18 +170,22 @@ convert_extra_groups = {
#
# Format: 'usertype': 'actual unix group name'
#
convert_primary_groups = {
'admin': 'committe',
'webmaster': 'committe',
'helpdesk': 'committe'
CONVERT_PRIMARY_GROUPS = {
'admin': 'committe',
'webmaster': 'committe',
'helpdesk': 'committe'
}

#---------------------------------------------------------------------#
# MODULE FUNCTIONS #
#---------------------------------------------------------------------#


def gen_passwd():
pass
"""Create a random string and return it for the users password"""
return ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits)
for _ in range(12))


def gen_homedir(username, usertype):
"""Construct a user's home directory path given username and usertype."""
@@ -188,12 +195,14 @@ def gen_homedir(username, usertype):
else:
letter = ''

return '%s/%s/%s%s' % (dir_home, usertype, letter, username)
return '%s/%s/%s%s' % (DIR_HOME, usertype, letter, username)


def gen_webtree(username):
"""Generate a user's webtree path for given username."""

return os.path.join(dir_webtree, username[0], username)
return os.path.join(DIR_WEBTREE, username[0], username)


def gen_quotas():
"""Returns a dictionary of quota limits for filesystems (possibly
@@ -213,14 +222,15 @@ def gen_quotas():
'/storage': (1000000, 1100000, 800000, 1000000)
}


def gen_extra_user_files(username):
"""Return list of files that may belong to the given user outside of
their main storage areas. For purposes of renaming or deleting."""

# XXX: need files for carbon now aswell.
# fixme: need files for carbon now aswell.

return (
'%s/%s' % (dir_signaway_state, username),
return (
'%s/%s' % (DIR_SIGNAWAY_STATE, username),
'/var/mail/%s' % username,
'/var/spool/cron/crontabs/%s' % username
)

+ 3
- 0
useradm/rberror.py View File

@@ -15,6 +15,7 @@ __author__ = 'Cillian Sharkey'
# CLASSES #
#-----------------------------------------------------------------------------#


class RBError(Exception):
"""Base class for RedBrick exceptions"""

@@ -28,6 +29,7 @@ class RBError(Exception):

return "ERROR: %s" % self.mesg


class RBFatalError(RBError):
"""Class for fatal RedBrick exceptions"""

@@ -36,6 +38,7 @@ class RBFatalError(RBError):

return "FATAL: %s" % self.mesg


class RBWarningError(RBError):
"""Class for warning RedBrick exceptions. These can be overrided."""



+ 1
- 0
useradm/rbopt.py View File

@@ -15,6 +15,7 @@ __author__ = 'Cillian Sharkey'
# CLASSES #
#-----------------------------------------------------------------------------#


class RBOpt:
"""Class for storing options to be shared by modules"""



+ 8
- 7
useradm/rbuser.py View File

@@ -15,6 +15,7 @@ __author__ = 'Cillian Sharkey'
# CLASSES #
#-----------------------------------------------------------------------------#


class RBUser:
"""Class to represent a user."""

@@ -25,7 +26,7 @@ class RBUser:
# Attributes associated with user.

'uid', # Username
'usertype', # XXX NOT IN LDAP: contains primary
'usertype', # fixme NOT IN LDAP: contains primary
# usertype from objectClass list.
# Placed here so it's at start of
# output for user's information.
@@ -64,7 +65,7 @@ class RBUser:
'bmonth', # Birthday month
'byear', # Birthday year
'disuser_period', # at(1) timespec
#XXX remove usr.override
# fixme remove usr.override
#'override' # Boolean
)

@@ -76,7 +77,7 @@ class RBUser:
# Attributes associated with user to be used for the useradm info command

'uid', # Username
'usertype', # XXX NOT IN LDAP: contains primary
'usertype', # fixme NOT IN LDAP: contains primary
# usertype from objectClass list.
# Placed here so it's at start of
# output for user's information.
@@ -126,10 +127,10 @@ class RBUser:
if i in attrs:
setattr(self, i, attrs[i])
elif not hasattr(self, i):
# XXX set list attributes to empty list [] or None ??
#if i in self.attr_list_value:
# fixme set list attributes to empty list [] or None ??
# if i in self.attr_list_value:
# setattr(self, i, [])
#else:
# else:
setattr(self, i, None)

def merge(self, usr, override=0):
@@ -142,5 +143,5 @@ class RBUser:

for i in self.attr_list_all:
if (hasattr(usr, i) and (getattr(self, i) is None or override) and
getattr(usr, i) != None):
getattr(usr, i) is not None):
setattr(self, i, getattr(usr, i))

+ 28
- 27
useradm/rbuserdb.py View File

@@ -32,6 +32,7 @@ __author__ = 'Cillian Sharkey'
# CLASSES #
#-----------------------------------------------------------------------------#


class RBUserDB:
"""Class to interface with user database."""
valid_shells = None
@@ -43,7 +44,7 @@ class RBUserDB:
self.ldap = None
self.ldap_dcu = None

#def connect(self, uri = rbconfig.ldap_uri, dn = rbconfig.ldap_root_dn, password = None,
# def connect(self, uri = rbconfig.ldap_uri, dn = rbconfig.ldap_root_dn, password = None,
# dcu_uri = rbconfig.ldap_dcu_uri):
def connect(self, uri=rbconfig.ldap_uri, dn=rbconfig.ldap_root_dn, password=None,
dcu_uri=rbconfig.ldap_dcu_uri, dcu_dn=rbconfig.ldap_dcu_rbdn, dcu_pw=None):
@@ -144,7 +145,7 @@ class RBUserDB:
# INFORMATION RETRIEVAL METHODS #
#---------------------------------------------------------------------#

# XXX still needed ?
# fixme still needed ?
# def get_usertype_byname(self, uid):
# """Return usertype for username in user database. Raise
# RBFatalError if user does not exist."""
@@ -183,7 +184,7 @@ class RBUserDB:
"""Checks if ID already belongs to an existing user and if so
raises RBFatalError. Populates RBUser object with data for new
user from DCU databases otherwise raises RBWarningError."""
if usr.id != None:
if usr.id is not None:
tmpusr = RBUser(id=usr.id)
try:
self.get_user_byid(tmpusr)
@@ -211,7 +212,7 @@ class RBUserDB:
self.get_user_byid(curusr)

usr.usertype = usr.usertype or curusr.usertype
usr.id = usr.id != None and usr.id or curusr.id
usr.id = usr.id if usr.id is not None else curusr.id
self.check_renewal_usertype(usr.usertype)

if usr.usertype in rbconfig.usertypes_dcu:
@@ -296,7 +297,7 @@ class RBUserDB:
else:
usertype = 'staff'

# XXX: this overrides committe people (typically back to member)
# fixme: this overrides committe people (typically back to member)
# which probably shouldn't be done?
if usertype and (override or not usr.usertype):
usr.usertype = usertype
@@ -407,7 +408,7 @@ class RBUserDB:
def get_backup_shell(self, username):
"""Return shell for given user from previous year's LDAP tree
or failing that, the default shell."""
# XXX Use old passwd.backup file FTTB. Should use
# fixme Use old passwd.backup file FTTB. Should use
# ou=<prevyear>,ou=accounts tree instead.
if self.backup_shells is None:
self.backup_shells = {}
@@ -466,14 +467,14 @@ class RBUserDB:
@classmethod
def check_renewal_usertype(cls, usertype):
"""Raise RBFatalError if renewal usertype is not valid."""
if not usertype in rbconfig.usertypes_paying:
if usertype not in rbconfig.usertypes_paying:
raise RBFatalError("Invalid renewal usertype '%s'" % usertype)

@classmethod
def check_id(cls, usr):
"""Raise RBFatalError if ID is not valid for usertypes that require one."""
if usr.usertype in rbconfig.usertypes_dcu:
if usr.id != None:
if usr.id is not None:
if not isinstance(usr.id, int):
raise RBFatalError('ID must be an integer')
if usr.id >= 100000000:
@@ -485,7 +486,7 @@ class RBUserDB:
def check_years_paid(cls, usr):
"""Raise RBFatalError if years_paid is not valid."""
if usr.usertype in rbconfig.usertypes_paying:
if usr.yearsPaid != None:
if usr.yearsPaid is not None:
if not isinstance(usr.yearsPaid, int):
raise RBFatalError('Years paid must be an integer')
if usr.yearsPaid < -1:
@@ -540,7 +541,7 @@ class RBUserDB:
def check_unpaid(self, usr):
"""Raise RBWarningError if the user is already paid up."""

if usr.yearsPaid != None and usr.yearsPaid > 0:
if usr.yearsPaid is not None and usr.yearsPaid > 0:
self.rberror(RBWarningError("User '%s' is already paid!" % usr.uid))

#---------------------------------------------------------------------#
@@ -691,7 +692,7 @@ class RBUserDB:
"""Show RBUser object information on standard output."""

for i in usr.attr_list_all:
if getattr(usr, i) != None:
if getattr(usr, i) is not None:
print("%13s: %s" % (i, getattr(usr, i)))

@classmethod
@@ -699,7 +700,7 @@ class RBUserDB:
"""Show passwordless RBUser object information on standard output."""

for i in usr.attr_list_info:
if getattr(usr, i) != None:
if getattr(usr, i) is not None:
print("%13s: %s" % (i, getattr(usr, i)))

@classmethod
@@ -713,7 +714,7 @@ class RBUserDB:

for i in 'uid', 'usertype', 'newbie', 'cn', 'altmail', 'id', 'course', 'year', 'yearsPaid':
info = getattr(usr, i)
if info != None:
if info is not None:
old_info = getattr(oldusr, i, None)
print("%15s: %s" % (old_info != info and "(NEW) " + i or i, info))
if old_info != info:
@@ -887,8 +888,8 @@ class RBUserDB:
and data."""
raise RBFatalError("NOT IMLEMENTED YET")
self.cur.execute(('SELECT username, usertype, id, name, course, year, email '
'FROM users WHERE ')
+ where + ' %s', ('%%%s%%' % var,))
'FROM users WHERE ') +
where + ' %s', ('%%%s%%' % var,))
return self.cur.fetchall()

def search_dcu_byid(self, user_id):
@@ -960,7 +961,7 @@ class RBUserDB:
usertypes[usr.usertype]['TOTAL'] += 1
signed = not self.opt.dbonly and os.path.exists(os.path.join(
rbconfig.dir_signaway_state, uid))
pay = usr.yearsPaid == None and 'nonpay' or usr.yearsPaid > 0 and 'paid' or 'unpaid'
pay = usr.yearsPaid is None and 'nonpay' or usr.yearsPaid > 0 and 'paid' or 'unpaid'
usertypes[usr.usertype][pay] += 1
usertypes[usr.usertype]['%s_%s' % (not signed and 'nosign' or 'signed', pay)] += 1

@@ -983,7 +984,7 @@ class RBUserDB:
print(" " * 9, end=' ')
for cat in categories:
if len(cat) > 6:
print("%7.6s" % cat[-(len(cat)-6):], end=' ')
print("%7.6s" % cat[-(len(cat) - 6):], end=' ')
else:
print("%7s" % cat, end=' ')
print()
@@ -1042,7 +1043,7 @@ class RBUserDB:
if password:
return "{CRYPT}" + cls.crypt(password)

# XXX: is this correct way to disable password?
# fixme: is this correct way to disable password?
return "{CRYPT}*"

@classmethod
@@ -1155,13 +1156,13 @@ class RBUserDB:
('userPassword', usr.userPassword),
('host', usr.host)
]
if usr.id != None:
if usr.id is not None:
tmp.append(('id', str(usr.id)))
if usr.course:
tmp.append(('course', usr.course))
if usr.year != None:
if usr.year is not None:
tmp.append(('year', usr.year))
if usr.yearsPaid != None:
if usr.yearsPaid is not None:
tmp.append(('yearsPaid', str(usr.yearsPaid)))
if usr.birthday:
tmp.append(('birthday', usr.birthday))
@@ -1179,13 +1180,13 @@ class RBUserDB:
(ldap.MOD_REPLACE, 'updatedby', usr.updatedby),
(ldap.MOD_REPLACE, 'updated', usr.updated),
]
if usr.id != None:
if usr.id is not None:
tmp.append((ldap.MOD_REPLACE, 'id', str(usr.id)))
if usr.course:
tmp.append((ldap.MOD_REPLACE, 'course', usr.course))
if usr.year != None:
if usr.year is not None:
tmp.append((ldap.MOD_REPLACE, 'year', usr.year))
if usr.yearsPaid != None:
if usr.yearsPaid is not None:
tmp.append((ldap.MOD_REPLACE, 'yearsPaid', str(usr.yearsPaid)))
if usr.birthday:
tmp.append((ldap.MOD_REPLACE, 'birthday', usr.birthday))
@@ -1203,13 +1204,13 @@ class RBUserDB:
(ldap.MOD_REPLACE, 'updatedby', usr.updatedby),
(ldap.MOD_REPLACE, 'updated', usr.updated)
]
if usr.id != None:
if usr.id is not None:
tmp.append((ldap.MOD_REPLACE, 'id', str(usr.id)))
if usr.course:
tmp.append((ldap.MOD_REPLACE, 'course', usr.course))
if usr.year != None:
if usr.year is not None:
tmp.append((ldap.MOD_REPLACE, 'year', usr.year))
if usr.yearsPaid != None:
if usr.yearsPaid is not None:
tmp.append((ldap.MOD_REPLACE, 'yearsPaid', str(usr.yearsPaid)))
if usr.birthday:
tmp.append((ldap.MOD_REPLACE, 'birthday', usr.birthday))


+ 9
- 6
useradm/server.py View File

@@ -4,19 +4,22 @@
import http.server
import cgitb

cgitb.enable() ## This line enables CGI error reporting
cgitb.enable() # This line enables CGI error reporting

SERVER = http.server.HTTPServer
HANDLER = http.server.CGIHTTPRequestHandler
SERVER_ADDRESS = ("", 8000)

server = http.server.HTTPServer
handler = http.server.CGIHTTPRequestHandler
server_address = ("", 8000)

class Handler(http.server.CGIHTTPRequestHandler):
"""Handler for cgi requests"""

def is_cgi(self):
self.cgi_info = '', self.path[1:]
if self.path[1:].startswith("rrs.cgi"):
return True
return False

httpd = server(server_address, Handler)
httpd.serve_forever()

HTTPD = SERVER(SERVER_ADDRESS, Handler)
HTTPD.serve_forever()

+ 753
- 592
useradm/useradm.py
File diff suppressed because it is too large
View File


Loading…
Cancel
Save