summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2011-05-01 12:06:38 +0000
committerArthur de Jong <arthur@arthurdejong.org>2011-05-01 12:06:38 +0000
commitc537c3acc5727a65dd41f94182391365ce022d27 (patch)
treedfee6154d69cb5e1ff9ff7801fec52eee89e5641
parent4dd7a4f46b8df6ea21654dae655e8b84f571ec9b (diff)
small code improvements
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1451 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--pynslcd/group.py3
-rw-r--r--pynslcd/pam.py8
-rwxr-xr-xpynslcd/pynslcd.py8
3 files changed, 9 insertions, 10 deletions
diff --git a/pynslcd/group.py b/pynslcd/group.py
index d77479f..e3ee70a 100644
--- a/pynslcd/group.py
+++ b/pynslcd/group.py
@@ -29,6 +29,7 @@ def clean(lst):
for i in lst:
yield i.replace('\0', '')
+
class GroupRequest(common.Request):
filter = '(|(objectClass=posixGroup)(objectClass=groupOfUniqueNames))'
@@ -62,14 +63,12 @@ class GroupRequest(common.Request):
if self.wantmembers:
# add the memberUid values
for member in clean(attributes.get(self.attmap_group_memberUid, [])):
- #print 'found member %r' % member
if common.isvalidname(member):
members.add(member)
# translate and add the uniqueMember values
from passwd import dn2uid
for memberdn in clean(attributes.get(self.attmap_group_uniqueMember, [])):
member = dn2uid(self.conn, memberdn)
- #print 'found memberdn %r, member=%r' % ( memberdn, member)
if member:
members.add(member)
# actually return the results
diff --git a/pynslcd/pam.py b/pynslcd/pam.py
index 2203e19..f680a1e 100644
--- a/pynslcd/pam.py
+++ b/pynslcd/pam.py
@@ -56,16 +56,16 @@ class PAMRequest(common.Request):
# save the DN
self.userdn = entry[0]
# get the "real" username
- value = common.get_rdn_value(entry, PasswdRequest.attmap_passwd_uid)
+ value = common.get_rdn_value(entry, passwd.PasswdRequest.attmap_passwd_uid)
if not value:
# get the username from the uid attribute
- values = myldap_get_values(entry, PasswdRequest.attmap_passwd_uid)
+ values = myldap_get_values(entry, passwd.PasswdRequest.attmap_passwd_uid)
if not values or not values[0]:
- logging.warn('%s: is missing a %s attribute', entry.dn, PasswdRequest.attmap_passwd_uid)
+ logging.warn('%s: is missing a %s attribute', entry.dn, passwd.PasswdRequest.attmap_passwd_uid)
value = values[0]
# check the username
if value and not common.isvalidname(value):
- raise ValueError('%s: has invalid %s attribute', entry.dn, PasswdRequest.attmap_passwd_uid)
+ raise ValueError('%s: has invalid %s attribute', entry.dn, passwd.PasswdRequest.attmap_passwd_uid)
# check if the username is different and update it if needed
if value != self.username:
logging.info('username changed from %r to %r', self.username, value)
diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py
index 2deab07..8460c28 100755
--- a/pynslcd/pynslcd.py
+++ b/pynslcd/pynslcd.py
@@ -68,7 +68,7 @@ def display_version(fp):
'Copyright (C) 2010, 2011 Arthur de Jong\n'
'This is free software; see the source for copying conditions. There is NO\n'
'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n'
- % { 'PACKAGE_STRING': config.PACKAGE_STRING, } );
+ % { 'PACKAGE_STRING': config.PACKAGE_STRING, } )
def display_usage(fp):
fp.write("Usage: %(program_name)s [OPTION]...\n"
@@ -249,10 +249,10 @@ if __name__ == '__main__':
with daemon:
# start normal logging
if not cfg.debug:
- log_startlogging();
+ log_startlogging()
logging.info('version %s starting', config.VERSION)
# create socket
- nslcd_serversocket = create_socket();
+ nslcd_serversocket = create_socket()
# drop all supplemental groups
try:
os.setgroups(())
@@ -275,7 +275,7 @@ if __name__ == '__main__':
thread = threading.Thread(target=worker, name='thread%d' % i)
thread.setDaemon(True)
thread.start()
- logging.debug('started thread %s' % thread.getName())
+ logging.debug('started thread %s', thread.getName())
threads.append(thread)
# wait for all threads to die
for thread in threads: