* some pylint fixes (addresses #24)
* add pydoc in client and domain backend classes * add support for buildutils in setup.py git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@262 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
4ee62d5b2e
commit
daf9517a83
13 changed files with 147 additions and 69 deletions
|
@ -28,7 +28,7 @@ import grp
|
|||
class PasswdUser(object):
|
||||
"""This class represents users in the user database."""
|
||||
|
||||
def __init__(self, username, pw, uid, gid, gecos, home, shell):
|
||||
def __init__(self, username, passw, uid, gid, gecos, home, shell):
|
||||
"""Create a new PasswdUser."""
|
||||
self.username = username
|
||||
self.uid = int(uid)
|
||||
|
@ -51,7 +51,7 @@ class PasswdUser(object):
|
|||
class PasswdGroup(object):
|
||||
"""This class represents lines in the groups database."""
|
||||
|
||||
def __init__(self, groupname, pw, gid, members):
|
||||
def __init__(self, groupname, passwd, gid, members):
|
||||
"""Create a new PasswdGroup."""
|
||||
self.groupname = groupname
|
||||
self.gid = int(gid)
|
||||
|
@ -109,7 +109,7 @@ def get_next_uid(lowerboundary = 10000, upperboundary = 65536):
|
|||
"""
|
||||
for uid in range(lowerboundary, upperboundary):
|
||||
try:
|
||||
user = pwd.getpwuid(uid)
|
||||
pwd.getpwuid(uid)
|
||||
except KeyError:
|
||||
return uid
|
||||
raise Exception("no free uid found in range %d to %d",
|
||||
|
|
|
@ -25,14 +25,14 @@ import crack
|
|||
import random
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_pwchars = []
|
||||
_PWCHARS = []
|
||||
for _pair in (('0', '9'), ('A', 'Z'), ('a', 'z')):
|
||||
_pwchars.extend(range(ord(_pair[0]), ord(_pair[1])))
|
||||
_saltchars = [_char for _char in _pwchars]
|
||||
_PWCHARS.extend(range(ord(_pair[0]), ord(_pair[1])))
|
||||
_SALTCHARS = [_char for _char in _PWCHARS]
|
||||
for _char in "-+/*_@":
|
||||
_pwchars.append(ord(_char))
|
||||
_PWCHARS.append(ord(_char))
|
||||
|
||||
|
||||
def generatepassword(minlength = 8, maxlength = 12):
|
||||
|
@ -41,12 +41,11 @@ def generatepassword(minlength = 8, maxlength = 12):
|
|||
The generated password has a length between minlength and maxlength.
|
||||
|
||||
Keyword arguments:
|
||||
minlength -- minimum length of the generated password
|
||||
maxlength -- the maximum length of the generated password
|
||||
|
||||
`minlength` -- minimum length of the generated password
|
||||
`maxlength` -- the maximum length of the generated password
|
||||
"""
|
||||
return "".join([chr(letter) for letter in \
|
||||
random.sample(_pwchars,
|
||||
random.sample(_PWCHARS,
|
||||
random.randint(minlength, maxlength))])
|
||||
|
||||
|
||||
|
@ -57,12 +56,12 @@ def checkpassword(password):
|
|||
returned.
|
||||
|
||||
Arguments:
|
||||
password -- the password to check
|
||||
`password` -- the password to check
|
||||
"""
|
||||
try:
|
||||
return crack.VeryFascistCheck(password)
|
||||
except ValueError, ve:
|
||||
log.info("Weak password: %s", ve)
|
||||
LOG.info("Weak password: %s", ve)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -72,10 +71,10 @@ def md5_crypt_password(password):
|
|||
A password hashed with MD5 and a random salt value is returned.
|
||||
|
||||
Arguments:
|
||||
password -- the password to hash
|
||||
`password` -- the password to hash
|
||||
"""
|
||||
salt = "".join([chr(letter) for letter in \
|
||||
random.sample(_saltchars, 8)])
|
||||
random.sample(_SALTCHARS, 8)])
|
||||
return crypt.crypt(password, '$1$' + salt)
|
||||
|
||||
|
||||
|
@ -83,7 +82,7 @@ def get_pw_tuple(password = None):
|
|||
"""Gets a valid (password, hashvalue) tuple.
|
||||
|
||||
The tuple consists of a password and a md5 hash of the same
|
||||
password. If a password is given it is checked and if it is too
|
||||
password. If a `password` is given it is checked and if it is too
|
||||
weak replaced by a generated one.
|
||||
|
||||
"""
|
||||
|
@ -92,8 +91,8 @@ def get_pw_tuple(password = None):
|
|||
return (password, md5_crypt_password(password))
|
||||
|
||||
|
||||
def validate_password(hash, password):
|
||||
"""Validates whether the given clear text password matches the
|
||||
given hash value.
|
||||
def validate_password(hashvalue, password):
|
||||
"""Validates whether the given clear text `password` matches the
|
||||
given `hashvalue`.
|
||||
"""
|
||||
return hash == crypt.crypt(password, hash)
|
||||
return hashvalue == crypt.crypt(password, hashvalue)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
creation."""
|
||||
|
||||
if __name__ == '__main__':
|
||||
from passwordutils import get_pw_tuple
|
||||
from gnuviechadmin.util.passwordutils import get_pw_tuple
|
||||
import sys
|
||||
|
||||
for line in sys.stdin.readlines():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue