lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1573 - nss-pam-ldapd/pynslcd

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1573 - nss-pam-ldapd/pynslcd



Author: arthur
Date: Tue Dec 27 19:04:33 2011
New Revision: 1573
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1573&view=revision

Log:
PEP8 fixes

Modified:
   nss-pam-ldapd/pynslcd/cfg.py
   nss-pam-ldapd/pynslcd/ether.py
   nss-pam-ldapd/pynslcd/group.py
   nss-pam-ldapd/pynslcd/netgroup.py
   nss-pam-ldapd/pynslcd/pam.py
   nss-pam-ldapd/pynslcd/passwd.py
   nss-pam-ldapd/pynslcd/pynslcd.py
   nss-pam-ldapd/pynslcd/shadow.py
   nss-pam-ldapd/pynslcd/tio.py

Modified: nss-pam-ldapd/pynslcd/cfg.py
==============================================================================
--- nss-pam-ldapd/pynslcd/cfg.py        Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/cfg.py        Tue Dec 27 19:04:33 2011        (r1573)
@@ -44,7 +44,7 @@
 scope = ldap.SCOPE_SUBTREE
 
 # LDAP search bases to search
-bases = ( 'dc=test, dc=tld', )
+bases = ('dc=test, dc=tld', )
 
 # the users for which no initgroups() searches should be done
 nss_initgroups_ignoreusers = []
@@ -53,6 +53,7 @@
 rootpwmoddn = 'cn=admin, dc=test, dc=tld'
 rootpwmodpw = 'test'
 
+
 # FIXME: implement reading configuration from file
 def read(cfgfile):
     pass

Modified: nss-pam-ldapd/pynslcd/ether.py
==============================================================================
--- nss-pam-ldapd/pynslcd/ether.py      Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/ether.py      Tue Dec 27 19:04:33 2011        (r1573)
@@ -28,6 +28,7 @@
     """Converst an ethernet address to binary form in network byte order."""
     return struct.pack('BBBBBB', *(int(x, 16) for x in ether.split(':')))
 
+
 def ether_ntoa(ether):
     """Conversts an ethernet address in network byte order to the string
     representation."""

Modified: nss-pam-ldapd/pynslcd/group.py
==============================================================================
--- nss-pam-ldapd/pynslcd/group.py      Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/group.py      Tue Dec 27 19:04:33 2011        (r1573)
@@ -59,9 +59,9 @@
             memberuid = self.parameters['memberUid']
             dn = uid2dn(self.conn, memberuid)
             if dn:
-                return '(&%s(|(%s=%s)(%s=%s)))' % ( self.filter,
+                return '(&%s(|(%s=%s)(%s=%s)))' % (self.filter,
                           attmap['memberUid'], 
ldap.filter.escape_filter_chars(memberuid),
-                          attmap['member'], 
ldap.filter.escape_filter_chars(dn) )
+                          attmap['member'], 
ldap.filter.escape_filter_chars(dn))
         return super(Search, self).mk_filter()
 
 
@@ -75,7 +75,7 @@
         # get group group password
         passwd = attributes['userPassword'][0]
         # get group id(s)
-        gids = [ int(x) for x in attributes['gidNumber'] ]
+        gids = [int(x) for x in attributes['gidNumber']]
         # build member list
         members = set()
         if self.wantmembers:
@@ -91,7 +91,7 @@
         # actually return the results
         for name in names:
             if not common.isvalidname(name):
-                print 'Warning: group entry %s contains invalid group name: 
"%s"' % ( dn, name )
+                print 'Warning: group entry %s contains invalid group name: 
"%s"' % (dn, name)
             else:
                 for gid in gids:
                     self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
@@ -119,8 +119,6 @@
         return dict(gidNumber=fp.read_gid_t())
 
 
-
-
 class GroupByMemberRequest(GroupRequest):
 
     action = constants.NSLCD_ACTION_GROUP_BYMEMBER

Modified: nss-pam-ldapd/pynslcd/netgroup.py
==============================================================================
--- nss-pam-ldapd/pynslcd/netgroup.py   Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/netgroup.py   Tue Dec 27 19:04:33 2011        (r1573)
@@ -47,7 +47,7 @@
         for triple in attributes['nisNetgroupTriple']:
             m = _netgroup_triple_re.match(triple)
             if not m:
