diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-05-01 14:14:54 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-05-01 14:14:54 +0200 |
commit | 13ddc63d947d11106a4183604017f9ae57bffe41 (patch) | |
tree | da0d4d4c28a12bb687fb637cae179b3121603e74 /pynslcd | |
parent | c537c3acc5727a65dd41f94182391365ce022d27 (diff) |
pass dn and attributes to functions separately
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1452 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd')
-rw-r--r-- | pynslcd/alias.py | 3 | ||||
-rw-r--r-- | pynslcd/common.py | 4 | ||||
-rw-r--r-- | pynslcd/ether.py | 3 | ||||
-rw-r--r-- | pynslcd/host.py | 5 | ||||
-rw-r--r-- | pynslcd/netgroup.py | 3 | ||||
-rw-r--r-- | pynslcd/network.py | 5 | ||||
-rw-r--r-- | pynslcd/pam.py | 2 | ||||
-rw-r--r-- | pynslcd/passwd.py | 3 | ||||
-rw-r--r-- | pynslcd/protocol.py | 5 | ||||
-rw-r--r-- | pynslcd/rpc.py | 5 | ||||
-rw-r--r-- | pynslcd/service.py | 5 | ||||
-rw-r--r-- | pynslcd/shadow.py | 3 |
12 files changed, 18 insertions, 28 deletions
diff --git a/pynslcd/alias.py b/pynslcd/alias.py index 979d266..940a98f 100644 --- a/pynslcd/alias.py +++ b/pynslcd/alias.py @@ -33,8 +33,7 @@ class AliasRequest(common.Request): attributes = ( 'cn', 'rfc822MailMember' ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name and check against requested name names = attributes.get(self.attmap_cn, []) if not names: diff --git a/pynslcd/common.py b/pynslcd/common.py index 1b1f2cb..0440272 100644 --- a/pynslcd/common.py +++ b/pynslcd/common.py @@ -95,7 +95,7 @@ class Request(object): res = self.conn.search_s(base, self.scope, self.mk_filter(), self.attributes) for entry in res: if entry[0]: - self.write(entry) + self.write(entry[0], entry[1]) except ldap.NO_SUCH_OBJECT: # FIXME: log message pass @@ -121,6 +121,6 @@ def get_handlers(module): res[cls.action] = cls return res -def get_rdn_value(entry, attribute): +def get_rdn_value(dn, attribute): dn, attributes = entry return dict((x, y) for x, y, z in ldap.dn.str2dn(dn)[0])[attribute] diff --git a/pynslcd/ether.py b/pynslcd/ether.py index e5724b8..fca25e6 100644 --- a/pynslcd/ether.py +++ b/pynslcd/ether.py @@ -45,8 +45,7 @@ class EtherRequest(common.Request): super(EtherRequest, self).__init__(*args) self.ether = None - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name and check against requested name names = attributes.get(self.attmap_cn, []) if not names: diff --git a/pynslcd/host.py b/pynslcd/host.py index 1f5d58c..b8c86d0 100644 --- a/pynslcd/host.py +++ b/pynslcd/host.py @@ -33,9 +33,8 @@ class HostRequest(common.Request): attributes = ( 'cn', 'ipHostNumber' ) - def write(self, entry): - dn, attributes = entry - hostname = common.get_rdn_value(entry, self.attmap_cn) + def write(self, dn, attributes): + hostname = common.get_rdn_value(dn, self.attmap_cn) hostnames = attributes.get(self.attmap_cn, []) if not hostnames: print 'Error: entry %s does not contain %s value' % ( dn, self.attmap_cn ) diff --git a/pynslcd/netgroup.py b/pynslcd/netgroup.py index b31343c..a7c6344 100644 --- a/pynslcd/netgroup.py +++ b/pynslcd/netgroup.py @@ -38,8 +38,7 @@ class NetgroupRequest(common.Request): attributes = ( 'cn', 'nisNetgroupTriple', 'memberNisNetgroup' ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get names and check against requested user name names = attributes.get(self.attmap_cn, []) if self.name: diff --git a/pynslcd/network.py b/pynslcd/network.py index 397d669..ca54cfe 100644 --- a/pynslcd/network.py +++ b/pynslcd/network.py @@ -33,9 +33,8 @@ class NetworkRequest(common.Request): attributes = ( 'cn', 'ipNetworkNumber' ) - def write(self, entry): - dn, attributes = entry - networkname = common.get_rdn_value(entry, self.attmap_cn) + def write(self, dn, attributes): + networkname = common.get_rdn_value(dn, self.attmap_cn) networknames = attributes.get(self.attmap_cn, []) if not networknames: print 'Error: entry %s does not contain %s value' % ( dn, self.attmap_cn) diff --git a/pynslcd/pam.py b/pynslcd/pam.py index f680a1e..61fcea7 100644 --- a/pynslcd/pam.py +++ b/pynslcd/pam.py @@ -56,7 +56,7 @@ class PAMRequest(common.Request): # save the DN self.userdn = entry[0] # get the "real" username - value = common.get_rdn_value(entry, passwd.PasswdRequest.attmap_passwd_uid) + value = common.get_rdn_value(entry[0], passwd.PasswdRequest.attmap_passwd_uid) if not value: # get the username from the uid attribute values = myldap_get_values(entry, passwd.PasswdRequest.attmap_passwd_uid) diff --git a/pynslcd/passwd.py b/pynslcd/passwd.py index 5176244..1876b15 100644 --- a/pynslcd/passwd.py +++ b/pynslcd/passwd.py @@ -52,8 +52,7 @@ class PasswdRequest(common.Request): bases = ( 'ou=people,dc=test,dc=tld', ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get uid attribute and check against requested user name names = attributes.get('uid', []) if self.name: diff --git a/pynslcd/protocol.py b/pynslcd/protocol.py index 32a6db9..b14de99 100644 --- a/pynslcd/protocol.py +++ b/pynslcd/protocol.py @@ -33,10 +33,9 @@ class ProtocolRequest(common.Request): attributes = ( 'cn', 'ipProtocolNumber' ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name - name = common.get_rdn_value(entry, self.attmap_cn) + name = common.get_rdn_value(dn, self.attmap_cn) names = attributes.get(self.attmap_cn, []) if not names: print 'Error: entry %s does not contain %s value' % ( dn, self.attmap_cn ) diff --git a/pynslcd/rpc.py b/pynslcd/rpc.py index 9db1b16..94c63e2 100644 --- a/pynslcd/rpc.py +++ b/pynslcd/rpc.py @@ -33,10 +33,9 @@ class RpcRequest(common.Request): attributes = ( 'cn', 'oncRpcNumber' ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name - name = common.get_rdn_value(entry, self.attmap_cn) + name = common.get_rdn_value(dn, self.attmap_cn) names = attributes.get(self.attmap_cn, []) if not names: print 'Error: entry %s does not contain %s value' % ( dn, self.attmap_cn ) diff --git a/pynslcd/service.py b/pynslcd/service.py index 671bd20..106f744 100644 --- a/pynslcd/service.py +++ b/pynslcd/service.py @@ -38,10 +38,9 @@ class ServiceRequest(common.Request): super(ServiceRequest, self).__init__(*args) self.protocol = None - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name - name = common.get_rdn_value(entry, self.attmap_cn) + name = common.get_rdn_value(dn, self.attmap_cn) names = attributes.get(self.attmap_cn, []) if not names: print 'Error: entry %s does not contain %s value' % ( dn, self.attmap_cn ) diff --git a/pynslcd/shadow.py b/pynslcd/shadow.py index 254e599..ed54eab 100644 --- a/pynslcd/shadow.py +++ b/pynslcd/shadow.py @@ -44,8 +44,7 @@ class ShadowRequest(common.Request): bases = ( 'ou=people,dc=test,dc=tld', ) - def write(self, entry): - dn, attributes = entry + def write(self, dn, attributes): # get name and check against requested name names = attributes.get(self.attmap_uid, []) if not names: |