-                print 'Warning: entry %s contains invalid %s value: %r' % ( 
dn, attmap['nisNetgroupTriple'], triple)
+                print 'Warning: entry %s contains invalid %s value: %r' % (dn, 
attmap['nisNetgroupTriple'], triple)
             else:
                 self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
                 self.fp.write_int32(constants.NSLCD_NETGROUP_TYPE_TRIPLE)

Modified: nss-pam-ldapd/pynslcd/pam.py
==============================================================================
--- nss-pam-ldapd/pynslcd/pam.py        Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/pam.py        Tue Dec 27 19:04:33 2011        (r1573)
@@ -33,7 +33,7 @@
     # bind using the specified credentials
     conn.simple_bind_s(userdn, password)
     # perform search for own object (just to do any kind of search)
-    res = conn.search_s(userdn, ldap.SCOPE_BASE, '(objectClass=*)', [ 'dn', ])
+    res = conn.search_s(userdn, ldap.SCOPE_BASE, '(objectClass=*)', ['dn', ])
     for entry in res:
         if entry[0] == userdn:
             return
@@ -89,7 +89,7 @@
         self.fp.write_string(parameters['userdn'])
         self.fp.write_int32(code)  # authc
         self.fp.write_int32(constants.NSLCD_PAM_SUCCESS)  # authz
-        self.fp.write_string(msg) # authzmsg
+        self.fp.write_string(msg)  # authzmsg
         self.fp.write_int32(constants.NSLCD_RESULT_END)
 
     def handle_request(self, parameters):

Modified: nss-pam-ldapd/pynslcd/passwd.py
==============================================================================
--- nss-pam-ldapd/pynslcd/passwd.py     Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/passwd.py     Tue Dec 27 19:04:33 2011        (r1573)
@@ -34,7 +34,7 @@
                            loginShell='loginShell',
                            objectClass='objectClass')
 filter = '(objectClass=posixAccount)'
-bases = ( 'ou=people,dc=test,dc=tld', )
+bases = ('ou=people,dc=test,dc=tld', )
 
 
 class Search(common.Search):
@@ -54,7 +54,7 @@
             passwd = 'x'
         else:
             passwd = attributes['userPassword'][0]
-        uids = [ int(x) for x in attributes['uidNumber'] ]
+        uids = [int(x) for x in attributes['uidNumber']]
         gid = int(attributes['gidNumber'][0])
         gecos = attributes['gecos'][0]
         home = attributes['homeDirectory'][0]
@@ -62,7 +62,7 @@
         # write results
         for name in names:
             if not common.isvalidname(name):
-                print 'Warning: passwd entry %s contains invalid user name: 
"%s"' % ( dn, name )
+                print 'Warning: passwd entry %s contains invalid user name: 
"%s"' % (dn, name)
             else:
                 for uid in uids:
                     self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)

Modified: nss-pam-ldapd/pynslcd/pynslcd.py
==============================================================================
--- nss-pam-ldapd/pynslcd/pynslcd.py    Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/pynslcd.py    Tue Dec 27 19:04:33 2011        (r1573)
@@ -61,6 +61,7 @@
 #syslog.setFormatter(formatter)
 #logger.addHandler(syslog)
 
+
 def display_version(fp):
     fp.write('%(PACKAGE_STRING)s\n'
              'Written by Arthur de Jong.\n'
@@ -68,7 +69,8 @@
              '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"
@@ -79,8 +81,9 @@
              "      --version      output version information and exit\n"
              "\n"
              "Report bugs to <%(PACKAGE_BUGREPORT)s>.\n"
-             % { 'program_name': cfg.program_name,
-                 'PACKAGE_BUGREPORT': config.PACKAGE_BUGREPORT, } )
+             % {'program_name': cfg.program_name,
+                'PACKAGE_BUGREPORT': config.PACKAGE_BUGREPORT, })
+
 
 def parse_cmdline():
     """Parse command-line arguments."""
@@ -105,10 +108,11 @@
     except getopt.GetoptError, reason:
         sys.stderr.write("%(program_name)s: %(reason)s\n"
                          "Try '%(program_name)s --help' for more 
information.\n"
-                          % { 'program_name': cfg.program_name,
-                              'reason': reason, })
+                          % {'program_name': cfg.program_name,
+                             'reason': reason, })
         sys.exit(1)
 
+
 def create_socket():
     """Returns a socket ready to answer requests from the client."""
     import socket
@@ -118,7 +122,7 @@
     try:
         os.unlink(config.NSLCD_SOCKET)
     except OSError:
-        pass # ignore any problems
+        pass  # ignore any problems
     # bind to named socket
     sock.bind((config.NSLCD_SOCKET))
     # close the file descriptor on exit
@@ -129,14 +133,17 @@
     sock.listen(socket.SOMAXCONN)
     return sock
 
+
 def log_newsession():
     pass
     # FIXME: implement
 
+
 def getpeercred(fd):
     return (None, None, None)
     # FIXME: implement and return uid, gid, pid
 
+
 handlers = {}
 handlers.update(common.get_handlers('alias'))
 handlers.update(common.get_handlers('ether'))
@@ -151,6 +158,7 @@
 handlers.update(common.get_handlers('service'))
 handlers.update(common.get_handlers('shadow'))
 
+
 def acceptconnection(session):
     # accept a new connection
     conn, addr = nslcd_serversocket.accept()
@@ -165,7 +173,7 @@
             uid, gid, pid = getpeercred(conn)
             logging.debug('connection from pid=%r uid=%r gid=%r', pid, uid, 
gid)
         except:
-            raise # FIXME: handle exception gracefully
+            raise  # FIXME: handle exception gracefully
         # create a stream object
         fp = TIOStream(conn)
         # read request
@@ -184,12 +192,14 @@
         if fp:
             fp.close()
 
+
 def disable_nss_ldap():
     """Disable the nss_ldap module to avoid lookup loops."""
     import ctypes
     lib = ctypes.CDLL(config.NSS_LDAP_SONAME)
     ctypes.c_int.in_dll(lib, '_nss_ldap_enablelookups').value = 0
 
+
 def worker():
     # create a new LDAP session
     #session = myldap_create_session()
@@ -200,6 +210,7 @@
         acceptconnection(session)
         # FIXME: handle exceptions
 
+
 if __name__ == '__main__':
     # parse options
     parse_cmdline()

Modified: nss-pam-ldapd/pynslcd/shadow.py
==============================================================================
--- nss-pam-ldapd/pynslcd/shadow.py     Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/shadow.py     Tue Dec 27 19:04:33 2011        (r1573)
@@ -34,7 +34,7 @@
                            shadowExpire='"${shadowExpire:--1}"',
                            shadowFlag='"${shadowFlag:-0}"')
 filter = '(objectClass=shadowAccount)'
-bases = ( 'ou=people,dc=test,dc=tld', )
+bases = ('ou=people,dc=test,dc=tld', )
 
 
 class Search(common.Search):
@@ -67,7 +67,7 @@
         # first we devide by 1000000000 by stripping the
         # last 9 digits from the string and going from there */
         if attmap['shadowLastChange'] == 'pwdLastSet':
-            lastchangedate = ( lastchangedate / 864000000000 ) - 134774
+            lastchangedate = (lastchangedate / 864000000000) - 134774
         # get longs
         mindays = mk_int(attributes.get('shadowMin', [-1])[0])
         maxdays = mk_int(attributes.get('shadowMax', [-1])[0])

Modified: nss-pam-ldapd/pynslcd/tio.py
==============================================================================
--- nss-pam-ldapd/pynslcd/tio.py        Tue Dec 27 18:53:35 2011        (r1572)
+++ nss-pam-ldapd/pynslcd/tio.py        Tue Dec 27 19:04:33 2011        (r1573)
@@ -35,9 +35,11 @@
 # FIXME: use something from config.py to determine the correct size
 _struct_timeval = struct.Struct('ll')
 
+
 class TIOStreamError(Exception):
     pass
 
+
 class TIOStream(object):
     """File-like object that allows reading and writing nslcd-protocol
     entities."""
@@ -46,7 +48,7 @@
         conn.setblocking(1)
         conn.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, 
_struct_timeval.pack(0, 500000))
         conn.setsockopt(socket.SOL_SOCKET, socket.SO_SNDTIMEO, 
_struct_timeval.pack(60, 0))
-        self.fp = os.fdopen(conn.fileno(), 'w+b', 1024*1024)
+        self.fp = os.fdopen(conn.fileno(), 'w+b', 1024 * 1024)
 
     def read(self, size):
         return self.fp.read(size)
@@ -100,7 +102,7 @@
         try:
             return socket.AF_INET, socket.inet_pton(socket.AF_INET, value)
         except socket.error:
-            pass # try the next one
+            pass  # try the next one
         # fall back to IPv6
         return socket.AF_INET6, socket.inet_pton(socket.AF_INET6, value)
 
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/