lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1873 - in nss-pam-ldapd: . common compat nslcd nss pam tests

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

nss-pam-ldapd commit: r1873 - in nss-pam-ldapd: . common compat nslcd nss pam tests



Author: arthur
Date: Sat Dec 22 22:38:26 2012
New Revision: 1873
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1873&view=revision

Log:
update C coding style to a more commonly used style

Modified:
   nss-pam-ldapd/common/dict.c
   nss-pam-ldapd/common/dict.h
   nss-pam-ldapd/common/expr.c
   nss-pam-ldapd/common/expr.h
   nss-pam-ldapd/common/nslcd-prot.c
   nss-pam-ldapd/common/nslcd-prot.h
   nss-pam-ldapd/common/set.c
   nss-pam-ldapd/common/set.h
   nss-pam-ldapd/common/tio.c
   nss-pam-ldapd/common/tio.h
   nss-pam-ldapd/compat/attrs.h
   nss-pam-ldapd/compat/daemon.c
   nss-pam-ldapd/compat/daemon.h
   nss-pam-ldapd/compat/ether.c
   nss-pam-ldapd/compat/ether.h
   nss-pam-ldapd/compat/getopt_long.c
   nss-pam-ldapd/compat/getopt_long.h
   nss-pam-ldapd/compat/getpeercred.c
   nss-pam-ldapd/compat/getpeercred.h
   nss-pam-ldapd/compat/ldap_compat.h
   nss-pam-ldapd/compat/ldap_initialize.c
   nss-pam-ldapd/compat/ldap_passwd_s.c
   nss-pam-ldapd/compat/nss_compat.h
   nss-pam-ldapd/compat/pam_compat.h
   nss-pam-ldapd/compat/pam_get_authtok.c
   nss-pam-ldapd/compat/pam_prompt.c
   nss-pam-ldapd/compat/socket.h
   nss-pam-ldapd/compat/strndup.c
   nss-pam-ldapd/compat/strndup.h
   nss-pam-ldapd/configure.ac
   nss-pam-ldapd/nslcd/alias.c
   nss-pam-ldapd/nslcd/attmap.c
   nss-pam-ldapd/nslcd/attmap.h
   nss-pam-ldapd/nslcd/cfg.c
   nss-pam-ldapd/nslcd/cfg.h
   nss-pam-ldapd/nslcd/common.c
   nss-pam-ldapd/nslcd/common.h
   nss-pam-ldapd/nslcd/config.c
   nss-pam-ldapd/nslcd/ether.c
   nss-pam-ldapd/nslcd/group.c
   nss-pam-ldapd/nslcd/host.c
   nss-pam-ldapd/nslcd/log.c
   nss-pam-ldapd/nslcd/log.h
   nss-pam-ldapd/nslcd/myldap.c
   nss-pam-ldapd/nslcd/myldap.h
   nss-pam-ldapd/nslcd/netgroup.c
   nss-pam-ldapd/nslcd/network.c
   nss-pam-ldapd/nslcd/nslcd.c
   nss-pam-ldapd/nslcd/nsswitch.c
   nss-pam-ldapd/nslcd/pam.c
   nss-pam-ldapd/nslcd/passwd.c
   nss-pam-ldapd/nslcd/protocol.c
   nss-pam-ldapd/nslcd/rpc.c
   nss-pam-ldapd/nslcd/service.c
   nss-pam-ldapd/nslcd/shadow.c
   nss-pam-ldapd/nss/aliases.c
   nss-pam-ldapd/nss/bsdnss.c
   nss-pam-ldapd/nss/common.c
   nss-pam-ldapd/nss/common.h
   nss-pam-ldapd/nss/ethers.c
   nss-pam-ldapd/nss/group.c
   nss-pam-ldapd/nss/hosts.c
   nss-pam-ldapd/nss/netgroup.c
   nss-pam-ldapd/nss/networks.c
   nss-pam-ldapd/nss/passwd.c
   nss-pam-ldapd/nss/protocols.c
   nss-pam-ldapd/nss/prototypes.h
   nss-pam-ldapd/nss/rpc.c
   nss-pam-ldapd/nss/services.c
   nss-pam-ldapd/nss/shadow.c
   nss-pam-ldapd/nss/solnss.c
   nss-pam-ldapd/nss/solnss.h
   nss-pam-ldapd/pam/common.h
   nss-pam-ldapd/pam/pam.c
   nss-pam-ldapd/tests/common.h
   nss-pam-ldapd/tests/test_cfg.c
   nss-pam-ldapd/tests/test_common.c
   nss-pam-ldapd/tests/test_dict.c
   nss-pam-ldapd/tests/test_expr.c
   nss-pam-ldapd/tests/test_getpeercred.c
   nss-pam-ldapd/tests/test_myldap.c
   nss-pam-ldapd/tests/test_set.c
   nss-pam-ldapd/tests/test_tio.c

Modified: nss-pam-ldapd/common/dict.c
==============================================================================
--- nss-pam-ldapd/common/dict.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/dict.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    dict.c - dictionary functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -72,9 +72,9 @@
 /* Simple hash function that computes the hash value of a string. */
 static uint32_t stringhash(const char *str)
 {
-  uint32_t hash=0;
-  while (*str!='\0')
-    hash=3*hash+*str++;
+  uint32_t hash = 0;
+  while (*str != '\0')
+    hash = 3 * hash + *str++;
   return hash;
 }
 
@@ -84,34 +84,34 @@
   int i;
   int newsize;
   struct dict_entry **newtable;
-  struct dict_entry *entry,*tmp;
-  newsize=dict->size*3+1;
+  struct dict_entry *entry, *tmp;
+  newsize = dict->size * 3 + 1;
   /* allocate room for new hashtable */
-  newtable=(struct dict_entry **)malloc(newsize*sizeof(struct dict_entry *));
-  if (newtable==NULL)
+  newtable = (struct dict_entry **)malloc(newsize * sizeof(struct dict_entry 
*));
+  if (newtable == NULL)
     return; /* allocating memory failed continue to fill the existing table */
   /* clear new table */
-  for (i=0;i<newsize;i++)
-    newtable[i]=NULL;
+  for (i = 0; i < newsize; i++)
+    newtable[i] = NULL;
   /* copy old hashtable into new table */
-  for (i=0;i<dict->size;i++)
+  for (i = 0; i < dict->size; i++)
   {
     /* go over elements in linked list */
-    entry=dict->table[i];
-    while (entry!=NULL)
+    entry = dict->table[i];
+    while (entry != NULL)
     {
-      tmp=entry;
-      entry=entry->next;
+      tmp = entry;
+      entry = entry->next;
       /* put in new position */
-      tmp->next=newtable[tmp->hash%newsize];
-      newtable[tmp->hash%newsize]=tmp;
+      tmp->next = newtable[tmp->hash % newsize];
+      newtable[tmp->hash % newsize] = tmp;
     }
   }
   /* free the old hashtable */
   free(dict->table);
   /* put new hashtable in place */
-  dict->size=newsize;
-  dict->table=newtable;
+  dict->size = newsize;
+  dict->table = newtable;
 }
 
 DICT *dict_new(void)
@@ -119,37 +119,37 @@
   struct dictionary *dict;
   int i;
   /* allocate room for dictionary information */
-  dict=(struct dictionary *)malloc(sizeof(struct dictionary));
-  if (dict==NULL)
+  dict = (struct dictionary *)malloc(sizeof(struct dictionary));
+  if (dict == NULL)
     return NULL;
-  dict->size=DICT_INITSIZE;
-  dict->num=0;
+  dict->size = DICT_INITSIZE;
+  dict->num = 0;
   /* allocate initial hashtable */
-  dict->table=(struct dict_entry **)malloc(DICT_INITSIZE*sizeof(struct 
dict_entry *));
-  if (dict->table==NULL)
+  dict->table = (struct dict_entry **)malloc(DICT_INITSIZE * sizeof(struct 
dict_entry *));
+  if (dict->table == NULL)
   {
     free(dict);
     return NULL;
   }
   /* clear the hashtable */
-  for (i=0;i<DICT_INITSIZE;i++)
-    dict->table[i]=NULL;
+  for (i = 0; i < DICT_INITSIZE; i++)
+    dict->table[i] = NULL;
   /* we're done */
   return dict;
 }
 
 void dict_free(DICT *dict)
 {
-  struct dict_entry *entry,*etmp;
+  struct dict_entry *entry, *etmp;
   int i;
   /* free hashtable entries */
-  for (i=0;i<dict->size;i++)
+  for (i = 0; i < dict->size; i++)
   {
-    entry=dict->table[i];
-    while (entry!=NULL)
+    entry = dict->table[i];
+    while (entry != NULL)
     {
-      etmp=entry;
-      entry=entry->next;
+      etmp = entry;
+      entry = entry->next;
       free(etmp);
     }
   }
@@ -159,17 +159,16 @@
   free(dict);
 }
 
-void *dict_get(DICT *dict,const char *key)
+void *dict_get(DICT *dict, const char *key)
 {
   uint32_t hash;
   struct dict_entry *entry;
   /* calculate the hash */
-  hash=stringhash(key);
+  hash = stringhash(key);
   /* loop over the linked list in the hashtable */
-  for (entry=dict->table[hash%dict->size];entry!=NULL;entry=entry->next)
+  for (entry = dict->table[hash % dict->size]; entry != NULL; entry = 
entry->next)
   {
-    if ( (entry->hash==hash) &&
-         (strcmp(entry->key,key)==0) )
+    if ((entry->hash == hash) && (strcmp(entry->key, key) == 0))
       return entry->value;
   }
   /* no matches found */
@@ -180,69 +179,66 @@
 {
   int i;
   /* loop over the linked list in the hashtable */
-  for (i=0;i<dict->size;i++)
+  for (i = 0; i < dict->size; i++)
     if (dict->table[i])
       return dict->table[i]->key;
   /* no matches found */
   return NULL;
 }
 
-int dict_put(DICT *dict,const char *key,void *value)
+int dict_put(DICT *dict, const char *key, void *value)
 {
   uint32_t hash;
   int l;
   char *buf;
   int idx;
-  struct dict_entry *entry,*prev;
+  struct dict_entry *entry, *prev;
   /* check if we should grow the hashtable */
-  if ( dict->num >= ((dict->size*DICT_LOADPERCENTAGE)/100) )
+  if (dict->num >= ((dict->size * DICT_LOADPERCENTAGE) / 100))
     growhashtable(dict);
   /* calculate the hash and position in the hashtable */
-  hash=stringhash(key);
-  idx=hash%dict->size;
+  hash = stringhash(key);
+  idx = hash % dict->size;
   /* check if the entry is already present */
-  for (entry=dict->table[idx],prev=NULL;
-       entry!=NULL;
-       prev=entry,entry=entry->next)
+  for (entry = dict->table[idx], prev = NULL; entry != NULL; prev = entry, 
entry = entry->next)
   {
-    if ( (entry->hash==hash) &&
-         (strcmp(entry->key,key)==0) )
+    if ((entry->hash == hash) && (strcmp(entry->key, key) == 0))
     {
       /* check if we should unset the entry */
-      if (value==NULL)
+      if (value == NULL)
       {
         /* remove from linked list */
-        if (prev==NULL)
-          dict->table[idx]=entry->next;
+        if (prev == NULL)
+          dict->table[idx] = entry->next;
         else
-          prev->next=entry->next;
+          prev->next = entry->next;
         /* free entry memory and register removal */
         free(entry);
         dict->num--;
         return 0;
       }
       /* just set the new value */
-      entry->value=value;
+      entry->value = value;
       return 0;
     }
   }
   /* if entry should be unset we're done */
-  if (value==NULL)
+  if (value == NULL)
     return 0;
   /* entry is not present, make new entry */
-  l=strlen(key)+1;
-  buf=(char *)malloc(sizeof(struct dict_entry)+l);
-  if (buf==NULL)
+  l = strlen(key) + 1;
+  buf = (char *)malloc(sizeof(struct dict_entry) + l);
+  if (buf == NULL)
     return -1;
-  entry=(struct dict_entry *)(void *)buf;
-  buf+=sizeof(struct dict_entry);
-  strcpy(buf,key);
-  entry->hash=hash;
-  entry->key=buf;
-  entry->value=value;
+  entry = (struct dict_entry *)(void *)buf;
+  buf += sizeof(struct dict_entry);
+  strcpy(buf, key);
+  entry->hash = hash;
+  entry->key = buf;
+  entry->value = value;
   /* insert into hashtable/linked list */
-  entry->next=dict->table[idx];
-  dict->table[idx]=entry;
+  entry->next = dict->table[idx];
+  dict->table[idx] = entry;
   /* increment number of stored items */
   dict->num++;
   return 0;
@@ -257,38 +253,38 @@
   size_t sz;
   int num;
   /* figure out how much memory to allocate */
-  num=0;
-  sz=0;
-  for (i=0;i<dict->size;i++)
+  num = 0;
+  sz = 0;
+  for (i = 0; i < dict->size; i++)
   {
-    entry=dict->table[i];
-    while (entry!=NULL)
+    entry = dict->table[i];
+    while (entry != NULL)
     {
       num++;
-      sz+=strlen(entry->key)+1;
-      entry=entry->next;
+      sz += strlen(entry->key) + 1;
+      entry = entry->next;
     }
   }
   /* allocate the needed memory */
-  buf=(char *)malloc((num+1)*sizeof(char *)+sz);
-  if (buf==NULL)
+  buf = (char *)malloc((num + 1) * sizeof(char *) + sz);
+  if (buf == NULL)
     return NULL;
-  values=(const char **)(void *)buf;
-  buf+=(num+1)*sizeof(char *);
+  values = (const char **)(void *)buf;
+  buf += (num + 1) * sizeof(char *);
   /* fill the array with the keys */
-  num=0;
-  for (i=0;i<dict->size;i++)
+  num = 0;
+  for (i = 0; i < dict->size; i++)
   {
-    entry=dict->table[i];
-    while (entry!=NULL)
+    entry = dict->table[i];
+    while (entry != NULL)
     {
-      strcpy(buf,entry->key);
-      values[num++]=buf;
-      buf+=strlen(buf)+1;
-      entry=entry->next;
+      strcpy(buf, entry->key);
+      values[num++] = buf;
+      buf += strlen(buf) + 1;
+      entry = entry->next;
     }
   }
-  values[num]=NULL;
+  values[num] = NULL;
   /* done */
   return values;
 }

Modified: nss-pam-ldapd/common/dict.h
==============================================================================
--- nss-pam-ldapd/common/dict.h Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/dict.h Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    dict.h - dictionary functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -37,15 +37,15 @@
 
 /* Add a relation in the dictionary. The key is duplicated
    and can be reused by the caller. The pointer is just stored.
-   This function returns non-0 in case of memory allocation
+   This function returns non-zero in case of memory allocation
    errors. If the key was previously in use the value
    is replaced. All key comparisons are case sensitive. */
-int dict_put(DICT *dict,const char *key,void *value);
+int dict_put(DICT *dict, const char *key, void *value);
 
 /* Look up a key in the dictionary and return the associated
    value. NULL is returned if the key is not found in the dictionary.
    All key comparisons are case sensitive. */
-void *dict_get(DICT *dict,const char *key)
+void *dict_get(DICT *dict, const char *key)
   MUST_USE;
 
 /* Get a key from the dictionary that has a value set. The caller does
@@ -55,7 +55,7 @@
 
 /* Delete a key-value association from the dictionary.
    All key comparisons are case sensitive. */
-/*void dict_del(DICT *dict,const char *key);*/
+/*void dict_del(DICT *dict, const char *key);*/
 
 /* Remove the dictionary from memory. All allocated storage
    for the dictionary and the keys is freed.

Modified: nss-pam-ldapd/common/expr.c
==============================================================================
--- nss-pam-ldapd/common/expr.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/expr.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    expr.c - limited shell-like expression parsing functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -34,110 +34,112 @@
 
 static inline int my_isalpha(const char c)
 {
-  return ((c>='a')&&(c<='z'))||((c>='A')&&(c<='Z'));
+  return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
 }
 
 static inline int my_isalphanum(const char c)
 {
-  return my_isalpha(c)||((c>='0')&&(c<='9'));
+  return my_isalpha(c) || ((c >= '0') && (c <= '9'));
 }
 
 /* return the part of the string that is a valid name */
-MUST_USE static const char *parse_name(const char *str,int *ptr,char 
*buffer,size_t buflen)
+MUST_USE static const char *parse_name(const char *str, int *ptr,
+                                       char *buffer, size_t buflen)
 {
-  int i=0;
+  int i = 0;
   /* clear the buffer */
-  buffer[i]='\0';
-  /* look for an alpha+alphanumeric* string */
+  buffer[i] = '\0';
+  /* look for an alpha + alphanumeric* string */
   if (!my_isalpha(str[*ptr]))
     return NULL;
-  while (my_isalphanum(str[*ptr])||(str[*ptr]==';'))
+  while (my_isalphanum(str[*ptr]) || (str[*ptr] == ';'))
   {
-    if ((size_t)i>=buflen)
+    if ((size_t)i >= buflen)
       return NULL;
-    buffer[i++]=str[(*ptr)++];
+    buffer[i++] = str[(*ptr)++];
   }
   /* NULL-terminate the string */
-  if ((size_t)i>=buflen)
+  if ((size_t)i >= buflen)
     return NULL;
-  buffer[i++]='\0';
+  buffer[i++] = '\0';
   return buffer;
 }
 
 /* dummy expander function to always return an empty string */
-static const char *empty_expander(const char UNUSED(*name),void 
UNUSED(*expander_arg))
+static const char *empty_expander(const char UNUSED(*name),
+                                  void UNUSED(*expander_arg))
 {
   return "";
 }
 
 /* definition of the parse functions (they call eachother) */
 MUST_USE static const char *parse_dollar_expression(
-              const char *str,int *ptr,char *buffer,size_t buflen,
-              expr_expander_func expander,void *expander_arg);
+              const char *str, int *ptr, char *buffer, size_t buflen,
+              expr_expander_func expander, void *expander_arg);
 MUST_USE static const char *parse_expression(
-              const char *str,int *ptr,int endat,char *buffer,size_t buflen,
-              expr_expander_func expander,void *expander_arg);
+              const char *str, int *ptr, int endat, char *buffer, size_t 
buflen,
+              expr_expander_func expander, void *expander_arg);
 
 MUST_USE static const char *parse_dollar_expression(
-              const char *str,int *ptr,char *buffer,size_t buflen,
-              expr_expander_func expander,void *expander_arg)
+              const char *str, int *ptr, char *buffer, size_t buflen,
+              expr_expander_func expander, void *expander_arg)
 {
   char varname[MAXVARLENGTH];
   const char *varvalue;
-  if ((buflen<=0)||(buffer==NULL)||(str==NULL)||(ptr==NULL))
+  if ((buflen <= 0) || (buffer == NULL) || (str == NULL) || (ptr == NULL))
     return NULL;
-  if (str[*ptr]=='{')
+  if (str[*ptr] == '{')
   {
     (*ptr)++;
     /* the first part is always a variable name */
-    if (parse_name(str,ptr,varname,sizeof(varname))==NULL)
+    if (parse_name(str, ptr, varname, sizeof(varname)) == NULL)
       return NULL;
-    varvalue=expander(varname,expander_arg);
-    if (varvalue==NULL)
-      varvalue="";
-    if (str[*ptr]=='}')
+    varvalue = expander(varname, expander_arg);
+    if (varvalue == NULL)
+      varvalue = "";
+    if (str[*ptr] == '}')
     {
       /* simple substitute */
-      if (strlen(varvalue)>=buflen)
+      if (strlen(varvalue) >= buflen)
         return NULL;
-      strcpy(buffer,varvalue);
+      strcpy(buffer, varvalue);
     }
-    else if (strncmp(str+*ptr,":-",2)==0)
+    else if (strncmp(str + *ptr, ":-", 2) == 0)
     {
       /* if variable is not set or empty, substitute remainder */
-      (*ptr)+=2;
-      if ((varvalue!=NULL)&&(*varvalue!='\0'))
+      (*ptr) += 2;
+      if ((varvalue != NULL) && (*varvalue != '\0'))
       {
         /* value is set, skip rest of expression and use value */
-        if 
(parse_expression(str,ptr,'}',buffer,buflen,empty_expander,NULL)==NULL)
+        if (parse_expression(str, ptr, '}', buffer, buflen, empty_expander, 
NULL) == NULL)
           return NULL;
-        if (strlen(varvalue)>=buflen)
+        if (strlen(varvalue) >= buflen)
           return NULL;
-        strcpy(buffer,varvalue);
+        strcpy(buffer, varvalue);
       }
       else
       {
         /* value is not set, evaluate rest of expression */
-        if 
(parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL)
+        if (parse_expression(str, ptr, '}', buffer, buflen, expander, 
expander_arg) == NULL)
           return NULL;
       }
     }
-    else if (strncmp(str+*ptr,":+",2)==0)
+    else if (strncmp(str + *ptr, ":+", 2) == 0)
     {
       /* if variable is set, substitute remainer */
-      (*ptr)+=2;
-      if ((varvalue!=NULL)&&(*varvalue!='\0'))
+      (*ptr) += 2;
+      if ((varvalue != NULL) && (*varvalue != '\0'))
       {
         /* value is set, evaluate rest of expression */
-        if 
(parse_expression(str,ptr,'}',buffer,buflen,expander,expander_arg)==NULL)
+        if (parse_expression(str, ptr, '}', buffer, buflen, expander, 
expander_arg) == NULL)
           return NULL;
       }
       else
       {
         /* value is not set, skip rest of expression and blank */
-        if 
(parse_expression(str,ptr,'}',buffer,buflen,empty_expander,NULL)==NULL)
+        if (parse_expression(str, ptr, '}', buffer, buflen, empty_expander, 
NULL) == NULL)
           return NULL;
-        buffer[0]='\0';
+        buffer[0] = '\0';
       }
     }
     else
@@ -147,81 +149,82 @@
   else
   {
     /* it is a simple reference to a variable, like $uidNumber */
-    if (parse_name(str,ptr,varname,sizeof(varname))==NULL)
+    if (parse_name(str, ptr, varname, sizeof(varname)) == NULL)
       return NULL;
-    varvalue=expander(varname,expander_arg);
-    if (varvalue==NULL)
-      varvalue="";
-    if (strlen(varvalue)>=buflen)
+    varvalue = expander(varname, expander_arg);
+    if (varvalue == NULL)
+      varvalue = "";
+    if (strlen(varvalue) >= buflen)
       return NULL;
-    strcpy(buffer,varvalue);
+    strcpy(buffer, varvalue);
   }
   return buffer;
 }
 
 MUST_USE static const char *parse_expression(
-              const char *str,int *ptr,int endat,char *buffer,size_t buflen,
-              expr_expander_func expander,void *expander_arg)
+              const char *str, int *ptr, int endat, char *buffer, size_t 
buflen,
+              expr_expander_func expander, void *expander_arg)
 {
-  int j=0;
+  int j = 0;
   /* go over string */
-  while ((str[*ptr]!=endat)&&(str[*ptr]!='\0'))
+  while ((str[*ptr] != endat) && (str[*ptr] != '\0'))
   {
     switch (str[*ptr])
     {
       case '$': /* beginning of an expression */
         (*ptr)++;
-        if ((size_t)j>=buflen)
+        if ((size_t)j >= buflen)
           return NULL;
-        if 
(parse_dollar_expression(str,ptr,buffer+j,buflen-j,expander,expander_arg)==NULL)
+        if (parse_dollar_expression(str, ptr, buffer + j, buflen - j,
+                                    expander, expander_arg) == NULL)
           return NULL;
-        j=strlen(buffer);
+        j = strlen(buffer);
         break;
       case '\\': /* escaped character, unescape */
         (*ptr)++;
       default: /* just copy the text */
-        if ((size_t)j>=buflen)
+        if ((size_t)j >= buflen)
           return NULL;
-        buffer[j++]=str[*ptr];
+        buffer[j++] = str[*ptr];
         (*ptr)++;
     }
   }
   /* NULL-terminate buffer */
-  if ((size_t)j>=buflen)
+  if ((size_t)j >= buflen)
     return NULL;
-  buffer[j++]='\0';
+  buffer[j++] = '\0';
   return buffer;
 }
 
-MUST_USE const char *expr_parse(const char *str,char *buffer,size_t buflen,
-                                expr_expander_func expander,void *expander_arg)
-
+MUST_USE const char *expr_parse(const char *str, char *buffer, size_t buflen,
+                                expr_expander_func expander, void 
*expander_arg)
 {
-  int i=0;
-  return parse_expression(str,&i,'\0',buffer,buflen,expander,expander_arg);
+  int i = 0;
+  return parse_expression(str, &i, '\0', buffer, buflen,
+                          expander, expander_arg);
 }
 
-SET *expr_vars(const char *str,SET *set)
+SET *expr_vars(const char *str, SET *set)
 {
   char varname[MAXVARLENGTH];
-  int i=0;
+  int i = 0;
   /* allocate set if needed */
-  if (set==NULL)
-    set=set_new();
-  if (set==NULL)
+  if (set == NULL)
+    set = set_new();
+  if (set == NULL)
     return NULL;
   /* go over string */
-  while (str[i]!='\0')
+  while (str[i] != '\0')
   {
     switch (str[i])
     {
       case '$': /* beginning of a $-expression */
         i++;
-        if (str[i]=='{')
+        if (str[i] == '{')
           i++;
         /* the rest should start with a variable name */
-        if (parse_name(str,&i,varname,sizeof(varname))!=NULL)
-          set_add(set,varname);
+        if (parse_name(str, &i, varname, sizeof(varname)) != NULL)
+          set_add(set, varname);
         break;
       case '\\': /* escaped character, unescape */
         i++;

Modified: nss-pam-ldapd/common/expr.h
==============================================================================
--- nss-pam-ldapd/common/expr.h Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/expr.h Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    expr.h - limited shell-like expression parsing functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2009 Arthur de Jong
+   Copyright (C) 2009, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -26,16 +26,16 @@
 #include "compat/attrs.h"
 #include "common/set.h"
 
-typedef const char *(*expr_expander_func)(const char *name,void *expander_arg);
+typedef const char *(*expr_expander_func) (const char *name, void 
*expander_arg);
 
 /* Parse the expression and store the result in buffer, using the
    expander function to expand variable names to values. If the expression
    is invalid or the result didn't fit in the buffer NULL is returned. */
-MUST_USE const char *expr_parse(const char *expr,char *buffer,size_t buflen,
-                                expr_expander_func expander,void 
*expander_arg);
+MUST_USE const char *expr_parse(const char *expr, char *buffer, size_t buflen,
+                                expr_expander_func expander, void 
*expander_arg);
 
 /* Return the variable names that are used in expr. If set is NULL a new one
    is allocated, otherwise the passed set is added to. */
-SET *expr_vars(const char *expr,SET *set);
+SET *expr_vars(const char *expr, SET *set);
 
 #endif /* not _COMMON__ */

Modified: nss-pam-ldapd/common/nslcd-prot.c
==============================================================================
--- nss-pam-ldapd/common/nslcd-prot.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/nslcd-prot.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -41,12 +41,12 @@
 
 /* read timeout is 60 seconds because looking up stuff may take some time
    write timeout is 10 secods because nslcd could be loaded with requests */
-#define READ_TIMEOUT 60*1000
-#define WRITE_TIMEOUT 10*1000
+#define READ_TIMEOUT 60 * 1000
+#define WRITE_TIMEOUT 10 * 1000
 
 /* buffer sizes for I/O */
 #define READBUFFER_MINSIZE 1024
-#define READBUFFER_MAXSIZE 2*1024*1024
+#define READBUFFER_MAXSIZE 2 * 1024 * 1024
 #define WRITEBUFFER_MINSIZE 32
 #define WRITEBUFFER_MAXSIZE 32
 
@@ -65,27 +65,27 @@
   TFILE *fp;
   int flags;
   /* create a socket */
-  if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 )
+  if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
     return NULL;
   /* create socket address structure */
-  memset(&addr,0,sizeof(struct sockaddr_un));
-  addr.sun_family=AF_UNIX;
-  strncpy(addr.sun_path,NSLCD_SOCKET,sizeof(addr.sun_path));
-  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
+  memset(&addr, 0, sizeof(struct sockaddr_un));
+  addr.sun_family = AF_UNIX;
+  strncpy(addr.sun_path, NSLCD_SOCKET, sizeof(addr.sun_path));
+  addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
   /* close the file descriptor on exec (ignore errors) */
-  flags=fcntl(sock,F_GETFL);
-  if (flags>=0)
-    (void)fcntl(sock,F_SETFD,flags|FD_CLOEXEC);
+  flags = fcntl(sock, F_GETFL);
+  if (flags >= 0)
+    (void)fcntl(sock, F_SETFD, flags | FD_CLOEXEC);
   /* connect to the socket */
-  if (connect(sock,(struct sockaddr *)&addr,SUN_LEN(&addr))<0)
+  if (connect(sock, (struct sockaddr *)&addr, SUN_LEN(&addr)) < 0)
   {
     (void)close(sock);
     return NULL;
   }
   /* create a stream object */
-  if ((fp=tio_fdopen(sock,READ_TIMEOUT,WRITE_TIMEOUT,
-                     READBUFFER_MINSIZE,READBUFFER_MAXSIZE,
-                     WRITEBUFFER_MINSIZE,WRITEBUFFER_MAXSIZE))==NULL)
+  if ((fp = tio_fdopen(sock, READ_TIMEOUT, WRITE_TIMEOUT,
+                       READBUFFER_MINSIZE, READBUFFER_MAXSIZE,
+                       WRITEBUFFER_MINSIZE, WRITEBUFFER_MAXSIZE)) == NULL)
   {
     (void)close(sock);
     return NULL;

Modified: nss-pam-ldapd/common/nslcd-prot.h
==============================================================================
--- nss-pam-ldapd/common/nslcd-prot.h   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/nslcd-prot.h   Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    nslcd-prot.h - helper macros for reading and writing in protocol streams
 
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -45,11 +45,12 @@
 /* define a debugging macro to output logging */
 #include <string.h>
 #include <errno.h>
-#define DEBUG_PRINT(fmt,arg) \
-  fprintf(stderr,"%s:%d:%s: " fmt 
"\n",__FILE__,__LINE__,__PRETTY_FUNCTION__,arg);
+#define DEBUG_PRINT(fmt, arg)                                               \
+  fprintf(stderr, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__,                \
+          __PRETTY_FUNCTION__, arg);
 #else /* DEBUG_PROT */
 /* define an empty debug macro to disable logging */
-#define DEBUG_PRINT(fmt,arg)
+#define DEBUG_PRINT(fmt, arg)
 #endif /* not DEBUG_PROT */
 
 #ifdef DEBUG_PROT_DUMP
@@ -57,19 +58,19 @@
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif /* HAVE_STDINT_H */
-static void debug_dump(const void *ptr,size_t size)
+static void debug_dump(const void *ptr, size_t size)
 {
   int i;
-  for (i=0;i<size;i++)
-    fprintf(stderr," %02x",((const uint8_t *)ptr)[i]);
-  fprintf(stderr,"\n");
+  for (i = 0; i < size; i++)
+    fprintf(stderr, " %02x", ((const uint8_t *)ptr)[i]);
+  fprintf(stderr, "\n");
 }
-#define DEBUG_DUMP(ptr,size) \
-  fprintf(stderr,"%s:%d:%s:",__FILE__,__LINE__,__PRETTY_FUNCTION__); \
-  debug_dump(ptr,size);
+#define DEBUG_DUMP(ptr, size)                                               \
+  fprintf(stderr, "%s:%d:%s:", __FILE__, __LINE__, __PRETTY_FUNCTION__);    \
+  debug_dump(ptr, size);
 #else /* DEBUG_PROT_DUMP */
 /* define an empty debug macro to disable logging */
-#define DEBUG_DUMP(ptr,size)
+#define DEBUG_DUMP(ptr, size)
 #endif /* not DEBUG_PROT_DUMP */
 
 
@@ -80,74 +81,76 @@
    int32_t tmpint32; - temporary variable
    */
 
-#define WRITE(fp,ptr,size) \
-  DEBUG_PRINT("WRITE       : var="__STRING(ptr)" size=%d",(int)size); \
-  DEBUG_DUMP(ptr,size); \
-  if (tio_write(fp,ptr,(size_t)size)) \
-  { \
-    DEBUG_PRINT("WRITE       : var="__STRING(ptr)" error: 
%s",strerror(errno)); \
-    ERROR_OUT_WRITEERROR(fp); \
+#define WRITE(fp, ptr, size)                                                \
+  DEBUG_PRINT("WRITE       : var="__STRING(ptr)" size=%d", (int)size);      \
+  DEBUG_DUMP(ptr, size);                                                    \
+  if (tio_write(fp, ptr, (size_t)size))                                     \
+  {                                                                         \
+    DEBUG_PRINT("WRITE       : var="__STRING(ptr)" error: %s",              \
+                strerror(errno));                                           \
+    ERROR_OUT_WRITEERROR(fp);                                               \
   }
 
-#define WRITE_INT32(fp,i) \
-  DEBUG_PRINT("WRITE_INT32 : var="__STRING(i)" int32=%d",(int)i); \
-  tmpint32=htonl((int32_t)(i)); \
-  WRITE(fp,&tmpint32,sizeof(int32_t))
-
-#define WRITE_STRING(fp,str) \
-  DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"",(str)); \
-  if ((str)==NULL) \
-  { \
-    WRITE_INT32(fp,0); \
-  } \
-  else \
-  { \
-    WRITE_INT32(fp,strlen(str)); \
-    tmpint32=ntohl(tmpint32); \
-    if (tmpint32>0) \
-      { WRITE(fp,(str),tmpint32); } \
+#define WRITE_INT32(fp, i)                                                  \
+  DEBUG_PRINT("WRITE_INT32 : var="__STRING(i)" int32=%d", (int)i);          \
+  tmpint32 = htonl((int32_t)(i));                                           \
+  WRITE(fp, &tmpint32, sizeof(int32_t))
+
+#define WRITE_STRING(fp, str)                                               \
+  DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"", (str));    \
+  if ((str) == NULL)                                                        \
+  {                                                                         \
+    WRITE_INT32(fp, 0);                                                     \
+  }                                                                         \
+  else                                                                      \
+  {                                                                         \
+    WRITE_INT32(fp, strlen(str));                                           \
+    tmpint32 = ntohl(tmpint32);                                             \
+    if (tmpint32 > 0)                                                       \
+    {                                                                       \
+      WRITE(fp, (str), tmpint32);                                           \
+    }                                                                       \
   }
 
-#define WRITE_STRINGLIST(fp,arr) \
-  if ((arr)==NULL) \
-  { \
-    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",0); \
-    WRITE_INT32(fp,0); \
-  } \
-  else \
-  { \
-    /* first determin length of array */ \
-    for (tmp3int32=0;(arr)[tmp3int32]!=NULL;tmp3int32++) \
-      /*noting*/ ; \
-    /* write number of strings */ \
-    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
-    WRITE_INT32(fp,tmp3int32); \
-    /* write strings */ \
-    for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
-    { \
-      WRITE_STRING(fp,(arr)[tmp2int32]); \
-    } \
+#define WRITE_STRINGLIST(fp, arr)                                           \
+  if ((arr) == NULL)                                                        \
+  {                                                                         \
+    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d", 0);             \
+    WRITE_INT32(fp, 0);                                                     \
+  }                                                                         \
+  else                                                                      \
+  {                                                                         \
+    /* first determine length of array */                                   \
+    for (tmp3int32 = 0; (arr)[tmp3int32] != NULL; tmp3int32++)              \
+      /* noting */ ;                                                        \
+    /* write number of strings */                                           \
+    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d", (int)tmp3int32); \
+    WRITE_INT32(fp, tmp3int32);                                             \
+    /* write strings */                                                     \
+    for (tmp2int32 = 0; tmp2int32 < tmp3int32; tmp2int32++)                 \
+    {                                                                       \
+      WRITE_STRING(fp, (arr)[tmp2int32]);                                   \
+    }                                                                       \
   }
 
-#define WRITE_STRINGLIST_EXCEPT(fp,arr,not) \
-  /* first determin length of array */ \
-  tmp3int32=0; \
-  for (tmp2int32=0;(arr)[tmp2int32]!=NULL;tmp2int32++) \
-    if (strcmp((arr)[tmp2int32],(not))!=0) \
-      tmp3int32++; \
-  /* write number of strings (mius one because we intend to skip one) */ \
-  DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
-  WRITE_INT32(fp,tmp3int32); \
-  /* write strings */ \
-  for (tmp2int32=0;(arr)[tmp2int32]!=NULL;tmp2int32++) \
-  { \
-    if (strcmp((arr)[tmp2int32],(not))!=0) \
-    { \
-      WRITE_STRING(fp,(arr)[tmp2int32]); \
-    } \
+#define WRITE_STRINGLIST_EXCEPT(fp, arr, not)                               \
+  /* first determine length of array */                                     \
+  tmp3int32 = 0;                                                            \
+  for (tmp2int32 = 0; (arr)[tmp2int32] != NULL; tmp2int32++)                \
+    if (strcmp((arr)[tmp2int32], (not)) != 0)                               \
+      tmp3int32++;                                                          \
+  /* write number of strings (mius one because we intend to skip one) */    \
+  DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d", (int)tmp3int32);  \
+  WRITE_INT32(fp, tmp3int32);                                               \
+  /* write strings */                                                       \
+  for (tmp2int32 = 0; (arr)[tmp2int32] != NULL; tmp2int32++)                \
+  {                                                                         \
+    if (strcmp((arr)[tmp2int32], (not)) != 0)                               \
+    {                                                                       \
+      WRITE_STRING(fp, (arr)[tmp2int32]);                                   \
+    }                                                                       \
   }
 
-
 /* READ macros, used for reading data, on read error they will
    call the ERROR_OUT_READERROR or ERROR_OUT_BUFERROR macro
    these macros may require the availability of the following
@@ -155,40 +158,43 @@
    int32_t tmpint32; - temporary variable
    */
 
-#define READ(fp,ptr,size) \
-  if (tio_read(fp,ptr,(size_t)size)) \
-  { \
-    DEBUG_PRINT("READ       : var="__STRING(ptr)" error: %s",strerror(errno)); 
\
-    ERROR_OUT_READERROR(fp); \
-  } \
-  DEBUG_PRINT("READ       : var="__STRING(ptr)" size=%d",(int)size); \
-  DEBUG_DUMP(ptr,size);
-
-#define READ_INT32(fp,i) \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  i=ntohl(tmpint32); \
-  DEBUG_PRINT("READ_INT32 : var="__STRING(i)" int32=%d",(int)i);
+#define READ(fp, ptr, size)                                                 \
+  if (tio_read(fp, ptr, (size_t)size))                                      \
+  {                                                                         \
+    DEBUG_PRINT("READ       : var="__STRING(ptr)" error: %s",               \
+                strerror(errno));                                           \
+    ERROR_OUT_READERROR(fp);                                                \
+  }                                                                         \
+  DEBUG_PRINT("READ       : var="__STRING(ptr)" size=%d", (int)(size));     \
+  DEBUG_DUMP(ptr, size);
+
+#define READ_INT32(fp, i)                                                   \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  (i) = ntohl(tmpint32);                                                    \
+  DEBUG_PRINT("READ_INT32 : var="__STRING(i)" int32=%d", (int)(i));
 
 /* read a string in a fixed-size "normal" buffer */
-#define READ_STRING(fp,buffer) \
-  /* read the size of the string */ \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" strlen=%d",tmpint32); \
-  /* check if read would fit */ \
-  if (((size_t)tmpint32)>=sizeof(buffer)) \
-  { \
-    /* will not fit */ \
-    tmpint32=(tmpint32-sizeof(buffer))+1; \
-    DEBUG_PRINT("READ       : buffer %d bytes too small",tmpint32); \
-    ERROR_OUT_BUFERROR(fp); \
-  } \
-  /* read string from the stream */ \
-  if (tmpint32>0) \
-    { READ(fp,buffer,(size_t)tmpint32); } \
-  /* null-terminate string in buffer */ \
-  buffer[tmpint32]='\0'; \
-  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" string=\"%s\"",buffer);
+#define READ_STRING(fp, buffer)                                             \
+  /* read the size of the string */                                         \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" strlen=%d", tmpint32);   \
+  /* check if read would fit */                                             \
+  if (((size_t)tmpint32) >= sizeof(buffer))                                 \
+  {                                                                         \
+    /* will not fit */                                                      \
+    tmpint32 = (tmpint32 - sizeof(buffer)) + 1;                             \
+    DEBUG_PRINT("READ       : buffer %d bytes too small", tmpint32);        \
+    ERROR_OUT_BUFERROR(fp);                                                 \
+  }                                                                         \
+  /* read string from the stream */                                         \
+  if (tmpint32 > 0)                                                         \
+  {                                                                         \
+    READ(fp, buffer, (size_t)tmpint32);                                     \
+  }                                                                         \
+  /* null-terminate string in buffer */                                     \
+  buffer[tmpint32] = '\0';                                                  \
+  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" string=\"%s\"", buffer);
 
 
 /* READ BUF macros that read data into a pre-allocated buffer.
@@ -201,120 +207,123 @@
    */
 
 /* current position in the buffer */
-#define BUF_CUR \
-  (buffer+bufptr)
+#define BUF_CUR                                                             \
+  (buffer + bufptr)
 
 /* check that the buffer has sz bytes left in it */
-#define BUF_CHECK(fp,sz) \
-  if ((bufptr+(size_t)(sz))>buflen) \
-  { \
-    /* will not fit */ \
-    tmpint32=bufptr+(sz)-(buflen); \
-    DEBUG_PRINT("READ       : buffer %d bytes too small",tmpint32); \
-    ERROR_OUT_BUFERROR(fp); \
+#define BUF_CHECK(fp, sz)                                                   \
+  if ((bufptr + (size_t)(sz)) > buflen)                                     \
+  {                                                                         \
+    /* will not fit */                                                      \
+    tmpint32 = bufptr + (sz) - (buflen);                                    \
+    DEBUG_PRINT("READ       : buffer %d bytes too small", tmpint32);        \
+    ERROR_OUT_BUFERROR(fp);                                                 \
   }
 
 /* move the buffer pointer */
-#define BUF_SKIP(sz) \
-  bufptr+=(size_t)(sz);
+#define BUF_SKIP(sz)                                                        \
+  bufptr += (size_t)(sz);
 
 /* move BUF_CUR foreward so that it is aligned to the specified
    type width */
-#define BUF_ALIGN(fp,type) \
-  /* figure out number of bytes to skip foreward */ \
-  tmp2int32=(sizeof(type)-((BUF_CUR-(char *)NULL)%sizeof(type)))%sizeof(type); 
\
-  /* check and skip */ \
-  BUF_CHECK(fp,tmp2int32); \
+#define BUF_ALIGN(fp, type)                                                 \
+  /* figure out number of bytes to skip foreward */                         \
+  tmp2int32 = (sizeof(type) - ((BUF_CUR - (char *)NULL) % sizeof(type)))    \
+              % sizeof(type);                                               \
+  /* check and skip */                                                      \
+  BUF_CHECK(fp, tmp2int32);                                                 \
   BUF_SKIP(tmp2int32);
 
 /* allocate a piece of the buffer to store an array in */
-#define BUF_ALLOC(fp,ptr,type,num) \
-  /* align to the specified type width */ \
-  BUF_ALIGN(fp,type); \
-  /* check that we have enough room */ \
-  BUF_CHECK(fp,(size_t)(num)*sizeof(type)); \
-  /* store the pointer */ \
-  (ptr)=(type *)BUF_CUR; \
-  /* reserve the space */ \
-  BUF_SKIP((size_t)(num)*sizeof(type));
+#define BUF_ALLOC(fp, ptr, type, num)                                       \
+  /* align to the specified type width */                                   \
+  BUF_ALIGN(fp, type);                                                      \
+  /* check that we have enough room */                                      \
+  BUF_CHECK(fp, (size_t)(num) * sizeof(type));                              \
+  /* store the pointer */                                                   \
+  (ptr) = (type *)BUF_CUR;                                                  \
+  /* reserve the space */                                                   \
+  BUF_SKIP((size_t)(num) * sizeof(type));
 
 /* read a binary blob into the buffer */
-#define READ_BUF(fp,ptr,sz) \
-  /* check that there is enough room and read */ \
-  BUF_CHECK(fp,sz); \
-  READ(fp,BUF_CUR,(size_t)sz); \
-  /* store pointer and skip */ \
-  (ptr)=BUF_CUR; \
+#define READ_BUF(fp, ptr, sz)                                               \
+  /* check that there is enough room and read */                            \
+  BUF_CHECK(fp, sz);                                                        \
+  READ(fp, BUF_CUR, (size_t)sz);                                            \
+  /* store pointer and skip */                                              \
+  (ptr) = BUF_CUR;                                                          \
   BUF_SKIP(sz);
 
 /* read string in the buffer (using buffer, buflen and bufptr)
    and store the actual location of the string in field */
-#define READ_BUF_STRING(fp,field) \
-  /* read the size of the string */ \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" strlen=%d",tmpint32); \
-  /* check if read would fit */ \
-  BUF_CHECK(fp,tmpint32+1); \
-  /* read string from the stream */ \
-  if (tmpint32>0) \
-    { READ(fp,BUF_CUR,(size_t)tmpint32); } \
-  /* null-terminate string in buffer */ \
-  BUF_CUR[tmpint32]='\0'; \
-  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" string=\"%s\"",BUF_CUR); 
\
-  /* prepare result */ \
-  (field)=BUF_CUR; \
-  BUF_SKIP(tmpint32+1);
+#define READ_BUF_STRING(fp, field)                                          \
+  /* read the size of the string */                                         \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" strlen=%d", tmpint32); \
+  /* check if read would fit */                                             \
+  BUF_CHECK(fp, tmpint32 + 1);                                              \
+  /* read string from the stream */                                         \
+  if (tmpint32 > 0)                                                         \
+  {                                                                         \
+    READ(fp, BUF_CUR, (size_t)tmpint32);                                    \
+  }                                                                         \
+  /* null-terminate string in buffer */                                     \
+  BUF_CUR[tmpint32] = '\0';                                                 \
+  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" string=\"%s\"", 
BUF_CUR); \
+  /* prepare result */                                                      \
+  (field) = BUF_CUR;                                                        \
+  BUF_SKIP(tmpint32 + 1);
 
 /* read an array from a stram and store it as a null-terminated
    array list (size for the array is allocated) */
-#define READ_BUF_STRINGLIST(fp,arr) \
-  /* read the number of entries */ \
-  READ(fp,&tmp3int32,sizeof(int32_t)); \
-  tmp3int32=ntohl(tmp3int32); \
-  DEBUG_PRINT("READ_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
-  /* allocate room for *char[num+1] */ \
-  BUF_ALLOC(fp,arr,char *,tmp3int32+1); \
-  /* read all entries */ \
-  for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
-  { \
-    READ_BUF_STRING(fp,(arr)[tmp2int32]); \
-  } \
-  /* set last entry to NULL */ \
-  (arr)[tmp2int32]=NULL;
+#define READ_BUF_STRINGLIST(fp, arr)                                        \
+  /* read the number of entries */                                          \
+  READ(fp, &tmp3int32, sizeof(int32_t));                                    \
+  tmp3int32 = ntohl(tmp3int32);                                             \
+  DEBUG_PRINT("READ_STRLST: var="__STRING(arr)" num=%d", (int)tmp3int32);   \
+  /* allocate room for *char[num + 1] */                                      \
+  BUF_ALLOC(fp, arr, char *, tmp3int32 + 1);                                \
+  /* read all entries */                                                    \
+  for (tmp2int32 = 0; tmp2int32 < tmp3int32; tmp2int32++)                   \
+  {                                                                         \
+    READ_BUF_STRING(fp, (arr)[tmp2int32]);                                  \
+  }                                                                         \
+  /* set last entry to NULL */                                              \
+  (arr)[tmp2int32] = NULL;
 
 
 /* SKIP macros for skipping over certain parts of the protocol stream. */
 
 /* skip a number of bytes foreward */
-#define SKIP(fp,sz) \
-  DEBUG_PRINT("READ       : skip %d bytes",(int)(sz)); \
-  /* read (skip) the specified number of bytes */ \
-  if (tio_skip(fp,sz)) \
-  { \
-    DEBUG_PRINT("READ       : skip error: %s",strerror(errno)); \
-    ERROR_OUT_READERROR(fp); \
+#define SKIP(fp, sz)                                                        \
+  DEBUG_PRINT("READ       : skip %d bytes", (int)(sz));                     \
+  /* read (skip) the specified number of bytes */                           \
+  if (tio_skip(fp, sz))                                                     \
+  {                                                                         \
+    DEBUG_PRINT("READ       : skip error: %s", strerror(errno));            \
+    ERROR_OUT_READERROR(fp);                                                \
   }
 
 /* read a string from the stream but don't do anything with the result */
-#define SKIP_STRING(fp) \
-  /* read the size of the string */ \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  DEBUG_PRINT("READ_STRING: skip %d bytes",(int)tmpint32); \
-  /* read (skip) the specified number of bytes */ \
-  SKIP(fp,tmpint32);
+#define SKIP_STRING(fp)                                                     \
+  /* read the size of the string */                                         \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  DEBUG_PRINT("READ_STRING: skip %d bytes", (int)tmpint32);                 \
+  /* read (skip) the specified number of bytes */                           \
+  SKIP(fp, tmpint32);
 
 /* skip a list of strings */
-#define SKIP_STRINGLIST(fp) \
-  /* read the number of entries */ \
-  READ(fp,&tmp3int32,sizeof(int32_t)); \
-  tmp3int32=ntohl(tmp3int32); \
-  DEBUG_PRINT("READ_STRLST: skip %d strings",(int)tmp3int32); \
-  /* read all entries */ \
-  for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
-  { \
-    SKIP_STRING(fp); \
+#define SKIP_STRINGLIST(fp)                                                 \
+  /* read the number of entries */                                          \
+  READ(fp, &tmp3int32, sizeof(int32_t));                                    \
+  tmp3int32 = ntohl(tmp3int32);                                             \
+  DEBUG_PRINT("READ_STRLST: skip %d strings", (int)tmp3int32);              \
+  /* read all entries */                                                    \
+  for (tmp2int32 = 0; tmp2int32 < tmp3int32; tmp2int32++)                   \
+  {                                                                         \
+    SKIP_STRING(fp);                                                        \
   }
 
 
@@ -327,38 +336,46 @@
   MUST_USE;
 
 /* generic request code */
-#define NSLCD_REQUEST(fp,action,writefn) \
-  /* open a client socket */ \
-  if ((fp=nslcd_client_open())==NULL) \
-    { ERROR_OUT_OPENERROR } \
-  /* write a request header with a request code */ \
-  WRITE_INT32(fp,(int32_t)NSLCD_VERSION) \
-  WRITE_INT32(fp,(int32_t)action) \
-  /* write the request parameters (if any) */ \
-  writefn; \
-  /* flush the stream */ \
-  if (tio_flush(fp)<0) \
-  { \
-    DEBUG_PRINT("WRITE_FLUSH : error: %s",strerror(errno)); \
-    ERROR_OUT_WRITEERROR(fp); \
-  } \
-  /* read and check response version number */ \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  if (tmpint32!=(int32_t)NSLCD_VERSION) \
-    { ERROR_OUT_READERROR(fp) } \
-  /* read and check response request number */ \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  if (tmpint32!=(int32_t)(action)) \
-    { ERROR_OUT_READERROR(fp) }
+#define NSLCD_REQUEST(fp, action, writefn)                                  \
+  /* open a client socket */                                                \
+  if ((fp = nslcd_client_open()) == NULL)                                   \
+  {                                                                         \
+    ERROR_OUT_OPENERROR;                                                    \
+  }                                                                         \
+  /* write a request header with a request code */                          \
+  WRITE_INT32(fp, (int32_t)NSLCD_VERSION)                                   \
+  WRITE_INT32(fp, (int32_t)action)                                          \
+  /* write the request parameters (if any) */                               \
+  writefn;                                                                  \
+  /* flush the stream */                                                    \
+  if (tio_flush(fp) < 0)                                                    \
+  {                                                                         \
+    DEBUG_PRINT("WRITE_FLUSH : error: %s", strerror(errno));                \
+    ERROR_OUT_WRITEERROR(fp);                                               \
+  }                                                                         \
+  /* read and check response version number */                              \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  if (tmpint32 != (int32_t)NSLCD_VERSION)                                   \
+  {                                                                         \
+    ERROR_OUT_READERROR(fp);                                                \
+  }                                                                         \
+  /* read and check response request number */                              \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  if (tmpint32 != (int32_t)(action))                                        \
+  {                                                                         \
+    ERROR_OUT_READERROR(fp);                                                \
+  }
 
 /* Read the response code (the result code of the query) from
    the stream. */
-#define READ_RESPONSE_CODE(fp) \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  tmpint32=ntohl(tmpint32); \
-  if (tmpint32!=(int32_t)NSLCD_RESULT_BEGIN) \
-    { ERROR_OUT_NOSUCCESS(fp) }
+#define READ_RESPONSE_CODE(fp)                                              \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  tmpint32 = ntohl(tmpint32);                                               \
+  if (tmpint32 != (int32_t)NSLCD_RESULT_BEGIN)                              \
+  {                                                                         \
+    ERROR_OUT_NOSUCCESS(fp);                                                \
+  }
 
 #endif /* not COMMON__NSLCD_PROT_H */

Modified: nss-pam-ldapd/common/set.c
==============================================================================
--- nss-pam-ldapd/common/set.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/set.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    set.c - set functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -41,27 +41,27 @@
   return (SET *)dict_new();
 }
 
-int set_add(SET *set,const char *value)
+int set_add(SET *set, const char *value)
 {
-  return dict_put((DICT *)set,value,set);
+  return dict_put((DICT *)set, value, set);
 }
 
 char *set_pop(SET *set)
 {
   const char *key;
   char *value;
-  key=dict_getany((DICT *)set);
-  if (key==NULL)
+  key = dict_getany((DICT *)set);
+  if (key == NULL)
     return NULL; /* no more entries in set */
   /* remove the entry from the dict and return a copy */
-  value=strdup(key);
-  dict_put((DICT *)set,key,NULL);
+  value = strdup(key);
+  dict_put((DICT *)set, key, NULL);
   return value;
 }
 
-int set_contains(SET *set,const char *value)
+int set_contains(SET *set, const char *value)
 {
-  return dict_get((DICT *)set,value)!=NULL;
+  return dict_get((DICT *)set, value) != NULL;
 }
 
 void set_free(SET *set)

Modified: nss-pam-ldapd/common/set.h
==============================================================================
--- nss-pam-ldapd/common/set.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/set.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    set.h - set functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -38,13 +38,13 @@
 
 /* Add a string in the set. The value is duplicated
    and can be reused by the caller.
-   This function returns non-0 in case of memory allocation
+   This function returns non-zero in case of memory allocation
    errors. All value comparisons are case sensitive. */
-int set_add(SET *set,const char *value);
+int set_add(SET *set, const char *value);
 
 /* Return non-zero if the value is in the set.
    All value comparisons are case sensitive. */
-int set_contains(SET *set,const char *value)
+int set_contains(SET *set, const char *value)
   MUST_USE;
 
 /* Get an element from the set and removes it from the set.

Modified: nss-pam-ldapd/common/tio.c
==============================================================================
--- nss-pam-ldapd/common/tio.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/tio.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -76,17 +76,17 @@
 };
 
 /* build a timeval for comparison to when the operation should be finished */
-static inline void tio_get_deadline(struct timeval *deadline,int timeout)
+static inline void tio_get_deadline(struct timeval *deadline, int timeout)
 {
-  if (gettimeofday(deadline,NULL))
+  if (gettimeofday(deadline, NULL))
   {
     /* just blank it in case of errors */
-    deadline->tv_sec=0;
-    deadline->tv_usec=0;
+    deadline->tv_sec = 0;
+    deadline->tv_usec = 0;
     return;
   }
-  deadline->tv_sec+=timeout/1000;
-  deadline->tv_usec+=(timeout%1000)*1000;
+  deadline->tv_sec += timeout / 1000;
+  deadline->tv_usec += (timeout % 1000) * 1000;
 }
 
 /* update the timeout to the value that is remaining before deadline
@@ -95,62 +95,63 @@
 {
   struct timeval tv;
   /* get the current time */
-  if (gettimeofday(&tv,NULL))
+  if (gettimeofday(&tv, NULL))
   {
     /* 1 second default if gettimeofday() is broken */
     return 1000;
   }
   /* calculate time remaining in miliseconds */
-  return (deadline->tv_sec-tv.tv_sec)*1000 + 
(deadline->tv_usec-tv.tv_usec)/1000;
+  return (deadline->tv_sec - tv.tv_sec) * 1000 +
+         (deadline->tv_usec - tv.tv_usec) / 1000;
 }
 
 /* open a new TFILE based on the file descriptor */
-TFILE *tio_fdopen(int fd,int readtimeout,int writetimeout,
-                  size_t initreadsize,size_t maxreadsize,
-                  size_t initwritesize,size_t maxwritesize)
+TFILE *tio_fdopen(int fd, int readtimeout, int writetimeout,
+                  size_t initreadsize, size_t maxreadsize,
+                  size_t initwritesize, size_t maxwritesize)
 {
   struct tio_fileinfo *fp;
-  fp=(struct tio_fileinfo *)malloc(sizeof(struct tio_fileinfo));
-  if (fp==NULL)
+  fp = (struct tio_fileinfo *)malloc(sizeof(struct tio_fileinfo));
+  if (fp == NULL)
     return NULL;
-  fp->fd=fd;
+  fp->fd = fd;
   /* initialize read buffer */
-  fp->readbuffer.buffer=(uint8_t *)malloc(initreadsize);
-  if (fp->readbuffer.buffer==NULL)
+  fp->readbuffer.buffer = (uint8_t *)malloc(initreadsize);
+  if (fp->readbuffer.buffer == NULL)
   {
     free(fp);
     return NULL;
   }
-  fp->readbuffer.size=initreadsize;
-  fp->readbuffer.maxsize=maxreadsize;
-  fp->readbuffer.start=0;
-  fp->readbuffer.len=0;
+  fp->readbuffer.size = initreadsize;
+  fp->readbuffer.maxsize = maxreadsize;
+  fp->readbuffer.start = 0;
+  fp->readbuffer.len = 0;
   /* initialize write buffer */
-  fp->writebuffer.buffer=(uint8_t *)malloc(initwritesize);
-  if (fp->writebuffer.buffer==NULL)
+  fp->writebuffer.buffer = (uint8_t *)malloc(initwritesize);
+  if (fp->writebuffer.buffer == NULL)
   {
     free(fp->readbuffer.buffer);
     free(fp);
     return NULL;
   }
-  fp->writebuffer.size=initwritesize;
-  fp->writebuffer.maxsize=maxwritesize;
-  fp->writebuffer.start=0;
-  fp->writebuffer.len=0;
+  fp->writebuffer.size = initwritesize;
+  fp->writebuffer.maxsize = maxwritesize;
+  fp->writebuffer.start = 0;
+  fp->writebuffer.len = 0;
   /* initialize other attributes */
-  fp->readtimeout=readtimeout;
-  fp->writetimeout=writetimeout;
-  fp->read_resettable=0;
+  fp->readtimeout = readtimeout;
+  fp->writetimeout = writetimeout;
+  fp->read_resettable = 0;
 #ifdef DEBUG_TIO_STATS
-  fp->byteswritten=0;
-  fp->bytesread=0;
+  fp->byteswritten = 0;
+  fp->bytesread = 0;
 #endif /* DEBUG_TIO_STATS */
   return fp;
 }
 
 /* wait for any activity on the specified file descriptor using
    the specified deadline */
-static int tio_wait(TFILE *fp,int readfd,const struct timeval *deadline)
+static int tio_wait(TFILE *fp, int readfd, const struct timeval *deadline)
 {
   int timeout;
   struct pollfd fds[1];
@@ -158,38 +159,38 @@
   while (1)
   {
     /* figure out the time we need to wait */
-    if ((timeout=tio_time_remaining(deadline))<0)
+    if ((timeout = tio_time_remaining(deadline)) < 0)
     {
-      errno=ETIME;
+      errno = ETIME;
       return -1;
     }
     /* wait for activity */
     if (readfd)
     {
-      fds[0].fd=fp->fd;
-      fds[0].events=POLLIN;
+      fds[0].fd = fp->fd;
+      fds[0].events = POLLIN;
       /* santiy check for moving clock */
-      if (timeout>fp->readtimeout)
-        timeout=fp->readtimeout;
+      if (timeout > fp->readtimeout)
+        timeout = fp->readtimeout;
     }
     else
     {
-      fds[0].fd=fp->fd;
-      fds[0].events=POLLOUT;
+      fds[0].fd = fp->fd;
+      fds[0].events = POLLOUT;
       /* santiy check for moving clock */
-      if (timeout>fp->writetimeout)
-        timeout=fp->writetimeout;
+      if (timeout > fp->writetimeout)
+        timeout = fp->writetimeout;
     }
-    rv=poll(fds,1,timeout);
-    if (rv>0)
+    rv = poll(fds, 1, timeout);
+    if (rv > 0)
       return 0; /* we have activity */
-    else if (rv==0)
+    else if (rv == 0)
     {
       /* no file descriptors were available within the specified time */
-      errno=ETIME;
+      errno = ETIME;
       return -1;
     }
-    else if (errno!=EINTR)
+    else if (errno != EINTR)
       /* some error ocurred */
       return -1;
     /* we just try again on EINTR */
@@ -206,87 +207,88 @@
   size_t newsz;
   size_t len;
   /* have a more convenient storage type for the buffer */
-  uint8_t *ptr=(uint8_t *)buf;
+  uint8_t *ptr = (uint8_t *)buf;
   /* build a time by which we should be finished */
-  tio_get_deadline(&deadline,fp->readtimeout);
+  tio_get_deadline(&deadline, fp->readtimeout);
   /* loop until we have returned all the needed data */
   while (1)
   {
     /* check if we have enough data in the buffer */
     if (fp->readbuffer.len >= count)
     {
-      if (count>0)
+      if (count > 0)
       {
-        if (ptr!=NULL)
-          memcpy(ptr,fp->readbuffer.buffer+fp->readbuffer.start,count);
+        if (ptr != NULL)
+          memcpy(ptr, fp->readbuffer.buffer + fp->readbuffer.start, count);
         /* adjust buffer position */
-        fp->readbuffer.start+=count;
-        fp->readbuffer.len-=count;
+        fp->readbuffer.start += count;
+        fp->readbuffer.len -= count;
       }
       return 0;
     }
     /* empty what we have and continue from there */
-    if (fp->readbuffer.len>0)
+    if (fp->readbuffer.len > 0)
     {
-      if (ptr!=NULL)
+      if (ptr != NULL)
       {
-        
memcpy(ptr,fp->readbuffer.buffer+fp->readbuffer.start,fp->readbuffer.len);
-        ptr+=fp->readbuffer.len;
+        memcpy(ptr, fp->readbuffer.buffer + fp->readbuffer.start,
+               fp->readbuffer.len);
+        ptr += fp->readbuffer.len;
       }
-      count-=fp->readbuffer.len;
-      fp->readbuffer.start+=fp->readbuffer.len;
-      fp->readbuffer.len=0;
+      count -= fp->readbuffer.len;
+      fp->readbuffer.start += fp->readbuffer.len;
+      fp->readbuffer.len = 0;
     }
     /* after this point until the read fp->readbuffer.len is 0 */
     if (!fp->read_resettable)
     {
       /* the stream is not resettable, re-use the buffer */
-      fp->readbuffer.start=0;
+      fp->readbuffer.start = 0;
     }
-    else if (fp->readbuffer.start>=(fp->readbuffer.size-4))
+    else if (fp->readbuffer.start >= (fp->readbuffer.size - 4))
     {
       /* buffer is running empty, try to grow buffer */
-      if (fp->readbuffer.size<fp->readbuffer.maxsize)
+      if (fp->readbuffer.size < fp->readbuffer.maxsize)
       {
-        newsz=fp->readbuffer.size*2;
-        if (newsz>fp->readbuffer.maxsize)
-          newsz=fp->readbuffer.maxsize;
-        tmp=realloc(fp->readbuffer.buffer,newsz);
-        if (tmp!=NULL)
+        newsz = fp->readbuffer.size * 2;
+        if (newsz > fp->readbuffer.maxsize)
+          newsz = fp->readbuffer.maxsize;
+        tmp = realloc(fp->readbuffer.buffer, newsz);
+        if (tmp != NULL)
         {
-          fp->readbuffer.buffer=tmp;
-          fp->readbuffer.size=newsz;
+          fp->readbuffer.buffer = tmp;
+          fp->readbuffer.size = newsz;
         }
       }
       /* if buffer still does not contain enough room, clear resettable */
-      if (fp->readbuffer.start>=(fp->readbuffer.size-4))
+      if (fp->readbuffer.start >= (fp->readbuffer.size - 4))
       {
-        fp->readbuffer.start=0;
-        fp->read_resettable=0;
+        fp->readbuffer.start = 0;
+        fp->read_resettable = 0;
       }
     }
     /* wait until we have input */
-    if (tio_wait(fp,1,&deadline))
+    if (tio_wait(fp, 1, &deadline))
       return -1;
     /* read the input in the buffer */
-    len=fp->readbuffer.size-fp->readbuffer.start;
+    len = fp->readbuffer.size - fp->readbuffer.start;
 #ifdef SSIZE_MAX
-    if (len>SSIZE_MAX)
-      len=SSIZE_MAX;
+    if (len > SSIZE_MAX)
+      len = SSIZE_MAX;
 #endif /* SSIZE_MAX */
-    rv=read(fp->fd,fp->readbuffer.buffer+fp->readbuffer.start,len);
+    rv = read(fp->fd, fp->readbuffer.buffer + fp->readbuffer.start, len);
     /* check for errors */
-    if (rv==0)
+    if (rv == 0)
     {
-      errno=ECONNRESET;
+      errno = ECONNRESET;
       return -1;
     }
-    else if ((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN))
-      return -1; /* something went wrong with the read */
+    else if ((rv < 0) && (errno != EINTR) && (errno != EAGAIN))
+      return -1;        /* something went wrong with the read */
     /* skip the read part in the buffer */
-    fp->readbuffer.len=rv;
+    fp->readbuffer.len = rv;
 #ifdef DEBUG_TIO_STATS
-    fp->bytesread+=rv;
+    fp->bytesread += rv;
 #endif /* DEBUG_TIO_STATS */
   }
 }
@@ -294,7 +296,7 @@
 /* Read and discard the specified number of bytes from the stream. */
 int tio_skip(TFILE *fp, size_t count)
 {
-  return tio_read(fp,NULL,count);
+  return tio_read(fp, NULL, count);
 }
 
 /* Read all available data from the stream and empty the read buffer. */
@@ -304,35 +306,35 @@
   int rv;
   size_t len;
   /* clear the read buffer */
-  fp->readbuffer.start=0;
-  fp->readbuffer.len=0;
-  fp->read_resettable=0;
+  fp->readbuffer.start = 0;
+  fp->readbuffer.len = 0;
+  fp->read_resettable = 0;
   /* read until we can't read no more */
-  len=fp->readbuffer.size;
+  len = fp->readbuffer.size;
 #ifdef SSIZE_MAX
-  if (len>SSIZE_MAX)
-    len=SSIZE_MAX;
+  if (len > SSIZE_MAX)
+    len = SSIZE_MAX;
 #endif /* SSIZE_MAX */
   while (1)
   {
     /* see if any data is available */
-    fds[0].fd=fp->fd;
-    fds[0].events=POLLIN;
-    rv=poll(fds,1,0);
+    fds[0].fd = fp->fd;
+    fds[0].events = POLLIN;
+    rv = poll(fds, 1, 0);
     /* check the poll() result */
-    if (rv==0)
+    if (rv == 0)
       return 0; /* no file descriptor ready */
-    if ((rv<0)&&((errno==EINTR)||(errno==EAGAIN)))
+    if ((rv < 0) && ((errno == EINTR) || (errno == EAGAIN)))
       continue; /* interrupted, try again */
-    if (rv<0)
+    if (rv < 0)
       return -1; /* something went wrong */
     /* read data from the stream */
-    rv=read(fp->fd,fp->readbuffer.buffer,len);
-    if (rv==0)
+    rv = read(fp->fd, fp->readbuffer.buffer, len);
+    if (rv == 0)
       return 0; /* end-of-file */
-    if ((rv<0)&&(errno==EWOULDBLOCK))
+    if ((rv < 0) && (errno == EWOULDBLOCK))
       return 0; /* we've ready everything we can without blocking */
-    if ((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN))
+    if ((rv < 0) && (errno != EINTR) && (errno != EAGAIN))
       return -1; /* something went wrong with the read */
   }
 }
@@ -344,46 +346,50 @@
   int rv;
   /* write the buffer */
 #ifdef MSG_NOSIGNAL
-  
rv=send(fp->fd,fp->writebuffer.buffer+fp->writebuffer.start,fp->writebuffer.len,MSG_NOSIGNAL);
+  rv = send(fp->fd, fp->writebuffer.buffer + fp->writebuffer.start,
+            fp->writebuffer.len, MSG_NOSIGNAL);
 #else /* not MSG_NOSIGNAL */
   /* on platforms that cannot use send() with masked signals, we change the
      signal mask and change it back after the write (note that there is a
      race condition here) */
-  struct sigaction act,oldact;
+  struct sigaction act, oldact;
   /* set up sigaction */
-  memset(&act,0,sizeof(struct sigaction));
-  act.sa_sigaction=NULL;
-  act.sa_handler=SIG_IGN;
+  memset(&act, 0, sizeof(struct sigaction));
+  act.sa_sigaction = NULL;
+  act.sa_handler = SIG_IGN;
   sigemptyset(&act.sa_mask);
-  act.sa_flags=SA_RESTART;
+  act.sa_flags = SA_RESTART;
   /* ignore SIGPIPE */
-  if (sigaction(SIGPIPE,&act,&oldact)!=0)
+  if (sigaction(SIGPIPE, &act, &oldact) != 0)
     return -1; /* error setting signal handler */
   /* write the buffer */
-  
rv=write(fp->fd,fp->writebuffer.buffer+fp->writebuffer.start,fp->writebuffer.len);
+  rv = write(fp->fd, fp->writebuffer.buffer + fp->writebuffer.start,
+             fp->writebuffer.len);
   /* restore the old handler for SIGPIPE */
-  if (sigaction(SIGPIPE,&oldact,NULL)!=0)
+  if (sigaction(SIGPIPE, &oldact, NULL) != 0)
     return -1; /* error restoring signal handler */
 #endif
   /* check for errors */
-  if ((rv==0)||((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN)))
+  if ((rv == 0) || ((rv < 0) && (errno != EINTR) && (errno != EAGAIN)))
     return -1; /* something went wrong with the write */
   /* skip the written part in the buffer */
-  if (rv>0)
+  if (rv > 0)
   {
-    fp->writebuffer.start+=rv;
-    fp->writebuffer.len-=rv;
+    fp->writebuffer.start += rv;
+    fp->writebuffer.len -= rv;
 #ifdef DEBUG_TIO_STATS
-    fp->byteswritten+=rv;
+    fp->byteswritten += rv;
 #endif /* DEBUG_TIO_STATS */
     /* reset start if len is 0 */
-    if (fp->writebuffer.len==0)
-      fp->writebuffer.start=0;
+    if (fp->writebuffer.len == 0)
+      fp->writebuffer.start = 0;
     /* move contents of the buffer to the front if it will save enough room */
-    if (fp->writebuffer.start>=(fp->writebuffer.size/4))
+    if (fp->writebuffer.start >= (fp->writebuffer.size / 4))
     {
-      
memmove(fp->writebuffer.buffer,fp->writebuffer.buffer+fp->writebuffer.start,fp->writebuffer.len);
-      fp->writebuffer.start=0;
+      memmove(fp->writebuffer.buffer,
+              fp->writebuffer.buffer + fp->writebuffer.start,
+              fp->writebuffer.len);
+      fp->writebuffer.start = 0;
     }
   }
   return 0;
@@ -394,12 +400,12 @@
 {
   struct timeval deadline;
   /* build a time by which we should be finished */
-  tio_get_deadline(&deadline,fp->writetimeout);
+  tio_get_deadline(&deadline, fp->writetimeout);
   /* loop until we have written our buffer */
   while (fp->writebuffer.len > 0)
   {
     /* wait until we can write */
-    if (tio_wait(fp,0,&deadline))
+    if (tio_wait(fp, 0, &deadline))
       return -1;
     /* write one block */
     if (tio_writebuf(fp))
@@ -415,15 +421,15 @@
   struct pollfd fds[1];
   int rv;
   /* see if we can write without blocking */
-  fds[0].fd=fp->fd;
-  fds[0].events=POLLOUT;
-  rv=poll(fds,1,0);
+  fds[0].fd = fp->fd;
+  fds[0].events = POLLOUT;
+  rv = poll(fds, 1, 0);
   /* check if any file descriptors were ready (timeout) or we were
      interrupted */
-  if ((rv==0)||((rv<0)&&(errno==EINTR)))
+  if ((rv == 0) || ((rv < 0) && (errno == EINTR)))
     return 0;
   /* any other errors? */
-  if (rv<0)
+  if (rv < 0)
     return -1;
   /* so file descriptor will accept writes */
   return tio_writebuf(fp);
@@ -434,44 +440,46 @@
   size_t fr;
   uint8_t *tmp;
   size_t newsz;
-  const uint8_t *ptr=(const uint8_t *)buf;
+  const uint8_t *ptr = (const uint8_t *)buf;
   /* keep filling the buffer until we have bufferred everything */
-  while (count>0)
+  while (count > 0)
   {
     /* figure out free size in buffer */
-    fr=fp->writebuffer.size-(fp->writebuffer.start+fp->writebuffer.len);
+    fr = fp->writebuffer.size - (fp->writebuffer.start + fp->writebuffer.len);
     if (count <= fr)
     {
       /* the data fits in the buffer */
-      
memcpy(fp->writebuffer.buffer+fp->writebuffer.start+fp->writebuffer.len,ptr,count);
-      fp->writebuffer.len+=count;
+      memcpy(fp->writebuffer.buffer + fp->writebuffer.start +
+             fp->writebuffer.len, ptr, count);
+      fp->writebuffer.len += count;
       return 0;
     }
     else if (fr > 0)
     {
       /* fill the buffer with data that will fit */
-      
memcpy(fp->writebuffer.buffer+fp->writebuffer.start+fp->writebuffer.len,ptr,fr);
-      fp->writebuffer.len+=fr;
-      ptr+=fr;
-      count-=fr;
+      memcpy(fp->writebuffer.buffer + fp->writebuffer.start +
+             fp->writebuffer.len, ptr, fr);
+      fp->writebuffer.len += fr;
+      ptr += fr;
+      count -= fr;
     }
     /* try to flush some of the data that is in the buffer */
     if (tio_flush_nonblock(fp))
       return -1;
     /* if we have room now, try again */
-    if (fp->writebuffer.size>(fp->writebuffer.start+fp->writebuffer.len))
+    if (fp->writebuffer.size > (fp->writebuffer.start + fp->writebuffer.len))
       continue;
     /* try to grow the buffer */
-    if (fp->writebuffer.size<fp->writebuffer.maxsize)
+    if (fp->writebuffer.size < fp->writebuffer.maxsize)
     {
-      newsz=fp->writebuffer.size*2;
-      if (newsz>fp->writebuffer.maxsize)
-        newsz=fp->writebuffer.maxsize;
-      tmp=realloc(fp->writebuffer.buffer,newsz);
-      if (tmp!=NULL)
+      newsz = fp->writebuffer.size * 2;
+      if (newsz > fp->writebuffer.maxsize)
+        newsz = fp->writebuffer.maxsize;
+      tmp = realloc(fp->writebuffer.buffer, newsz);
+      if (tmp != NULL)
       {
-        fp->writebuffer.buffer=tmp;
-        fp->writebuffer.size=newsz;
+        fp->writebuffer.buffer = tmp;
+        fp->writebuffer.size = newsz;
         continue; /* try again */
       }
     }
@@ -486,14 +494,15 @@
 {
   int retv;
   /* write any buffered data */
-  retv=tio_flush(fp);
+  retv = tio_flush(fp);
 #ifdef DEBUG_TIO_STATS
   /* dump statistics to stderr */
-  fprintf(stderr,"DEBUG_TIO_STATS READ=%d 
WRITTEN=%d\n",fp->bytesread,fp->byteswritten);
+  fprintf(stderr, "DEBUG_TIO_STATS READ=%d WRITTEN=%d\n", fp->bytesread,
+          fp->byteswritten);
 #endif /* DEBUG_TIO_STATS */
   /* close file descriptor */
   if (close(fp->fd))
-    retv=-1;
+    retv = -1;
   /* free any allocated buffers */
   free(fp->readbuffer.buffer);
   free(fp->writebuffer.buffer);
@@ -506,13 +515,14 @@
 void tio_mark(TFILE *fp)
 {
   /* move any data in the buffer to the start of the buffer */
-  if ((fp->readbuffer.start>0)&&(fp->readbuffer.len>0))
+  if ((fp->readbuffer.start > 0) && (fp->readbuffer.len > 0))
   {
-    
memmove(fp->readbuffer.buffer,fp->readbuffer.buffer+fp->readbuffer.start,fp->readbuffer.len);
-    fp->readbuffer.start=0;
+    memmove(fp->readbuffer.buffer,
+            fp->readbuffer.buffer + fp->readbuffer.start, fp->readbuffer.len);
+    fp->readbuffer.start = 0;
   }
   /* mark the stream as resettable */
-  fp->read_resettable=1;
+  fp->read_resettable = 1;
 }
 
 int tio_reset(TFILE *fp)
@@ -521,7 +531,7 @@
   if (!fp->read_resettable)
     return -1;
   /* reset the buffer */
-  fp->readbuffer.len+=fp->readbuffer.start;
-  fp->readbuffer.start=0;
+  fp->readbuffer.len += fp->readbuffer.start;
+  fp->readbuffer.start = 0;
   return 0;
 }

Modified: nss-pam-ldapd/common/tio.h
==============================================================================
--- nss-pam-ldapd/common/tio.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/common/tio.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -47,22 +47,22 @@
 
 /* Open a new TFILE based on the file descriptor. The timeout is set for any
    operation (value in milliseconds). */
-TFILE *tio_fdopen(int fd,int readtimeout,int writetimeout,
-                  size_t initreadsize,size_t maxreadsize,
-                  size_t initwritesize,size_t maxwritesize)
+TFILE *tio_fdopen(int fd, int readtimeout, int writetimeout,
+                  size_t initreadsize, size_t maxreadsize,
+                  size_t initwritesize, size_t maxwritesize)
   LIKE_MALLOC MUST_USE;
 
 /* Read the specified number of bytes from the stream. */
-int tio_read(TFILE *fp,void *buf,size_t count);
+int tio_read(TFILE *fp, void *buf, size_t count);
 
 /* Read and discard the specified number of bytes from the stream. */
-int tio_skip(TFILE *fp,size_t count);
+int tio_skip(TFILE *fp, size_t count);
 
 /* Read all available data from the stream and empty the read buffer. */
 int tio_skipall(TFILE *fp);
 
 /* Write the specified buffer to the stream. */
-int tio_write(TFILE *fp,const void *buf,size_t count);
+int tio_write(TFILE *fp, const void *buf, size_t count);
 
 /* Write out all buffered data to the stream. */
 int tio_flush(TFILE *fp);

Modified: nss-pam-ldapd/compat/attrs.h
==============================================================================
--- nss-pam-ldapd/compat/attrs.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/attrs.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    attrs.h - wrapper macros for the gcc __attribute__(()) directive
 
-   Copyright (C) 2007, 2008 Arthur de Jong
+   Copyright (C) 2007, 2008, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,7 @@
 #define COMPAT__ATTRS_H 1
 
 /* macro for testing the version of GCC */
-#define GCC_VERSION(major,minor) \
+#define GCC_VERSION(major, minor)                                           \
   ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
 
 /* These are macros to use some gcc-specific flags in case the're available
@@ -34,7 +34,7 @@
 
 /* this is used to flag function parameters that are not used in the function
    body. */
-#if GCC_VERSION(3,0)
+#if GCC_VERSION(3, 0)
 #define UNUSED(x)   x __attribute__((__unused__))
 #else
 #define UNUSED(x)   x
@@ -42,16 +42,16 @@
 
 /* this is used to add extra format checking to the function calls as if this
    was a printf()-like function */
-#if GCC_VERSION(3,0)
-#define LIKE_PRINTF(format_idx,arg_idx) \
-                    __attribute__((__format__(__printf__,format_idx,arg_idx)))
+#if GCC_VERSION(3, 0)
+#define LIKE_PRINTF(format_idx, arg_idx)                                    \
+                    __attribute__((__format__(__printf__, format_idx, 
arg_idx)))
 #else
-#define LIKE_PRINTF(format_idx,arg_idx) /* no attribute */
+#define LIKE_PRINTF(format_idx, arg_idx) /* no attribute */
 #endif
 
 /* indicates that the function is "pure": it's result is purely based on
    the parameters and has no side effects or used static data */
-#if GCC_VERSION(3,0)
+#if GCC_VERSION(3, 0)
 #define PURE        __attribute__((__pure__))
 #else
 #define PURE        /* no attribute */
@@ -59,21 +59,21 @@
 
 /* the function returns a new data structure that has been freshly
    allocated */
-#if GCC_VERSION(3,0)
+#if GCC_VERSION(3, 0)
 #define LIKE_MALLOC __attribute__((__malloc__))
 #else
 #define LIKE_MALLOC /* no attribute */
 #endif
 
 /* the function's return value should be used by the caller */
-#if GCC_VERSION(3,4)
+#if GCC_VERSION(3, 4)
 #define MUST_USE    __attribute__((__warn_unused_result__))
 #else
 #define MUST_USE    /* no attribute */
 #endif
 
 /* the function's return value should be used by the caller */
-#if GCC_VERSION(2,5)
+#if GCC_VERSION(2, 5)
 #define NORETURN    __attribute__((__noreturn__))
 #else
 #define NORETURN    /* no attribute */

Modified: nss-pam-ldapd/compat/daemon.c
==============================================================================
--- nss-pam-ldapd/compat/daemon.c       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/daemon.c       Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    daemon.c - implementation of daemon() for systems that lack it
 
-   Copyright (C) 2002, 2003, 2008 Arthur de Jong
+   Copyright (C) 2002, 2003, 2008, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -26,46 +26,46 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-int daemon(int nochdir,int noclose)
+int daemon(int nochdir, int noclose)
 {
   /* change directory */
   if (!nochdir)
-    if (chdir("/")!=0)
+    if (chdir("/") != 0)
       return -1;
   /* fork() and exit() to detach from the parent process */
   switch (fork())
   {
-  case 0: /* we are the child */
-    break;
-  case -1: /* we are the parent, but have an error */
-    return -1;
-  default: /* we are the parent and we're done*/
-    _exit(0);
+    case 0:    /* we are the child */
+      break;
+    case -1:   /* we are the parent, but have an error */
+      return -1;
+    default:   /* we are the parent and we're done */
+      _exit(0);
   }
   /* become process leader */
-  if (setsid()<0)
+  if (setsid() < 0)
   {
     return -1;
   }
   /* fork again so we cannot allocate a pty */
   switch (fork())
   {
-  case 0: /* we are the child */
-    break;
-  case -1: /* we are the parent, but have an error */
-    return -1;
-  default: /* we are the parent and we're done*/
-    _exit(0);
+    case 0:    /* we are the child */
+      break;
+    case -1:   /* we are the parent, but have an error */
+      return -1;
+    default:   /* we are the parent and we're done */
+      _exit(0);
   }
   /* close stdin, stdout and stderr and reconnect to /dev/null */
   if (!noclose)
   {
-    close(0); /* stdin */
-    close(1); /* stdout */
-    close(2); /* stderr */
-    open("/dev/null",O_RDWR); /* stdin, fd=0 */
-    dup(0); /* stdout, fd=1 */
-    dup(0); /* stderr, fd=2 */
+    close(0);   /* stdin */
+    close(1);   /* stdout */
+    close(2);   /* stderr */
+    open("/dev/null", O_RDWR);  /* stdin, fd=0 */
+    dup(0);     /* stdout, fd=1 */
+    dup(0);     /* stderr, fd=2 */
   }
   return 0;
 }

Modified: nss-pam-ldapd/compat/daemon.h
==============================================================================
--- nss-pam-ldapd/compat/daemon.h       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/daemon.h       Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    daemon.h - definition of daemon() for systems that lack it
 
-   Copyright (C) 2002, 2003, 2008, 2011 Arthur de Jong
+   Copyright (C) 2002, 2003, 2008, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@
 /* we define daemon() here because on some platforms the function is
    undefined: deamonize process, optionally chdir to / and optionally
    close stdin, strdout and stderr and redirect them to /dev/null */
-int daemon(int nochdir,int noclose);
+int daemon(int nochdir, int noclose);
 #endif /* not HAVE_DECL_DAEMON */
 
 #endif /* not COMPAT__DAEMON_H */

Modified: nss-pam-ldapd/compat/ether.c
==============================================================================
--- nss-pam-ldapd/compat/ether.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/ether.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    ether.c - useful ethernet functions for systems lacking those
 
-   Copyright (C) 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -36,25 +36,25 @@
 /* these functions are not really reentrant */
 
 #ifndef HAVE_ETHER_NTOA_R
-char *ether_ntoa_r(const struct ether_addr *addr,char *buf)
+char *ether_ntoa_r(const struct ether_addr *addr, char *buf)
 {
   char *tmp;
-  tmp=ether_ntoa(addr);
-  if (tmp==NULL)
+  tmp = ether_ntoa(addr);
+  if (tmp == NULL)
     return NULL;
-  strcpy(buf,tmp);
+  strcpy(buf, tmp);
   return buf;
 }
 #endif /* not HAVE_ETHER_NTOA_R */
 
 #ifndef HAVE_ETHER_ATON_R
-struct ether_addr *ether_aton_r(const char *asc,struct ether_addr *addr)
+struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
 {
   struct ether_addr *tmp;
-  tmp=ether_aton(asc);
-  if (tmp==NULL)
+  tmp = ether_aton(asc);
+  if (tmp == NULL)
     return NULL;
-  memcpy(addr,tmp,sizeof(struct ether_addr));
+  memcpy(addr, tmp, sizeof(struct ether_addr));
   return addr;
 }
 #endif /* not HAVE_ETHER_ATON_R */

Modified: nss-pam-ldapd/compat/ether.h
==============================================================================
--- nss-pam-ldapd/compat/ether.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/ether.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    ether.h - ethernet definitions for systems lacking those
 
-   Copyright (C) 2008, 2010 Arthur de Jong
+   Copyright (C) 2008, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -38,11 +38,11 @@
 #endif /* not HAVE_STRUCT_ETHER_ADDR */
 
 #ifndef HAVE_ETHER_NTOA_R
-char *ether_ntoa_r(const struct ether_addr *addr,char *buf);
+char *ether_ntoa_r(const struct ether_addr *addr, char *buf);
 #endif /* not HAVE_ETHER_NTOA_R */
 
 #ifndef HAVE_ETHER_ATON_R
-struct ether_addr *ether_aton_r(const char *asc,struct ether_addr *addr);
+struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr);
 #endif /* not HAVE_ETHER_ATON_R */
 
 #ifdef HAVE_ETHER_NTOA

Modified: nss-pam-ldapd/compat/getopt_long.c
==============================================================================
--- nss-pam-ldapd/compat/getopt_long.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/getopt_long.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    getopt_long.c - implementation of getopt_long() for systems that lack it
 
-   Copyright (C) 2001, 2002, 2008 Arthur de Jong
+   Copyright (C) 2001, 2002, 2008, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -31,55 +31,53 @@
    to options and options following filenames is not quite right, allso
    minimal error checking is provided
    */
-int getopt_long(int argc,char * const argv[],
+int getopt_long(int argc, char *const argv[],
                 const char *optstring,
-                const struct option *longopts,int *longindex)
+                const struct option *longopts, int *longindex)
 {
-  int i;   /* for looping through options */
-  int l;   /* for length */
-
+  int i, l;
   /* first check if there realy is a -- option */
-  if ( (optind>0)&&(optind<argc) &&
-       (strncmp(argv[optind],"--",2)==0) &&
-       (argv[optind][2]!='\0') )
+  if ((optind > 0) && (optind < argc) &&
+      (strncmp(argv[optind], "--", 2) == 0) &&
+      (argv[optind][2] != '\0'))
   {
     /* check the longopts list for a valid option */
-    for (i=0;longopts[i].name!=NULL;i++)
+    for (i = 0; longopts[i].name != NULL; i++)
     {
       /* save the length for later */
-      l=strlen(longopts[i].name);
-      if (strncmp(argv[optind]+2,longopts[i].name,l)==0)
+      l = strlen(longopts[i].name);
+      if (strncmp(argv[optind] + 2, longopts[i].name, l) == 0)
       {
         /* we have a match */
-        if ( (longopts[i].has_arg==no_argument) &&
-             (argv[optind][2+l]=='\0') )
+        if ((longopts[i].has_arg == no_argument) &&
+            (argv[optind][2 + l] == '\0'))
         {
           optind++;
           return longopts[i].val;
         }
-        else if ( (longopts[i].has_arg==required_argument) &&
-                  (argv[optind][2+l]=='=') )
+        else if ((longopts[i].has_arg == required_argument) &&
+                 (argv[optind][2 + l] == '='))
         {
-          optarg=argv[optind]+3+l;
+          optarg = argv[optind] + 3 + l;
           optind++;
           return longopts[i].val;
         }
-        else if ( (longopts[i].has_arg==required_argument) &&
-                  (argv[optind][2+l]=='\0') )
+        else if ((longopts[i].has_arg == required_argument) &&
+                 (argv[optind][2 + l] == '\0'))
         {
-          optarg=argv[optind+1];
-          optind+=2;
+          optarg = argv[optind + 1];
+          optind += 2;
           return longopts[i].val;
         }
-        else if ( (longopts[i].has_arg==optional_argument) &&
-                  (argv[optind][2+l]=='=') )
+        else if ((longopts[i].has_arg == optional_argument) &&
+                 (argv[optind][2 + l] == '='))
         {
-          optarg=argv[optind]+3+l;
+          optarg = argv[optind] + 3 + l;
           optind++;
           return longopts[i].val;
         }
-        else if ( (longopts[i].has_arg==optional_argument) &&
-                  (argv[optind][2+l]=='\0') )
+        else if ((longopts[i].has_arg == optional_argument) &&
+                 (argv[optind][2 + l] == '\0'))
         {
           optind++;
           return longopts[i].val;
@@ -88,5 +86,5 @@
     }
   }
   /* if all else fails use plain getopt() */
-  return getopt(argc,argv,optstring);
+  return getopt(argc, argv, optstring);
 }

Modified: nss-pam-ldapd/compat/getopt_long.h
==============================================================================
--- nss-pam-ldapd/compat/getopt_long.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/getopt_long.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    getopt_long.h - definition of getopt_long() for systems that lack it
 
-   Copyright (C) 2001, 2002, 2008 Arthur de Jong
+   Copyright (C) 2001, 2002, 2008, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -41,9 +41,9 @@
    to options and options following filenames is not quite right, allso
    minimal error checking
    */
-int getopt_long(int argc,char * const argv[],
+int getopt_long(int argc, char *const argv[],
                 const char *optstring,
-                const struct option *longopts,int *longindex);
+                const struct option *longopts, int *longindex);
 
 #endif /* not HAVE_GETOPT_LONG */
 

Modified: nss-pam-ldapd/compat/getpeercred.c
==============================================================================
--- nss-pam-ldapd/compat/getpeercred.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/getpeercred.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -3,7 +3,7 @@
                    other end of a unix socket
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008 Arthur de Jong
+   Copyright (C) 2008, 2009, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -40,67 +40,81 @@
 /* Note: most of this code is untested, except for the first
          implementation (it may even fail to compile) */
 
-int getpeercred(int sock,uid_t *uid,gid_t *gid,pid_t *pid)
+int getpeercred(int sock, uid_t *uid, gid_t *gid, pid_t *pid)
 {
 #if defined(SO_PEERCRED)
   socklen_t l;
   struct ucred cred;
   /* initialize client information (in case getsockopt() breaks) */
-  cred.pid=(pid_t)0;
-  cred.uid=(uid_t)-1;
-  cred.gid=(gid_t)-1;
+  cred.pid = (pid_t)0;
+  cred.uid = (uid_t)-1;
+  cred.gid = (gid_t)-1;
   /* look up process information from peer */
-  l=(socklen_t)sizeof(struct ucred);
-  if (getsockopt(sock,SOL_SOCKET,SO_PEERCRED,&cred,&l) < 0)
+  l = (socklen_t)sizeof(struct ucred);
+  if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &cred, &l) < 0)
     return -1; /* errno already set */
   /* return the data */
-  if (uid!=NULL) *uid=cred.uid;
-  if (gid!=NULL) *gid=cred.gid;
-  if (pid!=NULL) *pid=cred.pid;
+  if (uid != NULL)
+    *uid = cred.uid;
+  if (gid != NULL)
+    *gid = cred.gid;
+  if (pid != NULL)
+    *pid = cred.pid;
   return 0;
 #elif defined(LOCAL_PEERCRED)
   socklen_t l;
   struct xucred cred;
   /* look up process information from peer */
-  l=(socklen_t)sizeof(struct xucred);
-  if (getsockopt(sock,0,LOCAL_PEERCRED,&cred,&l) < 0)
+  l = (socklen_t)sizeof(struct xucred);
+  if (getsockopt(sock, 0, LOCAL_PEERCRED, &cred, &l) < 0)
     return -1; /* errno already set */
-  if (cred.cr_version!=XUCRED_VERSION)
+  if (cred.cr_version != XUCRED_VERSION)
   {
-    errno=EINVAL;
+    errno = EINVAL;
     return -1;
   }
   /* return the data */
-  if (uid!=NULL) *uid=cred.cr_uid;
-  if (gid!=NULL) *gid=cred.cr_gid;
-  if (pid!=NULL) *pid=(pid_t)-1;
+  if (uid != NULL)
+    *uid = cred.cr_uid;
+  if (gid != NULL)
+    *gid = cred.cr_gid;
+  if (pid != NULL)
+    *pid = (pid_t)-1;
   return 0;
 #elif defined(HAVE_GETPEERUCRED)
-  ucred_t *cred=NULL;
-  if (getpeerucred(sock,&cred))
+  ucred_t *cred = NULL;
+  if (getpeerucred(sock, &cred))
     return -1;
   /* save the data */
-  if (uid!=NULL) *uid=ucred_geteuid(cred);
-  if (gid!=NULL) *gid=ucred_getegid(cred);
-  if (pid!=NULL) *pid=ucred_getpid(cred);
+  if (uid != NULL)
+    *uid = ucred_geteuid(cred);
+  if (gid != NULL)
+    *gid = ucred_getegid(cred);
+  if (pid != NULL)
+    *pid = ucred_getpid(cred);
   /* free cred and return */
   ucred_free(cred);
   return 0;
 #elif defined(HAVE_GETPEEREID)
   uid_t tuid;
   gid_t tgid;
-  if (uid==NULL) uid=&tuid;
-  if (gid==NULL) gid=&tguid;
-  if (getpeereid(sock,uid,gid))
+  if (uid == NULL)
+    uid = &tuid;
+  if (gid == NULL)
+    gid = &tguid;
+  if (getpeereid(sock, uid, gid))
     return -1;
   /* return the data */
-  if (uid!=NULL) *uid=cred.uid;
-  if (gid!=NULL) *gid=cred.gid;
-  if (pid!=NULL) *pid=-1; /* we return a -1 pid because we have no usable pid 
*/
+  if (uid != NULL)
+    *uid = cred.uid;
+  if (gid != NULL)
+    *gid = cred.gid;
+  if (pid != NULL)
+    *pid = -1; /* we return a -1 pid because we have no usable pid */
   return 0;
 #else
   /* nothing found that is supported */
-  errno=ENOSYS;
+  errno = ENOSYS;
   return -1;
 #endif
 }

Modified: nss-pam-ldapd/compat/getpeercred.h
==============================================================================
--- nss-pam-ldapd/compat/getpeercred.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/getpeercred.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -3,7 +3,7 @@
                    other end of a unix socket
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008 Arthur de Jong
+   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,6 @@
    that information.
    On success, zero is returned.  On error, -1 is returned, and errno
    is set appropriately. */
-int getpeercred(int sock,uid_t *uid,gid_t *gid,pid_t *pid);
+int getpeercred(int sock, uid_t *uid, gid_t *gid, pid_t *pid);
 
 #endif /* not COMPAT__GETPEERCRED_H */

Modified: nss-pam-ldapd/compat/ldap_compat.h
==============================================================================
--- nss-pam-ldapd/compat/ldap_compat.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/ldap_compat.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    ldap_compat.h - provide a replacement definitions for some ldap functions
 
-   Copyright (C) 2009, 2010 Arthur de Jong
+   Copyright (C) 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -36,25 +36,25 @@
 #ifndef HAVE_LDAP_INITIALIZE
 /* provide a wrapper around ldap_init() if the system doesn't have
    ldap_initialize() */
-int ldap_initialize(LDAP **ldp,const char *url);
+int ldap_initialize(LDAP **ldp, const char *url);
 #endif /* not HAVE_LDAP_INITIALIZE */
 
 #ifndef HAVE_LDAP_CREATE_PAGE_CONTROL
-int ldap_create_page_control(LDAP *ld,unsigned long pagesize,
-                             struct berval *cookiep,int iscritical,
+int ldap_create_page_control(LDAP *ld, unsigned long pagesize,
+                             struct berval *cookiep, int iscritical,
                              LDAPControl **ctrlp);
 #endif /* not HAVE_LDAP_CREATE_PAGE_CONTROL */
 
 #ifndef HAVE_LDAP_PARSE_PAGE_CONTROL
-int ldap_parse_page_control(LDAP *ld,LDAPControl **ctrls,
+int ldap_parse_page_control(LDAP *ld, LDAPControl **ctrls,
                             unsigned long *list_countp,
                             struct berval **cookiep);
 #endif /* not HAVE_LDAP_PARSE_PAGE_CONTROL */
 
 #ifndef HAVE_LDAP_PASSWD_S
-int ldap_passwd_s(LDAP *ld,struct berval *user,struct berval *oldpw,
-                  struct berval *newpw,struct berval *newpasswd,
-                  LDAPControl **sctrls,LDAPControl **cctrls);
+int ldap_passwd_s(LDAP *ld, struct berval *user, struct berval *oldpw,
+                  struct berval *newpw, struct berval *newpasswd,
+                  LDAPControl **sctrls, LDAPControl **cctrls);
 #endif /* not HAVE_LDAP_PASSWD_S */
 
 /* compatibility definition */

Modified: nss-pam-ldapd/compat/ldap_initialize.c
==============================================================================
--- nss-pam-ldapd/compat/ldap_initialize.c      Fri Dec 21 22:00:30 2012        
(r1872)
+++ nss-pam-ldapd/compat/ldap_initialize.c      Sat Dec 22 22:38:26 2012        
(r1873)
@@ -1,7 +1,7 @@
 /*
    ldap_initialize.c - replacement function for ldap_initialize()
 
-   Copyright (C) 2009 Arthur de Jong
+   Copyright (C) 2009, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -36,29 +36,29 @@
 
 /* provide a wrapper around ldap_init() if the system doesn't have
    ldap_initialize() */
-int ldap_initialize(LDAP **ldp,const char *url)
+int ldap_initialize(LDAP **ldp, const char *url)
 {
   char host[80];
   /* check schema part */
-  if (strncasecmp(url,"ldap://",7)==0)
+  if (strncasecmp(url, "ldap://";, 7) == 0)
   {
-    strncpy(host,url+7,sizeof(host));
-    host[sizeof(host)-1]='\0';
+    strncpy(host, url + 7, sizeof(host));
+    host[sizeof(host) - 1] = '\0';
   }
-  else if (strncasecmp(url,"ldaps://",8)==0)
+  else if (strncasecmp(url, "ldaps://", 8) == 0)
   {
-    strncpy(host,url+8,sizeof(host));
-    host[sizeof(host)-1]='\0';
+    strncpy(host, url + 8, sizeof(host));
+    host[sizeof(host) - 1] = '\0';
   }
   else
   {
-    log_log(LOG_ERR,"ldap_initialize(): schema not supported: %s",url);
+    log_log(LOG_ERR, "ldap_initialize(): schema not supported: %s", url);
     exit(EXIT_FAILURE);
   }
   /* strip trailing slash */
-  if ((strlen(host)>0)&&(host[strlen(host)-1]=='/'))
-    host[strlen(host)-1]='\0';
+  if ((strlen(host) > 0) && (host[strlen(host) - 1] == '/'))
+    host[strlen(host) - 1] = '\0';
   /* call ldap_init() */
-  *ldp=ldap_init(host,LDAP_PORT);
-  return (*ldp==NULL)?LDAP_OPERATIONS_ERROR:LDAP_SUCCESS;
+  *ldp = ldap_init(host, LDAP_PORT);
+  return (*ldp == NULL) ? LDAP_OPERATIONS_ERROR : LDAP_SUCCESS;
 }

Modified: nss-pam-ldapd/compat/ldap_passwd_s.c
==============================================================================
--- nss-pam-ldapd/compat/ldap_passwd_s.c        Fri Dec 21 22:00:30 2012        
(r1872)
+++ nss-pam-ldapd/compat/ldap_passwd_s.c        Sat Dec 22 22:38:26 2012        
(r1873)
@@ -4,7 +4,7 @@
    (taken from _update_authtok() in pam_ldap.c).
 
    Copyright (C) 1998-2004 Luke Howard
-   Copyright (C) 2009, 2010 Arthur de Jong
+   Copyright (C) 2009, 2010, 20120 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -39,9 +39,9 @@
 #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW
 #else /* not LDAP_EXOP_X_MODIFY_PASSWD */
 #define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1"
-#define LDAP_TAG_EXOP_MODIFY_PASSWD_ID ((ber_tag_t) 0x80U)
-#define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U)
-#define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U)
+#define LDAP_TAG_EXOP_MODIFY_PASSWD_ID ((ber_tag_t)0x80U)
+#define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t)0x81U)
+#define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t)0x82U)
 #endif /* not LDAP_EXOP_X_MODIFY_PASSWD */
 #endif /* not LDAP_EXOP_MODIFY_PASSWD */
 
@@ -56,18 +56,18 @@
 #if !HAVE_DECL_LDAP_EXTENDED_OPERATION_S
 /* we define this ourselves here because some LDAP header versions don't
    seem to define this */
-extern int ldap_extended_operation_s(LDAP *ld,LDAP_CONST char *reqoid,
-    struct berval *reqdata,LDAPControl **serverctrls,LDAPControl **clientctrls,
-    char **retoidp,struct berval **retdatap);
+extern int ldap_extended_operation_s(LDAP *ld, LDAP_CONST char *reqoid,
+      struct berval *reqdata, LDAPControl **serverctrls,
+      LDAPControl **clientctrls, char **retoidp, struct berval **retdatap);
 #endif /* not HAVE_DECL_LDAP_EXTENDED_OPERATION_S */
 
 /* Replacement for password modification. user is the DN of the entry to
    change, oldpw is the old password (may not always be needed?), newpw is
    the new password to set and newpasswd is sometimes returned (though not
-   by us). See RFC 3062 for details.*/
-int ldap_passwd_s(LDAP *ld,struct berval *user,struct berval *oldpw,
-                  struct berval *newpw,struct berval UNUSED(*newpasswd),
-                  LDAPControl **sctrls,LDAPControl **cctrls)
+   by us). See RFC 3062 for details. */
+int ldap_passwd_s(LDAP *ld, struct berval *user, struct berval *oldpw,
+                  struct berval *newpw, struct berval UNUSED(*newpasswd),
+                  LDAPControl **sctrls, LDAPControl **cctrls)
 {
 #ifndef HAVE_LDAP_EXTENDED_OPERATION_S
   return LDAP_OPERATIONS_ERROR;
@@ -78,25 +78,25 @@
   char *retoid;
   struct berval *retdata;
   /* set up request data */
-  ber=ber_alloc_t(LBER_USE_DER);
-  if (ber==NULL)
+  ber = ber_alloc_t(LBER_USE_DER);
+  if (ber == NULL)
     return LDAP_NO_MEMORY;
-  ber_printf(ber,"{");
-  ber_printf(ber,"tO",LDAP_TAG_EXOP_MODIFY_PASSWD_ID,user);
-  if (oldpw!=NULL)
-    ber_printf(ber,"tO",LDAP_TAG_EXOP_MODIFY_PASSWD_OLD,oldpw);
-  ber_printf(ber,"tO",LDAP_TAG_EXOP_MODIFY_PASSWD_NEW,newpw);
-  ber_printf(ber,"N}");
-  rc=ber_flatten(ber,&bv);
-  ber_free(ber,1);
-  if (rc<0)
+  ber_printf(ber, "{");
+  ber_printf(ber, "tO", LDAP_TAG_EXOP_MODIFY_PASSWD_ID, user);
+  if (oldpw != NULL)
+    ber_printf(ber, "tO", LDAP_TAG_EXOP_MODIFY_PASSWD_OLD, oldpw);
+  ber_printf(ber, "tO", LDAP_TAG_EXOP_MODIFY_PASSWD_NEW, newpw);
+  ber_printf(ber, "N}");
+  rc = ber_flatten(ber, &bv);
+  ber_free(ber, 1);
+  if (rc < 0)
     return LDAP_NO_MEMORY;
   /* perform the operation */
-  rc=ldap_extended_operation_s(ld,LDAP_EXOP_MODIFY_PASSWD,bv,sctrls,cctrls,
-                               &retoid,&retdata);
+  rc = ldap_extended_operation_s(ld, LDAP_EXOP_MODIFY_PASSWD, bv, sctrls,
+                                 cctrls, &retoid, &retdata);
   /* free data */
   ber_bvfree(bv);
-  if (rc==LDAP_SUCCESS)
+  if (rc == LDAP_SUCCESS)
   {
     ber_bvfree(retdata);
     ber_memfree(retoid);

Modified: nss-pam-ldapd/compat/nss_compat.h
==============================================================================
--- nss-pam-ldapd/compat/nss_compat.h   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/nss_compat.h   Sat Dec 22 22:38:26 2012        (r1873)
@@ -81,8 +81,7 @@
 
 /* Define an aliasent if it was not found on the system. */
 #ifndef HAVE_STRUCT_ALIASENT
-struct aliasent
-{
+struct aliasent {
   char *alias_name;
   size_t alias_members_len;
   char **alias_members;
@@ -92,8 +91,7 @@
 
 /* Define an rpcent if it was not found on the system */
 #ifndef HAVE_STRUCT_RPCENT
-struct rpcent
-{
+struct rpcent {
   char *r_name;
   char **r_aliases;
   int r_number;
@@ -105,8 +103,7 @@
    by glibc. This is taken from include/netinet/ether.h
    of the glibc (2.3.6) source tarball. */
 #ifndef HAVE_STRUCT_ETHERENT
-struct etherent
-{
+struct etherent {
   const char *e_name;
   struct ether_addr e_addr;
 };
@@ -118,13 +115,10 @@
    The first part of the struct is the only part that is modified
    by our getnetgrent() function, all the other fields are not
    touched at all. */
-struct __netgrent
-{
+struct __netgrent {
   enum { triple_val, group_val } type;
-  union
-  {
-    struct
-    {
+  union {
+    struct {
       const char *host;
       const char *user;
       const char *domain;
@@ -137,8 +131,7 @@
      by our caller */
   char *data;
   size_t data_size;
-  union
-  {
+  union {
     char *cursor;
     unsigned long int position;
   } insertedname; /* added name to union to avoid warning */

Modified: nss-pam-ldapd/compat/pam_compat.h
==============================================================================
--- nss-pam-ldapd/compat/pam_compat.h   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/pam_compat.h   Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    pam_compat.h - provide a replacement definitions for some pam functions
 
-   Copyright (C) 2009, 2010 Arthur de Jong
+   Copyright (C) 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -48,32 +48,35 @@
 
 /* define our own replacement pam_get_authtok() if it wasn't found */
 #ifndef HAVE_PAM_GET_AUTHTOK
-int pam_get_authtok(pam_handle_t *pamh,int item,const char **authtok,const 
char *prompt);
+int pam_get_authtok(pam_handle_t *pamh, int item, const char **authtok,
+                    const char *prompt);
 #endif /* not HAVE_PAM_GET_AUTHTOK */
 
 /* replace pam_prompt() if needed */
 #ifndef HAVE_PAM_PROMPT
-int pam_prompt(pam_handle_t *pamh,int style,char **response,const char 
*format,...)
-  LIKE_PRINTF(4,5);
+int pam_prompt(pam_handle_t *pamh, int style, char **response,
+               const char *format, ...)
+  LIKE_PRINTF(4, 5);
 #endif /* not HAVE_PAM_PROMPT */
 
 /* provide pam_info() if needed */
 #ifndef pam_info
-#define pam_info(pamh,format...) \
-            pam_prompt(pamh,PAM_TEXT_INFO,NULL,##format)
+#define pam_info(pamh, format...)                                           \
+  pam_prompt(pamh, PAM_TEXT_INFO, NULL, ##format)
 #endif /* not pam_info */
 
 /* provide pam_error() if needed */
 #ifndef pam_error
-#define pam_error(pamh,format...) \
-            pam_prompt(pamh,PAM_ERROR_MSG,NULL,##format)
+#define pam_error(pamh, format...)                                          \
+  pam_prompt(pamh, PAM_ERROR_MSG, NULL, ##format)
 #endif /* not pam_error */
 
 /* fall back to using getpwnam() if pam_modutil_getpwnam() isn't defined */
 #ifndef HAVE_PAM_MODUTIL_GETGWNAM
 #include <sys/types.h>
 #include <pwd.h>
-#define pam_modutil_getpwnam(pamh,user) getpwnam(user)
+#define pam_modutil_getpwnam(pamh, user)                                    \
+  getpwnam(user)
 #endif /* not HAVE_PAM_MODUTIL_GETGWNAM */
 
 /* fall back to using syslog() if pam_syslog() doesn't exist */
@@ -81,8 +84,8 @@
 #ifndef LOG_AUTHPRIV
 #define LOG_AUTHPRIV LOG_AUTH
 #endif /* not LOG_AUTHPRIV */
-#define pam_syslog(pamh,priority,format...) \
-    syslog(LOG_AUTHPRIV|(priority),##format)
+#define pam_syslog(pamh, priority, format...)                               \
+    syslog(LOG_AUTHPRIV|(priority), ##format)
 #endif /* not HAVE_PAM_SYSLOG */
 
 #endif /* _COMPAT_LDAP_COMPAT_H */

Modified: nss-pam-ldapd/compat/pam_get_authtok.c
==============================================================================
--- nss-pam-ldapd/compat/pam_get_authtok.c      Fri Dec 21 22:00:30 2012        
(r1872)
+++ nss-pam-ldapd/compat/pam_get_authtok.c      Sat Dec 22 22:38:26 2012        
(r1873)
@@ -1,7 +1,7 @@
 /*
    pam_get_authtok.c - replacement function for pam_get_authtok()
 
-   Copyright (C) 2009, 2010 Arthur de Jong
+   Copyright (C) 2009, 2010, 2012 Arthur de Jong
    Copyright (C) 2010 Symas Corporation
 
    This library is free software; you can redistribute it and/or
@@ -35,58 +35,60 @@
 
 /* warning: this version assumes that try_first_pass is specified */
 
-int pam_get_authtok(pam_handle_t *pamh,int item,const char **authtok,const 
char *prompt)
+int pam_get_authtok(pam_handle_t *pamh, int item, const char **authtok,
+                    const char *prompt)
 {
   int rc;
-  char *passwd=NULL,*retype_passwd=NULL;
+  char *passwd = NULL, *retype_passwd = NULL;
   const void *oldauthtok;
   char retype_prompt[80];
   /* first try to see if the value is already on the stack */
-  *authtok=NULL;
-  rc=pam_get_item(pamh,item,(const void **)authtok);
-  if ((rc==PAM_SUCCESS)&&(*authtok!=NULL))
+  *authtok = NULL;
+  rc = pam_get_item(pamh, item, (const void **)authtok);
+  if ((rc == PAM_SUCCESS) && (*authtok != NULL))
     return PAM_SUCCESS;
   /* check what to prompt for and provide default prompt */
-  *retype_prompt='\0';
-  if (item==PAM_OLDAUTHTOK)
-    prompt=(prompt!=NULL)?prompt:"Old Password: ";
+  *retype_prompt = '\0';
+  if (item == PAM_OLDAUTHTOK)
+    prompt = (prompt != NULL) ? prompt : "Old Password: ";
   else
   {
-    rc=pam_get_item(pamh,PAM_OLDAUTHTOK,(const void **)&oldauthtok);
-    if ((rc==PAM_SUCCESS)&&(oldauthtok!=NULL))
+    rc = pam_get_item(pamh, PAM_OLDAUTHTOK, (const void **)&oldauthtok);
+    if ((rc == PAM_SUCCESS) && (oldauthtok != NULL))
     {
-      prompt=(prompt!=NULL)?prompt:"New Password: ";
-      snprintf(retype_prompt,sizeof(retype_prompt),"Retype %s",prompt);
-      retype_prompt[sizeof(retype_prompt)-1]='\0';
+      prompt = (prompt != NULL) ? prompt : "New Password: ";
+      snprintf(retype_prompt, sizeof(retype_prompt), "Retype %s", prompt);
+      retype_prompt[sizeof(retype_prompt) - 1] = '\0';
     }
     else
-      prompt=(prompt!=NULL)?prompt:"Password: ";
+      prompt = (prompt != NULL) ? prompt : "Password: ";
   }
   /* prepare prompt and get password */
-  rc=pam_prompt(pamh,PAM_PROMPT_ECHO_OFF,&passwd,"%s",prompt);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &passwd, "%s", prompt);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* if a second prompt should be presented, do it */
   if (*retype_prompt)
   {
-    rc=pam_prompt(pamh,PAM_PROMPT_ECHO_OFF,&retype_passwd,"%s",retype_prompt);
+    rc = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &retype_passwd, "%s",
+                    retype_prompt);
     /* check passwords */
-    if ((rc==PAM_SUCCESS)&&(strcmp(retype_passwd,passwd)!=0))
-      rc=PAM_AUTHTOK_RECOVERY_ERR;
+    if ((rc == PAM_SUCCESS) && (strcmp(retype_passwd, passwd) != 0))
+      rc = PAM_AUTHTOK_RECOVERY_ERR;
   }
   /* store the password if everything went ok */
-  if (rc==PAM_SUCCESS)
-    rc=pam_set_item(pamh,item,passwd);
+  if (rc == PAM_SUCCESS)
+    rc = pam_set_item(pamh, item, passwd);
   /* clear and free any password information */
-  memset(passwd,0,strlen(passwd));
+  memset(passwd, 0, strlen(passwd));
   free(passwd);
-  if (retype_passwd!=NULL)
+  if (retype_passwd != NULL)
   {
-    memset(retype_passwd,0,strlen(retype_passwd));
+    memset(retype_passwd, 0, strlen(retype_passwd));
     free(retype_passwd);
   }
-  if (rc!=PAM_SUCCESS)
+  if (rc != PAM_SUCCESS)
     return rc;
   /* return token from the stack */
-  return pam_get_item(pamh,item,(const void **)authtok);
+  return pam_get_item(pamh, item, (const void **)authtok);
 }

Modified: nss-pam-ldapd/compat/pam_prompt.c
==============================================================================
--- nss-pam-ldapd/compat/pam_prompt.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/pam_prompt.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    pam_prompt.c - replacement function for pam_prompt()
 
-   Copyright (C) 2010 Arthur de Jong
+   Copyright (C) 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,8 @@
 #include "compat/attrs.h"
 #include "compat/pam_compat.h"
 
-int pam_prompt(pam_handle_t *pamh,int style,char **response,const char 
*format,...)
+int pam_prompt(pam_handle_t *pamh, int style, char **response,
+               const char *format, ...)
 {
   int rc;
   struct pam_conv *aconv;
@@ -37,33 +38,33 @@
   struct pam_message msg, *pmsg;
   struct pam_response *resp;
   /* the the conversion function */
-  rc=pam_get_item(pamh,PAM_CONV,(const void **)&aconv);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_item(pamh, PAM_CONV, (const void **)&aconv);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* make the message string */
-  va_start(ap,format);
-  vsnprintf(buffer,sizeof(buffer),format,ap);
-  buffer[sizeof(buffer)-1]='\0';
+  va_start(ap, format);
+  vsnprintf(buffer, sizeof(buffer), format, ap);
+  buffer[sizeof(buffer) - 1] = '\0';
   va_end(ap);
   /* build the message */
-  msg.msg_style=style;
-  msg.msg=buffer;
-  pmsg=&msg;
-  resp=NULL;
-  rc=aconv->conv(1,(const struct pam_message 
**)&pmsg,&resp,aconv->appdata_ptr);
-  if (rc!=PAM_SUCCESS)
+  msg.msg_style = style;
+  msg.msg = buffer;
+  pmsg = &msg;
+  resp = NULL;
+  rc = aconv->conv(1, (const struct pam_message **)&pmsg, &resp, 
aconv->appdata_ptr);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* assign response if it is set */
-  if (response!=NULL)
+  if (response != NULL)
   {
-    if (resp==NULL)
+    if (resp == NULL)
       return PAM_CONV_ERR;
-    if (resp[0].resp==NULL)
+    if (resp[0].resp == NULL)
     {
       free(resp);
       return PAM_CONV_ERR;
     }
-    *response=resp[0].resp;
+    *response = resp[0].resp;
   }
   else
     free(resp[0].resp);

Modified: nss-pam-ldapd/compat/socket.h
==============================================================================
--- nss-pam-ldapd/compat/socket.h       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/socket.h       Sat Dec 22 22:38:26 2012        (r1873)
@@ -28,7 +28,7 @@
 
 /* provide a definition for SUN_LEN for systems without it */
 #ifndef SUN_LEN
-#define SUN_LEN(addr) (sizeof((addr)->sun_family)+strlen((addr)->sun_path)+1)
+#define SUN_LEN(addr) (sizeof((addr)->sun_family) + strlen((addr)->sun_path) + 
1)
 #endif /* not SUN_LEN */
 
 #endif /* not COMPAT__SOCKET_H */

Modified: nss-pam-ldapd/compat/strndup.c
==============================================================================
--- nss-pam-ldapd/compat/strndup.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/strndup.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    strndup.c - implementation of strndup() for systems that lack it
 
-   Copyright (C) 2011 Arthur de Jong
+   Copyright (C) 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -28,14 +28,14 @@
 
 /* this is a strndup() replacement for systems that don't have it
    (strndup() is in POSIX 2008 now) */
-char *strndup(const char *s,size_t size)
+char *strndup(const char *s, size_t size)
 {
   char *result;
-  result=(char *)malloc(size+1);
-  if (result!=NULL)
+  result = (char *)malloc(size + 1);
+  if (result != NULL)
   {
-    strncpy(result,s,size);
-    result[size]='\0';
+    strncpy(result, s, size);
+    result[size] = '\0';
   }
   return result;
 }

Modified: nss-pam-ldapd/compat/strndup.h
==============================================================================
--- nss-pam-ldapd/compat/strndup.h      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/compat/strndup.h      Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    strndup.h - definition of strndup() for systems that lack it
 
-   Copyright (C) 2011 Arthur de Jong
+   Copyright (C) 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,7 @@
 
 /* this is a strndup() replacement for systems that don't have it
    (strndup() is in POSIX 2008 now) */
-char *strndup(const char *s,size_t size);
+char *strndup(const char *s, size_t size);
 
 #endif /* not HAVE_STRNDUP */
 

Modified: nss-pam-ldapd/configure.ac
==============================================================================
--- nss-pam-ldapd/configure.ac  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/configure.ac  Sat Dec 22 22:38:26 2012        (r1873)
@@ -176,7 +176,7 @@
 AC_MSG_RESULT($configfile_checking)
 if test "x$configfile_checking" = "xyes"
 then
-  AC_DEFINE(ENABLE_CONFIGFILE_CHECKING,1,[Whether to check configfile 
options.])
+  AC_DEFINE(ENABLE_CONFIGFILE_CHECKING, 1 ,[Whether to check configfile 
options.])
 fi
 
 # check the name of the configuration file
@@ -185,7 +185,7 @@
                            [path to nslcd configuration file 
@<:@/etc/nslcd.conf@:>@]),
             [ NSLCD_CONF_PATH="$with_ldap_conf_file" ],
             [ NSLCD_CONF_PATH="/etc/nslcd.conf" ])
-AC_DEFINE_UNQUOTED(NSLCD_CONF_PATH,"$NSLCD_CONF_PATH",[Path to nslcd 
configuration file.])
+AC_DEFINE_UNQUOTED(NSLCD_CONF_PATH, "$NSLCD_CONF_PATH", [Path to nslcd 
configuration file.])
 AC_SUBST(NSLCD_CONF_PATH)
 
 # check the name of the file with a bindpw value
@@ -193,7 +193,7 @@
             AS_HELP_STRING([--with-bindpw-file=PATH],
                            [path to file with value for bindpw 
@<:@disabled@:>@]),
             [ NSLCD_BINDPW_PATH="$with_bindpw_file"
-              AC_DEFINE_UNQUOTED(NSLCD_BINDPW_PATH,"$NSLCD_BINDPW_PATH",[Path 
to bindpw value.])
+              AC_DEFINE_UNQUOTED(NSLCD_BINDPW_PATH, "$NSLCD_BINDPW_PATH", 
[Path to bindpw value.])
               AC_SUBST(NSLCD_BINDPW_PATH)
             ])
 
@@ -203,7 +203,7 @@
                            [path to pidfile @<:@/var/run/nslcd/nslcd.pid@:>@]),
             [ NSLCD_PIDFILE="$with_nslcd_pidfile" ],
             [ NSLCD_PIDFILE="/var/run/nslcd/nslcd.pid" ])
-AC_DEFINE_UNQUOTED(NSLCD_PIDFILE,"$NSLCD_PIDFILE",[The location of the pidfile 
used for checking availability of the nslcd.])
+AC_DEFINE_UNQUOTED(NSLCD_PIDFILE, "$NSLCD_PIDFILE", [The location of the 
pidfile used for checking availability of the nslcd.])
 AC_SUBST(NSLCD_PIDFILE)
 
 # where is the socket used for communication
@@ -212,7 +212,7 @@
                            [path to socket @<:@/var/run/nslcd/socket@:>@]),
             [ NSLCD_SOCKET="$with_nslcd_socket" ],
             [ NSLCD_SOCKET="/var/run/nslcd/socket" ])
-AC_DEFINE_UNQUOTED(NSLCD_SOCKET,"$NSLCD_SOCKET",[The location of the socket 
used for communicating.])
+AC_DEFINE_UNQUOTED(NSLCD_SOCKET, "$NSLCD_SOCKET", [The location of the socket 
used for communicating.])
 AC_SUBST(NSLCD_SOCKET)
 
 # the directory PAM librabries are expected to be placed into
@@ -221,7 +221,7 @@
                            [path to PAM security library 
@<:@/lib/security@:>@]),
             [ PAM_SECLIB_DIR="$with_pam_seclib_dir" ],
             [ PAM_SECLIB_DIR="/lib/security" ])
-AC_DEFINE_UNQUOTED(PAM_SECLIB_DIR,"$PAM_SECLIB_DIR",[path to PAM security 
library])
+AC_DEFINE_UNQUOTED(PAM_SECLIB_DIR, "$PAM_SECLIB_DIR", [path to PAM security 
library])
 AC_SUBST(PAM_SECLIB_DIR)
 
 # the SONAME to use for the NSS module
@@ -240,7 +240,7 @@
   esac
 fi
 AC_MSG_RESULT($NSS_LDAP_SONAME)
-AC_DEFINE_UNQUOTED(NSS_LDAP_SONAME,"$NSS_LDAP_SONAME",[The SONAME of the NSS 
library module.])
+AC_DEFINE_UNQUOTED(NSS_LDAP_SONAME, "$NSS_LDAP_SONAME", [The SONAME of the NSS 
library module.])
 AC_SUBST(NSS_LDAP_SONAME)
 
 # the SONAME to use for the PAM module
@@ -263,8 +263,8 @@
 # check which modules should be build
 AC_ARG_WITH(nss-maps,
             AS_HELP_STRING([--with-nss-maps=MAP LIST],
-                           [comma separated list of NSS maps to build 
@<:@all@:>@]),
-            ,[ with_nss_maps="all" ])
+                           [comma separated list of NSS maps to build 
@<:@all@:>@]),,
+            [ with_nss_maps="all" ])
 
 # checks for availability of header files
 AC_CHECK_HEADERS([ctype.h strings.h pthread.h pthread_np.h fcntl.h limits.h])
@@ -280,7 +280,7 @@
 
 # checks for availability of common functions
 AC_CHECK_FUNCS([sigaction snprintf])
-AC_SEARCH_LIBS(socket,socket)
+AC_SEARCH_LIBS(socket, socket)
 AC_CHECK_FUNCS([strcasecmp strncasecmp strchr strcspn strspn strtol strtoul 
strtoull])
 AC_CHECK_FUNCS([malloc realloc])
 AC_FUNC_FORK
@@ -309,11 +309,11 @@
 if test $mn_cv_c___thread_supported != yes
 then
   AC_MSG_WARN([$CC does not support '__thread' keyword])
-  AC_DEFINE(__thread,,[Define to empty if compiler does not support `__thread' 
keyword.])
+  AC_DEFINE(__thread,, [Define to empty if compiler does not support 
`__thread' keyword.])
 fi
 
 # check for support for the struct ether_addr structure
-AC_CHECK_TYPES(struct ether_addr,,,[
+AC_CHECK_TYPES(struct ether_addr,,, [
     #include <sys/types.h>
     #include <sys/socket.h>
     #include <net/if.h>
@@ -325,7 +325,7 @@
 
 # check for ether_aton and ether_ntoa functions
 AC_CHECK_FUNCS(ether_aton ether_ntoa ether_aton_r ether_ntoa_r)
-AC_CHECK_DECLS([ether_aton,ether_ntoa],,,[
+AC_CHECK_DECLS([ether_aton, ether_ntoa],,, [
     #include <sys/types.h>
     #include <sys/socket.h>
     #include <net/if.h>
@@ -337,7 +337,7 @@
 
 # check to see if socklen_t is defined
 AC_CHECK_TYPE(socklen_t,,
-    AC_DEFINE(socklen_t,size_t,[Define to `size_t' if not defined elswhere.]),[
+    AC_DEFINE(socklen_t, size_t, [Define to `size_t' if not defined 
elswhere.]), [
     #include <sys/types.h>
     #include <sys/socket.h>])
 
@@ -349,13 +349,13 @@
   nss_save_LIBS="$LIBS"
 
   # check for a definition of struct aliasent
-  AC_CHECK_TYPES(struct aliasent,,,[
+  AC_CHECK_TYPES(struct aliasent,,, [
       #ifdef HAVE_ALIASES_H
       #include <aliases.h>
       #endif])
 
   # check for a definition of struct etherent
-  AC_CHECK_TYPES(struct etherent,,,[
+  AC_CHECK_TYPES(struct etherent,,, [
     #include <sys/socket.h>
     #include <net/if.h>
     #include <netinet/in.h>
@@ -365,18 +365,18 @@
     #endif])
 
   # check if struct passwd has a pw_class member
-  AC_CHECK_MEMBERS([struct passwd.pw_class],,,[
+  AC_CHECK_MEMBERS([struct passwd.pw_class],,, [
       #include <pwd.h>])
 
   # check for a definition of struct rpcent
-  AC_CHECK_TYPES(struct rpcent,,,[
+  AC_CHECK_TYPES(struct rpcent,,, [
       #include <netdb.h>
       #ifdef HAVE_RPC_RPCENT_H
       #include <rpc/rpcent.h>
       #endif])
 
   # check for a definition of struct spwd
-  AC_CHECK_TYPES(struct spwd,,,[
+  AC_CHECK_TYPES(struct spwd,,, [
       #ifdef HAVE_NSS_H
       #include <nss.h>
       #endif
@@ -389,7 +389,7 @@
       #endif])
 
   # check for a definition of enum nss_status and nss_backend_t
-  AC_CHECK_TYPES([enum nss_status,nss_backend_t],,,[
+  AC_CHECK_TYPES([enum nss_status, nss_backend_t],,, [
       #ifdef HAVE_NSS_H
       #include <nss.h>
       #endif
@@ -407,7 +407,7 @@
       #endif])
 
   # check if struct nss_XbyY_args has a returnlen attribute
-  AC_CHECK_MEMBERS([struct nss_XbyY_args.returnlen],,,[[
+  AC_CHECK_MEMBERS([struct nss_XbyY_args.returnlen],,, [[
       #ifdef HAVE_NSS_H
       #include <nss.h>
       #endif
@@ -441,9 +441,9 @@
   fi
   AC_MSG_RESULT($with_nss_flavour)
   case "$with_nss_flavour" in
-    glibc)   AC_DEFINE(NSS_FLAVOUR_GLIBC,1,[Whether to use the Glibc NSS 
interface flavour.]) ;;
-    solaris) AC_DEFINE(NSS_FLAVOUR_SOLARIS,1,[Whether to use the Solaris NSS 
interface flavour.]) ;;
-    freebsd) AC_DEFINE(NSS_FLAVOUR_FREEBSD,1,[Whether to use the FreeBSD NSS 
interface flavour.]) ;;
+    glibc)   AC_DEFINE(NSS_FLAVOUR_GLIBC, 1, [Whether to use the Glibc NSS 
interface flavour.]) ;;
+    solaris) AC_DEFINE(NSS_FLAVOUR_SOLARIS, 1, [Whether to use the Solaris NSS 
interface flavour.]) ;;
+    freebsd) AC_DEFINE(NSS_FLAVOUR_FREEBSD, 1, [Whether to use the FreeBSD NSS 
interface flavour.]) ;;
   esac
 
   # check which module source files to use
@@ -492,7 +492,7 @@
 
   # check for headers
   AC_CHECK_HEADERS(security/pam_appl.h)
-  AC_CHECK_HEADERS(security/pam_modules.h,,,[
+  AC_CHECK_HEADERS(security/pam_modules.h,,, [
       #ifdef HAVE_SECURITY_PAM_APPL_H
       #include <security/pam_appl.h>
       #endif
@@ -509,7 +509,7 @@
   fi
 
   # find pam library
-  AC_SEARCH_LIBS(pam_get_data,pam,,AC_MSG_ERROR(no PAM library available))
+  AC_SEARCH_LIBS(pam_get_data, pam,, AC_MSG_ERROR(no PAM library available))
 
   # replace some PAM functions if they are unavailable
   AC_REPLACE_FUNCS(pam_get_authtok pam_prompt)
@@ -547,7 +547,7 @@
 
   # check header files
   AC_CHECK_HEADERS(lber.h)
-  AC_CHECK_HEADERS(ldap.h,, test "x$enable_nslcd" = "xyes" && 
AC_MSG_ERROR([could not locate <ldap.h>]),[
+  AC_CHECK_HEADERS(ldap.h,, test "x$enable_nslcd" = "xyes" && 
AC_MSG_ERROR([could not locate <ldap.h>]), [
       #if HAVE_LBER_H
       #include <lber.h>
       #endif
@@ -566,9 +566,9 @@
   AC_CHECK_HEADERS(regex.h)
 
   # checks for availability of system libraries for nslcd
-  AC_SEARCH_LIBS(gethostbyname,nsl socket)
-  AC_SEARCH_LIBS(hstrerror,resolv)
-  AC_SEARCH_LIBS(dlopen,dl)
+  AC_SEARCH_LIBS(gethostbyname, nsl socket)
+  AC_SEARCH_LIBS(hstrerror, resolv)
+  AC_SEARCH_LIBS(dlopen, dl)
 
   # check for availability of functions
   AC_CHECK_FUNCS(initgroups setgroups)
@@ -584,30 +584,30 @@
   AC_REPLACE_FUNCS(strndup)
 
   # replace daemon() function if it is not on the system
-  AC_SEARCH_LIBS(daemon,bsd)
+  AC_SEARCH_LIBS(daemon, bsd)
   AC_REPLACE_FUNCS(daemon)
-  AC_CHECK_DECLS([daemon],,,[
+  AC_CHECK_DECLS([daemon],,, [
       #include <unistd.h>
       #include <stdlib.h>])
 
   # replace ether_aton_r() and ether_ntoa_r() if they are not found
-  AC_CHECK_FUNCS(ether_aton_r ether_ntoa_r,,[AC_LIBOBJ(ether)])
+  AC_CHECK_FUNCS(ether_aton_r ether_ntoa_r,, [AC_LIBOBJ(ether)])
 
   # check to see if struct sockaddr_storage is defined
   AC_CHECK_TYPE(struct sockaddr_storage,,
-      AC_DEFINE(sockaddr_storage,sockaddr_in,[Define to `sockaddr_in' if not 
defined elsewhere.]),[
+      AC_DEFINE(sockaddr_storage, sockaddr_in, [Define to `sockaddr_in' if not 
defined elsewhere.]), [
       #include <sys/types.h>
       #include <sys/socket.h>])
 
   # check for support for the struct ucred structure
   AC_CHECK_TYPE(struct ucred,
-      AC_DEFINE(HAVE_STRUCT_UCRED,1,[Define to 1 if you have a `struct ucred' 
definition.]),,[
+      AC_DEFINE(HAVE_STRUCT_UCRED, 1, [Define to 1 if you have a `struct 
ucred' definition.]),, [
       #include <sys/socket.h>
       #include <sys/un.h>
       #include <sys/types.h>])
 
   # check threading stuff
-  AX_PTHREAD(,AC_MSG_ERROR([no support for pthreads]))
+  AX_PTHREAD(, AC_MSG_ERROR([no support for pthreads]))
   pthread_save_CFLAGS="$CFLAGS"
   pthread_save_LIBS="$LIBS"
   CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
@@ -631,7 +631,7 @@
   fi
   if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = 
umich -o $with_ldap_lib = openldap \)
   then
-    AC_SEARCH_LIBS(ldap_search_ext,[ldap_r ldap],found_ldap_lib=yes,,)
+    AC_SEARCH_LIBS(ldap_search_ext, [ldap_r ldap], found_ldap_lib=yes,, )
   fi
   if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = 
netscape5 \)
   then
@@ -646,40 +646,40 @@
     fi
     if test -z "$found_ldap_lib"
     then
-      AC_CHECK_LIB(ldap41, main, LIBS="-lldap41 $LIBS" found_ldap_lib=yes,,)
+      AC_CHECK_LIB(ldap41, main, LIBS="-lldap41 $LIBS" found_ldap_lib=yes,, )
     fi
     if test -z "$found_ldap_lib"
     then
-      AC_CHECK_LIB(ldap40, main, LIBS="-lldap40 $LIBS" found_ldap_lib=yes,,)
+      AC_CHECK_LIB(ldap40, main, LIBS="-lldap40 $LIBS" found_ldap_lib=yes,, )
     fi
   fi
   if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = 
netscape3 \)
   then
     AC_CHECK_LIB(ldapssl30, main, LIBS="-lldapssl30 $LIBS" 
found_ldap_lib=yes,, -lpthread)
   fi
-  AC_CHECK_FUNCS(ldap_search_ext,,AC_MSG_ERROR([could not locate a valid LDAP 
library]))
+  AC_CHECK_FUNCS(ldap_search_ext,, AC_MSG_ERROR([could not locate a valid LDAP 
library]))
 
   # see if we need a BER library
-  AC_SEARCH_LIBS(ber_bvfree,lber)
+  AC_SEARCH_LIBS(ber_bvfree, lber)
 
   # check for extra SASL libraries
   if test "$enable_sasl" = "yes"
   then
     AC_CHECK_TYPE(sasl_interact_t,
-        AC_DEFINE(HAVE_SASL_INTERACT_T,1,[Define to 1 if you have a 
`sasl_interact_t' definition.]),,[
+        AC_DEFINE(HAVE_SASL_INTERACT_T, 1, [Define to 1 if you have a 
`sasl_interact_t' definition.]),, [
         #ifdef HAVE_SASL_SASL_H
         #include <sasl/sasl.h>
         #elif defined(HAVE_SASL_H)
         #include <sasl.h>
         #endif])
-    AC_SEARCH_LIBS(ldap_sasl_interactive_bind_s,sasl2)
+    AC_SEARCH_LIBS(ldap_sasl_interactive_bind_s, sasl2)
     AC_CHECK_FUNCS(ldap_sasl_interactive_bind_s)
   fi
 
   # check for extra Kerberos libraries
   if test "$enable_kerberos" = "yes"
   then
-    AC_SEARCH_LIBS(gss_krb5_ccache_name,gssapi gssapi_krb5)
+    AC_SEARCH_LIBS(gss_krb5_ccache_name, gssapi gssapi_krb5)
     AC_CHECK_FUNCS(gss_krb5_ccache_name)
   fi
 
@@ -695,8 +695,8 @@
   AC_CHECK_FUNCS(ber_bvfree ber_free ber_set_option)
 
   # replace ldap_create_page_control() and ldap_parse_page_control()
-  AC_CHECK_FUNCS(ldap_create_page_control 
ldap_parse_page_control,,[AC_LIBOBJ(pagectrl)])
-  AC_CHECK_DECLS(ldap_extended_operation_s,,,[
+  AC_CHECK_FUNCS(ldap_create_page_control ldap_parse_page_control,, 
[AC_LIBOBJ(pagectrl)])
+  AC_CHECK_DECLS(ldap_extended_operation_s,,, [
       #if HAVE_LBER_H
       #include <lber.h>
       #endif
@@ -714,12 +714,12 @@
           [AC_LANG_PROGRAM([[
               #include <lber.h>
               #include <ldap.h>
-              ]],[[
-              ldap_set_rebind_proc(0,0,0);
+              ]], [[
+              ldap_set_rebind_proc(0, 0, 0);
               ]])],
           [nss_ldapd_cv_ldap_set_rebind_proc_args=3],
           [nss_ldapd_cv_ldap_set_rebind_proc_args=2]) ])
-  
AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS,$nss_ldapd_cv_ldap_set_rebind_proc_args,
+  AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, 
$nss_ldapd_cv_ldap_set_rebind_proc_args,
                      [Define to the number of arguments to 
ldap_set_rebindproc.])
 
   # check the return type of ldap_set_rebind_proc()
@@ -730,18 +730,18 @@
           [AC_LANG_PROGRAM([[
               #include <lber.h>
               #include <ldap.h>
-              ]],[[
+              ]], [[
               #if LDAP_SET_REBIND_PROC_ARGS == 3
-              return ldap_set_rebind_proc(0,0,0);
+              return ldap_set_rebind_proc(0, 0, 0);
               #else
-              return ldap_set_rebind_proc(0,0);
+              return ldap_set_rebind_proc(0, 0);
               #endif
               ]])],
           [nss_ldapd_cv_ldap_set_rebind_proc_type=int],
           [nss_ldapd_cv_ldap_set_rebind_proc_type=void]) ])
   if test "x$nss_ldapd_cv_ldap_set_rebind_proc_type" = "xvoid"
   then
-    AC_DEFINE(LDAP_SET_REBIND_PROC_RETURNS_VOID,1,
+    AC_DEFINE(LDAP_SET_REBIND_PROC_RETURNS_VOID, 1,
               [Define to 1 if ldap_set_rebind_proc() returns void.])
   fi
 

Modified: nss-pam-ldapd/nslcd/alias.c
==============================================================================
--- nss-pam-ldapd/nslcd/alias.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/alias.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -62,79 +62,77 @@
 /* create a search filter for searching an alias by name,
    return -1 on errors */
 static int mkfilter_alias_byname(const char *name,
-                                 char *buffer,size_t buflen)
+                                 char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    alias_filter,
-                    attmap_alias_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    alias_filter, attmap_alias_cn, safename);
 }
 
 void alias_init(void)
 {
   int i;
   /* set up search bases */
-  if (alias_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      alias_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (alias_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      alias_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (alias_scope==LDAP_SCOPE_DEFAULT)
-    alias_scope=nslcd_cfg->ldc_scope;
+  if (alias_scope == LDAP_SCOPE_DEFAULT)
+    alias_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  alias_attrs[0]=attmap_alias_cn;
-  alias_attrs[1]=attmap_alias_rfc822MailMember;
-  alias_attrs[2]=NULL;
+  alias_attrs[0] = attmap_alias_cn;
+  alias_attrs[1] = attmap_alias_rfc822MailMember;
+  alias_attrs[2] = NULL;
 }
 
-static int write_alias(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqalias)
+static int write_alias(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqalias)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  const char **names,**members;
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  const char **names, **members;
   int i;
   /* get the name of the alias */
-  names=myldap_get_values(entry,attmap_alias_cn);
-  if ((names==NULL)||(names[0]==NULL))
+  names = myldap_get_values(entry, attmap_alias_cn);
+  if ((names == NULL) || (names[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_alias_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_alias_cn);
     return 0;
   }
   /* get the members of the alias */
-  members=myldap_get_values(entry,attmap_alias_rfc822MailMember);
+  members = myldap_get_values(entry, attmap_alias_rfc822MailMember);
   /* for each name, write an entry */
-  for (i=0;names[i]!=NULL;i++)
+  for (i = 0; names[i] != NULL; i++)
   {
-    if ((reqalias==NULL)||(strcasecmp(reqalias,names[i])==0))
+    if ((reqalias == NULL) || (strcasecmp(reqalias, names[i]) == 0))
     {
-      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-      WRITE_STRING(fp,names[i]);
-      WRITE_STRINGLIST(fp,members);
+      WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+      WRITE_STRING(fp, names[i]);
+      WRITE_STRINGLIST(fp, members);
     }
   }
   return 0;
 }
 
 NSLCD_HANDLE(
-  alias,byname,
+  alias, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("alias=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("alias=\"%s\"", name);,
   NSLCD_ACTION_ALIAS_BYNAME,
-  mkfilter_alias_byname(name,filter,sizeof(filter)),
-  write_alias(fp,entry,name)
+  mkfilter_alias_byname(name, filter, sizeof(filter)),
+  write_alias(fp, entry, name)
 )
 
 NSLCD_HANDLE(
-  alias,all,
+  alias, all,
   const char *filter;
   log_setrequest("alias(all)");,
   NSLCD_ACTION_ALIAS_ALL,
-  (filter=alias_filter,0),
-  write_alias(fp,entry,NULL)
+  (filter = alias_filter, 0),
+  write_alias(fp, entry, NULL)
 )

Modified: nss-pam-ldapd/nslcd/attmap.c
==============================================================================
--- nss-pam-ldapd/nslcd/attmap.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/attmap.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    attmap.c - attribute mapping values and functions
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -128,168 +128,169 @@
   }
 }
 
-const char **attmap_get_var(enum ldap_map_selector map,const char *name)
+const char **attmap_get_var(enum ldap_map_selector map, const char *name)
 {
-  if (map==LM_ALIASES)
+  if (map == LM_ALIASES)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_alias_cn;
-    if (strcasecmp(name,"rfc822MailMember")==0)  return 
&attmap_alias_rfc822MailMember;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_alias_cn;
+    if (strcasecmp(name, "rfc822MailMember") == 0)  return 
&attmap_alias_rfc822MailMember;
   }
-  else if (map==LM_ETHERS)
+  else if (map == LM_ETHERS)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_ether_cn;
-    if (strcasecmp(name,"macAddress")==0)        return 
&attmap_ether_macAddress;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_ether_cn;
+    if (strcasecmp(name, "macAddress") == 0)        return 
&attmap_ether_macAddress;
   }
-  else if (map==LM_GROUP)
+  else if (map == LM_GROUP)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_group_cn;
-    if (strcasecmp(name,"userPassword")==0)      return 
&attmap_group_userPassword;
-    if (strcasecmp(name,"gidNumber")==0)         return 
&attmap_group_gidNumber;
-    if (strcasecmp(name,"memberUid")==0)         return 
&attmap_group_memberUid;
-    if (strcasecmp(name,"member")==0)            return &attmap_group_member;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_group_cn;
+    if (strcasecmp(name, "userPassword") == 0)      return 
&attmap_group_userPassword;
+    if (strcasecmp(name, "gidNumber") == 0)         return 
&attmap_group_gidNumber;
+    if (strcasecmp(name, "memberUid") == 0)         return 
&attmap_group_memberUid;
+    if (strcasecmp(name, "member") == 0)            return 
&attmap_group_member;
   }
-  else if (map==LM_HOSTS)
+  else if (map == LM_HOSTS)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_host_cn;
-    if (strcasecmp(name,"ipHostNumber")==0)      return 
&attmap_host_ipHostNumber;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_host_cn;
+    if (strcasecmp(name, "ipHostNumber") == 0)      return 
&attmap_host_ipHostNumber;
   }
-  else if (map==LM_NETGROUP)
+  else if (map == LM_NETGROUP)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_netgroup_cn;
-    if (strcasecmp(name,"nisNetgroupTriple")==0) return 
&attmap_netgroup_nisNetgroupTriple;
-    if (strcasecmp(name,"memberNisNetgroup")==0) return 
&attmap_netgroup_memberNisNetgroup;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_netgroup_cn;
+    if (strcasecmp(name, "nisNetgroupTriple") == 0) return 
&attmap_netgroup_nisNetgroupTriple;
+    if (strcasecmp(name, "memberNisNetgroup") == 0) return 
&attmap_netgroup_memberNisNetgroup;
   }
-  else if (map==LM_NETWORKS)
+  else if (map == LM_NETWORKS)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_network_cn;
-    if (strcasecmp(name,"ipNetworkNumber")==0)   return 
&attmap_network_ipNetworkNumber;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_network_cn;
+    if (strcasecmp(name, "ipNetworkNumber") == 0)   return 
&attmap_network_ipNetworkNumber;
   }
-  else if (map==LM_PASSWD)
+  else if (map == LM_PASSWD)
   {
-    if (strcasecmp(name,"uid")==0)               return &attmap_passwd_uid;
-    if (strcasecmp(name,"userPassword")==0)      return 
&attmap_passwd_userPassword;
-    if (strcasecmp(name,"uidNumber")==0)         return 
&attmap_passwd_uidNumber;
-    if (strcasecmp(name,"gidNumber")==0)         return 
&attmap_passwd_gidNumber;
-    if (strcasecmp(name,"gecos")==0)             return &attmap_passwd_gecos;
-    if (strcasecmp(name,"homeDirectory")==0)     return 
&attmap_passwd_homeDirectory;
-    if (strcasecmp(name,"loginShell")==0)        return 
&attmap_passwd_loginShell;
+    if (strcasecmp(name, "uid") == 0)               return &attmap_passwd_uid;
+    if (strcasecmp(name, "userPassword") == 0)      return 
&attmap_passwd_userPassword;
+    if (strcasecmp(name, "uidNumber") == 0)         return 
&attmap_passwd_uidNumber;
+    if (strcasecmp(name, "gidNumber") == 0)         return 
&attmap_passwd_gidNumber;
+    if (strcasecmp(name, "gecos") == 0)             return 
&attmap_passwd_gecos;
+    if (strcasecmp(name, "homeDirectory") == 0)     return 
&attmap_passwd_homeDirectory;
+    if (strcasecmp(name, "loginShell") == 0)        return 
&attmap_passwd_loginShell;
   }
-  else if (map==LM_PROTOCOLS)
+  else if (map == LM_PROTOCOLS)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_protocol_cn;
-    if (strcasecmp(name,"ipProtocolNumber")==0)  return 
&attmap_protocol_ipProtocolNumber;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_protocol_cn;
+    if (strcasecmp(name, "ipProtocolNumber") == 0)  return 
&attmap_protocol_ipProtocolNumber;
   }
-  else if (map==LM_RPC)
+  else if (map == LM_RPC)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_rpc_cn;
-    if (strcasecmp(name,"oncRpcNumber")==0)      return 
&attmap_rpc_oncRpcNumber;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_rpc_cn;
+    if (strcasecmp(name, "oncRpcNumber") == 0)      return 
&attmap_rpc_oncRpcNumber;
   }
-  else if (map==LM_SERVICES)
+  else if (map == LM_SERVICES)
   {
-    if (strcasecmp(name,"cn")==0)                return &attmap_service_cn;
-    if (strcasecmp(name,"ipServicePort")==0)     return 
&attmap_service_ipServicePort;
-    if (strcasecmp(name,"ipServiceProtocol")==0) return 
&attmap_service_ipServiceProtocol;
+    if (strcasecmp(name, "cn") == 0)                return &attmap_service_cn;
+    if (strcasecmp(name, "ipServicePort") == 0)     return 
&attmap_service_ipServicePort;
+    if (strcasecmp(name, "ipServiceProtocol") == 0) return 
&attmap_service_ipServiceProtocol;
   }
-  else if (map==LM_SHADOW)
+  else if (map == LM_SHADOW)
   {
-    if (strcasecmp(name,"uid")==0)               return &attmap_shadow_uid;
-    if (strcasecmp(name,"userPassword")==0)      return 
&attmap_shadow_userPassword;
-    if (strcasecmp(name,"shadowLastChange")==0)  return 
&attmap_shadow_shadowLastChange;
-    if (strcasecmp(name,"shadowMin")==0)         return 
&attmap_shadow_shadowMin;
-    if (strcasecmp(name,"shadowMax")==0)         return 
&attmap_shadow_shadowMax;
-    if (strcasecmp(name,"shadowWarning")==0)     return 
&attmap_shadow_shadowWarning;
-    if (strcasecmp(name,"shadowInactive")==0)    return 
&attmap_shadow_shadowInactive;
-    if (strcasecmp(name,"shadowExpire")==0)      return 
&attmap_shadow_shadowExpire;
-    if (strcasecmp(name,"shadowFlag")==0)        return 
&attmap_shadow_shadowFlag;
+    if (strcasecmp(name, "uid") == 0)               return &attmap_shadow_uid;
+    if (strcasecmp(name, "userPassword") == 0)      return 
&attmap_shadow_userPassword;
+    if (strcasecmp(name, "shadowLastChange") == 0)  return 
&attmap_shadow_shadowLastChange;
+    if (strcasecmp(name, "shadowMin") == 0)         return 
&attmap_shadow_shadowMin;
+    if (strcasecmp(name, "shadowMax") == 0)         return 
&attmap_shadow_shadowMax;
+    if (strcasecmp(name, "shadowWarning") == 0)     return 
&attmap_shadow_shadowWarning;
+    if (strcasecmp(name, "shadowInactive") == 0)    return 
&attmap_shadow_shadowInactive;
+    if (strcasecmp(name, "shadowExpire") == 0)      return 
&attmap_shadow_shadowExpire;
+    if (strcasecmp(name, "shadowFlag") == 0)        return 
&attmap_shadow_shadowFlag;
   }
   return NULL;
 }
 
-const char *attmap_set_mapping(const char **var,const char *value)
+const char *attmap_set_mapping(const char **var, const char *value)
 {
   /* check if we are setting an expression */
-  if (value[0]=='"')
+  if (value[0] == '"')
   {
     /* these attributes may contain an expression
        (note that this needs to match the functionality in the specific
        lookup module) */
-    if ( (var!=&attmap_group_userPassword) &&
-         (var!=&attmap_passwd_userPassword) &&
-         (var!=&attmap_passwd_gidNumber) &&
-         (var!=&attmap_passwd_gecos) &&
-         (var!=&attmap_passwd_homeDirectory) &&
-         (var!=&attmap_passwd_loginShell) &&
-         (var!=&attmap_shadow_userPassword) &&
-         (var!=&attmap_shadow_shadowLastChange) &&
-         (var!=&attmap_shadow_shadowMin) &&
-         (var!=&attmap_shadow_shadowMax) &&
-         (var!=&attmap_shadow_shadowWarning) &&
-         (var!=&attmap_shadow_shadowInactive) &&
-         (var!=&attmap_shadow_shadowExpire) &&
-         (var!=&attmap_shadow_shadowFlag) )
+    if ((var != &attmap_group_userPassword) &&
+        (var != &attmap_passwd_userPassword) &&
+        (var != &attmap_passwd_gidNumber) &&
+        (var != &attmap_passwd_gecos) &&
+        (var != &attmap_passwd_homeDirectory) &&
+        (var != &attmap_passwd_loginShell) &&
+        (var != &attmap_shadow_userPassword) &&
+        (var != &attmap_shadow_shadowLastChange) &&
+        (var != &attmap_shadow_shadowMin) &&
+        (var != &attmap_shadow_shadowMax) &&
+        (var != &attmap_shadow_shadowWarning) &&
+        (var != &attmap_shadow_shadowInactive) &&
+        (var != &attmap_shadow_shadowExpire) &&
+        (var != &attmap_shadow_shadowFlag))
       return NULL;
   }
   /* check if the value will be changed */
-  if ( (*var==NULL) || (strcmp(*var,value)!=0) )
-    *var=strdup(value);
+  if ((*var == NULL) || (strcmp(*var, value) != 0))
+    *var = strdup(value);
   return *var;
 }
 
-static const char *entry_expand(const char *name,void *expander_attr)
+static const char *entry_expand(const char *name, void *expander_attr)
 {
-  MYLDAP_ENTRY *entry=(MYLDAP_ENTRY *)expander_attr;
+  MYLDAP_ENTRY *entry = (MYLDAP_ENTRY *)expander_attr;
   const char **values;
-  if (strcasecmp(name,"dn")==0)
+  if (strcasecmp(name, "dn") == 0)
     return myldap_get_dn(entry);
-  values=myldap_get_values(entry,name);
-  if (values==NULL)
+  values = myldap_get_values(entry, name);
+  if (values == NULL)
     return "";
   /* TODO: handle userPassword attribute specially */
-  if ((values[0]!=NULL)&&(values[1]!=NULL))
+  if ((values[0] != NULL) && (values[1] != NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: multiple values",
-                        myldap_get_dn(entry),name);
+    log_log(LOG_WARNING, "%s: %s: multiple values",
+            myldap_get_dn(entry), name);
   }
   return values[0];
 }
 
-const char *attmap_get_value(MYLDAP_ENTRY *entry,const char *attr,char 
*buffer,size_t buflen)
+const char *attmap_get_value(MYLDAP_ENTRY *entry, const char *attr,
+                             char *buffer, size_t buflen)
 {
   const char **values;
   /* check and clear buffer */
-  if ((buffer==NULL)||(buflen<=0))
+  if ((buffer == NULL) || (buflen <= 0))
     return NULL;
-  buffer[0]='\0';
+  buffer[0] = '\0';
   /* for simple values just return the attribute */
-  if (attr[0]!='"')
+  if (attr[0] != '"')
   {
-    values=myldap_get_values(entry,attr);
-    if ((values==NULL)||(values[0]==NULL))
+    values = myldap_get_values(entry, attr);
+    if ((values == NULL) || (values[0] == NULL))
       return NULL;
-    strncpy(buffer,values[0],buflen);
-    buffer[buflen-1]='\0';
+    strncpy(buffer, values[0], buflen);
+    buffer[buflen - 1] = '\0';
     return buffer;
     /* TODO: maybe warn when multiple values are found */
   }
   /* we have an expression, try to parse */
-  if ( (attr[strlen(attr)-1]!='"') ||
-       (expr_parse(attr+1,buffer,buflen,entry_expand,(void *)entry)==NULL) )
+  if ((attr[strlen(attr) - 1] != '"') ||
+      (expr_parse(attr + 1, buffer, buflen, entry_expand, (void *)entry) == 
NULL))
   {
-    log_log(LOG_ERR,"attribute mapping %s is invalid",attr);
-    buffer[0]='\0';
+    log_log(LOG_ERR, "attribute mapping %s is invalid", attr);
+    buffer[0] = '\0';
     return NULL;
   }
   /* strip trailing " */
-  if (buffer[strlen(buffer)-1]=='"')
-    buffer[strlen(buffer)-1]='\0';
+  if (buffer[strlen(buffer) - 1] == '"')
+    buffer[strlen(buffer) - 1] = '\0';
   return buffer;
 }
 
-SET *attmap_add_attributes(SET *set,const char *attr)
+SET *attmap_add_attributes(SET *set, const char *attr)
 {
-  if (attr[0]!='\"')
-    set_add(set,attr);
+  if (attr[0] != '\"')
+    set_add(set, attr);
   else
-    expr_vars(attr,set);
+    expr_vars(attr, set);
   return set;
 }

Modified: nss-pam-ldapd/nslcd/attmap.h
==============================================================================
--- nss-pam-ldapd/nslcd/attmap.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/attmap.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    attmap.h - attribute mapping variables
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -80,19 +80,20 @@
 /* return a reference to the attribute mapping variable for the specified name
    the name is the name after the attmap_... variables above with the
    underscode replaced by a dot (e.g passwd.homeDirectory) */
-const char **attmap_get_var(enum ldap_map_selector map,const char *name);
+const char **attmap_get_var(enum ldap_map_selector map, const char *name);
 
 /* Set the attribute mapping of the variable to the value specified.
    Returns the new value on success. */
-MUST_USE const char *attmap_set_mapping(const char **var,const char *value);
+MUST_USE const char *attmap_set_mapping(const char **var, const char *value);
 
 /* Return a value for the attribute, handling the case where attr
    is an expression. On error (e.g. problem parsing expression, attribute
    value not found) it returns NULL and the buffer is made empty. */
-const char *attmap_get_value(MYLDAP_ENTRY *entry,const char *attr,char 
*buffer,size_t buflen);
+const char *attmap_get_value(MYLDAP_ENTRY *entry, const char *attr,
+                             char *buffer, size_t buflen);
 
 /* Add the attributes from attr to the set. The attr argumenent
    can either be an attribute or an attribute expression. */
-SET *attmap_add_attributes(SET *set,const char *attr);
+SET *attmap_add_attributes(SET *set, const char *attr);
 
 #endif /* not NSLCD__ATTMAP_H */

Modified: nss-pam-ldapd/nslcd/cfg.c
==============================================================================
--- nss-pam-ldapd/nslcd/cfg.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/cfg.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -59,7 +59,7 @@
 #include "attmap.h"
 #include "common/expr.h"
 
-struct ldap_config *nslcd_cfg=NULL;
+struct ldap_config *nslcd_cfg = NULL;
 
 /* the maximum line length in the configuration file */
 #define MAX_LINE_LENGTH          4096
@@ -68,210 +68,214 @@
 #define TOKEN_DELIM " \t\n\r"
 
 /* convenient wrapper macro for ldap_set_option() */
-#define LDAP_SET_OPTION(ld,option,invalue) \
-  rc=ldap_set_option(ld,option,invalue); \
-  if (rc!=LDAP_SUCCESS) \
-  { \
-    log_log(LOG_ERR,"ldap_set_option(" #option ") failed: 
%s",ldap_err2string(rc)); \
-    exit(EXIT_FAILURE); \
+#define LDAP_SET_OPTION(ld, option, invalue)                                \
+  rc = ldap_set_option(ld, option, invalue);                                \
+  if (rc != LDAP_SUCCESS)                                                   \
+  {                                                                         \
+    log_log(LOG_ERR, "ldap_set_option(" #option ") failed: %s",             \
+            ldap_err2string(rc));                                           \
+    exit(EXIT_FAILURE);                                                     \
   }
 
 /* prototype for parse_validnames_statement() because it is used in
    cfg_defaults() */
-static void parse_validnames_statement(const char *filename,int lnr,
-                   const char *keyword,char *line,struct ldap_config *cfg);
+static void parse_validnames_statement(const char *filename, int lnr,
+                                       const char *keyword, char *line,
+                                       struct ldap_config *cfg);
 
 /* set the configuration information to the defaults */
 static void cfg_defaults(struct ldap_config *cfg)
 {
   int i;
-  memset(cfg,0,sizeof(struct ldap_config));
-  cfg->ldc_threads=5;
-  cfg->ldc_uidname=NULL;
-  cfg->ldc_uid=NOUID;
-  cfg->ldc_gid=NOGID;
-  cfg->ldc_ignorecase=0;
-  for (i=0;i<(NSS_LDAP_CONFIG_URI_MAX+1);i++)
-  {
-    cfg->ldc_uris[i].uri=NULL;
-    cfg->ldc_uris[i].firstfail=0;
-    cfg->ldc_uris[i].lastfail=0;
+  memset(cfg, 0, sizeof(struct ldap_config));
+  cfg->ldc_threads = 5;
+  cfg->ldc_uidname = NULL;
+  cfg->ldc_uid = NOUID;
+  cfg->ldc_gid = NOGID;
+  cfg->ldc_ignorecase = 0;
+  for (i = 0; i < (NSS_LDAP_CONFIG_URI_MAX + 1); i++)
+  {
+    cfg->ldc_uris[i].uri = NULL;
+    cfg->ldc_uris[i].firstfail = 0;
+    cfg->ldc_uris[i].lastfail = 0;
   }
 #ifdef LDAP_VERSION3
-  cfg->ldc_version=LDAP_VERSION3;
+  cfg->ldc_version = LDAP_VERSION3;
 #else /* LDAP_VERSION3 */
-  cfg->ldc_version=LDAP_VERSION2;
+  cfg->ldc_version = LDAP_VERSION2;
 #endif /* not LDAP_VERSION3 */
-  cfg->ldc_binddn=NULL;
-  cfg->ldc_bindpw=NULL;
-  cfg->ldc_rootpwmoddn=NULL;
-  cfg->ldc_rootpwmodpw=NULL;
-  cfg->ldc_sasl_mech=NULL;
-  cfg->ldc_sasl_realm=NULL;
-  cfg->ldc_sasl_authcid=NULL;
-  cfg->ldc_sasl_authzid=NULL;
-  cfg->ldc_sasl_secprops=NULL;
+  cfg->ldc_binddn = NULL;
+  cfg->ldc_bindpw = NULL;
+  cfg->ldc_rootpwmoddn = NULL;
+  cfg->ldc_rootpwmodpw = NULL;
+  cfg->ldc_sasl_mech = NULL;
+  cfg->ldc_sasl_realm = NULL;
+  cfg->ldc_sasl_authcid = NULL;
+  cfg->ldc_sasl_authzid = NULL;
+  cfg->ldc_sasl_secprops = NULL;
 #ifdef LDAP_OPT_X_SASL_NOCANON
-  cfg->ldc_sasl_canonicalize=-1;
+  cfg->ldc_sasl_canonicalize = -1;
 #endif /* LDAP_OPT_X_SASL_NOCANON */
-  for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-    cfg->ldc_bases[i]=NULL;
-  cfg->ldc_scope=LDAP_SCOPE_SUBTREE;
-  cfg->ldc_deref=LDAP_DEREF_NEVER;
-  cfg->ldc_referrals=1;
-  cfg->ldc_bind_timelimit=10;
-  cfg->ldc_timelimit=LDAP_NO_LIMIT;
-  cfg->ldc_idle_timelimit=0;
-  cfg->ldc_reconnect_sleeptime=1;
-  cfg->ldc_reconnect_retrytime=10;
+  for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+    cfg->ldc_bases[i] = NULL;
+  cfg->ldc_scope = LDAP_SCOPE_SUBTREE;
+  cfg->ldc_deref = LDAP_DEREF_NEVER;
+  cfg->ldc_referrals = 1;
+  cfg->ldc_bind_timelimit = 10;
+  cfg->ldc_timelimit = LDAP_NO_LIMIT;
+  cfg->ldc_idle_timelimit = 0;
+  cfg->ldc_reconnect_sleeptime = 1;
+  cfg->ldc_reconnect_retrytime = 10;
 #ifdef LDAP_OPT_X_TLS
-  cfg->ldc_ssl_on=SSL_OFF;
+  cfg->ldc_ssl_on = SSL_OFF;
 #endif /* LDAP_OPT_X_TLS */
-  cfg->ldc_restart=1;
-  cfg->ldc_pagesize=0;
-  cfg->ldc_nss_initgroups_ignoreusers=NULL;
-  for (i=0;i<NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES;i++)
-    cfg->ldc_pam_authz_search[i]=NULL;
-  cfg->ldc_nss_min_uid=0;
-  parse_validnames_statement(__FILE__,__LINE__,"",
-                "/^[a-z0-9._@$][a-z0-9._@$ \\~-]*[a-z0-9._@$~-]$/i",cfg);
-  cfg->pam_password_prohibit_message=NULL;
+  cfg->ldc_restart = 1;
+  cfg->ldc_pagesize = 0;
+  cfg->ldc_nss_initgroups_ignoreusers = NULL;
+  for (i = 0; i < NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES; i++)
+    cfg->ldc_pam_authz_search[i] = NULL;
+  cfg->ldc_nss_min_uid = 0;
+  parse_validnames_statement(__FILE__, __LINE__, "",
+                             "/^[a-z0-9._@$][a-z0-9._@$ 
\\~-]*[a-z0-9._@$~-]$/i",
+                             cfg);
+  cfg->pam_password_prohibit_message = NULL;
 }
 
 /* simple strdup wrapper */
 static char *xstrdup(const char *s)
 {
   char *tmp;
-  if (s==NULL)
+  if (s == NULL)
   {
-    log_log(LOG_CRIT,"xstrdup() called with NULL");
+    log_log(LOG_CRIT, "xstrdup() called with NULL");
     exit(EXIT_FAILURE);
   }
-  tmp=strdup(s);
-  if (tmp==NULL)
+  tmp = strdup(s);
+  if (tmp == NULL)
   {
-    log_log(LOG_CRIT,"strdup() failed to allocate memory");
+    log_log(LOG_CRIT, "strdup() failed to allocate memory");
     exit(EXIT_FAILURE);
   }
   return tmp;
 }
 
 /* add a single URI to the list of URIs in the configuration */
-static void add_uri(const char *filename,int lnr,
-                    struct ldap_config *cfg,const char *uri)
+static void add_uri(const char *filename, int lnr,
+                    struct ldap_config *cfg, const char *uri)
 {
   int i;
-  log_log(LOG_DEBUG,"add_uri(%s)",uri);
+  log_log(LOG_DEBUG, "add_uri(%s)", uri);
   /* find the place where to insert the URI */
-  for (i=0;cfg->ldc_uris[i].uri!=NULL;i++)
-    ;
+  for (i = 0; cfg->ldc_uris[i].uri != NULL; i++)
+    /* nothing */ ;
   /* check for room */
-  if (i>=NSS_LDAP_CONFIG_URI_MAX)
+  if (i >= NSS_LDAP_CONFIG_URI_MAX)
   {
-    log_log(LOG_ERR,"%s:%d: maximum number of URIs exceeded",filename,lnr);
+    log_log(LOG_ERR, "%s:%d: maximum number of URIs exceeded",
+            filename, lnr);
     exit(EXIT_FAILURE);
   }
   /* append URI to list */
-  cfg->ldc_uris[i].uri=xstrdup(uri);
+  cfg->ldc_uris[i].uri = xstrdup(uri);
 }
 
 #ifdef HAVE_LDAP_DOMAIN2HOSTLIST
 /* return the domain name of the current host
    the returned string must be freed by caller */
-static const char *cfg_getdomainname(const char *filename,int lnr)
+static const char *cfg_getdomainname(const char *filename, int lnr)
 {
-  const char *fqdn,*domain;
-  fqdn=getfqdn();
-  if ((fqdn!=NULL)&&((domain=strchr(fqdn,'.'))!=NULL)&&(domain[1]!='\0'))
-    return domain+1;
-  log_log(LOG_ERR,"%s:%d: unable to determinate a domain name",
-          filename,lnr);
+  const char *fqdn, *domain;
+  fqdn = getfqdn();
+  if ((fqdn != NULL) && ((domain = strchr(fqdn, '.')) != NULL) && (domain[1] 
!= '\0'))
+    return domain + 1;
+  log_log(LOG_ERR, "%s:%d: unable to determinate a domain name",
+          filename, lnr);
   exit(EXIT_FAILURE);
 }
 
 /* add URIs by doing DNS queries for SRV records */
-static void add_uris_from_dns(const char *filename,int lnr,
-                              struct ldap_config *cfg,
-                              const char *domain)
+static void add_uris_from_dns(const char *filename, int lnr,
+                              struct ldap_config *cfg, const char *domain)
 {
   int rc;
-  char *hostlist=NULL,*nxt;
-  char buf[HOST_NAME_MAX+sizeof("ldap://";)];
-  log_log(LOG_DEBUG,"query %s for SRV records",domain);
-  rc=ldap_domain2hostlist(domain,&hostlist);
-  if (rc!=LDAP_SUCCESS)
+  char *hostlist = NULL, *nxt;
+  char buf[HOST_NAME_MAX + sizeof("ldap://";)];
+  log_log(LOG_DEBUG, "query %s for SRV records", domain);
+  rc = ldap_domain2hostlist(domain, &hostlist);
+  if (rc != LDAP_SUCCESS)
   {
-    log_log(LOG_ERR,"%s:%d: no servers found in DNS zone %s: %s",
-            filename,lnr,domain,ldap_err2string(rc));
+    log_log(LOG_ERR, "%s:%d: no servers found in DNS zone %s: %s",
+            filename, lnr, domain, ldap_err2string(rc));
     exit(EXIT_FAILURE);
   }
-  if ((hostlist==NULL)||(*hostlist=='\0'))
+  if ((hostlist == NULL) || (*hostlist == '\0'))
   {
-    log_log(LOG_ERR,"%s:%d: no servers found in DNS zone 
%s",filename,lnr,domain);
+    log_log(LOG_ERR, "%s:%d: no servers found in DNS zone %s",
+            filename, lnr, domain);
     exit(EXIT_FAILURE);
   }
   /* hostlist is a space-separated list of host names that we use to build
      URIs */
-  while(hostlist!=NULL)
+  while (hostlist != NULL)
   {
     /* find the next space and split the string there */
-    nxt=strchr(hostlist,' ');
-    if (nxt!=NULL)
+    nxt = strchr(hostlist, ' ');
+    if (nxt != NULL)
     {
-      *nxt='\0';
+      *nxt = '\0';
       nxt++;
     }
     /* if port is 636, use ldaps:// URI */
-    if ((strlen(hostlist)>4)&&(strcmp(hostlist+strlen(hostlist)-4,":636")==0))
+    if ((strlen(hostlist) > 4) && (strcmp(hostlist + strlen(hostlist) - 4, 
":636") == 0))
     {
-      hostlist[strlen(hostlist)-4]='\0';
-      mysnprintf(buf,sizeof(buf),"ldaps://%s",hostlist);
+      hostlist[strlen(hostlist) - 4] = '\0';
+      mysnprintf(buf, sizeof(buf), "ldaps://%s", hostlist);
     }
     else
     {
       /* strip default port number */
-      if 
((strlen(hostlist)>4)&&(strcmp(hostlist+strlen(hostlist)-4,":389")==0))
-        hostlist[strlen(hostlist)-4]='\0';
-      mysnprintf(buf,sizeof(buf),"ldap://%s",hostlist);
+      if ((strlen(hostlist) > 4) && (strcmp(hostlist + strlen(hostlist) - 4, 
":389") == 0))
+        hostlist[strlen(hostlist) - 4] = '\0';
+      mysnprintf(buf, sizeof(buf), "ldap://%s";, hostlist);
     }
-    log_log(LOG_DEBUG,"add_uris_from_dns(): found uri: %s",buf);
-    add_uri(filename,lnr,cfg,buf);
+    log_log(LOG_DEBUG, "add_uris_from_dns(): found uri: %s", buf);
+    add_uri(filename, lnr, cfg, buf);
     /* get next entry from list */
-    hostlist=nxt;
+    hostlist = nxt;
   }
 }
 #endif /* HAVE_LDAP_DOMAIN2HOSTLIST */
 
-static int parse_boolean(const char *filename,int lnr,const char *value)
+static int parse_boolean(const char *filename, int lnr, const char *value)
 {
-  if ( (strcasecmp(value,"on")==0) ||
-       (strcasecmp(value,"yes")==0) ||
-       (strcasecmp(value,"true")==0) ||
-       (strcasecmp(value,"1")==0) )
+  if ((strcasecmp(value, "on") == 0) ||
+      (strcasecmp(value, "yes") == 0) ||
+      (strcasecmp(value, "true") == 0) || (strcasecmp(value, "1") == 0))
     return 1;
-  else if ( (strcasecmp(value,"off")==0) ||
-            (strcasecmp(value,"no")==0) ||
-            (strcasecmp(value,"false")==0) ||
-            (strcasecmp(value,"0")==0) )
+  else if ((strcasecmp(value, "off") == 0) ||
+           (strcasecmp(value, "no") == 0) ||
+           (strcasecmp(value, "false") == 0) || (strcasecmp(value, "0") == 0))
     return 0;
   else
   {
-    log_log(LOG_ERR,"%s:%d: not a boolean argument: '%s'",filename,lnr,value);
+    log_log(LOG_ERR, "%s:%d: not a boolean argument: '%s'",
+            filename, lnr, value);
     exit(EXIT_FAILURE);
   }
 }
 
-static int parse_scope(const char *filename,int lnr,const char *value)
+static int parse_scope(const char *filename, int lnr, const char *value)
 {
-  if ( (strcasecmp(value,"sub")==0) || (strcasecmp(value,"subtree")==0) )
+  if ((strcasecmp(value, "sub") == 0) || (strcasecmp(value, "subtree") == 0))
     return LDAP_SCOPE_SUBTREE;
-  else if ( (strcasecmp(value,"one")==0) || (strcasecmp(value,"onelevel")==0) )
+  else if ((strcasecmp(value, "one") == 0) || (strcasecmp(value, "onelevel") 
== 0))
     return LDAP_SCOPE_ONELEVEL;
-  else if (strcasecmp(value,"base")==0)
+  else if (strcasecmp(value, "base") == 0)
     return LDAP_SCOPE_BASE;
   else
   {
-    log_log(LOG_ERR,"%s:%d: not a scope argument: '%s'",filename,lnr,value);
+    log_log(LOG_ERR, "%s:%d: not a scope argument: '%s'",
+            filename, lnr, value);
     exit(EXIT_FAILURE);
   }
 }
@@ -281,56 +285,56 @@
    is returned (this can be used to pass to the function on the next
    iteration). If no more tokens are found or the token will not fit in
    the buffer, NULL is returned. */
-static char *get_token(char **line,char *buf,size_t buflen)
+static char *get_token(char **line, char *buf, size_t buflen)
 {
   size_t len;
-  if ((line==NULL)||(*line==NULL)||(**line=='\0')||(buf==NULL))
+  if ((line == NULL) || (*line == NULL) || (**line == '\0') || (buf == NULL))
     return NULL;
   /* find the beginning and length of the token */
-  *line+=strspn(*line,TOKEN_DELIM);
-  len=strcspn(*line,TOKEN_DELIM);
+  *line += strspn(*line, TOKEN_DELIM);
+  len = strcspn(*line, TOKEN_DELIM);
   /* check if there is a token */
-  if (len==0)
+  if (len == 0)
   {
-    *line=NULL;
+    *line = NULL;
     return NULL;
   }
   /* limit the token length */
-  if (len>=buflen)
-    len=buflen-1;
+  if (len >= buflen)
+    len = buflen - 1;
   /* copy the token */
-  strncpy(buf,*line,len);
-  buf[len]='\0';
+  strncpy(buf, *line, len);
+  buf[len] = '\0';
   /* skip to the next token */
-  *line+=len;
-  *line+=strspn(*line,TOKEN_DELIM);
+  *line += len;
+  *line += strspn(*line, TOKEN_DELIM);
   /* return the token */
   return buf;
 }
 
 static enum ldap_map_selector parse_map(const char *value)
 {
-  if ( (strcasecmp(value,"alias")==0) || (strcasecmp(value,"aliases")==0) )
+  if ((strcasecmp(value, "alias") == 0) || (strcasecmp(value, "aliases") == 0))
     return LM_ALIASES;
-  else if ( (strcasecmp(value,"ether")==0) || (strcasecmp(value,"ethers")==0) )
+  else if ((strcasecmp(value, "ether") == 0) || (strcasecmp(value, "ethers") 
== 0))
     return LM_ETHERS;
-  else if (strcasecmp(value,"group")==0)
+  else if (strcasecmp(value, "group") == 0)
     return LM_GROUP;
-  else if ( (strcasecmp(value,"host")==0) || (strcasecmp(value,"hosts")==0) )
+  else if ((strcasecmp(value, "host") == 0) || (strcasecmp(value, "hosts") == 
0))
     return LM_HOSTS;
-  else if (strcasecmp(value,"netgroup")==0)
+  else if (strcasecmp(value, "netgroup") == 0)
     return LM_NETGROUP;
-  else if ( (strcasecmp(value,"network")==0) || 
(strcasecmp(value,"networks")==0) )
+  else if ((strcasecmp(value, "network") == 0) || (strcasecmp(value, 
"networks") == 0))
     return LM_NETWORKS;
-  else if (strcasecmp(value,"passwd")==0)
+  else if (strcasecmp(value, "passwd") == 0)
     return LM_PASSWD;
-  else if ( (strcasecmp(value,"protocol")==0) || 
(strcasecmp(value,"protocols")==0) )
+  else if ((strcasecmp(value, "protocol") == 0) || (strcasecmp(value, 
"protocols") == 0))
     return LM_PROTOCOLS;
-  else if (strcasecmp(value,"rpc")==0)
+  else if (strcasecmp(value, "rpc") == 0)
     return LM_RPC;
-  else if ( (strcasecmp(value,"service")==0) || 
(strcasecmp(value,"services")==0) )
+  else if ((strcasecmp(value, "service") == 0) || (strcasecmp(value, 
"services") == 0))
     return LM_SERVICES;
-  else if (strcasecmp(value,"shadow")==0)
+  else if (strcasecmp(value, "shadow") == 0)
     return LM_SHADOW;
   else
     return LM_NONE;
@@ -343,201 +347,204 @@
   char *old;
   enum ldap_map_selector map;
   /* get the token */
-  old=*line;
-  if (get_token(line,token,sizeof(token))==NULL)
+  old = *line;
+  if (get_token(line, token, sizeof(token)) == NULL)
     return LM_NONE;
   /* find the map if any */
-  map=parse_map(token);
+  map = parse_map(token);
   /* unknown map, return to the previous state */
-  if (map==LM_NONE)
-    *line=old;
+  if (map == LM_NONE)
+    *line = old;
   return map;
 }
 
 /* check that the condition is true and otherwise log an error
    and bail out */
-static inline void check_argumentcount(const char *filename,int lnr,
-                                       const char *keyword,int condition)
+static inline void check_argumentcount(const char *filename, int lnr,
+                                       const char *keyword, int condition)
 {
   if (!condition)
   {
-    log_log(LOG_ERR,"%s:%d: %s: wrong number of 
arguments",filename,lnr,keyword);
+    log_log(LOG_ERR, "%s:%d: %s: wrong number of arguments",
+            filename, lnr, keyword);
     exit(EXIT_FAILURE);
   }
 }
 
 /* check that the file is not world readable */
-static void check_permissions(const char *filename,const char *keyword)
+static void check_permissions(const char *filename, const char *keyword)
 {
   struct stat sb;
   /* get file status */
-  if (stat(filename,&sb))
+  if (stat(filename, &sb))
   {
-    log_log(LOG_ERR,"cannot stat() %s: %s",filename,strerror(errno));
+    log_log(LOG_ERR, "cannot stat() %s: %s", filename, strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* check permissions */
-  if ((sb.st_mode&0007)!=0)
+  if ((sb.st_mode & 0007) != 0)
   {
-    if (keyword!=NULL)
-      log_log(LOG_ERR,"%s: file should not be world readable if %s is set",
+    if (keyword != NULL)
+      log_log(LOG_ERR, "%s: file should not be world readable if %s is set",
               filename, keyword);
     else
-      log_log(LOG_ERR,"%s: file should not be world readable",filename);
+      log_log(LOG_ERR, "%s: file should not be world readable", filename);
     exit(EXIT_FAILURE);
   }
 }
 
-static void get_int(const char *filename,int lnr,
-                    const char *keyword,char **line,
-                    int *var)
+static void get_int(const char *filename, int lnr,
+                    const char *keyword, char **line, int *var)
 {
   /* TODO: refactor to have less overhead */
   char token[32];
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
   /* TODO: replace with correct numeric parse */
-  *var=atoi(token);
+  *var = atoi(token);
 }
 
-static void get_boolean(const char *filename,int lnr,
-                        const char *keyword,char **line,
-                        int *var)
+static void get_boolean(const char *filename, int lnr,
+                        const char *keyword, char **line, int *var)
 {
   /* TODO: refactor to have less overhead */
   char token[32];
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
-  *var=parse_boolean(filename,lnr,token);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
+  *var = parse_boolean(filename, lnr, token);
 }
 
-static void get_strdup(const char *filename,int lnr,
-                       const char *keyword,char **line,
-                       char **var)
+static void get_strdup(const char *filename, int lnr,
+                       const char *keyword, char **line, char **var)
 {
   /* TODO: refactor to have less overhead */
   char token[64];
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
   /* Note: we have a memory leak here if a single variable is changed
-           multiple times in one config (deemed not a problem) */
-  *var=xstrdup(token);
+     multiple times in one config (deemed not a problem) */
+  *var = xstrdup(token);
 }
 
-static void get_restdup(const char *filename,int lnr,
-                        const char *keyword,char **line,
-                        char **var)
+static void get_restdup(const char *filename, int lnr,
+                        const char *keyword, char **line, char **var)
 {
-  check_argumentcount(filename,lnr,keyword,(*line!=NULL)&&(**line!='\0'));
+  check_argumentcount(filename, lnr, keyword, (*line != NULL) && (**line != 
'\0'));
   /* Note: we have a memory leak here if a single mapping is changed
-           multiple times in one config (deemed not a problem) */
-  *var=xstrdup(*line);
+     multiple times in one config (deemed not a problem) */
+  *var = xstrdup(*line);
   /* mark that we are at the end of the line */
-  *line=NULL;
+  *line = NULL;
 }
 
-static void get_eol(const char *filename,int lnr,
-                    const char *keyword,char **line)
+static void get_eol(const char *filename, int lnr,
+                    const char *keyword, char **line)
 {
-  if ((line!=NULL)&&(*line!=NULL)&&(**line!='\0'))
+  if ((line != NULL) && (*line != NULL) && (**line != '\0'))
   {
-    log_log(LOG_ERR,"%s:%d: %s: too may arguments",filename,lnr,keyword);
+    log_log(LOG_ERR, "%s:%d: %s: too may arguments", filename, lnr, keyword);
     exit(EXIT_FAILURE);
   }
 }
 
-static void get_uid(const char *filename,int lnr,
-                    const char *keyword,char **line,
-                    uid_t *var,gid_t *gid,char **str)
+static void get_uid(const char *filename, int lnr,
+                    const char *keyword, char **line,
+                    uid_t *var, gid_t *gid, char **str)
 {
   /* TODO: refactor to have less overhead */
   char token[32];
   struct passwd *pwent;
   char *tmp;
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
   /* check if it is a valid numerical uid */
-  errno=0;
-  *var=strtouid(token,&tmp,10);
-  if ((*token!='\0')&&(*tmp=='\0')&&(errno==0)&&(strchr(token,'-')==NULL))
+  errno = 0;
+  *var = strtouid(token, &tmp, 10);
+  if ((*token != '\0') && (*tmp == '\0') && (errno == 0) && (strchr(token, 
'-') == NULL))
   {
     /* get the name and gid from the passwd database */
-    pwent=getpwuid(*var);
-    if ((gid!=NULL)&&(*gid!=NOGID))
-      *gid=pwent->pw_gid;
-    if (str!=NULL)
-      *str=strdup(pwent->pw_name);
+    pwent = getpwuid(*var);
+    if ((gid != NULL) && (*gid != NOGID))
+      *gid = pwent->pw_gid;
+    if (str != NULL)
+      *str = strdup(pwent->pw_name);
     return;
   }
   /* find by name */
-  pwent=getpwnam(token);
-  if (pwent!=NULL)
+  pwent = getpwnam(token);
+  if (pwent != NULL)
   {
-    *var=pwent->pw_uid;
-    if ((gid!=NULL)&&(*gid!=NOGID))
-      *gid=pwent->pw_gid;
-    if (str!=NULL)
-      *str=strdup(token);
+    *var = pwent->pw_uid;
+    if ((gid != NULL) && (*gid != NOGID))
+      *gid = pwent->pw_gid;
+    if (str != NULL)
+      *str = strdup(token);
     return;
   }
   /* log an error */
-  log_log(LOG_ERR,"%s:%d: %s: not a valid uid: 
'%s'",filename,lnr,keyword,token);
+  log_log(LOG_ERR, "%s:%d: %s: not a valid uid: '%s'",
+          filename, lnr, keyword, token);
   exit(EXIT_FAILURE);
 }
 
-static void get_gid(const char *filename,int lnr,
-                    const char *keyword,char **line,
-                    gid_t *var)
+static void get_gid(const char *filename, int lnr,
+                    const char *keyword, char **line, gid_t *var)
 {
   /* TODO: refactor to have less overhead */
   char token[32];
   struct group *grent;
   char *tmp;
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
   /* check if it is a valid numerical gid */
-  errno=0;
-  *var=strtogid(token,&tmp,10);
-  if ((*token!='\0')&&(*tmp=='\0')&&(errno==0)&&(strchr(token,'-')==NULL))
+  errno = 0;
+  *var = strtogid(token, &tmp, 10);
+  if ((*token != '\0') && (*tmp == '\0') && (errno == 0) && (strchr(token, 
'-') == NULL))
     return;
   /* find by name */
-  grent=getgrnam(token);
-  if (grent!=NULL)
+  grent = getgrnam(token);
+  if (grent != NULL)
   {
-    *var=grent->gr_gid;
+    *var = grent->gr_gid;
     return;
   }
   /* log an error */
-  log_log(LOG_ERR,"%s:%d: %s: not a valid gid: 
'%s'",filename,lnr,keyword,token);
+  log_log(LOG_ERR, "%s:%d: %s: not a valid gid: '%s'",
+          filename, lnr, keyword, token);
   exit(EXIT_FAILURE);
 }
 
 #ifdef LDAP_OPT_X_TLS
-static void get_reqcert(const char *filename,int lnr,
-                        const char *keyword,char **line,
-                        int *var)
+static void get_reqcert(const char *filename, int lnr,
+                        const char *keyword, char **line, int *var)
 {
   char token[16];
   /* get token */
-  
check_argumentcount(filename,lnr,keyword,get_token(line,token,sizeof(token))!=NULL);
+  check_argumentcount(filename, lnr, keyword,
+                      get_token(line, token, sizeof(token)) != NULL);
   /* check if it is a valid value for tls_reqcert option */
-  if ( (strcasecmp(token,"never")==0) ||
-       (strcasecmp(token,"no")==0) )
-    *var=LDAP_OPT_X_TLS_NEVER;
-  else if (strcasecmp(token,"allow")==0)
-    *var=LDAP_OPT_X_TLS_ALLOW;
-  else if (strcasecmp(token,"try")==0)
-    *var=LDAP_OPT_X_TLS_TRY;
-  else if ( (strcasecmp(token,"demand")==0) ||
-       (strcasecmp(token,"yes")==0) )
-    *var=LDAP_OPT_X_TLS_DEMAND;
-  else if (strcasecmp(token,"hard")==0)
-    *var=LDAP_OPT_X_TLS_HARD;
+  if ((strcasecmp(token, "never") == 0) || (strcasecmp(token, "no") == 0))
+    *var = LDAP_OPT_X_TLS_NEVER;
+  else if (strcasecmp(token, "allow") == 0)
+    *var = LDAP_OPT_X_TLS_ALLOW;
+  else if (strcasecmp(token, "try") == 0)
+    *var = LDAP_OPT_X_TLS_TRY;
+  else if ((strcasecmp(token, "demand") == 0) ||
+           (strcasecmp(token, "yes") == 0))
+    *var = LDAP_OPT_X_TLS_DEMAND;
+  else if (strcasecmp(token, "hard") == 0)
+    *var = LDAP_OPT_X_TLS_HARD;
   else
   {
-    log_log(LOG_ERR,"%s:%d: %s: invalid argument: 
'%s'",filename,lnr,keyword,token);
+    log_log(LOG_ERR, "%s:%d: %s: invalid argument: '%s'",
+            filename, lnr, keyword, token);
     exit(EXIT_FAILURE);
   }
 }
 #endif /* LDAP_OPT_X_TLS */
 
-static void parse_krb5_ccname_statement(const char *filename,int lnr,
-                                        const char *keyword,char *line)
+static void parse_krb5_ccname_statement(const char *filename, int lnr,
+                                        const char *keyword, char *line)
 {
   char token[80];
   const char *ccname;
@@ -546,302 +553,317 @@
   char *ccenv;
 #ifdef HAVE_GSS_KRB5_CCACHE_NAME
   OM_uint32 minor_status;
-# endif /* HAVE_GSS_KRB5_CCACHE_NAME */
+#endif /* HAVE_GSS_KRB5_CCACHE_NAME */
   /* get token */
-  check_argumentcount(filename,lnr,keyword,
-      (get_token(&line,token,sizeof(token))!=NULL)&&(*line=='\0'));
+  check_argumentcount(filename, lnr, keyword,
+                      (get_token(&line, token, sizeof(token)) != NULL) &&
+                      (*line == '\0'));
   /* set default kerberos ticket cache for SASL-GSSAPI */
-  ccname=token;
+  ccname = token;
   /* check that cache exists and is readable if it is a file */
-  if ( (strncasecmp(ccname,"FILE:",sizeof("FILE:")-1)==0) ||
-       (strncasecmp(ccname,"WRFILE:",sizeof("WRFILE:")-1)==0))
+  if ((strncasecmp(ccname, "FILE:", sizeof("FILE:") - 1) == 0) ||
+      (strncasecmp(ccname, "WRFILE:", sizeof("WRFILE:") - 1) == 0))
   {
-    ccfile=strchr(ccname,':')+1;
-    if (access(ccfile,R_OK)!=0)
+    ccfile = strchr(ccname, ':') + 1;
+    if (access(ccfile, R_OK) != 0)
     {
-      log_log(LOG_ERR,"%s:%d: error accessing %s: 
%s",filename,lnr,ccfile,strerror(errno));
+      log_log(LOG_ERR, "%s:%d: error accessing %s: %s",
+              filename, lnr, ccfile, strerror(errno));
       exit(EXIT_FAILURE);
     }
   }
   /* set the environment variable (we have a memory leak if this option
      is set multiple times) */
-  ccenvlen=strlen(ccname)+sizeof("KRB5CCNAME=");
-  ccenv=(char *)malloc(ccenvlen);
-  if (ccenv==NULL)
+  ccenvlen = strlen(ccname) + sizeof("KRB5CCNAME=");
+  ccenv = (char *)malloc(ccenvlen);
+  if (ccenv == NULL)
   {
-    log_log(LOG_CRIT,"malloc() failed to allocate memory");
+    log_log(LOG_CRIT, "malloc() failed to allocate memory");
     exit(EXIT_FAILURE);
   }
-  mysnprintf(ccenv,ccenvlen,"KRB5CCNAME=%s",ccname);
+  mysnprintf(ccenv, ccenvlen, "KRB5CCNAME=%s", ccname);
   putenv(ccenv);
 #ifdef HAVE_GSS_KRB5_CCACHE_NAME
   /* set the name with gss_krb5_ccache_name() */
-  if (gss_krb5_ccache_name(&minor_status,ccname,NULL)!=GSS_S_COMPLETE)
+  if (gss_krb5_ccache_name(&minor_status, ccname, NULL) != GSS_S_COMPLETE)
   {
-    log_log(LOG_ERR,"%s:%d: unable to set default credential cache: 
%s",filename,lnr,ccname);
+    log_log(LOG_ERR, "%s:%d: unable to set default credential cache: %s",
+            filename, lnr, ccname);
     exit(EXIT_FAILURE);
   }
-# endif /* HAVE_GSS_KRB5_CCACHE_NAME */
+#endif /* HAVE_GSS_KRB5_CCACHE_NAME */
 }
 
 /* assigns the base to the specified variable doing domain expansion
    and a simple check to avoid overwriting duplicate values */
-static void set_base(const char *filename,int lnr,
-                     const char *value,const char **var)
+static void set_base(const char *filename, int lnr,
+                     const char *value, const char **var)
 {
 #ifdef HAVE_LDAP_DOMAIN2DN
-  const char *domain=NULL;
-  char *domaindn=NULL;
+  const char *domain = NULL;
+  char *domaindn = NULL;
 #endif /* HAVE_LDAP_DOMAIN2DN */
   /* if the base is "DOMAIN" use the domain name */
-  if (strcasecmp(value,"domain")==0)
+  if (strcasecmp(value, "domain") == 0)
   {
 #ifdef HAVE_LDAP_DOMAIN2DN
-    domain=cfg_getdomainname(filename,lnr);
-    ldap_domain2dn(domain,&domaindn);
-    log_log(LOG_DEBUG,"set_base(): setting base to %s from domain",domaindn);
-    value=domaindn;
+    domain = cfg_getdomainname(filename, lnr);
+    ldap_domain2dn(domain, &domaindn);
+    log_log(LOG_DEBUG, "set_base(): setting base to %s from domain",
+            domaindn);
+    value = domaindn;
 #else /* not HAVE_LDAP_DOMAIN2DN */
-    log_log(LOG_ERR,"%s:%d: value %s not supported on 
platform",filename,lnr,value);
+    log_log(LOG_ERR, "%s:%d: value %s not supported on platform",
+            filename, lnr, value);
     exit(EXIT_FAILURE);
 #endif /* not HAVE_LDAP_DOMAIN2DN */
   }
   /* set the new value */
-  *var=xstrdup(value);
+  *var = xstrdup(value);
 }
 
 /* parse the validnames statement */
-static void parse_validnames_statement(const char *filename,int lnr,
-                   const char *keyword,char *line,struct ldap_config *cfg)
+static void parse_validnames_statement(const char *filename, int lnr,
+                                       const char *keyword, char *line,
+                                       struct ldap_config *cfg)
 {
   char *value;
-  int i,l;
-  int flags=REG_EXTENDED|REG_NOSUB;
+  int i, l;
+  int flags = REG_EXTENDED | REG_NOSUB;
   /* the rest of the line should be a regular expression */
-  get_restdup(filename,lnr,keyword,&line,&value);
+  get_restdup(filename, lnr, keyword, &line, &value);
   /* check formatting and update flags */
-  if (value[0]!='/')
+  if (value[0] != '/')
   {
-    log_log(LOG_ERR,"%s:%d: regular expression incorrectly 
delimited",filename,lnr);
+    log_log(LOG_ERR, "%s:%d: regular expression incorrectly delimited",
+            filename, lnr);
     exit(EXIT_FAILURE);
   }
-  l=strlen(value);
-  if (value[l-1]=='i')
+  l = strlen(value);
+  if (value[l - 1] == 'i')
   {
-    value[l-1]='\0';
+    value[l - 1] = '\0';
     l--;
-    flags|=REG_ICASE;
+    flags |= REG_ICASE;
   }
-  if (value[l-1]!='/')
+  if (value[l - 1] != '/')
   {
-    log_log(LOG_ERR,"%s:%d: regular expression incorrectly 
delimited",filename,lnr);
+    log_log(LOG_ERR, "%s:%d: regular expression incorrectly delimited",
+            filename, lnr);
     exit(EXIT_FAILURE);
   }
-  value[l-1]='\0';
+  value[l - 1] = '\0';
   /* compile the regular expression */
-  if ((i=regcomp(&cfg->validnames,value+1,flags))!= 0)
+  if ((i = regcomp(&cfg->validnames, value + 1, flags)) != 0)
   {
     /* get the error message */
-    l=regerror(i,&cfg->validnames,NULL,0);
-    value=malloc(l);
-    if (value==NULL)
-      log_log(LOG_ERR,"%s:%d: invalid regular expression",filename,lnr);
+    l = regerror(i, &cfg->validnames, NULL, 0);
+    value = malloc(l);
+    if (value == NULL)
+      log_log(LOG_ERR, "%s:%d: invalid regular expression", filename, lnr);
     else
     {
-      regerror(i,&cfg->validnames,value,l);
-      log_log(LOG_ERR,"%s:%d: invalid regular expression: %s",filename,lnr,
-              value);
+      regerror(i, &cfg->validnames, value, l);
+      log_log(LOG_ERR, "%s:%d: invalid regular expression: %s",
+              filename, lnr, value);
     }
     exit(EXIT_FAILURE);
   }
 }
 
-static void parse_pam_password_prohibit_message_statement(const char 
*filename,int lnr,
-                   const char *keyword,char *line,struct ldap_config *cfg)
+static void parse_pam_password_prohibit_message_statement(
+                const char *filename, int lnr, const char *keyword,
+                char *line, struct ldap_config *cfg)
 {
   char *value;
   int l;
   /* the rest of the line should be a message */
-  get_restdup(filename,lnr,keyword,&line,&value);
+  get_restdup(filename, lnr, keyword, &line, &value);
   /* strip quotes if they are present */
-  l=strlen(value);
-  if ((value[0]=='\"')&&(value[l-1]=='\"'))
+  l = strlen(value);
+  if ((value[0] == '\"') && (value[l - 1] == '\"'))
   {
-    value[l-1]='\0';
+    value[l - 1] = '\0';
     value++;
   }
-  cfg->pam_password_prohibit_message=value;
+  cfg->pam_password_prohibit_message = value;
 }
 
-static void parse_base_statement(const char *filename,int lnr,
-                                 const char *keyword,char *line,
+static void parse_base_statement(const char *filename, int lnr,
+                                 const char *keyword, char *line,
                                  struct ldap_config *cfg)
 {
   const char **bases;
   int i;
   /* get the list of bases to update */
-  bases=base_get_var(get_map(&line));
-  if (bases==NULL)
-    bases=cfg->ldc_bases;
+  bases = base_get_var(get_map(&line));
+  if (bases == NULL)
+    bases = cfg->ldc_bases;
   /* find the spot in the list of bases */
-  for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
+  for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
   {
-    if (bases[i]==NULL)
+    if (bases[i] == NULL)
     {
-      check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
-      set_base(filename,lnr,line,&bases[i]);
+      check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
+      set_base(filename, lnr, line, &bases[i]);
       return;
     }
   }
   /* no free spot found */
-  log_log(LOG_ERR,"%s:%d: maximum number of base options per map (%d) 
exceeded",
-          filename,lnr,NSS_LDAP_CONFIG_MAX_BASES);
+  log_log(LOG_ERR, "%s:%d: maximum number of base options per map (%d) 
exceeded",
+          filename, lnr, NSS_LDAP_CONFIG_MAX_BASES);
   exit(EXIT_FAILURE);
 }
 
-static void parse_scope_statement(const char *filename,int lnr,
-                                  const char *keyword,char *line,
+static void parse_scope_statement(const char *filename, int lnr,
+                                  const char *keyword, char *line,
                                   struct ldap_config *cfg)
 {
   int *var;
-  var=scope_get_var(get_map(&line));
-  if (var==NULL)
-    var=&cfg->ldc_scope;
-  check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
-  *var=parse_scope(filename,lnr,line);
+  var = scope_get_var(get_map(&line));
+  if (var == NULL)
+    var = &cfg->ldc_scope;
+  check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
+  *var = parse_scope(filename, lnr, line);
 }
 
-static void parse_filter_statement(const char *filename,int lnr,
-                                   const char *keyword,char *line)
+static void parse_filter_statement(const char *filename, int lnr,
+                                   const char *keyword, char *line)
 {
   const char **var;
-  const char *map=line;
-  var=filter_get_var(get_map(&line));
-  if (var==NULL)
+  const char *map = line;
+  var = filter_get_var(get_map(&line));
+  if (var == NULL)
   {
-    log_log(LOG_ERR,"%s:%d: unknown map: '%s'",filename,lnr,map);
+    log_log(LOG_ERR, "%s:%d: unknown map: '%s'", filename, lnr, map);
     exit(EXIT_FAILURE);
   }
-  check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
+  check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
   /* check if the value will be changed */
-  if (strcmp(*var,line)!=0)
+  if (strcmp(*var, line) != 0)
   {
     /* Note: we have a memory leak here if a single mapping is changed
-             multiple times in one config (deemed not a problem) */
-    *var=xstrdup(line);
+       multiple times in one config (deemed not a problem) */
+    *var = xstrdup(line);
   }
 }
 
 /* this function modifies the statement argument passed */
-static void parse_map_statement(const char *filename,int lnr,
-                                const char *keyword,char *line)
+static void parse_map_statement(const char *filename, int lnr,
+                                const char *keyword, char *line)
 {
   enum ldap_map_selector map;
   const char **var;
   char oldatt[32], newatt[1024];
   /* get the map */
-  if ((map=get_map(&line))==LM_NONE)
+  if ((map = get_map(&line)) == LM_NONE)
   {
-    log_log(LOG_ERR,"%s:%d: unknown map: '%s'",filename,lnr,line);
+    log_log(LOG_ERR, "%s:%d: unknown map: '%s'", filename, lnr, line);
     exit(EXIT_FAILURE);
   }
   /* read the other tokens */
-  check_argumentcount(filename,lnr,keyword,
-      (get_token(&line,oldatt,sizeof(oldatt))!=NULL)&&
-      (get_token(&line,newatt,sizeof(newatt))!=NULL));
+  check_argumentcount(filename, lnr, keyword,
+                      (get_token(&line, oldatt, sizeof(oldatt)) != NULL) &&
+                      (get_token(&line, newatt, sizeof(newatt)) != NULL));
   /* check that there are no more tokens left on the line */
-  get_eol(filename,lnr,keyword,&line);
+  get_eol(filename, lnr, keyword, &line);
   /* change attribute mapping */
-  var=attmap_get_var(map,oldatt);
-  if (var==NULL)
+  var = attmap_get_var(map, oldatt);
+  if (var == NULL)
   {
-    log_log(LOG_ERR,"%s:%d: unknown attribute to map: 
'%s'",filename,lnr,oldatt);
+    log_log(LOG_ERR, "%s:%d: unknown attribute to map: '%s'",
+            filename, lnr, oldatt);
     exit(EXIT_FAILURE);
   }
-  if (attmap_set_mapping(var,newatt)==NULL)
+  if (attmap_set_mapping(var, newatt) == NULL)
   {
-    log_log(LOG_ERR,"%s:%d: attribute %s cannot be an 
expression",filename,lnr,oldatt);
+    log_log(LOG_ERR, "%s:%d: attribute %s cannot be an expression",
+            filename, lnr, oldatt);
     exit(EXIT_FAILURE);
   }
 }
 
 /* this function modifies the statement argument passed */
 static void parse_nss_initgroups_ignoreusers_statement(
-              const char *filename,int lnr,const char *keyword,
-              char *line,struct ldap_config *cfg)
+                const char *filename, int lnr, const char *keyword,
+                char *line, struct ldap_config *cfg)
 {
   char token[MAX_LINE_LENGTH];
-  char *username,*next;
+  char *username, *next;
   struct passwd *pwent;
-  check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
-  if (cfg->ldc_nss_initgroups_ignoreusers==NULL)
-    cfg->ldc_nss_initgroups_ignoreusers=set_new();
-  while (get_token(&line,token,sizeof(token))!=NULL)
+  check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
+  if (cfg->ldc_nss_initgroups_ignoreusers == NULL)
+    cfg->ldc_nss_initgroups_ignoreusers = set_new();
+  while (get_token(&line, token, sizeof(token)) != NULL)
   {
-    if (strcasecmp(token,"alllocal")==0)
+    if (strcasecmp(token, "alllocal") == 0)
     {
       /* go over all users (this will work because nslcd is not yet running) */
       setpwent();
-      while ((pwent=getpwent())!=NULL)
-        set_add(cfg->ldc_nss_initgroups_ignoreusers,pwent->pw_name);
+      while ((pwent = getpwent()) != NULL)
+        set_add(cfg->ldc_nss_initgroups_ignoreusers, pwent->pw_name);
       endpwent();
     }
     else
     {
-      next=token;
-      while (*next!='\0')
+      next = token;
+      while (*next != '\0')
       {
-        username=next;
+        username = next;
         /* find the end of the current username */
-        while ((*next!='\0')&&(*next!=',')) next++;
-        if (*next==',')
+        while ((*next != '\0') && (*next != ','))
+          next++;
+        if (*next == ',')
         {
-          *next='\0';
+          *next = '\0';
           next++;
         }
         /* check if user exists (but add anyway) */
-        pwent=getpwnam(username);
-        if (pwent==NULL)
-          log_log(LOG_ERR,"%s:%d: user '%s' does not 
exist",filename,lnr,username);
-        set_add(cfg->ldc_nss_initgroups_ignoreusers,username);
+        pwent = getpwnam(username);
+        if (pwent == NULL)
+          log_log(LOG_ERR, "%s:%d: user '%s' does not exist",
+                  filename, lnr, username);
+        set_add(cfg->ldc_nss_initgroups_ignoreusers, username);
       }
     }
   }
 }
 
 static void parse_pam_authz_search_statement(
-              const char *filename,int lnr,const char *keyword,
-              char *line,struct ldap_config *cfg)
+                const char *filename, int lnr, const char *keyword,
+                char *line, struct ldap_config *cfg)
 {
   SET *set;
   const char **list;
   int i;
-  check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
+  check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
   /* find free spot for search filter */
-  for 
(i=0;(i<NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES)&&(cfg->ldc_pam_authz_search[i]!=NULL);i++);
-  if (i>=NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES)
+  for (i = 0;
+       (i < NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES) && 
(cfg->ldc_pam_authz_search[i] != NULL);
+       i++)
+    /* nothing */ ;
+  if (i >= NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES)
   {
-    log_log(LOG_ERR,"%s:%d: maximum number of pam_authz_search options (%d) 
exceeded",
-            filename,lnr,NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES);
+    log_log(LOG_ERR, "%s:%d: maximum number of pam_authz_search options (%d) 
exceeded",
+            filename, lnr, NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES);
     exit(EXIT_FAILURE);
   }
-  cfg->ldc_pam_authz_search[i]=xstrdup(line);
+  cfg->ldc_pam_authz_search[i] = xstrdup(line);
   /* check the variables used in the expression */
-  set=expr_vars(cfg->ldc_pam_authz_search[i],NULL);
-  list=set_tolist(set);
-  for (i=0;list[i]!=NULL;i++)
-  {
-    if ((strcmp(list[i],"username")!=0)&&
-        (strcmp(list[i],"service")!=0)&&
-        (strcmp(list[i],"ruser")!=0)&&
-        (strcmp(list[i],"rhost")!=0)&&
-        (strcmp(list[i],"tty")!=0)&&
-        (strcmp(list[i],"hostname")!=0)&&
-        (strcmp(list[i],"fqdn")!=0)&&
-        (strcmp(list[i],"dn")!=0)&&
-        (strcmp(list[i],"uid")!=0))
+  set = expr_vars(cfg->ldc_pam_authz_search[i], NULL);
+  list = set_tolist(set);
+  for (i = 0; list[i] != NULL; i++)
+  {
+    if ((strcmp(list[i], "username") != 0) &&
+        (strcmp(list[i], "service") != 0) &&
+        (strcmp(list[i], "ruser") != 0) &&
+        (strcmp(list[i], "rhost") != 0) &&
+        (strcmp(list[i], "tty") != 0) &&
+        (strcmp(list[i], "hostname") != 0) &&
+        (strcmp(list[i], "fqdn") != 0) &&
+        (strcmp(list[i], "dn") != 0) && (strcmp(list[i], "uid") != 0))
     {
-      log_log(LOG_ERR,"%s:%d: unknown variable $%s",filename,lnr,list[i]);
+      log_log(LOG_ERR, "%s:%d: unknown variable $%s", filename, lnr, list[i]);
       exit(EXIT_FAILURE);
     }
   }
@@ -850,10 +872,10 @@
   free(list);
 }
 
-static void cfg_read(const char *filename,struct ldap_config *cfg)
+static void cfg_read(const char *filename, struct ldap_config *cfg)
 {
   FILE *fp;
-  int lnr=0;
+  int lnr = 0;
   char linebuf[MAX_LINE_LENGTH];
   char *line;
   char keyword[32];
@@ -864,343 +886,365 @@
   char *value;
 #endif
   /* open config file */
-  if ((fp=fopen(filename,"r"))==NULL)
+  if ((fp = fopen(filename, "r")) == NULL)
   {
-    log_log(LOG_ERR,"cannot open config file (%s): 
%s",filename,strerror(errno));
+    log_log(LOG_ERR, "cannot open config file (%s): %s",
+            filename, strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* read file and parse lines */
-  while (fgets(linebuf,sizeof(linebuf),fp)!=NULL)
+  while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
   {
     lnr++;
-    line=linebuf;
+    line = linebuf;
     /* strip newline */
-    i=(int)strlen(line);
-    if ((i<=0)||(line[i-1]!='\n'))
+    i = (int)strlen(line);
+    if ((i <= 0) || (line[i - 1] != '\n'))
     {
-      log_log(LOG_ERR,"%s:%d: line too long or last line missing 
newline",filename,lnr);
+      log_log(LOG_ERR, "%s:%d: line too long or last line missing newline",
+              filename, lnr);
       exit(EXIT_FAILURE);
     }
-    line[i-1]='\0';
+    line[i - 1] = '\0';
     /* ignore comment lines */
-    if (line[0]=='#')
+    if (line[0] == '#')
       continue;
     /* strip trailing spaces */
-    for (i--;(i>0)&&isspace(line[i-1]);i--)
-      line[i-1]='\0';
+    for (i--; (i > 0) && isspace(line[i - 1]); i--)
+      line[i - 1] = '\0';
     /* get keyword from line and ignore empty lines */
-    if (get_token(&line,keyword,sizeof(keyword))==NULL)
+    if (get_token(&line, keyword, sizeof(keyword)) == NULL)
       continue;
     /* runtime options */
-    if (strcasecmp(keyword,"threads")==0)
+    if (strcasecmp(keyword, "threads") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_threads);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_threads);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"uid")==0)
+    else if (strcasecmp(keyword, "uid") == 0)
     {
-      
get_uid(filename,lnr,keyword,&line,&cfg->ldc_uid,&cfg->ldc_gid,&cfg->ldc_uidname);
-      get_eol(filename,lnr,keyword,&line);
+      get_uid(filename, lnr, keyword, &line, &cfg->ldc_uid, &cfg->ldc_gid,
+              &cfg->ldc_uidname);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"gid")==0)
+    else if (strcasecmp(keyword, "gid") == 0)
     {
-      get_gid(filename,lnr,keyword,&line,&cfg->ldc_gid);
-      get_eol(filename,lnr,keyword,&line);
+      get_gid(filename, lnr, keyword, &line, &cfg->ldc_gid);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"ignorecase")==0)
+    else if (strcasecmp(keyword, "ignorecase") == 0)
     {
-      get_boolean(filename,lnr,keyword,&line,&cfg->ldc_ignorecase);
-      get_eol(filename,lnr,keyword,&line);
+      get_boolean(filename, lnr, keyword, &line, &cfg->ldc_ignorecase);
+      get_eol(filename, lnr, keyword, &line);
     }
     /* general connection options */
-    else if (strcasecmp(keyword,"uri")==0)
+    else if (strcasecmp(keyword, "uri") == 0)
     {
-      check_argumentcount(filename,lnr,keyword,(line!=NULL)&&(*line!='\0'));
-      while (get_token(&line,token,sizeof(token))!=NULL)
+      check_argumentcount(filename, lnr, keyword, (line != NULL) && (*line != 
'\0'));
+      while (get_token(&line, token, sizeof(token)) != NULL)
       {
-        if (strcasecmp(token,"dns")==0)
+        if (strcasecmp(token, "dns") == 0)
         {
 #ifdef HAVE_LDAP_DOMAIN2HOSTLIST
-          add_uris_from_dns(filename,lnr,cfg,cfg_getdomainname(filename,lnr));
+          add_uris_from_dns(filename, lnr, cfg,
+                            cfg_getdomainname(filename, lnr));
 #else /* not HAVE_LDAP_DOMAIN2HOSTLIST */
-          log_log(LOG_ERR,"%s:%d: value %s not supported on 
platform",filename,lnr,token);
+          log_log(LOG_ERR, "%s:%d: value %s not supported on platform",
+                  filename, lnr, token);
           exit(EXIT_FAILURE);
 #endif /* not HAVE_LDAP_DOMAIN2HOSTLIST */
         }
-        else if (strncasecmp(token,"dns:",4)==0)
+        else if (strncasecmp(token, "dns:", 4) == 0)
         {
 #ifdef HAVE_LDAP_DOMAIN2HOSTLIST
-          add_uris_from_dns(filename,lnr,cfg,strdup(token+sizeof("dns")));
+          add_uris_from_dns(filename, lnr, cfg,
+                            strdup(token + sizeof("dns")));
 #else /* not HAVE_LDAP_DOMAIN2HOSTLIST */
-          log_log(LOG_ERR,"%s:%d: value %s not supported on 
platform",filename,lnr,token);
+          log_log(LOG_ERR, "%s:%d: value %s not supported on platform",
+                  filename, lnr, token);
           exit(EXIT_FAILURE);
 #endif /* not HAVE_LDAP_DOMAIN2HOSTLIST */
         }
         else
-          add_uri(filename,lnr,cfg,token);
+          add_uri(filename, lnr, cfg, token);
       }
     }
-    else if (strcasecmp(keyword,"ldap_version")==0)
+    else if (strcasecmp(keyword, "ldap_version") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_version);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_version);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"binddn")==0)
+    else if (strcasecmp(keyword, "binddn") == 0)
     {
-      get_restdup(filename,lnr,keyword,&line,&cfg->ldc_binddn);
+      get_restdup(filename, lnr, keyword, &line, &cfg->ldc_binddn);
     }
-    else if (strcasecmp(keyword,"bindpw")==0)
+    else if (strcasecmp(keyword, "bindpw") == 0)
     {
-      check_permissions(filename,keyword);
-      get_restdup(filename,lnr,keyword,&line,&cfg->ldc_bindpw);
+      check_permissions(filename, keyword);
+      get_restdup(filename, lnr, keyword, &line, &cfg->ldc_bindpw);
     }
-    else if (strcasecmp(keyword,"rootpwmoddn")==0)
+    else if (strcasecmp(keyword, "rootpwmoddn") == 0)
     {
-      get_restdup(filename,lnr,keyword,&line,&cfg->ldc_rootpwmoddn);
+      get_restdup(filename, lnr, keyword, &line, &cfg->ldc_rootpwmoddn);
     }
-    else if (strcasecmp(keyword,"rootpwmodpw")==0)
+    else if (strcasecmp(keyword, "rootpwmodpw") == 0)
     {
-      check_permissions(filename,keyword);
-      get_restdup(filename,lnr,keyword,&line,&cfg->ldc_rootpwmodpw);
+      check_permissions(filename, keyword);
+      get_restdup(filename, lnr, keyword, &line, &cfg->ldc_rootpwmodpw);
     }
     /* SASL authentication options */
-    else if (strcasecmp(keyword,"use_sasl")==0)
+    else if (strcasecmp(keyword, "use_sasl") == 0)
     {
-      log_log(LOG_WARNING,"%s:%d: option %s is deprecated (and will be removed 
in an upcoming release), use sasl_mech instead",filename,lnr,keyword);
+      log_log(LOG_WARNING, "%s:%d: option %s is deprecated (and will be 
removed in an upcoming release), use sasl_mech instead",
+              filename, lnr, keyword);
     }
-    else if (strcasecmp(keyword,"sasl_mech")==0)
+    else if (strcasecmp(keyword, "sasl_mech") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&cfg->ldc_sasl_mech);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &cfg->ldc_sasl_mech);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"sasl_realm")==0)
+    else if (strcasecmp(keyword, "sasl_realm") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&cfg->ldc_sasl_realm);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &cfg->ldc_sasl_realm);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"sasl_authcid")==0)
+    else if (strcasecmp(keyword, "sasl_authcid") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&cfg->ldc_sasl_authcid);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &cfg->ldc_sasl_authcid);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"sasl_authzid")==0)
+    else if (strcasecmp(keyword, "sasl_authzid") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&cfg->ldc_sasl_authzid);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &cfg->ldc_sasl_authzid);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"sasl_secprops")==0)
+    else if (strcasecmp(keyword, "sasl_secprops") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&cfg->ldc_sasl_secprops);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &cfg->ldc_sasl_secprops);
+      get_eol(filename, lnr, keyword, &line);
     }
 #ifdef LDAP_OPT_X_SASL_NOCANON
-    else if ( (strcasecmp(keyword,"sasl_canonicalize")==0) ||
-              (strcasecmp(keyword,"sasl_canonicalise")==0) ||
-              (strcasecmp(keyword,"ldap_sasl_canonicalize")==0) ||
-              (strcasecmp(keyword,"sasl_canon")==0) )
-    {
-      get_boolean(filename,lnr,keyword,&line,&cfg->ldc_sasl_canonicalize);
-      get_eol(filename,lnr,keyword,&line);
-    }
-    else if (strcasecmp(keyword,"sasl_nocanon")==0)
-    {
-      get_boolean(filename,lnr,keyword,&line,&cfg->ldc_sasl_canonicalize);
-      cfg->ldc_sasl_canonicalize=!cfg->ldc_sasl_canonicalize;
-      get_eol(filename,lnr,keyword,&line);
+    else if ((strcasecmp(keyword, "sasl_canonicalize") == 0) ||
+             (strcasecmp(keyword, "sasl_canonicalise") == 0) ||
+             (strcasecmp(keyword, "ldap_sasl_canonicalize") == 0) ||
+             (strcasecmp(keyword, "sasl_canon") == 0))
+    {
+      get_boolean(filename, lnr, keyword, &line, &cfg->ldc_sasl_canonicalize);
+      get_eol(filename, lnr, keyword, &line);
+    }
+    else if (strcasecmp(keyword, "sasl_nocanon") == 0)
+    {
+      get_boolean(filename, lnr, keyword, &line, &cfg->ldc_sasl_canonicalize);
+      cfg->ldc_sasl_canonicalize = !cfg->ldc_sasl_canonicalize;
+      get_eol(filename, lnr, keyword, &line);
     }
 #endif /* LDAP_OPT_X_SASL_NOCANON */
     /* Kerberos authentication options */
-    else if (strcasecmp(keyword,"krb5_ccname")==0)
+    else if (strcasecmp(keyword, "krb5_ccname") == 0)
     {
-      parse_krb5_ccname_statement(filename,lnr,keyword,line);
+      parse_krb5_ccname_statement(filename, lnr, keyword, line);
     }
     /* search/mapping options */
-    else if (strcasecmp(keyword,"base")==0)
+    else if (strcasecmp(keyword, "base") == 0)
     {
-      parse_base_statement(filename,lnr,keyword,line,cfg);
+      parse_base_statement(filename, lnr, keyword, line, cfg);
     }
-    else if (strcasecmp(keyword,"scope")==0)
+    else if (strcasecmp(keyword, "scope") == 0)
     {
-      parse_scope_statement(filename,lnr,keyword,line,cfg);
+      parse_scope_statement(filename, lnr, keyword, line, cfg);
     }
-    else if (strcasecmp(keyword,"deref")==0)
-    {
-      check_argumentcount(filename,lnr,keyword,
-          (get_token(&line,token,sizeof(token))!=NULL));
-      if (strcasecmp(token,"never")==0)
-        cfg->ldc_deref=LDAP_DEREF_NEVER;
-      else if (strcasecmp(token,"searching")==0)
-        cfg->ldc_deref=LDAP_DEREF_SEARCHING;
-      else if (strcasecmp(token,"finding")==0)
-        cfg->ldc_deref=LDAP_DEREF_FINDING;
-      else if (strcasecmp(token,"always")==0)
-        cfg->ldc_deref=LDAP_DEREF_ALWAYS;
+    else if (strcasecmp(keyword, "deref") == 0)
+    {
+      check_argumentcount(filename, lnr, keyword,
+                          (get_token(&line, token, sizeof(token)) != NULL));
+      if (strcasecmp(token, "never") == 0)
+        cfg->ldc_deref = LDAP_DEREF_NEVER;
+      else if (strcasecmp(token, "searching") == 0)
+        cfg->ldc_deref = LDAP_DEREF_SEARCHING;
+      else if (strcasecmp(token, "finding") == 0)
+        cfg->ldc_deref = LDAP_DEREF_FINDING;
+      else if (strcasecmp(token, "always") == 0)
+        cfg->ldc_deref = LDAP_DEREF_ALWAYS;
       else
       {
-        log_log(LOG_ERR,"%s:%d: wrong argument: '%s'",filename,lnr,token);
+        log_log(LOG_ERR, "%s:%d: wrong argument: '%s'", filename, lnr, token);
         exit(EXIT_FAILURE);
       }
-      get_eol(filename,lnr,keyword,&line);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"referrals")==0)
+    else if (strcasecmp(keyword, "referrals") == 0)
     {
-      get_boolean(filename,lnr,keyword,&line,&cfg->ldc_referrals);
-      get_eol(filename,lnr,keyword,&line);
+      get_boolean(filename, lnr, keyword, &line, &cfg->ldc_referrals);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"filter")==0)
+    else if (strcasecmp(keyword, "filter") == 0)
     {
-      parse_filter_statement(filename,lnr,keyword,line);
+      parse_filter_statement(filename, lnr, keyword, line);
     }
-    else if (strcasecmp(keyword,"map")==0)
+    else if (strcasecmp(keyword, "map") == 0)
     {
-      parse_map_statement(filename,lnr,keyword,line);
+      parse_map_statement(filename, lnr, keyword, line);
     }
     /* timing/reconnect options */
-    else if (strcasecmp(keyword,"bind_timelimit")==0)
+    else if (strcasecmp(keyword, "bind_timelimit") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_bind_timelimit);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_bind_timelimit);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"timelimit")==0)
+    else if (strcasecmp(keyword, "timelimit") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_timelimit);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_timelimit);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"idle_timelimit")==0)
+    else if (strcasecmp(keyword, "idle_timelimit") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_idle_timelimit);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_idle_timelimit);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"reconnect_tries")==0)
-      log_log(LOG_WARNING,"%s:%d: option %s has been removed and will be 
ignored",filename,lnr,keyword);
-    else if (!strcasecmp(keyword,"reconnect_sleeptime"))
+    else if (strcasecmp(keyword, "reconnect_tries") == 0)
+      log_log(LOG_WARNING, "%s:%d: option %s has been removed and will be 
ignored",
+              filename, lnr, keyword);
+    else if (!strcasecmp(keyword, "reconnect_sleeptime"))
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_reconnect_sleeptime);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_reconnect_sleeptime);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if ( (strcasecmp(keyword,"reconnect_retrytime")==0) ||
-              (strcasecmp(keyword,"reconnect_maxsleeptime")==0) )
+    else if ((strcasecmp(keyword, "reconnect_retrytime") == 0) ||
+             (strcasecmp(keyword, "reconnect_maxsleeptime") == 0))
     {
-      if (strcasecmp(keyword,"reconnect_maxsleeptime")==0)
-        log_log(LOG_WARNING,"%s:%d: option %s has been renamed to 
reconnect_retrytime",filename,lnr,keyword);
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_reconnect_retrytime);
-      get_eol(filename,lnr,keyword,&line);
+      if (strcasecmp(keyword, "reconnect_maxsleeptime") == 0)
+        log_log(LOG_WARNING, "%s:%d: option %s has been renamed to 
reconnect_retrytime",
+                filename, lnr, keyword);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_reconnect_retrytime);
+      get_eol(filename, lnr, keyword, &line);
     }
 #ifdef LDAP_OPT_X_TLS
     /* SSL/TLS options */
-    else if (strcasecmp(keyword,"ssl")==0)
+    else if (strcasecmp(keyword, "ssl") == 0)
     {
-      check_argumentcount(filename,lnr,keyword,
-          (get_token(&line,token,sizeof(token))!=NULL));
-      if ( (strcasecmp(token,"start_tls")==0) ||
-           (strcasecmp(token,"starttls")==0) )
-        cfg->ldc_ssl_on=SSL_START_TLS;
-      else if (parse_boolean(filename,lnr,token))
-        cfg->ldc_ssl_on=SSL_LDAPS;
-      get_eol(filename,lnr,keyword,&line);
-    }
-    else if ( (strcasecmp(keyword,"tls_reqcert")==0) ||
-              (strcasecmp(keyword,"tls_checkpeer")==0) )
-    {
-      if (strcasecmp(keyword,"tls_checkpeer")==0)
-        log_log(LOG_WARNING,"%s:%d: option %s is deprecated (and will be 
removed in an upcoming release), use tls_reqcert instead",filename,lnr,keyword);
-      get_reqcert(filename,lnr,keyword,&line,&i);
-      get_eol(filename,lnr,keyword,&line);
-      log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_REQUIRE_CERT,%d)",i);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_REQUIRE_CERT,&i);
+      check_argumentcount(filename, lnr, keyword,
+                          (get_token(&line, token, sizeof(token)) != NULL));
+      if ((strcasecmp(token, "start_tls") == 0) ||
+          (strcasecmp(token, "starttls") == 0))
+        cfg->ldc_ssl_on = SSL_START_TLS;
+      else if (parse_boolean(filename, lnr, token))
+        cfg->ldc_ssl_on = SSL_LDAPS;
+      get_eol(filename, lnr, keyword, &line);
+    }
+    else if ((strcasecmp(keyword, "tls_reqcert") == 0) ||
+             (strcasecmp(keyword, "tls_checkpeer") == 0))
+    {
+      if (strcasecmp(keyword, "tls_checkpeer") == 0)
+        log_log(LOG_WARNING, "%s:%d: option %s is deprecated (and will be 
removed in an upcoming release), use tls_reqcert instead",
+                filename, lnr, keyword);
+      get_reqcert(filename, lnr, keyword, &line, &i);
+      get_eol(filename, lnr, keyword, &line);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_REQUIRE_CERT,%d)", i);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &i);
     }
-    else if (strcasecmp(keyword,"tls_cacertdir")==0)
+    else if (strcasecmp(keyword, "tls_cacertdir") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&value);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &value);
+      get_eol(filename, lnr, keyword, &line);
       /* TODO: check that the path is valid */
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_CACERTDIR,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_CACERTDIR,value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CACERTDIR,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CACERTDIR, value);
       free(value);
     }
-    else if ( (strcasecmp(keyword,"tls_cacertfile")==0) ||
-              (strcasecmp(keyword,"tls_cacert")==0) )
+    else if ((strcasecmp(keyword, "tls_cacertfile") == 0) ||
+             (strcasecmp(keyword, "tls_cacert") == 0))
     {
-      get_strdup(filename,lnr,keyword,&line,&value);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &value);
+      get_eol(filename, lnr, keyword, &line);
       /* TODO: check that the path is valid */
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_CACERTFILE,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_CACERTFILE,value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CACERTFILE,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CACERTFILE, value);
       free(value);
     }
-    else if (strcasecmp(keyword,"tls_randfile")==0)
+    else if (strcasecmp(keyword, "tls_randfile") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&value);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &value);
+      get_eol(filename, lnr, keyword, &line);
       /* TODO: check that the path is valid */
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_RANDOM_FILE,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_RANDOM_FILE,value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_RANDOM_FILE,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_RANDOM_FILE, value);
       free(value);
     }
-    else if (strcasecmp(keyword,"tls_ciphers")==0)
+    else if (strcasecmp(keyword, "tls_ciphers") == 0)
     {
-      get_restdup(filename,lnr,keyword,&line,&value);
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_CIPHER_SUITE,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_CIPHER_SUITE,value);
+      get_restdup(filename, lnr, keyword, &line, &value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CIPHER_SUITE,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CIPHER_SUITE, value);
       free(value);
     }
-    else if (strcasecmp(keyword,"tls_cert")==0)
+    else if (strcasecmp(keyword, "tls_cert") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&value);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &value);
+      get_eol(filename, lnr, keyword, &line);
       /* TODO: check that the path is valid */
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_CERTFILE,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_CERTFILE,value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_CERTFILE,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_CERTFILE, value);
       free(value);
     }
-    else if (strcasecmp(keyword,"tls_key")==0)
+    else if (strcasecmp(keyword, "tls_key") == 0)
     {
-      get_strdup(filename,lnr,keyword,&line,&value);
-      get_eol(filename,lnr,keyword,&line);
+      get_strdup(filename, lnr, keyword, &line, &value);
+      get_eol(filename, lnr, keyword, &line);
       /* TODO: check that the path is valid */
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS_KEYFILE,\"%s\")",value);
-      LDAP_SET_OPTION(NULL,LDAP_OPT_X_TLS_KEYFILE,value);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS_KEYFILE,\"%s\")",
+              value);
+      LDAP_SET_OPTION(NULL, LDAP_OPT_X_TLS_KEYFILE, value);
       free(value);
     }
 #endif /* LDAP_OPT_X_TLS */
     /* other options */
-    else if (strcasecmp(keyword,"restart")==0)
+    else if (strcasecmp(keyword, "restart") == 0)
     {
-      log_log(LOG_WARNING,"%s:%d: option %s is currently untested (and may be 
removed in an upcoming release)",filename,lnr,keyword);
-      get_boolean(filename,lnr,keyword,&line,&cfg->ldc_restart);
-      get_eol(filename,lnr,keyword,&line);
+      log_log(LOG_WARNING, "%s:%d: option %s is currently untested (and may be 
removed in an upcoming release)",
+              filename, lnr, keyword);
+      get_boolean(filename, lnr, keyword, &line, &cfg->ldc_restart);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"pagesize")==0)
+    else if (strcasecmp(keyword, "pagesize") == 0)
     {
-      get_int(filename,lnr,keyword,&line,&cfg->ldc_pagesize);
-      get_eol(filename,lnr,keyword,&line);
+      get_int(filename, lnr, keyword, &line, &cfg->ldc_pagesize);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"nss_initgroups_ignoreusers")==0)
+    else if (strcasecmp(keyword, "nss_initgroups_ignoreusers") == 0)
     {
-      
parse_nss_initgroups_ignoreusers_statement(filename,lnr,keyword,line,cfg);
+      parse_nss_initgroups_ignoreusers_statement(filename, lnr, keyword, line,
+                                                 cfg);
     }
-    else if (strcasecmp(keyword,"pam_authz_search")==0)
+    else if (strcasecmp(keyword, "pam_authz_search") == 0)
     {
-      parse_pam_authz_search_statement(filename,lnr,keyword,line,cfg);
+      parse_pam_authz_search_statement(filename, lnr, keyword, line, cfg);
     }
-    else if (strcasecmp(keyword,"nss_min_uid")==0)
+    else if (strcasecmp(keyword, "nss_min_uid") == 0)
     {
-      get_uid(filename,lnr,keyword,&line,&cfg->ldc_nss_min_uid,NULL,NULL);
-      get_eol(filename,lnr,keyword,&line);
+      get_uid(filename, lnr, keyword, &line, &cfg->ldc_nss_min_uid, NULL,
+              NULL);
+      get_eol(filename, lnr, keyword, &line);
     }
-    else if (strcasecmp(keyword,"validnames")==0)
+    else if (strcasecmp(keyword, "validnames") == 0)
     {
-      parse_validnames_statement(filename,lnr,keyword,line,cfg);
+      parse_validnames_statement(filename, lnr, keyword, line, cfg);
     }
-    else if (strcasecmp(keyword,"pam_password_prohibit_message")==0)
+    else if (strcasecmp(keyword, "pam_password_prohibit_message") == 0)
     {
-      
parse_pam_password_prohibit_message_statement(filename,lnr,keyword,line,cfg);
+      parse_pam_password_prohibit_message_statement(filename, lnr, keyword,
+                                                    line, cfg);
     }
 #ifdef ENABLE_CONFIGFILE_CHECKING
     /* fallthrough */
     else
     {
-      log_log(LOG_ERR,"%s:%d: unknown keyword: '%s'",filename,lnr,keyword);
+      log_log(LOG_ERR, "%s:%d: unknown keyword: '%s'",
+              filename, lnr, keyword);
       exit(EXIT_FAILURE);
     }
 #endif
@@ -1210,52 +1254,54 @@
 }
 
 #ifdef NSLCD_BINDPW_PATH
-static void bindpw_read(const char *filename,struct ldap_config *cfg)
+static void bindpw_read(const char *filename, struct ldap_config *cfg)
 {
   FILE *fp;
   char linebuf[MAX_LINE_LENGTH];
   int i;
   /* open config file */
-  errno=0;
-  if ((fp=fopen(filename,"r"))==NULL)
+  errno = 0;
+  if ((fp = fopen(filename, "r")) == NULL)
   {
-    if (errno==ENOENT)
+    if (errno == ENOENT)
     {
-      log_log(LOG_DEBUG,"no bindpw file (%s)",filename);
+      log_log(LOG_DEBUG, "no bindpw file (%s)", filename);
       return; /* ignore */
     }
     else
     {
-      log_log(LOG_ERR,"cannot open bindpw file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "cannot open bindpw file (%s): %s",
+              filename, strerror(errno));
       exit(EXIT_FAILURE);
     }
   }
   /* check permissions */
-  check_permissions(filename,NULL);
+  check_permissions(filename, NULL);
   /* read the first line */
-  if (fgets(linebuf,sizeof(linebuf),fp)==NULL)
+  if (fgets(linebuf, sizeof(linebuf), fp) == NULL)
   {
-    log_log(LOG_ERR,"%s: error reading first line",filename);
+    log_log(LOG_ERR, "%s: error reading first line", filename);
     exit(EXIT_FAILURE);
   }
   /* chop the last char off and save the rest as bindpw */
-  i=(int)strlen(linebuf);
-  if ((i<=0)||(linebuf[i-1]!='\n'))
+  i = (int)strlen(linebuf);
+  if ((i <= 0) || (linebuf[i - 1] != '\n'))
   {
-    log_log(LOG_ERR,"%s:1: line too long or missing newline",filename);
+    log_log(LOG_ERR, "%s:1: line too long or missing newline", filename);
     exit(EXIT_FAILURE);
   }
-  linebuf[i-1]='\0';
-  if (strlen(linebuf)==0)
+  linebuf[i - 1] = '\0';
+  if (strlen(linebuf) == 0)
   {
-    log_log(LOG_ERR,"%s:1: the password is empty",filename);
+    log_log(LOG_ERR, "%s:1: the password is empty", filename);
     exit(EXIT_FAILURE);
   }
-  cfg->ldc_bindpw=strdup(linebuf);
+  cfg->ldc_bindpw = strdup(linebuf);
   /* check if there is no more data in the file */
-  if (fgets(linebuf,sizeof(linebuf),fp)!=NULL)
+  if (fgets(linebuf, sizeof(linebuf), fp) != NULL)
   {
-    log_log(LOG_ERR,"%s:2: there is more than one line in the bindpw 
file",filename);
+    log_log(LOG_ERR, "%s:2: there is more than one line in the bindpw file",
+            filename);
     exit(EXIT_FAILURE);
   }
   fclose(fp);
@@ -1275,34 +1321,37 @@
   int i;
   int rc;
   const char **values;
-  char *base=NULL;
+  char *base = NULL;
   /* initialize session */
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
-  
search=myldap_search(session,"",LDAP_SCOPE_BASE,"(objectClass=*)",attrs,NULL);
-  if (search==NULL)
+  search = myldap_search(session, "", LDAP_SCOPE_BASE, "(objectClass=*)",
+                         attrs, NULL);
+  if (search == NULL)
   {
     myldap_session_close(session);
     return NULL;
   }
   /* go over results */
-  for (i=0;(entry=myldap_get_entry(search,&rc))!=NULL;i++)
+  for (i = 0; (entry = myldap_get_entry(search, &rc)) != NULL; i++)
   {
     /* get defaultNamingContext */
-    values=myldap_get_values(entry,"defaultNamingContext");
-    if ((values!=NULL)&&(values[0]!=NULL))
+    values = myldap_get_values(entry, "defaultNamingContext");
+    if ((values != NULL) && (values[0] != NULL))
     {
-      base=xstrdup(values[0]);
-      log_log(LOG_DEBUG,"get_basedn_from_rootdse(): found attribute 
defaultNamingContext with value %s",values[0]);
+      base = xstrdup(values[0]);
+      log_log(LOG_DEBUG, "get_basedn_from_rootdse(): found attribute 
defaultNamingContext with value %s",
+              values[0]);
       break;
     }
     /* get namingContexts */
-    values=myldap_get_values(entry,"namingContexts");
-    if ((values!=NULL)&&(values[0]!=NULL))
+    values = myldap_get_values(entry, "namingContexts");
+    if ((values != NULL) && (values[0] != NULL))
     {
-      base=xstrdup(values[0]);
-      log_log(LOG_DEBUG,"get_basedn_from_rootdse(): found attribute 
namingContexts with value %s",values[0]);
+      base = xstrdup(values[0]);
+      log_log(LOG_DEBUG, "get_basedn_from_rootdse(): found attribute 
namingContexts with value %s",
+              values[0]);
       break;
     }
   }
@@ -1317,52 +1366,52 @@
   int i;
 #endif /* LDAP_OPT_X_TLS */
   /* check if we were called before */
-  if (nslcd_cfg!=NULL)
+  if (nslcd_cfg != NULL)
   {
-    log_log(LOG_CRIT,"cfg_init() may only be called once");
+    log_log(LOG_CRIT, "cfg_init() may only be called once");
     exit(EXIT_FAILURE);
   }
   /* allocate the memory (this memory is not freed anywhere) */
-  nslcd_cfg=(struct ldap_config *)malloc(sizeof(struct ldap_config));
-  if (nslcd_cfg==NULL)
+  nslcd_cfg = (struct ldap_config *)malloc(sizeof(struct ldap_config));
+  if (nslcd_cfg == NULL)
   {
-    log_log(LOG_CRIT,"malloc() failed to allocate memory");
+    log_log(LOG_CRIT, "malloc() failed to allocate memory");
     exit(EXIT_FAILURE);
   }
   /* clear configuration */
   cfg_defaults(nslcd_cfg);
   /* read configfile */
-  cfg_read(fname,nslcd_cfg);
+  cfg_read(fname, nslcd_cfg);
 #ifdef NSLCD_BINDPW_PATH
-  bindpw_read(NSLCD_BINDPW_PATH,nslcd_cfg);
+  bindpw_read(NSLCD_BINDPW_PATH, nslcd_cfg);
 #endif /* NSLCD_BINDPW_PATH */
   /* do some sanity checks */
-  if (nslcd_cfg->ldc_uris[0].uri==NULL)
+  if (nslcd_cfg->ldc_uris[0].uri == NULL)
   {
-    log_log(LOG_ERR,"no URIs defined in config");
+    log_log(LOG_ERR, "no URIs defined in config");
     exit(EXIT_FAILURE);
   }
   /* if ssl is on each URI should start with ldaps */
 #ifdef LDAP_OPT_X_TLS
-  if (nslcd_cfg->ldc_ssl_on==SSL_LDAPS)
+  if (nslcd_cfg->ldc_ssl_on == SSL_LDAPS)
   {
-    for (i=0;nslcd_cfg->ldc_uris[i].uri!=NULL;i++)
+    for (i = 0; nslcd_cfg->ldc_uris[i].uri != NULL; i++)
     {
-      if (strncasecmp(nslcd_cfg->ldc_uris[i].uri,"ldaps://",8)!=0)
-        log_log(LOG_WARNING,"%s doesn't start with ldaps:// and \"ssl on\" is 
specified",
-                            nslcd_cfg->ldc_uris[i].uri);
+      if (strncasecmp(nslcd_cfg->ldc_uris[i].uri, "ldaps://", 8) != 0)
+        log_log(LOG_WARNING, "%s doesn't start with ldaps:// and \"ssl on\" is 
specified",
+                nslcd_cfg->ldc_uris[i].uri);
     }
   }
   /* TODO: check that if some tls options are set the ssl option should be set 
to on (just warn) */
 #endif /* LDAP_OPT_X_TLS */
   /* if basedn is not yet set,  get if from the rootDSE */
-  if (nslcd_cfg->ldc_bases[0]==NULL)
-    nslcd_cfg->ldc_bases[0]=get_base_from_rootdse();
+  if (nslcd_cfg->ldc_bases[0] == NULL)
+    nslcd_cfg->ldc_bases[0] = get_base_from_rootdse();
   /* TODO: handle the case gracefully when no LDAP server is available yet */
   /* see if we have a valid basedn */
-  if ((nslcd_cfg->ldc_bases[0]==NULL)||(nslcd_cfg->ldc_bases[0][0]=='\0'))
+  if ((nslcd_cfg->ldc_bases[0] == NULL) || (nslcd_cfg->ldc_bases[0][0] == 
'\0'))
   {
-    log_log(LOG_ERR,"no base defined in config and couldn't get one from 
server");
+    log_log(LOG_ERR, "no base defined in config and couldn't get one from 
server");
     exit(EXIT_FAILURE);
   }
   /* initialise all database modules */

Modified: nss-pam-ldapd/nslcd/cfg.h
==============================================================================
--- nss-pam-ldapd/nslcd/cfg.h   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/cfg.h   Sat Dec 22 22:38:26 2012        (r1873)
@@ -48,16 +48,14 @@
 /* maximum number of pam_authz_search options */
 #define NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES 8
 
-enum ldap_ssl_options
-{
+enum ldap_ssl_options {
   SSL_OFF,
   SSL_LDAPS,
   SSL_START_TLS
 };
 
 /* selectors for different maps */
-enum ldap_map_selector
-{
+enum ldap_map_selector {
   LM_PASSWD,
   LM_SHADOW,
   LM_GROUP,
@@ -72,8 +70,7 @@
   LM_NONE
 };
 
-struct myldap_uri
-{
+struct myldap_uri {
   char *uri;
   /* time of first failed operation */
   time_t firstfail;
@@ -81,8 +78,7 @@
   time_t lastfail;
 };
 
-struct ldap_config
-{
+struct ldap_config {
   /* the number of threads to start */
   int ldc_threads;
   /* the user name specified in the uid option */
@@ -94,7 +90,7 @@
   /* whether or not case should be ignored in lookups */
   int ldc_ignorecase;
   /* NULL terminated list of URIs */
-  struct myldap_uri ldc_uris[NSS_LDAP_CONFIG_URI_MAX+1];
+  struct myldap_uri ldc_uris[NSS_LDAP_CONFIG_URI_MAX + 1];
   /* protocol version */
   int ldc_version;
   /* bind DN */

Modified: nss-pam-ldapd/nslcd/common.c
==============================================================================
--- nss-pam-ldapd/nslcd/common.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/common.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -42,177 +42,178 @@
 #include "attmap.h"
 #include "cfg.h"
 
-/* simple wrapper around snptintf() to return non-0 in case
+/* simple wrapper around snptintf() to return non-zero in case
    of any failure (but always keep string 0-terminated) */
-int mysnprintf(char *buffer,size_t buflen,const char *format, ...)
+int mysnprintf(char *buffer, size_t buflen, const char *format, ...)
 {
   int res;
   va_list ap;
   /* do snprintf */
-  va_start(ap,format);
-  res=vsnprintf(buffer,buflen,format,ap);
+  va_start(ap, format);
+  res = vsnprintf(buffer, buflen, format, ap);
   va_end(ap);
   /* NULL-terminate the string just to be on the safe side */
-  buffer[buflen-1]='\0';
+  buffer[buflen - 1] = '\0';
   /* check if the string was completely written */
-  return ((res<0)||(((size_t)res)>=buflen));
+  return ((res < 0) || (((size_t)res) >= buflen));
 }
 
 /* return the fully qualified domain name of the current host */
 const char *getfqdn(void)
 {
-  static char *fqdn=NULL;
-  char hostname[HOST_NAME_MAX+1];
+  static char *fqdn = NULL;
+  char hostname[HOST_NAME_MAX + 1];
   int hostnamelen;
   int i;
-  struct hostent *host=NULL;
+  struct hostent *host = NULL;
   /* if we already have a fqdn return that */
-  if (fqdn!=NULL)
+  if (fqdn != NULL)
     return fqdn;
   /* get system hostname */
-  if (gethostname(hostname,sizeof(hostname))<0)
+  if (gethostname(hostname, sizeof(hostname)) < 0)
   {
-    log_log(LOG_ERR,"gethostname() failed: %s",strerror(errno));
+    log_log(LOG_ERR, "gethostname() failed: %s", strerror(errno));
     return NULL;
   }
-  hostnamelen=strlen(hostname);
+  hostnamelen = strlen(hostname);
   /* lookup hostent */
-  host=gethostbyname(hostname);
-  if (host==NULL)
+  host = gethostbyname(hostname);
+  if (host == NULL)
   {
-    log_log(LOG_ERR,"gethostbyname(%s): %s",hostname,hstrerror(h_errno));
+    log_log(LOG_ERR, "gethostbyname(%s): %s", hostname, hstrerror(h_errno));
     /* fall back to hostname */
-    fqdn=strdup(hostname);
+    fqdn = strdup(hostname);
     return fqdn;
   }
   /* check h_name for fqdn starting with our hostname */
-  if ((strncasecmp(hostname,host->h_name,hostnamelen)==0)&&
-      (host->h_name[hostnamelen]=='.')&&
-      (host->h_name[hostnamelen+1]!='\0'))
+  if ((strncasecmp(hostname, host->h_name, hostnamelen) == 0) &&
+      (host->h_name[hostnamelen] == '.') &&
+      (host->h_name[hostnamelen + 1] != '\0'))
   {
-    fqdn=strdup(host->h_name);
+    fqdn = strdup(host->h_name);
     return fqdn;
   }
   /* also check h_aliases */
-  for (i=0;host->h_aliases[i]!=NULL;i++)
+  for (i = 0; host->h_aliases[i] != NULL; i++)
   {
-    if ((strncasecmp(hostname,host->h_aliases[i],hostnamelen)==0)&&
-        (host->h_aliases[i][hostnamelen]=='.')&&
-        (host->h_aliases[i][hostnamelen+1]!='\0'))
+    if ((strncasecmp(hostname, host->h_aliases[i], hostnamelen) == 0) &&
+        (host->h_aliases[i][hostnamelen] == '.') &&
+        (host->h_aliases[i][hostnamelen + 1] != '\0'))
     {
-      fqdn=strdup(host->h_aliases[i]);
+      fqdn = strdup(host->h_aliases[i]);
       return fqdn;
     }
   }
   /* fall back to h_name if it has a dot in it */
-  if (strchr(host->h_name,'.')!=NULL)
+  if (strchr(host->h_name, '.') != NULL)
   {
-    fqdn=strdup(host->h_name);
+    fqdn = strdup(host->h_name);
     return fqdn;
   }
   /* also check h_aliases */
-  for (i=0;host->h_aliases[i]!=NULL;i++)
+  for (i = 0; host->h_aliases[i] != NULL; i++)
   {
-    if (strchr(host->h_aliases[i],'.')!=NULL)
+    if (strchr(host->h_aliases[i], '.') != NULL)
     {
-      fqdn=strdup(host->h_aliases[i]);
+      fqdn = strdup(host->h_aliases[i]);
       return fqdn;
     }
   }
   /* nothing found, fall back to hostname */
-  fqdn=strdup(hostname);
+  fqdn = strdup(hostname);
   return fqdn;
 }
 
-const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr,char 
*buffer,size_t buflen)
+const char *get_userpassword(MYLDAP_ENTRY *entry, const char *attr,
+                             char *buffer, size_t buflen)
 {
   const char *tmpvalue;
   /* get the value */
-  tmpvalue=attmap_get_value(entry,attr,buffer,buflen);
-  if (tmpvalue==NULL)
+  tmpvalue = attmap_get_value(entry, attr, buffer, buflen);
+  if (tmpvalue == NULL)
     return NULL;
   /* go over the entries and return the remainder of the value if it
      starts with {crypt} or crypt$ */
-  if (strncasecmp(tmpvalue,"{crypt}",7)==0)
-    return tmpvalue+7;
-  if (strncasecmp(tmpvalue,"crypt$",6)==0)
-    return tmpvalue+6;
+  if (strncasecmp(tmpvalue, "{crypt}", 7) == 0)
+    return tmpvalue + 7;
+  if (strncasecmp(tmpvalue, "crypt$", 6) == 0)
+    return tmpvalue + 6;
   /* just return the first value completely */
   return tmpvalue;
   /* TODO: support more password formats e.g. SMD5
-    (which is $1$ but in a different format)
-    (any code for this is more than welcome) */
+     (which is $1$ but in a different format)
+     (any code for this is more than welcome) */
 }
 
 /* Checks if the specified name seems to be a valid user or group name. */
 int isvalidname(const char *name)
 {
-  return regexec(&nslcd_cfg->validnames,name,0,NULL,0)==0;
+  return regexec(&nslcd_cfg->validnames, name, 0, NULL, 0) == 0;
 }
 
 /* this writes a single address to the stream */
-int write_address(TFILE *fp,MYLDAP_ENTRY *entry,const char *attr,
+int write_address(TFILE *fp, MYLDAP_ENTRY *entry, const char *attr,
                   const char *addr)
 {
   int32_t tmpint32;
   struct in_addr ipv4addr;
   struct in6_addr ipv6addr;
   /* try to parse the address as IPv4 first, fall back to IPv6 */
-  if (inet_pton(AF_INET,addr,&ipv4addr)>0)
+  if (inet_pton(AF_INET, addr, &ipv4addr) > 0)
   {
     /* write address type */
-    WRITE_INT32(fp,AF_INET);
+    WRITE_INT32(fp, AF_INET);
     /* write the address length */
-    WRITE_INT32(fp,sizeof(struct in_addr));
+    WRITE_INT32(fp, sizeof(struct in_addr));
     /* write the address itself (in network byte order) */
-    WRITE(fp,&ipv4addr,sizeof(struct in_addr));
+    WRITE(fp, &ipv4addr, sizeof(struct in_addr));
   }
-  else if (inet_pton(AF_INET6,addr,&ipv6addr)>0)
+  else if (inet_pton(AF_INET6, addr, &ipv6addr) > 0)
   {
     /* write address type */
-    WRITE_INT32(fp,AF_INET6);
+    WRITE_INT32(fp, AF_INET6);
     /* write the address length */
-    WRITE_INT32(fp,sizeof(struct in6_addr));
+    WRITE_INT32(fp, sizeof(struct in6_addr));
     /* write the address itself (in network byte order) */
-    WRITE(fp,&ipv6addr,sizeof(struct in6_addr));
+    WRITE(fp, &ipv6addr, sizeof(struct in6_addr));
   }
   else
   {
     /* failure, log but write simple invalid address
        (otherwise the address list is messed up) */
     /* TODO: have error message in correct format */
-    log_log(LOG_WARNING,"%s: %s: \"%s\" unparseble",
-                        myldap_get_dn(entry),attmap_ether_cn,addr);
+    log_log(LOG_WARNING, "%s: %s: \"%s\" unparseble",
+            myldap_get_dn(entry), attmap_ether_cn, addr);
     /* write an illegal address type */
-    WRITE_INT32(fp,-1);
+    WRITE_INT32(fp, -1);
     /* write an emtpy address */
-    WRITE_INT32(fp,0);
+    WRITE_INT32(fp, 0);
   }
   /* we're done */
   return 0;
 }
 
-int read_address(TFILE *fp,char *addr,int *addrlen,int *af)
+int read_address(TFILE *fp, char *addr, int *addrlen, int *af)
 {
   int32_t tmpint32;
   int len;
   /* read address family */
-  READ_INT32(fp,*af);
-  if ((*af!=AF_INET)&&(*af!=AF_INET6))
+  READ_INT32(fp, *af);
+  if ((*af != AF_INET) && (*af != AF_INET6))
   {
-    log_log(LOG_WARNING,"incorrect address family specified: %d",*af);
+    log_log(LOG_WARNING, "incorrect address family specified: %d", *af);
     return -1;
   }
   /* read address length */
-  READ_INT32(fp,len);
-  if ((len>*addrlen)||(len<=0))
+  READ_INT32(fp, len);
+  if ((len > *addrlen) || (len <= 0))
   {
-    log_log(LOG_WARNING,"address length incorrect: %d",len);
+    log_log(LOG_WARNING, "address length incorrect: %d", len);
     return -1;
   }
-  *addrlen=len;
+  *addrlen = len;
   /* read address */
-  READ(fp,addr,len);
+  READ(fp, addr, len);
   /* we're done */
   return 0;
 }
@@ -222,43 +223,45 @@
    to a format that can be used to search the objectSid property with */
 char *sid2search(const char *sid)
 {
-  const char *tmpsid=sid;
-  char *res,*tmp;
-  int i=0;
+  const char *tmpsid = sid;
+  char *res, *tmp;
+  int i = 0;
   long int l;
   /* check the beginning of the string */
-  if (strncasecmp(sid,"S-",2)!=0)
+  if (strncasecmp(sid, "S-", 2) != 0)
   {
-    log_log(LOG_ERR,"error in SID %s",sid);
+    log_log(LOG_ERR, "error in SID %s", sid);
     exit(EXIT_FAILURE);
   }
   /* count the number of dashes in the sid */
-  while (tmpsid!=NULL)
+  while (tmpsid != NULL)
   {
     i++;
-    tmpsid=strchr(tmpsid+1,'-');
+    tmpsid = strchr(tmpsid + 1, '-');
   }
-  i-=2; /* number of security ids plus one because we add the uid later */
+  i -= 2; /* number of security ids plus one because we add the uid later */
   /* allocate memory */
-  res=malloc(3+3+6*3+i*4*3+1);
-  if (res==NULL)
+  res = malloc(3 + 3 + 6 * 3 + i * 4 * 3 + 1);
+  if (res == NULL)
   {
-    log_log(LOG_CRIT,"malloc() failed to allocate memory");
+    log_log(LOG_CRIT, "malloc() failed to allocate memory");
     exit(1);
   }
   /* build the first part */
-  l=strtol(sid+2,&tmp,10);
-  sprintf(res,"\\%02x\\%02x",(int)l&0xff,(int)i);
+  l = strtol(sid + 2, &tmp, 10);
+  sprintf(res, "\\%02x\\%02x", (int)l & 0xff, (int)i);
   /* build authority part (we only handle 32 of the 48 bits) */
-  l=strtol(tmp+1,&tmp,10);
-  sprintf(res+strlen(res),"\\00\\00\\%02x\\%02x\\%02x\\%02x",
-          
(int)((l>>24)&0xff),(int)((l>>16)&0xff),(int)((l>>8)&0xff),(int)(l&0xff));
+  l = strtol(tmp + 1, &tmp, 10);
+  sprintf(res + strlen(res), "\\00\\00\\%02x\\%02x\\%02x\\%02x",
+          (int)((l >> 24) & 0xff), (int)((l >> 16) & 0xff),
+          (int)((l >> 8) & 0xff), (int)(l & 0xff));
   /* go over the rest of the bits */
-  while (*tmp!='\0')
+  while (*tmp != '\0')
   {
-    l=strtol(tmp+1,&tmp,10);
-    sprintf(res+strlen(res),"\\%02x\\%02x\\%02x\\%02x",
-            
(int)(l&0xff),(int)((l>>8)&0xff),(int)((l>>16)&0xff),(int)((l>>24)&0xff));
+    l = strtol(tmp + 1, &tmp, 10);
+    sprintf(res + strlen(res), "\\%02x\\%02x\\%02x\\%02x",
+            (int)(l & 0xff), (int)((l >> 8) & 0xff), (int)((l >> 16) & 0xff),
+            (int)((l >> 24) & 0xff));
   }
   return res;
 }
@@ -268,21 +271,23 @@
 {
   int i;
   /* find the position of the last security id */
-  i=2+6+((((int)binsid[1])&0xff)-1)*4;
-  return (((long int)binsid[i])&0xff)|((((long int)binsid[i+1])&0xff)<<8)|
-         ((((long int)binsid[i+2])&0xff)<<16)|((((long 
int)binsid[i+3])&0xff)<<24);
+  i = 2 + 6 + ((((int)binsid[1]) & 0xff) - 1) * 4;
+  return (((long int)binsid[i]) & 0xff) |
+         ((((long int)binsid[i + 1]) & 0xff) << 8) |
+         ((((long int)binsid[i + 2]) & 0xff) << 16) |
+         ((((long int)binsid[i + 3]) & 0xff) << 24);
 }
 
 #ifdef WANT_STRTOUI
 /* provide a strtoui() implementation, similar to strtoul() but returning
    an range-checked unsigned int instead */
-unsigned int strtoui(const char *nptr,char **endptr,int base)
+unsigned int strtoui(const char *nptr, char **endptr, int base)
 {
   unsigned long val;
-  val=strtoul(nptr,endptr,base);
-  if (val>UINT_MAX)
+  val = strtoul(nptr, endptr, base);
+  if (val > UINT_MAX)
   {
-    errno=ERANGE;
+    errno = ERANGE;
     return UINT_MAX;
   }
   /* If errno was set by strtoul, we'll pass it back as-is */

Modified: nss-pam-ldapd/nslcd/common.h
==============================================================================
--- nss-pam-ldapd/nslcd/common.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/common.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -42,22 +42,23 @@
    the stream is not closed because the caller closes the
    stream */
 
-#define ERROR_OUT_WRITEERROR(fp) \
-  log_log(LOG_WARNING,"error writing to client: %s",strerror(errno)); \
+#define ERROR_OUT_WRITEERROR(fp)                                            \
+  log_log(LOG_WARNING, "error writing to client: %s", strerror(errno));     \
   return -1;
 
-#define ERROR_OUT_READERROR(fp) \
-  log_log(LOG_WARNING,"error reading from client: %s",strerror(errno)); \
+#define ERROR_OUT_READERROR(fp)                                             \
+  log_log(LOG_WARNING, "error reading from client: %s", strerror(errno));   \
   return -1;
 
-#define ERROR_OUT_BUFERROR(fp) \
-  log_log(LOG_WARNING,"client supplied argument %d bytes too large",tmpint32); 
\
+#define ERROR_OUT_BUFERROR(fp)                                              \
+  log_log(LOG_WARNING, "client supplied argument %d bytes too large",       \
+          tmpint32);                                                        \
   return -1;
 
 /* a simple wrapper around snprintf,
    returns 0 if ok, -1 on error */
-int mysnprintf(char *buffer,size_t buflen,const char *format, ...)
-  LIKE_PRINTF(3,4);
+int mysnprintf(char *buffer, size_t buflen, const char *format, ...)
+  LIKE_PRINTF(3, 4);
 
 /* return the fully qualified domain name of the current host
    the returned value does not need to be freed but is re-used for every
@@ -69,25 +70,25 @@
    /etc/group or /etc/shadow depending upon what is in the directory.
    This function will return NULL if no passwd is found and will return the
    literal value in the directory if conversion is not possible. */
-const char *get_userpassword(MYLDAP_ENTRY *entry,const char *attr,
-                             char *buffer,size_t buflen);
+const char *get_userpassword(MYLDAP_ENTRY *entry, const char *attr,
+                             char *buffer, size_t buflen);
 
 /* write out an address, parsing the addr value */
-int write_address(TFILE *fp,MYLDAP_ENTRY *entry,const char *attr,
+int write_address(TFILE *fp, MYLDAP_ENTRY *entry, const char *attr,
                   const char *addr);
 
 /* a helper macro to write out addresses and bail out on errors */
-#define WRITE_ADDRESS(fp,entry,attr,addr) \
-  if (write_address(fp,entry,attr,addr)) \
+#define WRITE_ADDRESS(fp, entry, attr, addr)                                \
+  if (write_address(fp, entry, attr, addr))                                 \
     return -1;
 
 /* read an address from the stream */
-int read_address(TFILE *fp,char *addr,int *addrlen,int *af);
+int read_address(TFILE *fp, char *addr, int *addrlen, int *af);
 
 /* helper macro to read an address from the stream */
-#define READ_ADDRESS(fp,addr,len,af) \
-  len=(int)sizeof(addr); \
-  if (read_address(fp,addr,&(len),&(af))) \
+#define READ_ADDRESS(fp, addr, len, af)                                     \
+  len = (int)sizeof(addr);                                                  \
+  if (read_address(fp, addr, &(len), &(af)))                                \
     return -1;
 
 /* convert the provided string representation of a sid
@@ -103,28 +104,33 @@
 
 /* Perform an LDAP lookup to translate the DN into a uid.
    This function either returns NULL or a strdup()ed string. */
-MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int 
*rcp,char *buf,size_t buflen);
+MUST_USE char *lookup_dn2uid(MYLDAP_SESSION *session, const char *dn,
+                             int *rcp, char *buf, size_t buflen);
 
 /* transforms the DN info a uid doing an LDAP lookup if needed */
-MUST_USE char *dn2uid(MYLDAP_SESSION *session,const char *dn,char *buf,size_t 
buflen);
+MUST_USE char *dn2uid(MYLDAP_SESSION *session, const char *dn, char *buf,
+                      size_t buflen);
 
 /* use the user id to lookup an LDAP entry */
-MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp);
+MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session, const char *uid, int *rcp);
 
 /* transforms the uid into a DN by doing an LDAP lookup */
-MUST_USE char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t 
buflen);
+MUST_USE char *uid2dn(MYLDAP_SESSION *session, const char *uid, char *buf,
+                      size_t buflen);
 
 /* try to update the shadowLastChange attribute of the entry if possible */
-int update_lastchange(MYLDAP_SESSION *session,const char *userdn);
+int update_lastchange(MYLDAP_SESSION *session, const char *userdn);
 
 /* use the user id to lookup an LDAP entry with the shadow attributes
-   requested*/
-MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session,const char 
*username,int *rcp);
+   requested */
+MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session, const char *username,
+                               int *rcp);
 
 /* return shadown information */
-void get_shadow_properties(MYLDAP_ENTRY *entry,long *lastchangedate,
-                           long *mindays,long *maxdays,long *warndays,
-                           long *inactdays,long *expiredate,unsigned long 
*flag);
+void get_shadow_properties(MYLDAP_ENTRY *entry, long *lastchangedate,
+                           long *mindays, long *maxdays, long *warndays,
+                           long *inactdays, long *expiredate,
+                           unsigned long *flag);
 
 
 /* check whether the nsswitch file should be reloaded */
@@ -170,7 +176,7 @@
 
 #ifdef WANT_STRTOUI
 /* provide a strtoui() if it is needed */
-unsigned int strtoui(const char *nptr,char **endptr,int base);
+unsigned int strtoui(const char *nptr, char **endptr, int base);
 #endif /* WANT_STRTOUI */
 
 /* these are the functions for initialising the database specific
@@ -189,94 +195,97 @@
 
 /* these are the different functions that handle the database
    specific actions, see nslcd.h for the action descriptions */
-int nslcd_config_get(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_alias_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_alias_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_ether_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_ether_byether(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_ether_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_group_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_group_bygid(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_group_bymember(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_group_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_host_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_host_byaddr(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_host_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_netgroup_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_network_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_network_byaddr(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_network_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_passwd_byname(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
-int nslcd_passwd_byuid(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
-int nslcd_passwd_all(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
-int nslcd_protocol_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_protocol_bynumber(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_protocol_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_rpc_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_rpc_bynumber(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_rpc_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_service_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_service_bynumber(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_service_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_shadow_byname(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_shadow_all(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
-int nslcd_pam_authz(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_pam_sess_o(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_pam_sess_c(TFILE *fp,MYLDAP_SESSION *session);
-int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid);
+int nslcd_config_get(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_alias_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_alias_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_ether_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_ether_byether(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_ether_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_group_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_group_bygid(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_group_bymember(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_group_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_host_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_host_byaddr(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_host_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_netgroup_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_network_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_network_byaddr(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_network_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_passwd_byname(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid);
+int nslcd_passwd_byuid(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid);
+int nslcd_passwd_all(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid);
+int nslcd_protocol_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_protocol_bynumber(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_protocol_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_rpc_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_rpc_bynumber(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_rpc_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_service_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_service_bynumber(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_service_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_shadow_byname(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_shadow_all(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_pam_authc(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid);
+int nslcd_pam_authz(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_pam_sess_o(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_pam_sess_c(TFILE *fp, MYLDAP_SESSION *session);
+int nslcd_pam_pwmod(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid);
 
 /* macros for generating service handling code */
-#define NSLCD_HANDLE(db,fn,readfn,action,mkfilter,writefn) \
-  int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session) \
-  NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
-#define NSLCD_HANDLE_UID(db,fn,readfn,action,mkfilter,writefn) \
-  int nslcd_##db##_##fn(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid) \
-  NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn)
-#define NSLCD_HANDLE_BODY(db,fn,readfn,action,mkfilter,writefn) \
-  { \
-    /* define common variables */ \
-    int32_t tmpint32; \
-    MYLDAP_SEARCH *search; \
-    MYLDAP_ENTRY *entry; \
-    const char *base; \
-    int rc,i; \
-    /* read request parameters */ \
-    readfn; \
-    /* write the response header */ \
-    WRITE_INT32(fp,NSLCD_VERSION); \
-    WRITE_INT32(fp,action); \
-    /* prepare the search filter */ \
-    if (mkfilter) \
-    { \
-      log_log(LOG_WARNING,"nslcd_" __STRING(db) "_" __STRING(fn) "(): filter 
buffer too small"); \
-      return -1; \
-    } \
-    /* perform a search for each search base */ \
-    for (i=0; (base=db##_bases[i])!=NULL; i++) \
-    { \
-      /* do the LDAP search */ \
-      if 
((search=myldap_search(session,base,db##_scope,filter,db##_attrs,NULL))==NULL) \
-        return -1; \
-      /* go over results */ \
-      while ((entry=myldap_get_entry(search,&rc))!=NULL) \
-      { \
-        if (writefn) \
-          return -1; \
-      } \
-    } \
-    /* write the final result code */ \
-    if (rc==LDAP_SUCCESS) \
-    { \
-      WRITE_INT32(fp,NSLCD_RESULT_END); \
-    } \
-    return 0; \
+#define NSLCD_HANDLE(db, fn, readfn, action, mkfilter, writefn)             \
+  int nslcd_##db##_##fn(TFILE *fp, MYLDAP_SESSION *session)                 \
+  NSLCD_HANDLE_BODY(db, fn, readfn, action, mkfilter, writefn)
+#define NSLCD_HANDLE_UID(db, fn, readfn, action, mkfilter, writefn)         \
+  int nslcd_##db##_##fn(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid) \
+  NSLCD_HANDLE_BODY(db, fn, readfn, action, mkfilter, writefn)
+#define NSLCD_HANDLE_BODY(db, fn, readfn, action, mkfilter, writefn)        \
+  {                                                                         \
+    /* define common variables */                                           \
+    int32_t tmpint32;                                                       \
+    MYLDAP_SEARCH *search;                                                  \
+    MYLDAP_ENTRY *entry;                                                    \
+    const char *base;                                                       \
+    int rc, i;                                                              \
+    /* read request parameters */                                           \
+    readfn;                                                                 \
+    /* write the response header */                                         \
+    WRITE_INT32(fp, NSLCD_VERSION);                                         \
+    WRITE_INT32(fp, action);                                                \
+    /* prepare the search filter */                                         \
+    if (mkfilter)                                                           \
+    {                                                                       \
+      log_log(LOG_WARNING, "nslcd_" __STRING(db) "_" __STRING(fn)           \
+              "(): filter buffer too small");                               \
+      return -1;                                                            \
+    }                                                                       \
+    /* perform a search for each search base */                             \
+    for (i = 0; (base = db##_bases[i]) != NULL; i++)                        \
+    {                                                                       \
+      /* do the LDAP search */                                              \
+      search = myldap_search(session, base, db##_scope, filter,             \
+                             db##_attrs, NULL);                             \
+      if (search == NULL)                                                   \
+        return -1;                                                          \
+      /* go over results */                                                 \
+      while ((entry = myldap_get_entry(search, &rc)) != NULL)               \
+      {                                                                     \
+        if (writefn)                                                        \
+          return -1;                                                        \
+      }                                                                     \
+    }                                                                       \
+    /* write the final result code */                                       \
+    if (rc == LDAP_SUCCESS)                                                 \
+    {                                                                       \
+      WRITE_INT32(fp, NSLCD_RESULT_END);                                    \
+    }                                                                       \
+    return 0;                                                               \
   }
 
-/* macro to compare strings
-   Use the ignorecase config option to determine whether or not to do a
-   case-sensitive match */
-#define STR_CMP(str1,str2) \
-  (nslcd_cfg->ldc_ignorecase == 1 ? strcasecmp(str1,str2) : strcmp(str1,str2))
+/* macro to compare strings which uses the ignorecase config option to
+   determine whether or not to do a case-sensitive match */
+#define STR_CMP(str1, str2)                                                 \
+  (nslcd_cfg->ldc_ignorecase == 1 ?                                         \
+    strcasecmp(str1, str2) : strcmp(str1, str2))
 
 #endif /* not NSLCD__COMMON_H */

Modified: nss-pam-ldapd/nslcd/config.c
==============================================================================
--- nss-pam-ldapd/nslcd/config.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/config.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -33,29 +33,29 @@
 #include "log.h"
 #include "cfg.h"
 
-int nslcd_config_get(TFILE *fp,MYLDAP_SESSION *session)
+int nslcd_config_get(TFILE *fp, MYLDAP_SESSION *session)
 {
   int32_t tmpint32;
   int32_t cfgopt;
   /* read request parameters */
-  READ_INT32(fp,cfgopt);
+  READ_INT32(fp, cfgopt);
   /* log call */
-  log_setrequest("config=%d",(int)cfgopt);
-  log_log(LOG_DEBUG,"nslcd_config_get(%d)",(int)cfgopt);
+  log_setrequest("config=%d", (int)cfgopt);
+  log_log(LOG_DEBUG, "nslcd_config_get(%d)", (int)cfgopt);
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_CONFIG_GET);
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_CONFIG_GET);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
   /* validate request */
   switch (cfgopt)
   {
     case NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE:
-      WRITE_STRING(fp,nslcd_cfg->pam_password_prohibit_message);
+      WRITE_STRING(fp, nslcd_cfg->pam_password_prohibit_message);
       break;
     default:
       /* all other config options are ignored */
       break;
   }
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }

Modified: nss-pam-ldapd/nslcd/ether.c
==============================================================================
--- nss-pam-ldapd/nslcd/ether.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/ether.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -55,8 +55,8 @@
 const char *ether_filter = "(objectClass=ieee802Device)";
 
 /* the attributes to request with searches */
-const char *attmap_ether_cn          = "cn";
-const char *attmap_ether_macAddress  = "macAddress";
+const char *attmap_ether_cn         = "cn";
+const char *attmap_ether_macAddress = "macAddress";
 
 /* the attribute list to request with searches */
 static const char *ether_attrs[3];
@@ -64,129 +64,125 @@
 /* create a search filter for searching an ethernet address
    by name, return -1 on errors */
 static int mkfilter_ether_byname(const char *name,
-                                 char *buffer,size_t buflen)
+                                 char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if(myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                   "(&%s(%s=%s))",
-                   ether_filter,
-                   attmap_ether_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    ether_filter, attmap_ether_cn, safename);
 }
 
 static int mkfilter_ether_byether(const char *addrstr,
-                                  char *buffer,size_t buflen)
+                                  char *buffer, size_t buflen)
 {
   /* FIXME: this has a bug when the directory has 01:00:0e:...
-            and we're looking for 1:0:e:... (leading zeros) */
+     and we're looking for 1:0:e:... (leading zeros) */
   /* there should be no characters that need escaping */
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                   "(&%s(%s=%s))",
-                   ether_filter,
-                   attmap_ether_macAddress,addrstr);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    ether_filter, attmap_ether_macAddress, addrstr);
 }
 
 void ether_init(void)
 {
   int i;
   /* set up search bases */
-  if (ether_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      ether_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (ether_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      ether_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (ether_scope==LDAP_SCOPE_DEFAULT)
-    ether_scope=nslcd_cfg->ldc_scope;
+  if (ether_scope == LDAP_SCOPE_DEFAULT)
+    ether_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  ether_attrs[0]=attmap_ether_cn;
-  ether_attrs[1]=attmap_ether_macAddress;
-  ether_attrs[2]=NULL;
+  ether_attrs[0] = attmap_ether_cn;
+  ether_attrs[1] = attmap_ether_macAddress;
+  ether_attrs[2] = NULL;
 }
 
 /* TODO: check for errors in aton() */
-#define WRITE_ETHER(fp,addr) \
-  ether_aton_r(addr,&tmpaddr); \
-  WRITE(fp,&tmpaddr,sizeof(uint8_t[6]));
+#define WRITE_ETHER(fp, addr)                                               \
+  ether_aton_r(addr, &tmpaddr);                                             \
+  WRITE(fp, &tmpaddr, sizeof(uint8_t[6]));
 
-static int write_ether(TFILE *fp,MYLDAP_ENTRY *entry,
-                       const char *reqname,const char *reqether)
+static int write_ether(TFILE *fp, MYLDAP_ENTRY *entry,
+                       const char *reqname, const char *reqether)
 {
   int32_t tmpint32;
   struct ether_addr tmpaddr;
   const char *tmparr[2];
-  const char **names,**ethers;
-  int i,j;
+  const char **names, **ethers;
+  int i, j;
   /* get the name of the ether entry */
-  names=myldap_get_values(entry,attmap_ether_cn);
-  if ((names==NULL)||(names[0]==NULL))
+  names = myldap_get_values(entry, attmap_ether_cn);
+  if ((names == NULL) || (names[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_ether_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_ether_cn);
     return 0;
   }
   /* get the addresses */
-  if (reqether!=NULL)
+  if (reqether != NULL)
   {
-    ethers=tmparr;
-    ethers[0]=reqether;
-    ethers[1]=NULL;
+    ethers = tmparr;
+    ethers[0] = reqether;
+    ethers[1] = NULL;
   }
   else
   {
-    ethers=myldap_get_values(entry,attmap_ether_macAddress);
-    if ((ethers==NULL)||(ethers[0]==NULL))
+    ethers = myldap_get_values(entry, attmap_ether_macAddress);
+    if ((ethers == NULL) || (ethers[0] == NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_ether_macAddress);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_ether_macAddress);
       return 0;
     }
     /* TODO: move parsing of addresses up here */
   }
   /* write entries for all names and addresses */
-  for (i=0;names[i]!=NULL;i++)
-    if ((reqname==NULL)||(strcasecmp(reqname,names[i])==0))
-      for (j=0;ethers[j]!=NULL;j++)
+  for (i = 0; names[i] != NULL; i++)
+    if ((reqname == NULL) || (strcasecmp(reqname, names[i]) == 0))
+      for (j = 0; ethers[j] != NULL; j++)
       {
-        WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-        WRITE_STRING(fp,names[i]);
-        WRITE_ETHER(fp,ethers[j]);
+        WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+        WRITE_STRING(fp, names[i]);
+        WRITE_ETHER(fp, ethers[j]);
       }
   return 0;
 }
 
 NSLCD_HANDLE(
-  ether,byname,
+  ether, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("ether=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("ether=\"%s\"", name);,
   NSLCD_ACTION_ETHER_BYNAME,
-  mkfilter_ether_byname(name,filter,sizeof(filter)),
-  write_ether(fp,entry,name,NULL)
+  mkfilter_ether_byname(name, filter, sizeof(filter)),
+  write_ether(fp, entry, name, NULL)
 )
 
 NSLCD_HANDLE(
-  ether,byether,
+  ether, byether,
   struct ether_addr addr;
   char addrstr[20];
   char filter[4096];
-  READ(fp,&addr,sizeof(uint8_t[6]));
-  if (ether_ntoa_r(&addr,addrstr)==NULL)
+  READ(fp, &addr, sizeof(uint8_t[6]));
+  if (ether_ntoa_r(&addr, addrstr) == NULL)
     return -1;
-  log_setrequest("ether=%s",addrstr);,
+  log_setrequest("ether=%s", addrstr);,
   NSLCD_ACTION_ETHER_BYETHER,
-  mkfilter_ether_byether(addrstr,filter,sizeof(filter)),
-  write_ether(fp,entry,NULL,addrstr)
+  mkfilter_ether_byether(addrstr, filter, sizeof(filter)),
+  write_ether(fp, entry, NULL, addrstr)
 )
 
 NSLCD_HANDLE(
-  ether,all,
+  ether, all,
   const char *filter;
   log_setrequest("ether(all)");,
   NSLCD_ACTION_ETHER_ALL,
-  (filter=ether_filter,0),
-  write_ether(fp,entry,NULL,NULL)
+  (filter = ether_filter, 0),
+  write_ether(fp, entry, NULL, NULL)
 )

Modified: nss-pam-ldapd/nslcd/group.c
==============================================================================
--- nss-pam-ldapd/nslcd/group.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/group.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -61,58 +61,51 @@
 const char *group_filter = "(objectClass=posixGroup)";
 
 /* the attributes to request with searches */
-const char *attmap_group_cn            = "cn";
-const char *attmap_group_userPassword  = "\"*\"";
-const char *attmap_group_gidNumber     = "gidNumber";
-const char *attmap_group_memberUid     = "memberUid";
-const char *attmap_group_member        = "member";
+const char *attmap_group_cn           = "cn";
+const char *attmap_group_userPassword = "\"*\"";
+const char *attmap_group_gidNumber    = "gidNumber";
+const char *attmap_group_memberUid    = "memberUid";
+const char *attmap_group_member       = "member";
 
 /* special property for objectSid-based searches
    (these are already LDAP-escaped strings) */
-static char *gidSid=NULL;
+static char *gidSid = NULL;
 
 /* default values for attributes */
-static const char *default_group_userPassword     = "*"; /* unmatchable */
+static const char *default_group_userPassword = "*"; /* unmatchable */
 
 /* the attribute list to request with searches */
-static const char **group_attrs=NULL;
+static const char **group_attrs = NULL;
 
 /* create a search filter for searching a group entry
    by name, return -1 on errors */
 static int mkfilter_group_byname(const char *name,
-                                 char *buffer,size_t buflen)
+                                 char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if(myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    group_filter,
-                    attmap_group_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    group_filter, attmap_group_cn, safename);
 }
 
 /* create a search filter for searching a group entry
    by gid, return -1 on errors */
-static int mkfilter_group_bygid(gid_t gid,
-                                char *buffer,size_t buflen)
+static int mkfilter_group_bygid(gid_t gid, char *buffer, size_t buflen)
 {
-  if (gidSid!=NULL)
+  if (gidSid != NULL)
   {
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%s\\%02x\\%02x\\%02x\\%02x))",
-                      group_filter,
-                      attmap_group_gidNumber,gidSid,
-                      (int)(gid&0xff),(int)((gid>>8)&0xff),
-                      (int)((gid>>16)&0xff),(int)((gid>>24)&0xff));
+    return mysnprintf(buffer, buflen, "(&%s(%s=%s\\%02x\\%02x\\%02x\\%02x))",
+                      group_filter, attmap_group_gidNumber, gidSid,
+                      (int)(gid & 0xff), (int)((gid >> 8) & 0xff),
+                      (int)((gid >> 16) & 0xff), (int)((gid >> 24) & 0xff));
   }
   else
   {
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%d))",
-                      group_filter,
-                      attmap_group_gidNumber,(int)gid);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%d))",
+                      group_filter, attmap_group_gidNumber, (int)gid);
   }
 }
 
@@ -120,29 +113,26 @@
    by member uid, return -1 on errors */
 static int mkfilter_group_bymember(MYLDAP_SESSION *session,
                                    const char *uid,
-                                   char *buffer,size_t buflen)
+                                   char *buffer, size_t buflen)
 {
   char dn[256];
   char safeuid[300];
   char safedn[300];
   /* escape attribute */
-  if(myldap_escape(uid,safeuid,sizeof(safeuid)))
+  if (myldap_escape(uid, safeuid, sizeof(safeuid)))
     return -1;
   /* try to translate uid to DN */
-  if (uid2dn(session,uid,dn,sizeof(dn))==NULL)
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%s))",
-                      group_filter,
-                      attmap_group_memberUid,safeuid);
+  if (uid2dn(session, uid, dn, sizeof(dn)) == NULL)
+    return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                      group_filter, attmap_group_memberUid, safeuid);
   /* escape DN */
-  if(myldap_escape(dn,safedn,sizeof(safedn)))
+  if (myldap_escape(dn, safedn, sizeof(safedn)))
     return -1;
   /* also lookup using user DN */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(|(%s=%s)(%s=%s)))",
+  return mysnprintf(buffer, buflen, "(&%s(|(%s=%s)(%s=%s)))",
                     group_filter,
-                    attmap_group_memberUid,safeuid,
-                    attmap_group_member,safedn);
+                    attmap_group_memberUid, safeuid,
+                    attmap_group_member, safedn);
 }
 
 void group_init(void)
@@ -150,52 +140,53 @@
   int i;
   SET *set;
   /* set up search bases */
-  if (group_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      group_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (group_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      group_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (group_scope==LDAP_SCOPE_DEFAULT)
-    group_scope=nslcd_cfg->ldc_scope;
+  if (group_scope == LDAP_SCOPE_DEFAULT)
+    group_scope = nslcd_cfg->ldc_scope;
   /* special case when gidNumber references objectSid */
-  if (strncasecmp(attmap_group_gidNumber,"objectSid:",10)==0)
+  if (strncasecmp(attmap_group_gidNumber, "objectSid:", 10) == 0)
   {
-    gidSid=sid2search(attmap_group_gidNumber+10);
-    attmap_group_gidNumber=strndup(attmap_group_gidNumber,9);
+    gidSid = sid2search(attmap_group_gidNumber + 10);
+    attmap_group_gidNumber = strndup(attmap_group_gidNumber, 9);
   }
   /* set up attribute list */
-  set=set_new();
-  attmap_add_attributes(set,attmap_group_cn);
-  attmap_add_attributes(set,attmap_group_userPassword);
-  attmap_add_attributes(set,attmap_group_memberUid);
-  attmap_add_attributes(set,attmap_group_gidNumber);
-  attmap_add_attributes(set,attmap_group_member);
-  group_attrs=set_tolist(set);
+  set = set_new();
+  attmap_add_attributes(set, attmap_group_cn);
+  attmap_add_attributes(set, attmap_group_userPassword);
+  attmap_add_attributes(set, attmap_group_memberUid);
+  attmap_add_attributes(set, attmap_group_gidNumber);
+  attmap_add_attributes(set, attmap_group_member);
+  group_attrs = set_tolist(set);
   set_free(set);
 }
 
-static int do_write_group(
-    TFILE *fp,MYLDAP_ENTRY *entry,const char **names,gid_t gids[],int numgids,
-    const char *passwd,const char **members,const char *reqname)
+static int do_write_group(TFILE *fp, MYLDAP_ENTRY *entry,
+                          const char **names, gid_t gids[], int numgids,
+                          const char *passwd, const char **members,
+                          const char *reqname)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  int i,j;
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  int i, j;
   /* write entries for all names and gids */
-  for (i=0;names[i]!=NULL;i++)
+  for (i = 0; names[i] != NULL; i++)
   {
     if (!isvalidname(names[i]))
     {
-      log_log(LOG_WARNING,"%s: %s: denied by validnames option",
-                          myldap_get_dn(entry),attmap_group_cn);
+      log_log(LOG_WARNING, "%s: %s: denied by validnames option",
+              myldap_get_dn(entry), attmap_group_cn);
     }
-    else if ((reqname==NULL)||(STR_CMP(reqname,names[i])==0))
+    else if ((reqname == NULL) || (STR_CMP(reqname, names[i]) == 0))
     {
-      for (j=0;j<numgids;j++)
+      for (j = 0; j < numgids; j++)
       {
-        WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-        WRITE_STRING(fp,names[i]);
-        WRITE_STRING(fp,passwd);
-        WRITE_INT32(fp,gids[j]);
-        WRITE_STRINGLIST(fp,members);
+        WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+        WRITE_STRING(fp, names[i]);
+        WRITE_STRING(fp, passwd);
+        WRITE_INT32(fp, gids[j]);
+        WRITE_STRINGLIST(fp, members);
       }
     }
   }
@@ -203,35 +194,35 @@
 }
 
 /* return the list of members */
-static const char **getmembers(MYLDAP_ENTRY *entry,MYLDAP_SESSION *session)
+static const char **getmembers(MYLDAP_ENTRY *entry, MYLDAP_SESSION *session)
 {
   char buf[256];
   int i;
   const char **values;
   SET *set;
-  set=set_new();
-  if (set==NULL)
+  set = set_new();
+  if (set == NULL)
     return NULL;
   /* add the memberUid values */
-  values=myldap_get_values(entry,attmap_group_memberUid);
-  if (values!=NULL)
-    for (i=0;values[i]!=NULL;i++)
+  values = myldap_get_values(entry, attmap_group_memberUid);
+  if (values != NULL)
+    for (i = 0; values[i] != NULL; i++)
     {
       /* only add valid usernames */
       if (isvalidname(values[i]))
-        set_add(set,values[i]);
+        set_add(set, values[i]);
     }
   /* add the member values */
-  values=myldap_get_values(entry,attmap_group_member);
-  if (values!=NULL)
-    for (i=0;values[i]!=NULL;i++)
+  values = myldap_get_values(entry, attmap_group_member);
+  if (values != NULL)
+    for (i = 0; values[i] != NULL; i++)
     {
       /* transform the DN into a uid (dn2uid() already checks validity) */
-      if (dn2uid(session,values[i],buf,sizeof(buf))!=NULL)
-        set_add(set,buf);
+      if (dn2uid(session, values[i], buf, sizeof(buf)) != NULL)
+        set_add(set, buf);
     }
   /* return the members */
-  values=set_tolist(set);
+  values = set_tolist(set);
   set_free(set);
   return values;
 }
@@ -239,11 +230,11 @@
 /* the maximum number of gidNumber attributes per entry */
 #define MAXGIDS_PER_ENTRY 5
 
-static int write_group(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname,
-                       const gid_t *reqgid,int wantmembers,
+static int write_group(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqname,
+                       const gid_t *reqgid, int wantmembers,
                        MYLDAP_SESSION *session)
 {
-  const char **names,**gidvalues;
+  const char **names, **gidvalues;
   const char *passwd;
   const char **members;
   gid_t gids[MAXGIDS_PER_ENTRY];
@@ -252,126 +243,129 @@
   char passbuffer[64];
   int rc;
   /* get group name (cn) */
-  names=myldap_get_values(entry,attmap_group_cn);
-  if ((names==NULL)||(names[0]==NULL))
+  names = myldap_get_values(entry, attmap_group_cn);
+  if ((names == NULL) || (names[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_group_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_group_cn);
     return 0;
   }
   /* get the group id(s) */
-  if (reqgid!=NULL)
+  if (reqgid != NULL)
   {
-    gids[0]=*reqgid;
-    numgids=1;
+    gids[0] = *reqgid;
+    numgids = 1;
   }
   else
   {
-    gidvalues=myldap_get_values_len(entry,attmap_group_gidNumber);
-    if ((gidvalues==NULL)||(gidvalues[0]==NULL))
+    gidvalues = myldap_get_values_len(entry, attmap_group_gidNumber);
+    if ((gidvalues == NULL) || (gidvalues[0] == NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_group_gidNumber);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_group_gidNumber);
       return 0;
     }
-    for 
(numgids=0;(numgids<MAXGIDS_PER_ENTRY)&&(gidvalues[numgids]!=NULL);numgids++)
+    for (numgids = 0; (numgids < MAXGIDS_PER_ENTRY) && (gidvalues[numgids] != 
NULL); numgids++)
     {
-      if (gidSid!=NULL)
-        gids[numgids]=(gid_t)binsid2id(gidvalues[numgids]);
+      if (gidSid != NULL)
+        gids[numgids] = (gid_t)binsid2id(gidvalues[numgids]);
       else
       {
-        errno=0;
-        gids[numgids]=strtogid(gidvalues[numgids],&tmp,10);
-        if ((*(gidvalues[numgids])=='\0')||(*tmp!='\0'))
+        errno = 0;
+        gids[numgids] = strtogid(gidvalues[numgids], &tmp, 10);
+        if ((*(gidvalues[numgids]) == '\0') || (*tmp != '\0'))
         {
-          log_log(LOG_WARNING,"%s: %s: non-numeric",
-                              myldap_get_dn(entry),attmap_group_gidNumber);
+          log_log(LOG_WARNING, "%s: %s: non-numeric",
+                  myldap_get_dn(entry), attmap_group_gidNumber);
           return 0;
         }
-        else if ((errno!=0)||(strchr(gidvalues[numgids],'-')!=NULL))
+        else if ((errno != 0) || (strchr(gidvalues[numgids], '-') != NULL))
         {
-          log_log(LOG_WARNING,"%s: %s: out of range",
-                              myldap_get_dn(entry),attmap_group_gidNumber);
+          log_log(LOG_WARNING, "%s: %s: out of range",
+                  myldap_get_dn(entry), attmap_group_gidNumber);
           return 0;
         }
       }
     }
   }
   /* get group passwd (userPassword) (use only first entry) */
-  
passwd=get_userpassword(entry,attmap_group_userPassword,passbuffer,sizeof(passbuffer));
-  if (passwd==NULL)
-    passwd=default_group_userPassword;
+  passwd = get_userpassword(entry, attmap_group_userPassword,
+                            passbuffer, sizeof(passbuffer));
+  if (passwd == NULL)
+    passwd = default_group_userPassword;
   /* get group memebers (memberUid&member) */
   if (wantmembers)
-    members=getmembers(entry,session);
+    members = getmembers(entry, session);
   else
-    members=NULL;
+    members = NULL;
   /* write entries (split to a separate function so we can ensure the call
      to free() below in case a write fails) */
-  rc=do_write_group(fp,entry,names,gids,numgids,passwd,members,reqname);
+  rc = do_write_group(fp, entry, names, gids, numgids, passwd, members,
+                      reqname);
   /* free and return */
-  if (members!=NULL)
+  if (members != NULL)
     free(members);
   return rc;
 }
 
 NSLCD_HANDLE(
-  group,byname,
+  group, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("group=\"%s\"",name);
-  if (!isvalidname(name)) {
-    log_log(LOG_WARNING,"request denied by validnames option");
+  READ_STRING(fp, name);
+  log_setrequest("group=\"%s\"", name);
+  if (!isvalidname(name))
+  {
+    log_log(LOG_WARNING, "request denied by validnames option");
     return -1;
   },
   NSLCD_ACTION_GROUP_BYNAME,
-  mkfilter_group_byname(name,filter,sizeof(filter)),
-  write_group(fp,entry,name,NULL,1,session)
+  mkfilter_group_byname(name, filter, sizeof(filter)),
+  write_group(fp, entry, name, NULL, 1, session)
 )
 
 NSLCD_HANDLE(
-  group,bygid,
+  group, bygid,
   gid_t gid;
   char filter[4096];
-  READ_INT32(fp,gid);
-  log_setrequest("group=%lu",(unsigned long int)gid);,
+  READ_INT32(fp, gid);
+  log_setrequest("group=%lu", (unsigned long int)gid);,
   NSLCD_ACTION_GROUP_BYGID,
-  mkfilter_group_bygid(gid,filter,sizeof(filter)),
-  write_group(fp,entry,NULL,&gid,1,session)
+  mkfilter_group_bygid(gid, filter, sizeof(filter)),
+  write_group(fp, entry, NULL, &gid, 1, session)
 )
 
 NSLCD_HANDLE(
-  group,bymember,
+  group, bymember,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("group/member=\"%s\"",name);
+  READ_STRING(fp, name);
+  log_setrequest("group/member=\"%s\"", name);
   if (!isvalidname(name))
   {
-    log_log(LOG_WARNING,"request denied by validnames option");
+    log_log(LOG_WARNING, "request denied by validnames option");
     return -1;
   }
-  if ((nslcd_cfg->ldc_nss_initgroups_ignoreusers!=NULL)&&
-      set_contains(nslcd_cfg->ldc_nss_initgroups_ignoreusers,name))
+  if ((nslcd_cfg->ldc_nss_initgroups_ignoreusers != NULL) &&
+      set_contains(nslcd_cfg->ldc_nss_initgroups_ignoreusers, name))
   {
-    log_log(LOG_DEBUG,"ignored group member");
+    log_log(LOG_DEBUG, "ignored group member");
     /* just end the request, returning no results */
-    WRITE_INT32(fp,NSLCD_VERSION);
-    WRITE_INT32(fp,NSLCD_ACTION_GROUP_BYMEMBER);
-    WRITE_INT32(fp,NSLCD_RESULT_END);
+    WRITE_INT32(fp, NSLCD_VERSION);
+    WRITE_INT32(fp, NSLCD_ACTION_GROUP_BYMEMBER);
+    WRITE_INT32(fp, NSLCD_RESULT_END);
     return 0;
   },
   NSLCD_ACTION_GROUP_BYMEMBER,
-  mkfilter_group_bymember(session,name,filter,sizeof(filter)),
-  write_group(fp,entry,NULL,NULL,0,session)
+  mkfilter_group_bymember(session, name, filter, sizeof(filter)),
+  write_group(fp, entry, NULL, NULL, 0, session)
 )
 
 NSLCD_HANDLE(
-  group,all,
+  group, all,
   const char *filter;
   log_setrequest("group(all)");,
   NSLCD_ACTION_GROUP_ALL,
-  (filter=group_filter,0),
-  write_group(fp,entry,NULL,NULL,1,session)
+  (filter = group_filter, 0),
+  write_group(fp, entry, NULL, NULL, 1, session)
 )

Modified: nss-pam-ldapd/nslcd/host.c
==============================================================================
--- nss-pam-ldapd/nslcd/host.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/host.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -56,137 +56,133 @@
 const char *host_filter = "(objectClass=ipHost)";
 
 /* the attributes to request with searches */
-const char *attmap_host_cn            = "cn";
-const char *attmap_host_ipHostNumber  = "ipHostNumber";
+const char *attmap_host_cn           = "cn";
+const char *attmap_host_ipHostNumber = "ipHostNumber";
 
 /* the attribute list to request with searches */
 static const char *host_attrs[3];
 
 /* create a search filter for searching a host entry
    by name, return -1 on errors */
-static int mkfilter_host_byname(const char *name,
-                                char *buffer,size_t buflen)
+static int mkfilter_host_byname(const char *name, char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    host_filter,
-                    attmap_host_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    host_filter, attmap_host_cn, safename);
 }
 
 static int mkfilter_host_byaddr(const char *addrstr,
-                                char *buffer,size_t buflen)
+                                char *buffer, size_t buflen)
 {
   char safeaddr[64];
   /* escape attribute */
-  if (myldap_escape(addrstr,safeaddr,sizeof(safeaddr)))
+  if (myldap_escape(addrstr, safeaddr, sizeof(safeaddr)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    host_filter,
-                    attmap_host_ipHostNumber,safeaddr);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    host_filter, attmap_host_ipHostNumber, safeaddr);
 }
 
 void host_init(void)
 {
   int i;
   /* set up search bases */
-  if (host_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      host_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (host_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      host_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (host_scope==LDAP_SCOPE_DEFAULT)
-    host_scope=nslcd_cfg->ldc_scope;
+  if (host_scope == LDAP_SCOPE_DEFAULT)
+    host_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  host_attrs[0]=attmap_host_cn;
-  host_attrs[1]=attmap_host_ipHostNumber;
-  host_attrs[2]=NULL;
+  host_attrs[0] = attmap_host_cn;
+  host_attrs[1] = attmap_host_ipHostNumber;
+  host_attrs[2] = NULL;
 }
 
 /* write a single host entry to the stream */
-static int write_host(TFILE *fp,MYLDAP_ENTRY *entry)
+static int write_host(TFILE *fp, MYLDAP_ENTRY *entry)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  int numaddr,i;
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  int numaddr, i;
   const char *hostname;
   const char **hostnames;
   const char **addresses;
   /* get the most canonical name */
-  hostname=myldap_get_rdn_value(entry,attmap_host_cn);
+  hostname = myldap_get_rdn_value(entry, attmap_host_cn);
   /* get the other names for the host */
-  hostnames=myldap_get_values(entry,attmap_host_cn);
-  if ((hostnames==NULL)||(hostnames[0]==NULL))
+  hostnames = myldap_get_values(entry, attmap_host_cn);
+  if ((hostnames == NULL) || (hostnames[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_host_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_host_cn);
     return 0;
   }
   /* if the hostname is not yet found, get the first entry from hostnames */
-  if (hostname==NULL)
-    hostname=hostnames[0];
+  if (hostname == NULL)
+    hostname = hostnames[0];
   /* get the addresses */
-  addresses=myldap_get_values(entry,attmap_host_ipHostNumber);
-  if ((addresses==NULL)||(addresses[0]==NULL))
+  addresses = myldap_get_values(entry, attmap_host_ipHostNumber);
+  if ((addresses == NULL) || (addresses[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_host_ipHostNumber);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_host_ipHostNumber);
     return 0;
   }
   /* write the entry */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_STRING(fp,hostname);
-  WRITE_STRINGLIST_EXCEPT(fp,hostnames,hostname);
-  for (numaddr=0;addresses[numaddr]!=NULL;numaddr++)
-    /*noting*/ ;
-  WRITE_INT32(fp,numaddr);
-  for (i=0;i<numaddr;i++)
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_STRING(fp, hostname);
+  WRITE_STRINGLIST_EXCEPT(fp, hostnames, hostname);
+  for (numaddr = 0; addresses[numaddr] != NULL; numaddr++)
+    /* noting */ ;
+  WRITE_INT32(fp, numaddr);
+  for (i = 0; i < numaddr; i++)
   {
-    WRITE_ADDRESS(fp,entry,attmap_host_ipHostNumber,addresses[i]);
+    WRITE_ADDRESS(fp, entry, attmap_host_ipHostNumber, addresses[i]);
   }
   return 0;
 }
 
 NSLCD_HANDLE(
-  host,byname,
+  host, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("host=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("host=\"%s\"", name);,
   NSLCD_ACTION_HOST_BYNAME,
-  mkfilter_host_byname(name,filter,sizeof(filter)),
-  write_host(fp,entry)
+  mkfilter_host_byname(name, filter, sizeof(filter)),
+  write_host(fp, entry)
 )
 
 NSLCD_HANDLE(
-  host,byaddr,
+  host, byaddr,
   int af;
   char addr[64];
-  int len=sizeof(addr);
+  int len = sizeof(addr);
   char addrstr[64];
   char filter[4096];
-  READ_ADDRESS(fp,addr,len,af);
+  READ_ADDRESS(fp, addr, len, af);
   /* translate the address to a string */
-  if (inet_ntop(af,addr,addrstr,sizeof(addrstr))==NULL)
+  if (inet_ntop(af, addr, addrstr, sizeof(addrstr)) == NULL)
   {
-    log_log(LOG_WARNING,"unable to convert address to string");
+    log_log(LOG_WARNING, "unable to convert address to string");
     return -1;
   }
-  log_setrequest("host=%s",addrstr);,
+  log_setrequest("host=%s", addrstr);,
   NSLCD_ACTION_HOST_BYADDR,
-  mkfilter_host_byaddr(addrstr,filter,sizeof(filter)),
-  write_host(fp,entry)
+  mkfilter_host_byaddr(addrstr, filter, sizeof(filter)),
+  write_host(fp, entry)
 )
 
+
 NSLCD_HANDLE(
-  host,all,
+  host, all,
   const char *filter;
   log_setrequest("host(all)");,
   NSLCD_ACTION_HOST_ALL,
-  (filter=host_filter,0),
-  write_host(fp,entry)
+  (filter = host_filter, 0),
+  write_host(fp, entry)
 )

Modified: nss-pam-ldapd/nslcd/log.c
==============================================================================
--- nss-pam-ldapd/nslcd/log.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/log.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    log.c - logging funtions
 
-   Copyright (C) 2002, 2003, 2008, 2010, 2011 Arthur de Jong
+   Copyright (C) 2002, 2003, 2008, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -38,30 +38,30 @@
 #define PACKAGE "nslcd"
 
 /* default loglevel when no logging is configured */
-static int prelogging_loglevel=LOG_INFO;
+static int prelogging_loglevel = LOG_INFO;
 
 /* loglevel to use before logging to syslog */
-static int loglevel=LOG_INFO;
+static int loglevel = LOG_INFO;
 
 /* the session id that is set for this thread */
-static __thread char *sessionid=NULL;
+static __thread char *sessionid = NULL;
 
 /* the request identifier that is set for this thread */
-static __thread char *requestid=NULL;
+static __thread char *requestid = NULL;
 #define MAX_REQUESTID_LENGTH 40
 
 /* set loglevel when no logging is configured */
 void log_setdefaultloglevel(int pri)
 {
-  prelogging_loglevel=pri;
+  prelogging_loglevel = pri;
 }
 
 /* start the logging with the configured logging methods
    if no method is configured yet, logging is done to syslog */
 void log_startlogging(void)
 {
-  openlog(PACKAGE,LOG_PID,LOG_DAEMON);
-  prelogging_loglevel=-1;
+  openlog(PACKAGE, LOG_PID, LOG_DAEMON);
+  prelogging_loglevel = -1;
 }
 
 /* indicate that we should clear any session identifiers set by
@@ -69,11 +69,11 @@
 void log_clearsession(void)
 {
   /* set the session id to empty */
-  if (sessionid!=NULL)
-    sessionid[0]='\0';
+  if (sessionid != NULL)
+    sessionid[0] = '\0';
   /* set the request id to empty */
-  if (requestid!=NULL)
-    requestid[0]='\0';
+  if (requestid != NULL)
+    requestid[0] = '\0';
 }
 
 /* indicate that a session id should be included in the output
@@ -81,19 +81,19 @@
 void log_newsession(void)
 {
   /* ensure that sessionid can hold a string */
-  if (sessionid==NULL)
+  if (sessionid == NULL)
   {
-    sessionid=(char *)malloc(7);
-    if (sessionid==NULL)
+    sessionid = (char *)malloc(7);
+    if (sessionid == NULL)
     {
-      fprintf(stderr,"malloc() failed: %s",strerror(errno));
+      fprintf(stderr, "malloc() failed: %s", strerror(errno));
       return; /* silently fail */
     }
   }
-  sprintf(sessionid,"%06x",(int)(rand()&0xffffff));
+  sprintf(sessionid, "%06x", (int)(rand() & 0xffffff));
   /* set the request id to empty */
-  if (requestid!=NULL)
-    requestid[0]='\0';
+  if (requestid != NULL)
+    requestid[0] = '\0';
 }
 
 /* indicate that a request identifier should be included in the output
@@ -102,64 +102,67 @@
 {
   va_list ap;
   /* ensure that requestid can hold a string */
-  if (requestid==NULL)
+  if (requestid == NULL)
   {
-    requestid=(char *)malloc(MAX_REQUESTID_LENGTH);
-    if (requestid==NULL)
+    requestid = (char *)malloc(MAX_REQUESTID_LENGTH);
+    if (requestid == NULL)
     {
-      fprintf(stderr,"malloc() failed: %s",strerror(errno));
+      fprintf(stderr, "malloc() failed: %s", strerror(errno));
       return; /* silently fail */
     }
   }
   /* make the message */
-  va_start(ap,format);
-  vsnprintf(requestid,MAX_REQUESTID_LENGTH,format,ap);
-  requestid[MAX_REQUESTID_LENGTH-1]='\0';
+  va_start(ap, format);
+  vsnprintf(requestid, MAX_REQUESTID_LENGTH, format, ap);
+  requestid[MAX_REQUESTID_LENGTH - 1] = '\0';
   va_end(ap);
 }
 
 /* log the given message using the configured logging method */
-void log_log(int pri,const char *format, ...)
+void log_log(int pri, const char *format, ...)
 {
   int res;
   char buffer[200];
   va_list ap;
   /* make the message */
-  va_start(ap,format);
-  res=vsnprintf(buffer,sizeof(buffer),format,ap);
-  if ((res<0)||(res>=(int)sizeof(buffer)))
+  va_start(ap, format);
+  res = vsnprintf(buffer, sizeof(buffer), format, ap);
+  if ((res < 0) || (res >= (int)sizeof(buffer)))
   {
     /* truncate with "..." */
-    buffer[sizeof(buffer)-2]='.';
-    buffer[sizeof(buffer)-3]='.';
-    buffer[sizeof(buffer)-4]='.';
+    buffer[sizeof(buffer) - 2] = '.';
+    buffer[sizeof(buffer) - 3] = '.';
+    buffer[sizeof(buffer) - 4] = '.';
   }
-  buffer[sizeof(buffer)-1]='\0';
+  buffer[sizeof(buffer) - 1] = '\0';
   va_end(ap);
   /* do the logging */
-  if (prelogging_loglevel>=0)
+  if (prelogging_loglevel >= 0)
   {
     /* if logging is not yet defined, log to stderr */
-    if (pri<=prelogging_loglevel)
+    if (pri <= prelogging_loglevel)
     {
-      if ((requestid!=NULL)&&(requestid[0]!='\0'))
-        fprintf(stderr,"%s: [%s] <%s> 
%s%s\n",PACKAGE,sessionid,requestid,pri==LOG_DEBUG?"DEBUG: ":"",buffer);
-      else if ((sessionid!=NULL)&&(sessionid[0]!='\0'))
-        fprintf(stderr,"%s: [%s] 
%s%s\n",PACKAGE,sessionid,pri==LOG_DEBUG?"DEBUG: ":"",buffer);
+      if ((requestid != NULL) && (requestid[0] != '\0'))
+        fprintf(stderr, "%s: [%s] <%s> %s%s\n", PACKAGE, sessionid, requestid,
+                pri == LOG_DEBUG ? "DEBUG: " : "", buffer);
+      else if ((sessionid != NULL) && (sessionid[0] != '\0'))
+        fprintf(stderr, "%s: [%s] %s%s\n", PACKAGE, sessionid,
+                pri == LOG_DEBUG ? "DEBUG: " : "", buffer);
       else
-        fprintf(stderr,"%s: %s%s\n",PACKAGE,pri==LOG_DEBUG?"DEBUG: 
":"",buffer);
+        fprintf(stderr, "%s: %s%s\n", PACKAGE,
+                pri == LOG_DEBUG ? "DEBUG: " : "", buffer);
     }
   }
   else
   {
-    if (pri<=loglevel)
+    if (pri <= loglevel)
     {
-      if ((requestid!=NULL)&&(requestid[0]!='\0'))
-        syslog(pri,"[%s] <%s> %s",sessionid,requestid,buffer);
-      else if ((sessionid!=NULL)&&(sessionid[0]!='\0'))
-        syslog(pri,"[%s] %s",sessionid,buffer);
+      if ((requestid != NULL) && (requestid[0] != '\0'))
+        syslog(pri, "[%s] <%s> %s", sessionid, requestid, buffer);
+      else if ((sessionid != NULL) && (sessionid[0] != '\0'))
+        syslog(pri, "[%s] %s", sessionid, buffer);
       else
-        syslog(pri,"%s",buffer);
+        syslog(pri, "%s", buffer);
     }
   }
 }

Modified: nss-pam-ldapd/nslcd/log.h
==============================================================================
--- nss-pam-ldapd/nslcd/log.h   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/log.h   Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    log.h - definitions of logging funtions
 
-   Copyright (C) 2002, 2003, 2007, 2008, 2010, 2011 Arthur de Jong
+   Copyright (C) 2002, 2003, 2007, 2008, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -44,10 +44,10 @@
 /* indicate that a request identifier should be included in the output
    from this point on, until log_newsession() is called */
 void log_setrequest(const char *format, ...)
-  LIKE_PRINTF(1,2);
+  LIKE_PRINTF(1, 2);
 
 /* log the given message using the configured logging method */
-void log_log(int pri,const char *format, ...)
-  LIKE_PRINTF(2,3);
+void log_log(int pri, const char *format, ...)
+  LIKE_PRINTF(2, 3);
 
 #endif /* not NSLCD__LOG_H */

Modified: nss-pam-ldapd/nslcd/myldap.c
==============================================================================
--- nss-pam-ldapd/nslcd/myldap.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/myldap.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -81,8 +81,7 @@
 
 /* This refers to a current LDAP session that contains the connection
    information. */
-struct ldap_session
-{
+struct ldap_session {
   /* the connection */
   LDAP *ld;
   /* the username to bind with */
@@ -98,8 +97,7 @@
 };
 
 /* A search description set as returned by myldap_search(). */
-struct myldap_search
-{
+struct myldap_search {
   /* reference to the session */
   MYLDAP_SESSION *session;
   /* indicator that the search is still valid */
@@ -134,8 +132,7 @@
 
 /* A single entry from the LDAP database as returned by
    myldap_get_entry(). */
-struct myldap_entry
-{
+struct myldap_entry {
   /* reference to the search to be used to get parameters
      (e.g. LDAP connection) for other calls */
   MYLDAP_SEARCH *search;
@@ -149,37 +146,37 @@
   char **rangedattributevalues[MAX_RANGED_ATTRIBUTES_PER_ENTRY];
 };
 
-static void myldap_err(int pri,LDAP *ld,int rc,const char *format, ...)
+static void myldap_err(int pri, LDAP *ld, int rc, const char *format, ...)
 {
   char message[200];
-  char *msg_ldap=NULL;
-  char *msg_diag=NULL;
-  char *msg_errno=NULL;
+  char *msg_ldap = NULL;
+  char *msg_diag = NULL;
+  char *msg_errno = NULL;
   va_list ap;
   /* make the message */
-  va_start(ap,format);
-  vsnprintf(message,sizeof(message),format,ap);
-  message[sizeof(message)-1]='\0';
+  va_start(ap, format);
+  vsnprintf(message, sizeof(message), format, ap);
+  message[sizeof(message) - 1] = '\0';
   va_end(ap);
   /* get the various error message */
-  if (rc!=LDAP_SUCCESS)
+  if (rc != LDAP_SUCCESS)
   {
-    msg_ldap=ldap_err2string(rc);
+    msg_ldap = ldap_err2string(rc);
     /* get the diagnostic information */
 #ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
-    if (ld!=NULL)
-      ldap_get_option(ld,LDAP_OPT_DIAGNOSTIC_MESSAGE,&msg_diag);
+    if (ld != NULL)
+      ldap_get_option(ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, &msg_diag);
 #endif /* LDAP_OPT_DIAGNOSTIC_MESSAGE */
   }
-  if (errno!=0)
-    msg_errno=strerror(errno);
+  if (errno != 0)
+    msg_errno = strerror(errno);
   /* log the message */
-  log_log(pri,"%s%s%s%s%s%s%s",message,
-          (msg_ldap==NULL)?"":": ",(msg_ldap==NULL)?"":msg_ldap,
-          (msg_diag==NULL)?"":": ",(msg_diag==NULL)?"":msg_diag,
-          (msg_errno==NULL)?"":": ",(msg_errno==NULL)?"":msg_errno);
+  log_log(pri, "%s%s%s%s%s%s%s", message,
+          (msg_ldap == NULL) ? "" : ": ", (msg_ldap == NULL) ? "" : msg_ldap,
+          (msg_diag == NULL) ? "" : ": ", (msg_diag == NULL) ? "" : msg_diag,
+          (msg_errno == NULL) ? "" : ": ", (msg_errno == NULL) ? "" : 
msg_errno);
   /* free diagnostic message */
-  if (msg_diag!=NULL)
+  if (msg_diag != NULL)
     ldap_memfree(msg_diag);
 }
 
@@ -190,20 +187,20 @@
   /* Note: as an alternative we could embed the myldap_entry into the
      myldap_search struct to save on malloc() and free() calls. */
   /* allocate new entry */
-  entry=(MYLDAP_ENTRY *)malloc(sizeof(struct myldap_entry));
-  if (entry==NULL)
+  entry = (MYLDAP_ENTRY *)malloc(sizeof(struct myldap_entry));
+  if (entry == NULL)
   {
-    log_log(LOG_CRIT,"myldap_entry_new(): malloc() failed to allocate memory");
+    log_log(LOG_CRIT, "myldap_entry_new(): malloc() failed to allocate 
memory");
     exit(EXIT_FAILURE);
   }
   /* fill in fields */
-  entry->search=search;
-  entry->dn=NULL;
-  entry->exploded_rdn=NULL;
-  for (i=0;i<MAX_ATTRIBUTES_PER_ENTRY;i++)
-    entry->attributevalues[i]=NULL;
-  for (i=0;i<MAX_RANGED_ATTRIBUTES_PER_ENTRY;i++)
-    entry->rangedattributevalues[i]=NULL;
+  entry->search = search;
+  entry->dn = NULL;
+  entry->exploded_rdn = NULL;
+  for (i = 0; i < MAX_ATTRIBUTES_PER_ENTRY; i++)
+    entry->attributevalues[i] = NULL;
+  for (i = 0; i < MAX_RANGED_ATTRIBUTES_PER_ENTRY; i++)
+    entry->rangedattributevalues[i] = NULL;
   /* return the fresh entry */
   return entry;
 }
@@ -212,29 +209,30 @@
 {
   int i;
   /* free the DN */
-  if (entry->dn!=NULL)
+  if (entry->dn != NULL)
     ldap_memfree((char *)entry->dn);
   /* free the exploded RDN */
-  if (entry->exploded_rdn!=NULL)
+  if (entry->exploded_rdn != NULL)
     ldap_value_free(entry->exploded_rdn);
   /* free all attribute values */
-  for (i=0;i<MAX_ATTRIBUTES_PER_ENTRY;i++)
-    if (entry->attributevalues[i]!=NULL)
+  for (i = 0; i < MAX_ATTRIBUTES_PER_ENTRY; i++)
+    if (entry->attributevalues[i] != NULL)
       ldap_value_free(entry->attributevalues[i]);
   /* free all ranged attribute values */
-  for (i=0;i<MAX_RANGED_ATTRIBUTES_PER_ENTRY;i++)
-    if (entry->rangedattributevalues[i]!=NULL)
+  for (i = 0; i < MAX_RANGED_ATTRIBUTES_PER_ENTRY; i++)
+    if (entry->rangedattributevalues[i] != NULL)
       free(entry->rangedattributevalues[i]);
   /* we don't need the result anymore, ditch it. */
   ldap_msgfree(entry->search->msg);
-  entry->search->msg=NULL;
+  entry->search->msg = NULL;
   /* free the actual memory for the struct */
   free(entry);
 }
 
-static MYLDAP_SEARCH *myldap_search_new(
-        MYLDAP_SESSION *session,
-        const char *base,int scope,const char *filter,const char **attrs)
+static MYLDAP_SEARCH *myldap_search_new(MYLDAP_SESSION *session,
+                                        const char *base, int scope,
+                                        const char *filter,
+                                        const char **attrs)
 {
   char *buffer;
   MYLDAP_SEARCH *search;
@@ -242,54 +240,54 @@
   size_t sz;
   /* figure out size for new memory block to allocate
      this has the advantage that we can free the whole lot with one call */
-  sz=sizeof(struct myldap_search);
-  sz+=strlen(base)+1+strlen(filter)+1;
-  for (i=0;attrs[i]!=NULL;i++)
-    sz+=strlen(attrs[i])+1;
-  sz+=(i+1)*sizeof(char *);
+  sz = sizeof(struct myldap_search);
+  sz += strlen(base) + 1 + strlen(filter) + 1;
+  for (i = 0; attrs[i] != NULL; i++)
+    sz += strlen(attrs[i]) + 1;
+  sz += (i + 1) * sizeof(char *);
   /* allocate new results memory region */
-  buffer=(char *)malloc(sz);
-  if (buffer==NULL)
+  buffer = (char *)malloc(sz);
+  if (buffer == NULL)
   {
-    log_log(LOG_CRIT,"myldap_search_new(): malloc() failed to allocate 
memory");
+    log_log(LOG_CRIT, "myldap_search_new(): malloc() failed to allocate 
memory");
     exit(EXIT_FAILURE);
   }
   /* initialize struct */
-  search=(MYLDAP_SEARCH *)(void *)(buffer);
-  buffer+=sizeof(struct myldap_search);
+  search = (MYLDAP_SEARCH *)(void *)(buffer);
+  buffer += sizeof(struct myldap_search);
   /* save pointer to session */
-  search->session=session;
+  search->session = session;
   /* flag as valid search */
-  search->valid=1;
+  search->valid = 1;
   /* initialize array of attributes */
-  search->attrs=(char **)(void *)buffer;
-  buffer+=(i+1)*sizeof(char *);
+  search->attrs = (char **)(void *)buffer;
+  buffer += (i + 1) * sizeof(char *);
   /* copy base */
-  strcpy(buffer,base);
-  search->base=buffer;
-  buffer+=strlen(base)+1;
+  strcpy(buffer, base);
+  search->base = buffer;
+  buffer += strlen(base) + 1;
   /* just plainly store scope */
-  search->scope=scope;
+  search->scope = scope;
   /* copy filter */
-  strcpy(buffer,filter);
-  search->filter=buffer;
-  buffer+=strlen(filter)+1;
+  strcpy(buffer, filter);
+  search->filter = buffer;
+  buffer += strlen(filter) + 1;
   /* copy attributes themselves */
-  for (i=0;attrs[i]!=NULL;i++)
+  for (i = 0; attrs[i] != NULL; i++)
   {
-    strcpy(buffer,attrs[i]);
-    search->attrs[i]=buffer;
-    buffer+=strlen(attrs[i])+1;
+    strcpy(buffer, attrs[i]);
+    search->attrs[i] = buffer;
+    buffer += strlen(attrs[i]) + 1;
   }
-  search->attrs[i]=NULL;
+  search->attrs[i] = NULL;
   /* initialize context */
-  search->cookie=NULL;
-  search->msg=NULL;
-  search->msgid=-1;
-  search->may_retry_search=1;
+  search->cookie = NULL;
+  search->msg = NULL;
+  search->msgid = -1;
+  search->may_retry_search = 1;
   /* clear result entry */
-  search->entry=NULL;
-  search->count=0;
+  search->entry = NULL;
+  search->count = 0;
   /* return the new search struct */
   return search;
 }
@@ -299,94 +297,99 @@
   MYLDAP_SESSION *session;
   int i;
   /* allocate memory for the session storage */
-  session=(struct ldap_session *)malloc(sizeof(struct ldap_session));
-  if (session==NULL)
+  session = (struct ldap_session *)malloc(sizeof(struct ldap_session));
+  if (session == NULL)
   {
-    log_log(LOG_CRIT,"myldap_session_new(): malloc() failed to allocate 
memory");
+    log_log(LOG_CRIT, "myldap_session_new(): malloc() failed to allocate 
memory");
     exit(EXIT_FAILURE);
   }
   /* initialize the session */
-  session->ld=NULL;
-  session->binddn[0]='\0';
-  session->bindpw[0]='\0';
-  session->lastactivity=0;
-  session->current_uri=0;
-  for (i=0;i<MAX_SEARCHES_IN_SESSION;i++)
-    session->searches[i]=NULL;
+  session->ld = NULL;
+  session->binddn[0] = '\0';
+  session->bindpw[0] = '\0';
+  session->lastactivity = 0;
+  session->current_uri = 0;
+  for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
+    session->searches[i] = NULL;
   /* return the new session */
   return session;
 }
 
 PURE static inline int is_valid_session(MYLDAP_SESSION *session)
 {
-  return (session!=NULL);
+  return (session != NULL);
 }
 
 PURE static inline int is_open_session(MYLDAP_SESSION *session)
 {
-  return is_valid_session(session)&&(session->ld!=NULL);
+  return is_valid_session(session) && (session->ld != NULL);
 }
 
 /* note that this does not check the valid flag of the search */
 PURE static inline int is_valid_search(MYLDAP_SEARCH *search)
 {
-  return (search!=NULL)&&is_open_session(search->session);
+  return (search != NULL) && is_open_session(search->session);
 }
 
 PURE static inline int is_valid_entry(MYLDAP_ENTRY *entry)
 {
-  return 
(entry!=NULL)&&is_valid_search(entry->search)&&(entry->search->msg!=NULL);
+  return (entry != NULL) && is_valid_search(entry->search) &&
+         (entry->search->msg != NULL);
 }
 
 #ifdef HAVE_SASL_INTERACT_T
 /* this is registered with ldap_sasl_interactive_bind_s() in do_bind() */
-static int do_sasl_interact(LDAP UNUSED(*ld),unsigned UNUSED(flags),void 
*defaults,void *_interact)
+static int do_sasl_interact(LDAP UNUSED(*ld), unsigned UNUSED(flags),
+                            void *defaults, void *_interact)
 {
-  struct ldap_config *cfg=defaults;
-  sasl_interact_t *interact=_interact;
-  while (interact->id!=SASL_CB_LIST_END)
+  struct ldap_config *cfg = defaults;
+  sasl_interact_t *interact = _interact;
+  while (interact->id != SASL_CB_LIST_END)
   {
-    switch(interact->id)
+    switch (interact->id)
     {
       case SASL_CB_GETREALM:
         if (cfg->ldc_sasl_realm)
         {
-          log_log(LOG_DEBUG,"do_sasl_interact(): returning sasl_realm 
\"%s\"",cfg->ldc_sasl_realm);
-          interact->result=cfg->ldc_sasl_realm;
-          interact->len=strlen(cfg->ldc_sasl_realm);
+          log_log(LOG_DEBUG, "do_sasl_interact(): returning sasl_realm \"%s\"",
+                  cfg->ldc_sasl_realm);
+          interact->result = cfg->ldc_sasl_realm;
+          interact->len = strlen(cfg->ldc_sasl_realm);
         }
         else
-          log_log(LOG_DEBUG,"do_sasl_interact(): were asked for sasl_realm but 
we don't have any");
+          log_log(LOG_DEBUG, "do_sasl_interact(): were asked for sasl_realm 
but we don't have any");
         break;
       case SASL_CB_AUTHNAME:
         if (cfg->ldc_sasl_authcid)
         {
-          log_log(LOG_DEBUG,"do_sasl_interact(): returning sasl_authcid 
\"%s\"",cfg->ldc_sasl_authcid);
-          interact->result=cfg->ldc_sasl_authcid;
-          interact->len=strlen(cfg->ldc_sasl_authcid);
+          log_log(LOG_DEBUG, "do_sasl_interact(): returning sasl_authcid 
\"%s\"",
+                  cfg->ldc_sasl_authcid);
+          interact->result = cfg->ldc_sasl_authcid;
+          interact->len = strlen(cfg->ldc_sasl_authcid);
         }
         else
-          log_log(LOG_DEBUG,"do_sasl_interact(): were asked for sasl_authcid 
but we don't have any");
+          log_log(LOG_DEBUG, "do_sasl_interact(): were asked for sasl_authcid 
but we don't have any");
         break;
       case SASL_CB_USER:
         if (cfg->ldc_sasl_authzid)
         {
-          log_log(LOG_DEBUG,"do_sasl_interact(): returning sasl_authzid 
\"%s\"",cfg->ldc_sasl_authzid);
-          interact->result=cfg->ldc_sasl_authzid;
-          interact->len=strlen(cfg->ldc_sasl_authzid);
+          log_log(LOG_DEBUG, "do_sasl_interact(): returning sasl_authzid 
\"%s\"",
+                  cfg->ldc_sasl_authzid);
+          interact->result = cfg->ldc_sasl_authzid;
+          interact->len = strlen(cfg->ldc_sasl_authzid);
         }
         else
-          log_log(LOG_DEBUG,"do_sasl_interact(): were asked for sasl_authzid 
but we don't have any");
+          log_log(LOG_DEBUG, "do_sasl_interact(): were asked for sasl_authzid 
but we don't have any");
         break;
       case SASL_CB_PASS:
         if (cfg->ldc_bindpw)
         {
-          log_log(LOG_DEBUG,"do_sasl_interact(): returning bindpw \"***\"");
-          interact->result=cfg->ldc_bindpw;
-          interact->len=strlen(cfg->ldc_bindpw);
+          log_log(LOG_DEBUG, "do_sasl_interact(): returning bindpw \"***\"");
+          interact->result = cfg->ldc_bindpw;
+          interact->len = strlen(cfg->ldc_bindpw);
         }
         else
-          log_log(LOG_DEBUG,"do_sasl_interact(): were asked for bindpw but we 
don't have any");
+          log_log(LOG_DEBUG, "do_sasl_interact(): were asked for bindpw but we 
don't have any");
         break;
       default:
         /* just ignore */
@@ -398,19 +401,20 @@
 }
 #endif /* HAVE_SASL_INTERACT_T */
 
-#define LDAP_SET_OPTION(ld,option,invalue) \
-  rc=ldap_set_option(ld,option,invalue); \
-  if (rc!=LDAP_SUCCESS) \
-  { \
-    myldap_err(LOG_ERR,ld,rc,"ldap_set_option(" #option ") failed"); \
-    return rc; \
+#define LDAP_SET_OPTION(ld, option, invalue)                                \
+  rc = ldap_set_option(ld, option, invalue);                                \
+  if (rc != LDAP_SUCCESS)                                                   \
+  {                                                                         \
+    myldap_err(LOG_ERR, ld, rc, "ldap_set_option(" #option ") failed");     \
+    return rc;                                                              \
   }
 
 /* This function performs the authentication phase of opening a connection.
    The binddn and bindpw parameters may be used to override the authentication
    mechanism defined in the configuration.  This returns an LDAP result
    code. */
-static int do_bind(LDAP *ld,const char *binddn,const char *bindpw,const char 
*uri)
+static int do_bind(LDAP *ld, const char *binddn, const char *bindpw,
+                   const char *uri)
 {
   int rc;
 #ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
@@ -420,114 +424,119 @@
 #endif /* HAVE_LDAP_SASL_INTERACTIVE_BIND_S */
 #ifdef LDAP_OPT_X_TLS
   /* check if StartTLS is requested */
-  if (nslcd_cfg->ldc_ssl_on==SSL_START_TLS)
+  if (nslcd_cfg->ldc_ssl_on == SSL_START_TLS)
   {
-    log_log(LOG_DEBUG,"ldap_start_tls_s()");
-    errno=0;
-    rc=ldap_start_tls_s(ld,NULL,NULL);
-    if (rc!=LDAP_SUCCESS)
+    log_log(LOG_DEBUG, "ldap_start_tls_s()");
+    errno = 0;
+    rc = ldap_start_tls_s(ld, NULL, NULL);
+    if (rc != LDAP_SUCCESS)
     {
-      myldap_err(LOG_WARNING,ld,rc,"ldap_start_tls_s() failed (uri=%s)",uri);
+      myldap_err(LOG_WARNING, ld, rc, "ldap_start_tls_s() failed (uri=%s)",
+                 uri);
       return rc;
     }
   }
 #endif /* LDAP_OPT_X_TLS */
   /* check if the binddn and bindpw are overwritten in the session */
-  if ((binddn!=NULL)&&(binddn[0]!='\0'))
+  if ((binddn != NULL) && (binddn[0] != '\0'))
   {
     /* do a simple bind */
-    log_log(LOG_DEBUG,"ldap_simple_bind_s(\"%s\",%s) (uri=\"%s\")",binddn,
-                      
((bindpw!=NULL)&&(bindpw[0]!='\0'))?"\"***\"":"\"\"",uri);
-    return ldap_simple_bind_s(ld,binddn,bindpw);
+    log_log(LOG_DEBUG, "ldap_simple_bind_s(\"%s\",%s) (uri=\"%s\")",
+            binddn, ((bindpw != NULL) && (bindpw[0] != '\0')) ? "\"***\"" : 
"\"\"", uri);
+    return ldap_simple_bind_s(ld, binddn, bindpw);
   }
   /* perform SASL bind if requested and available on platform */
 #ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
   /* TODO: store this information in the session */
-  if (nslcd_cfg->ldc_sasl_mech!=NULL)
+  if (nslcd_cfg->ldc_sasl_mech != NULL)
   {
     /* do a SASL bind */
-    if (nslcd_cfg->ldc_sasl_secprops!=NULL)
+    if (nslcd_cfg->ldc_sasl_secprops != NULL)
     {
-      
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_SASL_SECPROPS,\"%s\")",nslcd_cfg->ldc_sasl_secprops);
-      LDAP_SET_OPTION(ld,LDAP_OPT_X_SASL_SECPROPS,(void 
*)nslcd_cfg->ldc_sasl_secprops);
+      log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_SASL_SECPROPS,\"%s\")",
+              nslcd_cfg->ldc_sasl_secprops);
+      LDAP_SET_OPTION(ld, LDAP_OPT_X_SASL_SECPROPS, (void 
*)nslcd_cfg->ldc_sasl_secprops);
     }
 #ifdef HAVE_SASL_INTERACT_T
-    if (nslcd_cfg->ldc_binddn!=NULL)
-      log_log(LOG_DEBUG,"ldap_sasl_interactive_bind_s(\"%s\",\"%s\") 
(uri=\"%s\")",
-            nslcd_cfg->ldc_binddn,nslcd_cfg->ldc_sasl_mech,uri);
+    if (nslcd_cfg->ldc_binddn != NULL)
+      log_log(LOG_DEBUG, "ldap_sasl_interactive_bind_s(\"%s\",\"%s\") 
(uri=\"%s\")",
+              nslcd_cfg->ldc_binddn, nslcd_cfg->ldc_sasl_mech, uri);
     else
-      log_log(LOG_DEBUG,"ldap_sasl_interactive_bind_s(NULL,\"%s\") 
(uri=\"%s\")",
-            nslcd_cfg->ldc_sasl_mech,uri);
-    return 
ldap_sasl_interactive_bind_s(ld,nslcd_cfg->ldc_binddn,nslcd_cfg->ldc_sasl_mech,NULL,NULL,
-                                        LDAP_SASL_QUIET,
-                                        do_sasl_interact,(void *)nslcd_cfg);
+      log_log(LOG_DEBUG, "ldap_sasl_interactive_bind_s(NULL,\"%s\") 
(uri=\"%s\")",
+              nslcd_cfg->ldc_sasl_mech, uri);
+    return ldap_sasl_interactive_bind_s(ld, nslcd_cfg->ldc_binddn,
+                                        nslcd_cfg->ldc_sasl_mech, NULL, NULL,
+                                        LDAP_SASL_QUIET, do_sasl_interact,
+                                        (void *)nslcd_cfg);
 #else /* HAVE_SASL_INTERACT_T */
-    if (nslcd_cfg->ldc_bindpw!=NULL)
+    if (nslcd_cfg->ldc_bindpw != NULL)
     {
-      cred.bv_val=nslcd_cfg->ldc_bindpw;
-      cred.bv_len=strlen(nslcd_cfg->ldc_bindpw);
+      cred.bv_val = nslcd_cfg->ldc_bindpw;
+      cred.bv_len = strlen(nslcd_cfg->ldc_bindpw);
     }
     else
     {
-      cred.bv_val="";
-      cred.bv_len=0;
+      cred.bv_val = "";
+      cred.bv_len = 0;
     }
-    if (nslcd_cfg->ldc_binddn!=NULL)
-      log_log(LOG_DEBUG,"ldap_sasl_bind_s(\"%s\",\"%s\",%s) (uri=\"%s\")",
-            nslcd_cfg->ldc_binddn,nslcd_cfg->ldc_sasl_mech,
-            nslcd_cfg->ldc_bindpw?"\"***\"":"NULL",uri);
+    if (nslcd_cfg->ldc_binddn != NULL)
+      log_log(LOG_DEBUG, "ldap_sasl_bind_s(\"%s\",\"%s\",%s) (uri=\"%s\")",
+              nslcd_cfg->ldc_binddn, nslcd_cfg->ldc_sasl_mech,
+              nslcd_cfg->ldc_bindpw ? "\"***\"" : "NULL", uri);
     else
-      log_log(LOG_DEBUG,"ldap_sasl_bind_s(NULL,\"%s\",%s) (uri=\"%s\")",
-            nslcd_cfg->ldc_sasl_mech,
-            nslcd_cfg->ldc_bindpw?"\"***\"":"NULL",uri);
-    return 
ldap_sasl_bind_s(ld,nslcd_cfg->ldc_binddn,nslcd_cfg->ldc_sasl_mech,&cred,NULL,NULL,NULL);
+      log_log(LOG_DEBUG, "ldap_sasl_bind_s(NULL,\"%s\",%s) (uri=\"%s\")",
+              nslcd_cfg->ldc_sasl_mech,
+              nslcd_cfg->ldc_bindpw ? "\"***\"" : "NULL", uri);
+    return ldap_sasl_bind_s(ld, nslcd_cfg->ldc_binddn,
+                            nslcd_cfg->ldc_sasl_mech, &cred, NULL, NULL, NULL);
 #endif /* not HAVE_SASL_INTERACT_T */
   }
 #endif /* HAVE_LDAP_SASL_INTERACTIVE_BIND_S */
   /* do a simple bind */
   if (nslcd_cfg->ldc_binddn)
-    log_log(LOG_DEBUG,"ldap_simple_bind_s(\"%s\",%s) 
(uri=\"%s\")",nslcd_cfg->ldc_binddn,
-                      nslcd_cfg->ldc_bindpw?"\"***\"":"NULL",uri);
+    log_log(LOG_DEBUG, "ldap_simple_bind_s(\"%s\",%s) (uri=\"%s\")",
+            nslcd_cfg->ldc_binddn, nslcd_cfg->ldc_bindpw ? "\"***\"" : "NULL",
+            uri);
   else
-    log_log(LOG_DEBUG,"ldap_simple_bind_s(NULL,%s) (uri=\"%s\")",
-                      nslcd_cfg->ldc_bindpw?"\"***\"":"NULL",uri);
-  return ldap_simple_bind_s(ld,nslcd_cfg->ldc_binddn,nslcd_cfg->ldc_bindpw);
+    log_log(LOG_DEBUG, "ldap_simple_bind_s(NULL,%s) (uri=\"%s\")",
+            nslcd_cfg->ldc_bindpw ? "\"***\"" : "NULL", uri);
+  return ldap_simple_bind_s(ld, nslcd_cfg->ldc_binddn, nslcd_cfg->ldc_bindpw);
 }
 
 #ifdef HAVE_LDAP_SET_REBIND_PROC
 /* This function is called by the LDAP library when chasing referrals.
    It is configured with the ldap_set_rebind_proc() below. */
 #if defined(LDAP_API_FEATURE_X_OPENLDAP) && (LDAP_API_VERSION > 2000)
-static int do_rebind(LDAP *ld,LDAP_CONST char *url,
+static int do_rebind(LDAP *ld, LDAP_CONST char *url,
                      ber_tag_t UNUSED(request),
-                     ber_int_t UNUSED(msgid),void *arg)
+                     ber_int_t UNUSED(msgid), void *arg)
 {
-  MYLDAP_SESSION *session=(MYLDAP_SESSION *)arg;
-  log_log(LOG_DEBUG,"rebinding to %s",url);
-  return do_bind(ld,session->binddn,session->bindpw,url);
+  MYLDAP_SESSION *session = (MYLDAP_SESSION *)arg;
+  log_log(LOG_DEBUG, "rebinding to %s", url);
+  return do_bind(ld, session->binddn, session->bindpw, url);
 }
 #else /* not recent OpenLDAP */
-static int do_rebind(LDAP *ld,char **dnp,char **passwdp,int *authmethodp,
-                     int freeit,void *arg)
+static int do_rebind(LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
+                     int freeit, void *arg)
 {
-  MYLDAP_SESSION *session=(MYLDAP_SESSION *)arg;
+  MYLDAP_SESSION *session = (MYLDAP_SESSION *)arg;
   if (freeit)
   {
     free(*dnp);
-    memset(*passwdp,0,strlen(*passwdp));
+    memset(*passwdp, 0, strlen(*passwdp));
     free(*passwdp);
   }
   else
   {
-    log_log(LOG_DEBUG,"rebinding");
-    *dnp=strdup(session->binddn);
-    *passwdp=strdup(session->bindpw);
-    *authmethodp=LDAP_AUTH_SIMPLE;
-    if ((*dnp==NULL)||(*passwdp==NULL))
+    log_log(LOG_DEBUG, "rebinding");
+    *dnp = strdup(session->binddn);
+    *passwdp = strdup(session->bindpw);
+    *authmethodp = LDAP_AUTH_SIMPLE;
+    if ((*dnp == NULL) || (*passwdp == NULL))
     {
-      if (*dnp!=NULL)
+      if (*dnp != NULL)
         free(*dnp);
-      log_log(LOG_CRIT,"do_rebind(): strdup() failed to allocate memory");
+      log_log(LOG_CRIT, "do_rebind(): strdup() failed to allocate memory");
       return LDAP_NO_MEMORY;
     }
   }
@@ -537,34 +546,37 @@
 #endif /* HAVE_LDAP_SET_REBIND_PROC */
 
 /* set a recieve and send timeout on a socket */
-static int set_socket_timeout(LDAP *ld,time_t sec,suseconds_t usec)
+static int set_socket_timeout(LDAP *ld, time_t sec, suseconds_t usec)
 {
   struct timeval tv;
-  int rc=LDAP_SUCCESS;
+  int rc = LDAP_SUCCESS;
   int sd;
-  log_log(LOG_DEBUG,"set_socket_timeout(%lu,%lu)",(unsigned long)sec,(unsigned 
long)usec);
+  log_log(LOG_DEBUG, "set_socket_timeout(%lu,%lu)",
+          (unsigned long)sec, (unsigned long)usec);
   /* get the socket */
-  if ((rc=ldap_get_option(ld,LDAP_OPT_DESC,&sd))!=LDAP_SUCCESS)
+  if ((rc = ldap_get_option(ld, LDAP_OPT_DESC, &sd)) != LDAP_SUCCESS)
   {
-    myldap_err(LOG_ERR,ld,rc,"ldap_get_option(LDAP_OPT_DESC) failed");
+    myldap_err(LOG_ERR, ld, rc, "ldap_get_option(LDAP_OPT_DESC) failed");
     return rc;
   }
   /* ignore invalid (probably closed) file descriptors */
-  if (sd<=0)
+  if (sd <= 0)
     return LDAP_SUCCESS;
   /* set timeouts */
-  memset(&tv,0,sizeof(tv));
-  tv.tv_sec=sec;
-  tv.tv_usec=usec;
-  if (setsockopt(sd,SOL_SOCKET,SO_RCVTIMEO,(void *)&tv,sizeof(tv)))
-  {
-    log_log(LOG_ERR,"setsockopt(%d,SO_RCVTIMEO) failed: 
%s",sd,strerror(errno));
-    rc=LDAP_LOCAL_ERROR;
-  }
-  if (setsockopt(sd,SOL_SOCKET,SO_SNDTIMEO,(void *)&tv,sizeof(tv)))
-  {
-    log_log(LOG_ERR,"setsockopt(%d,SO_RCVTIMEO) failed: 
%s",sd,strerror(errno));
-    rc=LDAP_LOCAL_ERROR;
+  memset(&tv, 0, sizeof(tv));
+  tv.tv_sec = sec;
+  tv.tv_usec = usec;
+  if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)))
+  {
+    log_log(LOG_ERR, "setsockopt(%d,SO_RCVTIMEO) failed: %s",
+            sd, strerror(errno));
+    rc = LDAP_LOCAL_ERROR;
+  }
+  if (setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, (void *)&tv, sizeof(tv)))
+  {
+    log_log(LOG_ERR, "setsockopt(%d,SO_RCVTIMEO) failed: %s",
+            sd, strerror(errno));
+    rc = LDAP_LOCAL_ERROR;
   }
   return rc;
 }
@@ -573,20 +585,22 @@
 /* This function is called by the LDAP library once a connection was made to 
the server. We
    set a timeout on the socket here, to catch netzwork timeouts during the ssl
    handshake phase. It is configured with LDAP_OPT_CONNECT_CB. */
-static int connect_cb(LDAP *ld,Sockbuf UNUSED(*sb),LDAPURLDesc UNUSED(*srv),
-        struct sockaddr UNUSED(*addr),struct ldap_conncb UNUSED(*ctx))
+static int connect_cb(LDAP *ld, Sockbuf UNUSED(*sb),
+                      LDAPURLDesc UNUSED(*srv), struct sockaddr UNUSED(*addr),
+                      struct ldap_conncb UNUSED(*ctx))
 {
   /* set timeout options on socket to avoid hang in some cases (a little
      more than the normal timeout so this should only be triggered in cases
      where the library behaves incorrectly) */
   if (nslcd_cfg->ldc_timelimit)
-    set_socket_timeout(ld,nslcd_cfg->ldc_timelimit,500000);
+    set_socket_timeout(ld, nslcd_cfg->ldc_timelimit, 500000);
   return LDAP_SUCCESS;
 }
 
 /* We have an empty disconnect callback because LDAP_OPT_CONNECT_CB expects
    both functions to be available. */
-static void disconnect_cb(LDAP UNUSED(*ld),Sockbuf UNUSED(*sb),struct 
ldap_conncb UNUSED(*ctx))
+static void disconnect_cb(LDAP UNUSED(*ld), Sockbuf UNUSED(*sb),
+                          struct ldap_conncb UNUSED(*ctx))
 {
 }
 #endif /* LDAP_OPT_CONNECT_CB */
@@ -611,67 +625,80 @@
      
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/apis/ldap_set_rebind_proc.htm
      
http://www.openldap.org/software/man.cgi?query=ldap_set_rebind_proc&manpath=OpenLDAP+2.4-Release
 */
   /* TODO: probably only set this if we should chase referrals */
-  log_log(LOG_DEBUG,"ldap_set_rebind_proc()");
+  log_log(LOG_DEBUG, "ldap_set_rebind_proc()");
 #ifndef LDAP_SET_REBIND_PROC_RETURNS_VOID /* it returns int */
-  rc=ldap_set_rebind_proc(session->ld,do_rebind,session);
-  if (rc!=LDAP_SUCCESS)
+  rc = ldap_set_rebind_proc(session->ld, do_rebind, session);
+  if (rc != LDAP_SUCCESS)
   {
-    myldap_err(LOG_ERR,session->ld,rc,"ldap_set_rebind_proc() failed");
+    myldap_err(LOG_ERR, session->ld, rc, "ldap_set_rebind_proc() failed");
     return rc;
   }
 #else /* ldap_set_rebind_proc() returns void */
-  ldap_set_rebind_proc(session->ld,do_rebind,session);
+  ldap_set_rebind_proc(session->ld, do_rebind, session);
 #endif
 #endif /* HAVE_LDAP_SET_REBIND_PROC */
   /* set the protocol version to use */
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_PROTOCOL_VERSION,%d)",nslcd_cfg->ldc_version);
-  
LDAP_SET_OPTION(session->ld,LDAP_OPT_PROTOCOL_VERSION,&nslcd_cfg->ldc_version);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_PROTOCOL_VERSION,%d)",
+          nslcd_cfg->ldc_version);
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_PROTOCOL_VERSION,
+                  &nslcd_cfg->ldc_version);
   /* set some other options */
-  log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_DEREF,%d)",nslcd_cfg->ldc_deref);
-  LDAP_SET_OPTION(session->ld,LDAP_OPT_DEREF,&nslcd_cfg->ldc_deref);
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_TIMELIMIT,%d)",nslcd_cfg->ldc_timelimit);
-  LDAP_SET_OPTION(session->ld,LDAP_OPT_TIMELIMIT,&nslcd_cfg->ldc_timelimit);
-  tv.tv_sec=nslcd_cfg->ldc_bind_timelimit;
-  tv.tv_usec=0;
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_DEREF,%d)",
+          nslcd_cfg->ldc_deref);
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_DEREF, &nslcd_cfg->ldc_deref);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_TIMELIMIT,%d)",
+          nslcd_cfg->ldc_timelimit);
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_TIMELIMIT, &nslcd_cfg->ldc_timelimit);
+  tv.tv_sec = nslcd_cfg->ldc_bind_timelimit;
+  tv.tv_usec = 0;
 #ifdef LDAP_OPT_TIMEOUT
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_TIMEOUT,%d)",nslcd_cfg->ldc_timelimit);
-  LDAP_SET_OPTION(session->ld,LDAP_OPT_TIMEOUT,&tv);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_TIMEOUT,%d)",
+          nslcd_cfg->ldc_timelimit);
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_TIMEOUT, &tv);
 #endif /* LDAP_OPT_TIMEOUT */
 #ifdef LDAP_OPT_NETWORK_TIMEOUT
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_NETWORK_TIMEOUT,%d)",nslcd_cfg->ldc_timelimit);
-  LDAP_SET_OPTION(session->ld,LDAP_OPT_NETWORK_TIMEOUT,&tv);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_NETWORK_TIMEOUT,%d)",
+          nslcd_cfg->ldc_timelimit);
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);
 #endif /* LDAP_OPT_NETWORK_TIMEOUT */
 #ifdef LDAP_X_OPT_CONNECT_TIMEOUT
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_X_OPT_CONNECT_TIMEOUT,%d)",nslcd_cfg->ldc_timelimit);
-  LDAP_SET_OPTION(session->ld,LDAP_X_OPT_CONNECT_TIMEOUT,&tv);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_X_OPT_CONNECT_TIMEOUT,%d)",
+          nslcd_cfg->ldc_timelimit);
+  LDAP_SET_OPTION(session->ld, LDAP_X_OPT_CONNECT_TIMEOUT, &tv);
 #endif /* LDAP_X_OPT_CONNECT_TIMEOUT */
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_REFERRALS,%s)",nslcd_cfg->ldc_referrals?"LDAP_OPT_ON":"LDAP_OPT_OFF");
-  
LDAP_SET_OPTION(session->ld,LDAP_OPT_REFERRALS,nslcd_cfg->ldc_referrals?LDAP_OPT_ON:LDAP_OPT_OFF);
-  
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_RESTART,%s)",nslcd_cfg->ldc_restart?"LDAP_OPT_ON":"LDAP_OPT_OFF");
-  
LDAP_SET_OPTION(session->ld,LDAP_OPT_RESTART,nslcd_cfg->ldc_restart?LDAP_OPT_ON:LDAP_OPT_OFF);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_REFERRALS,%s)",
+          nslcd_cfg->ldc_referrals ? "LDAP_OPT_ON" : "LDAP_OPT_OFF");
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_REFERRALS,
+                  nslcd_cfg->ldc_referrals ? LDAP_OPT_ON : LDAP_OPT_OFF);
+  log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_RESTART,%s)",
+          nslcd_cfg->ldc_restart ? "LDAP_OPT_ON" : "LDAP_OPT_OFF");
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_RESTART,
+                  nslcd_cfg->ldc_restart ? LDAP_OPT_ON : LDAP_OPT_OFF);
 #ifdef LDAP_OPT_CONNECT_CB
   /* register a connection callback */
-  cb.lc_add=connect_cb;
-  cb.lc_del=disconnect_cb;
-  cb.lc_arg=NULL;
-  LDAP_SET_OPTION(session->ld,LDAP_OPT_CONNECT_CB,(void *)&cb);
+  cb.lc_add = connect_cb;
+  cb.lc_del = disconnect_cb;
+  cb.lc_arg = NULL;
+  LDAP_SET_OPTION(session->ld, LDAP_OPT_CONNECT_CB, (void *)&cb);
 #endif /* LDAP_OPT_CONNECT_CB */
 #ifdef LDAP_OPT_X_TLS
   /* if SSL is desired, then enable it */
-  if ( (nslcd_cfg->ldc_ssl_on==SSL_LDAPS) ||
-       
(strncasecmp(nslcd_cfg->ldc_uris[session->current_uri].uri,"ldaps://",8)==0) )
+  if ((nslcd_cfg->ldc_ssl_on == SSL_LDAPS) ||
+      (strncasecmp(nslcd_cfg->ldc_uris[session->current_uri].uri, "ldaps://", 
8) == 0))
   {
     /* use tls */
-    i=LDAP_OPT_X_TLS_HARD;
-    log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_TLS,LDAP_OPT_X_TLS_HARD)");
-    LDAP_SET_OPTION(session->ld,LDAP_OPT_X_TLS,&i);
+    i = LDAP_OPT_X_TLS_HARD;
+    log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_TLS,LDAP_OPT_X_TLS_HARD)");
+    LDAP_SET_OPTION(session->ld, LDAP_OPT_X_TLS, &i);
   }
 #endif /* LDAP_OPT_X_TLS */
 #ifdef LDAP_OPT_X_SASL_NOCANON
-  if (nslcd_cfg->ldc_sasl_canonicalize>=0)
+  if (nslcd_cfg->ldc_sasl_canonicalize >= 0)
   {
-    
log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_X_SASL_NOCANON,%s)",nslcd_cfg->ldc_sasl_canonicalize?"LDAP_OPT_OFF":"LDAP_OPT_ON");
-    
LDAP_SET_OPTION(session->ld,LDAP_OPT_X_SASL_NOCANON,nslcd_cfg->ldc_sasl_canonicalize?LDAP_OPT_OFF:LDAP_OPT_ON);
+    log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_X_SASL_NOCANON,%s)",
+            nslcd_cfg->ldc_sasl_canonicalize ? "LDAP_OPT_OFF" : "LDAP_OPT_ON");
+    LDAP_SET_OPTION(session->ld, LDAP_OPT_X_SASL_NOCANON,
+                    nslcd_cfg->ldc_sasl_canonicalize ? LDAP_OPT_OFF : 
LDAP_OPT_ON);
   }
 #endif /* LDAP_OPT_X_SASL_NOCANON */
   /* if nothing above failed, everything should be fine */
@@ -685,50 +712,52 @@
   int rc;
   time_t sec;
   /* if we had reachability problems with the server close the connection */
-  if (session->ld!=NULL)
+  if (session->ld != NULL)
   {
     /* set timeout options on socket to avoid hang in some cases
        (we set a short timeout because we don't care too much about properly
        shutting down the connection) */
     if (nslcd_cfg->ldc_timelimit)
     {
-      sec=nslcd_cfg->ldc_timelimit/2;
-      if (!sec) sec=1;
-      set_socket_timeout(session->ld,sec,0);
+      sec = nslcd_cfg->ldc_timelimit / 2;
+      if (!sec)
+        sec = 1;
+      set_socket_timeout(session->ld, sec, 0);
     }
     /* go over the other searches and partially close them */
-    for (i=0;i<MAX_SEARCHES_IN_SESSION;i++)
+    for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
     {
-      if (session->searches[i]!=NULL)
+      if (session->searches[i] != NULL)
       {
         /* free any messages (because later ld is no longer valid) */
-        if (session->searches[i]->msg!=NULL)
+        if (session->searches[i]->msg != NULL)
         {
           ldap_msgfree(session->searches[i]->msg);
-          session->searches[i]->msg=NULL;
+          session->searches[i]->msg = NULL;
         }
         /* abandon the search if there were more results to fetch */
-        if (session->searches[i]->msgid!=-1)
+        if (session->searches[i]->msgid != -1)
         {
-          log_log(LOG_DEBUG,"ldap_abandon()");
-          if 
(ldap_abandon(session->searches[i]->session->ld,session->searches[i]->msgid))
+          log_log(LOG_DEBUG, "ldap_abandon()");
+          if (ldap_abandon(session->searches[i]->session->ld, 
session->searches[i]->msgid))
           {
-            if 
(ldap_get_option(session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-              rc=LDAP_OTHER;
-            myldap_err(LOG_WARNING,session->ld,rc,"ldap_abandon() failed to 
abandon search");
+            if (ldap_get_option(session->ld, LDAP_OPT_ERROR_NUMBER, &rc) != 
LDAP_SUCCESS)
+              rc = LDAP_OTHER;
+            myldap_err(LOG_WARNING, session->ld, rc,
+                       "ldap_abandon() failed to abandon search");
           }
-          session->searches[i]->msgid=-1;
+          session->searches[i]->msgid = -1;
         }
         /* flag the search as invalid */
-        session->searches[i]->valid=0;
+        session->searches[i]->valid = 0;
       }
     }
     /* close the connection to the server */
-    log_log(LOG_DEBUG,"ldap_unbind()");
-    rc=ldap_unbind(session->ld);
-    session->ld=NULL;
-    if (rc!=LDAP_SUCCESS)
-      myldap_err(LOG_WARNING,session->ld,rc,"ldap_unbind() failed");
+    log_log(LOG_DEBUG, "ldap_unbind()");
+    rc = ldap_unbind(session->ld);
+    session->ld = NULL;
+    if (rc != LDAP_SUCCESS)
+      myldap_err(LOG_WARNING, session->ld, rc, "ldap_unbind() failed");
   }
 }
 
@@ -739,22 +768,22 @@
   /* check parameters */
   if (!is_valid_session(session))
   {
-    log_log(LOG_ERR,"myldap_session_check(): invalid parameter passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_session_check(): invalid parameter passed");
+    errno = EINVAL;
     return;
   }
   /* check if we should time out the connection */
-  if ((session->ld!=NULL)&&(nslcd_cfg->ldc_idle_timelimit>0))
+  if ((session->ld != NULL) && (nslcd_cfg->ldc_idle_timelimit > 0))
   {
     /* if we have any running searches, don't time out */
-    for (i=0;i<MAX_SEARCHES_IN_SESSION;i++)
-      if ((session->searches[i]!=NULL)&&(session->searches[i]->valid))
+    for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
+      if ((session->searches[i] != NULL) && (session->searches[i]->valid))
         return;
     /* consider timeout (there are no running searches) */
     time(&current_time);
-    if ((session->lastactivity+nslcd_cfg->ldc_idle_timelimit)<current_time)
+    if ((session->lastactivity + nslcd_cfg->ldc_idle_timelimit) < current_time)
     {
-      log_log(LOG_DEBUG,"myldap_session_check(): idle_timelimit reached");
+      log_log(LOG_DEBUG, "myldap_session_check(): idle_timelimit reached");
       do_close(session);
     }
   }
@@ -767,44 +796,45 @@
   int rc;
   /* if the connection is still there (ie. ldap_unbind() wasn't
      called) then we can return the cached connection */
-  if (session->ld!=NULL)
+  if (session->ld != NULL)
     return LDAP_SUCCESS;
   /* we should build a new session now */
-  session->ld=NULL;
-  session->lastactivity=0;
+  session->ld = NULL;
+  session->lastactivity = 0;
   /* open the connection */
-  
log_log(LOG_DEBUG,"ldap_initialize(%s)",nslcd_cfg->ldc_uris[session->current_uri].uri);
-  errno=0;
-  
rc=ldap_initialize(&(session->ld),nslcd_cfg->ldc_uris[session->current_uri].uri);
-  if (rc!=LDAP_SUCCESS)
+  log_log(LOG_DEBUG, "ldap_initialize(%s)",
+          nslcd_cfg->ldc_uris[session->current_uri].uri);
+  errno = 0;
+  rc = ldap_initialize(&(session->ld), 
nslcd_cfg->ldc_uris[session->current_uri].uri);
+  if (rc != LDAP_SUCCESS)
   {
-    myldap_err(LOG_WARNING,session->ld,rc,"ldap_initialize(%s) failed",
+    myldap_err(LOG_WARNING, session->ld, rc, "ldap_initialize(%s) failed",
                nslcd_cfg->ldc_uris[session->current_uri].uri);
-    if (session->ld!=NULL)
+    if (session->ld != NULL)
       do_close(session);
     return rc;
   }
-  else if (session->ld==NULL)
+  else if (session->ld == NULL)
   {
-    log_log(LOG_WARNING,"ldap_initialize() returned NULL");
+    log_log(LOG_WARNING, "ldap_initialize() returned NULL");
     return LDAP_LOCAL_ERROR;
   }
   /* set the options for the connection */
-  rc=do_set_options(session);
-  if (rc!=LDAP_SUCCESS)
+  rc = do_set_options(session);
+  if (rc != LDAP_SUCCESS)
   {
     do_close(session);
     return rc;
   }
   /* bind to the server */
-  errno=0;
-  rc=do_bind(session->ld,session->binddn,session->bindpw,
-             nslcd_cfg->ldc_uris[session->current_uri].uri);
-  if (rc!=LDAP_SUCCESS)
+  errno = 0;
+  rc = do_bind(session->ld, session->binddn, session->bindpw,
+               nslcd_cfg->ldc_uris[session->current_uri].uri);
+  if (rc != LDAP_SUCCESS)
   {
     /* log actual LDAP error code */
-    myldap_err((session->binddn[0]=='\0')?LOG_WARNING:LOG_DEBUG,
-               session->ld,rc,"failed to bind to LDAP server %s",
+    myldap_err((session->binddn[0] == '\0') ? LOG_WARNING : LOG_DEBUG,
+               session->ld, rc, "failed to bind to LDAP server %s",
                nslcd_cfg->ldc_uris[session->current_uri].uri);
     do_close(session);
     return rc;
@@ -815,14 +845,14 @@
 }
 
 /* Set alternative credentials for the session. */
-void myldap_set_credentials(MYLDAP_SESSION *session,const char *dn,
-                           const char *password)
+void myldap_set_credentials(MYLDAP_SESSION *session, const char *dn,
+                            const char *password)
 {
   /* copy dn and password into session */
-  strncpy(session->binddn,dn,sizeof(session->binddn));
-  session->binddn[sizeof(session->binddn)-1]='\0';
-  strncpy(session->bindpw,password,sizeof(session->bindpw));
-  session->bindpw[sizeof(session->bindpw)-1]='\0';
+  strncpy(session->binddn, dn, sizeof(session->binddn));
+  session->binddn[sizeof(session->binddn) - 1] = '\0';
+  strncpy(session->bindpw, password, sizeof(session->bindpw));
+  session->bindpw[sizeof(session->bindpw) - 1] = '\0';
 }
 
 static int do_try_search(MYLDAP_SEARCH *search)
@@ -832,52 +862,52 @@
   LDAPControl **pServerCtrls;
   int msgid;
   /* ensure that we have an open connection */
-  rc=do_open(search->session);
-  if (rc!=LDAP_SUCCESS)
+  rc = do_open(search->session);
+  if (rc != LDAP_SUCCESS)
     return rc;
   /* if we're using paging, build a page control */
-  if ((nslcd_cfg->ldc_pagesize>0)&&(search->scope!=LDAP_SCOPE_BASE))
+  if ((nslcd_cfg->ldc_pagesize > 0) && (search->scope != LDAP_SCOPE_BASE))
   {
-    rc=ldap_create_page_control(search->session->ld,nslcd_cfg->ldc_pagesize,
-                                NULL,0,&serverCtrls[0]);
-    if (rc==LDAP_SUCCESS)
+    rc = ldap_create_page_control(search->session->ld, nslcd_cfg->ldc_pagesize,
+                                  NULL, 0, &serverCtrls[0]);
+    if (rc == LDAP_SUCCESS)
     {
-      serverCtrls[1]=NULL;
-      pServerCtrls=serverCtrls;
+      serverCtrls[1] = NULL;
+      pServerCtrls = serverCtrls;
     }
     else
     {
-      
myldap_err(LOG_WARNING,search->session->ld,rc,"ldap_create_page_control() 
failed");
+      myldap_err(LOG_WARNING, search->session->ld, rc,
+                 "ldap_create_page_control() failed");
       /* clear error flag */
-      rc=LDAP_SUCCESS;
-      if 
(ldap_set_option(search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-        log_log(LOG_WARNING,"failed to clear the error flag");
-      pServerCtrls=NULL;
+      rc = LDAP_SUCCESS;
+      if (ldap_set_option(search->session->ld, LDAP_OPT_ERROR_NUMBER, &rc) != 
LDAP_SUCCESS)
+        log_log(LOG_WARNING, "failed to clear the error flag");
+      pServerCtrls = NULL;
     }
   }
   else
-    pServerCtrls=NULL;
+    pServerCtrls = NULL;
   /* perform the search */
-  rc=ldap_search_ext(search->session->ld,search->base,search->scope,
-                     search->filter,(char **)(search->attrs),
-                     0,pServerCtrls,NULL,NULL,
-                     LDAP_NO_LIMIT,&msgid);
+  rc = ldap_search_ext(search->session->ld, search->base, search->scope,
+                       search->filter, (char **)(search->attrs),
+                       0, pServerCtrls, NULL, NULL, LDAP_NO_LIMIT, &msgid);
   /* free the controls if we had them */
-  if (pServerCtrls!=NULL)
+  if (pServerCtrls != NULL)
   {
     ldap_control_free(serverCtrls[0]);
-    serverCtrls[0]=NULL;
+    serverCtrls[0] = NULL;
   }
   /* handle errors */
-  if (rc!=LDAP_SUCCESS)
+  if (rc != LDAP_SUCCESS)
   {
-    myldap_err(LOG_WARNING,search->session->ld,rc,"ldap_search_ext() failed");
+    myldap_err(LOG_WARNING, search->session->ld, rc, "ldap_search_ext() 
failed");
     return rc;
   }
   /* update the last activity on the connection */
   time(&(search->session->lastactivity));
   /* save msgid */
-  search->msgid=msgid;
+  search->msgid = msgid;
   /* return the new search */
   return LDAP_SUCCESS;
 }
@@ -893,16 +923,16 @@
   /* check parameter */
   if (!is_valid_session(session))
   {
-    log_log(LOG_ERR,"myldap_session_cleanup(): invalid session passed");
+    log_log(LOG_ERR, "myldap_session_cleanup(): invalid session passed");
     return;
   }
   /* go over all searches in the session and close them */
-  for (i=0;i<MAX_SEARCHES_IN_SESSION;i++)
+  for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
   {
-    if (session->searches[i]!=NULL)
+    if (session->searches[i] != NULL)
     {
       myldap_search_close(session->searches[i]);
-      session->searches[i]=NULL;
+      session->searches[i] = NULL;
     }
   }
 }
@@ -912,7 +942,7 @@
   /* check parameter */
   if (!is_valid_session(session))
   {
-    log_log(LOG_ERR,"myldap_session_cleanup(): invalid session passed");
+    log_log(LOG_ERR, "myldap_session_cleanup(): invalid session passed");
     return;
   }
   /* close pending searches */
@@ -928,376 +958,377 @@
 
 static int do_retry_search(MYLDAP_SEARCH *search)
 {
-  int sleeptime=0;
+  int sleeptime = 0;
   int start_uri;
   time_t endtime;
   time_t nexttry;
   time_t t;
-  int rc=LDAP_UNAVAILABLE;
+  int rc = LDAP_UNAVAILABLE;
   struct myldap_uri *current_uri;
   int dotry[NSS_LDAP_CONFIG_URI_MAX];
   /* clear time stamps */
-  for (start_uri=0;start_uri<NSS_LDAP_CONFIG_URI_MAX;start_uri++)
-    dotry[start_uri]=1;
+  for (start_uri = 0; start_uri < NSS_LDAP_CONFIG_URI_MAX; start_uri++)
+    dotry[start_uri] = 1;
   /* keep trying until we time out */
-  endtime=time(NULL)+nslcd_cfg->ldc_reconnect_retrytime;
+  endtime = time(NULL) + nslcd_cfg->ldc_reconnect_retrytime;
   while (1)
   {
-    nexttry=endtime;
+    nexttry = endtime;
     /* try each configured URL once */
     pthread_mutex_lock(&uris_mutex);
-    start_uri=search->session->current_uri;
+    start_uri = search->session->current_uri;
     do
     {
-      current_uri=&(nslcd_cfg->ldc_uris[search->session->current_uri]);
+      current_uri = &(nslcd_cfg->ldc_uris[search->session->current_uri]);
       /* only try this URI if we should */
       if (!dotry[search->session->current_uri])
       { /* skip this URI */ }
-      else if ( (current_uri->lastfail > 
(current_uri->firstfail+nslcd_cfg->ldc_reconnect_retrytime)) &&
-                ((t=time(NULL)) < 
(current_uri->lastfail+nslcd_cfg->ldc_reconnect_retrytime)) )
+      else if ((current_uri->lastfail > (current_uri->firstfail + 
nslcd_cfg->ldc_reconnect_retrytime)) &&
+               ((t = time(NULL)) < (current_uri->lastfail + 
nslcd_cfg->ldc_reconnect_retrytime)))
       {
         /* we are in a hard fail state and have retried not long ago */
-        log_log(LOG_DEBUG,"not retrying server %s which failed just %d 
second(s) ago and has been failing for %d seconds",
-                          current_uri->uri,(int)(t-current_uri->lastfail),
-                          (int)(t-current_uri->firstfail));
-        dotry[search->session->current_uri]=0;
+        log_log(LOG_DEBUG, "not retrying server %s which failed just %d 
second(s) ago and has been failing for %d seconds",
+                current_uri->uri, (int)(t - current_uri->lastfail),
+                (int)(t - current_uri->firstfail));
+        dotry[search->session->current_uri] = 0;
       }
       else
       {
         /* try to start the search */
         pthread_mutex_unlock(&uris_mutex);
-        rc=do_try_search(search);
-        if (rc==LDAP_SUCCESS)
+        rc = do_try_search(search);
+        if (rc == LDAP_SUCCESS)
         {
           pthread_mutex_lock(&uris_mutex);
           /* check if we are coming back from an error */
-          if 
((current_uri->lastfail>0)||(search->session->current_uri!=start_uri))
-            log_log(LOG_INFO,"connected to LDAP server %s",current_uri->uri);
+          if ((current_uri->lastfail > 0) || (search->session->current_uri != 
start_uri))
+            log_log(LOG_INFO, "connected to LDAP server %s", current_uri->uri);
           /* update ok time */
-          current_uri->firstfail=0;
-          current_uri->lastfail=0;
+          current_uri->firstfail = 0;
+          current_uri->lastfail = 0;
           pthread_mutex_unlock(&uris_mutex);
           /* flag the search as valid */
-          search->valid=1;
+          search->valid = 1;
           return LDAP_SUCCESS;
         }
         /* close the current connection */
         do_close(search->session);
         /* update time of failure and figure out when we should retry */
         pthread_mutex_lock(&uris_mutex);
-        t=time(NULL);
+        t = time(NULL);
         /* update timestaps unless we are doing an authentication search */
-        if (search->session->binddn[0]=='\0')
+        if (search->session->binddn[0] == '\0')
         {
-          if (current_uri->firstfail==0)
-            current_uri->firstfail=t;
-          current_uri->lastfail=t;
+          if (current_uri->firstfail == 0)
+            current_uri->firstfail = t;
+          current_uri->lastfail = t;
         }
         /* if it is one of these, retrying this URI is not going to help */
-        if ((rc==LDAP_INVALID_CREDENTIALS)||(rc==LDAP_INSUFFICIENT_ACCESS)||
-            (rc==LDAP_AUTH_METHOD_NOT_SUPPORTED))
-          dotry[search->session->current_uri]=0;
+        if ((rc == LDAP_INVALID_CREDENTIALS) || (rc == 
LDAP_INSUFFICIENT_ACCESS) ||
+            (rc == LDAP_AUTH_METHOD_NOT_SUPPORTED))
+          dotry[search->session->current_uri] = 0;
         /* check when we should try this URI again */
-        else if (t <= 
(current_uri->firstfail+nslcd_cfg->ldc_reconnect_retrytime))
+        else if (t <= (current_uri->firstfail + 
nslcd_cfg->ldc_reconnect_retrytime))
         {
-          t+=nslcd_cfg->ldc_reconnect_sleeptime;
-          if (t<nexttry)
-            nexttry=t;
+          t += nslcd_cfg->ldc_reconnect_sleeptime;
+          if (t < nexttry)
+            nexttry = t;
         }
       }
       /* try the next URI (with wrap-around) */
       search->session->current_uri++;
-      if (nslcd_cfg->ldc_uris[search->session->current_uri].uri==NULL)
-        search->session->current_uri=0;
+      if (nslcd_cfg->ldc_uris[search->session->current_uri].uri == NULL)
+        search->session->current_uri = 0;
     }
-    while (search->session->current_uri!=start_uri);
+    while (search->session->current_uri != start_uri);
     pthread_mutex_unlock(&uris_mutex);
     /* see if it is any use sleeping */
-    if (nexttry>=endtime)
+    if (nexttry >= endtime)
     {
-      if (search->session->binddn[0]=='\0')
-        myldap_err(LOG_ERR,search->session->ld,rc,"no available LDAP server 
found");
+      if (search->session->binddn[0] == '\0')
+        myldap_err(LOG_ERR, search->session->ld, rc, "no available LDAP server 
found");
       return rc;
     }
     /* sleep between tries */
-    sleeptime=nexttry-time(NULL);
-    if (sleeptime>0)
+    sleeptime = nexttry - time(NULL);
+    if (sleeptime > 0)
     {
-      log_log(LOG_WARNING,"no available LDAP server found, sleeping %d 
seconds",sleeptime);
+      log_log(LOG_WARNING, "no available LDAP server found, sleeping %d 
seconds",
+              sleeptime);
       (void)sleep(sleeptime);
     }
   }
 }
 
-MYLDAP_SEARCH *myldap_search(
-        MYLDAP_SESSION *session,
-        const char *base,int scope,const char *filter,const char **attrs,
-        int *rcp)
+MYLDAP_SEARCH *myldap_search(MYLDAP_SESSION *session,
+                             const char *base, int scope, const char *filter,
+                             const char **attrs, int *rcp)
 {
   MYLDAP_SEARCH *search;
   int i;
   int rc;
   /* check parameters */
-  if (!is_valid_session(session)||(base==NULL)||(filter==NULL)||(attrs==NULL))
+  if (!is_valid_session(session) || (base == NULL) || (filter == NULL) ||
+      (attrs == NULL))
   {
-    log_log(LOG_ERR,"myldap_search(): invalid parameter passed");
-    errno=EINVAL;
-    if (rcp!=NULL)
-      *rcp=LDAP_OPERATIONS_ERROR;
+    log_log(LOG_ERR, "myldap_search(): invalid parameter passed");
+    errno = EINVAL;
+    if (rcp != NULL)
+      *rcp = LDAP_OPERATIONS_ERROR;
     return NULL;
   }
   /* log the call */
-  log_log(LOG_DEBUG,"myldap_search(base=\"%s\", filter=\"%s\")",
-                    base,filter);
+  log_log(LOG_DEBUG, "myldap_search(base=\"%s\", filter=\"%s\")",
+          base, filter);
   /* check if the idle time for the connection has expired */
   myldap_session_check(session);
   /* allocate a new search entry */
-  search=myldap_search_new(session,base,scope,filter,attrs);
+  search = myldap_search_new(session, base, scope, filter, attrs);
   /* find a place in the session where we can register our search */
-  for (i=0;(session->searches[i]!=NULL)&&(i<MAX_SEARCHES_IN_SESSION);i++)
-    ;
-  if (i>=MAX_SEARCHES_IN_SESSION)
+  for (i = 0; (session->searches[i] != NULL) && (i < MAX_SEARCHES_IN_SESSION); 
i++)
+    /* nothing */ ;
+  if (i >= MAX_SEARCHES_IN_SESSION)
   {
-    log_log(LOG_ERR,"myldap_search(): too many searches registered with 
session (max %d)",
-                    MAX_SEARCHES_IN_SESSION);
+    log_log(LOG_ERR, "myldap_search(): too many searches registered with 
session (max %d)",
+            MAX_SEARCHES_IN_SESSION);
     myldap_search_close(search);
-    if (rcp!=NULL)
-      *rcp=LDAP_OPERATIONS_ERROR;
+    if (rcp != NULL)
+      *rcp = LDAP_OPERATIONS_ERROR;
     return NULL;
   }
   /* regsiter search with the session so we can free it later on */
-  session->searches[i]=search;
+  session->searches[i] = search;
   /* do the search with retries to all configured servers */
-  rc=do_retry_search(search);
-  if (rc!=LDAP_SUCCESS)
+  rc = do_retry_search(search);
+  if (rc != LDAP_SUCCESS)
   {
     myldap_search_close(search);
-    if (rcp!=NULL)
-      *rcp=rc;
+    if (rcp != NULL)
+      *rcp = rc;
     return NULL;
   }
-  if (rcp!=NULL)
-    *rcp=LDAP_SUCCESS;
+  if (rcp != NULL)
+    *rcp = LDAP_SUCCESS;
   return search;
 }
 
 void myldap_search_close(MYLDAP_SEARCH *search)
 {
   int i;
-  if (search==NULL)
+  if (search == NULL)
     return;
   /* free any messages */
-  if (search->msg!=NULL)
+  if (search->msg != NULL)
   {
     ldap_msgfree(search->msg);
-    search->msg=NULL;
+    search->msg = NULL;
   }
   /* abandon the search if there were more results to fetch */
-  if ((search->session->ld!=NULL)&&(search->msgid!=-1))
+  if ((search->session->ld != NULL) && (search->msgid != -1))
   {
-    ldap_abandon(search->session->ld,search->msgid);
-    search->msgid=-1;
+    ldap_abandon(search->session->ld, search->msgid);
+    search->msgid = -1;
   }
   /* find the reference to this search in the session */
-  for (i=0;i<MAX_SEARCHES_IN_SESSION;i++)
+  for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
   {
-    if (search->session->searches[i]==search)
-      search->session->searches[i]=NULL;
+    if (search->session->searches[i] == search)
+      search->session->searches[i] = NULL;
   }
   /* free any search entries */
-  if (search->entry!=NULL)
+  if (search->entry != NULL)
     myldap_entry_free(search->entry);
   /* clean up cookie */
-  if (search->cookie!=NULL)
+  if (search->cookie != NULL)
     ber_bvfree(search->cookie);
   /* free read messages */
-  if (search->msg!=NULL)
+  if (search->msg != NULL)
     ldap_msgfree(search->msg);
   /* free the storage we allocated */
   free(search);
 }
 
-MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search,int *rcp)
+MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search, int *rcp)
 {
   int rc;
   int parserc;
   int msgid;
-  struct timeval tv,*tvp;
+  struct timeval tv, *tvp;
   LDAPControl **resultcontrols;
   LDAPControl *serverctrls[2];
   ber_int_t count;
   /* check parameters */
   if (!is_valid_search(search))
   {
-    log_log(LOG_ERR,"myldap_get_entry(): invalid search passed");
-    errno=EINVAL;
-    if (rcp!=NULL)
-      *rcp=LDAP_OPERATIONS_ERROR;
+    log_log(LOG_ERR, "myldap_get_entry(): invalid search passed");
+    errno = EINVAL;
+    if (rcp != NULL)
+      *rcp = LDAP_OPERATIONS_ERROR;
     return NULL;
   }
   /* check if the connection wasn't closed in another search */
   if (!search->valid)
   {
-    log_log(LOG_WARNING,"myldap_get_entry(): connection was closed");
+    log_log(LOG_WARNING, "myldap_get_entry(): connection was closed");
     /* retry the search */
     if (search->may_retry_search)
     {
-      log_log(LOG_DEBUG,"myldap_get_entry(): retry search");
-      search->may_retry_search=0;
-      if (do_retry_search(search)==LDAP_SUCCESS)
-        return myldap_get_entry(search,rcp);
+      log_log(LOG_DEBUG, "myldap_get_entry(): retry search");
+      search->may_retry_search = 0;
+      if (do_retry_search(search) == LDAP_SUCCESS)
+        return myldap_get_entry(search, rcp);
     }
     myldap_search_close(search);
-    if (rcp!=NULL)
-      *rcp=LDAP_SERVER_DOWN;
+    if (rcp != NULL)
+      *rcp = LDAP_SERVER_DOWN;
     return NULL;
   }
   /* set up a timelimit value for operations */
-  if (nslcd_cfg->ldc_timelimit==LDAP_NO_LIMIT)
-    tvp=NULL;
+  if (nslcd_cfg->ldc_timelimit == LDAP_NO_LIMIT)
+    tvp = NULL;
   else
   {
-    tv.tv_sec=nslcd_cfg->ldc_timelimit;
-    tv.tv_usec=0;
-    tvp=&tv;
+    tv.tv_sec = nslcd_cfg->ldc_timelimit;
+    tv.tv_usec = 0;
+    tvp = &tv;
   }
   /* if we have an existing result entry, free it */
-  if (search->entry!=NULL)
+  if (search->entry != NULL)
   {
     myldap_entry_free(search->entry);
-    search->entry=NULL;
+    search->entry = NULL;
   }
   /* try to parse results until we have a final error or ok */
   while (1)
   {
     /* free the previous message if there was any */
-    if (search->msg!=NULL)
+    if (search->msg != NULL)
     {
       ldap_msgfree(search->msg);
-      search->msg=NULL;
+      search->msg = NULL;
     }
     /* get the next result */
-    
rc=ldap_result(search->session->ld,search->msgid,LDAP_MSG_ONE,tvp,&(search->msg));
+    rc = ldap_result(search->session->ld, search->msgid, LDAP_MSG_ONE, tvp,
+                     &(search->msg));
     /* handle result */
     switch (rc)
     {
       case LDAP_RES_SEARCH_ENTRY:
         /* we have a normal search entry, update timestamp and return result */
         time(&(search->session->lastactivity));
-        search->entry=myldap_entry_new(search);
-        if (rcp!=NULL)
-          *rcp=LDAP_SUCCESS;
+        search->entry = myldap_entry_new(search);
+        if (rcp != NULL)
+          *rcp = LDAP_SUCCESS;
         /* log the first couple of dns in the result (but not all, to
            prevent swamping the log) */
-        if (search->count<MAX_DEBUG_LOG_DNS)
-          log_log(LOG_DEBUG,"ldap_result(): %s",myldap_get_dn(search->entry));
+        if (search->count < MAX_DEBUG_LOG_DNS)
+          log_log(LOG_DEBUG, "ldap_result(): %s", 
myldap_get_dn(search->entry));
         search->count++;
-        search->may_retry_search=0;
+        search->may_retry_search = 0;
         return search->entry;
       case LDAP_RES_SEARCH_RESULT:
         /* we have a search result, parse it */
-        resultcontrols=NULL;
-        if (search->cookie!=NULL)
+        resultcontrols = NULL;
+        if (search->cookie != NULL)
         {
           ber_bvfree(search->cookie);
-          search->cookie=NULL;
+          search->cookie = NULL;
         }
         /* NB: this frees search->msg */
-        parserc=ldap_parse_result(search->session->ld,search->msg,&rc,NULL,
-                                  NULL,NULL,&resultcontrols,1);
-        search->msg=NULL;
+        parserc = ldap_parse_result(search->session->ld, search->msg, &rc,
+                                    NULL, NULL, NULL, &resultcontrols, 1);
+        search->msg = NULL;
         /* check for errors during parsing */
-        if ((parserc!=LDAP_SUCCESS)&&(parserc!=LDAP_MORE_RESULTS_TO_RETURN))
+        if ((parserc != LDAP_SUCCESS) && (parserc != 
LDAP_MORE_RESULTS_TO_RETURN))
         {
-          if (resultcontrols!=NULL)
+          if (resultcontrols != NULL)
             ldap_controls_free(resultcontrols);
-          myldap_err(LOG_ERR,search->session->ld,parserc,"ldap_parse_result() 
failed");
+          myldap_err(LOG_ERR, search->session->ld, parserc, 
"ldap_parse_result() failed");
           myldap_search_close(search);
-          if (rcp!=NULL)
-            *rcp=parserc;
+          if (rcp != NULL)
+            *rcp = parserc;
           return NULL;
         }
         /* check for errors in message */
-        if ((rc!=LDAP_SUCCESS)&&(rc!=LDAP_MORE_RESULTS_TO_RETURN))
+        if ((rc != LDAP_SUCCESS) && (rc != LDAP_MORE_RESULTS_TO_RETURN))
         {
-          if (resultcontrols!=NULL)
+          if (resultcontrols != NULL)
             ldap_controls_free(resultcontrols);
-          myldap_err(LOG_ERR,search->session->ld,rc,"ldap_result() failed");
+          myldap_err(LOG_ERR, search->session->ld, rc, "ldap_result() failed");
           /* close connection on connection problems */
-          if ((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN))
+          if ((rc == LDAP_UNAVAILABLE) || (rc == LDAP_SERVER_DOWN))
             do_close(search->session);
           myldap_search_close(search);
-          if (rcp!=NULL)
-            *rcp=rc;
+          if (rcp != NULL)
+            *rcp = rc;
           return NULL;
         }
         /* handle result controls */
-        if (resultcontrols!=NULL)
+        if (resultcontrols != NULL)
         {
           /* see if there are any more pages to come */
-          rc=ldap_parse_page_control(search->session->ld,
-                                    resultcontrols,&count,
-                                    &(search->cookie));
-          if (rc!=LDAP_SUCCESS)
+          rc = ldap_parse_page_control(search->session->ld, resultcontrols,
+                                       &count, &(search->cookie));
+          if (rc != LDAP_SUCCESS)
           {
-            
myldap_err(LOG_WARNING,search->session->ld,rc,"ldap_parse_page_control() 
failed");
+            myldap_err(LOG_WARNING, search->session->ld, rc, 
"ldap_parse_page_control() failed");
             /* clear error flag */
-            rc=LDAP_SUCCESS;
-            if 
(ldap_set_option(search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-              log_log(LOG_WARNING,"failed to clear the error flag");
+            rc = LDAP_SUCCESS;
+            if (ldap_set_option(search->session->ld, LDAP_OPT_ERROR_NUMBER,
+                                &rc) != LDAP_SUCCESS)
+              log_log(LOG_WARNING, "failed to clear the error flag");
           }
           /* TODO: handle the above return code?? */
           ldap_controls_free(resultcontrols);
         }
-        search->msgid=-1;
+        search->msgid = -1;
         /* check if there are more pages to come */
-        if ((search->cookie==NULL)||(search->cookie->bv_len==0))
+        if ((search->cookie == NULL) || (search->cookie->bv_len == 0))
         {
-          if (search->count>MAX_DEBUG_LOG_DNS)
-            log_log(LOG_DEBUG,"ldap_result(): ... %d more results",
-                              search->count-MAX_DEBUG_LOG_DNS);
-          log_log(LOG_DEBUG,"ldap_result(): end of results (%d total)",
-                            search->count);
+          if (search->count > MAX_DEBUG_LOG_DNS)
+            log_log(LOG_DEBUG, "ldap_result(): ... %d more results",
+                    search->count - MAX_DEBUG_LOG_DNS);
+          log_log(LOG_DEBUG, "ldap_result(): end of results (%d total)",
+                  search->count);
           /* we are at the end of the search, no more results */
           myldap_search_close(search);
-          if (rcp!=NULL)
-            *rcp=LDAP_SUCCESS;
+          if (rcp != NULL)
+            *rcp = LDAP_SUCCESS;
           return NULL;
         }
         /* try the next page */
-        serverctrls[0]=NULL;
-        serverctrls[1]=NULL;
-        rc=ldap_create_page_control(search->session->ld,
-                                    nslcd_cfg->ldc_pagesize,
-                                    search->cookie,0,&serverctrls[0]);
-        if (rc!=LDAP_SUCCESS)
+        serverctrls[0] = NULL;
+        serverctrls[1] = NULL;
+        rc = ldap_create_page_control(search->session->ld, 
nslcd_cfg->ldc_pagesize,
+                                      search->cookie, 0, &serverctrls[0]);
+        if (rc != LDAP_SUCCESS)
         {
-          if (serverctrls[0]!=NULL)
+          if (serverctrls[0] != NULL)
             ldap_control_free(serverctrls[0]);
-          
myldap_err(LOG_WARNING,search->session->ld,rc,"ldap_create_page_control() 
failed");
+          myldap_err(LOG_WARNING, search->session->ld, rc, 
"ldap_create_page_control() failed");
           myldap_search_close(search);
-          if (rcp!=NULL)
-            *rcp=rc;
+          if (rcp != NULL)
+            *rcp = rc;
           return NULL;
         }
         /* set up a new search for the next page */
-        rc=ldap_search_ext(search->session->ld,
-                           search->base,search->scope,search->filter,
-                           search->attrs,0,serverctrls,NULL,NULL,
-                           LDAP_NO_LIMIT,&msgid);
+        rc = ldap_search_ext(search->session->ld,
+                             search->base, search->scope, search->filter,
+                             search->attrs, 0, serverctrls, NULL, NULL,
+                             LDAP_NO_LIMIT, &msgid);
         ldap_control_free(serverctrls[0]);
-        if (rc!=LDAP_SUCCESS)
+        if (rc != LDAP_SUCCESS)
         {
-          myldap_err(LOG_WARNING,search->session->ld,rc,"ldap_search_ext() 
failed");
+          myldap_err(LOG_WARNING, search->session->ld, rc, "ldap_search_ext() 
failed");
           /* close connection on connection problems */
-          if ((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN))
+          if ((rc == LDAP_UNAVAILABLE) || (rc == LDAP_SERVER_DOWN))
             do_close(search->session);
           myldap_search_close(search);
-          if (rcp!=NULL)
-            *rcp=rc;
+          if (rcp != NULL)
+            *rcp = rc;
           return NULL;
         }
-        search->msgid=msgid;
+        search->msgid = msgid;
         /* we continue with another pass */
         break;
       case LDAP_RES_SEARCH_REFERENCE:
@@ -1308,39 +1339,40 @@
         {
           case -1:
             /* try to get error code */
-            if 
(ldap_get_option(search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-              rc=LDAP_UNAVAILABLE;
-            myldap_err(LOG_ERR,search->session->ld,rc,"ldap_result() failed");
+            if (ldap_get_option(search->session->ld, LDAP_OPT_ERROR_NUMBER,
+                                &rc) != LDAP_SUCCESS)
+              rc = LDAP_UNAVAILABLE;
+            myldap_err(LOG_ERR, search->session->ld, rc, "ldap_result() 
failed");
             break;
           case 0:
             /* the timeout expired */
-            log_log(LOG_ERR,"ldap_result() timed out");
-            rc=LDAP_TIMELIMIT_EXCEEDED;
+            log_log(LOG_ERR, "ldap_result() timed out");
+            rc = LDAP_TIMELIMIT_EXCEEDED;
             break;
           default:
             /* unknown code */
-            log_log(LOG_WARNING,"ldap_result() returned unexpected result 
type");
-            rc=LDAP_PROTOCOL_ERROR;
+            log_log(LOG_WARNING, "ldap_result() returned unexpected result 
type");
+            rc = LDAP_PROTOCOL_ERROR;
         }
         /* close connection on some connection problems */
-        if 
((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN)||(rc==LDAP_SUCCESS)||
-            (rc==LDAP_TIMELIMIT_EXCEEDED)||(rc==LDAP_OPERATIONS_ERROR)||
-            (rc==LDAP_PROTOCOL_ERROR))
+        if ((rc == LDAP_UNAVAILABLE) || (rc == LDAP_SERVER_DOWN) ||
+            (rc == LDAP_SUCCESS) || (rc == LDAP_TIMELIMIT_EXCEEDED) ||
+            (rc == LDAP_OPERATIONS_ERROR) || (rc == LDAP_PROTOCOL_ERROR))
         {
           do_close(search->session);
           /* retry once if no data has been received yet */
           if (search->may_retry_search)
           {
-            log_log(LOG_DEBUG,"myldap_get_entry(): retry search");
-            search->may_retry_search=0;
-            if (do_retry_search(search)==LDAP_SUCCESS)
-              return myldap_get_entry(search,rcp);
+            log_log(LOG_DEBUG, "myldap_get_entry(): retry search");
+            search->may_retry_search = 0;
+            if (do_retry_search(search) == LDAP_SUCCESS)
+              return myldap_get_entry(search, rcp);
           }
         }
         /* close search */
         myldap_search_close(search);
-        if (rcp!=NULL)
-          *rcp=rc;
+        if (rcp != NULL)
+          *rcp = rc;
         return NULL;
     }
   }
@@ -1355,133 +1387,134 @@
   /* check parameters */
   if (!is_valid_entry(entry))
   {
-    log_log(LOG_ERR,"myldap_get_dn(): invalid result entry passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_dn(): invalid result entry passed");
+    errno = EINVAL;
     return "unknown";
   }
   /* if we don't have it yet, retreive it */
-  if ((entry->dn==NULL)&&(entry->search->valid))
+  if ((entry->dn == NULL) && (entry->search->valid))
   {
-    entry->dn=ldap_get_dn(entry->search->session->ld,entry->search->msg);
-    if (entry->dn==NULL)
+    entry->dn = ldap_get_dn(entry->search->session->ld, entry->search->msg);
+    if (entry->dn == NULL)
     {
-      if 
(ldap_get_option(entry->search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-        rc=LDAP_UNAVAILABLE;
-      myldap_err(LOG_WARNING,entry->search->session->ld,rc,"ldap_get_dn() 
returned NULL");
+      if (ldap_get_option(entry->search->session->ld, LDAP_OPT_ERROR_NUMBER,
+                          &rc) != LDAP_SUCCESS)
+        rc = LDAP_UNAVAILABLE;
+      myldap_err(LOG_WARNING, entry->search->session->ld, rc, "ldap_get_dn() 
returned NULL");
       /* close connection on connection problems */
-      if ((rc==LDAP_UNAVAILABLE)||(rc==LDAP_SERVER_DOWN))
+      if ((rc == LDAP_UNAVAILABLE) || (rc == LDAP_SERVER_DOWN))
         do_close(entry->search->session);
     }
   }
   /* if we still don't have it, return unknown */
-  if (entry->dn==NULL)
+  if (entry->dn == NULL)
     return "unknown";
   /* return it */
   return entry->dn;
 }
 
-char *myldap_cpy_dn(MYLDAP_ENTRY *entry,char *buf,size_t buflen)
+char *myldap_cpy_dn(MYLDAP_ENTRY *entry, char *buf, size_t buflen)
 {
   const char *dn;
   /* get the dn */
-  dn=myldap_get_dn(entry);
+  dn = myldap_get_dn(entry);
   /* copy into buffer */
-  if (strlen(dn)<buflen)
-    strcpy(buf,dn);
+  if (strlen(dn) < buflen)
+    strcpy(buf, dn);
   else
-    buf=NULL;
+    buf = NULL;
   return buf;
 }
 
 /* Perform ranged retreival of attributes.
    http://msdn.microsoft.com/en-us/library/aa367017(vs.85).aspx
    http://www.tkk.fi/cc/docs/kerberos/draft-kashi-incremental-00.txt */
-static SET *myldap_get_ranged_values(MYLDAP_ENTRY *entry,const char *attr)
+static SET *myldap_get_ranged_values(MYLDAP_ENTRY *entry, const char *attr)
 {
   char **values;
   char *attn;
   const char *attrs[2];
   BerElement *ber;
   int i;
-  int startat=0,nxt=0;
+  int startat = 0, nxt = 0;
   char attbuf[80];
-  const char *dn=myldap_get_dn(entry);
-  MYLDAP_SESSION *session=entry->search->session;
-  MYLDAP_SEARCH *search=NULL;
-  SET *set=NULL;
+  const char *dn = myldap_get_dn(entry);
+  MYLDAP_SESSION *session = entry->search->session;
+  MYLDAP_SEARCH *search = NULL;
+  SET *set = NULL;
   /* build the attribute name to find */
-  if (mysnprintf(attbuf,sizeof(attbuf),"%s;range=0-*",attr))
+  if (mysnprintf(attbuf, sizeof(attbuf), "%s;range=0-*", attr))
     return NULL;
   /* keep doing lookups untul we can't get any more results */
   while (1)
   {
     /* go over all attributes to find the ranged attribute */
-    ber=NULL;
-    
attn=ldap_first_attribute(entry->search->session->ld,entry->search->msg,&ber);
-    values=NULL;
-    while (attn!=NULL)
+    ber = NULL;
+    attn = ldap_first_attribute(entry->search->session->ld, 
entry->search->msg, &ber);
+    values = NULL;
+    while (attn != NULL)
     {
-      if (strncasecmp(attn,attbuf,strlen(attbuf)-1)==0)
+      if (strncasecmp(attn, attbuf, strlen(attbuf) - 1) == 0)
       {
-        log_log(LOG_DEBUG,"found ranged results %s",attn);
-        nxt=atoi(attn+strlen(attbuf)-1)+1;
-        
values=ldap_get_values(entry->search->session->ld,entry->search->msg,attn);
+        log_log(LOG_DEBUG, "found ranged results %s", attn);
+        nxt = atoi(attn + strlen(attbuf) - 1) + 1;
+        values = ldap_get_values(entry->search->session->ld, 
entry->search->msg, attn);
         ldap_memfree(attn);
         break;
       }
       /* free old attribute name and get next one */
       ldap_memfree(attn);
-      
attn=ldap_next_attribute(entry->search->session->ld,entry->search->msg,ber);
+      attn = ldap_next_attribute(entry->search->session->ld, 
entry->search->msg, ber);
     }
-    ber_free(ber,0);
+    ber_free(ber, 0);
     /* see if we found any values */
-    if ((values==NULL)||(*values==NULL))
+    if ((values == NULL) || (*values == NULL))
       break;
     /* allocate memory */
-    if (set==NULL)
+    if (set == NULL)
     {
-      set=set_new();
-      if (set==NULL)
+      set = set_new();
+      if (set == NULL)
       {
         ldap_value_free(values);
-        log_log(LOG_CRIT,"myldap_get_ranged_values(): set_new() failed to 
allocate memory");
+        log_log(LOG_CRIT, "myldap_get_ranged_values(): set_new() failed to 
allocate memory");
         return NULL;
       }
     }
     /* add to the set */
-    for (i=0;values[i]!=NULL;i++)
-      set_add(set,values[i]);
+    for (i = 0; values[i] != NULL; i++)
+      set_add(set, values[i]);
     /* free results */
     ldap_value_free(values);
     /* check if we should start a new search */
-    if (nxt<=startat)
+    if (nxt <= startat)
       break;
-    startat=nxt;
+    startat = nxt;
     /* build attributes for a new search */
-    if (mysnprintf(attbuf,sizeof(attbuf),"%s;range=%d-*",attr,startat))
+    if (mysnprintf(attbuf, sizeof(attbuf), "%s;range=%d-*", attr, startat))
       break;
-    attrs[0]=attbuf;
-    attrs[1]=NULL;
+    attrs[0] = attbuf;
+    attrs[1] = NULL;
     /* close the previous search, if any */
-    if (search!=NULL)
+    if (search != NULL)
       myldap_search_close(search);
     /* start the new search */
-    
search=myldap_search(session,dn,LDAP_SCOPE_BASE,"(objectClass=*)",attrs,NULL);
-    if (search==NULL)
+    search = myldap_search(session, dn, LDAP_SCOPE_BASE, "(objectClass=*)", 
attrs, NULL);
+    if (search == NULL)
       break;
-    entry=myldap_get_entry(search,NULL);
-    if (entry==NULL)
+    entry = myldap_get_entry(search, NULL);
+    if (entry == NULL)
       break;
   }
   /* close any started searches */
-  if (search!=NULL)
+  if (search != NULL)
     myldap_search_close(search);
   /* return the contents of the set as a list */
   return set;
 }
 
 /* Simple wrapper around ldap_get_values(). */
-const char **myldap_get_values(MYLDAP_ENTRY *entry,const char *attr)
+const char **myldap_get_values(MYLDAP_ENTRY *entry, const char *attr)
 {
   char **values;
   int rc;
@@ -1490,66 +1523,66 @@
   /* check parameters */
   if (!is_valid_entry(entry))
   {
-    log_log(LOG_ERR,"myldap_get_values(): invalid result entry passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_values(): invalid result entry passed");
+    errno = EINVAL;
     return NULL;
   }
-  else if (attr==NULL)
+  else if (attr == NULL)
   {
-    log_log(LOG_ERR,"myldap_get_values(): invalid attribute name passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_values(): invalid attribute name passed");
+    errno = EINVAL;
     return NULL;
   }
   if (!entry->search->valid)
     return NULL; /* search has been stopped */
   /* get from LDAP */
-  values=ldap_get_values(entry->search->session->ld,entry->search->msg,attr);
-  if (values==NULL)
+  values = ldap_get_values(entry->search->session->ld, entry->search->msg, 
attr);
+  if (values == NULL)
   {
-    if 
(ldap_get_option(entry->search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-      rc=LDAP_UNAVAILABLE;
+    if (ldap_get_option(entry->search->session->ld, LDAP_OPT_ERROR_NUMBER, 
&rc) != LDAP_SUCCESS)
+      rc = LDAP_UNAVAILABLE;
     /* ignore decoding errors as they are just nonexisting attribute values */
-    if (rc==LDAP_DECODING_ERROR)
+    if (rc == LDAP_DECODING_ERROR)
     {
-      rc=LDAP_SUCCESS;
-      if 
(ldap_set_option(entry->search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-        log_log(LOG_WARNING,"failed to clear the error flag");
+      rc = LDAP_SUCCESS;
+      if (ldap_set_option(entry->search->session->ld, LDAP_OPT_ERROR_NUMBER, 
&rc) != LDAP_SUCCESS)
+        log_log(LOG_WARNING, "failed to clear the error flag");
     }
-    else if (rc==LDAP_SUCCESS)
+    else if (rc == LDAP_SUCCESS)
     {
       /* we have a success code but no values, let's try to get ranged
          values */
-      set=myldap_get_ranged_values(entry,attr);
-      if (set==NULL)
+      set = myldap_get_ranged_values(entry, attr);
+      if (set == NULL)
         return NULL;
       /* store values entry so we can free it later on */
-      for (i=0;i<MAX_RANGED_ATTRIBUTES_PER_ENTRY;i++)
-        if (entry->rangedattributevalues[i]==NULL)
+      for (i = 0; i < MAX_RANGED_ATTRIBUTES_PER_ENTRY; i++)
+        if (entry->rangedattributevalues[i] == NULL)
         {
-          entry->rangedattributevalues[i]=(char **)set_tolist(set);
+          entry->rangedattributevalues[i] = (char **)set_tolist(set);
           set_free(set);
           return (const char **)entry->rangedattributevalues[i];
         }
       /* we found no room to store the values */
-      log_log(LOG_ERR,"ldap_get_values() couldn't store results, increase 
MAX_RANGED_ATTRIBUTES_PER_ENTRY");
+      log_log(LOG_ERR, "ldap_get_values() couldn't store results, increase 
MAX_RANGED_ATTRIBUTES_PER_ENTRY");
       set_free(set);
       return NULL;
     }
     else
-      myldap_err(LOG_WARNING,entry->search->session->ld,rc,
+      myldap_err(LOG_WARNING, entry->search->session->ld, rc,
                  "ldap_get_values() of attribute \"%s\" on entry \"%s\" 
returned NULL",
-                 attr,myldap_get_dn(entry));
+                 attr, myldap_get_dn(entry));
     return NULL;
   }
   /* store values entry so we can free it later on */
-  for (i=0;i<MAX_ATTRIBUTES_PER_ENTRY;i++)
-    if (entry->attributevalues[i]==NULL)
+  for (i = 0; i < MAX_ATTRIBUTES_PER_ENTRY; i++)
+    if (entry->attributevalues[i] == NULL)
     {
-      entry->attributevalues[i]=values;
+      entry->attributevalues[i] = values;
       return (const char **)values;
     }
   /* we found no room to store the entry */
-  log_log(LOG_ERR,"ldap_get_values() couldn't store results, increase 
MAX_ATTRIBUTES_PER_ENTRY");
+  log_log(LOG_ERR, "ldap_get_values() couldn't store results, increase 
MAX_ATTRIBUTES_PER_ENTRY");
   ldap_value_free(values);
   return NULL;
 }
@@ -1564,34 +1597,34 @@
   char *buf;
   char **values;
   /* figure out how much memory to allocate */
-  num_values=ldap_count_values_len(bvalues);
-  sz=(num_values+1)*sizeof(char *);
-  for (i=0;i<num_values;i++)
-    sz+=bvalues[i]->bv_len+1;
+  num_values = ldap_count_values_len(bvalues);
+  sz = (num_values + 1) * sizeof(char *);
+  for (i = 0; i < num_values; i++)
+    sz += bvalues[i]->bv_len + 1;
   /* allocate the needed memory */
-  values=(char **)malloc(sz);
-  if (values==NULL)
+  values = (char **)malloc(sz);
+  if (values == NULL)
   {
-    log_log(LOG_CRIT,"myldap_get_values_len(): malloc() failed to allocate 
memory");
+    log_log(LOG_CRIT, "myldap_get_values_len(): malloc() failed to allocate 
memory");
     ldap_value_free_len(bvalues);
     return NULL;
   }
-  buf=(char *)values;
-  buf+=(num_values+1)*sizeof(char *);
+  buf = (char *)values;
+  buf += (num_values + 1) * sizeof(char *);
   /* copy from bvalues */
-  for (i=0;i<num_values;i++)
+  for (i = 0; i < num_values; i++)
   {
-    values[i]=buf;
-    memcpy(values[i],bvalues[i]->bv_val,bvalues[i]->bv_len);
-    values[i][bvalues[i]->bv_len]='\0';
-    buf+=bvalues[i]->bv_len+1;
+    values[i] = buf;
+    memcpy(values[i], bvalues[i]->bv_val, bvalues[i]->bv_len);
+    values[i][bvalues[i]->bv_len] = '\0';
+    buf += bvalues[i]->bv_len + 1;
   }
-  values[i]=NULL;
+  values[i] = NULL;
   return (const char **)values;
 }
 
 /* Simple wrapper around ldap_get_values(). */
-const char **myldap_get_values_len(MYLDAP_ENTRY *entry,const char *attr)
+const char **myldap_get_values_len(MYLDAP_ENTRY *entry, const char *attr)
 {
   const char **values;
   struct berval **bvalues;
@@ -1601,63 +1634,63 @@
   /* check parameters */
   if (!is_valid_entry(entry))
   {
-    log_log(LOG_ERR,"myldap_get_values_len(): invalid result entry passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_values_len(): invalid result entry passed");
+    errno = EINVAL;
     return NULL;
   }
-  else if (attr==NULL)
+  else if (attr == NULL)
   {
-    log_log(LOG_ERR,"myldap_get_values_len(): invalid attribute name passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_values_len(): invalid attribute name passed");
+    errno = EINVAL;
     return NULL;
   }
   if (!entry->search->valid)
     return NULL; /* search has been stopped */
   /* get from LDAP */
-  
bvalues=ldap_get_values_len(entry->search->session->ld,entry->search->msg,attr);
-  if (bvalues==NULL)
+  bvalues = ldap_get_values_len(entry->search->session->ld, 
entry->search->msg, attr);
+  if (bvalues == NULL)
   {
-    if 
(ldap_get_option(entry->search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-      rc=LDAP_UNAVAILABLE;
+    if (ldap_get_option(entry->search->session->ld, LDAP_OPT_ERROR_NUMBER, 
&rc) != LDAP_SUCCESS)
+      rc = LDAP_UNAVAILABLE;
     /* ignore decoding errors as they are just nonexisting attribute values */
-    if (rc==LDAP_DECODING_ERROR)
+    if (rc == LDAP_DECODING_ERROR)
     {
-      rc=LDAP_SUCCESS;
-      if 
(ldap_set_option(entry->search->session->ld,LDAP_OPT_ERROR_NUMBER,&rc)!=LDAP_SUCCESS)
-        log_log(LOG_WARNING,"failed to clear the error flag");
+      rc = LDAP_SUCCESS;
+      if (ldap_set_option(entry->search->session->ld, LDAP_OPT_ERROR_NUMBER, 
&rc) != LDAP_SUCCESS)
+        log_log(LOG_WARNING, "failed to clear the error flag");
       return NULL;
     }
-    else if (rc==LDAP_SUCCESS)
+    else if (rc == LDAP_SUCCESS)
     {
       /* we have a success code but no values, let's try to get ranged
          values */
-      set=myldap_get_ranged_values(entry,attr);
-      if (set==NULL)
+      set = myldap_get_ranged_values(entry, attr);
+      if (set == NULL)
         return NULL;
-      values=set_tolist(set);
+      values = set_tolist(set);
     }
     else
     {
-      myldap_err(LOG_WARNING,entry->search->session->ld,rc,
+      myldap_err(LOG_WARNING, entry->search->session->ld, rc,
                  "myldap_get_values_len() of attribute \"%s\" on entry \"%s\" 
returned NULL",
-                 attr,myldap_get_dn(entry));
+                 attr, myldap_get_dn(entry));
       return NULL;
     }
   }
   else
   {
-    values=bervalues_to_values(bvalues);
+    values = bervalues_to_values(bvalues);
     ldap_value_free_len(bvalues);
   }
   /* store values entry so we can free it later on */
-  for (i=0;i<MAX_RANGED_ATTRIBUTES_PER_ENTRY;i++)
-    if (entry->rangedattributevalues[i]==NULL)
+  for (i = 0; i < MAX_RANGED_ATTRIBUTES_PER_ENTRY; i++)
+    if (entry->rangedattributevalues[i] == NULL)
     {
-      entry->rangedattributevalues[i]=(char **)values;
+      entry->rangedattributevalues[i] = (char **)values;
       return values;
     }
   /* we found no room to store the values */
-  log_log(LOG_ERR,"myldap_get_values_len() couldn't store results, increase 
MAX_RANGED_ATTRIBUTES_PER_ENTRY");
+  log_log(LOG_ERR, "myldap_get_values_len() couldn't store results, increase 
MAX_RANGED_ATTRIBUTES_PER_ENTRY");
   free(values);
   return NULL;
 }
@@ -1665,33 +1698,35 @@
 /* Go over the entries in exploded_rdn and see if any start with
    the requested attribute. Return a reference to the value part of
    the DN (does not modify exploded_rdn). */
-static const char *find_rdn_value(char **exploded_rdn,const char *attr)
+static const char *find_rdn_value(char **exploded_rdn, const char *attr)
 {
-  int i,j;
+  int i, j;
   int l;
-  if (exploded_rdn==NULL)
+  if (exploded_rdn == NULL)
     return NULL;
   /* go over all RDNs */
-  l=strlen(attr);
-  for (i=0;exploded_rdn[i]!=NULL;i++)
+  l = strlen(attr);
+  for (i = 0; exploded_rdn[i] != NULL; i++)
   {
     /* check that RDN starts with attr */
-    if (strncasecmp(exploded_rdn[i],attr,l)!=0)
+    if (strncasecmp(exploded_rdn[i], attr, l) != 0)
       continue;
-    j=l;
+    j = l;
     /* skip spaces */
-    while (isspace(exploded_rdn[i][j])) j++;
+    while (isspace(exploded_rdn[i][j]))
+      j++;
     /* ensure that we found an equals sign now */
-    if (exploded_rdn[i][j]!='=')
+    if (exploded_rdn[i][j] != '=')
       continue;
     j++;
     /* skip more spaces */
-    while (isspace(exploded_rdn[i][j])) j++;
+    while (isspace(exploded_rdn[i][j]))
+      j++;
     /* ensure that we're not at the end of the string */
-    if (exploded_rdn[i][j]=='\0')
+    if (exploded_rdn[i][j] == '\0')
       continue;
     /* we found our value */
-    return exploded_rdn[i]+j;
+    return exploded_rdn[i] + j;
   }
   /* fail */
   return NULL;
@@ -1705,26 +1740,26 @@
   char **exploded_dn;
   char **exploded_rdn;
   /* check if we have a DN */
-  if ((dn==NULL)||(strcasecmp(dn,"unknown")==0))
+  if ((dn == NULL) || (strcasecmp(dn, "unknown") == 0))
     return NULL;
   /* explode dn into { "uid=test", "ou=people", ..., NULL } */
-  exploded_dn=ldap_explode_dn(dn,0);
-  if ((exploded_dn==NULL)||(exploded_dn[0]==NULL))
+  exploded_dn = ldap_explode_dn(dn, 0);
+  if ((exploded_dn == NULL) || (exploded_dn[0] == NULL))
   {
-    log_log(LOG_WARNING,"ldap_explode_dn(%s) returned NULL: %s",
-                        dn,strerror(errno));
+    log_log(LOG_WARNING, "ldap_explode_dn(%s) returned NULL: %s",
+            dn, strerror(errno));
     return NULL;
   }
   /* explode rdn (first part of exploded_dn),
-      e.g. "cn=Test User+uid=testusr" into
+     e.g. "cn=Test User+uid=testusr" into
      { "cn=Test User", "uid=testusr", NULL } */
-  errno=0;
-  exploded_rdn=ldap_explode_rdn(exploded_dn[0],0);
-  if ((exploded_rdn==NULL)||(exploded_rdn[0]==NULL))
-  {
-    log_log(LOG_WARNING,"ldap_explode_rdn(%s) returned NULL: %s",
-                        exploded_dn[0],strerror(errno));
-    if (exploded_rdn!=NULL)
+  errno = 0;
+  exploded_rdn = ldap_explode_rdn(exploded_dn[0], 0);
+  if ((exploded_rdn == NULL) || (exploded_rdn[0] == NULL))
+  {
+    log_log(LOG_WARNING, "ldap_explode_rdn(%s) returned NULL: %s",
+            exploded_dn[0], strerror(errno));
+    if (exploded_rdn != NULL)
       ldap_value_free(exploded_rdn);
     ldap_value_free(exploded_dn);
     return NULL;
@@ -1733,111 +1768,111 @@
   return exploded_rdn;
 }
 
-const char *myldap_get_rdn_value(MYLDAP_ENTRY *entry,const char *attr)
+const char *myldap_get_rdn_value(MYLDAP_ENTRY *entry, const char *attr)
 {
   /* check parameters */
   if (!is_valid_entry(entry))
   {
-    log_log(LOG_ERR,"myldap_get_rdn_value(): invalid result entry passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_rdn_value(): invalid result entry passed");
+    errno = EINVAL;
     return NULL;
   }
-  else if (attr==NULL)
+  else if (attr == NULL)
   {
-    log_log(LOG_ERR,"myldap_get_rdn_value(): invalid attribute name passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_get_rdn_value(): invalid attribute name passed");
+    errno = EINVAL;
     return NULL;
   }
   /* check if entry contains exploded_rdn */
-  if (entry->exploded_rdn==NULL)
+  if (entry->exploded_rdn == NULL)
   {
-    entry->exploded_rdn=get_exploded_rdn(myldap_get_dn(entry));
-    if (entry->exploded_rdn==NULL)
+    entry->exploded_rdn = get_exploded_rdn(myldap_get_dn(entry));
+    if (entry->exploded_rdn == NULL)
       return NULL;
   }
   /* find rnd value */
-  return find_rdn_value(entry->exploded_rdn,attr);
+  return find_rdn_value(entry->exploded_rdn, attr);
 }
 
-const char *myldap_cpy_rdn_value(const char *dn,const char *attr,
-                                 char *buf,size_t buflen)
+const char *myldap_cpy_rdn_value(const char *dn, const char *attr,
+                                 char *buf, size_t buflen)
 {
   char **exploded_rdn;
   const char *value;
   /* explode dn into { "cn=Test", "uid=test", NULL } */
-  exploded_rdn=get_exploded_rdn(dn);
-  if (exploded_rdn==NULL)
+  exploded_rdn = get_exploded_rdn(dn);
+  if (exploded_rdn == NULL)
     return NULL;
   /* see if we have a match */
-  value=find_rdn_value(exploded_rdn,attr);
+  value = find_rdn_value(exploded_rdn, attr);
   /* if we have something store it in the buffer */
-  if ((value!=NULL)&&(strlen(value)<buflen))
-    strcpy(buf,value);
+  if ((value != NULL) && (strlen(value) < buflen))
+    strcpy(buf, value);
   else
-    value=NULL;
+    value = NULL;
   /* free allocated stuff */
   ldap_value_free(exploded_rdn);
   /* check if we have something to return */
-  return (value!=NULL)?buf:NULL;
+  return (value != NULL) ? buf : NULL;
 }
 
-int myldap_has_objectclass(MYLDAP_ENTRY *entry,const char *objectclass)
+int myldap_has_objectclass(MYLDAP_ENTRY *entry, const char *objectclass)
 {
   const char **values;
   int i;
-  if ((!is_valid_entry(entry))||(objectclass==NULL))
+  if ((!is_valid_entry(entry)) || (objectclass == NULL))
   {
-    log_log(LOG_ERR,"myldap_has_objectclass(): invalid argument passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_has_objectclass(): invalid argument passed");
+    errno = EINVAL;
     return 0;
   }
-  values=myldap_get_values(entry,"objectClass");
-  if (values==NULL)
+  values = myldap_get_values(entry, "objectClass");
+  if (values == NULL)
     return 0;
-  for (i=0;values[i]!=NULL;i++)
+  for (i = 0; values[i] != NULL; i++)
   {
-    if (strcasecmp(values[i],objectclass)==0)
+    if (strcasecmp(values[i], objectclass) == 0)
       return -1;
   }
   return 0;
 }
 
-int myldap_escape(const char *src,char *buffer,size_t buflen)
+int myldap_escape(const char *src, char *buffer, size_t buflen)
 {
-  size_t pos=0;
+  size_t pos = 0;
   /* go over all characters in source string */
-  for (;*src!='\0';src++)
+  for (; *src != '\0'; src++)
   {
     /* check if char will fit */
-    if ((pos+4)>=buflen)
+    if ((pos + 4) >= buflen)
       return -1;
     /* do escaping for some characters */
     switch (*src)
     {
       case '*':
-        strcpy(buffer+pos,"\\2a");
-        pos+=3;
+        strcpy(buffer + pos, "\\2a");
+        pos += 3;
         break;
       case '(':
-        strcpy(buffer+pos,"\\28");
-        pos+=3;
+        strcpy(buffer + pos, "\\28");
+        pos += 3;
         break;
       case ')':
-        strcpy(buffer+pos,"\\29");
-        pos+=3;
+        strcpy(buffer + pos, "\\29");
+        pos += 3;
         break;
       case '\\':
-        strcpy(buffer+pos,"\\5c");
-        pos+=3;
+        strcpy(buffer + pos, "\\5c");
+        pos += 3;
         break;
       default:
         /* just copy character */
-        buffer[pos++]=*src;
+        buffer[pos++] = *src;
         break;
     }
   }
   /* terminate destination string */
-  buffer[pos]='\0';
+  buffer[pos] = '\0';
   return 0;
 }
 
@@ -1846,37 +1881,37 @@
   int i;
   int rc;
   /* turn on debugging */
-  if (level>1)
+  if (level > 1)
   {
 #ifdef LBER_OPT_LOG_PRINT_FILE
-    log_log(LOG_DEBUG,"ber_set_option(LBER_OPT_LOG_PRINT_FILE)"); \
-    rc=ber_set_option(NULL,LBER_OPT_LOG_PRINT_FILE,stderr);
-    if (rc!=LDAP_SUCCESS)
+    log_log(LOG_DEBUG, "ber_set_option(LBER_OPT_LOG_PRINT_FILE)");
+    rc = ber_set_option(NULL, LBER_OPT_LOG_PRINT_FILE, stderr);
+    if (rc != LDAP_SUCCESS)
     {
-      myldap_err(LOG_ERR,NULL,rc,"ber_set_option(LBER_OPT_LOG_PRINT_FILE) 
failed");
+      myldap_err(LOG_ERR, NULL, rc, "ber_set_option(LBER_OPT_LOG_PRINT_FILE) 
failed");
       return rc;
     }
 #endif /* LBER_OPT_LOG_PRINT_FILE */
 #ifdef LBER_OPT_DEBUG_LEVEL
-    if (level>2)
+    if (level > 2)
     {
-      i=-1;
-      log_log(LOG_DEBUG,"ber_set_option(LBER_OPT_DEBUG_LEVEL,-1)");
-      rc=ber_set_option(NULL,LBER_OPT_DEBUG_LEVEL,&i);
-      if (rc!=LDAP_SUCCESS)
+      i = -1;
+      log_log(LOG_DEBUG, "ber_set_option(LBER_OPT_DEBUG_LEVEL,-1)");
+      rc = ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, &i);
+      if (rc != LDAP_SUCCESS)
       {
-        myldap_err(LOG_ERR,NULL,rc,"ber_set_option(LBER_OPT_DEBUG_LEVEL) 
failed");
+        myldap_err(LOG_ERR, NULL, rc, "ber_set_option(LBER_OPT_DEBUG_LEVEL) 
failed");
         return rc;
       }
     }
 #endif /* LBER_OPT_DEBUG_LEVEL */
 #ifdef LDAP_OPT_DEBUG_LEVEL
-    i=-1;
-    log_log(LOG_DEBUG,"ldap_set_option(LDAP_OPT_DEBUG_LEVEL,-1)");
-    rc=ldap_set_option(NULL,LDAP_OPT_DEBUG_LEVEL,&i);
-    if (rc!=LDAP_SUCCESS)
+    i = -1;
+    log_log(LOG_DEBUG, "ldap_set_option(LDAP_OPT_DEBUG_LEVEL,-1)");
+    rc = ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &i);
+    if (rc != LDAP_SUCCESS)
     {
-      myldap_err(LOG_ERR,NULL,rc,"ldap_set_option(LDAP_OPT_DEBUG_LEVEL) 
failed");
+      myldap_err(LOG_ERR, NULL, rc, "ldap_set_option(LDAP_OPT_DEBUG_LEVEL) 
failed");
       return rc;
     }
 #endif /* LDAP_OPT_DEBUG_LEVEL */
@@ -1884,63 +1919,63 @@
   return LDAP_SUCCESS;
 }
 
-int myldap_passwd(
-        MYLDAP_SESSION *session,
-        const char *userdn,const char *oldpassword,const char *newpasswd)
+int myldap_passwd(MYLDAP_SESSION *session,
+                  const char *userdn, const char *oldpassword,
+                  const char *newpasswd)
 {
   int rc;
   struct berval ber_userdn, ber_oldpassword, ber_newpassword, ber_retpassword;
   /* check parameters */
-  if (!is_valid_session(session)||(userdn==NULL)||(newpasswd==NULL))
+  if (!is_valid_session(session) || (userdn == NULL) || (newpasswd == NULL))
   {
-    log_log(LOG_ERR,"myldap_passwd(): invalid parameter passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_passwd(): invalid parameter passed");
+    errno = EINVAL;
     return LDAP_OTHER;
   }
   /* log the call */
-  
log_log(LOG_DEBUG,"myldap_passwd(userdn=\"%s\",oldpasswd=%s,newpasswd=\"***\")",
-                    userdn,oldpassword?"\"***\"":"NULL");
+  log_log(LOG_DEBUG, 
"myldap_passwd(userdn=\"%s\",oldpasswd=%s,newpasswd=\"***\")",
+          userdn, oldpassword ? "\"***\"" : "NULL");
   /* translate to ber stuff */
-  ber_userdn.bv_val=(char *)userdn;
-  ber_userdn.bv_len=strlen(userdn);
-  ber_newpassword.bv_val=(char *)newpasswd;
-  ber_newpassword.bv_len=strlen(newpasswd);
-  ber_retpassword.bv_val=NULL;
-  ber_retpassword.bv_len=0;
+  ber_userdn.bv_val = (char *)userdn;
+  ber_userdn.bv_len = strlen(userdn);
+  ber_newpassword.bv_val = (char *)newpasswd;
+  ber_newpassword.bv_len = strlen(newpasswd);
+  ber_retpassword.bv_val = NULL;
+  ber_retpassword.bv_len = 0;
   /* perform request */
-  log_log(LOG_DEBUG,"myldap_passwd(): try ldap_passwd_s() without old 
password");
-  rc=ldap_passwd_s(session->ld,&ber_userdn,NULL,
-                   &ber_newpassword,&ber_retpassword,NULL,NULL);
-  if (rc!=LDAP_SUCCESS)
-    myldap_err(LOG_ERR,session->ld,rc,"ldap_passwd_s() without old password 
failed");
+  log_log(LOG_DEBUG, "myldap_passwd(): try ldap_passwd_s() without old 
password");
+  rc = ldap_passwd_s(session->ld, &ber_userdn, NULL, &ber_newpassword,
+                     &ber_retpassword, NULL, NULL);
+  if (rc != LDAP_SUCCESS)
+    myldap_err(LOG_ERR, session->ld, rc, "ldap_passwd_s() without old password 
failed");
   /* free returned data if needed */
-  if (ber_retpassword.bv_val!=NULL)
+  if (ber_retpassword.bv_val != NULL)
     ldap_memfree(ber_retpassword.bv_val);
-  if ((rc!=LDAP_SUCCESS)&&(oldpassword!=NULL))
+  if ((rc != LDAP_SUCCESS) && (oldpassword != NULL))
   {
     /* retry with old password */
-    log_log(LOG_DEBUG,"myldap_passwd(): try ldap_passwd_s() with old 
password");
-    ber_oldpassword.bv_val=(char *)oldpassword;
-    ber_oldpassword.bv_len=strlen(oldpassword);
+    log_log(LOG_DEBUG, "myldap_passwd(): try ldap_passwd_s() with old 
password");
+    ber_oldpassword.bv_val = (char *)oldpassword;
+    ber_oldpassword.bv_len = strlen(oldpassword);
     /* perform request */
-    rc=ldap_passwd_s(session->ld,&ber_userdn,&ber_oldpassword,
-                     &ber_newpassword,&ber_retpassword,NULL,NULL);
-    if (rc!=LDAP_SUCCESS)
-      myldap_err(LOG_ERR,session->ld,rc,"ldap_passwd_s() with old password 
failed");
+    rc = ldap_passwd_s(session->ld, &ber_userdn, &ber_oldpassword,
+                       &ber_newpassword, &ber_retpassword, NULL, NULL);
+    if (rc != LDAP_SUCCESS)
+      myldap_err(LOG_ERR, session->ld, rc, "ldap_passwd_s() with old password 
failed");
     /* free returned data if needed */
-    if (ber_retpassword.bv_val!=NULL)
+    if (ber_retpassword.bv_val != NULL)
       ldap_memfree(ber_retpassword.bv_val);
   }
   return rc;
 }
 
-int myldap_modify(MYLDAP_SESSION *session,const char *dn,LDAPMod *mods[])
+int myldap_modify(MYLDAP_SESSION *session, const char *dn, LDAPMod * mods[])
 {
-  if (!is_valid_session(session)||(dn==NULL))
+  if (!is_valid_session(session) || (dn == NULL))
   {
-    log_log(LOG_ERR,"myldap_passwd(): invalid parameter passed");
-    errno=EINVAL;
+    log_log(LOG_ERR, "myldap_passwd(): invalid parameter passed");
+    errno = EINVAL;
     return LDAP_OTHER;
   }
-  return ldap_modify_ext_s(session->ld,dn,mods,NULL,NULL);
+  return ldap_modify_ext_s(session->ld, dn, mods, NULL, NULL);
 }

Modified: nss-pam-ldapd/nslcd/myldap.h
==============================================================================
--- nss-pam-ldapd/nslcd/myldap.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/myldap.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    myldap.h - simple interface to do LDAP requests
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -69,7 +69,7 @@
 MUST_USE MYLDAP_SESSION *myldap_create_session(void);
 
 /* Set alternative credentials for the session. */
-void myldap_set_credentials(MYLDAP_SESSION *session,const char *dn,
+void myldap_set_credentials(MYLDAP_SESSION *session, const char *dn,
                             const char *password);
 
 /* Closes all pending searches and deallocates any memory that is allocated
@@ -89,10 +89,10 @@
    error). This function uses paging, and does reconnects to the configured
    URLs transparently. The function returns an LDAP status code in the
    location pointed to by rcp if it is non-NULL. */
-MUST_USE MYLDAP_SEARCH *myldap_search(
-        MYLDAP_SESSION *session,
-        const char *base,int scope,const char *filter,const char **attrs,
-        int *rcp);
+MUST_USE MYLDAP_SEARCH *myldap_search(MYLDAP_SESSION *session,
+                                      const char *base, int scope,
+                                      const char *filter, const char **attrs,
+                                      int *rcp);
 
 /* Close the specified search. This frees all the memory that was allocated
    for the search and its results. */
@@ -104,51 +104,51 @@
    freed with this call. The search is autoamtically closed when no more
    results are available. The function returns an LDAP status code in the
    location pointed to by rcp if it is non-NULL. */
-MUST_USE MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search,int *rcp);
+MUST_USE MYLDAP_ENTRY *myldap_get_entry(MYLDAP_SEARCH *search, int *rcp);
 
 /* Get the DN from the entry. This function does not return NULL (on error
    "unknown" is returned). */
 MUST_USE const char *myldap_get_dn(MYLDAP_ENTRY *entry);
 
 /* Just like myldap_get_dn() but copies the result into the buffer. */
-char *myldap_cpy_dn(MYLDAP_ENTRY *entry,char *buf,size_t buflen);
+char *myldap_cpy_dn(MYLDAP_ENTRY *entry, char *buf, size_t buflen);
 
 /* Get the attribute values from a certain entry as a NULL terminated list.
    May return NULL or an empty array. */
-MUST_USE const char **myldap_get_values(MYLDAP_ENTRY *entry,const char *attr);
+MUST_USE const char **myldap_get_values(MYLDAP_ENTRY *entry, const char *attr);
 
 /* Get the attribute values from a certain entry as a NULL terminated list.
    May return NULL or an empty array. */
-MUST_USE const char **myldap_get_values_len(MYLDAP_ENTRY *entry,const char 
*attr);
+MUST_USE const char **myldap_get_values_len(MYLDAP_ENTRY *entry, const char 
*attr);
 
 /* Checks to see if the entry has the specified object class. */
-MUST_USE int myldap_has_objectclass(MYLDAP_ENTRY *entry,const char 
*objectclass);
+MUST_USE int myldap_has_objectclass(MYLDAP_ENTRY *entry, const char 
*objectclass);
 
 /* Get the RDN's value: eg. if the DN was cn=lukeh, ou=People, dc=example,
-   dc=com getrdnvalue(entry,cn) would return lukeh. If the attribute was not
+   dc=com getrdnvalue(entry, cn) would return lukeh. If the attribute was not
    found in the DN or if some error occurs NULL is returned. This method may
    be used to get the "most authorative" value for an attribute. */
-MUST_USE const char *myldap_get_rdn_value(MYLDAP_ENTRY *entry,const char 
*attr);
+MUST_USE const char *myldap_get_rdn_value(MYLDAP_ENTRY *entry, const char 
*attr);
 
 /* Just like myldap_get_rdn_value() but use the supplied character sequence
    and copies the result into the buffer.
    Returns a pointer to the start of the string on success and NULL on
    failure. */
-MUST_USE const char *myldap_cpy_rdn_value(const char *dn,const char *attr,
-                                          char *buf,size_t buflen);
+MUST_USE const char *myldap_cpy_rdn_value(const char *dn, const char *attr,
+                                          char *buf, size_t buflen);
 
 /* Escapes characters in a string for use in a search filter. */
-MUST_USE int myldap_escape(const char *src,char *buffer,size_t buflen);
+MUST_USE int myldap_escape(const char *src, char *buffer, size_t buflen);
 
 /* Set the debug level globally. Returns an LDAP status code. */
 int myldap_set_debuglevel(int level);
 
 /* Perform an EXOP password modification call. Returns an LDAP status code. */
-int myldap_passwd(
-        MYLDAP_SESSION *session,
-        const char *userdn,const char *oldpassword,const char *newpasswd);
+int myldap_passwd(MYLDAP_SESSION *session,
+                  const char *userdn, const char *oldpassword,
+                  const char *newpasswd);
 
 /* Perform an LDAP modification request. Returns an LDAP status code. */
-int myldap_modify(MYLDAP_SESSION *session,const char *dn,LDAPMod *mods[]);
+int myldap_modify(MYLDAP_SESSION *session, const char *dn, LDAPMod * mods[]);
 
 #endif /* not NSLCD__MYLDAP_H */

Modified: nss-pam-ldapd/nslcd/netgroup.c
==============================================================================
--- nss-pam-ldapd/nslcd/netgroup.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/netgroup.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -63,149 +63,148 @@
 static const char *netgroup_attrs[4];
 
 static int mkfilter_netgroup_byname(const char *name,
-                                    char *buffer,size_t buflen)
+                                    char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    netgroup_filter,
-                    attmap_netgroup_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    netgroup_filter, attmap_netgroup_cn, safename);
 }
 
 void netgroup_init(void)
 {
   int i;
   /* set up search bases */
-  if (netgroup_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      netgroup_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (netgroup_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      netgroup_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (netgroup_scope==LDAP_SCOPE_DEFAULT)
-    netgroup_scope=nslcd_cfg->ldc_scope;
+  if (netgroup_scope == LDAP_SCOPE_DEFAULT)
+    netgroup_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  netgroup_attrs[0]=attmap_netgroup_cn;
-  netgroup_attrs[1]=attmap_netgroup_nisNetgroupTriple;
-  netgroup_attrs[2]=attmap_netgroup_memberNisNetgroup;
-  netgroup_attrs[3]=NULL;
+  netgroup_attrs[0] = attmap_netgroup_cn;
+  netgroup_attrs[1] = attmap_netgroup_nisNetgroupTriple;
+  netgroup_attrs[2] = attmap_netgroup_memberNisNetgroup;
+  netgroup_attrs[3] = NULL;
 }
 
-static int write_string_stripspace_len(TFILE *fp,const char *str,int len)
+static int write_string_stripspace_len(TFILE *fp, const char *str, int len)
 {
   int32_t tmpint32;
-  int i,j;
-  DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"",str);
-  if (str==NULL)
+  int i, j;
+  DEBUG_PRINT("WRITE_STRING: var=" __STRING(str) " string=\"%s\"", str);
+  if (str == NULL)
   {
-    WRITE_INT32(fp,0);
+    WRITE_INT32(fp, 0);
   }
   else
   {
     /* skip leading spaces */
-    for (i=0;(str[i]!='\0')&&(isspace(str[i]));i++)
-      /* nothing else to do */ ;
+    for (i = 0; (str[i] != '\0') && (isspace(str[i])); i++)
+      /* nothing */ ;
     /* skip trailing spaces */
-    for (j=len;(j>i)&&(isspace(str[j-1]));j--)
-      /* nothing else to do */ ;
+    for (j = len; (j > i) && (isspace(str[j - 1])); j--)
+      /* nothing */ ;
     /* write length of string */
-    WRITE_INT32(fp,j-i);
+    WRITE_INT32(fp, j - i);
     /* write string itself */
-    if (j>i)
+    if (j > i)
     {
-      WRITE(fp,str+i,j-i);
+      WRITE(fp, str + i, j - i);
     }
   }
   /* we're done */
   return 0;
 }
 
-#define WRITE_STRING_STRIPSPACE_LEN(fp,str,len) \
-  if (write_string_stripspace_len(fp,str,len)) \
+#define WRITE_STRING_STRIPSPACE_LEN(fp, str, len)                           \
+  if (write_string_stripspace_len(fp, str, len))                            \
     return -1;
 
-#define WRITE_STRING_STRIPSPACE(fp,str) \
-  WRITE_STRING_STRIPSPACE_LEN(fp,str,strlen(str))
+#define WRITE_STRING_STRIPSPACE(fp, str)                                    \
+  WRITE_STRING_STRIPSPACE_LEN(fp, str, strlen(str))
 
-static int write_netgroup_triple(TFILE *fp,MYLDAP_ENTRY *entry,const char 
*triple)
+static int write_netgroup_triple(TFILE *fp, MYLDAP_ENTRY *entry,
+                                 const char *triple)
 {
   int32_t tmpint32;
   int i;
-  int hostb,hoste,userb,usere,domainb,domaine;
+  int hostb, hoste, userb, usere, domainb, domaine;
   /* skip leading spaces */
-  for (i=0;(triple[i]!='\0')&&(isspace(triple[i]));i++)
-    /* nothing else to do */ ;
+  for (i = 0; (triple[i] != '\0') && (isspace(triple[i])); i++)
+    /* nothing */ ;
   /* we should have a bracket now */
-  if (triple[i]!='(')
+  if (triple[i] != '(')
   {
-    log_log(LOG_WARNING,"%s: %s: does not begin with '('",
-                        
myldap_get_dn(entry),attmap_netgroup_nisNetgroupTriple);
+    log_log(LOG_WARNING, "%s: %s: does not begin with '('",
+            myldap_get_dn(entry), attmap_netgroup_nisNetgroupTriple);
     return 0;
   }
   i++;
-  hostb=i;
+  hostb = i;
   /* find comma (end of host string) */
-  for (;(triple[i]!='\0')&&(triple[i]!=',');i++)
-    /* nothing else to do */ ;
-  if (triple[i]!=',')
+  for (; (triple[i] != '\0') && (triple[i] != ','); i++)
+    /* nothing */ ;
+  if (triple[i] != ',')
   {
-    log_log(LOG_WARNING,"%s: %s: missing ','",
-                        
myldap_get_dn(entry),attmap_netgroup_nisNetgroupTriple);
+    log_log(LOG_WARNING, "%s: %s: missing ','",
+            myldap_get_dn(entry), attmap_netgroup_nisNetgroupTriple);
     return 0;
   }
-  hoste=i;
+  hoste = i;
   i++;
-  userb=i;
+  userb = i;
   /* find comma (end of user string) */
-  for (;(triple[i]!='\0')&&(triple[i]!=',');i++)
-    /* nothing else to do */ ;
-  if (triple[i]!=',')
+  for (; (triple[i] != '\0') && (triple[i] != ','); i++)
+    /* nothing */ ;
+  if (triple[i] != ',')
   {
-    log_log(LOG_WARNING,"%s: %s: missing ','",
-                        
myldap_get_dn(entry),attmap_netgroup_nisNetgroupTriple);
+    log_log(LOG_WARNING, "%s: %s: missing ','",
+            myldap_get_dn(entry), attmap_netgroup_nisNetgroupTriple);
     return 0;
   }
-  usere=i;
+  usere = i;
   i++;
-  domainb=i;
+  domainb = i;
   /* find closing bracket (end of domain string) */
-  for (;(triple[i]!='\0')&&(triple[i]!=')');i++)
-    /* nothing else to do */ ;
-  if (triple[i]!=')')
+  for (; (triple[i] != '\0') && (triple[i] != ')'); i++)
+    /* nothing */ ;
+  if (triple[i] != ')')
   {
-    log_log(LOG_WARNING,"%s: %s: missing ')'",
-                        
myldap_get_dn(entry),attmap_netgroup_nisNetgroupTriple);
+    log_log(LOG_WARNING, "%s: %s: missing ')'",
+            myldap_get_dn(entry), attmap_netgroup_nisNetgroupTriple);
     return 0;
   }
-  domaine=i;
+  domaine = i;
   i++;
   /* skip trailing spaces */
-  for (;(triple[i]!='\0')&&(isspace(triple[i]));i++)
-    /* nothing else to do */ ;
+  for (; (triple[i] != '\0') && (isspace(triple[i])); i++)
+    /* nothing */ ;
   /* if anything is left in the string we have a problem */
-  if (triple[i]!='\0')
+  if (triple[i] != '\0')
   {
-    log_log(LOG_WARNING,"%s: %s: contains trailing data",
-                        
myldap_get_dn(entry),attmap_netgroup_nisNetgroupTriple);
+    log_log(LOG_WARNING, "%s: %s: contains trailing data",
+            myldap_get_dn(entry), attmap_netgroup_nisNetgroupTriple);
     return 0;
   }
   /* write strings */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_INT32(fp,NSLCD_NETGROUP_TYPE_TRIPLE);
-  WRITE_STRING_STRIPSPACE_LEN(fp,triple+hostb,hoste-hostb)
-  WRITE_STRING_STRIPSPACE_LEN(fp,triple+userb,usere-userb)
-  WRITE_STRING_STRIPSPACE_LEN(fp,triple+domainb,domaine-domainb)
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, NSLCD_NETGROUP_TYPE_TRIPLE);
+  WRITE_STRING_STRIPSPACE_LEN(fp, triple + hostb, hoste - hostb);
+  WRITE_STRING_STRIPSPACE_LEN(fp, triple + userb, usere - userb);
+  WRITE_STRING_STRIPSPACE_LEN(fp, triple + domainb, domaine - domainb);
   /* we're done */
   return 0;
 }
 
-#define WRITE_NETGROUP_TRIPLE(fp,entry,triple) \
-  if (write_netgroup_triple(fp,entry,triple)) \
+#define WRITE_NETGROUP_TRIPLE(fp, entry, triple)                            \
+  if (write_netgroup_triple(fp, entry, triple))                             \
     return -1;
 
-static int write_netgroup(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname)
+static int write_netgroup(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqname)
 {
   int32_t tmpint32;
   int i;
@@ -213,48 +212,48 @@
   const char **triples;
   const char **members;
   /* get the netgroup name */
-  names=myldap_get_values(entry,attmap_netgroup_cn);
-  if ((names==NULL)||(names[0]==NULL))
+  names = myldap_get_values(entry, attmap_netgroup_cn);
+  if ((names == NULL) || (names[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_netgroup_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_netgroup_cn);
     return 0;
   }
-  for (i=0;(names[i]!=NULL)&&(STR_CMP(reqname,names[i])!=0);i++)
-    /* nothing here */ ;
-  if (names[i]==NULL)
+  for (i = 0; (names[i] != NULL) && (STR_CMP(reqname, names[i]) != 0); i++)
+    /* nothing */ ;
+  if (names[i] == NULL)
     return 0; /* the name was not found */
   /* get the netgroup triples and member */
-  triples=myldap_get_values(entry,attmap_netgroup_nisNetgroupTriple);
-  members=myldap_get_values(entry,attmap_netgroup_memberNisNetgroup);
+  triples = myldap_get_values(entry, attmap_netgroup_nisNetgroupTriple);
+  members = myldap_get_values(entry, attmap_netgroup_memberNisNetgroup);
   /* write the netgroup triples */
-  if (triples!=NULL)
-    for (i=0;triples[i]!=NULL;i++)
+  if (triples != NULL)
+    for (i = 0; triples[i] != NULL; i++)
     {
-      WRITE_NETGROUP_TRIPLE(fp,entry,triples[i]);
+      WRITE_NETGROUP_TRIPLE(fp, entry, triples[i]);
     }
   /* write netgroup members */
-  if (members!=NULL)
-    for (i=0;members[i]!=NULL;i++)
+  if (members != NULL)
+    for (i = 0; members[i] != NULL; i++)
     {
       /* write the result code */
-      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
+      WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
       /* write triple indicator */
-      WRITE_INT32(fp,NSLCD_NETGROUP_TYPE_NETGROUP);
+      WRITE_INT32(fp, NSLCD_NETGROUP_TYPE_NETGROUP);
       /* write netgroup name */
-      WRITE_STRING_STRIPSPACE(fp,members[i]);
+      WRITE_STRING_STRIPSPACE(fp, members[i]);
     }
   /* we're done */
   return 0;
 }
 
 NSLCD_HANDLE(
-  netgroup,byname,
+  netgroup, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("netgroup=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("netgroup=\"%s\"", name);,
   NSLCD_ACTION_NETGROUP_BYNAME,
-  mkfilter_netgroup_byname(name,filter,sizeof(filter)),
-  write_netgroup(fp,entry,name)
+  mkfilter_netgroup_byname(name, filter, sizeof(filter)),
+  write_netgroup(fp, entry, name)
 )

Modified: nss-pam-ldapd/nslcd/network.c
==============================================================================
--- nss-pam-ldapd/nslcd/network.c       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/network.c       Sat Dec 22 22:38:26 2012        (r1873)
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -63,128 +63,124 @@
 /* create a search filter for searching a network entry
    by name, return -1 on errors */
 static int mkfilter_network_byname(const char *name,
-                                   char *buffer,size_t buflen)
+                                   char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    network_filter,
-                    attmap_network_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    network_filter, attmap_network_cn, safename);
 }
 
 static int mkfilter_network_byaddr(const char *addrstr,
-                                   char *buffer,size_t buflen)
+                                   char *buffer, size_t buflen)
 {
   char safeaddr[64];
   /* escape attribute */
-  if (myldap_escape(addrstr,safeaddr,sizeof(safeaddr)))
+  if (myldap_escape(addrstr, safeaddr, sizeof(safeaddr)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    network_filter,
-                    attmap_network_ipNetworkNumber,safeaddr);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    network_filter, attmap_network_ipNetworkNumber, safeaddr);
 }
 
 void network_init(void)
 {
   int i;
   /* set up search bases */
-  if (network_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      network_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (network_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      network_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (network_scope==LDAP_SCOPE_DEFAULT)
-    network_scope=nslcd_cfg->ldc_scope;
+  if (network_scope == LDAP_SCOPE_DEFAULT)
+    network_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  network_attrs[0]=attmap_network_cn;
-  network_attrs[1]=attmap_network_ipNetworkNumber;
-  network_attrs[2]=NULL;
+  network_attrs[0] = attmap_network_cn;
+  network_attrs[1] = attmap_network_ipNetworkNumber;
+  network_attrs[2] = NULL;
 }
 
 /* write a single network entry to the stream */
-static int write_network(TFILE *fp,MYLDAP_ENTRY *entry)
+static int write_network(TFILE *fp, MYLDAP_ENTRY *entry)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  int numaddr,i;
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  int numaddr, i;
   const char *networkname;
   const char **networknames;
   const char **addresses;
   /* get the most canonical name */
-  networkname=myldap_get_rdn_value(entry,attmap_network_cn);
+  networkname = myldap_get_rdn_value(entry, attmap_network_cn);
   /* get the other names for the network */
-  networknames=myldap_get_values(entry,attmap_network_cn);
-  if ((networknames==NULL)||(networknames[0]==NULL))
+  networknames = myldap_get_values(entry, attmap_network_cn);
+  if ((networknames == NULL) || (networknames[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_network_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_network_cn);
     return 0;
   }
   /* if the networkname is not yet found, get the first entry from 
networknames */
-  if (networkname==NULL)
-    networkname=networknames[0];
+  if (networkname == NULL)
+    networkname = networknames[0];
   /* get the addresses */
-  addresses=myldap_get_values(entry,attmap_network_ipNetworkNumber);
-  if ((addresses==NULL)||(addresses[0]==NULL))
+  addresses = myldap_get_values(entry, attmap_network_ipNetworkNumber);
+  if ((addresses == NULL) || (addresses[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_network_ipNetworkNumber);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_network_ipNetworkNumber);
     return 0;
   }
   /* write the entry */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_STRING(fp,networkname);
-  WRITE_STRINGLIST_EXCEPT(fp,networknames,networkname);
-  for (numaddr=0;addresses[numaddr]!=NULL;numaddr++)
-    /*noting*/ ;
-  WRITE_INT32(fp,numaddr);
-  for (i=0;i<numaddr;i++)
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_STRING(fp, networkname);
+  WRITE_STRINGLIST_EXCEPT(fp, networknames, networkname);
+  for (numaddr = 0; addresses[numaddr] != NULL; numaddr++)
+    /* noting */ ;
+  WRITE_INT32(fp, numaddr);
+  for (i = 0; i < numaddr; i++)
   {
-    WRITE_ADDRESS(fp,entry,attmap_network_ipNetworkNumber,addresses[i]);
+    WRITE_ADDRESS(fp, entry, attmap_network_ipNetworkNumber, addresses[i]);
   }
   return 0;
 }
 
 NSLCD_HANDLE(
-  network,byname,
+  network, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("network=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("network=\"%s\"", name);,
   NSLCD_ACTION_NETWORK_BYNAME,
-  mkfilter_network_byname(name,filter,sizeof(filter)),
-  write_network(fp,entry)
+  mkfilter_network_byname(name, filter, sizeof(filter)),
+  write_network(fp, entry)
 )
 
 NSLCD_HANDLE(
-  network,byaddr,
+  network, byaddr,
   int af;
   char addr[64];
-  int len=sizeof(addr);
+  int len = sizeof(addr);
   char addrstr[64];
   char filter[4096];
-  READ_ADDRESS(fp,addr,len,af);
+  READ_ADDRESS(fp, addr, len, af);
   /* translate the address to a string */
-  if (inet_ntop(af,addr,addrstr,sizeof(addrstr))==NULL)
+  if (inet_ntop(af, addr, addrstr, sizeof(addrstr)) == NULL)
   {
-    log_log(LOG_WARNING,"unable to convert address to string");
+    log_log(LOG_WARNING, "unable to convert address to string");
     return -1;
   }
-  log_setrequest("network=%s",addrstr);,
+  log_setrequest("network=%s", addrstr);,
   NSLCD_ACTION_NETWORK_BYADDR,
-  mkfilter_network_byaddr(addrstr,filter,sizeof(filter)),
-  write_network(fp,entry)
+  mkfilter_network_byaddr(addrstr, filter, sizeof(filter)),
+  write_network(fp, entry)
 )
 
 NSLCD_HANDLE(
-  network,all,
+  network, all,
   const char *filter;
   log_setrequest("network(all)");,
   NSLCD_ACTION_NETWORK_ALL,
-  (filter=network_filter,0),
-  write_network(fp,entry)
+  (filter = network_filter, 0),
+  write_network(fp, entry)
 )

Modified: nss-pam-ldapd/nslcd/nslcd.c
==============================================================================
--- nss-pam-ldapd/nslcd/nslcd.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/nslcd.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -70,25 +70,25 @@
    quickly, write timeout is 60 seconds because clients could be taking some
    time to process the results */
 #define READ_TIMEOUT 500
-#define WRITE_TIMEOUT 60*1000
+#define WRITE_TIMEOUT 60 * 1000
 
 /* buffer sizes for I/O */
 #define READBUFFER_MINSIZE 32
 #define READBUFFER_MAXSIZE 64
 #define WRITEBUFFER_MINSIZE 64
-#define WRITEBUFFER_MAXSIZE 1*1024*1024
+#define WRITEBUFFER_MAXSIZE 1 * 1024 * 1024
 
 /* flag to indicate if we are in debugging mode */
-static int nslcd_debugging=0;
+static int nslcd_debugging = 0;
 
 /* flag to indicate user requested the --check option */
-static int nslcd_checkonly=0;
+static int nslcd_checkonly = 0;
 
 /* the exit flag to indicate that a signal was received */
-static volatile int nslcd_exitsignal=0;
+static volatile int nslcd_exitsignal = 0;
 
 /* the server socket used for communication */
-static int nslcd_serversocket=-1;
+static int nslcd_serversocket = -1;
 
 /* thread ids of all running threads */
 static pthread_t *nslcd_threads;
@@ -112,73 +112,68 @@
 /* display version information */
 static void display_version(FILE *fp)
 {
-  fprintf(fp,"%s\n",PACKAGE_STRING);
-  fprintf(fp,"Written by Luke Howard and Arthur de Jong.\n\n");
-  fprintf(fp,"Copyright (C) 1997-2012 Luke Howard, Arthur de Jong and West 
Consulting\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");
+  fprintf(fp, "%s\n", PACKAGE_STRING);
+  fprintf(fp, "Written by Luke Howard and Arthur de Jong.\n\n");
+  fprintf(fp, "Copyright (C) 1997-2012 Luke Howard, Arthur de Jong and West 
Consulting\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");
 }
 
 /* display usage information */
-static void display_usage(FILE *fp,const char *program_name)
+static void display_usage(FILE *fp, const char *program_name)
 {
-  fprintf(fp,"Usage: %s [OPTION]...\n",program_name);
-  fprintf(fp,"Name Service LDAP connection daemon.\n");
-  fprintf(fp,"  -c, --check        check if the daemon already is running\n");
-  fprintf(fp,"  -d, --debug        don't fork and print debugging to 
stderr\n");
-  fprintf(fp,"      --help         display this help and exit\n");
-  fprintf(fp,"      --version      output version information and exit\n");
-  fprintf(fp,"\n"
-             "Report bugs to <%s>.\n",PACKAGE_BUGREPORT);
+  fprintf(fp, "Usage: %s [OPTION]...\n", program_name);
+  fprintf(fp, "Name Service LDAP connection daemon.\n");
+  fprintf(fp, "  -c, --check        check if the daemon already is running\n");
+  fprintf(fp, "  -d, --debug        don't fork and print debugging to 
stderr\n");
+  fprintf(fp, "      --help         display this help and exit\n");
+  fprintf(fp, "      --version      output version information and exit\n");
+  fprintf(fp, "\n" "Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
 }
 
 /* the definition of options for getopt(). see getopt(2) */
-static struct option const nslcd_options[] =
-{
-  { "check",       no_argument,       NULL, 'c' },
-  { "debug",       no_argument,       NULL, 'd' },
-  { "help",        no_argument,       NULL, 'h' },
-  { "version",     no_argument,       NULL, 'V' },
-  { NULL, 0, NULL, 0 }
+static struct option const nslcd_options[] = {
+  {"check",   no_argument, NULL, 'c'},
+  {"debug",   no_argument, NULL, 'd'},
+  {"help",    no_argument, NULL, 'h'},
+  {"version", no_argument, NULL, 'V'},
+  {NULL,      0,           NULL, 0}
 };
 #define NSLCD_OPTIONSTRING "cdhV"
 
 /* parse command line options and save settings in struct  */
-static void parse_cmdline(int argc,char *argv[])
+static void parse_cmdline(int argc, char *argv[])
 {
   int optc;
-  while 
((optc=getopt_long(argc,argv,NSLCD_OPTIONSTRING,nslcd_options,NULL))!=-1)
+  while ((optc = getopt_long(argc, argv, NSLCD_OPTIONSTRING, nslcd_options, 
NULL)) != -1)
   {
     switch (optc)
     {
-    case 'c': /* -c, --check        check if the daemon already is running */
-      nslcd_checkonly=1;
-      break;
-    case 'd': /* -d, --debug        don't fork and print debugging to stderr */
-      nslcd_debugging++;
-      log_setdefaultloglevel(LOG_DEBUG);
-      break;
-    case 'h': /*     --help         display this help and exit */
-      display_usage(stdout,argv[0]);
-      exit(EXIT_SUCCESS);
-    case 'V': /*     --version      output version information and exit */
-      display_version(stdout);
-      exit(EXIT_SUCCESS);
-    case ':': /* missing required parameter */
-    case '?': /* unknown option character or extraneous parameter */
-    default:
-      fprintf(stderr,"Try '%s --help' for more information.\n",
-              argv[0]);
-      exit(EXIT_FAILURE);
+      case 'c': /* -c, --check        check if the daemon already is running */
+        nslcd_checkonly = 1;
+        break;
+      case 'd': /* -d, --debug        don't fork and print debugging to stderr 
*/
+        nslcd_debugging++;
+        log_setdefaultloglevel(LOG_DEBUG);
+        break;
+      case 'h': /*     --help         display this help and exit */
+        display_usage(stdout, argv[0]);
+        exit(EXIT_SUCCESS);
+      case 'V': /*     --version      output version information and exit */
+        display_version(stdout);
+        exit(EXIT_SUCCESS);
+      case ':': /* missing required parameter */
+      case '?': /* unknown option character or extraneous parameter */
+      default:
+        fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
+        exit(EXIT_FAILURE);
     }
   }
   /* check for remaining arguments */
-  if (optind<argc)
+  if (optind < argc)
   {
-    fprintf(stderr,"%s: unrecognized option '%s'\n",
-            argv[0],argv[optind]);
-    fprintf(stderr,"Try '%s --help' for more information.\n",
-            argv[0]);
+    fprintf(stderr, "%s: unrecognized option '%s'\n", argv[0], argv[optind]);
+    fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
     exit(EXIT_FAILURE);
   }
 }
@@ -188,53 +183,53 @@
 {
   switch (signum)
   {
-  case SIGHUP:  return "SIGHUP";  /* Hangup detected */
-  case SIGINT:  return "SIGINT";  /* Interrupt from keyboard */
-  case SIGQUIT: return "SIGQUIT"; /* Quit from keyboard */
-  case SIGILL:  return "SIGILL";  /* Illegal Instruction */
-  case SIGABRT: return "SIGABRT"; /* Abort signal from abort(3) */
-  case SIGFPE:  return "SIGFPE";  /* Floating point exception */
-  case SIGKILL: return "SIGKILL"; /* Kill signal */
-  case SIGSEGV: return "SIGSEGV"; /* Invalid memory reference */
-  case SIGPIPE: return "SIGPIPE"; /* Broken pipe */
-  case SIGALRM: return "SIGALRM"; /* Timer signal from alarm(2) */
-  case SIGTERM: return "SIGTERM"; /* Termination signal */
-  case SIGUSR1: return "SIGUSR1"; /* User-defined signal 1 */
-  case SIGUSR2: return "SIGUSR2"; /* User-defined signal 2 */
-  case SIGCHLD: return "SIGCHLD"; /* Child stopped or terminated */
-  case SIGCONT: return "SIGCONT"; /* Continue if stopped */
-  case SIGSTOP: return "SIGSTOP"; /* Stop process */
-  case SIGTSTP: return "SIGTSTP"; /* Stop typed at tty */
-  case SIGTTIN: return "SIGTTIN"; /* tty input for background process */
-  case SIGTTOU: return "SIGTTOU"; /* tty output for background process */
+    case SIGHUP:  return "SIGHUP";  /* Hangup detected */
+    case SIGINT:  return "SIGINT";  /* Interrupt from keyboard */
+    case SIGQUIT: return "SIGQUIT"; /* Quit from keyboard */
+    case SIGILL:  return "SIGILL";  /* Illegal Instruction */
+    case SIGABRT: return "SIGABRT"; /* Abort signal from abort(3) */
+    case SIGFPE:  return "SIGFPE";  /* Floating point exception */
+    case SIGKILL: return "SIGKILL"; /* Kill signal */
+    case SIGSEGV: return "SIGSEGV"; /* Invalid memory reference */
+    case SIGPIPE: return "SIGPIPE"; /* Broken pipe */
+    case SIGALRM: return "SIGALRM"; /* Timer signal from alarm(2) */
+    case SIGTERM: return "SIGTERM"; /* Termination signal */
+    case SIGUSR1: return "SIGUSR1"; /* User-defined signal 1 */
+    case SIGUSR2: return "SIGUSR2"; /* User-defined signal 2 */
+    case SIGCHLD: return "SIGCHLD"; /* Child stopped or terminated */
+    case SIGCONT: return "SIGCONT"; /* Continue if stopped */
+    case SIGSTOP: return "SIGSTOP"; /* Stop process */
+    case SIGTSTP: return "SIGTSTP"; /* Stop typed at tty */
+    case SIGTTIN: return "SIGTTIN"; /* tty input for background process */
+    case SIGTTOU: return "SIGTTOU"; /* tty output for background process */
 #ifdef SIGBUS
-  case SIGBUS:  return "SIGBUS";  /* Bus error */
+    case SIGBUS:  return "SIGBUS";  /* Bus error */
 #endif
 #ifdef SIGPOLL
-  case SIGPOLL: return "SIGPOLL"; /* Pollable event */
+    case SIGPOLL: return "SIGPOLL"; /* Pollable event */
 #endif
 #ifdef SIGPROF
-  case SIGPROF: return "SIGPROF"; /* Profiling timer expired */
+    case SIGPROF: return "SIGPROF"; /* Profiling timer expired */
 #endif
 #ifdef SIGSYS
-  case SIGSYS:  return "SIGSYS";  /* Bad argument to routine */
+    case SIGSYS:  return "SIGSYS";  /* Bad argument to routine */
 #endif
 #ifdef SIGTRAP
-  case SIGTRAP: return "SIGTRAP"; /* Trace/breakpoint trap */
+    case SIGTRAP: return "SIGTRAP"; /* Trace/breakpoint trap */
 #endif
 #ifdef SIGURG
-  case SIGURG:  return "SIGURG";  /* Urgent condition on socket */
+    case SIGURG:  return "SIGURG";  /* Urgent condition on socket */
 #endif
 #ifdef SIGVTALRM
-  case SIGVTALRM: return "SIGVTALRM"; /* Virtual alarm clock */
+    case SIGVTALRM: return "SIGVTALRM"; /* Virtual alarm clock */
 #endif
 #ifdef SIGXCPU
-  case SIGXCPU: return "SIGXCPU"; /* CPU time limit exceeded */
+    case SIGXCPU: return "SIGXCPU"; /* CPU time limit exceeded */
 #endif
 #ifdef SIGXFSZ
-  case SIGXFSZ: return "SIGXFSZ"; /* File size limit exceeded */
+    case SIGXFSZ: return "SIGXFSZ"; /* File size limit exceeded */
 #endif
-  default:      return "UNKNOWN";
+    default:      return "UNKNOWN";
   }
 }
 
@@ -242,7 +237,7 @@
 static void sigexit_handler(int signum)
 {
   /* just save the signal to indicate that we're stopping */
-  nslcd_exitsignal=signum;
+  nslcd_exitsignal = signum;
 }
 
 /* do some cleaning up before terminating */
@@ -252,36 +247,39 @@
   if (nslcd_serversocket >= 0)
   {
     if (close(nslcd_serversocket))
-      log_log(LOG_WARNING,"problem closing server socket (ignored): 
%s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing server socket (ignored): %s",
+              strerror(errno));
   }
   /* remove existing named socket */
-  if (unlink(NSLCD_SOCKET)<0)
+  if (unlink(NSLCD_SOCKET) < 0)
   {
-    log_log(LOG_DEBUG,"unlink() of "NSLCD_SOCKET" failed (ignored): %s",
+    log_log(LOG_DEBUG, "unlink() of " NSLCD_SOCKET " failed (ignored): %s",
             strerror(errno));
   }
   /* remove pidfile */
-  if (unlink(NSLCD_PIDFILE)<0)
+  if (unlink(NSLCD_PIDFILE) < 0)
   {
-    log_log(LOG_DEBUG,"unlink() of "NSLCD_PIDFILE" failed (ignored): %s",
+    log_log(LOG_DEBUG, "unlink() of " NSLCD_PIDFILE " failed (ignored): %s",
             strerror(errno));
   }
   /* log exit */
-  log_log(LOG_INFO,"version %s bailing out",VERSION);
+  log_log(LOG_INFO, "version %s bailing out", VERSION);
 }
 
 /* create the directory for the specified file to reside in */
 static void mkdirname(const char *filename)
 {
-  char *tmpname,*path;
-  tmpname=strdup(filename);
-  if (tmpname==NULL) return;
-  path=dirname(tmpname);
-  if (mkdir(path,(mode_t)0755)==0)
+  char *tmpname, *path;
+  tmpname = strdup(filename);
+  if (tmpname == NULL)
+    return;
+  path = dirname(tmpname);
+  if (mkdir(path, (mode_t)0755) == 0)
   {
     /* if directory was just created, set correct ownership */
-    if (lchown(path,nslcd_cfg->ldc_uid,nslcd_cfg->ldc_gid)<0)
-      log_log(LOG_WARNING,"problem setting permissions for %s: 
%s",path,strerror(errno));
+    if (lchown(path, nslcd_cfg->ldc_uid, nslcd_cfg->ldc_gid) < 0)
+      log_log(LOG_WARNING, "problem setting permissions for %s: %s",
+              path, strerror(errno));
   }
   free(tmpname);
 }
@@ -294,53 +292,54 @@
   int i;
   struct sockaddr_un addr;
   /* create a socket */
-  if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 )
+  if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
   {
-    log_log(LOG_ERR,"cannot create socket: %s",strerror(errno));
+    log_log(LOG_ERR, "cannot create socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* remove existing named socket */
-  if (unlink(filename)<0)
+  if (unlink(filename) < 0)
   {
-    log_log(LOG_DEBUG,"unlink() of %s failed (ignored): %s",
-            filename,strerror(errno));
+    log_log(LOG_DEBUG, "unlink() of %s failed (ignored): %s",
+            filename, strerror(errno));
   }
   /* do not block on accept() */
-  if ((i=fcntl(sock,F_GETFL,0))<0)
+  if ((i = fcntl(sock, F_GETFL, 0)) < 0)
   {
-    log_log(LOG_ERR,"fctnl(F_GETFL) failed: %s",strerror(errno));
+    log_log(LOG_ERR, "fctnl(F_GETFL) failed: %s", strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
-  if (fcntl(sock,F_SETFL,i|O_NONBLOCK)<0)
+  if (fcntl(sock, F_SETFL, i | O_NONBLOCK) < 0)
   {
-    log_log(LOG_ERR,"fctnl(F_SETFL,O_NONBLOCK) failed: %s",strerror(errno));
+    log_log(LOG_ERR, "fctnl(F_SETFL,O_NONBLOCK) failed: %s", strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* create the directory if needed */
   mkdirname(filename);
   /* create socket address structure */
-  memset(&addr,0,sizeof(struct sockaddr_un));
-  addr.sun_family=AF_UNIX;
-  strncpy(addr.sun_path,filename,sizeof(addr.sun_path));
-  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
+  memset(&addr, 0, sizeof(struct sockaddr_un));
+  addr.sun_family = AF_UNIX;
+  strncpy(addr.sun_path, filename, sizeof(addr.sun_path));
+  addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
   /* bind to the named socket */
-  if (bind(sock,(struct sockaddr *)&addr,SUN_LEN(&addr)))
+  if (bind(sock, (struct sockaddr *)&addr, SUN_LEN(&addr)))
   {
-    log_log(LOG_ERR,"bind() to %s failed: %s",filename,strerror(errno));
+    log_log(LOG_ERR, "bind() to %s failed: %s", filename, strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* close the file descriptor on exit */
-  if (fcntl(sock,F_SETFD,FD_CLOEXEC)<0)
+  if (fcntl(sock, F_SETFD, FD_CLOEXEC) < 0)
   {
-    log_log(LOG_ERR,"fctnl(F_SETFL,FD_CLOEXEC) on %s failed: 
%s",filename,strerror(errno));
+    log_log(LOG_ERR, "fctnl(F_SETFL,FD_CLOEXEC) on %s failed: %s",
+            filename, strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* set permissions of socket so anybody can do requests */
@@ -348,19 +347,20 @@
      fchmod does not work on sockets
      http://www.opengroup.org/onlinepubs/009695399/functions/fchmod.html
      http://lkml.org/lkml/2005/5/16/11 */
-  if (chmod(filename,(mode_t)0666))
+  if (chmod(filename, (mode_t)0666))
   {
-    log_log(LOG_ERR,"chmod(0666) of %s failed: %s",filename,strerror(errno));
+    log_log(LOG_ERR, "chmod(0666) of %s failed: %s",
+            filename, strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* start listening for connections */
-  if (listen(sock,SOMAXCONN)<0)
+  if (listen(sock, SOMAXCONN) < 0)
   {
-    log_log(LOG_ERR,"listen() failed: %s",strerror(errno));
+    log_log(LOG_ERR, "listen() failed: %s", strerror(errno));
     if (close(sock))
-      log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* we're done */
@@ -369,48 +369,49 @@
 
 /* read the version information and action from the stream
    this function returns the read action in location pointer to by action */
-static int read_header(TFILE *fp,int32_t *action)
+static int read_header(TFILE *fp, int32_t *action)
 {
   int32_t tmpint32;
   int32_t protocol;
   /* read the protocol version */
-  READ_INT32(fp,protocol);
-  if (protocol!=(int32_t)NSLCD_VERSION)
+  READ_INT32(fp, protocol);
+  if (protocol != (int32_t)NSLCD_VERSION)
   {
-    log_log(LOG_DEBUG,"invalid nslcd version id: 0x%08x",(unsigned 
int)protocol);
+    log_log(LOG_DEBUG, "invalid nslcd version id: 0x%08x", (unsigned 
int)protocol);
     return -1;
   }
   /* read the request type */
-  READ_INT32(fp,*action);
+  READ_INT32(fp, *action);
   return 0;
 }
 
 /* read a request message, returns <0 in case of errors,
    this function closes the socket */
-static void handleconnection(int sock,MYLDAP_SESSION *session)
+static void handleconnection(int sock, MYLDAP_SESSION *session)
 {
   TFILE *fp;
   int32_t action;
-  uid_t uid=(uid_t)-1;
-  gid_t gid=(gid_t)-1;
-  pid_t pid=(pid_t)-1;
+  uid_t uid = (uid_t)-1;
+  gid_t gid = (gid_t)-1;
+  pid_t pid = (pid_t)-1;
   /* log connection */
-  if (getpeercred(sock,&uid,&gid,&pid))
-    log_log(LOG_DEBUG,"connection from unknown client: %s",strerror(errno));
+  if (getpeercred(sock, &uid, &gid, &pid))
+    log_log(LOG_DEBUG, "connection from unknown client: %s", strerror(errno));
   else
-    log_log(LOG_DEBUG,"connection from pid=%d uid=%d gid=%d",
-                      (int)pid,(int)uid,(int)gid);
+    log_log(LOG_DEBUG, "connection from pid=%d uid=%d gid=%d",
+            (int)pid, (int)uid, (int)gid);
   /* create a stream object */
-  if ((fp=tio_fdopen(sock,READ_TIMEOUT,WRITE_TIMEOUT,
-                     READBUFFER_MINSIZE,READBUFFER_MAXSIZE,
-                     WRITEBUFFER_MINSIZE,WRITEBUFFER_MAXSIZE))==NULL)
+  if ((fp = tio_fdopen(sock, READ_TIMEOUT, WRITE_TIMEOUT,
+                       READBUFFER_MINSIZE, READBUFFER_MAXSIZE,
+                       WRITEBUFFER_MINSIZE, WRITEBUFFER_MAXSIZE)) == NULL)
   {
-    log_log(LOG_WARNING,"cannot create stream for writing: 
%s",strerror(errno));
+    log_log(LOG_WARNING, "cannot create stream for writing: %s",
+            strerror(errno));
     (void)close(sock);
     return;
   }
   /* read request */
-  if (read_header(fp,&action))
+  if (read_header(fp, &action))
   {
     (void)tio_close(fp);
     return;
@@ -418,46 +419,46 @@
   /* handle request */
   switch (action)
   {
-    case NSLCD_ACTION_CONFIG_GET:       (void)nslcd_config_get(fp,session); 
break;
-    case NSLCD_ACTION_ALIAS_BYNAME:     (void)nslcd_alias_byname(fp,session); 
break;
-    case NSLCD_ACTION_ALIAS_ALL:        (void)nslcd_alias_all(fp,session); 
break;
-    case NSLCD_ACTION_ETHER_BYNAME:     (void)nslcd_ether_byname(fp,session); 
break;
-    case NSLCD_ACTION_ETHER_BYETHER:    (void)nslcd_ether_byether(fp,session); 
break;
-    case NSLCD_ACTION_ETHER_ALL:        (void)nslcd_ether_all(fp,session); 
break;
-    case NSLCD_ACTION_GROUP_BYNAME:     (void)nslcd_group_byname(fp,session); 
break;
-    case NSLCD_ACTION_GROUP_BYGID:      (void)nslcd_group_bygid(fp,session); 
break;
-    case NSLCD_ACTION_GROUP_BYMEMBER:   
(void)nslcd_group_bymember(fp,session); break;
-    case NSLCD_ACTION_GROUP_ALL:        (void)nslcd_group_all(fp,session); 
break;
-    case NSLCD_ACTION_HOST_BYNAME:      (void)nslcd_host_byname(fp,session); 
break;
-    case NSLCD_ACTION_HOST_BYADDR:      (void)nslcd_host_byaddr(fp,session); 
break;
-    case NSLCD_ACTION_HOST_ALL:         (void)nslcd_host_all(fp,session); 
break;
-    case NSLCD_ACTION_NETGROUP_BYNAME:  
(void)nslcd_netgroup_byname(fp,session); break;
-    case NSLCD_ACTION_NETWORK_BYNAME:   
(void)nslcd_network_byname(fp,session); break;
-    case NSLCD_ACTION_NETWORK_BYADDR:   
(void)nslcd_network_byaddr(fp,session); break;
-    case NSLCD_ACTION_NETWORK_ALL:      (void)nslcd_network_all(fp,session); 
break;
-    case NSLCD_ACTION_PASSWD_BYNAME:    
(void)nslcd_passwd_byname(fp,session,uid); break;
-    case NSLCD_ACTION_PASSWD_BYUID:     
(void)nslcd_passwd_byuid(fp,session,uid); break;
-    case NSLCD_ACTION_PASSWD_ALL:       
(void)nslcd_passwd_all(fp,session,uid); break;
-    case NSLCD_ACTION_PROTOCOL_BYNAME:  
(void)nslcd_protocol_byname(fp,session); break;
-    case 
NSLCD_ACTION_PROTOCOL_BYNUMBER:(void)nslcd_protocol_bynumber(fp,session); break;
-    case NSLCD_ACTION_PROTOCOL_ALL:     (void)nslcd_protocol_all(fp,session); 
break;
-    case NSLCD_ACTION_RPC_BYNAME:       (void)nslcd_rpc_byname(fp,session); 
break;
-    case NSLCD_ACTION_RPC_BYNUMBER:     (void)nslcd_rpc_bynumber(fp,session); 
break;
-    case NSLCD_ACTION_RPC_ALL:          (void)nslcd_rpc_all(fp,session); break;
-    case NSLCD_ACTION_SERVICE_BYNAME:   
(void)nslcd_service_byname(fp,session); break;
-    case NSLCD_ACTION_SERVICE_BYNUMBER: 
(void)nslcd_service_bynumber(fp,session); break;
-    case NSLCD_ACTION_SERVICE_ALL:      (void)nslcd_service_all(fp,session); 
break;
-    case NSLCD_ACTION_SHADOW_BYNAME:    if (uid==0) 
(void)nslcd_shadow_byname(fp,session);
-                                        else log_log(LOG_DEBUG,"denied shadow 
request by non-root user"); break;
-    case NSLCD_ACTION_SHADOW_ALL:       if (uid==0) 
(void)nslcd_shadow_all(fp,session);
-                                        else log_log(LOG_DEBUG,"denied shadow 
request by non-root user"); break;
-    case NSLCD_ACTION_PAM_AUTHC:        (void)nslcd_pam_authc(fp,session,uid); 
break;
-    case NSLCD_ACTION_PAM_AUTHZ:        (void)nslcd_pam_authz(fp,session); 
break;
-    case NSLCD_ACTION_PAM_SESS_O:       (void)nslcd_pam_sess_o(fp,session); 
break;
-    case NSLCD_ACTION_PAM_SESS_C:       (void)nslcd_pam_sess_c(fp,session); 
break;
-    case NSLCD_ACTION_PAM_PWMOD:        (void)nslcd_pam_pwmod(fp,session,uid); 
break;
+    case NSLCD_ACTION_CONFIG_GET:       (void)nslcd_config_get(fp, session); 
break;
+    case NSLCD_ACTION_ALIAS_BYNAME:     (void)nslcd_alias_byname(fp, session); 
break;
+    case NSLCD_ACTION_ALIAS_ALL:        (void)nslcd_alias_all(fp, session); 
break;
+    case NSLCD_ACTION_ETHER_BYNAME:     (void)nslcd_ether_byname(fp, session); 
break;
+    case NSLCD_ACTION_ETHER_BYETHER:    (void)nslcd_ether_byether(fp, 
session); break;
+    case NSLCD_ACTION_ETHER_ALL:        (void)nslcd_ether_all(fp, session); 
break;
+    case NSLCD_ACTION_GROUP_BYNAME:     (void)nslcd_group_byname(fp, session); 
break;
+    case NSLCD_ACTION_GROUP_BYGID:      (void)nslcd_group_bygid(fp, session); 
break;
+    case NSLCD_ACTION_GROUP_BYMEMBER:   (void)nslcd_group_bymember(fp, 
session); break;
+    case NSLCD_ACTION_GROUP_ALL:        (void)nslcd_group_all(fp, session); 
break;
+    case NSLCD_ACTION_HOST_BYNAME:      (void)nslcd_host_byname(fp, session); 
break;
+    case NSLCD_ACTION_HOST_BYADDR:      (void)nslcd_host_byaddr(fp, session); 
break;
+    case NSLCD_ACTION_HOST_ALL:         (void)nslcd_host_all(fp, session); 
break;
+    case NSLCD_ACTION_NETGROUP_BYNAME:  (void)nslcd_netgroup_byname(fp, 
session); break;
+    case NSLCD_ACTION_NETWORK_BYNAME:   (void)nslcd_network_byname(fp, 
session); break;
+    case NSLCD_ACTION_NETWORK_BYADDR:   (void)nslcd_network_byaddr(fp, 
session); break;
+    case NSLCD_ACTION_NETWORK_ALL:      (void)nslcd_network_all(fp, session); 
break;
+    case NSLCD_ACTION_PASSWD_BYNAME:    (void)nslcd_passwd_byname(fp, session, 
uid); break;
+    case NSLCD_ACTION_PASSWD_BYUID:     (void)nslcd_passwd_byuid(fp, session, 
uid); break;
+    case NSLCD_ACTION_PASSWD_ALL:       (void)nslcd_passwd_all(fp, session, 
uid); break;
+    case NSLCD_ACTION_PROTOCOL_BYNAME:  (void)nslcd_protocol_byname(fp, 
session); break;
+    case NSLCD_ACTION_PROTOCOL_BYNUMBER:(void)nslcd_protocol_bynumber(fp, 
session); break;
+    case NSLCD_ACTION_PROTOCOL_ALL:     (void)nslcd_protocol_all(fp, session); 
break;
+    case NSLCD_ACTION_RPC_BYNAME:       (void)nslcd_rpc_byname(fp, session); 
break;
+    case NSLCD_ACTION_RPC_BYNUMBER:     (void)nslcd_rpc_bynumber(fp, session); 
break;
+    case NSLCD_ACTION_RPC_ALL:          (void)nslcd_rpc_all(fp, session); 
break;
+    case NSLCD_ACTION_SERVICE_BYNAME:   (void)nslcd_service_byname(fp, 
session); break;
+    case NSLCD_ACTION_SERVICE_BYNUMBER: (void)nslcd_service_bynumber(fp, 
session); break;
+    case NSLCD_ACTION_SERVICE_ALL:      (void)nslcd_service_all(fp, session); 
break;
+    case NSLCD_ACTION_SHADOW_BYNAME:    if (uid == 0) 
(void)nslcd_shadow_byname(fp, session);
+      else log_log(LOG_DEBUG, "denied shadow request by non-root user"); break;
+    case NSLCD_ACTION_SHADOW_ALL:       if (uid == 0) 
(void)nslcd_shadow_all(fp, session);
+      else log_log(LOG_DEBUG, "denied shadow request by non-root user"); break;
+    case NSLCD_ACTION_PAM_AUTHC:        (void)nslcd_pam_authc(fp, session, 
uid); break;
+    case NSLCD_ACTION_PAM_AUTHZ:        (void)nslcd_pam_authz(fp, session); 
break;
+    case NSLCD_ACTION_PAM_SESS_O:       (void)nslcd_pam_sess_o(fp, session); 
break;
+    case NSLCD_ACTION_PAM_SESS_C:       (void)nslcd_pam_sess_c(fp, session); 
break;
+    case NSLCD_ACTION_PAM_PWMOD:        (void)nslcd_pam_pwmod(fp, session, 
uid); break;
     default:
-      log_log(LOG_WARNING,"invalid request id: 0x%08x",(unsigned int)action);
+      log_log(LOG_WARNING, "invalid request id: 0x%08x", (unsigned int)action);
       break;
   }
   /* we're done with the request */
@@ -467,27 +468,27 @@
 }
 
 /* test to see if we can lock the specified file */
-static int is_locked(const char* filename)
+static int is_locked(const char *filename)
 {
   int fd;
-  if (filename!=NULL)
+  if (filename != NULL)
   {
-    errno=0;
-    if ((fd=open(filename,O_RDWR,0644))<0)
+    errno = 0;
+    if ((fd = open(filename, O_RDWR, 0644)) < 0)
     {
-      if (errno==ENOENT)
+      if (errno == ENOENT)
         return 0; /* if file doesn't exist it cannot be locked */
-      log_log(LOG_ERR,"cannot open lock file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "cannot open lock file (%s): %s", filename, 
strerror(errno));
       exit(EXIT_FAILURE);
     }
-    if (lockf(fd,F_TEST,0)<0)
+    if (lockf(fd, F_TEST, 0) < 0)
     {
       if (close(fd))
-        log_log(LOG_WARNING,"problem closing fd: %s",strerror(errno));
+        log_log(LOG_WARNING, "problem closing fd: %s", strerror(errno));
       return -1;
     }
     if (close(fd))
-      log_log(LOG_WARNING,"problem closing fd: %s",strerror(errno));
+      log_log(LOG_WARNING, "problem closing fd: %s", strerror(errno));
   }
   return 0;
 }
@@ -497,28 +498,32 @@
 {
   int fd;
   char buffer[20];
-  if (filename!=NULL)
+  if (filename != NULL)
   {
     mkdirname(filename);
-    if ((fd=open(filename,O_RDWR|O_CREAT,0644))<0)
+    if ((fd = open(filename, O_RDWR | O_CREAT, 0644)) < 0)
     {
-      log_log(LOG_ERR,"cannot create pid file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "cannot create pid file (%s): %s",
+              filename, strerror(errno));
       exit(EXIT_FAILURE);
     }
-    if (lockf(fd,F_TLOCK,0)<0)
+    if (lockf(fd, F_TLOCK, 0) < 0)
     {
-      log_log(LOG_ERR,"cannot lock pid file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "cannot lock pid file (%s): %s",
+              filename, strerror(errno));
       exit(EXIT_FAILURE);
     }
-    if (ftruncate(fd,0)<0)
+    if (ftruncate(fd, 0) < 0)
     {
-      log_log(LOG_ERR,"cannot truncate pid file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "cannot truncate pid file (%s): %s",
+              filename, strerror(errno));
       exit(EXIT_FAILURE);
     }
-    mysnprintf(buffer,sizeof(buffer),"%d\n",(int)getpid());
-    if (write(fd,buffer,strlen(buffer))!=(int)strlen(buffer))
+    mysnprintf(buffer, sizeof(buffer), "%d\n", (int)getpid());
+    if (write(fd, buffer, strlen(buffer)) != (int)strlen(buffer))
     {
-      log_log(LOG_ERR,"error writing pid file (%s): 
%s",filename,strerror(errno));
+      log_log(LOG_ERR, "error writing pid file (%s): %s",
+              filename, strerror(errno));
       exit(EXIT_FAILURE);
     }
     /* we keep the pidfile open so the lock remains valid */
@@ -526,23 +531,24 @@
 }
 
 /* try to install signal handler and check result */
-static void install_sighandler(int signum,void (*handler) (int))
+static void install_sighandler(int signum, void (*handler) (int))
 {
   struct sigaction act;
-  memset(&act,0,sizeof(struct sigaction));
-  act.sa_handler=handler;
+  memset(&act, 0, sizeof(struct sigaction));
+  act.sa_handler = handler;
   sigemptyset(&act.sa_mask);
-  act.sa_flags=SA_RESTART|SA_NOCLDSTOP;
-  if (sigaction(signum,&act,NULL)!=0)
+  act.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+  if (sigaction(signum, &act, NULL) != 0)
   {
-    log_log(LOG_ERR,"error installing signal handler for '%s': 
%s",signame(signum),strerror(errno));
+    log_log(LOG_ERR, "error installing signal handler for '%s': %s",
+            signame(signum), strerror(errno));
     exit(EXIT_FAILURE);
   }
 }
 
 static void worker_cleanup(void *arg)
 {
-  MYLDAP_SESSION *session=(MYLDAP_SESSION *)arg;
+  MYLDAP_SESSION *session = (MYLDAP_SESSION *)arg;
   myldap_session_close(session);
 }
 
@@ -556,9 +562,9 @@
   fd_set fds;
   struct timeval tv;
   /* create a new LDAP session */
-  session=myldap_create_session();
+  session = myldap_create_session();
   /* clean up the session if we're done */
-  pthread_cleanup_push(worker_cleanup,session);
+  pthread_cleanup_push(worker_cleanup, session);
   /* start waiting for incoming connections */
   while (1)
   {
@@ -566,54 +572,55 @@
     myldap_session_check(session);
     /* set up the set of fds to wait on */
     FD_ZERO(&fds);
-    FD_SET(nslcd_serversocket,&fds);
+    FD_SET(nslcd_serversocket, &fds);
     /* set up our timeout value */
-    tv.tv_sec=nslcd_cfg->ldc_idle_timelimit;
-    tv.tv_usec=0;
+    tv.tv_sec = nslcd_cfg->ldc_idle_timelimit;
+    tv.tv_usec = 0;
     /* wait for a new connection */
-    
j=select(nslcd_serversocket+1,&fds,NULL,NULL,nslcd_cfg->ldc_idle_timelimit>0?&tv:NULL);
+    j = select(nslcd_serversocket + 1, &fds, NULL, NULL,
+               nslcd_cfg->ldc_idle_timelimit > 0 ? &tv : NULL);
     /* check result of select() */
-    if (j<0)
+    if (j < 0)
     {
-      if (errno==EINTR)
-        log_log(LOG_DEBUG,"select() failed (ignored): %s",strerror(errno));
+      if (errno == EINTR)
+        log_log(LOG_DEBUG, "select() failed (ignored): %s", strerror(errno));
       else
-        log_log(LOG_ERR,"select() failed: %s",strerror(errno));
+        log_log(LOG_ERR, "select() failed: %s", strerror(errno));
       continue;
     }
     /* see if our file descriptor is actually ready */
-    if (!FD_ISSET(nslcd_serversocket,&fds))
+    if (!FD_ISSET(nslcd_serversocket, &fds))
       continue;
     /* wait for a new connection */
-    alen=(socklen_t)sizeof(struct sockaddr_storage);
-    csock=accept(nslcd_serversocket,(struct sockaddr *)&addr,&alen);
-    if (csock<0)
+    alen = (socklen_t)sizeof(struct sockaddr_storage);
+    csock = accept(nslcd_serversocket, (struct sockaddr *)&addr, &alen);
+    if (csock < 0)
     {
-      if ((errno==EINTR)||(errno==EAGAIN)||(errno==EWOULDBLOCK))
-        log_log(LOG_DEBUG,"accept() failed (ignored): %s",strerror(errno));
+      if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK))
+        log_log(LOG_DEBUG, "accept() failed (ignored): %s", strerror(errno));
       else
-        log_log(LOG_ERR,"accept() failed: %s",strerror(errno));
+        log_log(LOG_ERR, "accept() failed: %s", strerror(errno));
       continue;
     }
     /* make sure O_NONBLOCK is not inherited */
-    if ((j=fcntl(csock,F_GETFL,0))<0)
+    if ((j = fcntl(csock, F_GETFL, 0)) < 0)
     {
-      log_log(LOG_ERR,"fctnl(F_GETFL) failed: %s",strerror(errno));
+      log_log(LOG_ERR, "fctnl(F_GETFL) failed: %s", strerror(errno));
       if (close(csock))
-        log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+        log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
       continue;
     }
-    if (fcntl(csock,F_SETFL,j&~O_NONBLOCK)<0)
+    if (fcntl(csock, F_SETFL, j & ~O_NONBLOCK) < 0)
     {
-      log_log(LOG_ERR,"fctnl(F_SETFL,~O_NONBLOCK) failed: %s",strerror(errno));
+      log_log(LOG_ERR, "fctnl(F_SETFL,~O_NONBLOCK) failed: %s", 
strerror(errno));
       if (close(csock))
-        log_log(LOG_WARNING,"problem closing socket: %s",strerror(errno));
+        log_log(LOG_WARNING, "problem closing socket: %s", strerror(errno));
       continue;
     }
     /* indicate new connection to logging module (generates unique id) */
     log_newsession();
     /* handle the connection */
-    handleconnection(csock,session);
+    handleconnection(csock, session);
     /* indicate end of session in log messages */
     log_clearsession();
   }
@@ -630,33 +637,35 @@
   int *enable_flag;
   /* try to load the NSS module */
 #ifdef RTLD_NODELETE
-  handle=dlopen(NSS_LDAP_SONAME,RTLD_LAZY|RTLD_NODELETE);
+  handle = dlopen(NSS_LDAP_SONAME, RTLD_LAZY | RTLD_NODELETE);
 #else /* not RTLD_NODELETE */
-  handle=dlopen(NSS_LDAP_SONAME,RTLD_LAZY);
+  handle = dlopen(NSS_LDAP_SONAME, RTLD_LAZY);
 #endif /* RTLD_NODELETE */
-  if (handle==NULL)
+  if (handle == NULL)
   {
-    log_log(LOG_WARNING,"Warning: LDAP NSS module not loaded: %s",dlerror());
+    log_log(LOG_WARNING, "Warning: LDAP NSS module not loaded: %s", dlerror());
     return;
   }
   /* clear any existing errors */
   dlerror();
   /* try to look up the flag */
-  enable_flag=(int *)dlsym(handle,"_nss_ldap_enablelookups");
-  error=dlerror();
-  if (error!=NULL)
+  enable_flag = (int *)dlsym(handle, "_nss_ldap_enablelookups");
+  error = dlerror();
+  if (error != NULL)
   {
-    log_log(LOG_WARNING,"Warning: %s (probably older NSS module 
loaded)",error);
+    log_log(LOG_WARNING, "Warning: %s (probably older NSS module loaded)",
+            error);
     /* fall back to changing the way host lookup is done */
 #ifdef HAVE___NSS_CONFIGURE_LOOKUP
-    if (__nss_configure_lookup("hosts","files dns"))
-      log_log(LOG_ERR,"unable to override hosts lookup method: 
%s",strerror(errno));
+    if (__nss_configure_lookup("hosts", "files dns"))
+      log_log(LOG_ERR, "unable to override hosts lookup method: %s",
+              strerror(errno));
 #endif /* HAVE___NSS_CONFIGURE_LOOKUP */
     dlclose(handle);
     return;
   }
   /* disable nss_ldap */
-  *enable_flag=0;
+  *enable_flag = 0;
 #ifdef RTLD_NODELETE
   /* only close the handle if RTLD_NODELETE was used */
   dlclose(handle);
@@ -664,194 +673,198 @@
 }
 
 /* the main program... */
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
 {
   int i;
-  sigset_t signalmask,oldmask;
+  sigset_t signalmask, oldmask;
 #ifdef HAVE_PTHREAD_TIMEDJOIN_NP
   struct timespec ts;
 #endif /* HAVE_PTHREAD_TIMEDJOIN_NP */
   /* parse the command line */
-  parse_cmdline(argc,argv);
+  parse_cmdline(argc, argv);
   /* clean the environment */
 #ifdef HAVE_CLEARENV
-  if ( clearenv() ||
-       putenv("HOME=/") ||
-       putenv("TMPDIR=/tmp") ||
-       putenv("LDAPNOINIT=1") )
+  if (clearenv() || putenv("HOME=/") || putenv("TMPDIR=/tmp") ||
+      putenv("LDAPNOINIT=1"))
   {
-    log_log(LOG_ERR,"clearing environment failed");
+    log_log(LOG_ERR, "clearing environment failed");
     exit(EXIT_FAILURE);
   }
 #else /* not HAVE_CLEARENV */
   /* this is a bit ugly */
-  environ=sane_environment;
+  environ = sane_environment;
 #endif /* not HAVE_CLEARENV */
   /* disable the nss_ldap module for this process */
   disable_nss_ldap();
   /* set LDAP log level */
-  if (myldap_set_debuglevel(nslcd_debugging)!=LDAP_SUCCESS)
+  if (myldap_set_debuglevel(nslcd_debugging) != LDAP_SUCCESS)
     exit(EXIT_FAILURE);
   /* read configuration file */
   cfg_init(NSLCD_CONF_PATH);
   /* set default mode for pidfile and socket */
   (void)umask((mode_t)0022);
   /* see if someone already locked the pidfile
-     if --check option was given:
-       exit TRUE if daemon runs (pidfile locked), FALSE otherwise */
+     if --check option was given exit TRUE if daemon runs
+     (pidfile locked), FALSE otherwise */
   if (nslcd_checkonly)
   {
     if (is_locked(NSLCD_PIDFILE))
     {
-      log_log(LOG_DEBUG,"pidfile (%s) is locked",NSLCD_PIDFILE);
+      log_log(LOG_DEBUG, "pidfile (%s) is locked", NSLCD_PIDFILE);
       exit(EXIT_SUCCESS);
     }
     else
     {
-      log_log(LOG_DEBUG,"pidfile (%s) is not locked",NSLCD_PIDFILE);
+      log_log(LOG_DEBUG, "pidfile (%s) is not locked", NSLCD_PIDFILE);
       exit(EXIT_FAILURE);
     }
   }
   /* normal check for pidfile locked */
   if (is_locked(NSLCD_PIDFILE))
   {
-    log_log(LOG_ERR,"daemon may already be active, cannot acquire lock (%s): 
%s",NSLCD_PIDFILE,strerror(errno));
+    log_log(LOG_ERR, "daemon may already be active, cannot acquire lock (%s): 
%s",
+            NSLCD_PIDFILE, strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* close all file descriptors (except stdin/out/err) */
-  i=sysconf(_SC_OPEN_MAX)-1;
+  i = sysconf(_SC_OPEN_MAX) - 1;
   /* if the system does not have OPEN_MAX just close the first 32 and
      hope we closed enough */
-  if (i<0)
-    i=32;
-  for (;i>3;i--)
+  if (i < 0)
+    i = 32;
+  for (; i > 3; i--)
     close(i);
   /* daemonize */
-  if ((!nslcd_debugging)&&(daemon(0,0)<0))
+  if ((!nslcd_debugging) && (daemon(0, 0) < 0))
   {
-    log_log(LOG_ERR,"unable to daemonize: %s",strerror(errno));
+    log_log(LOG_ERR, "unable to daemonize: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* intilialize logging */
   if (!nslcd_debugging)
     log_startlogging();
-  log_log(LOG_INFO,"version %s starting",VERSION);
+  log_log(LOG_INFO, "version %s starting", VERSION);
   /* write pidfile */
   create_pidfile(NSLCD_PIDFILE);
   /* install handler to close stuff off on exit and log notice */
   if (atexit(exithandler))
   {
-    log_log(LOG_ERR,"atexit() failed: %s",strerror(errno));
+    log_log(LOG_ERR, "atexit() failed: %s", strerror(errno));
     exit(EXIT_FAILURE);
   }
   /* create socket */
-  nslcd_serversocket=create_socket(NSLCD_SOCKET);
-  if ((nslcd_cfg->ldc_gid!=NOGID)&&(nslcd_cfg->ldc_uidname!=NULL))
+  nslcd_serversocket = create_socket(NSLCD_SOCKET);
+  if ((nslcd_cfg->ldc_gid != NOGID) && (nslcd_cfg->ldc_uidname != NULL))
   {
 #ifdef HAVE_INITGROUPS
     /* load supplementary groups */
-    if (initgroups(nslcd_cfg->ldc_uidname,nslcd_cfg->ldc_gid)<0)
-      log_log(LOG_WARNING,"cannot initgroups(\"%s\",%d) (ignored): %s",
-              nslcd_cfg->ldc_uidname,(int)nslcd_cfg->ldc_gid,strerror(errno));
+    if (initgroups(nslcd_cfg->ldc_uidname, nslcd_cfg->ldc_gid) < 0)
+      log_log(LOG_WARNING, "cannot initgroups(\"%s\",%d) (ignored): %s",
+              nslcd_cfg->ldc_uidname, (int)nslcd_cfg->ldc_gid, 
strerror(errno));
     else
-      log_log(LOG_DEBUG,"initgroups(\"%s\",%d) done",
-              nslcd_cfg->ldc_uidname,(int)nslcd_cfg->ldc_gid);
+      log_log(LOG_DEBUG, "initgroups(\"%s\",%d) done",
+              nslcd_cfg->ldc_uidname, (int)nslcd_cfg->ldc_gid);
 #else /* not HAVE_INITGROUPS */
 #ifdef HAVE_SETGROUPS
     /* just drop all supplemental groups */
-    if (setgroups(0,NULL)<0)
-      log_log(LOG_WARNING,"cannot setgroups(0,NULL) (ignored): 
%s",strerror(errno));
+    if (setgroups(0, NULL) < 0)
+      log_log(LOG_WARNING, "cannot setgroups(0,NULL) (ignored): %s",
+              strerror(errno));
     else
-      log_log(LOG_DEBUG,"setgroups(0,NULL) done");
+      log_log(LOG_DEBUG, "setgroups(0,NULL) done");
 #else /* not HAVE_SETGROUPS */
-    log_log(LOG_DEBUG,"neither initgroups() or setgroups() available");
+    log_log(LOG_DEBUG, "neither initgroups() or setgroups() available");
 #endif /* not HAVE_SETGROUPS */
 #endif /* not HAVE_INITGROUPS */
   }
   /* change to nslcd gid */
-  if (nslcd_cfg->ldc_gid!=NOGID)
+  if (nslcd_cfg->ldc_gid != NOGID)
   {
-    if (setgid(nslcd_cfg->ldc_gid)!=0)
+    if (setgid(nslcd_cfg->ldc_gid) != 0)
     {
-      log_log(LOG_ERR,"cannot setgid(%d): 
%s",(int)nslcd_cfg->ldc_gid,strerror(errno));
+      log_log(LOG_ERR, "cannot setgid(%d): %s",
+              (int)nslcd_cfg->ldc_gid, strerror(errno));
       exit(EXIT_FAILURE);
     }
-    log_log(LOG_DEBUG,"setgid(%d) done",(int)nslcd_cfg->ldc_gid);
+    log_log(LOG_DEBUG, "setgid(%d) done", (int)nslcd_cfg->ldc_gid);
   }
   /* change to nslcd uid */
-  if (nslcd_cfg->ldc_uid!=NOUID)
+  if (nslcd_cfg->ldc_uid != NOUID)
   {
-    if (setuid(nslcd_cfg->ldc_uid)!=0)
+    if (setuid(nslcd_cfg->ldc_uid) != 0)
     {
-      log_log(LOG_ERR,"cannot setuid(%d): 
%s",(int)nslcd_cfg->ldc_uid,strerror(errno));
+      log_log(LOG_ERR, "cannot setuid(%d): %s",
+              (int)nslcd_cfg->ldc_uid, strerror(errno));
       exit(EXIT_FAILURE);
     }
-    log_log(LOG_DEBUG,"setuid(%d) done",(int)nslcd_cfg->ldc_uid);
+    log_log(LOG_DEBUG, "setuid(%d) done", (int)nslcd_cfg->ldc_uid);
   }
   /* block all these signals so our worker threads won't handle them */
   sigemptyset(&signalmask);
-  sigaddset(&signalmask,SIGHUP);
-  sigaddset(&signalmask,SIGINT);
-  sigaddset(&signalmask,SIGQUIT);
-  sigaddset(&signalmask,SIGABRT);
-  sigaddset(&signalmask,SIGPIPE);
-  sigaddset(&signalmask,SIGTERM);
-  sigaddset(&signalmask,SIGUSR1);
-  sigaddset(&signalmask,SIGUSR2);
-  pthread_sigmask(SIG_BLOCK,&signalmask,&oldmask);
+  sigaddset(&signalmask, SIGHUP);
+  sigaddset(&signalmask, SIGINT);
+  sigaddset(&signalmask, SIGQUIT);
+  sigaddset(&signalmask, SIGABRT);
+  sigaddset(&signalmask, SIGPIPE);
+  sigaddset(&signalmask, SIGTERM);
+  sigaddset(&signalmask, SIGUSR1);
+  sigaddset(&signalmask, SIGUSR2);
+  pthread_sigmask(SIG_BLOCK, &signalmask, &oldmask);
   /* start worker threads */
-  log_log(LOG_INFO,"accepting connections");
-  nslcd_threads=(pthread_t *)malloc(nslcd_cfg->ldc_threads*sizeof(pthread_t));
-  if (nslcd_threads==NULL)
+  log_log(LOG_INFO, "accepting connections");
+  nslcd_threads = (pthread_t *)malloc(nslcd_cfg->ldc_threads * 
sizeof(pthread_t));
+  if (nslcd_threads == NULL)
   {
-    log_log(LOG_CRIT,"main(): malloc() failed to allocate memory");
+    log_log(LOG_CRIT, "main(): malloc() failed to allocate memory");
     exit(EXIT_FAILURE);
   }
-  for (i=0;i<nslcd_cfg->ldc_threads;i++)
+  for (i = 0; i < nslcd_cfg->ldc_threads; i++)
   {
-    if (pthread_create(&nslcd_threads[i],NULL,worker,NULL))
+    if (pthread_create(&nslcd_threads[i], NULL, worker, NULL))
     {
-      log_log(LOG_ERR,"unable to start worker thread %d: 
%s",i,strerror(errno));
+      log_log(LOG_ERR, "unable to start worker thread %d: %s",
+              i, strerror(errno));
       exit(EXIT_FAILURE);
     }
   }
-  pthread_sigmask(SIG_SETMASK,&oldmask,NULL);
+  pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
   /* install signalhandlers for some signals */
   install_sighandler(SIGHUP, sigexit_handler);
   install_sighandler(SIGINT, sigexit_handler);
-  install_sighandler(SIGQUIT,sigexit_handler);
-  install_sighandler(SIGABRT,sigexit_handler);
-  install_sighandler(SIGPIPE,SIG_IGN);
-  install_sighandler(SIGTERM,sigexit_handler);
-  install_sighandler(SIGUSR1,sigexit_handler);
-  install_sighandler(SIGUSR2,sigexit_handler);
+  install_sighandler(SIGQUIT, sigexit_handler);
+  install_sighandler(SIGABRT, sigexit_handler);
+  install_sighandler(SIGPIPE, SIG_IGN);
+  install_sighandler(SIGTERM, sigexit_handler);
+  install_sighandler(SIGUSR1, sigexit_handler);
+  install_sighandler(SIGUSR2, sigexit_handler);
   /* wait until we received a signal */
-  while (nslcd_exitsignal==0)
+  while (nslcd_exitsignal == 0)
   {
     sleep(INT_MAX); /* sleep as long as we can or until we receive a signal */
   }
   /* print something about received signal */
-  log_log(LOG_INFO,"caught signal %s (%d), shutting down",
-               signame(nslcd_exitsignal),nslcd_exitsignal);
+  log_log(LOG_INFO, "caught signal %s (%d), shutting down",
+          signame(nslcd_exitsignal), nslcd_exitsignal);
   /* cancel all running threads */
-  for (i=0;i<nslcd_cfg->ldc_threads;i++)
+  for (i = 0; i < nslcd_cfg->ldc_threads; i++)
     if (pthread_cancel(nslcd_threads[i]))
-      log_log(LOG_WARNING,"failed to stop thread %d (ignored): 
%s",i,strerror(errno));
+      log_log(LOG_WARNING, "failed to stop thread %d (ignored): %s",
+              i, strerror(errno));
   /* close server socket to trigger failures in threads waiting on accept() */
   close(nslcd_serversocket);
-  nslcd_serversocket=-1;
+  nslcd_serversocket = -1;
   /* if we can, wait a few seconds for the threads to finish */
 #ifdef HAVE_PTHREAD_TIMEDJOIN_NP
-  ts.tv_sec=time(NULL)+3;
-  ts.tv_nsec=0;
+  ts.tv_sec = time(NULL) + 3;
+  ts.tv_nsec = 0;
 #endif /* HAVE_PTHREAD_TIMEDJOIN_NP */
-  for (i=0;i<nslcd_cfg->ldc_threads;i++)
+  for (i = 0; i < nslcd_cfg->ldc_threads; i++)
   {
 #ifdef HAVE_PTHREAD_TIMEDJOIN_NP
-    pthread_timedjoin_np(nslcd_threads[i],NULL,&ts);
+    pthread_timedjoin_np(nslcd_threads[i], NULL, &ts);
 #endif /* HAVE_PTHREAD_TIMEDJOIN_NP */
-    if (pthread_kill(nslcd_threads[i],0)==0)
-      log_log(LOG_ERR,"thread %d is still running, shutting down anyway",i);
+    if (pthread_kill(nslcd_threads[i], 0) == 0)
+      log_log(LOG_ERR, "thread %d is still running, shutting down anyway", i);
   }
   /* we're done */
   return EXIT_FAILURE;

Modified: nss-pam-ldapd/nslcd/nsswitch.c
==============================================================================
--- nss-pam-ldapd/nslcd/nsswitch.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/nsswitch.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    nsswitch.c - functions for parsing /etc/nsswitch.conf
 
-   Copyright (C) 2011 Arthur de Jong
+   Copyright (C) 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -35,10 +35,10 @@
 /* the cached value of whether shadow lookups use LDAP in nsswitch.conf */
 #define NSSWITCH_FILE "/etc/nsswitch.conf"
 #define CACHED_UNKNOWN 22
-static int cached_shadow_uses_ldap=CACHED_UNKNOWN;
-static time_t cached_shadow_lastcheck=0;
+static int cached_shadow_uses_ldap = CACHED_UNKNOWN;
+static time_t cached_shadow_lastcheck = 0;
 #define CACHED_SHADOW_TIMEOUT (60)
-static time_t nsswitch_mtime=0;
+static time_t nsswitch_mtime = 0;
 
 /* the maximum line length supported of nsswitch.conf */
 #define MAX_LINE_LENGTH          4096
@@ -49,71 +49,77 @@
 {
   struct stat buf;
   time_t t;
-  if ((cached_shadow_uses_ldap!=CACHED_UNKNOWN)&&
-      ((t=time(NULL)) > (cached_shadow_lastcheck+CACHED_SHADOW_TIMEOUT)))
+  if ((cached_shadow_uses_ldap != CACHED_UNKNOWN) &&
+      ((t = time(NULL)) > (cached_shadow_lastcheck + CACHED_SHADOW_TIMEOUT)))
   {
-    cached_shadow_lastcheck=t;
-    if (stat(NSSWITCH_FILE,&buf))
+    cached_shadow_lastcheck = t;
+    if (stat(NSSWITCH_FILE, &buf))
     {
-      log_log(LOG_ERR,"stat(%s) failed: %s",NSSWITCH_FILE,strerror(errno));
+      log_log(LOG_ERR, "stat(%s) failed: %s", NSSWITCH_FILE, strerror(errno));
       /* trigger a recheck anyway */
-      cached_shadow_uses_ldap=CACHED_UNKNOWN;
+      cached_shadow_uses_ldap = CACHED_UNKNOWN;
       return;
     }
     /* trigger a recheck if file changed */
-    if (buf.st_mtime!=nsswitch_mtime)
+    if (buf.st_mtime != nsswitch_mtime)
     {
-      nsswitch_mtime=buf.st_mtime;
-      cached_shadow_uses_ldap=CACHED_UNKNOWN;
+      nsswitch_mtime = buf.st_mtime;
+      cached_shadow_uses_ldap = CACHED_UNKNOWN;
     }
   }
 }
 
 /* see if the line is a service definition for db and return a pointer to
    the beginning of the services list if it is */
-static const char *find_db(const char *line,const char *db)
+static const char *find_db(const char *line, const char *db)
 {
   int i;
-  i=strlen(db);
+  i = strlen(db);
   /* the line should begin with the db we're looking for */
-  if (strncmp(line,db,i)!=0)
+  if (strncmp(line, db, i) != 0)
     return NULL;
   /* followed by a : */
-  while (isspace(line[i])) i++;
-  if (line[i]!=':')
+  while (isspace(line[i]))
+    i++;
+  if (line[i] != ':')
     return NULL;
   i++;
-  while (isspace(line[i])) i++;
-  return line+i;
+  while (isspace(line[i]))
+    i++;
+  return line + i;
 }
 
 /* check to see if the list of services contains the specified service */
-static int has_service(const char *services,const char *service,
-                       const char *filename,int lnr)
+static int has_service(const char *services, const char *service,
+                       const char *filename, int lnr)
 {
-  int i=0,l;
-  if (services==NULL)
+  int i = 0, l;
+  if (services == NULL)
     return 0;
-  l=strlen(service);
-  while (services[i]!='\0')
+  l = strlen(service);
+  while (services[i] != '\0')
   {
     /* skip spaces */
-    while (isspace(services[i])) i++;
+    while (isspace(services[i]))
+      i++;
     /* check if this is the service */
-    if ((strncmp(services+i,service,l)==0)&&(!isalnum(services[i+l])))
+    if ((strncmp(services + i, service, l) == 0) && (!isalnum(services[i + 
l])))
       return 1;
     /* skip service name and spaces */
     i++;
-    while (isalnum(services[i])) i++;
-    while (isspace(services[i])) i++;
+    while (isalnum(services[i]))
+      i++;
+    while (isspace(services[i]))
+      i++;
     /* skip action mappings */
-    if (services[i]=='[')
+    if (services[i] == '[')
     {
       i++; /* skip [ */
-      while ((services[i]!=']')&&(services[i]!='\0')) i++;
-      if (services[i]!=']')
+      while ((services[i] != ']') && (services[i] != '\0'))
+        i++;
+      if (services[i] != ']')
       {
-        log_log(LOG_WARNING,"%s: error parsing line %d",filename,lnr);
+        log_log(LOG_WARNING, "%s: error parsing line %d", filename, lnr);
         return 0; /* parse error */
       }
       i++; /* skip ] */
@@ -125,36 +131,36 @@
 static int shadow_uses_ldap(void)
 {
   FILE *fp;
-  int lnr=0;
+  int lnr = 0;
   char linebuf[MAX_LINE_LENGTH];
   const char *services;
-  int shadow_found=0;
-  int passwd_has_ldap=0;
+  int shadow_found = 0;
+  int passwd_has_ldap = 0;
   /* open config file */
-  if ((fp=fopen(NSSWITCH_FILE,"r"))==NULL)
+  if ((fp = fopen(NSSWITCH_FILE, "r")) == NULL)
   {
-    log_log(LOG_ERR,"cannot open %s: %s",NSSWITCH_FILE,strerror(errno));
+    log_log(LOG_ERR, "cannot open %s: %s", NSSWITCH_FILE, strerror(errno));
     return 0;
   }
   /* read file and parse lines */
-  while (fgets(linebuf,sizeof(linebuf),fp)!=NULL)
+  while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
   {
     lnr++;
     /* see if we have a shadow line */
-    services=find_db(linebuf,"shadow");
-    if (services!=NULL)
+    services = find_db(linebuf, "shadow");
+    if (services != NULL)
     {
-      shadow_found=1;
-      if (has_service(services,"ldap",NSSWITCH_FILE,lnr))
+      shadow_found = 1;
+      if (has_service(services, "ldap", NSSWITCH_FILE, lnr))
       {
         fclose(fp);
         return 1;
       }
     }
     /* see if we have a passwd line */
-    services=find_db(linebuf,"passwd");
-    if (services!=NULL)
-      passwd_has_ldap=has_service(services,"ldap",NSSWITCH_FILE,lnr);
+    services = find_db(linebuf, "passwd");
+    if (services != NULL)
+      passwd_has_ldap = has_service(services, "ldap", NSSWITCH_FILE, lnr);
   }
   fclose(fp);
   if (shadow_found)
@@ -165,11 +171,11 @@
 /* check whether shadow lookups are configured to use ldap */
 int nsswitch_shadow_uses_ldap(void)
 {
-  if (cached_shadow_uses_ldap==CACHED_UNKNOWN)
+  if (cached_shadow_uses_ldap == CACHED_UNKNOWN)
   {
-    log_log(LOG_INFO,"(re)loading %s",NSSWITCH_FILE);
-    cached_shadow_uses_ldap=shadow_uses_ldap();
-    cached_shadow_lastcheck=time(NULL);
+    log_log(LOG_INFO, "(re)loading %s", NSSWITCH_FILE);
+    cached_shadow_uses_ldap = shadow_uses_ldap();
+    cached_shadow_lastcheck = time(NULL);
   }
   return cached_shadow_uses_ldap;
 }

Modified: nss-pam-ldapd/nslcd/pam.c
==============================================================================
--- nss-pam-ldapd/nslcd/pam.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/pam.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -41,7 +41,7 @@
 
 /* set up a connection and try to bind with the specified DN and password,
    returns an LDAP result code */
-static int try_bind(const char *userdn,const char *password)
+static int try_bind(const char *userdn, const char *password)
 {
   MYLDAP_SESSION *session;
   MYLDAP_SEARCH *search;
@@ -49,29 +49,30 @@
   static const char *attrs[2];
   int rc;
   /* set up a new connection */
-  session=myldap_create_session();
-  if (session==NULL)
+  session = myldap_create_session();
+  if (session == NULL)
     return LDAP_UNAVAILABLE;
   /* set up credentials for the session */
-  myldap_set_credentials(session,userdn,password);
+  myldap_set_credentials(session, userdn, password);
   /* perform search for own object (just to do any kind of search) */
-  attrs[0]="dn";
-  attrs[1]=NULL;
-  
search=myldap_search(session,userdn,LDAP_SCOPE_BASE,"(objectClass=*)",attrs,&rc);
-  if ((search==NULL)||(rc!=LDAP_SUCCESS))
-  {
-    if (rc==LDAP_SUCCESS)
-      rc=LDAP_LOCAL_ERROR;
-    log_log(LOG_WARNING,"%s: lookup failed: %s",userdn,ldap_err2string(rc));
+  attrs[0] = "dn";
+  attrs[1] = NULL;
+  search = myldap_search(session, userdn, LDAP_SCOPE_BASE,
+                         "(objectClass=*)", attrs, &rc);
+  if ((search == NULL) || (rc != LDAP_SUCCESS))
+  {
+    if (rc == LDAP_SUCCESS)
+      rc = LDAP_LOCAL_ERROR;
+    log_log(LOG_WARNING, "%s: lookup failed: %s", userdn, ldap_err2string(rc));
   }
   else
   {
-    entry=myldap_get_entry(search,&rc);
-    if ((entry==NULL)||(rc!=LDAP_SUCCESS))
+    entry = myldap_get_entry(search, &rc);
+    if ((entry == NULL) || (rc != LDAP_SUCCESS))
     {
-      if (rc==LDAP_SUCCESS)
-        rc=LDAP_NO_RESULTS_RETURNED;
-      log_log(LOG_WARNING,"%s: lookup failed: %s",userdn,ldap_err2string(rc));
+      if (rc == LDAP_SUCCESS)
+        rc = LDAP_NO_RESULTS_RETURNED;
+      log_log(LOG_WARNING, "%s: lookup failed: %s", userdn, 
ldap_err2string(rc));
     }
   }
   /* close the session */
@@ -83,87 +84,90 @@
 /* ensure that both userdn and username are filled in from the entry,
    returns an LDAP result code */
 static MYLDAP_ENTRY *validate_user(MYLDAP_SESSION *session,
-                         char *username,int *rcp)
+                                   char *username, int *rcp)
 {
   int rc;
-  MYLDAP_ENTRY *entry=NULL;
+  MYLDAP_ENTRY *entry = NULL;
   /* check username for validity */
   if (!isvalidname(username))
   {
-    log_log(LOG_WARNING,"request denied by validnames option");
-    *rcp=LDAP_NO_SUCH_OBJECT;
+    log_log(LOG_WARNING, "request denied by validnames option");
+    *rcp = LDAP_NO_SUCH_OBJECT;
     return NULL;
   }
   /* get the user entry based on the username */
-  entry=uid2entry(session,username,&rc);
-  if (entry==NULL)
+  entry = uid2entry(session, username, &rc);
+  if (entry == NULL)
   {
-    if (rc==LDAP_SUCCESS)
-      rc=LDAP_NO_SUCH_OBJECT;
-    log_log(LOG_DEBUG,"\"%s\": user not found: 
%s",username,ldap_err2string(rc));
-    *rcp=rc;
+    if (rc == LDAP_SUCCESS)
+      rc = LDAP_NO_SUCH_OBJECT;
+    log_log(LOG_DEBUG, "\"%s\": user not found: %s", username, 
ldap_err2string(rc));
+    *rcp = rc;
   }
   return entry;
 }
 
 /* update the username value from the entry if needed */
-static void update_username(MYLDAP_ENTRY *entry,char *username,size_t 
username_len)
+static void update_username(MYLDAP_ENTRY *entry, char *username,
+                            size_t username_len)
 {
   const char **values;
   const char *value;
   /* get the "real" username */
-  value=myldap_get_rdn_value(entry,attmap_passwd_uid);
-  if (value==NULL)
+  value = myldap_get_rdn_value(entry, attmap_passwd_uid);
+  if (value == NULL)
   {
     /* get the username from the uid attribute */
-    values=myldap_get_values(entry,attmap_passwd_uid);
-    if ((values==NULL)||(values[0]==NULL))
+    values = myldap_get_values(entry, attmap_passwd_uid);
+    if ((values == NULL) || (values[0] == NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_passwd_uid);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_passwd_uid);
       return;
     }
-    value=values[0];
+    value = values[0];
   }
   /* check the username */
-  if ((value==NULL)||!isvalidname(value)||strlen(value)>=username_len)
+  if ((value == NULL) || !isvalidname(value) || strlen(value) >= username_len)
   {
-    log_log(LOG_WARNING,"%s: %s: denied by validnames option",
-                        myldap_get_dn(entry),attmap_passwd_uid);
+    log_log(LOG_WARNING, "%s: %s: denied by validnames option",
+            myldap_get_dn(entry), attmap_passwd_uid);
     return;
   }
   /* check if the username is different and update it if needed */
-  if (strcmp(username,value)!=0)
+  if (strcmp(username, value) != 0)
   {
-    log_log(LOG_INFO,"username changed from \"%s\" to \"%s\"",username,value);
-    strcpy(username,value);
+    log_log(LOG_INFO, "username changed from \"%s\" to \"%s\"",
+            username, value);
+    strcpy(username, value);
   }
 }
 
-static int check_shadow(MYLDAP_SESSION *session,const char *username,
-                        char *authzmsg,size_t authzmsgsz,
-                        int check_maxdays,int check_mindays)
+static int check_shadow(MYLDAP_SESSION *session, const char *username,
+                        char *authzmsg, size_t authzmsgsz,
+                        int check_maxdays, int check_mindays)
 {
-  MYLDAP_ENTRY *entry=NULL;
-  long today,lastchangedate,mindays,maxdays,warndays,inactdays,expiredate;
+  MYLDAP_ENTRY *entry = NULL;
+  long today, lastchangedate, mindays, maxdays, warndays, inactdays, 
expiredate;
   unsigned long flag;
-  long daysleft,inactleft;
+  long daysleft, inactleft;
   /* get the shadow entry */
-  entry=shadow_uid2entry(session,username,NULL);
-  if (entry==NULL)
+  entry = shadow_uid2entry(session, username, NULL);
+  if (entry == NULL)
     return NSLCD_PAM_SUCCESS; /* no shadow entry found, nothing to check */
   /* get today's date */
-  today=(long)(time(NULL)/(60*60*24));
+  today = (long)(time(NULL) / (60 * 60 * 24));
   /* get shadown information */
-  get_shadow_properties(entry,&lastchangedate,&mindays,&maxdays,&warndays,
-                        &inactdays,&expiredate,&flag);
+  get_shadow_properties(entry, &lastchangedate, &mindays, &maxdays, &warndays,
+                        &inactdays, &expiredate, &flag);
   /* check account expiry date */
-  if ((expiredate!=-1)&&(today>=expiredate))
+  if ((expiredate != -1) && (today >= expiredate))
   {
-    daysleft=today-expiredate;
-    mysnprintf(authzmsg,authzmsgsz-1,"account expired %ld days ago",daysleft);
-    log_log(LOG_WARNING,"%s: %s: %s",
-                        
myldap_get_dn(entry),attmap_shadow_shadowExpire,authzmsg);
+    daysleft = today - expiredate;
+    mysnprintf(authzmsg, authzmsgsz - 1, "account expired %ld days ago",
+               daysleft);
+    log_log(LOG_WARNING, "%s: %s: %s",
+            myldap_get_dn(entry), attmap_shadow_shadowExpire, authzmsg);
     return NSLCD_PAM_ACCT_EXPIRED;
   }
   /* password expiration isn't interesting at this point because the user
@@ -172,67 +176,70 @@
   if (check_maxdays)
   {
     /* check lastchanged */
-    if (lastchangedate==0)
+    if (lastchangedate == 0)
     {
-      mysnprintf(authzmsg,authzmsgsz-1,"need a new password");
-      log_log(LOG_WARNING,"%s: %s: %s",
-                          
myldap_get_dn(entry),attmap_shadow_shadowLastChange,authzmsg);
+      mysnprintf(authzmsg, authzmsgsz - 1, "need a new password");
+      log_log(LOG_WARNING, "%s: %s: %s",
+              myldap_get_dn(entry), attmap_shadow_shadowLastChange, authzmsg);
       return NSLCD_PAM_NEW_AUTHTOK_REQD;
     }
-    else if (today<lastchangedate)
-      log_log(LOG_WARNING,"%s: %s: password changed in the future",
-                          myldap_get_dn(entry),attmap_shadow_shadowLastChange);
-    else if (maxdays!=-1)
+    else if (today < lastchangedate)
+      log_log(LOG_WARNING, "%s: %s: password changed in the future",
+              myldap_get_dn(entry), attmap_shadow_shadowLastChange);
+    else if (maxdays != -1)
     {
       /* check maxdays */
-      daysleft=lastchangedate+maxdays-today;
-      if (daysleft==0)
-        mysnprintf(authzmsg,authzmsgsz-1,"password will expire today");
-      else if (daysleft<0)
-        mysnprintf(authzmsg,authzmsgsz-1,"password expired %ld days 
ago",-daysleft);
+      daysleft = lastchangedate + maxdays - today;
+      if (daysleft == 0)
+        mysnprintf(authzmsg, authzmsgsz - 1, "password will expire today");
+      else if (daysleft < 0)
+        mysnprintf(authzmsg, authzmsgsz - 1, "password expired %ld days ago",
+                   -daysleft);
       /* check inactdays */
-      if ((daysleft<=0)&&(inactdays!=-1))
+      if ((daysleft <= 0) && (inactdays != -1))
       {
-        inactleft=lastchangedate+maxdays+inactdays-today;
-        if (inactleft==0)
-          mysnprintf(authzmsg+strlen(authzmsg),authzmsgsz-strlen(authzmsg)-1,
+        inactleft = lastchangedate + maxdays + inactdays - today;
+        if (inactleft == 0)
+          mysnprintf(authzmsg + strlen(authzmsg), authzmsgsz - 
strlen(authzmsg) - 1,
                      ", account will be locked today");
-        else if (inactleft>0)
-          mysnprintf(authzmsg+strlen(authzmsg),authzmsgsz-strlen(authzmsg)-1,
-                     ", account will be locked in %ld days",inactleft);
+        else if (inactleft > 0)
+          mysnprintf(authzmsg + strlen(authzmsg), authzmsgsz - 
strlen(authzmsg) - 1,
+                     ", account will be locked in %ld days", inactleft);
         else
         {
-          mysnprintf(authzmsg+strlen(authzmsg),authzmsgsz-strlen(authzmsg)-1,
-                     ", account locked %ld days ago",-inactleft);
-          log_log(LOG_WARNING,"%s: %s: %s",
-                              
myldap_get_dn(entry),attmap_shadow_shadowInactive,authzmsg);
+          mysnprintf(authzmsg + strlen(authzmsg), authzmsgsz - 
strlen(authzmsg) - 1,
+                     ", account locked %ld days ago", -inactleft);
+          log_log(LOG_WARNING, "%s: %s: %s", myldap_get_dn(entry),
+                  attmap_shadow_shadowInactive, authzmsg);
           return NSLCD_PAM_AUTHTOK_EXPIRED;
         }
       }
-      if (daysleft<=0)
+      if (daysleft <= 0)
       {
         /* log previously built message */
-        log_log(LOG_WARNING,"%s: %s: %s",
-                            
myldap_get_dn(entry),attmap_shadow_shadowMax,authzmsg);
+        log_log(LOG_WARNING, "%s: %s: %s",
+                myldap_get_dn(entry), attmap_shadow_shadowMax, authzmsg);
         return NSLCD_PAM_NEW_AUTHTOK_REQD;
       }
       /* check warndays */
-      if ((warndays>0)&&(daysleft<=warndays))
+      if ((warndays > 0) && (daysleft <= warndays))
       {
-        mysnprintf(authzmsg,authzmsgsz-1,"password will expire in %ld 
days",daysleft);
-        log_log(LOG_WARNING,"%s: %s: %s",
-                            
myldap_get_dn(entry),attmap_shadow_shadowWarning,authzmsg);
+        mysnprintf(authzmsg, authzmsgsz - 1,
+                   "password will expire in %ld days", daysleft);
+        log_log(LOG_WARNING, "%s: %s: %s",
+                myldap_get_dn(entry), attmap_shadow_shadowWarning, authzmsg);
       }
     }
   }
   if (check_mindays)
   {
-    daysleft=lastchangedate+mindays-today;
-    if ((mindays!=-1)&&(daysleft>0))
+    daysleft = lastchangedate + mindays - today;
+    if ((mindays != -1) && (daysleft > 0))
     {
-      mysnprintf(authzmsg,authzmsgsz-1,"password cannot be changed for another 
%ld days",daysleft);
-      log_log(LOG_WARNING,"%s: %s: %s",
-                          
myldap_get_dn(entry),attmap_shadow_shadowMin,authzmsg);
+      mysnprintf(authzmsg, authzmsgsz - 1,
+                 "password cannot be changed for another %ld days", daysleft);
+      log_log(LOG_WARNING, "%s: %s: %s",
+              myldap_get_dn(entry), attmap_shadow_shadowMin, authzmsg);
       return NSLCD_PAM_AUTHTOK_ERR;
     }
   }
@@ -240,108 +247,109 @@
 }
 
 /* check authentication credentials of the user */
-int nslcd_pam_authc(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid)
+int nslcd_pam_authc(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid)
 {
   int32_t tmpint32;
   int rc;
-  char username[256],service[64],ruser[256],rhost[HOST_NAME_MAX+1],tty[64];
+  char username[256], service[64], ruser[256], rhost[HOST_NAME_MAX + 1], 
tty[64];
   char password[64];
   const char *userdn;
   MYLDAP_ENTRY *entry;
-  int authzrc=NSLCD_PAM_SUCCESS;
+  int authzrc = NSLCD_PAM_SUCCESS;
   char authzmsg[1024];
-  authzmsg[0]='\0';
+  authzmsg[0] = '\0';
   /* read request parameters */
-  READ_STRING(fp,username);
-  READ_STRING(fp,service);
-  READ_STRING(fp,ruser);
-  READ_STRING(fp,rhost);
-  READ_STRING(fp,tty);
-  READ_STRING(fp,password);
+  READ_STRING(fp, username);
+  READ_STRING(fp, service);
+  READ_STRING(fp, ruser);
+  READ_STRING(fp, rhost);
+  READ_STRING(fp, tty);
+  READ_STRING(fp, password);
   /* log call */
-  log_setrequest("authc=\"%s\"",username);
-  log_log(LOG_DEBUG,"nslcd_pam_authc(\"%s\",\"%s\",\"%s\")",
-                    username,service,*password?"***":"");
+  log_setrequest("authc=\"%s\"", username);
+  log_log(LOG_DEBUG, "nslcd_pam_authc(\"%s\",\"%s\",\"%s\")",
+          username, service, *password ? "***" : "");
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_PAM_AUTHC);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_PAM_AUTHC);
   /* if the username is blank and rootpwmoddn is configured, try to
      authenticate as administrator, otherwise validate request as usual */
-  if ((*username=='\0')&&(nslcd_cfg->ldc_rootpwmoddn!=NULL))
+  if ((*username == '\0') && (nslcd_cfg->ldc_rootpwmoddn != NULL))
   {
-    userdn=nslcd_cfg->ldc_rootpwmoddn;
+    userdn = nslcd_cfg->ldc_rootpwmoddn;
     /* if the caller is root we will allow the use of the rootpwmodpw option */
-    if ((*password=='\0')&&(calleruid==0)&&(nslcd_cfg->ldc_rootpwmodpw!=NULL))
+    if ((*password == '\0') && (calleruid == 0) && (nslcd_cfg->ldc_rootpwmodpw 
!= NULL))
     {
-      if (strlen(nslcd_cfg->ldc_rootpwmodpw)>=sizeof(password))
+      if (strlen(nslcd_cfg->ldc_rootpwmodpw) >= sizeof(password))
       {
-        log_log(LOG_ERR,"nslcd_pam_authc(): rootpwmodpw will not fit in 
password");
+        log_log(LOG_ERR, "nslcd_pam_authc(): rootpwmodpw will not fit in 
password");
         return -1;
       }
-      strcpy(password,nslcd_cfg->ldc_rootpwmodpw);
+      strcpy(password, nslcd_cfg->ldc_rootpwmodpw);
     }
   }
   else
   {
     /* try normal authentication, lookup the user entry */
-    entry=validate_user(session,username,&rc);
-    if (entry==NULL)
+    entry = validate_user(session, username, &rc);
+    if (entry == NULL)
     {
       /* for user not found we just say no result */
-      if (rc==LDAP_NO_SUCH_OBJECT)
+      if (rc == LDAP_NO_SUCH_OBJECT)
       {
-        WRITE_INT32(fp,NSLCD_RESULT_END);
+        WRITE_INT32(fp, NSLCD_RESULT_END);
       }
       return -1;
     }
-    userdn=myldap_get_dn(entry);
-    update_username(entry,username,sizeof(username));
+    userdn = myldap_get_dn(entry);
+    update_username(entry, username, sizeof(username));
   }
   /* try authentication */
-  rc=try_bind(userdn,password);
-  if (rc==LDAP_SUCCESS)
-    log_log(LOG_DEBUG,"bind successful");
+  rc = try_bind(userdn, password);
+  if (rc == LDAP_SUCCESS)
+    log_log(LOG_DEBUG, "bind successful");
   /* map result code */
   switch (rc)
   {
-    case LDAP_SUCCESS:             rc=NSLCD_PAM_SUCCESS;  break;
-    case LDAP_INVALID_CREDENTIALS: rc=NSLCD_PAM_AUTH_ERR; break;
-    default:                       rc=NSLCD_PAM_AUTH_ERR;
+    case LDAP_SUCCESS:             rc = NSLCD_PAM_SUCCESS;  break;
+    case LDAP_INVALID_CREDENTIALS: rc = NSLCD_PAM_AUTH_ERR; break;
+    default:                       rc = NSLCD_PAM_AUTH_ERR;
   }
   /* perform shadow attribute checks */
-  if (*username!='\0')
-    authzrc=check_shadow(session,username,authzmsg,sizeof(authzmsg),1,0);
+  if (*username != '\0')
+    authzrc = check_shadow(session, username, authzmsg, sizeof(authzmsg), 1, 
0);
   /* write response */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_INT32(fp,rc);
-  WRITE_STRING(fp,username);
-  WRITE_INT32(fp,authzrc);
-  WRITE_STRING(fp,authzmsg);
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, rc);
+  WRITE_STRING(fp, username);
+  WRITE_INT32(fp, authzrc);
+  WRITE_STRING(fp, authzmsg);
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }
 
-static void autzsearch_var_add(DICT *dict,const char *name,const char *value)
+static void autzsearch_var_add(DICT *dict, const char *name,
+                               const char *value)
 {
   size_t sz;
   char *escaped_value;
   /* allocate memory for escaped string */
-  sz=((strlen(value)+8)*120)/100;
-  escaped_value=(char *)malloc(sz);
-  if (escaped_value==NULL)
+  sz = ((strlen(value) + 8) * 120) / 100;
+  escaped_value = (char *)malloc(sz);
+  if (escaped_value == NULL)
   {
-    log_log(LOG_CRIT,"autzsearch_var_add(): malloc() failed to allocate 
memory");
+    log_log(LOG_CRIT, "autzsearch_var_add(): malloc() failed to allocate 
memory");
     return;
   }
   /* perform escaping of the value */
-  if(myldap_escape(value,escaped_value,sz))
+  if (myldap_escape(value, escaped_value, sz))
   {
-    log_log(LOG_CRIT,"autzsearch_var_add(): myldap_escape() failed to fit in 
buffer");
+    log_log(LOG_CRIT, "autzsearch_var_add(): myldap_escape() failed to fit in 
buffer");
     free(escaped_value);
     return;
   }
   /* add to dict */
-  dict_put(dict,name,escaped_value);
+  dict_put(dict, name, escaped_value);
 }
 
 static void autzsearch_vars_free(DICT *dict)
@@ -352,10 +360,10 @@
   /* go over all keys and free all the values
      (they were allocated in autzsearch_var_add) */
   /* loop over dictionary contents */
-  keys=dict_keys(dict);
-  for (i=0;keys[i]!=NULL;i++)
+  keys = dict_keys(dict);
+  for (i = 0; keys[i] != NULL; i++)
   {
-    value=dict_get(dict,keys[i]);
+    value = dict_get(dict, keys[i]);
     if (value)
       free(value);
   }
@@ -363,22 +371,23 @@
   /* after this values from the dict should obviously no longer be used */
 }
 
-static const char *autzsearch_var_get(const char *name,void *expander_attr)
+static const char *autzsearch_var_get(const char *name, void *expander_attr)
 {
-  DICT *dict=(DICT *)expander_attr;
-  return (const char *)dict_get(dict,name);
+  DICT *dict = (DICT *)expander_attr;
+  return (const char *)dict_get(dict, name);
   /* TODO: if not set use entry to get attribute name (entry can be an
            element in the dict) */
 }
 
 /* perform an authorisation search, returns an LDAP status code */
-static int try_autzsearch(MYLDAP_SESSION *session,const char *dn,
-                          const char *username,const char *servicename,
-                          const char *ruser,const char *rhost,const char *tty)
+static int try_autzsearch(MYLDAP_SESSION *session, const char *dn,
+                          const char *username, const char *servicename,
+                          const char *ruser, const char *rhost,
+                          const char *tty)
 {
-  char hostname[HOST_NAME_MAX+1];
+  char hostname[HOST_NAME_MAX + 1];
   const char *fqdn;
-  DICT *dict=NULL;
+  DICT *dict = NULL;
   char filter[4096];
   MYLDAP_SEARCH *search;
   MYLDAP_ENTRY *entry;
@@ -387,67 +396,68 @@
   const char *res;
   int i;
   /* go over all pam_authz_search options */
-  for 
(i=0;(i<NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES)&&(nslcd_cfg->ldc_pam_authz_search[i]!=NULL);i++)
+  for (i = 0; (i < NSS_LDAP_CONFIG_MAX_AUTHZ_SEARCHES) && 
(nslcd_cfg->ldc_pam_authz_search[i] != NULL); i++)
   {
-    if (dict==NULL)
+    if (dict == NULL)
     {
       /* build the dictionary with variables
          NOTE: any variables added here also need to be added to
                cfg.c:parse_pam_authz_search_statement() */
-      dict=dict_new();
-      autzsearch_var_add(dict,"username",username);
-      autzsearch_var_add(dict,"service",servicename);
-      autzsearch_var_add(dict,"ruser",ruser);
-      autzsearch_var_add(dict,"rhost",rhost);
-      autzsearch_var_add(dict,"tty",tty);
-      if (gethostname(hostname,sizeof(hostname))==0)
-        autzsearch_var_add(dict,"hostname",hostname);
-      if ((fqdn=getfqdn())!=NULL)
-        autzsearch_var_add(dict,"fqdn",fqdn);
-      autzsearch_var_add(dict,"dn",dn);
-      autzsearch_var_add(dict,"uid",username);
+      dict = dict_new();
+      autzsearch_var_add(dict, "username", username);
+      autzsearch_var_add(dict, "service", servicename);
+      autzsearch_var_add(dict, "ruser", ruser);
+      autzsearch_var_add(dict, "rhost", rhost);
+      autzsearch_var_add(dict, "tty", tty);
+      if (gethostname(hostname, sizeof(hostname)) == 0)
+        autzsearch_var_add(dict, "hostname", hostname);
+      if ((fqdn = getfqdn()) != NULL)
+        autzsearch_var_add(dict, "fqdn", fqdn);
+      autzsearch_var_add(dict, "dn", dn);
+      autzsearch_var_add(dict, "uid", username);
     }
     /* build the search filter */
-    res=expr_parse(nslcd_cfg->ldc_pam_authz_search[i],
-                   filter,sizeof(filter),
-                   autzsearch_var_get,(void *)dict);
-    if (res==NULL)
+    res = expr_parse(nslcd_cfg->ldc_pam_authz_search[i],
+                     filter, sizeof(filter),
+                     autzsearch_var_get, (void *)dict);
+    if (res == NULL)
     {
       autzsearch_vars_free(dict);
       dict_free(dict);
-      log_log(LOG_ERR,"invalid pam_authz_search 
\"%s\"",nslcd_cfg->ldc_pam_authz_search[i]);
+      log_log(LOG_ERR, "invalid pam_authz_search \"%s\"",
+              nslcd_cfg->ldc_pam_authz_search[i]);
       return LDAP_LOCAL_ERROR;
     }
-    log_log(LOG_DEBUG,"trying pam_authz_search \"%s\"",filter);
+    log_log(LOG_DEBUG, "trying pam_authz_search \"%s\"", filter);
     /* perform the search */
-    attrs[0]="dn";
-    attrs[1]=NULL;
+    attrs[0] = "dn";
+    attrs[1] = NULL;
     /* FIXME: this only searches the first base */
-    search=myldap_search(session,nslcd_cfg->ldc_bases[0],LDAP_SCOPE_SUBTREE,
-                         filter,attrs,&rc);
-    if (search==NULL)
+    search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                           LDAP_SCOPE_SUBTREE, filter, attrs, &rc);
+    if (search == NULL)
     {
       autzsearch_vars_free(dict);
       dict_free(dict);
-      log_log(LOG_ERR,"pam_authz_search \"%s\" failed: %s",
-              filter,ldap_err2string(rc));
+      log_log(LOG_ERR, "pam_authz_search \"%s\" failed: %s",
+              filter, ldap_err2string(rc));
       return rc;
     }
     /* try to get an entry */
-    entry=myldap_get_entry(search,&rc);
-    if (entry==NULL)
+    entry = myldap_get_entry(search, &rc);
+    if (entry == NULL)
     {
       autzsearch_vars_free(dict);
       dict_free(dict);
-      log_log(LOG_ERR,"pam_authz_search \"%s\" found no matches",filter);
-      if (rc==LDAP_SUCCESS)
-        rc=LDAP_NO_SUCH_OBJECT;
+      log_log(LOG_ERR, "pam_authz_search \"%s\" found no matches", filter);
+      if (rc == LDAP_SUCCESS)
+        rc = LDAP_NO_SUCH_OBJECT;
       return rc;
     }
-    log_log(LOG_DEBUG,"pam_authz_search found \"%s\"",myldap_get_dn(entry));
+    log_log(LOG_DEBUG, "pam_authz_search found \"%s\"", myldap_get_dn(entry));
   }
   /* we went over all pam_authz_search entries */
-  if (dict!=NULL)
+  if (dict != NULL)
   {
     autzsearch_vars_free(dict);
     dict_free(dict);
@@ -456,141 +466,144 @@
 }
 
 /* check authorisation of the user */
-int nslcd_pam_authz(TFILE *fp,MYLDAP_SESSION *session)
+int nslcd_pam_authz(TFILE *fp, MYLDAP_SESSION *session)
 {
   int32_t tmpint32;
   int rc;
-  char username[256],service[64],ruser[256],rhost[HOST_NAME_MAX+1],tty[64];
+  char username[256], service[64], ruser[256], rhost[HOST_NAME_MAX + 1], 
tty[64];
   MYLDAP_ENTRY *entry;
   char authzmsg[1024];
-  authzmsg[0]='\0';
+  authzmsg[0] = '\0';
   /* read request parameters */
-  READ_STRING(fp,username);
-  READ_STRING(fp,service);
-  READ_STRING(fp,ruser);
-  READ_STRING(fp,rhost);
-  READ_STRING(fp,tty);
+  READ_STRING(fp, username);
+  READ_STRING(fp, service);
+  READ_STRING(fp, ruser);
+  READ_STRING(fp, rhost);
+  READ_STRING(fp, tty);
   /* log call */
-  log_setrequest("authz=\"%s\"",username);
-  log_log(LOG_DEBUG,"nslcd_pam_authz(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\")",
-            username,service,ruser,rhost,tty);
+  log_setrequest("authz=\"%s\"", username);
+  log_log(LOG_DEBUG, "nslcd_pam_authz(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\")",
+          username, service, ruser, rhost, tty);
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_PAM_AUTHZ);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_PAM_AUTHZ);
   /* validate request */
-  entry=validate_user(session,username,&rc);
-  if (entry==NULL)
+  entry = validate_user(session, username, &rc);
+  if (entry == NULL)
   {
     /* for user not found we just say no result */
-    if (rc==LDAP_NO_SUCH_OBJECT)
+    if (rc == LDAP_NO_SUCH_OBJECT)
     {
-      WRITE_INT32(fp,NSLCD_RESULT_END);
+      WRITE_INT32(fp, NSLCD_RESULT_END);
     }
     return -1;
   }
   /* check authorisation search */
-  
rc=try_autzsearch(session,myldap_get_dn(entry),username,service,ruser,rhost,tty);
-  if (rc!=LDAP_SUCCESS)
-  {
-    WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-    WRITE_INT32(fp,NSLCD_PAM_PERM_DENIED);
-    WRITE_STRING(fp,"LDAP authorisation check failed");
-    WRITE_INT32(fp,NSLCD_RESULT_END);
+  rc = try_autzsearch(session, myldap_get_dn(entry), username, service, ruser,
+                      rhost, tty);
+  if (rc != LDAP_SUCCESS)
+  {
+    WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+    WRITE_INT32(fp, NSLCD_PAM_PERM_DENIED);
+    WRITE_STRING(fp, "LDAP authorisation check failed");
+    WRITE_INT32(fp, NSLCD_RESULT_END);
     return 0;
   }
   /* perform shadow attribute checks */
-  rc=check_shadow(session,username,authzmsg,sizeof(authzmsg),0,0);
+  rc = check_shadow(session, username, authzmsg, sizeof(authzmsg), 0, 0);
   /* write response */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_INT32(fp,rc);
-  WRITE_STRING(fp,authzmsg);
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, rc);
+  WRITE_STRING(fp, authzmsg);
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }
 
-int nslcd_pam_sess_o(TFILE *fp,MYLDAP_SESSION *session)
+int nslcd_pam_sess_o(TFILE *fp, MYLDAP_SESSION *session)
 {
   int32_t tmpint32;
-  char username[256],service[64],ruser[256],rhost[HOST_NAME_MAX+1],tty[64];
+  char username[256], service[64], ruser[256], rhost[HOST_NAME_MAX + 1], 
tty[64];
   char sessionid[25];
-  static const char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                               "abcdefghijklmnopqrstuvwxyz"
-                               "01234567890";
+  static const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                 "abcdefghijklmnopqrstuvwxyz"
+                                 "01234567890";
   int i;
   /* read request parameters */
-  READ_STRING(fp,username);
-  READ_STRING(fp,service);
-  READ_STRING(fp,ruser);
-  READ_STRING(fp,rhost);
-  READ_STRING(fp,tty);
+  READ_STRING(fp, username);
+  READ_STRING(fp, service);
+  READ_STRING(fp, ruser);
+  READ_STRING(fp, rhost);
+  READ_STRING(fp, tty);
   /* generate pseudo-random session id */
-  for (i=0;i<(sizeof(sessionid)-1);i++)
-    sessionid[i]=alphabet[rand()%(sizeof(alphabet)-1)];
-  sessionid[i]='\0';
+  for (i = 0; i < (sizeof(sessionid) - 1); i++)
+    sessionid[i] = alphabet[rand() % (sizeof(alphabet) - 1)];
+  sessionid[i] = '\0';
   /* log call */
-  log_setrequest("sess_o=\"%s\"",username);
-  log_log(LOG_DEBUG,"nslcd_pam_sess_o(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"): %s",
-                    username,service,tty,rhost,ruser,sessionid);
+  log_setrequest("sess_o=\"%s\"", username);
+  log_log(LOG_DEBUG, "nslcd_pam_sess_o(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"): 
%s",
+          username, service, tty, rhost, ruser, sessionid);
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_PAM_SESS_O);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_PAM_SESS_O);
   /* write response */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_STRING(fp,sessionid);
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_STRING(fp, sessionid);
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }
 
-int nslcd_pam_sess_c(TFILE *fp,MYLDAP_SESSION *session)
+int nslcd_pam_sess_c(TFILE *fp, MYLDAP_SESSION *session)
 {
   int32_t tmpint32;
-  char username[256],service[64],ruser[256],rhost[HOST_NAME_MAX+1],tty[64];
+  char username[256], service[64], ruser[256], rhost[HOST_NAME_MAX + 1], 
tty[64];
   char sessionid[64];
   /* read request parameters */
-  READ_STRING(fp,username);
-  READ_STRING(fp,service);
-  READ_STRING(fp,ruser);
-  READ_STRING(fp,rhost);
-  READ_STRING(fp,tty);
-  READ_STRING(fp,sessionid);
+  READ_STRING(fp, username);
+  READ_STRING(fp, service);
+  READ_STRING(fp, ruser);
+  READ_STRING(fp, rhost);
+  READ_STRING(fp, tty);
+  READ_STRING(fp, sessionid);
   /* log call */
-  log_setrequest("sess_c=\"%s\"",username);
-  log_log(LOG_DEBUG,"nslcd_pam_sess_c(\"%s\",\"%s\",%s)",
-                    username,service,sessionid);
+  log_setrequest("sess_c=\"%s\"", username);
+  log_log(LOG_DEBUG, "nslcd_pam_sess_c(\"%s\",\"%s\",%s)",
+          username, service, sessionid);
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_PAM_SESS_C);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_PAM_SESS_C);
   /* write response */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }
 
 /* perform an LDAP password modification, returns an LDAP status code */
-static int try_pwmod(const char *binddn,const char *userdn,
-                     const char *oldpassword,const char *newpassword)
+static int try_pwmod(const char *binddn, const char *userdn,
+                     const char *oldpassword, const char *newpassword)
 {
   MYLDAP_SESSION *session;
   char buffer[256];
   int rc;
   /* set up a new connection */
-  session=myldap_create_session();
-  if (session==NULL)
+  session = myldap_create_session();
+  if (session == NULL)
     return LDAP_UNAVAILABLE;
   /* set up credentials for the session */
-  myldap_set_credentials(session,binddn,oldpassword);
+  myldap_set_credentials(session, binddn, oldpassword);
   /* perform search for own object (just to do any kind of search) */
-  if 
((lookup_dn2uid(session,userdn,&rc,buffer,sizeof(buffer))!=NULL)&&(rc==LDAP_SUCCESS))
+  if ((lookup_dn2uid(session, userdn, &rc, buffer, sizeof(buffer)) != NULL) &&
+      (rc == LDAP_SUCCESS))
   {
     /* if doing password modification as admin, don't pass old password along 
*/
-    if 
((nslcd_cfg->ldc_rootpwmoddn!=NULL)&&(strcmp(binddn,nslcd_cfg->ldc_rootpwmoddn)==0))
-      oldpassword=NULL;
+    if ((nslcd_cfg->ldc_rootpwmoddn != NULL) &&
+        (strcmp(binddn, nslcd_cfg->ldc_rootpwmoddn) == 0))
+      oldpassword = NULL;
     /* perform password modification */
-    rc=myldap_passwd(session,userdn,oldpassword,newpassword);
-    if (rc==LDAP_SUCCESS)
+    rc = myldap_passwd(session, userdn, oldpassword, newpassword);
+    if (rc == LDAP_SUCCESS)
     {
       /* try to update the shadowLastChange attribute */
-      (void)update_lastchange(session,userdn);
+      (void)update_lastchange(session, userdn);
     }
   }
   /* close the session */
@@ -599,101 +612,103 @@
   return rc;
 }
 
-int nslcd_pam_pwmod(TFILE *fp,MYLDAP_SESSION *session,uid_t calleruid)
+int nslcd_pam_pwmod(TFILE *fp, MYLDAP_SESSION *session, uid_t calleruid)
 {
   int32_t tmpint32;
   int rc;
-  char username[256],service[64],ruser[256],rhost[HOST_NAME_MAX+1],tty[64];
+  char username[256], service[64], ruser[256], rhost[HOST_NAME_MAX + 1], 
tty[64];
   int asroot;
   char oldpassword[64];
   char newpassword[64];
-  const char *binddn=NULL; /* the user performing the modification */
+  const char *binddn = NULL; /* the user performing the modification */
   MYLDAP_ENTRY *entry;
   char authzmsg[1024];
-  authzmsg[0]='\0';
+  authzmsg[0] = '\0';
   /* read request parameters */
-  READ_STRING(fp,username);
-  READ_STRING(fp,service);
-  READ_STRING(fp,ruser);
-  READ_STRING(fp,rhost);
-  READ_STRING(fp,tty);
-  READ_INT32(fp,asroot);
-  READ_STRING(fp,oldpassword);
-  READ_STRING(fp,newpassword);
+  READ_STRING(fp, username);
+  READ_STRING(fp, service);
+  READ_STRING(fp, ruser);
+  READ_STRING(fp, rhost);
+  READ_STRING(fp, tty);
+  READ_INT32(fp, asroot);
+  READ_STRING(fp, oldpassword);
+  READ_STRING(fp, newpassword);
   /* log call */
-  log_setrequest("pwmod=\"%s\"",username);
-  log_log(LOG_DEBUG,"nslcd_pam_pwmod(\"%s\",%s,\"%s\",\"%s\",\"%s\")",
-                    
username,asroot?"asroot":"asuser",service,*oldpassword?"***":"",
-                    *newpassword?"***":"");
+  log_setrequest("pwmod=\"%s\"", username);
+  log_log(LOG_DEBUG, "nslcd_pam_pwmod(\"%s\",%s,\"%s\",\"%s\",\"%s\")",
+          username, asroot ? "asroot" : "asuser", service,
+          *oldpassword ? "***" : "", *newpassword ? "***" : "");
   /* write the response header */
-  WRITE_INT32(fp,NSLCD_VERSION);
-  WRITE_INT32(fp,NSLCD_ACTION_PAM_PWMOD);
+  WRITE_INT32(fp, NSLCD_VERSION);
+  WRITE_INT32(fp, NSLCD_ACTION_PAM_PWMOD);
   /* validate request */
-  entry=validate_user(session,username,&rc);
-  if (entry==NULL)
+  entry = validate_user(session, username, &rc);
+  if (entry == NULL)
   {
     /* for user not found we just say no result */
-    if (rc==LDAP_NO_SUCH_OBJECT)
+    if (rc == LDAP_NO_SUCH_OBJECT)
     {
-      WRITE_INT32(fp,NSLCD_RESULT_END);
+      WRITE_INT32(fp, NSLCD_RESULT_END);
     }
     return -1;
   }
   /* check if pam_password_prohibit_message is set */
-  if (nslcd_cfg->pam_password_prohibit_message!=NULL)
+  if (nslcd_cfg->pam_password_prohibit_message != NULL)
   {
-    log_log(LOG_NOTICE,"password change prohibited");
-    WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-    WRITE_INT32(fp,NSLCD_PAM_PERM_DENIED);
-    WRITE_STRING(fp,nslcd_cfg->pam_password_prohibit_message);
-    WRITE_INT32(fp,NSLCD_RESULT_END);
+    log_log(LOG_NOTICE, "password change prohibited");
+    WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+    WRITE_INT32(fp, NSLCD_PAM_PERM_DENIED);
+    WRITE_STRING(fp, nslcd_cfg->pam_password_prohibit_message);
+    WRITE_INT32(fp, NSLCD_RESULT_END);
     return 0;
   }
   /* check if the the user passed the rootpwmoddn */
   if (asroot)
   {
-    binddn=nslcd_cfg->ldc_rootpwmoddn;
+    binddn = nslcd_cfg->ldc_rootpwmoddn;
     /* check if rootpwmodpw should be used */
-    if 
((*oldpassword=='\0')&&(calleruid==0)&&(nslcd_cfg->ldc_rootpwmodpw!=NULL))
+    if ((*oldpassword == '\0') && (calleruid == 0) &&
+        (nslcd_cfg->ldc_rootpwmodpw != NULL))
     {
-      if (strlen(nslcd_cfg->ldc_rootpwmodpw)>=sizeof(oldpassword))
+      if (strlen(nslcd_cfg->ldc_rootpwmodpw) >= sizeof(oldpassword))
       {
-        log_log(LOG_ERR,"nslcd_pam_pwmod(): rootpwmodpw will not fit in 
oldpassword");
+        log_log(LOG_ERR, "nslcd_pam_pwmod(): rootpwmodpw will not fit in 
oldpassword");
         return -1;
       }
-      strcpy(oldpassword,nslcd_cfg->ldc_rootpwmodpw);
+      strcpy(oldpassword, nslcd_cfg->ldc_rootpwmodpw);
     }
   }
   else
   {
-    binddn=myldap_get_dn(entry);
+    binddn = myldap_get_dn(entry);
     /* check whether shadow properties allow password change */
-    rc=check_shadow(session,username,authzmsg,sizeof(authzmsg),0,1);
-    if (rc!=NSLCD_PAM_SUCCESS)
+    rc = check_shadow(session, username, authzmsg, sizeof(authzmsg), 0, 1);
+    if (rc != NSLCD_PAM_SUCCESS)
     {
-      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-      WRITE_INT32(fp,rc);
-      WRITE_STRING(fp,authzmsg);
-      WRITE_INT32(fp,NSLCD_RESULT_END);
+      WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+      WRITE_INT32(fp, rc);
+      WRITE_STRING(fp, authzmsg);
+      WRITE_INT32(fp, NSLCD_RESULT_END);
       return 0;
     }
   }
   /* perform password modification */
-  rc=try_pwmod(binddn,myldap_get_dn(entry),oldpassword,newpassword);
-  if (rc!=LDAP_SUCCESS)
+  rc = try_pwmod(binddn, myldap_get_dn(entry), oldpassword, newpassword);
+  if (rc != LDAP_SUCCESS)
   {
-    mysnprintf(authzmsg,sizeof(authzmsg)-1,"password change failed: 
%s",ldap_err2string(rc));
-    WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-    WRITE_INT32(fp,NSLCD_PAM_PERM_DENIED);
-    WRITE_STRING(fp,authzmsg);
-    WRITE_INT32(fp,NSLCD_RESULT_END);
+    mysnprintf(authzmsg, sizeof(authzmsg) - 1, "password change failed: %s",
+               ldap_err2string(rc));
+    WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+    WRITE_INT32(fp, NSLCD_PAM_PERM_DENIED);
+    WRITE_STRING(fp, authzmsg);
+    WRITE_INT32(fp, NSLCD_RESULT_END);
     return 0;
   }
   /* write response */
-  log_log(LOG_NOTICE,"password changed for %s",myldap_get_dn(entry));
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_INT32(fp,NSLCD_PAM_SUCCESS);
-  WRITE_STRING(fp,"");
-  WRITE_INT32(fp,NSLCD_RESULT_END);
+  log_log(LOG_NOTICE, "password changed for %s", myldap_get_dn(entry));
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_INT32(fp, NSLCD_PAM_SUCCESS);
+  WRITE_STRING(fp, "");
+  WRITE_INT32(fp, NSLCD_RESULT_END);
   return 0;
 }

Modified: nss-pam-ldapd/nslcd/passwd.c
==============================================================================
--- nss-pam-ldapd/nslcd/passwd.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/passwd.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -66,11 +66,11 @@
 
 /* special properties for objectSid-based searches
    (these are already LDAP-escaped strings) */
-static char *uidSid=NULL;
-static char *gidSid=NULL;
+static char *uidSid = NULL;
+static char *gidSid = NULL;
 
 /* default values for attributes */
-static const char *default_passwd_userPassword     = "*"; /* unmatchable */
+static const char *default_passwd_userPassword = "*"; /* unmatchable */
 
 /* Note that the resulting password value should be one of:
    <empty> - no password set, allow login without password
@@ -80,44 +80,37 @@
    other   - encrypted password, usually in crypt(3) format */
 
 /* the attribute list to request with searches */
-static const char **passwd_attrs=NULL;
+static const char **passwd_attrs = NULL;
 
 /* create a search filter for searching a passwd entry
    by name, return -1 on errors */
 static int mkfilter_passwd_byname(const char *name,
-                                  char *buffer,size_t buflen)
+                                  char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if(myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    passwd_filter,
-                    attmap_passwd_uid,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    passwd_filter, attmap_passwd_uid, safename);
 }
 
 /* create a search filter for searching a passwd entry
    by uid, return -1 on errors */
-static int mkfilter_passwd_byuid(uid_t uid,
-                                 char *buffer,size_t buflen)
+static int mkfilter_passwd_byuid(uid_t uid, char *buffer, size_t buflen)
 {
-  if (uidSid!=NULL)
+  if (uidSid != NULL)
   {
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%s\\%02x\\%02x\\%02x\\%02x))",
-                      passwd_filter,
-                      attmap_passwd_uidNumber,uidSid,
-                      (int)(uid&0xff),(int)((uid>>8)&0xff),
-                      (int)((uid>>16)&0xff),(int)((uid>>24)&0xff));
+    return mysnprintf(buffer, buflen, "(&%s(%s=%s\\%02x\\%02x\\%02x\\%02x))",
+                      passwd_filter, attmap_passwd_uidNumber, uidSid,
+                      (int)(uid & 0xff), (int)((uid >> 8) & 0xff),
+                      (int)((uid >> 16) & 0xff), (int)((uid >> 24) & 0xff));
   }
   else
   {
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%d))",
-                      passwd_filter,
-                      attmap_passwd_uidNumber,(int)uid);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%d))",
+                      passwd_filter, attmap_passwd_uidNumber, (int)uid);
   }
 }
 
@@ -126,46 +119,45 @@
   int i;
   SET *set;
   /* set up search bases */
-  if (passwd_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      passwd_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (passwd_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      passwd_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (passwd_scope==LDAP_SCOPE_DEFAULT)
-    passwd_scope=nslcd_cfg->ldc_scope;
+  if (passwd_scope == LDAP_SCOPE_DEFAULT)
+    passwd_scope = nslcd_cfg->ldc_scope;
   /* special case when uidNumber or gidNumber reference objectSid */
-  if (strncasecmp(attmap_passwd_uidNumber,"objectSid:",10)==0)
+  if (strncasecmp(attmap_passwd_uidNumber, "objectSid:", 10) == 0)
   {
-    uidSid=sid2search(attmap_passwd_uidNumber+10);
-    attmap_passwd_uidNumber=strndup(attmap_passwd_uidNumber,9);
+    uidSid = sid2search(attmap_passwd_uidNumber + 10);
+    attmap_passwd_uidNumber = strndup(attmap_passwd_uidNumber, 9);
   }
-  if (strncasecmp(attmap_passwd_gidNumber,"objectSid:",10)==0)
+  if (strncasecmp(attmap_passwd_gidNumber, "objectSid:", 10) == 0)
   {
-    gidSid=sid2search(attmap_passwd_gidNumber+10);
-    attmap_passwd_gidNumber=strndup(attmap_passwd_gidNumber,9);
+    gidSid = sid2search(attmap_passwd_gidNumber + 10);
+    attmap_passwd_gidNumber = strndup(attmap_passwd_gidNumber, 9);
   }
   /* set up attribute list */
-  set=set_new();
-  attmap_add_attributes(set,"objectClass"); /* for testing shadowAccount */
-  attmap_add_attributes(set,attmap_passwd_uid);
-  attmap_add_attributes(set,attmap_passwd_userPassword);
-  attmap_add_attributes(set,attmap_passwd_uidNumber);
-  attmap_add_attributes(set,attmap_passwd_gidNumber);
-  attmap_add_attributes(set,attmap_passwd_gecos);
-  attmap_add_attributes(set,attmap_passwd_homeDirectory);
-  attmap_add_attributes(set,attmap_passwd_loginShell);
-  passwd_attrs=set_tolist(set);
+  set = set_new();
+  attmap_add_attributes(set, "objectClass"); /* for testing shadowAccount */
+  attmap_add_attributes(set, attmap_passwd_uid);
+  attmap_add_attributes(set, attmap_passwd_userPassword);
+  attmap_add_attributes(set, attmap_passwd_uidNumber);
+  attmap_add_attributes(set, attmap_passwd_gidNumber);
+  attmap_add_attributes(set, attmap_passwd_gecos);
+  attmap_add_attributes(set, attmap_passwd_homeDirectory);
+  attmap_add_attributes(set, attmap_passwd_loginShell);
+  passwd_attrs = set_tolist(set);
   set_free(set);
 }
 
 /* the cache that is used in dn2uid() */
-static pthread_mutex_t dn2uid_cache_mutex=PTHREAD_MUTEX_INITIALIZER;
-static DICT *dn2uid_cache=NULL;
-struct dn2uid_cache_entry
-{
+static pthread_mutex_t dn2uid_cache_mutex = PTHREAD_MUTEX_INITIALIZER;
+static DICT *dn2uid_cache = NULL;
+struct dn2uid_cache_entry {
   time_t timestamp;
   char *uid;
 };
-#define DN2UID_CACHE_TIMEOUT (15*60)
+#define DN2UID_CACHE_TIMEOUT (15 * 60)
 
 /* checks whether the entry has a valid uidNumber attribute
    (>= nss_min_uid) */
@@ -176,39 +168,39 @@
   char *tmp;
   uid_t uid;
   /* if min_uid is not set any entry should do */
-  if (nslcd_cfg->ldc_nss_min_uid==0)
+  if (nslcd_cfg->ldc_nss_min_uid == 0)
     return 1;
   /* get all uidNumber attributes */
-  values=myldap_get_values_len(entry,attmap_passwd_uidNumber);
-  if ((values==NULL)||(values[0]==NULL))
+  values = myldap_get_values_len(entry, attmap_passwd_uidNumber);
+  if ((values == NULL) || (values[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_passwd_uidNumber);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_passwd_uidNumber);
     return 0;
   }
   /* check if there is a uidNumber attributes >= min_uid */
-  for (i=0;values[i]!=NULL;i++)
+  for (i = 0; values[i] != NULL; i++)
   {
-    if (uidSid!=NULL)
-      uid=(uid_t)binsid2id(values[i]);
+    if (uidSid != NULL)
+      uid = (uid_t)binsid2id(values[i]);
     else
     {
-      errno=0;
-      uid=strtouid(values[i],&tmp,10);
-      if ((*(values[i])=='\0')||(*tmp!='\0'))
+      errno = 0;
+      uid = strtouid(values[i], &tmp, 10);
+      if ((*(values[i]) == '\0') || (*tmp != '\0'))
       {
-        log_log(LOG_WARNING,"%s: %s: non-numeric",
-                            myldap_get_dn(entry),attmap_passwd_uidNumber);
+        log_log(LOG_WARNING, "%s: %s: non-numeric",
+                myldap_get_dn(entry), attmap_passwd_uidNumber);
         continue;
       }
-      else if ((errno!=0)||(strchr(values[i],'-')!=NULL))
+      else if ((errno != 0) || (strchr(values[i], '-') != NULL))
       {
-        log_log(LOG_WARNING,"%s: %s: out of range",
-                            myldap_get_dn(entry),attmap_passwd_uidNumber);
+        log_log(LOG_WARNING, "%s: %s: out of range",
+                myldap_get_dn(entry), attmap_passwd_uidNumber);
         continue;
       }
     }
-    if (uid>=nslcd_cfg->ldc_nss_min_uid)
+    if (uid >= nslcd_cfg->ldc_nss_min_uid)
       return 1;
   }
   /* nothing found */
@@ -217,43 +209,45 @@
 
 /* Perform an LDAP lookup to translate the DN into a uid.
    This function either returns NULL or a strdup()ed string. */
-char *lookup_dn2uid(MYLDAP_SESSION *session,const char *dn,int *rcp,char 
*buf,size_t buflen)
+char *lookup_dn2uid(MYLDAP_SESSION *session, const char *dn, int *rcp,
+                    char *buf, size_t buflen)
 {
   MYLDAP_SEARCH *search;
   MYLDAP_ENTRY *entry;
   static const char *attrs[3];
-  int rc=LDAP_SUCCESS;
+  int rc = LDAP_SUCCESS;
   const char **values;
-  char *uid=NULL;
-  if (rcp==NULL)
-    rcp=&rc;
+  char *uid = NULL;
+  if (rcp == NULL)
+    rcp = &rc;
   /* we have to look up the entry */
-  attrs[0]=attmap_passwd_uid;
-  attrs[1]=attmap_passwd_uidNumber;
-  attrs[2]=NULL;
-  search=myldap_search(session,dn,LDAP_SCOPE_BASE,passwd_filter,attrs,rcp);
-  if (search==NULL)
+  attrs[0] = attmap_passwd_uid;
+  attrs[1] = attmap_passwd_uidNumber;
+  attrs[2] = NULL;
+  search = myldap_search(session, dn, LDAP_SCOPE_BASE, passwd_filter, attrs, 
rcp);
+  if (search == NULL)
   {
-    log_log(LOG_WARNING,"%s: lookup error: %s",dn,ldap_err2string(*rcp));
+    log_log(LOG_WARNING, "%s: lookup error: %s", dn, ldap_err2string(*rcp));
     return NULL;
   }
-  entry=myldap_get_entry(search,rcp);
-  if (entry==NULL)
+  entry = myldap_get_entry(search, rcp);
+  if (entry == NULL)
   {
-    if (*rcp!=LDAP_SUCCESS)
-      log_log(LOG_WARNING,"%s: lookup error: %s",dn,ldap_err2string(*rcp));
+    if (*rcp != LDAP_SUCCESS)
+      log_log(LOG_WARNING, "%s: lookup error: %s", dn, ldap_err2string(*rcp));
     return NULL;
   }
   /* check the uidNumber attribute if min_uid is set */
   if (entry_has_valid_uid(entry))
   {
     /* get uid (just use first one) */
-    values=myldap_get_values(entry,attmap_passwd_uid);
+    values = myldap_get_values(entry, attmap_passwd_uid);
     /* check the result for presence and validity */
-    if 
((values!=NULL)&&(values[0]!=NULL)&&isvalidname(values[0])&&(strlen(values[0])<buflen))
+    if ((values != NULL) && (values[0] != NULL) &&
+        isvalidname(values[0]) && (strlen(values[0]) < buflen))
     {
-      strcpy(buf,values[0]);
-      uid=buf;
+      strcpy(buf, values[0]);
+      uid = buf;
     }
   }
   /* clean up and return */
@@ -265,15 +259,15 @@
    at getting the user name, including looking in the DN for a uid attribute,
    looking in the cache and falling back to looking up a uid attribute in a
    LDAP query. */
-char *dn2uid(MYLDAP_SESSION *session,const char *dn,char *buf,size_t buflen)
+char *dn2uid(MYLDAP_SESSION *session, const char *dn, char *buf, size_t buflen)
 {
-  struct dn2uid_cache_entry *cacheentry=NULL;
+  struct dn2uid_cache_entry *cacheentry = NULL;
   char *uid;
   /* check for empty string */
-  if ((dn==NULL)||(*dn=='\0'))
+  if ((dn == NULL) || (*dn == '\0'))
     return NULL;
   /* try to look up uid within DN string */
-  if (myldap_cpy_rdn_value(dn,attmap_passwd_uid,buf,buflen)!=NULL)
+  if (myldap_cpy_rdn_value(dn, attmap_passwd_uid, buf, buflen) != NULL)
   {
     /* check if it is valid */
     if (!isvalidname(buf))
@@ -282,17 +276,17 @@
   }
   /* see if we have a cached entry */
   pthread_mutex_lock(&dn2uid_cache_mutex);
-  if (dn2uid_cache==NULL)
-    dn2uid_cache=dict_new();
-  if ((dn2uid_cache!=NULL) && ((cacheentry=dict_get(dn2uid_cache,dn))!=NULL))
+  if (dn2uid_cache == NULL)
+    dn2uid_cache = dict_new();
+  if ((dn2uid_cache != NULL) && ((cacheentry = dict_get(dn2uid_cache, dn)) != 
NULL))
   {
     /* if the cached entry is still valid, return that */
-    if (time(NULL) < (cacheentry->timestamp+DN2UID_CACHE_TIMEOUT))
+    if (time(NULL) < (cacheentry->timestamp + DN2UID_CACHE_TIMEOUT))
     {
-      if ((cacheentry->uid!=NULL)&&(strlen(cacheentry->uid)<buflen))
-        strcpy(buf,cacheentry->uid);
+      if ((cacheentry->uid != NULL) && (strlen(cacheentry->uid) < buflen))
+        strcpy(buf, cacheentry->uid);
       else
-        buf=NULL;
+        buf = NULL;
       pthread_mutex_unlock(&dn2uid_cache_mutex);
       return buf;
     }
@@ -300,33 +294,33 @@
   }
   pthread_mutex_unlock(&dn2uid_cache_mutex);
   /* look up the uid using an LDAP query */
-  uid=lookup_dn2uid(session,dn,NULL,buf,buflen);
+  uid = lookup_dn2uid(session, dn, NULL, buf, buflen);
   /* store the result in the cache */
   pthread_mutex_lock(&dn2uid_cache_mutex);
   /* try to get the entry from the cache here again because it could have
      changed in the meantime */
-  cacheentry=dict_get(dn2uid_cache,dn);
-  if (cacheentry==NULL)
+  cacheentry = dict_get(dn2uid_cache, dn);
+  if (cacheentry == NULL)
   {
     /* allocate a new entry in the cache */
-    cacheentry=(struct dn2uid_cache_entry *)malloc(sizeof(struct 
dn2uid_cache_entry));
-    if (cacheentry!=NULL)
+    cacheentry = (struct dn2uid_cache_entry *)malloc(sizeof(struct 
dn2uid_cache_entry));
+    if (cacheentry != NULL)
     {
-      cacheentry->uid=NULL;
-      dict_put(dn2uid_cache,dn,cacheentry);
+      cacheentry->uid = NULL;
+      dict_put(dn2uid_cache, dn, cacheentry);
     }
   }
   /* update the cache entry */
-  if (cacheentry!=NULL)
+  if (cacheentry != NULL)
   {
-    cacheentry->timestamp=time(NULL);
+    cacheentry->timestamp = time(NULL);
     /* copy the uid if needed */
-    if (cacheentry->uid==NULL)
-      cacheentry->uid=uid!=NULL?strdup(uid):NULL;
-    else if ((uid==NULL)||(strcmp(cacheentry->uid,uid)!=0))
+    if (cacheentry->uid == NULL)
+      cacheentry->uid = uid != NULL ? strdup(uid) : NULL;
+    else if ((uid == NULL) || (strcmp(cacheentry->uid, uid) != 0))
     {
       free(cacheentry->uid);
-      cacheentry->uid=uid!=NULL?strdup(uid):NULL;
+      cacheentry->uid = uid != NULL ? strdup(uid) : NULL;
     }
   }
   pthread_mutex_unlock(&dn2uid_cache_mutex);
@@ -334,10 +328,10 @@
   return uid;
 }
 
-MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session,const char *uid,int *rcp)
+MYLDAP_ENTRY *uid2entry(MYLDAP_SESSION *session, const char *uid, int *rcp)
 {
-  MYLDAP_SEARCH *search=NULL;
-  MYLDAP_ENTRY *entry=NULL;
+  MYLDAP_SEARCH *search = NULL;
+  MYLDAP_ENTRY *entry = NULL;
   const char *base;
   int i;
   static const char *attrs[3];
@@ -345,43 +339,43 @@
   /* if it isn't a valid username, just bail out now */
   if (!isvalidname(uid))
   {
-    if (rcp!=NULL)
-      *rcp=LDAP_INVALID_SYNTAX;
+    if (rcp != NULL)
+      *rcp = LDAP_INVALID_SYNTAX;
     return NULL;
   }
   /* set up attributes (we don't need much) */
-  attrs[0]=attmap_passwd_uid;
-  attrs[1]=attmap_passwd_uidNumber;
-  attrs[2]=NULL;
+  attrs[0] = attmap_passwd_uid;
+  attrs[1] = attmap_passwd_uidNumber;
+  attrs[2] = NULL;
   /* we have to look up the entry */
-  mkfilter_passwd_byname(uid,filter,sizeof(filter));
-  for (i=0;(i<NSS_LDAP_CONFIG_MAX_BASES)&&((base=passwd_bases[i])!=NULL);i++)
+  mkfilter_passwd_byname(uid, filter, sizeof(filter));
+  for (i = 0; (i < NSS_LDAP_CONFIG_MAX_BASES) && ((base = passwd_bases[i]) != 
NULL); i++)
   {
-    search=myldap_search(session,base,passwd_scope,filter,attrs,rcp);
-    if (search==NULL)
+    search = myldap_search(session, base, passwd_scope, filter, attrs, rcp);
+    if (search == NULL)
     {
-      if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS))
-        *rcp=LDAP_NO_SUCH_OBJECT;
+      if ((rcp != NULL) && (*rcp == LDAP_SUCCESS))
+        *rcp = LDAP_NO_SUCH_OBJECT;
       return NULL;
     }
-    entry=myldap_get_entry(search,rcp);
-    if ((entry!=NULL)&&(entry_has_valid_uid(entry)))
+    entry = myldap_get_entry(search, rcp);
+    if ((entry != NULL) && (entry_has_valid_uid(entry)))
       return entry;
   }
-  if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS))
-    *rcp=LDAP_NO_SUCH_OBJECT;
+  if ((rcp != NULL) && (*rcp == LDAP_SUCCESS))
+    *rcp = LDAP_NO_SUCH_OBJECT;
   return NULL;
 }
 
-char *uid2dn(MYLDAP_SESSION *session,const char *uid,char *buf,size_t buflen)
+char *uid2dn(MYLDAP_SESSION *session, const char *uid, char *buf, size_t 
buflen)
 {
   MYLDAP_ENTRY *entry;
   /* look up the entry */
-  entry=uid2entry(session,uid,NULL);
-  if (entry==NULL)
+  entry = uid2entry(session, uid, NULL);
+  if (entry == NULL)
     return NULL;
   /* get DN */
-  return myldap_cpy_dn(entry,buf,buflen);
+  return myldap_cpy_dn(entry, buf, buflen);
 }
 
 #ifndef NSS_FLAVOUR_GLIBC
@@ -393,8 +387,8 @@
 /* the maximum number of uidNumber attributes per entry */
 #define MAXUIDS_PER_ENTRY 5
 
-static int write_passwd(TFILE *fp,MYLDAP_ENTRY *entry,const char *requser,
-                        const uid_t *requid,uid_t calleruid)
+static int write_passwd(TFILE *fp, MYLDAP_ENTRY *entry, const char *requser,
+                        const uid_t *requid, uid_t calleruid)
 {
   int32_t tmpint32;
   const char **tmpvalues;
@@ -409,133 +403,134 @@
   char homedir[256];
   char shell[64];
   char passbuffer[64];
-  int i,j;
+  int i, j;
   /* get the usernames for this entry */
-  usernames=myldap_get_values(entry,attmap_passwd_uid);
-  if ((usernames==NULL)||(usernames[0]==NULL))
+  usernames = myldap_get_values(entry, attmap_passwd_uid);
+  if ((usernames == NULL) || (usernames[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_passwd_uid);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_passwd_uid);
     return 0;
   }
   /* if we are using shadow maps and this entry looks like it would return
      shadow information, make the passwd entry indicate it */
-  if 
(myldap_has_objectclass(entry,"shadowAccount")&&nsswitch_shadow_uses_ldap())
+  if (myldap_has_objectclass(entry, "shadowAccount") && 
nsswitch_shadow_uses_ldap())
   {
-    passwd="x";
+    passwd = "x";
   }
   else
   {
-    
passwd=get_userpassword(entry,attmap_passwd_userPassword,passbuffer,sizeof(passbuffer));
-    if ((passwd==NULL)||(calleruid!=0))
-      passwd=default_passwd_userPassword;
+    passwd = get_userpassword(entry, attmap_passwd_userPassword,
+                              passbuffer, sizeof(passbuffer));
+    if ((passwd == NULL) || (calleruid != 0))
+      passwd = default_passwd_userPassword;
   }
   /* get the uids for this entry */
-  if (requid!=NULL)
+  if (requid != NULL)
   {
-    uids[0]=*requid;
-    numuids=1;
+    uids[0] = *requid;
+    numuids = 1;
   }
   else
   {
-    tmpvalues=myldap_get_values_len(entry,attmap_passwd_uidNumber);
-    if ((tmpvalues==NULL)||(tmpvalues[0]==NULL))
+    tmpvalues = myldap_get_values_len(entry, attmap_passwd_uidNumber);
+    if ((tmpvalues == NULL) || (tmpvalues[0] == NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_passwd_uidNumber);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_passwd_uidNumber);
       return 0;
     }
-    for 
(numuids=0;(numuids<MAXUIDS_PER_ENTRY)&&(tmpvalues[numuids]!=NULL);numuids++)
+    for (numuids = 0; (numuids < MAXUIDS_PER_ENTRY) && (tmpvalues[numuids] != 
NULL); numuids++)
     {
-      if (uidSid!=NULL)
-        uids[numuids]=(uid_t)binsid2id(tmpvalues[numuids]);
+      if (uidSid != NULL)
+        uids[numuids] = (uid_t)binsid2id(tmpvalues[numuids]);
       else
       {
-        errno=0;
-        uids[numuids]=strtouid(tmpvalues[numuids],&tmp,10);
-        if ((*(tmpvalues[numuids])=='\0')||(*tmp!='\0'))
+        errno = 0;
+        uids[numuids] = strtouid(tmpvalues[numuids], &tmp, 10);
+        if ((*(tmpvalues[numuids]) == '\0') || (*tmp != '\0'))
         {
-          log_log(LOG_WARNING,"%s: %s: non-numeric",
-                              myldap_get_dn(entry),attmap_passwd_uidNumber);
+          log_log(LOG_WARNING, "%s: %s: non-numeric",
+                  myldap_get_dn(entry), attmap_passwd_uidNumber);
           return 0;
         }
-        else if ((errno!=0)||(strchr(tmpvalues[numuids],'-')!=NULL))
+        else if ((errno != 0) || (strchr(tmpvalues[numuids], '-') != NULL))
         {
-          log_log(LOG_WARNING,"%s: %s: out of range",
-                              myldap_get_dn(entry),attmap_passwd_uidNumber);
+          log_log(LOG_WARNING, "%s: %s: out of range",
+                  myldap_get_dn(entry), attmap_passwd_uidNumber);
           return 0;
         }
       }
     }
   }
   /* get the gid for this entry */
-  if (gidSid!=NULL)
+  if (gidSid != NULL)
   {
-    tmpvalues=myldap_get_values_len(entry,attmap_passwd_gidNumber);
-    if ((tmpvalues==NULL)||(tmpvalues[0]==NULL))
+    tmpvalues = myldap_get_values_len(entry, attmap_passwd_gidNumber);
+    if ((tmpvalues == NULL) || (tmpvalues[0] == NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_passwd_gidNumber);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_passwd_gidNumber);
       return 0;
     }
-    gid=(gid_t)binsid2id(tmpvalues[0]);
+    gid = (gid_t)binsid2id(tmpvalues[0]);
   }
   else
   {
-    attmap_get_value(entry,attmap_passwd_gidNumber,gidbuf,sizeof(gidbuf));
-    if (gidbuf[0]=='\0')
+    attmap_get_value(entry, attmap_passwd_gidNumber, gidbuf, sizeof(gidbuf));
+    if (gidbuf[0] == '\0')
     {
-      log_log(LOG_WARNING,"%s: %s: missing",
-                          myldap_get_dn(entry),attmap_passwd_gidNumber);
+      log_log(LOG_WARNING, "%s: %s: missing",
+              myldap_get_dn(entry), attmap_passwd_gidNumber);
       return 0;
     }
-    errno=0;
-    gid=strtogid(gidbuf,&tmp,10);
-    if ((gidbuf[0]=='\0')||(*tmp!='\0'))
+    errno = 0;
+    gid = strtogid(gidbuf, &tmp, 10);
+    if ((gidbuf[0] == '\0') || (*tmp != '\0'))
     {
-      log_log(LOG_WARNING,"%s: %s: non-numeric",
-                          myldap_get_dn(entry),attmap_passwd_gidNumber);
+      log_log(LOG_WARNING, "%s: %s: non-numeric",
+              myldap_get_dn(entry), attmap_passwd_gidNumber);
       return 0;
     }
-    else if ((errno!=0)||(strchr(gidbuf,'-')!=NULL))
+    else if ((errno != 0) || (strchr(gidbuf, '-') != NULL))
     {
-      log_log(LOG_WARNING,"%s: %s: out of range",
-                          myldap_get_dn(entry),attmap_passwd_gidNumber);
+      log_log(LOG_WARNING, "%s: %s: out of range",
+              myldap_get_dn(entry), attmap_passwd_gidNumber);
       return 0;
     }
   }
   /* get the gecos for this entry */
-  attmap_get_value(entry,attmap_passwd_gecos,gecos,sizeof(gecos));
+  attmap_get_value(entry, attmap_passwd_gecos, gecos, sizeof(gecos));
   /* get the home directory for this entry */
-  attmap_get_value(entry,attmap_passwd_homeDirectory,homedir,sizeof(homedir));
-  if (homedir[0]=='\0')
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_passwd_homeDirectory);
+  attmap_get_value(entry, attmap_passwd_homeDirectory, homedir, 
sizeof(homedir));
+  if (homedir[0] == '\0')
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_passwd_homeDirectory);
   /* get the shell for this entry */
-  attmap_get_value(entry,attmap_passwd_loginShell,shell,sizeof(shell));
+  attmap_get_value(entry, attmap_passwd_loginShell, shell, sizeof(shell));
   /* write the entries */
-  for (i=0;usernames[i]!=NULL;i++)
-    if ((requser==NULL)||(STR_CMP(requser,usernames[i])==0))
+  for (i = 0; usernames[i] != NULL; i++)
+    if ((requser == NULL) || (STR_CMP(requser, usernames[i]) == 0))
     {
       if (!isvalidname(usernames[i]))
       {
-        log_log(LOG_WARNING,"%s: %s: denied by validnames option",
-                            myldap_get_dn(entry),attmap_passwd_uid);
+        log_log(LOG_WARNING, "%s: %s: denied by validnames option",
+                myldap_get_dn(entry), attmap_passwd_uid);
       }
       else
       {
-        for (j=0;j<numuids;j++)
+        for (j = 0; j < numuids; j++)
         {
-          if (uids[j]>=nslcd_cfg->ldc_nss_min_uid)
+          if (uids[j] >= nslcd_cfg->ldc_nss_min_uid)
           {
-            WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-            WRITE_STRING(fp,usernames[i]);
-            WRITE_STRING(fp,passwd);
-            WRITE_INT32(fp,uids[j]);
-            WRITE_INT32(fp,gid);
-            WRITE_STRING(fp,gecos);
-            WRITE_STRING(fp,homedir);
-            WRITE_STRING(fp,shell);
+            WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+            WRITE_STRING(fp, usernames[i]);
+            WRITE_STRING(fp, passwd);
+            WRITE_INT32(fp, uids[j]);
+            WRITE_INT32(fp, gid);
+            WRITE_STRING(fp, gecos);
+            WRITE_STRING(fp, homedir);
+            WRITE_STRING(fp, shell);
           }
         }
       }
@@ -544,47 +539,48 @@
 }
 
 NSLCD_HANDLE_UID(
-  passwd,byname,
+  passwd, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("passwd=\"%s\"",name);
-  if (!isvalidname(name)) {
-    log_log(LOG_WARNING,"request denied by validnames option");
+  READ_STRING(fp, name);
+  log_setrequest("passwd=\"%s\"", name);
+  if (!isvalidname(name))
+  {
+    log_log(LOG_WARNING, "request denied by validnames option");
     return -1;
   }
   nsswitch_check_reload();,
   NSLCD_ACTION_PASSWD_BYNAME,
-  mkfilter_passwd_byname(name,filter,sizeof(filter)),
-  write_passwd(fp,entry,name,NULL,calleruid)
+  mkfilter_passwd_byname(name, filter, sizeof(filter)),
+  write_passwd(fp, entry, name, NULL, calleruid)
 )
 
 NSLCD_HANDLE_UID(
-  passwd,byuid,
+  passwd, byuid,
   uid_t uid;
   char filter[4096];
-  READ_INT32(fp,uid);
-  log_setrequest("passwd=%lu",(unsigned long int)uid);
-  if (uid<nslcd_cfg->ldc_nss_min_uid)
+  READ_INT32(fp, uid);
+  log_setrequest("passwd=%lu", (unsigned long int)uid);
+  if (uid < nslcd_cfg->ldc_nss_min_uid)
   {
     /* return an empty result */
-    WRITE_INT32(fp,NSLCD_VERSION);
-    WRITE_INT32(fp,NSLCD_ACTION_PASSWD_BYUID);
-    WRITE_INT32(fp,NSLCD_RESULT_END);
+    WRITE_INT32(fp, NSLCD_VERSION);
+    WRITE_INT32(fp, NSLCD_ACTION_PASSWD_BYUID);
+    WRITE_INT32(fp, NSLCD_RESULT_END);
     return 0;
   }
   nsswitch_check_reload();,
   NSLCD_ACTION_PASSWD_BYUID,
-  mkfilter_passwd_byuid(uid,filter,sizeof(filter)),
-  write_passwd(fp,entry,NULL,&uid,calleruid)
+  mkfilter_passwd_byuid(uid, filter, sizeof(filter)),
+  write_passwd(fp, entry, NULL, &uid, calleruid)
 )
 
 NSLCD_HANDLE_UID(
-  passwd,all,
+  passwd, all,
   const char *filter;
   log_setrequest("passwd(all)");
   nsswitch_check_reload();,
   NSLCD_ACTION_PASSWD_ALL,
-  (filter=passwd_filter,0),
-  write_passwd(fp,entry,NULL,NULL,calleruid)
+  (filter = passwd_filter, 0),
+  write_passwd(fp, entry, NULL, NULL, calleruid)
 )

Modified: nss-pam-ldapd/nslcd/protocol.c
==============================================================================
--- nss-pam-ldapd/nslcd/protocol.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/protocol.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -63,49 +63,45 @@
 static const char *protocol_attrs[3];
 
 static int mkfilter_protocol_byname(const char *name,
-                                    char *buffer,size_t buflen)
+                                    char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    protocol_filter,
-                    attmap_protocol_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    protocol_filter, attmap_protocol_cn, safename);
 }
 
 /* create a search filter for searching a protocol entry
    by uid, return -1 on errors */
 static int mkfilter_protocol_bynumber(int protocol,
-                                      char *buffer,size_t buflen)
+                                      char *buffer, size_t buflen)
 {
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%d))",
-                    protocol_filter,
-                    attmap_protocol_ipProtocolNumber,protocol);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%d))",
+                    protocol_filter, attmap_protocol_ipProtocolNumber, 
protocol);
 }
 
 void protocol_init(void)
 {
   int i;
   /* set up search bases */
-  if (protocol_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      protocol_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (protocol_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      protocol_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (protocol_scope==LDAP_SCOPE_DEFAULT)
-    protocol_scope=nslcd_cfg->ldc_scope;
+  if (protocol_scope == LDAP_SCOPE_DEFAULT)
+    protocol_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  protocol_attrs[0]=attmap_protocol_cn;
-  protocol_attrs[1]=attmap_protocol_ipProtocolNumber;
-  protocol_attrs[2]=NULL;
+  protocol_attrs[0] = attmap_protocol_cn;
+  protocol_attrs[1] = attmap_protocol_ipProtocolNumber;
+  protocol_attrs[2] = NULL;
 }
 
-static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname)
+static int write_protocol(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqname)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   const char *name;
   const char **aliases;
   const char **protos;
@@ -113,89 +109,89 @@
   long proto;
   int i;
   /* get the most canonical name */
-  name=myldap_get_rdn_value(entry,attmap_protocol_cn);
+  name = myldap_get_rdn_value(entry, attmap_protocol_cn);
   /* get the other names for the protocol */
-  aliases=myldap_get_values(entry,attmap_protocol_cn);
-  if ((aliases==NULL)||(aliases[0]==NULL))
+  aliases = myldap_get_values(entry, attmap_protocol_cn);
+  if ((aliases == NULL) || (aliases[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_protocol_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_protocol_cn);
     return 0;
   }
   /* if the protocol name is not yet found, get the first entry */
-  if (name==NULL)
-    name=aliases[0];
+  if (name == NULL)
+    name = aliases[0];
   /* check case of returned protocol entry */
-  if ((reqname!=NULL)&&(STR_CMP(reqname,name)!=0))
+  if ((reqname != NULL) && (STR_CMP(reqname, name) != 0))
   {
-    for (i=0;(aliases[i]!=NULL)&&(STR_CMP(reqname,aliases[i])!=0);i++)
-      /* nothing here */ ;
-    if (aliases[i]==NULL)
+    for (i = 0; (aliases[i] != NULL) && (STR_CMP(reqname, aliases[i]) != 0); 
i++)
+      /* nothing */ ;
+    if (aliases[i] == NULL)
       return 0; /* neither the name nor any of the aliases matched */
   }
   /* get the protocol number */
-  protos=myldap_get_values(entry,attmap_protocol_ipProtocolNumber);
-  if ((protos==NULL)||(protos[0]==NULL))
+  protos = myldap_get_values(entry, attmap_protocol_ipProtocolNumber);
+  if ((protos == NULL) || (protos[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_protocol_ipProtocolNumber);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_protocol_ipProtocolNumber);
     return 0;
   }
-  else if (protos[1]!=NULL)
+  else if (protos[1] != NULL)
   {
-    log_log(LOG_WARNING,"%s: %s: multiple values",
-                        myldap_get_dn(entry),attmap_protocol_ipProtocolNumber);
+    log_log(LOG_WARNING, "%s: %s: multiple values",
+            myldap_get_dn(entry), attmap_protocol_ipProtocolNumber);
   }
-  errno=0;
-  proto=strtol(protos[0],&tmp,10);
-  if ((*(protos[0])=='\0')||(*tmp!='\0'))
+  errno = 0;
+  proto = strtol(protos[0], &tmp, 10);
+  if ((*(protos[0]) == '\0') || (*tmp != '\0'))
   {
-    log_log(LOG_WARNING,"%s: %s: non-numeric",
-                        myldap_get_dn(entry),attmap_protocol_ipProtocolNumber);
+    log_log(LOG_WARNING, "%s: %s: non-numeric",
+            myldap_get_dn(entry), attmap_protocol_ipProtocolNumber);
     return 0;
   }
-  else if ((errno!=0)||(proto<0)||(proto>UINT8_MAX))
+  else if ((errno != 0) || (proto < 0) || (proto > UINT8_MAX))
   {
-    log_log(LOG_WARNING,"%s: %s: out of range",
-                        myldap_get_dn(entry),attmap_protocol_ipProtocolNumber);
+    log_log(LOG_WARNING, "%s: %s: out of range",
+            myldap_get_dn(entry), attmap_protocol_ipProtocolNumber);
     return 0;
   }
   /* write entry */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_STRING(fp,name);
-  WRITE_STRINGLIST_EXCEPT(fp,aliases,name);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_STRING(fp, name);
+  WRITE_STRINGLIST_EXCEPT(fp, aliases, name);
   /* proto number is actually an 8-bit value but we write 32 bits anyway */
-  WRITE_INT32(fp,proto);
+  WRITE_INT32(fp, proto);
   return 0;
 }
 
 NSLCD_HANDLE(
-  protocol,byname,
+  protocol, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("protocol=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("protocol=\"%s\"", name);,
   NSLCD_ACTION_PROTOCOL_BYNAME,
-  mkfilter_protocol_byname(name,filter,sizeof(filter)),
-  write_protocol(fp,entry,name)
+  mkfilter_protocol_byname(name, filter, sizeof(filter)),
+  write_protocol(fp, entry, name)
 )
 
 NSLCD_HANDLE(
-  protocol,bynumber,
+  protocol, bynumber,
   int protocol;
   char filter[4096];
-  READ_INT32(fp,protocol);
-  log_setrequest("protocol=%lu",(unsigned long int)protocol);,
+  READ_INT32(fp, protocol);
+  log_setrequest("protocol=%lu", (unsigned long int)protocol);,
   NSLCD_ACTION_PROTOCOL_BYNUMBER,
-  mkfilter_protocol_bynumber(protocol,filter,sizeof(filter)),
-  write_protocol(fp,entry,NULL)
+  mkfilter_protocol_bynumber(protocol, filter, sizeof(filter)),
+  write_protocol(fp, entry, NULL)
 )
 
 NSLCD_HANDLE(
-  protocol,all,
+  protocol, all,
   const char *filter;
   log_setrequest("protocol(all)");,
   NSLCD_ACTION_PROTOCOL_ALL,
-  (filter=protocol_filter,0),
-  write_protocol(fp,entry,NULL)
+  (filter = protocol_filter, 0),
+  write_protocol(fp, entry, NULL)
 )

Modified: nss-pam-ldapd/nslcd/rpc.c
==============================================================================
--- nss-pam-ldapd/nslcd/rpc.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/rpc.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -58,55 +58,49 @@
 const char *rpc_filter = "(objectClass=oncRpc)";
 
 /* the attributes to request with searches */
-const char *attmap_rpc_cn               = "cn";
-const char *attmap_rpc_oncRpcNumber     = "oncRpcNumber";
+const char *attmap_rpc_cn           = "cn";
+const char *attmap_rpc_oncRpcNumber = "oncRpcNumber";
 
 /* the attribute list to request with searches */
 static const char *rpc_attrs[3];
 
-static int mkfilter_rpc_byname(const char *name,
-                               char *buffer,size_t buflen)
+static int mkfilter_rpc_byname(const char *name, char *buffer, size_t buflen)
 {
   char safename[300];
   /* escape attribute */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    rpc_filter,
-                    attmap_rpc_cn,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    rpc_filter, attmap_rpc_cn, safename);
 }
 
-static int mkfilter_rpc_bynumber(int number,
-                                 char *buffer,size_t buflen)
+static int mkfilter_rpc_bynumber(int number, char *buffer, size_t buflen)
 {
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%d))",
-                    rpc_filter,
-                    attmap_rpc_oncRpcNumber,number);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%d))",
+                    rpc_filter, attmap_rpc_oncRpcNumber, number);
 }
 
 void rpc_init(void)
 {
   int i;
   /* set up search bases */
-  if (rpc_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      rpc_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (rpc_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      rpc_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (rpc_scope==LDAP_SCOPE_DEFAULT)
-    rpc_scope=nslcd_cfg->ldc_scope;
+  if (rpc_scope == LDAP_SCOPE_DEFAULT)
+    rpc_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  rpc_attrs[0]=attmap_rpc_cn;
-  rpc_attrs[1]=attmap_rpc_oncRpcNumber;
-  rpc_attrs[2]=NULL;
+  rpc_attrs[0] = attmap_rpc_cn;
+  rpc_attrs[1] = attmap_rpc_oncRpcNumber;
+  rpc_attrs[2] = NULL;
 }
 
 /* write a single rpc entry to the stream */
-static int write_rpc(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname)
+static int write_rpc(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqname)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   const char *name;
   const char **aliases;
   const char **numbers;
@@ -114,88 +108,88 @@
   long number;
   int i;
   /* get the most canonical name */
-  name=myldap_get_rdn_value(entry,attmap_rpc_cn);
+  name = myldap_get_rdn_value(entry, attmap_rpc_cn);
   /* get the other names for the rpc entries */
-  aliases=myldap_get_values(entry,attmap_rpc_cn);
-  if ((aliases==NULL)||(aliases[0]==NULL))
+  aliases = myldap_get_values(entry, attmap_rpc_cn);
+  if ((aliases == NULL) || (aliases[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_rpc_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_rpc_cn);
     return 0;
   }
   /* if the rpc name is not yet found, get the first entry */
-  if (name==NULL)
-    name=aliases[0];
+  if (name == NULL)
+    name = aliases[0];
   /* check case of returned rpc entry */
-  if ((reqname!=NULL)&&(STR_CMP(reqname,name)!=0))
+  if ((reqname != NULL) && (STR_CMP(reqname, name) != 0))
   {
-    for (i=0;(aliases[i]!=NULL)&&(STR_CMP(reqname,aliases[i])!=0);i++)
-      /* nothing here */ ;
-    if (aliases[i]==NULL)
+    for (i = 0; (aliases[i] != NULL) && (STR_CMP(reqname, aliases[i]) != 0); 
i++)
+      /* nothing */ ;
+    if (aliases[i] == NULL)
       return 0; /* neither the name nor any of the aliases matched */
   }
   /* get the rpc number */
-  numbers=myldap_get_values(entry,attmap_rpc_oncRpcNumber);
-  if ((numbers==NULL)||(numbers[0]==NULL))
+  numbers = myldap_get_values(entry, attmap_rpc_oncRpcNumber);
+  if ((numbers == NULL) || (numbers[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_rpc_oncRpcNumber);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_rpc_oncRpcNumber);
     return 0;
   }
-  else if (numbers[1]!=NULL)
+  else if (numbers[1] != NULL)
   {
-    log_log(LOG_WARNING,"%s: %s: multiple values",
-                        myldap_get_dn(entry),attmap_rpc_oncRpcNumber);
+    log_log(LOG_WARNING, "%s: %s: multiple values",
+            myldap_get_dn(entry), attmap_rpc_oncRpcNumber);
   }
-  errno=0;
-  number=strtol(numbers[0],&tmp,10);
-  if ((*(numbers[0])=='\0')||(*tmp!='\0'))
+  errno = 0;
+  number = strtol(numbers[0], &tmp, 10);
+  if ((*(numbers[0]) == '\0') || (*tmp != '\0'))
   {
-    log_log(LOG_WARNING,"%s: %s: non-numeric",
-                        myldap_get_dn(entry),attmap_rpc_oncRpcNumber);
+    log_log(LOG_WARNING, "%s: %s: non-numeric",
+            myldap_get_dn(entry), attmap_rpc_oncRpcNumber);
     return 0;
   }
-  else if ((errno!=0)||(number>UINT32_MAX))
+  else if ((errno != 0) || (number > UINT32_MAX))
   {
-    log_log(LOG_WARNING,"%s: %s: out of range",
-                        myldap_get_dn(entry),attmap_rpc_oncRpcNumber);
+    log_log(LOG_WARNING, "%s: %s: out of range",
+            myldap_get_dn(entry), attmap_rpc_oncRpcNumber);
     return 0;
   }
   /* write the entry */
-  WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-  WRITE_STRING(fp,name);
-  WRITE_STRINGLIST_EXCEPT(fp,aliases,name);
-  WRITE_INT32(fp,number);
+  WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+  WRITE_STRING(fp, name);
+  WRITE_STRINGLIST_EXCEPT(fp, aliases, name);
+  WRITE_INT32(fp, number);
   return 0;
 }
 
 NSLCD_HANDLE(
-  rpc,byname,
+  rpc, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("rpc=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("rpc=\"%s\"", name);,
   NSLCD_ACTION_RPC_BYNAME,
-  mkfilter_rpc_byname(name,filter,sizeof(filter)),
-  write_rpc(fp,entry,name)
+  mkfilter_rpc_byname(name, filter, sizeof(filter)),
+  write_rpc(fp, entry, name)
 )
 
 NSLCD_HANDLE(
-  rpc,bynumber,
+  rpc, bynumber,
   int number;
   char filter[4096];
-  READ_INT32(fp,number);
-  log_setrequest("rpc=%lu",(unsigned long int)number);,
+  READ_INT32(fp, number);
+  log_setrequest("rpc=%lu", (unsigned long int)number);,
   NSLCD_ACTION_RPC_BYNUMBER,
-  mkfilter_rpc_bynumber(number,filter,sizeof(filter)),
-  write_rpc(fp,entry,NULL)
+  mkfilter_rpc_bynumber(number, filter, sizeof(filter)),
+  write_rpc(fp, entry, NULL)
 )
 
 NSLCD_HANDLE(
-  rpc,all,
+  rpc, all,
   const char *filter;
   log_setrequest("rpc(all)");,
   NSLCD_ACTION_RPC_ALL,
-  (filter=rpc_filter,0),
-  write_rpc(fp,entry,NULL)
+  (filter = rpc_filter, 0),
+  write_rpc(fp, entry, NULL)
 )

Modified: nss-pam-ldapd/nslcd/service.c
==============================================================================
--- nss-pam-ldapd/nslcd/service.c       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/service.c       Sat Dec 22 22:38:26 2012        (r1873)
@@ -65,75 +65,65 @@
 /* the attribute list to request with searches */
 static const char *service_attrs[4];
 
-static int mkfilter_service_byname(const char *name,
-                                   const char *protocol,
-                                   char *buffer,size_t buflen)
+static int mkfilter_service_byname(const char *name, const char *protocol,
+                                   char *buffer, size_t buflen)
 {
-  char safename[300],safeprotocol[300];
+  char safename[300], safeprotocol[300];
   /* escape attributes */
-  if (myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  if (*protocol!='\0')
+  if (*protocol != '\0')
   {
-    if (myldap_escape(protocol,safeprotocol,sizeof(safeprotocol)))
+    if (myldap_escape(protocol, safeprotocol, sizeof(safeprotocol)))
       return -1;
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%s)(%s=%s))",
-                      service_filter,
-                      attmap_service_cn,safename,
-                      attmap_service_ipServiceProtocol,safeprotocol);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%s)(%s=%s))",
+                      service_filter, attmap_service_cn, safename,
+                      attmap_service_ipServiceProtocol, safeprotocol);
   }
   else
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%s))",
-                      service_filter,
-                      attmap_service_cn,safename);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                      service_filter, attmap_service_cn, safename);
 }
 
-static int mkfilter_service_bynumber(int number,
-                                     const char *protocol,
-                                     char *buffer,size_t buflen)
+static int mkfilter_service_bynumber(int number, const char *protocol,
+                                     char *buffer, size_t buflen)
 {
   char safeprotocol[300];
-  if (*protocol!='\0')
+  if (*protocol != '\0')
   {
-    if (myldap_escape(protocol,safeprotocol,sizeof(safeprotocol)))
+    if (myldap_escape(protocol, safeprotocol, sizeof(safeprotocol)))
       return -1;
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%d)(%s=%s))",
-                      service_filter,
-                      attmap_service_ipServicePort,number,
-                      attmap_service_ipServiceProtocol,safeprotocol);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%d)(%s=%s))",
+                      service_filter, attmap_service_ipServicePort, number,
+                      attmap_service_ipServiceProtocol, safeprotocol);
   }
   else
-    return mysnprintf(buffer,buflen,
-                      "(&%s(%s=%d))",
-                      service_filter,
-                      attmap_service_ipServicePort,number);
+    return mysnprintf(buffer, buflen, "(&%s(%s=%d))",
+                      service_filter, attmap_service_ipServicePort, number);
 }
 
 void service_init(void)
 {
   int i;
   /* set up search bases */
-  if (service_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      service_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (service_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      service_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (service_scope==LDAP_SCOPE_DEFAULT)
-    service_scope=nslcd_cfg->ldc_scope;
+  if (service_scope == LDAP_SCOPE_DEFAULT)
+    service_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  service_attrs[0]=attmap_service_cn;
-  service_attrs[1]=attmap_service_ipServicePort;
-  service_attrs[2]=attmap_service_ipServiceProtocol;
-  service_attrs[3]=NULL;
+  service_attrs[0] = attmap_service_cn;
+  service_attrs[1] = attmap_service_ipServicePort;
+  service_attrs[2] = attmap_service_ipServiceProtocol;
+  service_attrs[3] = NULL;
 }
 
-static int write_service(TFILE *fp,MYLDAP_ENTRY *entry,
-                         const char *reqname,const char *reqprotocol)
+static int write_service(TFILE *fp, MYLDAP_ENTRY *entry,
+                         const char *reqname, const char *reqprotocol)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   const char *name;
   const char **aliases;
   const char **ports;
@@ -142,106 +132,107 @@
   long port;
   int i;
   /* get the most canonical name */
-  name=myldap_get_rdn_value(entry,attmap_service_cn);
+  name = myldap_get_rdn_value(entry, attmap_service_cn);
   /* get the other names for the service entries */
-  aliases=myldap_get_values(entry,attmap_service_cn);
-  if ((aliases==NULL)||(aliases[0]==NULL))
+  aliases = myldap_get_values(entry, attmap_service_cn);
+  if ((aliases == NULL) || (aliases[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_service_cn);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_service_cn);
     return 0;
   }
   /* if the service name is not yet found, get the first entry */
-  if (name==NULL)
-    name=aliases[0];
+  if (name == NULL)
+    name = aliases[0];
   /* check case of returned servies entry */
-  if ((reqname!=NULL)&&(STR_CMP(reqname,name)!=0))
+  if ((reqname != NULL) && (STR_CMP(reqname, name) != 0))
   {
-    for (i=0;(aliases[i]!=NULL)&&(STR_CMP(reqname,aliases[i])!=0);i++)
-      /* nothing here */ ;
-    if (aliases[i]==NULL)
+    for (i = 0; (aliases[i] != NULL) && (STR_CMP(reqname, aliases[i]) != 0); 
i++)
+      /* nothing */ ;
+    if (aliases[i] == NULL)
       return 0; /* neither the name nor any of the aliases matched */
   }
   /* get the service number */
-  ports=myldap_get_values(entry,attmap_service_ipServicePort);
-  if ((ports==NULL)||(ports[0]==NULL))
+  ports = myldap_get_values(entry, attmap_service_ipServicePort);
+  if ((ports == NULL) || (ports[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_service_ipServicePort);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_service_ipServicePort);
     return 0;
   }
-  else if (ports[1]!=NULL)
+  else if (ports[1] != NULL)
   {
-    log_log(LOG_WARNING,"%s: %s: multiple values",
-                        myldap_get_dn(entry),attmap_service_ipServicePort);
+    log_log(LOG_WARNING, "%s: %s: multiple values",
+            myldap_get_dn(entry), attmap_service_ipServicePort);
   }
-  errno=0;
-  port=strtol(ports[0],&tmp,10);
-  if ((*(ports[0])=='\0')||(*tmp!='\0'))
+  errno = 0;
+  port = strtol(ports[0], &tmp, 10);
+  if ((*(ports[0]) == '\0') || (*tmp != '\0'))
   {
-    log_log(LOG_WARNING,"%s: %s: non-numeric value",
-                        myldap_get_dn(entry),attmap_service_ipServicePort);
+    log_log(LOG_WARNING, "%s: %s: non-numeric value",
+            myldap_get_dn(entry), attmap_service_ipServicePort);
     return 0;
   }
-  else if ((errno!=0)||(port<=0)||(port>UINT16_MAX))
+  else if ((errno != 0) || (port <= 0) || (port > UINT16_MAX))
   {
-    log_log(LOG_WARNING,"%s: %s: out of range",
-                        myldap_get_dn(entry),attmap_service_ipServicePort);
+    log_log(LOG_WARNING, "%s: %s: out of range",
+            myldap_get_dn(entry), attmap_service_ipServicePort);
     return 0;
   }
   /* get protocols */
-  protocols=myldap_get_values(entry,attmap_service_ipServiceProtocol);
-  if ((protocols==NULL)||(protocols[0]==NULL))
+  protocols = myldap_get_values(entry, attmap_service_ipServiceProtocol);
+  if ((protocols == NULL) || (protocols[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_service_ipServiceProtocol);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_service_ipServiceProtocol);
     return 0;
   }
   /* write the entries */
-  for (i=0;protocols[i]!=NULL;i++)
-    if 
((reqprotocol==NULL)||(*reqprotocol=='\0')||(STR_CMP(reqprotocol,protocols[i])==0))
+  for (i = 0; protocols[i] != NULL; i++)
+    if ((reqprotocol == NULL) || (*reqprotocol == '\0') ||
+        (STR_CMP(reqprotocol, protocols[i]) == 0))
     {
-      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-      WRITE_STRING(fp,name);
-      WRITE_STRINGLIST_EXCEPT(fp,aliases,name);
+      WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+      WRITE_STRING(fp, name);
+      WRITE_STRINGLIST_EXCEPT(fp, aliases, name);
       /* port number is actually a 16-bit value but we write 32 bits anyway */
-      WRITE_INT32(fp,port);
-      WRITE_STRING(fp,protocols[i]);
+      WRITE_INT32(fp, port);
+      WRITE_STRING(fp, protocols[i]);
     }
   return 0;
 }
 
 NSLCD_HANDLE(
-  service,byname,
+  service, byname,
   char name[256];
   char protocol[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  READ_STRING(fp,protocol);
-  log_setrequest("service=\"%s\"/%s",name,protocol);,
+  READ_STRING(fp, name);
+  READ_STRING(fp, protocol);
+  log_setrequest("service=\"%s\"/%s", name, protocol);,
   NSLCD_ACTION_SERVICE_BYNAME,
-  mkfilter_service_byname(name,protocol,filter,sizeof(filter)),
-  write_service(fp,entry,name,protocol)
+  mkfilter_service_byname(name, protocol, filter, sizeof(filter)),
+  write_service(fp, entry, name, protocol)
 )
 
 NSLCD_HANDLE(
-  service,bynumber,
+  service, bynumber,
   int number;
   char protocol[256];
   char filter[4096];
-  READ_INT32(fp,number);
-  READ_STRING(fp,protocol);
-  log_setrequest("service=%lu/%s",(unsigned long int)number,protocol);,
+  READ_INT32(fp, number);
+  READ_STRING(fp, protocol);
+  log_setrequest("service=%lu/%s", (unsigned long int)number, protocol);,
   NSLCD_ACTION_SERVICE_BYNUMBER,
-  mkfilter_service_bynumber(number,protocol,filter,sizeof(filter)),
-  write_service(fp,entry,NULL,protocol)
+  mkfilter_service_bynumber(number, protocol, filter, sizeof(filter)),
+  write_service(fp, entry, NULL, protocol)
 )
 
 NSLCD_HANDLE(
-  service,all,
+  service, all,
   const char *filter;
   log_setrequest("service(all)");,
   NSLCD_ACTION_SERVICE_ALL,
-  (filter=service_filter,0),
-  write_service(fp,entry,NULL,NULL)
+  (filter = service_filter, 0),
+  write_service(fp, entry, NULL, NULL)
 )

Modified: nss-pam-ldapd/nslcd/shadow.c
==============================================================================
--- nss-pam-ldapd/nslcd/shadow.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nslcd/shadow.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -65,23 +65,20 @@
 const char *attmap_shadow_shadowFlag       = "\"${shadowFlag:-0}\"";
 
 /* default values for attributes */
-static const char *default_shadow_userPassword     = "*"; /* unmatchable */
+static const char *default_shadow_userPassword = "*"; /* unmatchable */
 
 /* the attribute list to request with searches */
-static const char **shadow_attrs=NULL;
+static const char **shadow_attrs = NULL;
 
-static int mkfilter_shadow_byname(const char *name,
-                                  char *buffer,size_t buflen)
+static int mkfilter_shadow_byname(const char *name, char *buffer, size_t 
buflen)
 {
   char safename[300];
   /* escape attribute */
-  if(myldap_escape(name,safename,sizeof(safename)))
+  if (myldap_escape(name, safename, sizeof(safename)))
     return -1;
   /* build filter */
-  return mysnprintf(buffer,buflen,
-                    "(&%s(%s=%s))",
-                    shadow_filter,
-                    attmap_shadow_uid,safename);
+  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
+                    shadow_filter, attmap_shadow_uid, safename);
 }
 
 void shadow_init(void)
@@ -89,72 +86,72 @@
   int i;
   SET *set;
   /* set up search bases */
-  if (shadow_bases[0]==NULL)
-    for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++)
-      shadow_bases[i]=nslcd_cfg->ldc_bases[i];
+  if (shadow_bases[0] == NULL)
+    for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++)
+      shadow_bases[i] = nslcd_cfg->ldc_bases[i];
   /* set up scope */
-  if (shadow_scope==LDAP_SCOPE_DEFAULT)
-    shadow_scope=nslcd_cfg->ldc_scope;
+  if (shadow_scope == LDAP_SCOPE_DEFAULT)
+    shadow_scope = nslcd_cfg->ldc_scope;
   /* set up attribute list */
-  set=set_new();
-  attmap_add_attributes(set,attmap_shadow_uid);
-  attmap_add_attributes(set,attmap_shadow_userPassword);
-  attmap_add_attributes(set,attmap_shadow_shadowLastChange);
-  attmap_add_attributes(set,attmap_shadow_shadowMax);
-  attmap_add_attributes(set,attmap_shadow_shadowMin);
-  attmap_add_attributes(set,attmap_shadow_shadowWarning);
-  attmap_add_attributes(set,attmap_shadow_shadowInactive);
-  attmap_add_attributes(set,attmap_shadow_shadowExpire);
-  attmap_add_attributes(set,attmap_shadow_shadowFlag);
-  shadow_attrs=set_tolist(set);
+  set = set_new();
+  attmap_add_attributes(set, attmap_shadow_uid);
+  attmap_add_attributes(set, attmap_shadow_userPassword);
+  attmap_add_attributes(set, attmap_shadow_shadowLastChange);
+  attmap_add_attributes(set, attmap_shadow_shadowMax);
+  attmap_add_attributes(set, attmap_shadow_shadowMin);
+  attmap_add_attributes(set, attmap_shadow_shadowWarning);
+  attmap_add_attributes(set, attmap_shadow_shadowInactive);
+  attmap_add_attributes(set, attmap_shadow_shadowExpire);
+  attmap_add_attributes(set, attmap_shadow_shadowFlag);
+  shadow_attrs = set_tolist(set);
   set_free(set);
 }
 
-static long to_date(const char *dn,const char *date,const char *attr)
+static long to_date(const char *dn, const char *date, const char *attr)
 {
   char buffer[32];
   long value;
   char *tmp;
   size_t l;
   /* do some special handling for date values on AD */
-  if (strcasecmp(attr,"pwdLastSet")==0)
+  if (strcasecmp(attr, "pwdLastSet") == 0)
   {
     /* we expect an AD 64-bit datetime value;
        we should do date=date/864000000000-134774
        but that causes problems on 32-bit platforms,
        first we devide by 1000000000 by stripping the
        last 9 digits from the string and going from there */
-    l=strlen(date)-9;
-    if (l>(sizeof(buffer)-1))
+    l = strlen(date) - 9;
+    if (l > (sizeof(buffer) - 1))
       return -1; /* error */
-    strncpy(buffer,date,l);
-    buffer[l]='\0';
-    errno=0;
-    value=strtol(date,&tmp,10);
-    if ((*date=='\0')||(*tmp!='\0'))
+    strncpy(buffer, date, l);
+    buffer[l] = '\0';
+    errno = 0;
+    value = strtol(date, &tmp, 10);
+    if ((*date == '\0') || (*tmp != '\0'))
     {
-      log_log(LOG_WARNING,"%s: %s: non-numeric",dn,attr);
+      log_log(LOG_WARNING, "%s: %s: non-numeric", dn, attr);
       return -1;
     }
-    else if (errno!=0)
+    else if (errno != 0)
     {
-      log_log(LOG_WARNING,"%s: %s: out of range",dn,attr);
+      log_log(LOG_WARNING, "%s: %s: out of range", dn, attr);
       return -1;
     }
-    return value/864-134774;
+    return value / 864 - 134774;
     /* note that AD does not have expiry dates but a lastchangeddate
        and some value that needs to be added */
   }
-  errno=0;
-  value=strtol(date,&tmp,10);
-  if ((*date=='\0')||(*tmp!='\0'))
+  errno = 0;
+  value = strtol(date, &tmp, 10);
+  if ((*date == '\0') || (*tmp != '\0'))
   {
-    log_log(LOG_WARNING,"%s: %s: non-numeric",dn,attr);
+    log_log(LOG_WARNING, "%s: %s: non-numeric", dn, attr);
     return -1;
   }
-  else if (errno!=0)
+  else if (errno != 0)
   {
-    log_log(LOG_WARNING,"%s: %s: out of range",dn,attr);
+    log_log(LOG_WARNING, "%s: %s: out of range", dn, attr);
     return -1;
   }
   return value;
@@ -164,55 +161,58 @@
 #define UF_DONT_EXPIRE_PASSWD 0x10000
 #endif
 
-#define GET_OPTIONAL_LONG(var,att,fallback) \
-  tmpvalue=attmap_get_value(entry,attmap_shadow_##att,buffer,sizeof(buffer)); \
-  if (tmpvalue==NULL) \
-    tmpvalue=""; \
-  errno=0; \
-  var=strtol(tmpvalue,&tmp,10); \
-  if ((*(tmpvalue)=='\0')||(*tmp!='\0')) \
-  { \
-    log_log(LOG_WARNING,"%s: %s: non-numeric", \
-                        myldap_get_dn(entry),attmap_shadow_##att); \
-    var=fallback; \
-  } \
-  else if (errno!=0) \
-  { \
-    log_log(LOG_WARNING,"%s: %s: out of range", \
-                        myldap_get_dn(entry),attmap_shadow_##att); \
-    var=fallback; \
+#define GET_OPTIONAL_LONG(var, att, fallback)                               \
+  tmpvalue = attmap_get_value(entry, attmap_shadow_##att,                   \
+                              buffer, sizeof(buffer));                      \
+  if (tmpvalue == NULL)                                                     \
+    tmpvalue = "";                                                          \
+  errno = 0;                                                                \
+  var = strtol(tmpvalue, &tmp, 10);                                         \
+  if ((*(tmpvalue) == '\0') || (*tmp != '\0'))                              \
+  {                                                                         \
+    log_log(LOG_WARNING, "%s: %s: non-numeric",                             \
+            myldap_get_dn(entry), attmap_shadow_##att);                     \
+    var = fallback;                                                         \
+  }                                                                         \
+  else if (errno != 0)                                                      \
+  {                                                                         \
+    log_log(LOG_WARNING, "%s: %s: out of range",                            \
+            myldap_get_dn(entry), attmap_shadow_##att);                     \
+    var = fallback;                                                         \
   }
 
-void get_shadow_properties(MYLDAP_ENTRY *entry,long *lastchangedate,
-                           long *mindays,long *maxdays,long *warndays,
-                           long *inactdays,long *expiredate,unsigned long 
*flag)
+void get_shadow_properties(MYLDAP_ENTRY *entry, long *lastchangedate,
+                           long *mindays, long *maxdays, long *warndays,
+                           long *inactdays, long *expiredate,
+                           unsigned long *flag)
 {
   char buffer[64];
   const char *tmpvalue;
   char *tmp;
   /* get lastchange date */
-  
tmpvalue=attmap_get_value(entry,attmap_shadow_shadowLastChange,buffer,sizeof(buffer));
-  if (tmpvalue==NULL)
-    tmpvalue="";
-  
*lastchangedate=to_date(myldap_get_dn(entry),tmpvalue,attmap_shadow_shadowLastChange);
+  tmpvalue = attmap_get_value(entry, attmap_shadow_shadowLastChange,
+                              buffer, sizeof(buffer));
+  if (tmpvalue == NULL)
+    tmpvalue = "";
+  *lastchangedate = to_date(myldap_get_dn(entry), tmpvalue, 
attmap_shadow_shadowLastChange);
   /* get other shadow properties */
-  GET_OPTIONAL_LONG(*mindays,shadowMin,-1);
-  GET_OPTIONAL_LONG(*maxdays,shadowMax,-1);
-  GET_OPTIONAL_LONG(*warndays,shadowWarning,-1);
-  GET_OPTIONAL_LONG(*inactdays,shadowInactive,-1);
-  GET_OPTIONAL_LONG(*expiredate,shadowExpire,-1);
-  GET_OPTIONAL_LONG(*flag,shadowFlag,0);
+  GET_OPTIONAL_LONG(*mindays, shadowMin, -1);
+  GET_OPTIONAL_LONG(*maxdays, shadowMax, -1);
+  GET_OPTIONAL_LONG(*warndays, shadowWarning, -1);
+  GET_OPTIONAL_LONG(*inactdays, shadowInactive, -1);
+  GET_OPTIONAL_LONG(*expiredate, shadowExpire, -1);
+  GET_OPTIONAL_LONG(*flag, shadowFlag, 0);
   /* if we're using AD handle the flag specially */
-  if (strcasecmp(attmap_shadow_shadowLastChange,"pwdLastSet")==0)
+  if (strcasecmp(attmap_shadow_shadowLastChange, "pwdLastSet") == 0)
   {
-    if (*flag&UF_DONT_EXPIRE_PASSWD)
-      *maxdays=-1;
-    *flag=0;
+    if (*flag & UF_DONT_EXPIRE_PASSWD)
+      *maxdays = -1;
+    *flag = 0;
   }
 }
 
 /* try to update the shadowLastChange attribute of the entry if possible */
-int update_lastchange(MYLDAP_SESSION *session,const char *userdn)
+int update_lastchange(MYLDAP_SESSION *session, const char *userdn)
 {
   MYLDAP_SEARCH *search;
   MYLDAP_ENTRY *entry;
@@ -220,63 +220,64 @@
   const char *attr;
   int rc;
   const char **values;
-  LDAPMod mod,*mods[2];
-  char buffer[64],*strvals[2];
+  LDAPMod mod, *mods[2];
+  char buffer[64], *strvals[2];
   /* find the name of the attribute to use */
-  if ( (attmap_shadow_shadowLastChange==NULL) || 
(attmap_shadow_shadowLastChange[0]=='\0') )
+  if ((attmap_shadow_shadowLastChange == NULL) || 
(attmap_shadow_shadowLastChange[0] == '\0'))
     return LDAP_LOCAL_ERROR; /* attribute not mapped at all */
-  else if 
(strcmp(attmap_shadow_shadowLastChange,"\"${shadowLastChange:--1}\"")==0)
-    attr="shadowLastChange";
-  else if (attmap_shadow_shadowLastChange[0]=='\"')
+  else if (strcmp(attmap_shadow_shadowLastChange, 
"\"${shadowLastChange:--1}\"") == 0)
+    attr = "shadowLastChange";
+  else if (attmap_shadow_shadowLastChange[0] == '\"')
     return LDAP_LOCAL_ERROR; /* other expressions not supported for now */
   else
-    attr=attmap_shadow_shadowLastChange;
+    attr = attmap_shadow_shadowLastChange;
   /* set up the attributes we need */
-  attrs[0]=attmap_shadow_uid;
-  attrs[1]=attr;
-  attrs[2]=NULL;
+  attrs[0] = attmap_shadow_uid;
+  attrs[1] = attr;
+  attrs[2] = NULL;
   /* find the entry to see if the attribute is present */
-  search=myldap_search(session,userdn,LDAP_SCOPE_BASE,shadow_filter,attrs,&rc);
-  if (search==NULL)
+  search = myldap_search(session, userdn, LDAP_SCOPE_BASE, shadow_filter, 
attrs, &rc);
+  if (search == NULL)
     return rc;
-  entry=myldap_get_entry(search,&rc);
-  if (entry==NULL)
+  entry = myldap_get_entry(search, &rc);
+  if (entry == NULL)
     return rc;
-  values=myldap_get_values(entry,attr);
-  if ((values==NULL)||(values[0]==NULL)||(values[0][0]=='\0'))
+  values = myldap_get_values(entry, attr);
+  if ((values == NULL) || (values[0] == NULL) || (values[0][0] == '\0'))
     return LDAP_NO_SUCH_ATTRIBUTE;
   /* build the value for the new attribute */
-  if (strcasecmp(attr,"pwdLastSet")==0)
+  if (strcasecmp(attr, "pwdLastSet") == 0)
   {
     /* for AD we use another timestamp */
-    if(mysnprintf(buffer,sizeof(buffer),"%ld000000000",((long 
int)time(NULL)/100L+(134774L*864L))))
+    if (mysnprintf(buffer, sizeof(buffer), "%ld000000000",
+                   ((long int)time(NULL) / 100L + (134774L * 864L))))
       return LDAP_LOCAL_ERROR;
   }
   else
   {
     /* time in days since Jan 1, 1970 */
-    if(mysnprintf(buffer,sizeof(buffer),"%ld",((long int)(time(NULL)/(long 
int)(60*60*24)))))
+    if (mysnprintf(buffer, sizeof(buffer), "%ld",
+                   ((long int)(time(NULL) / (long int)(60 * 60 * 24)))))
       return LDAP_LOCAL_ERROR;
   }
   /* update the shadowLastChange attribute */
-  strvals[0]=buffer;
-  strvals[1]=NULL;
-  mod.mod_op=LDAP_MOD_REPLACE;
-  mod.mod_type=(char *)attr;
-  mod.mod_values=strvals;
-  mods[0]=&mod;
-  mods[1]=NULL;
-  rc=myldap_modify(session,userdn,mods);
-  if (rc!=LDAP_SUCCESS)
-    log_log(LOG_WARNING,"%s: %s: modification failed: %s",
-                        userdn,attr,ldap_err2string(rc));
+  strvals[0] = buffer;
+  strvals[1] = NULL;
+  mod.mod_op = LDAP_MOD_REPLACE;
+  mod.mod_type = (char *)attr;
+  mod.mod_values = strvals;
+  mods[0] = &mod;
+  mods[1] = NULL;
+  rc = myldap_modify(session, userdn, mods);
+  if (rc != LDAP_SUCCESS)
+    log_log(LOG_WARNING, "%s: %s: modification failed: %s",
+            userdn, attr, ldap_err2string(rc));
   else
-    log_log(LOG_DEBUG,"%s: %s: modification succeeded",
-                      userdn,attr);
+    log_log(LOG_DEBUG, "%s: %s: modification succeeded", userdn, attr);
   return rc;
 }
 
-static int write_shadow(TFILE *fp,MYLDAP_ENTRY *entry,const char *requser)
+static int write_shadow(TFILE *fp, MYLDAP_ENTRY *entry, const char *requser)
 {
   int32_t tmpint32;
   const char **usernames;
@@ -291,88 +292,90 @@
   int i;
   char passbuffer[64];
   /* get username */
-  usernames=myldap_get_values(entry,attmap_shadow_uid);
-  if ((usernames==NULL)||(usernames[0]==NULL))
+  usernames = myldap_get_values(entry, attmap_shadow_uid);
+  if ((usernames == NULL) || (usernames[0] == NULL))
   {
-    log_log(LOG_WARNING,"%s: %s: missing",
-                        myldap_get_dn(entry),attmap_shadow_uid);
+    log_log(LOG_WARNING, "%s: %s: missing",
+            myldap_get_dn(entry), attmap_shadow_uid);
     return 0;
   }
   /* get password */
-  
passwd=get_userpassword(entry,attmap_shadow_userPassword,passbuffer,sizeof(passbuffer));
-  if (passwd==NULL)
-    passwd=default_shadow_userPassword;
+  passwd = get_userpassword(entry, attmap_shadow_userPassword,
+                            passbuffer, sizeof(passbuffer));
+  if (passwd == NULL)
+    passwd = default_shadow_userPassword;
   /* get expiry properties */
-  get_shadow_properties(entry,&lastchangedate,&mindays,&maxdays,&warndays,
-                        &inactdays,&expiredate,&flag);
+  get_shadow_properties(entry, &lastchangedate, &mindays, &maxdays, &warndays,
+                        &inactdays, &expiredate, &flag);
   /* write the entries */
-  for (i=0;usernames[i]!=NULL;i++)
-    if ((requser==NULL)||(STR_CMP(requser,usernames[i])==0))
+  for (i = 0; usernames[i] != NULL; i++)
+    if ((requser == NULL) || (STR_CMP(requser, usernames[i]) == 0))
     {
-      WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
-      WRITE_STRING(fp,usernames[i]);
-      WRITE_STRING(fp,passwd);
-      WRITE_INT32(fp,lastchangedate);
-      WRITE_INT32(fp,mindays);
-      WRITE_INT32(fp,maxdays);
-      WRITE_INT32(fp,warndays);
-      WRITE_INT32(fp,inactdays);
-      WRITE_INT32(fp,expiredate);
-      WRITE_INT32(fp,flag);
+      WRITE_INT32(fp, NSLCD_RESULT_BEGIN);
+      WRITE_STRING(fp, usernames[i]);
+      WRITE_STRING(fp, passwd);
+      WRITE_INT32(fp, lastchangedate);
+      WRITE_INT32(fp, mindays);
+      WRITE_INT32(fp, maxdays);
+      WRITE_INT32(fp, warndays);
+      WRITE_INT32(fp, inactdays);
+      WRITE_INT32(fp, expiredate);
+      WRITE_INT32(fp, flag);
     }
   return 0;
 }
 
-MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session,const char 
*username,int *rcp)
+MYLDAP_ENTRY *shadow_uid2entry(MYLDAP_SESSION *session, const char *username,
+                               int *rcp)
 {
-  MYLDAP_SEARCH *search=NULL;
-  MYLDAP_ENTRY *entry=NULL;
+  MYLDAP_SEARCH *search = NULL;
+  MYLDAP_ENTRY *entry = NULL;
   const char *base;
   char filter[4096];
   int i;
   /* if it isn't a valid username, just bail out now */
   if (!isvalidname(username))
   {
-    if (rcp!=NULL)
-      *rcp=LDAP_INVALID_SYNTAX;
+    if (rcp != NULL)
+      *rcp = LDAP_INVALID_SYNTAX;
     return NULL;
   }
   /* we have to look up the entry */
-  mkfilter_shadow_byname(username,filter,sizeof(filter));
-  for (i=0;(i<NSS_LDAP_CONFIG_MAX_BASES)&&((base=shadow_bases[i])!=NULL);i++)
+  mkfilter_shadow_byname(username, filter, sizeof(filter));
+  for (i = 0; (i < NSS_LDAP_CONFIG_MAX_BASES) && ((base = shadow_bases[i]) != 
NULL); i++)
   {
-    search=myldap_search(session,base,shadow_scope,filter,shadow_attrs,rcp);
-    if (search==NULL)
+    search = myldap_search(session, base, shadow_scope, filter, shadow_attrs, 
rcp);
+    if (search == NULL)
     {
-      if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS))
-        *rcp=LDAP_NO_SUCH_OBJECT;
+      if ((rcp != NULL) && (*rcp == LDAP_SUCCESS))
+        *rcp = LDAP_NO_SUCH_OBJECT;
       return NULL;
     }
-    entry=myldap_get_entry(search,rcp);
-    if (entry!=NULL)
+    entry = myldap_get_entry(search, rcp);
+    if (entry != NULL)
       return entry;
   }
-  if ((rcp!=NULL)&&(*rcp==LDAP_SUCCESS))
-    *rcp=LDAP_NO_SUCH_OBJECT;
+  if ((rcp != NULL) && (*rcp == LDAP_SUCCESS))
+    *rcp = LDAP_NO_SUCH_OBJECT;
   return NULL;
 }
 
 NSLCD_HANDLE(
-  shadow,byname,
+  shadow, byname,
   char name[256];
   char filter[4096];
-  READ_STRING(fp,name);
-  log_setrequest("shadow=\"%s\"",name);,
+  READ_STRING(fp, name);
+  log_setrequest("shadow=\"%s\"", name);,
   NSLCD_ACTION_SHADOW_BYNAME,
-  mkfilter_shadow_byname(name,filter,sizeof(filter)),
-  write_shadow(fp,entry,name)
+  mkfilter_shadow_byname(name, filter, sizeof(filter)),
+  write_shadow(fp, entry, name)
 )
 
 NSLCD_HANDLE(
-  shadow,all,
+  shadow, all,
   const char *filter;
   log_setrequest("shadow(all)");,
   NSLCD_ACTION_SHADOW_ALL,
-  (filter=shadow_filter,0),
-  write_shadow(fp,entry,NULL)
+  (filter = shadow_filter, 0),
+  write_shadow(fp, entry, NULL)
 )

Modified: nss-pam-ldapd/nss/aliases.c
==============================================================================
--- nss-pam-ldapd/nss/aliases.c Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/aliases.c Sat Dec 22 22:38:26 2012        (r1873)
@@ -29,33 +29,32 @@
 #include "common.h"
 
 /* read an alias entry from the stream */
-static nss_status_t read_aliasent(
-        TFILE *fp,struct aliasent *result,
-        char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_aliasent(TFILE *fp, struct aliasent *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct aliasent));
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct aliasent));
   /* read the name of the alias */
-  READ_BUF_STRING(fp,result->alias_name);
+  READ_BUF_STRING(fp, result->alias_name);
   /* read the members */
-  READ_BUF_STRINGLIST(fp,result->alias_members);
+  READ_BUF_STRINGLIST(fp, result->alias_members);
   /* tmp3int32 holds the number of entries read */
-  result->alias_members_len=tmp3int32;
+  result->alias_members_len = tmp3int32;
   /* fill in remaining gaps in struct */
-  result->alias_local=0;
+  result->alias_local = 0;
   /* we're done */
   return NSS_STATUS_SUCCESS;
 }
 
 /* get an alias entry by name */
-nss_status_t _nss_ldap_getaliasbyname_r(
-        const char *name,struct aliasent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getaliasbyname_r(const char *name,
+                                        struct aliasent *result,
+                                        char *buffer, size_t buflen,
+                                        int *errnop)
 {
-  NSS_BYNAME(NSLCD_ACTION_ALIAS_BYNAME,
-             name,
-             read_aliasent(fp,result,buffer,buflen,errnop));
+  NSS_BYNAME(NSLCD_ACTION_ALIAS_BYNAME, name,
+             read_aliasent(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -68,12 +67,11 @@
 }
 
 /* read a single alias entry from the stream */
-nss_status_t _nss_ldap_getaliasent_r(
-        struct aliasent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result,
+                                     char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(aliasentfp,NSLCD_ACTION_ALIAS_ALL,
-             read_aliasent(aliasentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(aliasentfp, NSLCD_ACTION_ALIAS_ALL,
+             read_aliasent(aliasentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened with setaliasent() above */

Modified: nss-pam-ldapd/nss/bsdnss.c
==============================================================================
--- nss-pam-ldapd/nss/bsdnss.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/bsdnss.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -54,7 +54,7 @@
 NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname2);
 NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyaddr);
 
-static ns_mtab methods[]={
+static ns_mtab methods[] = {
   { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_ldap_getgrnam_r },
   { NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_ldap_getgrgid_r },
   { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_ldap_getgrent_r },
@@ -68,8 +68,8 @@
   { NSDB_PASSWD, "setpwent",   __nss_compat_setpwent,   _nss_ldap_setpwent },
   { NSDB_PASSWD, "endpwent",   __nss_compat_endpwent,   _nss_ldap_endpwent },
 
-  { NSDB_HOSTS, "gethostbyname", __nss_compat_gethostbyname, 
_nss_ldap_gethostbyname_r },
-  { NSDB_HOSTS, "gethostbyaddr", __nss_compat_gethostbyaddr, 
_nss_ldap_gethostbyaddr_r },
+  { NSDB_HOSTS, "gethostbyname",  __nss_compat_gethostbyname,  
_nss_ldap_gethostbyname_r },
+  { NSDB_HOSTS, "gethostbyaddr",  __nss_compat_gethostbyaddr,  
_nss_ldap_gethostbyaddr_r },
   { NSDB_HOSTS, "gethostbyname2", __nss_compat_gethostbyname2, 
_nss_ldap_gethostbyname2_r },
 
   { NSDB_GROUP_COMPAT, "getgrnam_r", __nss_compat_getgrnam_r, 
_nss_ldap_getgrnam_r },
@@ -85,9 +85,9 @@
   { NSDB_PASSWD_COMPAT, "endpwent",   __nss_compat_endpwent,   
_nss_ldap_endpwent },
 };
 
-int __nss_compat_gethostbyname(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyname(void *retval, void *mdata, va_list ap)
 {
-  nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+  nss_status_t (*fn)(const char *, struct hostent *, char *, size_t, int *, 
int *);
   const char *name;
   struct hostent *result;
   char buffer[BUFFER_SIZE];
@@ -95,19 +95,19 @@
   int h_errnop;
   int af;
   nss_status_t status;
-  fn=mdata;
-  name=va_arg(ap,const char*);
-  af=va_arg(ap,int);
-  result=va_arg(ap,struct hostent *);
-  status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
-  status=__nss_compat_result(status,errnop);
-  h_errno=h_errnop;
-  return (status);
+  fn = mdata;
+  name = va_arg(ap, const char *);
+  af = va_arg(ap, int);
+  result = va_arg(ap, struct hostent *);
+  status = fn(name, result, buffer, sizeof(buffer), &errnop, &h_errnop);
+  status = __nss_compat_result(status, errnop);
+  h_errno = h_errnop;
+  return status;
 }
 
-int __nss_compat_gethostbyname2(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyname2(void *retval, void *mdata, va_list ap)
 {
-  nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+  nss_status_t (*fn)(const char *, struct hostent *, char *, size_t, int *, 
int *);
   const char *name;
   struct hostent *result;
   char buffer[BUFFER_SIZE];
@@ -115,17 +115,17 @@
   int h_errnop;
   int af;
   nss_status_t status;
-  fn=mdata;
-  name=va_arg(ap,const char*);
-  af=va_arg(ap,int);
-  result=va_arg(ap,struct hostent *);
-  status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
-  status=__nss_compat_result(status,errnop);
-  h_errno=h_errnop;
-  return (status);
+  fn = mdata;
+  name = va_arg(ap, const char *);
+  af = va_arg(ap, int);
+  result = va_arg(ap, struct hostent *);
+  status = fn(name, result, buffer, sizeof(buffer), &errnop, &h_errnop);
+  status = __nss_compat_result(status, errnop);
+  h_errno = h_errnop;
+  return status;
 }
 
-int __nss_compat_gethostbyaddr(void *retval,void *mdata,va_list ap)
+int __nss_compat_gethostbyaddr(void *retval, void *mdata, va_list ap)
 {
   struct in_addr *addr;
   int len;
@@ -134,38 +134,38 @@
   char buffer[BUFFER_SIZE];
   int errnop;
   int h_errnop;
-  nss_status_t (*fn)(struct in_addr *,int,int,struct hostent *,char 
*,size_t,int *,int *);
+  nss_status_t (*fn)(struct in_addr *, int, int, struct hostent *, char *, 
size_t, int *, int *);
   nss_status_t status;
-  fn=mdata;
-  addr=va_arg(ap,struct in_addr*);
-  len=va_arg(ap,int);
-  type=va_arg(ap,int);
-  result=va_arg(ap,struct hostent*);
-  status=fn(addr,len,type,result,buffer,sizeof(buffer),&errnop,&h_errnop);
-  status=__nss_compat_result(status,errnop);
-  h_errno=h_errnop;
-  return (status);
+  fn = mdata;
+  addr = va_arg(ap, struct in_addr *);
+  len = va_arg(ap, int);
+  type = va_arg(ap, int);
+  result = va_arg(ap, struct hostent *);
+  status = fn(addr, len, type, result, buffer, sizeof(buffer), &errnop, 
&h_errnop);
+  status = __nss_compat_result(status, errnop);
+  h_errno = h_errnop;
+  return status;
 }
 
-static int __gr_addgid(gid_t gid,gid_t *groups,int maxgrp,int *groupc)
+static int __gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *groupc)
 {
-  int ret,dupc;
+  int ret, dupc;
   /* skip duplicates */
-  for (dupc=0;dupc<MIN(maxgrp,*groupc);dupc++)
+  for (dupc = 0; dupc < MIN(maxgrp, *groupc); dupc++)
   {
-    if (groups[dupc]==gid)
+    if (groups[dupc] == gid)
       return 1;
   }
-  ret=1;
-  if (*groupc<maxgrp)  /* add this gid */
-    groups[*groupc]=gid;
+  ret = 1;
+  if (*groupc < maxgrp) /* add this gid */
+    groups[*groupc] = gid;
   else
-    ret=0;
+    ret = 0;
   (*groupc)++;
   return ret;
 }
 
-int __freebsd_getgroupmembership(void *retval,void *mdata,va_list ap)
+int __freebsd_getgroupmembership(void *retval, void *mdata, va_list ap)
 {
   int err;
   nss_status_t s;
@@ -173,36 +173,36 @@
   gid_t *tmpgroups;
   const char *user;
   gid_t *groups;
-  int maxgrp,*grpcnt;
+  int maxgrp, *grpcnt;
   int i;
-  long int lstart,lsize;
-  user=va_arg(ap,const char *);
-  group=va_arg(ap,gid_t);
-  groups=va_arg(ap,gid_t *);
-  maxgrp=va_arg(ap,int);
-  grpcnt=va_arg(ap,int *);
-  tmpgroups=malloc(maxgrp*sizeof(gid_t));
-  if (tmpgroups==NULL)
+  long int lstart, lsize;
+  user = va_arg(ap, const char *);
+  group = va_arg(ap, gid_t);
+  groups = va_arg(ap, gid_t *);
+  maxgrp = va_arg(ap, int);
+  grpcnt = va_arg(ap, int *);
+  tmpgroups = malloc(maxgrp * sizeof(gid_t));
+  if (tmpgroups == NULL)
     return NSS_STATUS_UNAVAIL;
   /* insert primary membership */
-  __gr_addgid(group,groups,maxgrp,grpcnt);
-  lstart=0;
-  lsize=maxgrp;
-  s=_nss_ldap_initgroups_dyn(user,group,&lstart,&lsize,&tmpgroups,0,&err);
-  if (s==NSS_STATUS_SUCCESS)
+  __gr_addgid(group, groups, maxgrp, grpcnt);
+  lstart = 0;
+  lsize = maxgrp;
+  s = _nss_ldap_initgroups_dyn(user, group, &lstart, &lsize, &tmpgroups, 0, 
&err);
+  if (s == NSS_STATUS_SUCCESS)
   {
-    for (i=0;i<lstart;i++)
-      __gr_addgid(tmpgroups[i],groups,maxgrp,grpcnt);
-    s=NSS_STATUS_NOTFOUND;
+    for (i = 0; i < lstart; i++)
+      __gr_addgid(tmpgroups[i], groups, maxgrp, grpcnt);
+    s = NSS_STATUS_NOTFOUND;
   }
   free(tmpgroups);
-  return __nss_compat_result(s,0);
+  return __nss_compat_result(s, 0);
 }
 
-ns_mtab *nss_module_register(const char *source,unsigned int *mtabsize,
-    nss_module_unregister_fn *unreg)
+ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize,
+                             nss_module_unregister_fn *unreg)
 {
-  *mtabsize=sizeof(methods)/sizeof(methods[0]);
-  *unreg=NULL;
-  return (methods);
+  *mtabsize = sizeof(methods) / sizeof(methods[0]);
+  *unreg = NULL;
+  return methods;
 }

Modified: nss-pam-ldapd/nss/common.c
==============================================================================
--- nss-pam-ldapd/nss/common.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/common.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    common.c - common definitions
 
-   Copyright (C) 2010 Arthur de Jong
+   Copyright (C) 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -19,4 +19,4 @@
    02110-1301 USA
 */
 
-int _nss_ldap_enablelookups=1;
+int _nss_ldap_enablelookups = 1;

Modified: nss-pam-ldapd/nss/common.h
==============================================================================
--- nss-pam-ldapd/nss/common.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/common.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -41,42 +41,42 @@
    an error status. */
 
 /* Macro is called to handle errors in opening a client connection. */
-#define ERROR_OUT_OPENERROR \
-  *errnop=ENOENT; \
-  return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR                                                 \
+  *errnop = ENOENT;                                                         \
+  return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
 
 /* Macro is called to handle errors on read operations. */
-#define ERROR_OUT_READERROR(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
-  *errnop=ENOENT; \
+#define ERROR_OUT_READERROR(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
+  *errnop = ENOENT;                                                         \
   return NSS_STATUS_UNAVAIL;
 
 /* Macro is called to handle problems with too small a buffer.
    This triggers the caller to call the function with a larger
    buffer (see NSS_GETENT below). */
-#define ERROR_OUT_BUFERROR(fp) \
-  *errnop=ERANGE; \
+#define ERROR_OUT_BUFERROR(fp)                                              \
+  *errnop = ERANGE;                                                         \
   return NSS_STATUS_TRYAGAIN;
 
 /* This macro is called if there was a problem with a write
    operation. */
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp)                                            \
   ERROR_OUT_READERROR(fp)
 
 /* This macro is called if the read status code is not
    NSLCD_RESULT_BEGIN. */
-#define ERROR_OUT_NOSUCCESS(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
+#define ERROR_OUT_NOSUCCESS(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
   return NSS_STATUS_NOTFOUND;
 
 /* These are some general macros that are used to build parts of the
    genral macros below. */
 
 /* check to see if we should answer NSS requests */
-#define NSS_AVAILCHECK \
-  if (!_nss_ldap_enablelookups) \
+#define NSS_AVAILCHECK                                                      \
+  if (!_nss_ldap_enablelookups)                                             \
     return NSS_STATUS_UNAVAIL;
 
 #ifdef NSS_FLAVOUR_GLIBC
@@ -85,11 +85,11 @@
 #define NSS_EXTRA_DEFS ;
 
 /* check validity of passed buffer (Glibc flavour) */
-#define NSS_BUFCHECK \
-  if ((buffer==NULL)||(buflen==0)) \
-  { \
-    *errnop=EINVAL; \
-    return NSS_STATUS_UNAVAIL; \
+#define NSS_BUFCHECK                                                        \
+  if ((buffer == NULL) || (buflen == 0))                                    \
+  {                                                                         \
+    *errnop = EINVAL;                                                       \
+    return NSS_STATUS_UNAVAIL;                                              \
   }
 
 #endif /* NSS_FLAVOUR_GLIBC */
@@ -107,96 +107,96 @@
    the result structure, the user buffer with length and the
    errno to return. This macro should be called through some of
    the customized ones below. */
-#define NSS_BYGEN(action,writefn,readfn) \
-  TFILE *fp; \
-  int32_t tmpint32; \
-  nss_status_t retv; \
-  NSS_EXTRA_DEFS; \
-  NSS_AVAILCHECK; \
-  NSS_BUFCHECK; \
-  /* open socket and write request */ \
-  NSLCD_REQUEST(fp,action,writefn); \
-  /* read response */ \
-  READ_RESPONSE_CODE(fp); \
-  retv=readfn; \
-  /* close socket and we're done */ \
-  if ((retv==NSS_STATUS_SUCCESS)||(retv==NSS_STATUS_TRYAGAIN)) \
-  { \
-    (void)tio_skipall(fp); \
-    (void)tio_close(fp); \
-  } \
+#define NSS_BYGEN(action, writefn, readfn)                                  \
+  TFILE *fp;                                                                \
+  int32_t tmpint32;                                                         \
+  nss_status_t retv;                                                        \
+  NSS_EXTRA_DEFS;                                                           \
+  NSS_AVAILCHECK;                                                           \
+  NSS_BUFCHECK;                                                             \
+  /* open socket and write request */                                       \
+  NSLCD_REQUEST(fp, action, writefn);                                       \
+  /* read response */                                                       \
+  READ_RESPONSE_CODE(fp);                                                   \
+  retv = readfn;                                                            \
+  /* close socket and we're done */                                         \
+  if ((retv == NSS_STATUS_SUCCESS) || (retv == NSS_STATUS_TRYAGAIN))        \
+  {                                                                         \
+    (void)tio_skipall(fp);                                                  \
+    (void)tio_close(fp);                                                    \
+  }                                                                         \
   return retv;
 
 /* This macro can be used to generate a get..byname() function
    body. */
-#define NSS_BYNAME(action,name,readfn) \
-  NSS_BYGEN(action,WRITE_STRING(fp,name),readfn)
+#define NSS_BYNAME(action, name, readfn)                                    \
+  NSS_BYGEN(action, WRITE_STRING(fp, name), readfn)
 
 /* This macro can be used to generate a get..by..() function
    body where the value should be passed as an int32_t. */
-#define NSS_BYINT32(action,val,readfn) \
-  NSS_BYGEN(action,WRITE_INT32(fp,val),readfn)
+#define NSS_BYINT32(action, val, readfn)                                    \
+  NSS_BYGEN(action, WRITE_INT32(fp, val), readfn)
 
 /* This macro generates a simple setent() function body. This closes any
    open streams so that NSS_GETENT() can open a new file. */
-#define NSS_SETENT(fp) \
-  NSS_AVAILCHECK; \
-  if (fp!=NULL) \
-  { \
-    (void)tio_close(fp); \
-    fp=NULL; \
-  } \
+#define NSS_SETENT(fp)                                                      \
+  NSS_AVAILCHECK;                                                           \
+  if (fp != NULL)                                                           \
+  {                                                                         \
+    (void)tio_close(fp);                                                    \
+    fp = NULL;                                                              \
+  }                                                                         \
   return NSS_STATUS_SUCCESS;
 
 /* This macro generates a getent() function body. If the stream is not yet
    open, a new one is opened, a request is written and a check is done for
    a response header. A single entry is read with the readfn() function. */
-#define NSS_GETENT(fp,action,readfn) \
-  int32_t tmpint32; \
-  nss_status_t retv; \
-  NSS_EXTRA_DEFS; \
-  NSS_AVAILCHECK; \
-  NSS_BUFCHECK; \
-  /* check that we have a valid file descriptor */ \
-  if (fp==NULL) \
-  { \
-    /* open a new stream and write the request */ \
-    NSLCD_REQUEST(fp,action,/* no writefn */;); \
-  } \
-  /* prepare for buffer errors */ \
-  tio_mark(fp); \
-  /* read a response */ \
-  READ_RESPONSE_CODE(fp); \
-  retv=readfn; \
-  /* check read result */ \
-  if (retv==NSS_STATUS_TRYAGAIN) \
-  { \
-    /* if we have a full buffer try to reset the stream */ \
-    if (tio_reset(fp)) \
-    { \
-      /* reset failed, we close and give up with a permanent error \
-         because we cannot retry just the getent() call because it \
-         may not be only the first entry that failed */ \
-      tio_close(fp); \
-      fp=NULL; \
-      *errnop=EINVAL; \
-      return NSS_STATUS_UNAVAIL; \
-    } \
-  } \
-  else if (retv!=NSS_STATUS_SUCCESS) \
-    fp=NULL; /* file should be closed by now */ \
+#define NSS_GETENT(fp, action, readfn)                                      \
+  int32_t tmpint32;                                                         \
+  nss_status_t retv;                                                        \
+  NSS_EXTRA_DEFS;                                                           \
+  NSS_AVAILCHECK;                                                           \
+  NSS_BUFCHECK;                                                             \
+  /* check that we have a valid file descriptor */                          \
+  if (fp == NULL)                                                           \
+  {                                                                         \
+    /* open a new stream and write the request */                           \
+    NSLCD_REQUEST(fp, action, /* no writefn */ ;);                          \
+  }                                                                         \
+  /* prepare for buffer errors */                                           \
+  tio_mark(fp);                                                             \
+  /* read a response */                                                     \
+  READ_RESPONSE_CODE(fp);                                                   \
+  retv = readfn;                                                            \
+  /* check read result */                                                   \
+  if (retv == NSS_STATUS_TRYAGAIN)                                          \
+  {                                                                         \
+    /* if we have a full buffer try to reset the stream */                  \
+    if (tio_reset(fp))                                                      \
+    {                                                                       \
+      /* reset failed, we close and give up with a permanent error          \
+         because we cannot retry just the getent() call because it          \
+         may not be only the first entry that failed */                     \
+      tio_close(fp);                                                        \
+      fp = NULL;                                                            \
+      *errnop = EINVAL;                                                     \
+      return NSS_STATUS_UNAVAIL;                                            \
+    }                                                                       \
+  }                                                                         \
+  else if (retv != NSS_STATUS_SUCCESS)                                      \
+    fp = NULL; /* file should be closed by now */                           \
   return retv;
 
 /* This macro generates an endent() function body. This just closes
    the stream. */
-#define NSS_ENDENT(fp) \
-  NSS_AVAILCHECK; \
-  if (fp!=NULL) \
-  { \
-    (void)tio_skipall(fp); \
-    (void)tio_close(fp); \
-    fp=NULL; \
-  } \
+#define NSS_ENDENT(fp)                                                      \
+  NSS_AVAILCHECK;                                                           \
+  if (fp != NULL)                                                           \
+  {                                                                         \
+    (void)tio_skipall(fp);                                                  \
+    (void)tio_close(fp);                                                    \
+    fp = NULL;                                                              \
+  }                                                                         \
   return NSS_STATUS_SUCCESS;
 
 #endif /* not NSS__COMMON_H */

Modified: nss-pam-ldapd/nss/ethers.c
==============================================================================
--- nss-pam-ldapd/nss/ethers.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/ethers.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,38 +31,36 @@
 #include "compat/attrs.h"
 
 /* read an ethernet entry from the stream */
-static nss_status_t read_etherent(
-        TFILE *fp,struct etherent *result,
-        char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_etherent(TFILE *fp, struct etherent *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   int32_t tmpint32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct etherent));
-  READ_BUF_STRING(fp,result->e_name);
-  READ(fp,&(result->e_addr),sizeof(uint8_t[6]));
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct etherent));
+  READ_BUF_STRING(fp, result->e_name);
+  READ(fp, &(result->e_addr), sizeof(uint8_t[6]));
   return NSS_STATUS_SUCCESS;
 }
 
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* map a hostname to the corresponding ethernet address */
-nss_status_t _nss_ldap_gethostton_r(
-        const char *name,struct etherent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_gethostton_r(const char *name,
+                                    struct etherent *result, char *buffer,
+                                    size_t buflen, int *errnop)
 {
-  NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,
-             name,
-             read_etherent(fp,result,buffer,buflen,errnop));
+  NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME, name,
+             read_etherent(fp, result, buffer, buflen, errnop));
 }
 
 /* map an ethernet address to the corresponding hostname */
-nss_status_t _nss_ldap_getntohost_r(
-        const struct ether_addr *addr,struct etherent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr,
+                                    struct etherent *result, char *buffer,
+                                    size_t buflen, int *errnop)
 {
   NSS_BYGEN(NSLCD_ACTION_ETHER_BYETHER,
-            WRITE(fp,addr,sizeof(uint8_t[6])),
-            read_etherent(fp,result,buffer,buflen,errnop));
+            WRITE(fp, addr, sizeof(uint8_t[6])),
+            read_etherent(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -75,12 +73,11 @@
 }
 
 /* read a single ethernet entry from the stream */
-nss_status_t _nss_ldap_getetherent_r(
-        struct etherent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getetherent_r(struct etherent *result,
+                                     char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(etherentfp,NSLCD_ACTION_ETHER_ALL,
-             read_etherent(etherentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(etherentfp, NSLCD_ACTION_ETHER_ALL,
+             read_etherent(etherentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened with setetherent() above */
@@ -103,81 +100,84 @@
 #endif /* NSS_BUFLEN_ETHERS */
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *etherent2str(struct etherent *result,char *buffer,size_t buflen)
+static char *etherent2str(struct etherent *result, char *buffer,
+                          size_t buflen)
 {
   int res;
-  res=snprintf(buffer,buflen,"%s 
%s",ether_ntoa(&result->e_addr),result->e_name);
-  if ((res<0)||(res>=buflen))
+  res = snprintf(buffer, buflen, "%s %s", ether_ntoa(&result->e_addr),
+                 result->e_name);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args,int wantname)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args, int wantname)
 {
   struct etherent result;
   char buffer[NSS_BUFLEN_ETHERS];
   nss_status_t retv;
   /* read the result entry from the stream */
-  retv=read_etherent(fp,&result,buffer,sizeof(buffer),&args->erange);
-  if (retv!=NSS_STATUS_SUCCESS)
+  retv = read_etherent(fp, &result, buffer, sizeof(buffer), &args->erange);
+  if (retv != NSS_STATUS_SUCCESS)
     return retv;
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
   /* try to return in string format if requested */
-  if ((args->buf.buffer!=NULL)&&(args->buf.buflen>0))
+  if ((args->buf.buffer != NULL) && (args->buf.buflen > 0))
   {
-    if (etherent2str(&result,args->buf.buffer,args->buf.buflen)==NULL)
+    if (etherent2str(&result, args->buf.buffer, args->buf.buflen) == NULL)
     {
-      args->erange=1;
+      args->erange = 1;
       return NSS_NOTFOUND;
     }
-    args->returnval=args->buf.buffer;
-    args->returnlen=strlen(args->returnval);
+    args->returnval = args->buf.buffer;
+    args->returnlen = strlen(args->returnval);
     return NSS_SUCCESS;
   }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
   /* return the result entry */
   if (wantname)
   {
-    /* we expect the buffer to have enough room for the name (buflen==0) */
-    strcpy(args->buf.buffer,result.e_name);
-    args->returnval=args->buf.buffer;
+    /* we expect the buffer to have enough room for the name (buflen == 0) */
+    strcpy(args->buf.buffer, result.e_name);
+    args->returnval = args->buf.buffer;
   }
   else /* address */
   {
-    memcpy(args->buf.result,&result.e_addr,sizeof(result.e_addr));
-    args->returnval=args->buf.result;
+    memcpy(args->buf.result, &result.e_addr, sizeof(result.e_addr));
+    args->returnval = args->buf.result;
   }
   return NSS_SUCCESS;
 }
 
 /* map a hostname to the corresponding ethernet address */
-static nss_status_t ethers_gethostton(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t ethers_gethostton(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_ETHER_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args,0));
+             read_result(fp, args, 0));
 }
 
 /* map an ethernet address to the corresponding hostname */
-static nss_status_t ethers_getntohost(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t ethers_getntohost(nss_backend_t UNUSED(*be), void *args)
 {
-  struct ether_addr *addr=(struct ether_addr *)(NSS_ARGS(args)->key.ether);
+  struct ether_addr *addr = (struct ether_addr *)(NSS_ARGS(args)->key.ether);
   NSS_BYGEN(NSLCD_ACTION_ETHER_BYETHER,
-            WRITE(fp,addr,sizeof(uint8_t[6])),
-            read_result(fp,args,1));
+            WRITE(fp, addr, sizeof(uint8_t[6])),
+            read_result(fp, args, 1));
 }
 
-static nss_backend_op_t ethers_ops[]={
+static nss_backend_op_t ethers_ops[] = {
   nss_ldap_destructor,
   ethers_gethostton,
   ethers_getntohost
 };
 
 nss_backend_t *_nss_ldap_ethers_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                       const char UNUSED(*src_name),
+                                       const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(ethers_ops,sizeof(ethers_ops));
+  return nss_ldap_constructor(ethers_ops, sizeof(ethers_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/group.c
==============================================================================
--- nss-pam-ldapd/nss/group.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/group.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -32,83 +32,81 @@
 #include "compat/attrs.h"
 
 /* read a single group entry from the stream */
-static nss_status_t read_group(
-        TFILE *fp,struct group *result,
-        char *buffer,size_t buflen,int *errnop)
-{
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct group));
-  READ_BUF_STRING(fp,result->gr_name);
-  READ_BUF_STRING(fp,result->gr_passwd);
-  READ_INT32(fp,result->gr_gid);
-  READ_BUF_STRINGLIST(fp,result->gr_mem);
+static nss_status_t read_group(TFILE *fp, struct group *result,
+                               char *buffer, size_t buflen, int *errnop)
+{
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct group));
+  READ_BUF_STRING(fp, result->gr_name);
+  READ_BUF_STRING(fp, result->gr_passwd);
+  READ_INT32(fp, result->gr_gid);
+  READ_BUF_STRINGLIST(fp, result->gr_mem);
   return NSS_STATUS_SUCCESS;
 }
 
 /* read all group entries from the stream and add
    gids of these groups to the list */
-static nss_status_t read_gids(
-        TFILE *fp,gid_t skipgroup,long int *start,long int *size,
-        gid_t **groupsp,long int limit,int *errnop)
+static nss_status_t read_gids(TFILE *fp, gid_t skipgroup, long int *start,
+                              long int *size, gid_t **groupsp,
+                              long int limit, int *errnop)
 {
-  int32_t res=(int32_t)NSLCD_RESULT_BEGIN;
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t res = (int32_t)NSLCD_RESULT_BEGIN;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   gid_t gid;
 #ifdef NSS_FLAVOUR_GLIBC
   gid_t *newgroups;
   long int newsize;
 #endif /* NSS_FLAVOUR_GLIBC */
   /* loop over results */
-  while (res==(int32_t)NSLCD_RESULT_BEGIN)
+  while (res == (int32_t)NSLCD_RESULT_BEGIN)
   {
     /* skip group name */
     SKIP_STRING(fp);
     /* skip passwd entry */
     SKIP_STRING(fp);
     /* read gid */
-    READ_INT32(fp,gid);
+    READ_INT32(fp, gid);
     /* skip members */
     SKIP_STRINGLIST(fp);
     /* only add the group to the list if it is not the specified group */
-    if (gid!=skipgroup)
+    if (gid != skipgroup)
     {
 #ifdef NSS_FLAVOUR_GLIBC
       /* check if we reached the limit */
-      if ( (limit>0) && (*start>=limit) )
+      if ((limit > 0) && (*start >= limit))
         return NSS_STATUS_TRYAGAIN;
       /* check if our buffer is large enough */
-      if ((*start)>=(*size))
+      if ((*start) >= (*size))
       {
         /* for some reason Glibc expects us to grow the array (completely
            different from all other NSS functions) */
         /* calculate new size */
-        newsize=2*(*size);
-        if ( (limit>0) && (*start>=limit) )
-          newsize=limit;
+        newsize = 2 * (*size);
+        if ((limit > 0) && (*start >= limit))
+          newsize = limit;
         /* allocate new memory */
-        newgroups=realloc(*groupsp,newsize*sizeof(gid_t));
-        if (newgroups==NULL)
+        newgroups = realloc(*groupsp, newsize * sizeof(gid_t));
+        if (newgroups == NULL)
           return NSS_STATUS_TRYAGAIN;
-        *groupsp=newgroups;
-        *size=newsize;
+        *groupsp = newgroups;
+        *size = newsize;
       }
 #endif /* NSS_FLAVOUR_GLIBC */
 #ifdef NSS_FLAVOUR_SOLARIS
       /* check if we reached the limit */
-      if ( (limit>0) && (*start>=limit) )
+      if ((limit > 0) && (*start >= limit))
       {
-        *errnop=1; /* this is args->erange */
+        *errnop = 1; /* this is args->erange */
         return NSS_STATUS_NOTFOUND;
       }
 #endif /* NSS_FLAVOUR_SOLARIS */
       /* add gid to list */
-      (*groupsp)[(*start)++]=gid;
+      (*groupsp)[(*start)++] = gid;
     }
-    /* read next response code
-      (don't bail out on not success since we just want to build
-      up a list) */
-    READ_INT32(fp,res);
+    /* read next response code (don't bail out on not success since we
+       just want to build up a list) */
+    READ_INT32(fp, res);
   }
   /* return the proper status code */
   return NSS_STATUS_SUCCESS;
@@ -117,23 +115,21 @@
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a group entry by name */
-nss_status_t _nss_ldap_getgrnam_r(
-        const char *name,struct group *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_GROUP_BYNAME,
              name,
-             read_group(fp,result,buffer,buflen,errnop));
+             read_group(fp, result, buffer, buflen, errnop));
 }
 
 /* get a group entry by numeric gid */
-nss_status_t _nss_ldap_getgrgid_r(
-        gid_t gid,struct group *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   NSS_BYINT32(NSLCD_ACTION_GROUP_BYGID,
               gid,
-              read_group(fp,result,buffer,buflen,errnop));
+              read_group(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -146,12 +142,11 @@
 }
 
 /* read a single group from the stream */
-nss_status_t _nss_ldap_getgrent_r(
-        struct group *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getgrent_r(struct group *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(grentfp,NSLCD_ACTION_GROUP_ALL,
-             read_group(grentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(grentfp, NSLCD_ACTION_GROUP_ALL,
+             read_group(grentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened with setgrent() above */
@@ -172,9 +167,10 @@
    limit     IN     - the maxium size of the array
    *errnop   OUT    - for returning errno
 */
-nss_status_t _nss_ldap_initgroups_dyn(
-        const char *user,gid_t skipgroup,long int *start,
-        long int *size,gid_t **groupsp,long int limit,int *errnop)
+nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup,
+                                      long int *start, long int *size,
+                                      gid_t **groupsp, long int limit,
+                                      int *errnop)
 {
 /* temporarily map the buffer and buflen names so the check in NSS_BYNAME
    for validity of the buffer works (renaming the parameters may cause
@@ -183,7 +179,7 @@
 #define buflen *size
   NSS_BYNAME(NSLCD_ACTION_GROUP_BYMEMBER,
              user,
-             read_gids(fp,skipgroup,start,size,groupsp,limit,errnop));
+             read_gids(fp, skipgroup, start, size, groupsp, limit, errnop));
 #undef buffer
 #undef buflen
 }
@@ -193,73 +189,76 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *group2str(struct group *result,char *buffer,size_t buflen)
+static char *group2str(struct group *result, char *buffer, size_t buflen)
 {
-  int res,i;
-  
res=snprintf(buffer,buflen,"%s:%s:%d:",result->gr_name,result->gr_passwd,(int)result->gr_gid);
-  if ((res<0)||(res>=buflen))
+  int res, i;
+  res = snprintf(buffer, buflen, "%s:%s:%d:", result->gr_name,
+                 result->gr_passwd, (int)result->gr_gid);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   if (result->gr_mem)
-    for (i=0;result->gr_mem[i];i++)
+    for (i = 0; result->gr_mem[i]; i++)
     {
       if (i)
-        strlcat(buffer,",",buflen);
-      strlcat(buffer,result->gr_mem[i],buflen);
+        strlcat(buffer, ",", buflen);
+      strlcat(buffer, result->gr_mem[i], buflen);
     }
   /* check if buffer overflowed */
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(group,&args->erange);
+  READ_RESULT(group, &args->erange);
 }
 
-static nss_status_t group_getgrnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t group_getgrnam(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_GROUP_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t group_getgrgid(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t group_getgrgid(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYINT32(NSLCD_ACTION_GROUP_BYGID,
               NSS_ARGS(args)->key.gid,
-              read_result(fp,args));
+              read_result(fp, args));
 }
 
-static nss_status_t group_setgrent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t group_setgrent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t group_getgrent(nss_backend_t *be,void *args)
+static nss_status_t group_getgrent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_GROUP_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_GROUP_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t group_endgrent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t group_endgrent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t group_getgroupsbymember(nss_backend_t UNUSED(*be),void 
*args)
+static nss_status_t group_getgroupsbymember(nss_backend_t UNUSED(*be), void 
*args)
 {
-  struct nss_groupsbymem *argp=(struct nss_groupsbymem *)args;
-  long int start=(long int)argp->numgids;
-  gid_t skipgroup=(start>0)?argp->gid_array[0]:(gid_t)-1;
+  struct nss_groupsbymem *argp = (struct nss_groupsbymem *)args;
+  long int start = (long int)argp->numgids;
+  gid_t skipgroup = (start > 0) ? argp->gid_array[0] : (gid_t)-1;
   NSS_BYNAME(NSLCD_ACTION_GROUP_BYMEMBER,
              argp->username,
-             read_gids(fp,skipgroup,&start,NULL,(gid_t 
**)&argp->gid_array,argp->maxgids,&NSS_ARGS(args)->erange);
-             argp->numgids=(int)start;);
+             read_gids(fp, skipgroup, &start, NULL, (gid_t **)&argp->gid_array,
+                       argp->maxgids, &NSS_ARGS(args)->erange);
+             argp->numgids = (int)start;
+      );
 }
 
-static nss_backend_op_t group_ops[]={
+static nss_backend_op_t group_ops[] = {
   nss_ldap_destructor,
   group_endgrent,
   group_setgrent,
@@ -270,9 +269,10 @@
 };
 
 nss_backend_t *_nss_ldap_group_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                      const char UNUSED(*src_name),
+                                      const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(group_ops,sizeof(group_ops));
+  return nss_ldap_constructor(group_ops, sizeof(group_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/hosts.c
==============================================================================
--- nss-pam-ldapd/nss/hosts.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/hosts.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -36,101 +36,100 @@
 /* Redefine some ERROR_OUT macros as we also want to set h_errnop. */
 
 #undef ERROR_OUT_OPENERROR
-#define ERROR_OUT_OPENERROR \
-  *errnop=ENOENT; \
-  *h_errnop=HOST_NOT_FOUND; \
-  return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR                                                 \
+  *errnop = ENOENT;                                                         \
+  *h_errnop = HOST_NOT_FOUND;                                               \
+  return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
 
 #undef ERROR_OUT_READERROR
-#define ERROR_OUT_READERROR(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
-  *errnop=ENOENT; \
-  *h_errnop=NO_RECOVERY; \
+#define ERROR_OUT_READERROR(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
+  *errnop = ENOENT;                                                         \
+  *h_errnop = NO_RECOVERY;                                                  \
   return NSS_STATUS_UNAVAIL;
 
 #undef ERROR_OUT_BUFERROR
-#define ERROR_OUT_BUFERROR(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
-  *errnop=ERANGE; \
-  *h_errnop=TRY_AGAIN; \
+#define ERROR_OUT_BUFERROR(fp)                                              \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
+  *errnop = ERANGE;                                                         \
+  *h_errnop = TRY_AGAIN;                                                    \
   return NSS_STATUS_TRYAGAIN;
 
 #undef ERROR_OUT_WRITEERROR
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp)                                            \
   ERROR_OUT_READERROR(fp)
 
 /* read a single host entry from the stream, filtering on the
    specified address family, result is stored in result
    it will an empty entry if no addresses in the address family
    were available */
-static nss_status_t read_one_hostent(
-        TFILE *fp,struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop,int af)
+static nss_status_t read_one_hostent(TFILE *fp, struct hostent *result,
+                                     char *buffer, size_t buflen, int *errnop,
+                                     int *h_errnop, int af)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   int32_t numaddr;
   int i;
   int readaf;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct hostent));
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct hostent));
   /* read the host entry */
-  READ_BUF_STRING(fp,result->h_name);
-  READ_BUF_STRINGLIST(fp,result->h_aliases);
-  result->h_addrtype=af;
-  result->h_length=0;
+  READ_BUF_STRING(fp, result->h_name);
+  READ_BUF_STRINGLIST(fp, result->h_aliases);
+  result->h_addrtype = af;
+  result->h_length = 0;
   /* read number of addresses to follow */
-  READ_INT32(fp,numaddr);
+  READ_INT32(fp, numaddr);
   /* allocate memory for array */
-  /* Note: this may allocate too much memory (e.g. also for
-           address records of other address families) but
-           this is a simple way to do it */
-  BUF_ALLOC(fp,result->h_addr_list,char *,numaddr+1);
+  /* Note: this may allocate too much memory (e.g. also for address records
+           of other address families) but this is a simple way to do it */
+  BUF_ALLOC(fp, result->h_addr_list, char *, numaddr + 1);
   /* go through the address list and filter on af */
-  i=0;
-  while (--numaddr>=0)
+  i = 0;
+  while (--numaddr >= 0)
   {
     /* read address family and size */
-    READ_INT32(fp,readaf);
-    READ_INT32(fp,tmp2int32);
-    if (readaf==af)
+    READ_INT32(fp, readaf);
+    READ_INT32(fp, tmp2int32);
+    if (readaf == af)
     {
       /* read the address */
-      result->h_length=tmp2int32;
-      READ_BUF(fp,result->h_addr_list[i++],tmp2int32);
+      result->h_length = tmp2int32;
+      READ_BUF(fp, result->h_addr_list[i++], tmp2int32);
     }
     else
     {
-      SKIP(fp,tmpint32);
+      SKIP(fp, tmpint32);
     }
   }
   /* null-terminate address list */
-  result->h_addr_list[i]=NULL;
+  result->h_addr_list[i] = NULL;
   return NSS_STATUS_SUCCESS;
 }
 
 /* this is a wrapper around read_one_hostent() that checks whether the read
    address list is empty and tries the next result if available if
    retry is set */
-static nss_status_t read_hostent(
-        TFILE *fp,struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop,int af,int retry)
+static nss_status_t read_hostent(TFILE *fp, struct hostent *result,
+                                 char *buffer, size_t buflen, int *errnop,
+                                 int *h_errnop, int af, int retry)
 {
   int32_t tmpint32;
   nss_status_t retv;
   /* check until we read an non-empty entry, error or */
   while (1)
   {
-    retv=read_one_hostent(fp,result,buffer,buflen,errnop,h_errnop,af);
+    retv = read_one_hostent(fp, result, buffer, buflen, errnop, h_errnop, af);
     /* check result */
-    if ((retv!=NSS_STATUS_SUCCESS)||(result->h_addr_list[0]!=NULL))
+    if ((retv != NSS_STATUS_SUCCESS) || (result->h_addr_list[0] != NULL))
       return retv;
     /* error of if we are not retrying */
     if (!retry)
     {
-      *errnop=ENOENT;
-      *h_errnop=NO_ADDRESS;
+      *errnop = ENOENT;
+      *h_errnop = NO_ADDRESS;
       (void)tio_close(fp);
       return NSS_STATUS_NOTFOUND;
     }
@@ -140,10 +139,10 @@
 }
 
 /* write an address value */
-#define WRITE_ADDRESS(fp,af,len,addr) \
-  WRITE_INT32(fp,af); \
-  WRITE_INT32(fp,len); \
-  WRITE(fp,addr,len);
+#define WRITE_ADDRESS(fp, af, len, addr)                                    \
+  WRITE_INT32(fp, af);                                                      \
+  WRITE_INT32(fp, len);                                                     \
+  WRITE(fp, addr, len);
 
 #ifdef NSS_FLAVOUR_GLIBC
 
@@ -154,22 +153,25 @@
    result          - OUT - entry found
    buffer,buflen   - OUT - buffer to store allocated stuff on
    errnop,h_errnop - OUT - for reporting errors */
-nss_status_t _nss_ldap_gethostbyname2_r(
-        const char *name,int af,struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af,
+                                        struct hostent *result, char *buffer,
+                                        size_t buflen, int *errnop,
+                                        int *h_errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_HOST_BYNAME,
              name,
-             read_hostent(fp,result,buffer,buflen,errnop,h_errnop,af,0));
+             read_hostent(fp, result, buffer, buflen, errnop, h_errnop, af, 
0));
 }
 
 /* this function just calls the gethostbyname2() variant with the address
    familiy set */
-nss_status_t _nss_ldap_gethostbyname_r(
-        const char *name,struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyname_r(const char *name,
+                                       struct hostent *result, char *buffer,
+                                       size_t buflen, int *errnop,
+                                       int *h_errnop)
 {
-  return 
_nss_ldap_gethostbyname2_r(name,AF_INET,result,buffer,buflen,errnop,h_errnop);
+  return _nss_ldap_gethostbyname2_r(name, AF_INET, result, buffer, buflen,
+                                    errnop, h_errnop);
 }
 
 /* this function looks up a single host entry and returns all the addresses
@@ -180,13 +182,14 @@
    result          - OUT - entry found
    buffer,buflen   - OUT - buffer to store allocated stuff on
    errnop,h_errnop - OUT - for reporting errors */
-nss_status_t _nss_ldap_gethostbyaddr_r(
-        const void *addr,socklen_t len,int af,struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len,
+                                       int af, struct hostent *result,
+                                       char *buffer, size_t buflen,
+                                       int *errnop, int *h_errnop)
 {
   NSS_BYGEN(NSLCD_ACTION_HOST_BYADDR,
-            WRITE_ADDRESS(fp,af,len,addr),
-            read_hostent(fp,result,buffer,buflen,errnop,h_errnop,af,0))
+            WRITE_ADDRESS(fp, af, len, addr),
+            read_hostent(fp, result, buffer, buflen, errnop, h_errnop, af, 0));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -198,12 +201,13 @@
 }
 
 /* this function only returns addresses of the AF_INET address family */
-nss_status_t _nss_ldap_gethostent_r(
-        struct hostent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
-{
-  NSS_GETENT(hostentfp,NSLCD_ACTION_HOST_ALL,
-             
read_hostent(hostentfp,result,buffer,buflen,errnop,h_errnop,AF_INET,1));
+nss_status_t _nss_ldap_gethostent_r(struct hostent *result,
+                                    char *buffer, size_t buflen, int *errnop,
+                                    int *h_errnop)
+{
+  NSS_GETENT(hostentfp, NSLCD_ACTION_HOST_ALL,
+             read_hostent(hostentfp, result, buffer, buflen, errnop, h_errnop,
+                          AF_INET, 1));
 }
 
 /* close the stream opened with sethostent() above */
@@ -217,76 +221,81 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *hostent2str(struct hostent *result,char *buffer,size_t buflen)
+static char *hostent2str(struct hostent *result, char *buffer, size_t buflen)
 {
-  int i,j;
+  int i, j;
   /* build the formatted string, one line per address */
-  buffer[0]='\0';
-  if (result->h_addr_list!=NULL)
+  buffer[0] = '\0';
+  if (result->h_addr_list != NULL)
   {
-    for (i=0;result->h_addr_list[i];i++)
+    for (i = 0; result->h_addr_list[i]; i++)
     {
-      if (i>0)
-        strlcat(buffer,"\n",buflen);
+      if (i > 0)
+        strlcat(buffer, "\n", buflen);
       /* snprintf writes a terminating \0 on Solaris */
-      snprintf(buffer,buflen-strlen(buffer)-1,
-               "%s %s",inet_ntoa(*((struct in_addr 
*)result->h_addr_list[i])),result->h_name);
+      snprintf(buffer, buflen - strlen(buffer) - 1,
+               "%s %s",
+               inet_ntoa(*((struct in_addr *)result->h_addr_list[i])),
+               result->h_name);
       /* add aliases for first line only */
-      if ((i==0)&&(result->h_aliases))
+      if ((i == 0) && (result->h_aliases))
       {
-        for (j=0;result->h_aliases[j];j++)
+        for (j = 0; result->h_aliases[j]; j++)
         {
-          strlcat(buffer," ",buflen);
-          strlcat(buffer,result->h_aliases[j],buflen);
+          strlcat(buffer, " ", buflen);
+          strlcat(buffer, result->h_aliases[j], buflen);
         }
       }
     }
   }
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,int af,int retry,nss_XbyY_args_t 
*args)
+static nss_status_t read_result(TFILE *fp, int af, int retry,
+                                nss_XbyY_args_t *args)
 {
-  READ_RESULT(hostent,&args->erange,&args->h_errno,af,retry);
+  READ_RESULT(hostent, &args->erange, &args->h_errno, af, retry);
 }
 
 /* hack to set the correct h_errno */
 #define h_errnop &(NSS_ARGS(args)->h_errno)
 
-static nss_status_t hosts_gethostbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t hosts_gethostbyname(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_HOST_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,AF_INET,0,args));
+             read_result(fp, AF_INET, 0, args));
 }
 
-static nss_status_t hosts_gethostbyaddr(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t hosts_gethostbyaddr(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYGEN(NSLCD_ACTION_HOST_BYADDR,
-            
WRITE_ADDRESS(fp,NSS_ARGS(args)->key.hostaddr.type,NSS_ARGS(args)->key.hostaddr.len,NSS_ARGS(args)->key.hostaddr.addr),
-            read_result(fp,NSS_ARGS(args)->key.hostaddr.type,0,args));
+            WRITE_ADDRESS(fp, NSS_ARGS(args)->key.hostaddr.type,
+                          NSS_ARGS(args)->key.hostaddr.len,
+                          NSS_ARGS(args)->key.hostaddr.addr),
+            read_result(fp, NSS_ARGS(args)->key.hostaddr.type, 0, args));
 }
 
-static nss_status_t hosts_sethostent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t hosts_sethostent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t hosts_gethostent(nss_backend_t *be,void *args)
+static nss_status_t hosts_gethostent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_HOST_ALL,
-             read_result(LDAP_BE(be)->fp,AF_INET,1,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_HOST_ALL,
+             read_result(LDAP_BE(be)->fp, AF_INET, 1, args));
 }
 
-static nss_status_t hosts_endhostent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t hosts_endhostent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t hosts_ops[]={
+static nss_backend_op_t hosts_ops[] = {
   nss_ldap_destructor,
   hosts_endhostent,
   hosts_sethostent,
@@ -296,9 +305,10 @@
 };
 
 nss_backend_t *_nss_ldap_hosts_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                      const char UNUSED(*src_name),
+                                      const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(hosts_ops,sizeof(hosts_ops));
+  return nss_ldap_constructor(hosts_ops, sizeof(hosts_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/netgroup.c
==============================================================================
--- nss-pam-ldapd/nss/netgroup.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/netgroup.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -35,50 +35,49 @@
 /* we redefine this here because we need to return NSS_STATUS_RETURN
    instead of NSS_STATUS_NOTFOUND */
 #undef ERROR_OUT_NOSUCCESS
-#define ERROR_OUT_NOSUCCESS(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
+#define ERROR_OUT_NOSUCCESS(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
   return NSS_STATUS_RETURN;
 
 /* function for reading a single result entry */
-static nss_status_t read_netgrent(
-        TFILE *fp,struct __netgrent *result,
-        char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_netgrent(TFILE *fp, struct __netgrent *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   int32_t tmpint32;
   int type;
-  size_t bufptr=0;
+  size_t bufptr = 0;
   /* read netgroup type */
-  READ_INT32(fp,type);
-  if (type==NSLCD_NETGROUP_TYPE_NETGROUP)
+  READ_INT32(fp, type);
+  if (type == NSLCD_NETGROUP_TYPE_NETGROUP)
   {
     /* the response is a reference to another netgroup */
-    result->type=group_val;
-    READ_BUF_STRING(fp,result->val.group);
+    result->type = group_val;
+    READ_BUF_STRING(fp, result->val.group);
   }
-  else if (type==NSLCD_NETGROUP_TYPE_TRIPLE)
+  else if (type == NSLCD_NETGROUP_TYPE_TRIPLE)
   {
     /* the response is a host/user/domain triple */
-    result->type=triple_val;
+    result->type = triple_val;
     /* read host and revert to NULL on empty string */
-    READ_BUF_STRING(fp,result->val.triple.host);
-    if (result->val.triple.host[0]=='\0')
+    READ_BUF_STRING(fp, result->val.triple.host);
+    if (result->val.triple.host[0] == '\0')
     {
-      result->val.triple.host=NULL;
+      result->val.triple.host = NULL;
       bufptr--; /* free unused space */
     }
     /* read user and revert to NULL on empty string */
-    READ_BUF_STRING(fp,result->val.triple.user);
-    if (result->val.triple.user[0]=='\0')
+    READ_BUF_STRING(fp, result->val.triple.user);
+    if (result->val.triple.user[0] == '\0')
     {
-      result->val.triple.user=NULL;
+      result->val.triple.user = NULL;
       bufptr--; /* free unused space */
     }
     /* read domain and revert to NULL on empty string */
-    READ_BUF_STRING(fp,result->val.triple.domain);
-    if (result->val.triple.domain[0]=='\0')
+    READ_BUF_STRING(fp, result->val.triple.domain);
+    if (result->val.triple.domain[0] == '\0')
     {
-      result->val.triple.domain=NULL;
+      result->val.triple.domain = NULL;
       bufptr--; /* free unused space */
     }
   }
@@ -94,8 +93,8 @@
 static __thread TFILE *netgrentfp;
 
 /* start a request to get a netgroup by name */
-nss_status_t _nss_ldap_setnetgrent(
-        const char *group,struct __netgrent UNUSED(*result))
+nss_status_t _nss_ldap_setnetgrent(const char *group,
+                                   struct __netgrent UNUSED(*result))
 {
   /* we cannot use NSS_SETENT() here because we have a parameter that is only
      available in this function */
@@ -104,22 +103,22 @@
   int *errnop;
   if (!_nss_ldap_enablelookups)
     return NSS_STATUS_UNAVAIL;
-  errnop=&errnocp;
+  errnop = &errnocp;
   /* check parameter */
-  if ((group==NULL)||(group[0]=='\0'))
+  if ((group == NULL) || (group[0] == '\0'))
     return NSS_STATUS_UNAVAIL;
   /* open a new stream and write the request */
-  
NSLCD_REQUEST(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME,WRITE_STRING(netgrentfp,group));
+  NSLCD_REQUEST(netgrentfp, NSLCD_ACTION_NETGROUP_BYNAME,
+                WRITE_STRING(netgrentfp, group));
   return NSS_STATUS_SUCCESS;
 }
 
 /* get a single netgroup tuple from the stream */
-nss_status_t _nss_ldap_getnetgrent_r(
-        struct __netgrent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result,
+                                     char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(netgrentfp,NSLCD_ACTION_NETGROUP_BYNAME,
-             read_netgrent(netgrentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(netgrentfp, NSLCD_ACTION_NETGROUP_BYNAME,
+             read_netgrent(netgrentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened with setnetgrent() above */
@@ -133,13 +132,12 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 /* this is the backend structure for the {set,get,end}ent() functions */
-struct setnetgrent_backend
-{
+struct setnetgrent_backend {
   nss_backend_op_t *ops; /* function-pointer table */
-  int n_ops; /* number of function pointers */
-  TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
-  SET *seen_groups; /* netgroups seen, for loop detection */
-  SET *unseen_groups; /* netgroups that need to be chased */
+  int n_ops;             /* number of function pointers */
+  TFILE *fp;             /* the file pointer for {set,get,end}ent() functions 
*/
+  SET *seen_groups;      /* netgroups seen, for loop detection */
+  SET *unseen_groups;    /* netgroups that need to be chased */
 };
 
 /* easy way to get sets from back-end */
@@ -155,121 +153,133 @@
   char *group;
   while (1)
   {
-    group=set_pop(NETGROUP_BE(be)->unseen_groups);
-    if (group==NULL)
+    group = set_pop(NETGROUP_BE(be)->unseen_groups);
+    if (group == NULL)
       return NULL;
-    if (!set_contains(NETGROUP_BE(be)->seen_groups,group))
+    if (!set_contains(NETGROUP_BE(be)->seen_groups, group))
     {
-      set_add(NETGROUP_BE(be)->seen_groups,group);
+      set_add(NETGROUP_BE(be)->seen_groups, group);
       return group;
     }
   }
 }
 
-static nss_status_t netgroup_nslcd_setnetgrent(nss_backend_t *be,const char 
*group,int *errnop)
+static nss_status_t netgroup_nslcd_setnetgrent(nss_backend_t *be,
+                                               const char *group, int *errnop)
 {
   /* we cannot use NSS_SETENT() here because we have a parameter that is only
      available in this function */
   int32_t tmpint32;
   /* check parameter */
-  if ((group==NULL)||(group[0]=='\0'))
+  if ((group == NULL) || (group[0] == '\0'))
     return NSS_STATUS_UNAVAIL;
   /* open a new stream and write the request */
-  NSLCD_REQUEST(NETGROUP_BE(be)->fp,NSLCD_ACTION_NETGROUP_BYNAME,
-                WRITE_STRING(NETGROUP_BE(be)->fp,group));
+  NSLCD_REQUEST(NETGROUP_BE(be)->fp, NSLCD_ACTION_NETGROUP_BYNAME,
+                WRITE_STRING(NETGROUP_BE(be)->fp, group));
   return NSS_STATUS_SUCCESS;
 }
 
-static nss_status_t netgroup_nslcd_getnetgrent(nss_backend_t *be,struct 
__netgrent *result,char *buffer,size_t buflen,void *args)
-{
-  NSS_GETENT(NETGROUP_BE(be)->fp,NSLCD_ACTION_NETGROUP_BYNAME,
-             read_netgrent(NETGROUP_BE(be)->fp,result,buffer,buflen,errnop));
+static nss_status_t netgroup_nslcd_getnetgrent(nss_backend_t *be,
+                                               struct __netgrent *result,
+                                               char *buffer, size_t buflen,
+                                               void *args)
+{
+  NSS_GETENT(NETGROUP_BE(be)->fp, NSLCD_ACTION_NETGROUP_BYNAME,
+             read_netgrent(NETGROUP_BE(be)->fp, result, buffer, buflen,
+                           errnop));
 }
 
-static nss_status_t netgroup_setnetgrent_setnetgrent(nss_backend_t 
UNUSED(*be),void UNUSED(*args))
+static nss_status_t netgroup_setnetgrent_setnetgrent(nss_backend_t
+                                                     UNUSED(*be),
+                                                     void UNUSED(*args))
 {
   return NSS_STATUS_SUCCESS;
 }
 
-static nss_status_t netgroup_setnetgrent_getnetgrent(nss_backend_t *be,void 
*args)
+static nss_status_t netgroup_setnetgrent_getnetgrent(nss_backend_t *be,
+                                                     void *args)
 {
   struct __netgrent result;
-  char *group=NULL;
-  int done=0;
-  nss_status_t status,rc;
-  GETNETGRENT_ARGS(args)->status=NSS_NETGR_NO;
+  char *group = NULL;
+  int done = 0;
+  nss_status_t status, rc;
+  GETNETGRENT_ARGS(args)->status = NSS_NETGR_NO;
   while (!done)
   {
-    
status=netgroup_nslcd_getnetgrent(be,&result,GETNETGRENT_ARGS(args)->buffer,
-                                         GETNETGRENT_ARGS(args)->buflen,args);
-    if (status!=NSS_STATUS_SUCCESS)
+    status = netgroup_nslcd_getnetgrent(be, &result, 
GETNETGRENT_ARGS(args)->buffer,
+                                        GETNETGRENT_ARGS(args)->buflen, args);
+    if (status != NSS_STATUS_SUCCESS)
     {
-      if (errno==ENOENT)
+      if (errno == ENOENT)
       {
         /* done with the current netgroup */
-        /* explore nested netgroup,if any */
-        int found=0;
+        /* explore nested netgroup, if any */
+        int found = 0;
         while (!found)
         {
           /* find a nested netgroup to pursue further */
-          group=find_unseen_netgroup(be);
-          if (group==NULL)
+          group = find_unseen_netgroup(be);
+          if (group == NULL)
           {
             /* no more netgroup */
-            found=1; done=1;
-            errno=ENOENT;  /* TODO: probably don't do this */
+            found = 1;
+            done = 1;
+            errno = ENOENT; /* TODO: probably don't do this */
           }
           else
           {
-            rc=netgroup_nslcd_setnetgrent(be,group,&NSS_ARGS(args)->erange);
-            if (rc==NSS_STATUS_SUCCESS)
-              found=1;
+            rc = netgroup_nslcd_setnetgrent(be, group, 
&NSS_ARGS(args)->erange);
+            if (rc == NSS_STATUS_SUCCESS)
+              found = 1;
             free(group);
-            group=NULL;
+            group = NULL;
           }
         } /* while !found */
       }
       else
-      { /* err!=ENOENT */
-        done=1;
+      { /* err != ENOENT */
+        done = 1;
       }
     }
     else
-    { /* status==NSS_STATUS_SUCCESS */
-      if (result.type==group_val)
+    { /* status == NSS_STATUS_SUCCESS */
+      if (result.type == group_val)
       {
         /* a netgroup nested within the current netgroup */
-        set_add(NETGROUP_BE(be)->unseen_groups,result.val.group);
+        set_add(NETGROUP_BE(be)->unseen_groups, result.val.group);
       }
-      else if (result.type==triple_val)
+      else if (result.type == triple_val)
       {
-        GETNETGRENT_ARGS(args)->retp[NSS_NETGR_MACHINE]=result.val.triple.host;
-        GETNETGRENT_ARGS(args)->retp[NSS_NETGR_USER]=result.val.triple.user;
-        
GETNETGRENT_ARGS(args)->retp[NSS_NETGR_DOMAIN]=result.val.triple.domain;
-        GETNETGRENT_ARGS(args)->status=NSS_NETGR_FOUND;
-        done=1;
+        GETNETGRENT_ARGS(args)->retp[NSS_NETGR_MACHINE] = 
result.val.triple.host;
+        GETNETGRENT_ARGS(args)->retp[NSS_NETGR_USER] = result.val.triple.user;
+        GETNETGRENT_ARGS(args)->retp[NSS_NETGR_DOMAIN] = 
result.val.triple.domain;
+        GETNETGRENT_ARGS(args)->status = NSS_NETGR_FOUND;
+        done = 1;
       }
       else
       {
-        /* NSS_STATUS_SUCCESS,but type is not group_val or triple_val */
-        /* should not be here,log a message */
-        status=NSS_STATUS_NOTFOUND;
-        done=1;
+        /* NSS_STATUS_SUCCESS, but type is not group_val or triple_val */
+        /* should not be here, log a message */
+        status = NSS_STATUS_NOTFOUND;
+        done = 1;
       }
     }
   } /* while !done */
   return status;
 }
 
-static nss_status_t netgroup_setnetgrent_endnetgrent(nss_backend_t 
UNUSED(*be),void UNUSED(*args))
+static nss_status_t netgroup_setnetgrent_endnetgrent(nss_backend_t
+                                                     UNUSED(*be),
+                                                     void UNUSED(*args))
 {
   NSS_ENDENT(NETGROUP_BE(be)->fp);
 }
 
-static nss_status_t netgroup_setnetgrent_destructor(nss_backend_t *be,void 
*UNUSED(args))
+static nss_status_t netgroup_setnetgrent_destructor(nss_backend_t *be,
+                                                    void *UNUSED(args))
 {
-  struct setnetgrent_backend *ngbe=(struct setnetgrent_backend *)be;
-  if (ngbe->fp!=NULL)
+  struct setnetgrent_backend *ngbe = (struct setnetgrent_backend *)be;
+  if (ngbe->fp != NULL)
     (void)tio_close(ngbe->fp);
   set_free(ngbe->seen_groups);
   set_free(ngbe->unseen_groups);
@@ -277,53 +287,55 @@
   return NSS_STATUS_SUCCESS;
 }
 
-static nss_backend_op_t netgroup_setnetgrent_ops[]={
+static nss_backend_op_t netgroup_setnetgrent_ops[] = {
   netgroup_setnetgrent_destructor,
   netgroup_setnetgrent_endnetgrent,
   netgroup_setnetgrent_setnetgrent,
   netgroup_setnetgrent_getnetgrent,
 };
 
-static nss_status_t netgroup_setnetgrent_constructor(nss_backend_t *be,void 
*args)
+static nss_status_t netgroup_setnetgrent_constructor(nss_backend_t *be, void 
*args)
 {
   struct setnetgrent_backend *ngbe;
   nss_status_t retv;
   NSS_AVAILCHECK;
-  SETNETGRENT_ARGS(args)->iterator=NULL;        /* initialize */
+  SETNETGRENT_ARGS(args)->iterator = NULL; /* initialize */
   /* allocate a back-end specific to this request */
-  ngbe=(struct setnetgrent_backend *)malloc(sizeof(struct 
setnetgrent_backend));
-  if (ngbe==NULL)
+  ngbe = (struct setnetgrent_backend *)malloc(sizeof(struct 
setnetgrent_backend));
+  if (ngbe == NULL)
     return NSS_STATUS_UNAVAIL;
-  ngbe->ops=netgroup_setnetgrent_ops;
-  ngbe->n_ops=sizeof(netgroup_setnetgrent_ops)/sizeof(nss_backend_op_t);
-  ngbe->fp=NULL;
-  ngbe->seen_groups=set_new();
-  ngbe->unseen_groups=set_new();
+  ngbe->ops = netgroup_setnetgrent_ops;
+  ngbe->n_ops = sizeof(netgroup_setnetgrent_ops) / sizeof(nss_backend_op_t);
+  ngbe->fp = NULL;
+  ngbe->seen_groups = set_new();
+  ngbe->unseen_groups = set_new();
   /* start the first search */
-  
retv=netgroup_nslcd_setnetgrent(be,SETNETGRENT_ARGS(args)->netgroup,&NSS_ARGS(args)->erange);
-  if (retv!=NSS_STATUS_SUCCESS)
+  retv = netgroup_nslcd_setnetgrent(be, SETNETGRENT_ARGS(args)->netgroup,
+                                    &NSS_ARGS(args)->erange);
+  if (retv != NSS_STATUS_SUCCESS)
   {
-    netgroup_setnetgrent_destructor(be,args);
+    netgroup_setnetgrent_destructor(be, args);
     return retv;
   }
   /* return the new back-end */
-  SETNETGRENT_ARGS(args)->iterator=(nss_backend_t *)ngbe;
+  SETNETGRENT_ARGS(args)->iterator = (nss_backend_t *)ngbe;
   return NSS_STATUS_SUCCESS;
 }
 
-static nss_backend_op_t netgroup_ops[]={
+static nss_backend_op_t netgroup_ops[] = {
   nss_ldap_destructor,
   NULL,
   NULL,
   NULL,
-  NULL,/* TODO:_nss_ldap_netgr_in,*/
+  NULL, /* TODO:_nss_ldap_netgr_in */
   netgroup_setnetgrent_constructor
 };
 
 nss_backend_t *_nss_ldap_netgroup_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                         const char UNUSED(*src_name),
+                                         const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(netgroup_ops,sizeof(netgroup_ops));
+  return nss_ldap_constructor(netgroup_ops, sizeof(netgroup_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/networks.c
==============================================================================
--- nss-pam-ldapd/nss/networks.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/networks.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -36,67 +36,67 @@
 /* Redefine some ERROR_OUT macros as we also want to set h_errnop. */
 
 #undef ERROR_OUT_OPENERROR
-#define ERROR_OUT_OPENERROR \
-  *errnop=ENOENT; \
-  *h_errnop=HOST_NOT_FOUND; \
-  return (errno==EAGAIN)?NSS_STATUS_TRYAGAIN:NSS_STATUS_UNAVAIL;
+#define ERROR_OUT_OPENERROR                                                 \
+  *errnop = ENOENT;                                                         \
+  *h_errnop = HOST_NOT_FOUND;                                               \
+  return (errno == EAGAIN) ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
 
 #undef ERROR_OUT_READERROR
-#define ERROR_OUT_READERROR(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
-  *errnop=ENOENT; \
-  *h_errnop=NO_RECOVERY; \
+#define ERROR_OUT_READERROR(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
+  *errnop = ENOENT;                                                         \
+  *h_errnop = NO_RECOVERY;                                                  \
   return NSS_STATUS_UNAVAIL;
 
 #undef ERROR_OUT_BUFERROR
-#define ERROR_OUT_BUFERROR(fp) \
-  (void)tio_close(fp); \
-  fp=NULL; \
-  *errnop=ERANGE; \
-  *h_errnop=TRY_AGAIN; \
+#define ERROR_OUT_BUFERROR(fp)                                              \
+  (void)tio_close(fp);                                                      \
+  fp = NULL;                                                                \
+  *errnop = ERANGE;                                                         \
+  *h_errnop = TRY_AGAIN;                                                    \
   return NSS_STATUS_TRYAGAIN;
 
 #undef ERROR_OUT_WRITEERROR
-#define ERROR_OUT_WRITEERROR(fp) \
+#define ERROR_OUT_WRITEERROR(fp)                                            \
   ERROR_OUT_READERROR(fp)
 
 /* read a single network entry from the stream, ignoring entries
    that are not AF_INET (IPv4), result is stored in result */
-static nss_status_t read_netent(
-        TFILE *fp,struct netent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+static nss_status_t read_netent(TFILE *fp, struct netent *result,
+                                char *buffer, size_t buflen, int *errnop,
+                                int *h_errnop)
 {
-  int32_t tmpint32,tmp2int32,tmp3int32;
+  int32_t tmpint32, tmp2int32, tmp3int32;
   int32_t numaddr;
   int readaf;
-  size_t bufptr=0;
-  nss_status_t retv=NSS_STATUS_NOTFOUND;
-  memset(result,0,sizeof(struct netent));
+  size_t bufptr = 0;
+  nss_status_t retv = NSS_STATUS_NOTFOUND;
+  memset(result, 0, sizeof(struct netent));
   /* read the network entry */
-  READ_BUF_STRING(fp,result->n_name);
-  READ_BUF_STRINGLIST(fp,result->n_aliases);
-  result->n_addrtype=AF_INET;
+  READ_BUF_STRING(fp, result->n_name);
+  READ_BUF_STRINGLIST(fp, result->n_aliases);
+  result->n_addrtype = AF_INET;
   /* read number of addresses to follow */
-  READ_INT32(fp,numaddr);
+  READ_INT32(fp, numaddr);
   /* go through the address list and filter on af */
-  while (--numaddr>=0)
+  while (--numaddr >= 0)
   {
     /* read address family and size */
-    READ_INT32(fp,readaf);
-    READ_INT32(fp,tmp2int32); /* address length */
-    if ((readaf==AF_INET)&&(tmp2int32==4))
+    READ_INT32(fp, readaf);
+    READ_INT32(fp, tmp2int32); /* address length */
+    if ((readaf == AF_INET) && (tmp2int32 == 4))
     {
       /* read address and translate to host byte order */
-      READ_INT32(fp,result->n_net);
+      READ_INT32(fp, result->n_net);
       /* signal that we've read a proper entry */
-      retv=NSS_STATUS_SUCCESS;
+      retv = NSS_STATUS_SUCCESS;
       /* don't return here to not upset the stream */
     }
     else
     {
       /* skip unsupported address families */
-      SKIP(fp,tmpint32);
+      SKIP(fp, tmpint32);
     }
   }
   return retv;
@@ -105,32 +105,34 @@
 /* write an address value */
 /* version 2.10 of glibc changed the address from network to host order
    (changelog entry 2009-07-01) */
-#define WRITE_ADDRESS(fp,addr) \
-  WRITE_INT32(fp,AF_INET); \
-  WRITE_INT32(fp,4); \
-  WRITE_INT32(fp,addr);
+#define WRITE_ADDRESS(fp, addr)                                             \
+  WRITE_INT32(fp, AF_INET);                                                 \
+  WRITE_INT32(fp, 4);                                                       \
+  WRITE_INT32(fp, addr);
 
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a network entry by name */
-nss_status_t _nss_ldap_getnetbyname_r(
-        const char *name,struct netent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetbyname_r(const char *name,
+                                      struct netent *result, char *buffer,
+                                      size_t buflen, int *errnop,
+                                      int *h_errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME,
              name,
-             read_netent(fp,result,buffer,buflen,errnop,h_errnop));
+             read_netent(fp, result, buffer, buflen, errnop, h_errnop));
 }
 
 /* Note: the af parameter is ignored and is assumed to be AF_INET */
 /* TODO: implement handling of af parameter */
-nss_status_t _nss_ldap_getnetbyaddr_r(
-        uint32_t addr,int UNUSED(af),struct netent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int UNUSED(af),
+                                      struct netent *result, char *buffer,
+                                      size_t buflen, int *errnop,
+                                      int *h_errnop)
 {
   NSS_BYGEN(NSLCD_ACTION_NETWORK_BYADDR,
-            WRITE_ADDRESS(fp,addr),
-            read_netent(fp,result,buffer,buflen,errnop,h_errnop))
+            WRITE_ADDRESS(fp, addr),
+            read_netent(fp, result, buffer, buflen, errnop, h_errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -143,12 +145,12 @@
 }
 
 /* get a single network entry from the stream */
-nss_status_t _nss_ldap_getnetent_r(
-        struct netent *result,
-        char *buffer,size_t buflen,int *errnop,int *h_errnop)
+nss_status_t _nss_ldap_getnetent_r(struct netent *result,
+                                   char *buffer, size_t buflen, int *errnop,
+                                   int *h_errnop)
 {
-  NSS_GETENT(netentfp,NSLCD_ACTION_NETWORK_ALL,
-             read_netent(netentfp,result,buffer,buflen,errnop,h_errnop));
+  NSS_GETENT(netentfp, NSLCD_ACTION_NETWORK_ALL,
+             read_netent(netentfp, result, buffer, buflen, errnop, h_errnop));
 }
 
 /* close the stream opened by setnetent() above */
@@ -162,65 +164,65 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *netent2str(struct netent *result,char *buffer,size_t buflen)
+static char *netent2str(struct netent *result, char *buffer, size_t buflen)
 {
-  int i,res;
+  int i, res;
   struct in_addr priv_in_addr;
-  priv_in_addr.s_addr=result->n_net;
-  res=snprintf(buffer,buflen,"%s %s",result->n_name,inet_ntoa(priv_in_addr));
-  if ((res<0)||(res>=buflen))
+  priv_in_addr.s_addr = result->n_net;
+  res = snprintf(buffer, buflen, "%s %s", result->n_name, 
inet_ntoa(priv_in_addr));
+  if ((res < 0) || (res >= buflen))
     return NULL;
   if (result->n_aliases)
-    for (i=0;result->n_aliases[i];i++)
+    for (i = 0; result->n_aliases[i]; i++)
     {
-      strlcat(buffer," ",buflen);
-      strlcat(buffer,result->n_aliases[i],buflen);
+      strlcat(buffer, " ", buflen);
+      strlcat(buffer, result->n_aliases[i], buflen);
     }
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(netent,&args->erange,&args->h_errno);
+  READ_RESULT(netent, &args->erange, &args->h_errno);
 }
 
 /* more of a dirty hack */
 #define h_errnop (&(NSS_ARGS(args)->h_errno))
 
-static nss_status_t networks_getnetbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t networks_getnetbyname(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t networks_getnetbyaddr(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t networks_getnetbyaddr(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYGEN(NSLCD_ACTION_NETWORK_BYADDR,
-            WRITE_ADDRESS(fp,NSS_ARGS(args)->key.netaddr.net),
-            read_result(fp,args));
+            WRITE_ADDRESS(fp, NSS_ARGS(args)->key.netaddr.net),
+            read_result(fp, args));
 }
 
-static nss_status_t networks_setnetent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t networks_setnetent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t networks_getnetent(nss_backend_t *be,void *args)
+static nss_status_t networks_getnetent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_NETWORK_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_NETWORK_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t networks_endnetent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t networks_endnetent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t networks_ops[]={
+static nss_backend_op_t networks_ops[] = {
   nss_ldap_destructor,
   networks_endnetent,
   networks_setnetent,
@@ -230,9 +232,10 @@
 };
 
 nss_backend_t *_nss_ldap_networks_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                         const char UNUSED(*src_name),
+                                         const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(networks_ops,sizeof(networks_ops));
+  return nss_ldap_constructor(networks_ops, sizeof(networks_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/passwd.c
==============================================================================
--- nss-pam-ldapd/nss/passwd.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/passwd.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,23 +31,22 @@
 #include "compat/attrs.h"
 
 /* read a passwd entry from the stream */
-static nss_status_t read_passwd(
-        TFILE *fp,struct passwd *result,
-        char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_passwd(TFILE *fp, struct passwd *result,
+                                char *buffer, size_t buflen, int *errnop)
 {
   int32_t tmpint32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct passwd));
-  READ_BUF_STRING(fp,result->pw_name);
-  READ_BUF_STRING(fp,result->pw_passwd);
-  READ_INT32(fp,result->pw_uid);
-  READ_INT32(fp,result->pw_gid);
-  READ_BUF_STRING(fp,result->pw_gecos);
-  READ_BUF_STRING(fp,result->pw_dir);
-  READ_BUF_STRING(fp,result->pw_shell);
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct passwd));
+  READ_BUF_STRING(fp, result->pw_name);
+  READ_BUF_STRING(fp, result->pw_passwd);
+  READ_INT32(fp, result->pw_uid);
+  READ_INT32(fp, result->pw_gid);
+  READ_BUF_STRING(fp, result->pw_gecos);
+  READ_BUF_STRING(fp, result->pw_dir);
+  READ_BUF_STRING(fp, result->pw_shell);
 #ifdef HAVE_STRUCT_PASSWD_PW_CLASS
   /* set the user access class to an empty string */
-  result->pw_class=result->pw_name+strlen(result->pw_name);
+  result->pw_class = result->pw_name + strlen(result->pw_name);
 #endif /* HAVE_STRUCT_PASSWD_PW_CLASS */
   return NSS_STATUS_SUCCESS;
 }
@@ -55,23 +54,21 @@
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a single passwd entry by name */
-nss_status_t _nss_ldap_getpwnam_r(
-        const char *name,struct passwd *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME,
              name,
-             read_passwd(fp,result,buffer,buflen,errnop));
+             read_passwd(fp, result, buffer, buflen, errnop));
 }
 
 /* get a single passwd entry by uid */
-nss_status_t _nss_ldap_getpwuid_r(
-        uid_t uid,struct passwd *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID,
               uid,
-              read_passwd(fp,result,buffer,buflen,errnop));
+              read_passwd(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -84,12 +81,11 @@
 }
 
 /* read password data from an opened stream */
-nss_status_t _nss_ldap_getpwent_r(
-        struct passwd *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getpwent_r(struct passwd *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(pwentfp,NSLCD_ACTION_PASSWD_ALL,
-             read_passwd(pwentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(pwentfp, NSLCD_ACTION_PASSWD_ALL,
+             read_passwd(pwentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened with setpwent() above */
@@ -103,57 +99,58 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *passwd2str(struct passwd *result,char *buffer,size_t buflen)
+static char *passwd2str(struct passwd *result, char *buffer, size_t buflen)
 {
   int res;
-  res=snprintf(buffer,buflen,"%s:%s:%d:%d:%s:%s:%s",
-     result->pw_name,result->pw_passwd,(int)result->pw_uid,(int)result->pw_gid,
-     result->pw_gecos,result->pw_dir,result->pw_shell);
-  if ((res<0)||(res>=buflen))
+  res = snprintf(buffer, buflen, "%s:%s:%d:%d:%s:%s:%s",
+                 result->pw_name, result->pw_passwd, (int)result->pw_uid,
+                 (int)result->pw_gid, result->pw_gecos, result->pw_dir,
+                 result->pw_shell);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(passwd,&args->erange);
+  READ_RESULT(passwd, &args->erange);
 }
 
-static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID,
               NSS_ARGS(args)->key.uid,
-              read_result(fp,args));
+              read_result(fp, args));
 }
 
 /* open a connection to the nslcd and write the request */
-static nss_status_t passwd_setpwent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t passwd_setpwent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
 /* read password data from an opened stream */
-static nss_status_t passwd_getpwent(nss_backend_t *be,void *args)
+static nss_status_t passwd_getpwent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PASSWD_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_PASSWD_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
 /* close the stream opened with setpwent() above */
-static nss_status_t passwd_endpwent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t passwd_endpwent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t passwd_ops[]={
+static nss_backend_op_t passwd_ops[] = {
   nss_ldap_destructor,
   passwd_endpwent,
   passwd_setpwent,
@@ -163,9 +160,10 @@
 };
 
 nss_backend_t *_nss_ldap_passwd_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                       const char UNUSED(*src_name),
+                                       const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(passwd_ops,sizeof(passwd_ops));
+  return nss_ldap_constructor(passwd_ops, sizeof(passwd_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/protocols.c
==============================================================================
--- nss-pam-ldapd/nss/protocols.c       Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/protocols.c       Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,39 +31,39 @@
 #include "compat/attrs.h"
 
 /* read a single protocol entry from the stream */
-static nss_status_t read_protoent(
-        TFILE *fp,struct protoent *result,
-        char *buffer,size_t buflen,int *errnop)
-{
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct protoent));
-  READ_BUF_STRING(fp,result->p_name);
-  READ_BUF_STRINGLIST(fp,result->p_aliases);
-  READ_INT32(fp,result->p_proto);
+static nss_status_t read_protoent(TFILE *fp, struct protoent *result,
+                                  char *buffer, size_t buflen, int *errnop)
+{
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct protoent));
+  READ_BUF_STRING(fp, result->p_name);
+  READ_BUF_STRINGLIST(fp, result->p_aliases);
+  READ_INT32(fp, result->p_proto);
   return NSS_STATUS_SUCCESS;
 }
 
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a protocol entry by name */
-nss_status_t _nss_ldap_getprotobyname_r(
-        const char *name,struct protoent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotobyname_r(const char *name,
+                                        struct protoent *result,
+                                        char *buffer, size_t buflen,
+                                        int *errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
              name,
-             read_protoent(fp,result,buffer,buflen,errnop));
+             read_protoent(fp, result, buffer, buflen, errnop));
 }
 
 /* get a protocol entry by number */
-nss_status_t _nss_ldap_getprotobynumber_r(
-        int number,struct protoent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result,
+                                          char *buffer, size_t buflen,
+                                          int *errnop)
 {
   NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
               number,
-              read_protoent(fp,result,buffer,buflen,errnop));
+              read_protoent(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -76,12 +76,11 @@
 }
 
 /* get a single protocol entry */
-nss_status_t _nss_ldap_getprotoent_r(
-        struct protoent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getprotoent_r(struct protoent *result,
+                                     char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL,
-             read_protoent(protoentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(protoentfp, NSLCD_ACTION_PROTOCOL_ALL,
+             read_protoent(protoentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened by setprotoent() above */
@@ -95,60 +94,60 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *protoent2str(struct protoent *result,char *buffer,size_t buflen)
+static char *protoent2str(struct protoent *result, char *buffer, size_t buflen)
 {
-  int res,i;
-  res=snprintf(buffer,buflen,"%s\t\t%d",result->p_name,result->p_proto);
-  if ((res<0)||(res>=buflen))
+  int res, i;
+  res = snprintf(buffer, buflen, "%s\t\t%d", result->p_name, result->p_proto);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   if (result->p_aliases)
-    for (i=0;result->p_aliases[i];i++)
+    for (i = 0; result->p_aliases[i]; i++)
     {
-      strlcat(buffer," ",buflen);
-      strlcat(buffer,result->p_aliases[i],buflen);
+      strlcat(buffer, " ", buflen);
+      strlcat(buffer, result->p_aliases[i], buflen);
     }
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(protoent,&args->erange);
+  READ_RESULT(protoent, &args->erange);
 }
 
-static nss_status_t protocols_getprotobyname(nss_backend_t UNUSED(*be),void 
*args)
+static nss_status_t protocols_getprotobyname(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYNAME(NSLCD_ACTION_PROTOCOL_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be),void 
*args)
+static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYINT32(NSLCD_ACTION_PROTOCOL_BYNUMBER,
               NSS_ARGS(args)->key.number,
-              read_result(fp,args));
+              read_result(fp, args));
 }
 
-static nss_status_t protocols_setprotoent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t protocols_setprotoent(nss_backend_t *be, void 
UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t protocols_getprotoent(nss_backend_t *be,void *args)
+static nss_status_t protocols_getprotoent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PROTOCOL_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_PROTOCOL_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t protocols_endprotoent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t protocols_endprotoent(nss_backend_t *be, void 
UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t protocols_ops[]={
+static nss_backend_op_t protocols_ops[] = {
   nss_ldap_destructor,
   protocols_endprotoent,
   protocols_setprotoent,
@@ -158,9 +157,10 @@
 };
 
 nss_backend_t *_nss_ldap_protocols_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                          const char UNUSED(*src_name),
+                                          const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(protocols_ops,sizeof(protocols_ops));
+  return nss_ldap_constructor(protocols_ops, sizeof(protocols_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/prototypes.h
==============================================================================
--- nss-pam-ldapd/nss/prototypes.h      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/prototypes.h      Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    prototypes.h - all functions exported by the NSS library
 
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2008, 2010, 2011 Arthur de Jong
+   Copyright (C) 2006, 2008, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -57,78 +57,78 @@
 */
 
 /* aliases - mail aliases */
-nss_status_t _nss_ldap_getaliasbyname_r(const char *name,struct aliasent 
*result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getaliasbyname_r(const char *name, struct aliasent 
*result, char *buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setaliasent(void);
-nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result, char *buffer, 
size_t buflen, int *errnop);
 nss_status_t _nss_ldap_endaliasent(void);
 
 /* ethers - ethernet numbers */
-nss_status_t _nss_ldap_gethostton_r(const char *name,struct etherent 
*result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr,struct 
etherent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_gethostton_r(const char *name, struct etherent *result, 
char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr, struct 
etherent *result, char *buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setetherent(int stayopen);
-nss_status_t _nss_ldap_getetherent_r(struct etherent *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getetherent_r(struct etherent *result, char *buffer, 
size_t buflen, int *errnop);
 nss_status_t _nss_ldap_endetherent(void);
 
 /* group - groups of users */
-nss_status_t _nss_ldap_getgrnam_r(const char *name,struct group *result,char 
*buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getgrgid_r(gid_t gid,struct group *result,char 
*buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_initgroups_dyn(const char *user,gid_t skipgroup,long 
int *start,long int *size,gid_t **groupsp,long int limit,int *errnop);
+nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result, char 
*buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result, char 
*buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup, long 
int *start, long int *size, gid_t **groupsp, long int limit, int *errnop);
 nss_status_t _nss_ldap_setgrent(int stayopen);
-nss_status_t _nss_ldap_getgrent_r(struct group *result,char *buffer,size_t 
buflen,int *errnop);
+nss_status_t _nss_ldap_getgrent_r(struct group *result, char *buffer, size_t 
buflen, int *errnop);
 nss_status_t _nss_ldap_endgrent(void);
 
 /* hosts - host names and numbers */
-nss_status_t _nss_ldap_gethostbyname_r(const char *name,struct hostent 
*result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_gethostbyname2_r(const char *name,int af,struct hostent 
*result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr,socklen_t len,int 
af,struct hostent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_gethostbyname_r(const char *name, struct hostent 
*result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af, struct 
hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len, int 
af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int 
*h_errnop);
 nss_status_t _nss_ldap_sethostent(int stayopen);
-nss_status_t _nss_ldap_gethostent_r(struct hostent *result,char *buffer,size_t 
buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_gethostent_r(struct hostent *result, char *buffer, 
size_t buflen, int *errnop, int *h_errnop);
 nss_status_t _nss_ldap_endhostent(void);
 
 /* netgroup - list of host and users */
-nss_status_t _nss_ldap_setnetgrent(const char *group,struct __netgrent 
*result);
-nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_setnetgrent(const char *group, struct __netgrent 
*result);
+nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result, char *buffer, 
size_t buflen, int *errnop);
 nss_status_t _nss_ldap_endnetgrent(struct __netgrent *result);
 
 /* networks - network names and numbers */
-nss_status_t _nss_ldap_getnetbyname_r(const char *name,struct netent 
*result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
-nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr,int af,struct netent 
*result,char *buffer,size_t buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_getnetbyname_r(const char *name, struct netent *result, 
char *buffer, size_t buflen, int *errnop, int *h_errnop);
+nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int af, struct netent 
*result, char *buffer, size_t buflen, int *errnop, int *h_errnop);
 nss_status_t _nss_ldap_setnetent(int stayopen);
-nss_status_t _nss_ldap_getnetent_r(struct netent *result,char *buffer,size_t 
buflen,int *errnop,int *h_errnop);
+nss_status_t _nss_ldap_getnetent_r(struct netent *result, char *buffer, size_t 
buflen, int *errnop, int *h_errnop);
 nss_status_t _nss_ldap_endnetent(void);
 
 /* passwd - user database and passwords */
-nss_status_t _nss_ldap_getpwnam_r(const char *name,struct passwd *result,char 
*buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getpwuid_r(uid_t uid,struct passwd *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, 
char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, char 
*buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setpwent(int stayopen);
-nss_status_t _nss_ldap_getpwent_r(struct passwd *result,char *buffer,size_t 
buflen,int *errnop);
+nss_status_t _nss_ldap_getpwent_r(struct passwd *result, char *buffer, size_t 
buflen, int *errnop);
 nss_status_t _nss_ldap_endpwent(void);
 
 /* protocols - network protocols */
-nss_status_t _nss_ldap_getprotobyname_r(const char *name,struct protoent 
*result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getprotobynumber_r(int number,struct protoent 
*result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getprotobyname_r(const char *name, struct protoent 
*result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result, 
char *buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setprotoent(int stayopen);
-nss_status_t _nss_ldap_getprotoent_r(struct protoent *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getprotoent_r(struct protoent *result, char *buffer, 
size_t buflen, int *errnop);
 nss_status_t _nss_ldap_endprotoent(void);
 
 /* rpc - remote procedure call names and numbers */
-nss_status_t _nss_ldap_getrpcbyname_r(const char *name,struct rpcent 
*result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getrpcbynumber_r(int number,struct rpcent *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getrpcbyname_r(const char *name, struct rpcent *result, 
char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result, 
char *buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setrpcent(int stayopen);
-nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t 
buflen,int *errnop);
+nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result, char *buffer, size_t 
buflen, int *errnop);
 nss_status_t _nss_ldap_endrpcent(void);
 
 /* services - network services */
-nss_status_t _nss_ldap_getservbyname_r(const char *name,const char 
*protocol,struct servent *result,char *buffer,size_t buflen,int *errnop);
-nss_status_t _nss_ldap_getservbyport_r(int port,const char *protocol,struct 
servent *result,char *buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol, 
struct servent *result, char *buffer, size_t buflen, int *errnop);
+nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol, struct 
servent *result, char *buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setservent(int stayopen);
-nss_status_t _nss_ldap_getservent_r(struct servent *result,char *buffer,size_t 
buflen,int *errnop);
+nss_status_t _nss_ldap_getservent_r(struct servent *result, char *buffer, 
size_t buflen, int *errnop);
 nss_status_t _nss_ldap_endservent(void);
 
 /* shadow - extended user information */
-nss_status_t _nss_ldap_getspnam_r(const char *name,struct spwd *result,char 
*buffer,size_t buflen,int *errnop);
+nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result, char 
*buffer, size_t buflen, int *errnop);
 nss_status_t _nss_ldap_setspent(int stayopen);
-nss_status_t _nss_ldap_getspent_r(struct spwd *result,char *buffer,size_t 
buflen,int *errnop);
+nss_status_t _nss_ldap_getspent_r(struct spwd *result, char *buffer, size_t 
buflen, int *errnop);
 nss_status_t _nss_ldap_endspent(void);
 
 #endif /* NSS_FLAVOUR_GLIBC */
@@ -140,16 +140,16 @@
 #define LDAP_BE(be) ((struct nss_ldap_backend*)(be))
 
 /* these are the constructors we provide */
-nss_backend_t *_nss_ldap_ethers_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_group_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_hosts_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_netgroup_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_networks_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_passwd_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_protocols_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_rpc_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_services_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
-nss_backend_t *_nss_ldap_shadow_constr(const char *db_name,const char 
*src_name,const char *cfg_args);
+nss_backend_t *_nss_ldap_ethers_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_group_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_hosts_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_netgroup_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_networks_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_passwd_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_protocols_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_rpc_constr(const char *db_name, const char *src_name, 
const char *cfg_args);
+nss_backend_t *_nss_ldap_services_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
+nss_backend_t *_nss_ldap_shadow_constr(const char *db_name, const char 
*src_name, const char *cfg_args);
 
 #endif /* NSS_FLAVOUR_SOLARIS */
 

Modified: nss-pam-ldapd/nss/rpc.c
==============================================================================
--- nss-pam-ldapd/nss/rpc.c     Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/rpc.c     Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,39 +31,38 @@
 #include "compat/attrs.h"
 
 /* read a sinlge rpc entry from the stream */
-static nss_status_t read_rpcent(
-        TFILE *fp,struct rpcent *result,
-        char *buffer,size_t buflen,int *errnop)
-{
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct rpcent));
-  READ_BUF_STRING(fp,result->r_name);
-  READ_BUF_STRINGLIST(fp,result->r_aliases);
-  READ_INT32(fp,result->r_number);
+static nss_status_t read_rpcent(TFILE *fp, struct rpcent *result,
+                                char *buffer, size_t buflen, int *errnop)
+{
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct rpcent));
+  READ_BUF_STRING(fp, result->r_name);
+  READ_BUF_STRINGLIST(fp, result->r_aliases);
+  READ_INT32(fp, result->r_number);
   return NSS_STATUS_SUCCESS;
 }
 
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a rpc entry by name */
-nss_status_t _nss_ldap_getrpcbyname_r(
-        const char *name,struct rpcent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcbyname_r(const char *name,
+                                      struct rpcent *result, char *buffer,
+                                      size_t buflen, int *errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
              name,
-             read_rpcent(fp,result,buffer,buflen,errnop));
+             read_rpcent(fp, result, buffer, buflen, errnop));
 }
 
 /* get a rpc entry by number */
-nss_status_t _nss_ldap_getrpcbynumber_r(
-        int number,struct rpcent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result,
+                                        char *buffer, size_t buflen,
+                                        int *errnop)
 {
   NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
               number,
-              read_rpcent(fp,result,buffer,buflen,errnop));
+              read_rpcent(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -76,12 +75,11 @@
 }
 
 /* get an rpc entry from the list */
-nss_status_t _nss_ldap_getrpcent_r(
-        struct rpcent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result,
+                                   char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(rpcentfp,NSLCD_ACTION_RPC_ALL,
-             read_rpcent(rpcentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(rpcentfp, NSLCD_ACTION_RPC_ALL,
+             read_rpcent(rpcentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened by setrpcent() above */
@@ -95,60 +93,60 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *rpcent2str(struct rpcent *result,char *buffer,size_t buflen)
+static char *rpcent2str(struct rpcent *result, char *buffer, size_t buflen)
 {
-  int res,i;
-  res=snprintf(buffer,buflen,"%s %d",result->r_name,result->r_number);
-  if ((res<0)||(res>=buflen))
+  int res, i;
+  res = snprintf(buffer, buflen, "%s %d", result->r_name, result->r_number);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   if (result->r_aliases)
-    for (i=0;result->r_aliases[i];i++)
+    for (i = 0; result->r_aliases[i]; i++)
     {
-      strlcat(buffer," ",buflen);
-      strlcat(buffer,result->r_aliases[i],buflen);
+      strlcat(buffer, " ", buflen);
+      strlcat(buffer, result->r_aliases[i], buflen);
     }
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(rpcent,&args->erange);
+  READ_RESULT(rpcent, &args->erange);
 }
 
-static nss_status_t rpc_getrpcbyname(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t rpc_getrpcbyname(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t rpc_getrpcbynumber(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
               NSS_ARGS(args)->key.number,
-              read_result(fp,args));
+              read_result(fp, args));
 }
 
-static nss_status_t rpc_setrpcent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t rpc_setrpcent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t rpc_getrpcent(nss_backend_t *be,void *args)
+static nss_status_t rpc_getrpcent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_RPC_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_RPC_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t rpc_endrpcent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t rpc_endrpcent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t rpc_ops[]={
+static nss_backend_op_t rpc_ops[] = {
   nss_ldap_destructor,
   rpc_endrpcent,
   rpc_setrpcent,
@@ -158,9 +156,10 @@
 };
 
 nss_backend_t *_nss_ldap_rpc_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                    const char UNUSED(*src_name),
+                                    const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(rpc_ops,sizeof(rpc_ops));
+  return nss_ldap_constructor(rpc_ops, sizeof(rpc_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/services.c
==============================================================================
--- nss-pam-ldapd/nss/services.c        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/services.c        Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,19 +31,18 @@
 #include "compat/attrs.h"
 
 /* read a single services result entry from the stream */
-static nss_status_t read_servent(
-        TFILE *fp,struct servent *result,
-        char *buffer,size_t buflen,int *errnop)
-{
-  int32_t tmpint32,tmp2int32,tmp3int32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct servent));
-  READ_BUF_STRING(fp,result->s_name);
-  READ_BUF_STRINGLIST(fp,result->s_aliases);
+static nss_status_t read_servent(TFILE *fp, struct servent *result,
+                                 char *buffer, size_t buflen, int *errnop)
+{
+  int32_t tmpint32, tmp2int32, tmp3int32;
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct servent));
+  READ_BUF_STRING(fp, result->s_name);
+  READ_BUF_STRINGLIST(fp, result->s_aliases);
   /* store port number in network byte order */
-  READ_INT32(fp,tmp2int32);
-  result->s_port=htons((uint16_t)tmp2int32);;
-  READ_BUF_STRING(fp,result->s_proto);
+  READ_INT32(fp, tmp2int32);
+  result->s_port = htons((uint16_t)tmp2int32);
+  READ_BUF_STRING(fp, result->s_proto);
   /* we're done */
   return NSS_STATUS_SUCCESS;
 }
@@ -51,25 +50,27 @@
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a service entry by name and protocol */
-nss_status_t _nss_ldap_getservbyname_r(
-        const char *name,const char *protocol,struct servent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol,
+                                       struct servent *result, char *buffer,
+                                       size_t buflen, int *errnop)
 {
   NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNAME,
-            WRITE_STRING(fp,name);WRITE_STRING(fp,protocol),
-            read_servent(fp,result,buffer,buflen,errnop));
+            WRITE_STRING(fp, name);
+            WRITE_STRING(fp, protocol),
+            read_servent(fp, result, buffer, buflen, errnop));
 }
 
 /* get a service entry by port and protocol */
-nss_status_t _nss_ldap_getservbyport_r(
-        int port,const char *protocol,struct servent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol,
+                                       struct servent *result, char *buffer,
+                                       size_t buflen, int *errnop)
 {
   /* port is already in network byte order */
   NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNUMBER,
-            tmpint32=ntohs(port);
-            WRITE_INT32(fp,tmpint32);WRITE_STRING(fp,protocol),
-            read_servent(fp,result,buffer,buflen,errnop));
+            tmpint32 = ntohs(port);
+            WRITE_INT32(fp, tmpint32);
+            WRITE_STRING(fp, protocol),
+            read_servent(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -82,12 +83,11 @@
 }
 
 /* read a single returned service definition */
-nss_status_t _nss_ldap_getservent_r(
-        struct servent *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getservent_r(struct servent *result,
+                                    char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(serventfp,NSLCD_ACTION_SERVICE_ALL,
-             read_servent(serventfp,result,buffer,buflen,errnop));
+  NSS_GETENT(serventfp, NSLCD_ACTION_SERVICE_ALL,
+             read_servent(serventfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened by setservent() above */
@@ -101,62 +101,63 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *servent2str(struct servent *result,char *buffer,size_t buflen)
+static char *servent2str(struct servent *result, char *buffer, size_t buflen)
 {
-  int res,i;
-  res=snprintf(buffer,buflen,"%s 
%d/%s",result->s_name,result->s_port,result->s_proto);
-  if ((res<0)||(res>=buflen))
+  int res, i;
+  res = snprintf(buffer, buflen, "%s %d/%s", result->s_name, result->s_port,
+                 result->s_proto);
+  if ((res < 0) || (res >= buflen))
     return NULL;
   if (result->s_aliases)
-    for (i=0;result->s_aliases[i];i++)
+    for (i = 0; result->s_aliases[i]; i++)
     {
-      strlcat(buffer," ",buflen);
-      strlcat(buffer,result->s_aliases[i],buflen);
+      strlcat(buffer, " ", buflen);
+      strlcat(buffer, result->s_aliases[i], buflen);
     }
-  if (strlen(buffer)>=buflen-1)
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(servent,&args->erange);
+  READ_RESULT(servent, &args->erange);
 }
 
-static nss_status_t services_getservbyname(nss_backend_t UNUSED(*be),void 
*args)
+static nss_status_t services_getservbyname(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNAME,
-            WRITE_STRING(fp,NSS_ARGS(args)->key.serv.serv.name);
-            WRITE_STRING(fp,NSS_ARGS(args)->key.serv.proto),
-            read_result(fp,args));
+            WRITE_STRING(fp, NSS_ARGS(args)->key.serv.serv.name);
+            WRITE_STRING(fp, NSS_ARGS(args)->key.serv.proto),
+            read_result(fp, args));
 }
 
-static nss_status_t services_getservbyport(nss_backend_t UNUSED(*be),void 
*args)
+static nss_status_t services_getservbyport(nss_backend_t UNUSED(*be), void 
*args)
 {
   NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNUMBER,
-            WRITE_INT32(fp,ntohs(NSS_ARGS(args)->key.serv.serv.port));
-            WRITE_STRING(fp,NSS_ARGS(args)->key.serv.proto),
-            read_result(fp,args));
+            WRITE_INT32(fp, ntohs(NSS_ARGS(args)->key.serv.serv.port));
+            WRITE_STRING(fp, NSS_ARGS(args)->key.serv.proto),
+            read_result(fp, args));
 }
 
-static nss_status_t services_setservent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t services_setservent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t services_getservent(nss_backend_t *be,void *args)
+static nss_status_t services_getservent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_SERVICE_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_SERVICE_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t services_endservent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t services_endservent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t services_ops[]={
+static nss_backend_op_t services_ops[] = {
   nss_ldap_destructor,
   services_endservent,
   services_setservent,
@@ -166,9 +167,10 @@
 };
 
 nss_backend_t *_nss_ldap_services_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                         const char UNUSED(*src_name),
+                                         const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(services_ops,sizeof(services_ops));
+  return nss_ldap_constructor(services_ops, sizeof(services_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/shadow.c
==============================================================================
--- nss-pam-ldapd/nss/shadow.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/shadow.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -31,35 +31,33 @@
 #include "compat/attrs.h"
 
 /* read a single shadow entry from the stream */
-static nss_status_t read_spwd(
-        TFILE *fp,struct spwd *result,
-        char *buffer,size_t buflen,int *errnop)
+static nss_status_t read_spwd(TFILE *fp, struct spwd *result,
+                              char *buffer, size_t buflen, int *errnop)
 {
   int32_t tmpint32;
-  size_t bufptr=0;
-  memset(result,0,sizeof(struct spwd));
-  READ_BUF_STRING(fp,result->sp_namp);
-  READ_BUF_STRING(fp,result->sp_pwdp);
-  READ_INT32(fp,result->sp_lstchg);
-  READ_INT32(fp,result->sp_min);
-  READ_INT32(fp,result->sp_max);
-  READ_INT32(fp,result->sp_warn);
-  READ_INT32(fp,result->sp_inact);
-  READ_INT32(fp,result->sp_expire);
-  READ_INT32(fp,result->sp_flag);
+  size_t bufptr = 0;
+  memset(result, 0, sizeof(struct spwd));
+  READ_BUF_STRING(fp, result->sp_namp);
+  READ_BUF_STRING(fp, result->sp_pwdp);
+  READ_INT32(fp, result->sp_lstchg);
+  READ_INT32(fp, result->sp_min);
+  READ_INT32(fp, result->sp_max);
+  READ_INT32(fp, result->sp_warn);
+  READ_INT32(fp, result->sp_inact);
+  READ_INT32(fp, result->sp_expire);
+  READ_INT32(fp, result->sp_flag);
   return NSS_STATUS_SUCCESS;
 }
 
 #ifdef NSS_FLAVOUR_GLIBC
 
 /* get a shadow entry by name */
-nss_status_t _nss_ldap_getspnam_r(
-        const char *name,struct spwd *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
   NSS_BYNAME(NSLCD_ACTION_SHADOW_BYNAME,
              name,
-             read_spwd(fp,result,buffer,buflen,errnop));
+             read_spwd(fp, result, buffer, buflen, errnop));
 }
 
 /* thread-local file pointer to an ongoing request */
@@ -72,12 +70,11 @@
 }
 
 /* return a single shadow entry read from the stream */
-nss_status_t _nss_ldap_getspent_r(
-        struct spwd *result,
-        char *buffer,size_t buflen,int *errnop)
+nss_status_t _nss_ldap_getspent_r(struct spwd *result,
+                                  char *buffer, size_t buflen, int *errnop)
 {
-  NSS_GETENT(spentfp,NSLCD_ACTION_SHADOW_ALL,
-             read_spwd(spentfp,result,buffer,buflen,errnop));
+  NSS_GETENT(spentfp, NSLCD_ACTION_SHADOW_ALL,
+             read_spwd(spentfp, result, buffer, buflen, errnop));
 }
 
 /* close the stream opened by setspent() above */
@@ -91,65 +88,65 @@
 #ifdef NSS_FLAVOUR_SOLARIS
 
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-static char *spwd2str(struct spwd *result,char *buffer,size_t buflen)
+static char *spwd2str(struct spwd *result, char *buffer, size_t buflen)
 {
   /* snprintf writes a terminating \0 on Solaris */
-  snprintf(buffer,buflen,"%s:%s:",result->sp_namp,result->sp_pwdp);
-  if (result->sp_lstchg>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_lstchg);
-  strlcat(buffer,":",buflen);
-  if (result->sp_min>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_min);
-  strlcat(buffer,":",buflen);
-  if (result->sp_max>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_max);
-  strlcat(buffer,":",buflen);
-  if (result->sp_warn>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_warn);
-  strlcat(buffer,":",buflen);
-  if (result->sp_inact>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_inact);
-  strlcat(buffer,":",buflen);
-  if (result->sp_expire>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%d:",result->sp_expire);
-  strlcat(buffer,":",buflen);
-  if (result->sp_flag>=0)
-    snprintf(buffer,buflen-strlen(buffer)-1,"%x",result->sp_flag);
-  if (strlen(buffer)>=buflen-1)
+  snprintf(buffer, buflen, "%s:%s:", result->sp_namp, result->sp_pwdp);
+  if (result->sp_lstchg >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_lstchg);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_min >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_min);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_max >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_max);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_warn >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_warn);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_inact >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_inact);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_expire >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%d:", result->sp_expire);
+  strlcat(buffer, ":", buflen);
+  if (result->sp_flag >= 0)
+    snprintf(buffer, buflen - strlen(buffer) - 1, "%x", result->sp_flag);
+  if (strlen(buffer) >= buflen - 1)
     return NULL;
   return buffer;
 }
 #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
-static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args)
+static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args)
 {
-  READ_RESULT(spwd,&args->erange);
+  READ_RESULT(spwd, &args->erange);
 }
 
-static nss_status_t shadow_getspnam(nss_backend_t UNUSED(*be),void *args)
+static nss_status_t shadow_getspnam(nss_backend_t UNUSED(*be), void *args)
 {
   NSS_BYNAME(NSLCD_ACTION_SHADOW_BYNAME,
              NSS_ARGS(args)->key.name,
-             read_result(fp,args));
+             read_result(fp, args));
 }
 
-static nss_status_t shadow_setspent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t shadow_setspent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_SETENT(LDAP_BE(be)->fp);
 }
 
-static nss_status_t shadow_getspent(nss_backend_t *be,void *args)
+static nss_status_t shadow_getspent(nss_backend_t *be, void *args)
 {
-  NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_SHADOW_ALL,
-             read_result(LDAP_BE(be)->fp,args));
+  NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_SHADOW_ALL,
+             read_result(LDAP_BE(be)->fp, args));
 }
 
-static nss_status_t shadow_endspent(nss_backend_t *be,void UNUSED(*args))
+static nss_status_t shadow_endspent(nss_backend_t *be, void UNUSED(*args))
 {
   NSS_ENDENT(LDAP_BE(be)->fp);
 }
 
-static nss_backend_op_t shadow_ops[]={
+static nss_backend_op_t shadow_ops[] = {
   nss_ldap_destructor,
   shadow_endspent,
   shadow_setspent,
@@ -158,9 +155,10 @@
 };
 
 nss_backend_t *_nss_ldap_shadow_constr(const char UNUSED(*db_name),
-                  const char UNUSED(*src_name),const char UNUSED(*cfg_args))
+                                       const char UNUSED(*src_name),
+                                       const char UNUSED(*cfg_args))
 {
-  return nss_ldap_constructor(shadow_ops,sizeof(shadow_ops));
+  return nss_ldap_constructor(shadow_ops, sizeof(shadow_ops));
 }
 
 #endif /* NSS_FLAVOUR_SOLARIS */

Modified: nss-pam-ldapd/nss/solnss.c
==============================================================================
--- nss-pam-ldapd/nss/solnss.c  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/solnss.c  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    solnss.c - Solaris specific NSS interface functions
 
-   Copyright (C) 2010 Arthur de Jong
+   Copyright (C) 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -27,22 +27,22 @@
 #include "common.h"
 #include "compat/attrs.h"
 
-nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops)
+nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops, size_t sizeofops)
 {
   struct nss_ldap_backend *ldapbe;
-  ldapbe=(struct nss_ldap_backend *)malloc(sizeof(struct nss_ldap_backend));
-  if (ldapbe==NULL)
+  ldapbe = (struct nss_ldap_backend *)malloc(sizeof(struct nss_ldap_backend));
+  if (ldapbe == NULL)
     return NULL;
-  ldapbe->ops=ops;
-  ldapbe->n_ops=sizeofops/sizeof(nss_backend_op_t);
-  ldapbe->fp=NULL;
+  ldapbe->ops = ops;
+  ldapbe->n_ops = sizeofops / sizeof(nss_backend_op_t);
+  ldapbe->fp = NULL;
   return (nss_backend_t *)ldapbe;
 }
 
-nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args))
+nss_status_t nss_ldap_destructor(nss_backend_t *be, void UNUSED(*args))
 {
-  struct nss_ldap_backend *ldapbe=(struct nss_ldap_backend *)be;
-  if (ldapbe->fp!=NULL)
+  struct nss_ldap_backend *ldapbe = (struct nss_ldap_backend *)be;
+  if (ldapbe->fp != NULL)
     (void)tio_close(ldapbe->fp);
   free(ldapbe);
   return NSS_STATUS_SUCCESS;

Modified: nss-pam-ldapd/nss/solnss.h
==============================================================================
--- nss-pam-ldapd/nss/solnss.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/nss/solnss.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -26,87 +26,88 @@
 /* extra definitions we need (Solaris NSS functions don't pass errno)
    also clear the output values */
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-#define NSS_EXTRA_DEFS                \
-  int *errnop=&(errno);               \
-  NSS_ARGS(args)->returnval=NULL;     \
-  NSS_ARGS(args)->returnlen=0;        \
-  NSS_ARGS(args)->erange=0;           \
-  NSS_ARGS(args)->h_errno=0;
+#define NSS_EXTRA_DEFS                                                      \
+  int *errnop = &(errno);                                                   \
+  NSS_ARGS(args)->returnval = NULL;                                         \
+  NSS_ARGS(args)->returnlen = 0;                                            \
+  NSS_ARGS(args)->erange = 0;                                               \
+  NSS_ARGS(args)->h_errno = 0;
 #else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-#define NSS_EXTRA_DEFS                \
-  int *errnop=&(errno);               \
-  NSS_ARGS(args)->returnval=NULL;     \
-  NSS_ARGS(args)->erange=0;           \
-  NSS_ARGS(args)->h_errno=0;
+#define NSS_EXTRA_DEFS                                                      \
+  int *errnop = &(errno);                                                   \
+  NSS_ARGS(args)->returnval = NULL;                                         \
+  NSS_ARGS(args)->erange = 0;                                               \
+  NSS_ARGS(args)->h_errno = 0;
 #endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
 /* check validity of passed buffer (Solaris flavour) */
 #define NSS_BUFCHECK                                                        \
-  if ((NSS_ARGS(args)->buf.buffer==NULL)||(NSS_ARGS(args)->buf.buflen<=0))  \
+  if ((NSS_ARGS(args)->buf.buffer == NULL) ||                               \
+      (NSS_ARGS(args)->buf.buflen <= 0))                                    \
   {                                                                         \
-    NSS_ARGS(args)->erange=1;                                               \
+    NSS_ARGS(args)->erange = 1;                                             \
     return NSS_STATUS_TRYAGAIN;                                             \
   }
 
 /* wrapper function body for read_xxxent that does the buffer handling,
    return code handling and conversion to strings for nscd
    (also see READ_RESULT_STRING below) */
-#define READ_RESULT(ent,extra...)                                           \
+#define READ_RESULT(ent, extra...)                                          \
   nss_status_t retv;                                                        \
-  READ_RESULT_STRING(ent,##extra)                                           \
+  READ_RESULT_STRING(ent, ##extra)                                          \
   /* read the entry */                                                      \
-  
retv=read_##ent(fp,args->buf.result,args->buf.buffer,args->buf.buflen,##extra); 
\
-  if (retv!=NSS_STATUS_SUCCESS)                                             \
-    return retv; \
-  args->returnval=args->buf.result; \
+  retv = read_##ent(fp, args->buf.result, args->buf.buffer,                 \
+                    args->buf.buflen, ##extra);                             \
+  if (retv != NSS_STATUS_SUCCESS)                                           \
+    return retv;                                                            \
+  args->returnval = args->buf.result;                                       \
   return NSS_STATUS_SUCCESS;
 
 /* provide result handling for when libc (or nscd) expects the returned
    values to be in string format */
 #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN
-#define READ_RESULT_STRING(ent,extra...) \
-  struct ent result; \
-  char *buffer; \
-  /* try to return in string format if requested */ \
-  if (args->buf.result==NULL) \
-  { \
-    /* read the entry into a temporary buffer */ \
-    buffer=(char *)malloc(args->buf.buflen); \
-    if (buffer==NULL) \
-      return NSS_STATUS_UNAVAIL; \
-    retv=read_##ent(fp,&result,buffer,args->buf.buflen,##extra); \
-    /* format to string */ \
-    if (retv==NSS_STATUS_SUCCESS) \
-      if (ent##2str(&result,args->buf.buffer,args->buf.buflen)==NULL) \
-      { \
-        args->erange=1; \
-        retv=NSS_NOTFOUND; \
-      } \
-    /* clean up and return result */ \
-    free(buffer); \
-    if (retv!=NSS_STATUS_SUCCESS) \
-      return retv; \
-    args->returnval=args->buf.buffer; \
-    args->returnlen=strlen(args->returnval); \
-    return NSS_STATUS_SUCCESS; \
+#define READ_RESULT_STRING(ent, extra...)                                   \
+  struct ent result;                                                        \
+  char *buffer;                                                             \
+  /* try to return in string format if requested */                         \
+  if (args->buf.result == NULL)                                             \
+  {                                                                         \
+    /* read the entry into a temporary buffer */                            \
+    buffer = (char *)malloc(args->buf.buflen);                              \
+    if (buffer == NULL)                                                     \
+      return NSS_STATUS_UNAVAIL;                                            \
+    retv = read_##ent(fp, &result, buffer, args->buf.buflen, ##extra);      \
+    /* format to string */                                                  \
+    if (retv == NSS_STATUS_SUCCESS)                                         \
+      if (ent##2str(&result, args->buf.buffer, args->buf.buflen) == NULL)   \
+      {                                                                     \
+        args->erange = 1;                                                   \
+        retv = NSS_NOTFOUND;                                                \
+      }                                                                     \
+    /* clean up and return result */                                        \
+    free(buffer);                                                           \
+    if (retv != NSS_STATUS_SUCCESS)                                         \
+      return retv;                                                          \
+    args->returnval = args->buf.buffer;                                     \
+    args->returnlen = strlen(args->returnval);                              \
+    return NSS_STATUS_SUCCESS;                                              \
   }
 #else /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
-#define READ_RESULT_STRING(ent,extra...) ;
+#define READ_RESULT_STRING(ent, extra...) ;
 #endif /* not HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */
 
 /* this is the backend structure for Solaris */
-struct nss_ldap_backend
-{
-  nss_backend_op_t *ops; /* function-pointer table */
-  int n_ops; /* number of function pointers */
-  TFILE *fp; /* the file pointer for {set,get,end}ent() functions */
+struct nss_ldap_backend {
+  nss_backend_op_t *ops;  /* function-pointer table */
+  int n_ops;              /* number of function pointers */
+  TFILE *fp;              /* file pointer for {set,get,end}ent() functions */
 };
 
 /* constructor for LDAP backends */
-nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops,size_t sizeofops);
+nss_backend_t *nss_ldap_constructor(nss_backend_op_t *ops, size_t sizeofops);
 
 /* destructor for LDAP backends */
-nss_status_t nss_ldap_destructor(nss_backend_t *be,void UNUSED(*args));
+nss_status_t nss_ldap_destructor(nss_backend_t *be, void UNUSED(*args));
 
 #endif /* NSS_FLAVOUR_SOLARIS */
 #endif /* not NSS__COMMON_H */

Modified: nss-pam-ldapd/pam/common.h
==============================================================================
--- nss-pam-ldapd/pam/common.h  Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/pam/common.h  Sat Dec 22 22:38:26 2012        (r1873)
@@ -1,7 +1,7 @@
 /*
    common.h - common functions for PAM lookups
 
-   Copyright (C) 2009, 2010, 2011 Arthur de Jong
+   Copyright (C) 2009, 2010, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -34,35 +34,38 @@
    an error status. */
 
 /* Macro is called to handle errors in opening a client connection. */
-#define ERROR_OUT_OPENERROR \
-  pam_syslog(pamh,LOG_ERR,"error opening connection to nslcd: 
%s",strerror(errno)); \
+#define ERROR_OUT_OPENERROR                                                 \
+  pam_syslog(pamh, LOG_ERR, "error opening connection to nslcd: %s",        \
+             strerror(errno));                                              \
   return PAM_AUTHINFO_UNAVAIL;
 
 /* Macro is called to handle errors on read operations. */
-#define ERROR_OUT_READERROR(fp) \
-  pam_syslog(pamh,LOG_ERR,"error reading from nslcd: %s",strerror(errno)); \
-  (void)tio_close(fp); \
+#define ERROR_OUT_READERROR(fp)                                             \
+  pam_syslog(pamh, LOG_ERR, "error reading from nslcd: %s",                 \
+             strerror(errno));                                              \
+  (void)tio_close(fp);                                                      \
   return PAM_AUTHINFO_UNAVAIL;
 
 /* Macro is called to handle problems with too small a buffer. */
-#define ERROR_OUT_BUFERROR(fp) \
-  pam_syslog(pamh,LOG_CRIT,"buffer %d bytes too small",tmpint32); \
-  (void)tio_close(fp); \
+#define ERROR_OUT_BUFERROR(fp)                                              \
+  pam_syslog(pamh, LOG_CRIT, "buffer %d bytes too small", tmpint32);        \
+  (void)tio_close(fp);                                                      \
   return PAM_SYSTEM_ERR;
 
 /* This macro is called if there was a problem with a write
    operation. */
-#define ERROR_OUT_WRITEERROR(fp) \
-  pam_syslog(pamh,LOG_ERR,"error writing to nslcd: %s",strerror(errno)); \
-  (void)tio_close(fp); \
+#define ERROR_OUT_WRITEERROR(fp)                                            \
+  pam_syslog(pamh, LOG_ERR, "error writing to nslcd: %s",                   \
+             strerror(errno));                                              \
+  (void)tio_close(fp);                                                      \
   return PAM_AUTHINFO_UNAVAIL;
 
 /* This macro is called if the read status code is not
    NSLCD_RESULT_BEGIN. */
-#define ERROR_OUT_NOSUCCESS(fp) \
-  (void)tio_close(fp); \
-  if (cfg->debug) \
-    pam_syslog(pamh,LOG_DEBUG,"user not handled by nslcd"); \
+#define ERROR_OUT_NOSUCCESS(fp)                                             \
+  (void)tio_close(fp);                                                      \
+  if (cfg->debug)                                                           \
+    pam_syslog(pamh, LOG_DEBUG, "user not handled by nslcd");               \
   return PAM_USER_UNKNOWN;
 
 /* This is a generic PAM request generation macro. The action
@@ -73,25 +76,25 @@
    the result structure, the user buffer with length and the
    errno to return. This macro should be called through some of
    the customized ones below. */
-#define PAM_REQUEST(action,debuglog,writefn,readfn) \
-  TFILE *fp; \
-  int32_t tmpint32; \
-  if (cfg->debug) \
-    debuglog; \
-  /* open socket and write request */ \
-  NSLCD_REQUEST(fp,action,writefn); \
-  /* read response code */ \
-  READ_RESPONSE_CODE(fp); \
-  /* read the response */ \
-  readfn; \
-  /* close socket and we're done */ \
-  (void)tio_close(fp); \
+#define PAM_REQUEST(action, debuglog, writefn, readfn)                      \
+  TFILE *fp;                                                                \
+  int32_t tmpint32;                                                         \
+  if (cfg->debug)                                                           \
+    debuglog;                                                               \
+  /* open socket and write request */                                       \
+  NSLCD_REQUEST(fp, action, writefn);                                       \
+  /* read response code */                                                  \
+  READ_RESPONSE_CODE(fp);                                                   \
+  /* read the response */                                                   \
+  readfn;                                                                   \
+  /* close socket and we're done */                                         \
+  (void)tio_close(fp);                                                      \
   return PAM_SUCCESS;
 
 /* helper macro to read PAM status code (auto-translated from NSLCD PAM
    status code */
-#define READ_PAM_CODE(fp,i) \
-  READ(fp,&tmpint32,sizeof(int32_t)); \
-  (i)=nslcd2pam_rc(pamh,ntohl(tmpint32));
+#define READ_PAM_CODE(fp, i)                                                \
+  READ(fp, &tmpint32, sizeof(int32_t));                                     \
+  (i) = nslcd2pam_rc(pamh, ntohl(tmpint32));
 
 #endif /* not PAM__COMMON_H */

Modified: nss-pam-ldapd/pam/pam.c
==============================================================================
--- nss-pam-ldapd/pam/pam.c     Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/pam/pam.c     Sat Dec 22 22:38:26 2012        (r1873)
@@ -77,66 +77,68 @@
   if (ctx->username)
   {
     free(ctx->username);
-    ctx->username=NULL;
+    ctx->username = NULL;
   }
-  ctx->saved_authz.res=PAM_SUCCESS;
-  memset(ctx->saved_authz.msg,0,sizeof(ctx->saved_authz.msg));
-  ctx->saved_session.res=PAM_SUCCESS;
-  memset(ctx->saved_session.msg,0,sizeof(ctx->saved_session.msg));
-  ctx->asroot=0;
+  ctx->saved_authz.res = PAM_SUCCESS;
+  memset(ctx->saved_authz.msg, 0, sizeof(ctx->saved_authz.msg));
+  ctx->saved_session.res = PAM_SUCCESS;
+  memset(ctx->saved_session.msg, 0, sizeof(ctx->saved_session.msg));
+  ctx->asroot = 0;
   if (ctx->oldpassword)
   {
-    memset(ctx->oldpassword,0,strlen(ctx->oldpassword));
+    memset(ctx->oldpassword, 0, strlen(ctx->oldpassword));
     free(ctx->oldpassword);
-    ctx->oldpassword=NULL;
+    ctx->oldpassword = NULL;
   }
 }
 
 /* free the context (this is installed as handler into PAM) */
-static void ctx_free(pam_handle_t UNUSED(*pamh),void *data,int UNUSED(err))
+static void ctx_free(pam_handle_t UNUSED(*pamh), void *data, int UNUSED(err))
 {
-  struct pld_ctx *ctx=data;
+  struct pld_ctx *ctx = data;
   ctx_clear(ctx);
   free(ctx);
 }
 
 /* try to get the module's context, returns a PAM status code */
-static int ctx_get(pam_handle_t *pamh,const char *username,struct pld_ctx 
**pctx)
+static int ctx_get(pam_handle_t *pamh, const char *username, struct pld_ctx 
**pctx)
 {
-  struct pld_ctx *ctx=NULL;
+  struct pld_ctx *ctx = NULL;
   int rc;
   /* try to get the context from PAM */
-  rc=pam_get_data(pamh,PLD_CTX,(const void **)&ctx);
-  if ((rc==PAM_SUCCESS)&&(ctx!=NULL))
+  rc = pam_get_data(pamh, PLD_CTX, (const void **)&ctx);
+  if ((rc == PAM_SUCCESS) && (ctx != NULL))
   {
     /* if the user is different clear the context */
-    if ((ctx->username!=NULL)&&(strcmp(ctx->username,username)!=0))
+    if ((ctx->username != NULL) && (strcmp(ctx->username, username) != 0))
       ctx_clear(ctx);
   }
   else
   {
     /* allocate a new context */
-    ctx=calloc(1,sizeof(struct pld_ctx));
-    if (ctx==NULL)
+    ctx = calloc(1, sizeof(struct pld_ctx));
+    if (ctx == NULL)
     {
-      pam_syslog(pamh,LOG_CRIT,"calloc(): failed to allocate memory: 
%s",strerror(errno));
+      pam_syslog(pamh, LOG_CRIT, "calloc(): failed to allocate memory: %s",
+                 strerror(errno));
       return PAM_BUF_ERR;
     }
     ctx_clear(ctx);
     /* store the new context with the handler to free it */
-    rc=pam_set_data(pamh,PLD_CTX,ctx,ctx_free);
-    if (rc!=PAM_SUCCESS)
+    rc = pam_set_data(pamh, PLD_CTX, ctx, ctx_free);
+    if (rc != PAM_SUCCESS)
     {
-      ctx_free(pamh,ctx,0);
-      pam_syslog(pamh,LOG_ERR,"failed to store context: 
%s",pam_strerror(pamh,rc));
+      ctx_free(pamh, ctx, 0);
+      pam_syslog(pamh, LOG_ERR, "failed to store context: %s",
+                 pam_strerror(pamh, rc));
       return rc;
     }
   }
   /* save the username in the context */
-  if (ctx->username==NULL)
-    ctx->username=strdup(username);
+  if (ctx->username == NULL)
+    ctx->username = strdup(username);
   /* return the context */
-  *pctx=ctx;
+  *pctx = ctx;
   return PAM_SUCCESS;
 }
 
@@ -150,98 +152,102 @@
   uid_t minimum_uid;
 };
 
-static void cfg_init(pam_handle_t *pamh,int flags,int argc,const char **argv,
+static void cfg_init(pam_handle_t *pamh, int flags,
+                     int argc, const char **argv,
                      struct pld_cfg *cfg)
 {
   int i;
   /* initialise config with defaults */
-  cfg->nullok=0;
-  cfg->no_warn=0;
-  cfg->ignore_unknown_user=0;
-  cfg->ignore_authinfo_unavail=0;
-  cfg->debug=0;
-  cfg->minimum_uid=0;
+  cfg->nullok = 0;
+  cfg->no_warn = 0;
+  cfg->ignore_unknown_user = 0;
+  cfg->ignore_authinfo_unavail = 0;
+  cfg->debug = 0;
+  cfg->minimum_uid = 0;
   /* go over arguments */
-  for (i=0;i<argc;i++)
+  for (i = 0; i < argc; i++)
   {
-    if (strcmp(argv[i],"use_first_pass")==0)
-      /* ignore, this option is used by pam_get_authtok() internally */;
-    else if (strcmp(argv[i],"try_first_pass")==0)
-      /* ignore, this option is used by pam_get_authtok() internally */;
-    else if (strcmp(argv[i],"nullok")==0)
-      cfg->nullok=1;
-    else if (strcmp(argv[i],"use_authtok")==0)
-      /* ignore, this option is used by pam_get_authtok() internally */;
-    else if (strcmp(argv[i],"no_warn")==0)
-      cfg->no_warn=1;
-    else if (strcmp(argv[i],"ignore_unknown_user")==0)
-      cfg->ignore_unknown_user=1;
-    else if (strcmp(argv[i],"ignore_authinfo_unavail")==0)
-      cfg->ignore_authinfo_unavail=1;
-    else if (strcmp(argv[i],"debug")==0)
-      cfg->debug=1;
-    else if (strncmp(argv[i],"minimum_uid=",12) == 0)
-      cfg->minimum_uid=(uid_t)atoi(argv[i]+12);
+    if (strcmp(argv[i], "use_first_pass") == 0)
+      /* ignore, this option is used by pam_get_authtok() internally */ ;
+    else if (strcmp(argv[i], "try_first_pass") == 0)
+      /* ignore, this option is used by pam_get_authtok() internally */ ;
+    else if (strcmp(argv[i], "nullok") == 0)
+      cfg->nullok = 1;
+    else if (strcmp(argv[i], "use_authtok") == 0)
+      /* ignore, this option is used by pam_get_authtok() internally */ ;
+    else if (strcmp(argv[i], "no_warn") == 0)
+      cfg->no_warn = 1;
+    else if (strcmp(argv[i], "ignore_unknown_user") == 0)
+      cfg->ignore_unknown_user = 1;
+    else if (strcmp(argv[i], "ignore_authinfo_unavail") == 0)
+      cfg->ignore_authinfo_unavail = 1;
+    else if (strcmp(argv[i], "debug") == 0)
+      cfg->debug = 1;
+    else if (strncmp(argv[i], "minimum_uid=", 12) == 0)
+      cfg->minimum_uid = (uid_t)atoi(argv[i] + 12);
     else
-      pam_syslog(pamh,LOG_ERR,"unknown option: %s",argv[i]);
+      pam_syslog(pamh, LOG_ERR, "unknown option: %s", argv[i]);
   }
   /* check flags */
-  if (flags&PAM_SILENT)
-    cfg->no_warn=1;
+  if (flags & PAM_SILENT)
+    cfg->no_warn = 1;
 }
 
-static int init(pam_handle_t *pamh,struct pld_cfg *cfg,struct pld_ctx **ctx,
-                const char **username,const char **service,const char **ruser,
-                const char **rhost,const char **tty)
+static int init(pam_handle_t *pamh, struct pld_cfg *cfg, struct pld_ctx **ctx,
+                const char **username, const char **service, const char 
**ruser,
+                const char **rhost, const char **tty)
 {
   int rc;
   struct passwd *pwent;
   /* get user name */
-  rc=pam_get_user(pamh,username,NULL);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_user(pamh, username, NULL);
+  if (rc != PAM_SUCCESS)
   {
-    pam_syslog(pamh,LOG_ERR,"failed to get user name: 
%s",pam_strerror(pamh,rc));
+    pam_syslog(pamh, LOG_ERR, "failed to get user name: %s", 
pam_strerror(pamh, rc));
     return rc;
   }
-  if ((*username==NULL)||((*username)[0]=='\0'))
+  if ((*username == NULL) || ((*username)[0] == '\0'))
   {
-    pam_syslog(pamh,LOG_ERR,"got empty user name");
+    pam_syslog(pamh, LOG_ERR, "got empty user name");
     return PAM_USER_UNKNOWN;
   }
   /* check uid */
-  if (cfg->minimum_uid>0)
+  if (cfg->minimum_uid > 0)
   {
-    pwent=pam_modutil_getpwnam(args->pamh,*username);
-    if ((pwent!=NULL)&&(pwent->pw_uid<cfg->minimum_uid))
+    pwent = pam_modutil_getpwnam(args->pamh, *username);
+    if ((pwent != NULL) && (pwent->pw_uid < cfg->minimum_uid))
     {
       if (cfg->debug)
-        pam_syslog(pamh,LOG_DEBUG,"uid below minimum_uid; user=%s 
uid=%ld",*username,(long)pwent->pw_uid);
-      return cfg->ignore_unknown_user?PAM_IGNORE:PAM_USER_UNKNOWN;
+        pam_syslog(pamh, LOG_DEBUG, "uid below minimum_uid; user=%s uid=%ld",
+                   *username, (long)pwent->pw_uid);
+      return cfg->ignore_unknown_user ? PAM_IGNORE : PAM_USER_UNKNOWN;
     }
   }
   /* get our context */
-  rc=ctx_get(pamh,*username,ctx);
-  if (rc!=PAM_SUCCESS)
+  rc = ctx_get(pamh, *username, ctx);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* get service name */
-  rc=pam_get_item(pamh,PAM_SERVICE,(const void **)service);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_item(pamh, PAM_SERVICE, (const void **)service);
+  if (rc != PAM_SUCCESS)
   {
-    pam_syslog(pamh,LOG_ERR,"failed to get service name: 
%s",pam_strerror(pamh,rc));
+    pam_syslog(pamh, LOG_ERR, "failed to get service name: %s",
+               pam_strerror(pamh, rc));
     return rc;
   }
   /* get more PAM information (ignore errors) */
-  pam_get_item(pamh,PAM_RUSER,(const void **)ruser);
-  pam_get_item(pamh,PAM_RHOST,(const void **)rhost);
-  pam_get_item(pamh,PAM_TTY,(const void **)tty);
+  pam_get_item(pamh, PAM_RUSER, (const void **)ruser);
+  pam_get_item(pamh, PAM_RHOST, (const void **)rhost);
+  pam_get_item(pamh, PAM_TTY, (const void **)tty);
   return PAM_SUCCESS;
 }
 
 /* map a NSLCD PAM status code to a PAM status code */
-static int nslcd2pam_rc(pam_handle_t *pamh,int rc)
+static int nslcd2pam_rc(pam_handle_t *pamh, int rc)
 {
 #define map(i) case NSLCD_##i: return i;
-  switch(rc) {
+  switch (rc)
+  {
     map(PAM_SUCCESS);
     map(PAM_PERM_DENIED);
     map(PAM_AUTH_ERR);
@@ -258,488 +264,526 @@
     map(PAM_ABORT);
     map(PAM_AUTHTOK_EXPIRED);
     default:
-      pam_syslog(pamh,LOG_ERR,"unknown NSLCD_PAM_* code returned: %d",rc);
+      pam_syslog(pamh, LOG_ERR, "unknown NSLCD_PAM_* code returned: %d", rc);
       return PAM_ABORT;
   }
 }
 
 /* check whether the specified user is handled by nslcd */
-static int nslcd_request_exists(pam_handle_t *pamh,struct pld_ctx *ctx,struct 
pld_cfg *cfg,
-                                const char *username)
+static int nslcd_request_exists(pam_handle_t *pamh, struct pld_ctx *ctx,
+                                struct pld_cfg *cfg, const char *username)
 {
-  PAM_REQUEST(NSLCD_ACTION_PASSWD_BYNAME,
+  PAM_REQUEST(
+    NSLCD_ACTION_PASSWD_BYNAME,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd account check; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd account check; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username),
+    WRITE_STRING(fp, username),
     /* read the result entry (skip it completely) */
-    SKIP_STRING(fp); /* user name */
-    SKIP_STRING(fp); /* passwd entry */
-    SKIP(fp,sizeof(int32_t)); /* uid */
-    SKIP(fp,sizeof(int32_t)); /* gid */
-    SKIP_STRING(fp); /* gecos */
-    SKIP_STRING(fp); /* home dir */
-    SKIP_STRING(fp); /* shell */
+    SKIP_STRING(fp);            /* user name */
+    SKIP_STRING(fp);            /* passwd entry */
+    SKIP(fp, sizeof(int32_t));  /* uid */
+    SKIP(fp, sizeof(int32_t));  /* gid */
+    SKIP_STRING(fp);            /* gecos */
+    SKIP_STRING(fp);            /* home dir */
+    SKIP_STRING(fp);            /* shell */
   )
 }
 
 /* perform an authentication call over nslcd */
-static int nslcd_request_authc(pam_handle_t *pamh,struct pld_cfg *cfg,
-                               const char *username,const char *service,
-                               const char *ruser,const char *rhost,
-                               const char *tty,const char *passwd,
+static int nslcd_request_authc(pam_handle_t *pamh, struct pld_cfg *cfg,
+                               const char *username, const char *service,
+                               const char *ruser, const char *rhost,
+                               const char *tty, const char *passwd,
                                struct nslcd_resp *authc_resp,
                                struct nslcd_resp *authz_resp)
 {
-  PAM_REQUEST(NSLCD_ACTION_PAM_AUTHC,
+  PAM_REQUEST(
+    NSLCD_ACTION_PAM_AUTHC,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd authentication; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd authentication; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username);
-    WRITE_STRING(fp,service);
-    WRITE_STRING(fp,ruser);
-    WRITE_STRING(fp,rhost);
-    WRITE_STRING(fp,tty);
-    WRITE_STRING(fp,passwd),
+    WRITE_STRING(fp, username);
+    WRITE_STRING(fp, service);
+    WRITE_STRING(fp, ruser);
+    WRITE_STRING(fp, rhost);
+    WRITE_STRING(fp, tty);
+    WRITE_STRING(fp, passwd),
     /* read the result entry */
-    READ_PAM_CODE(fp,authc_resp->res);
-    READ_STRING(fp,authc_resp->msg); /* user name */
+    READ_PAM_CODE(fp, authc_resp->res);
+    READ_STRING(fp, authc_resp->msg); /* user name */
     /* if we want the authorisation response, save it, otherwise skip it */
-    if (authz_resp!=NULL)
+    if (authz_resp != NULL)
     {
-      READ_PAM_CODE(fp,authz_resp->res);
-      READ_STRING(fp,authz_resp->msg);
+      READ_PAM_CODE(fp, authz_resp->res);
+      READ_STRING(fp, authz_resp->msg);
     }
     else
     {
-      SKIP(fp,sizeof(int32_t));
+      SKIP(fp, sizeof(int32_t));
       SKIP_STRING(fp);
-    })
+    }
+  )
 }
 
 /* perform an authorisation call over nslcd */
-static int nslcd_request_authz(pam_handle_t *pamh,struct pld_cfg *cfg,
-                               const char *username,const char *service,
-                               const char *ruser,const char *rhost,
-                               const char *tty,struct nslcd_resp *resp)
+static int nslcd_request_authz(pam_handle_t *pamh, struct pld_cfg *cfg,
+                               const char *username, const char *service,
+                               const char *ruser, const char *rhost,
+                               const char *tty, struct nslcd_resp *resp)
 {
-  PAM_REQUEST(NSLCD_ACTION_PAM_AUTHZ,
+  PAM_REQUEST(
+    NSLCD_ACTION_PAM_AUTHZ,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd authorisation; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd authorisation; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username);
-    WRITE_STRING(fp,service);
-    WRITE_STRING(fp,ruser);
-    WRITE_STRING(fp,rhost);
-    WRITE_STRING(fp,tty),
+    WRITE_STRING(fp, username);
+    WRITE_STRING(fp, service);
+    WRITE_STRING(fp, ruser);
+    WRITE_STRING(fp, rhost);
+    WRITE_STRING(fp, tty),
     /* read the result entry */
-    READ_PAM_CODE(fp,resp->res);
-    READ_STRING(fp,resp->msg);)
+    READ_PAM_CODE(fp, resp->res);
+    READ_STRING(fp, resp->msg);
+  )
 }
 
 /* do a session open nslcd request */
-static int nslcd_request_sess_o(pam_handle_t *pamh,struct pld_cfg *cfg,
-                               const char *username,const char *service,
-                               const char *ruser,const char *rhost,
-                               const char *tty,struct nslcd_resp *resp)
+static int nslcd_request_sess_o(pam_handle_t *pamh, struct pld_cfg *cfg,
+                                const char *username, const char *service,
+                                const char *ruser, const char *rhost,
+                                const char *tty, struct nslcd_resp *resp)
 {
-  PAM_REQUEST(NSLCD_ACTION_PAM_SESS_O,
+  PAM_REQUEST(
+    NSLCD_ACTION_PAM_SESS_O,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd session open; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd session open; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username);
-    WRITE_STRING(fp,service);
-    WRITE_STRING(fp,ruser);
-    WRITE_STRING(fp,rhost);
-    WRITE_STRING(fp,tty),
+    WRITE_STRING(fp, username);
+    WRITE_STRING(fp, service);
+    WRITE_STRING(fp, ruser);
+    WRITE_STRING(fp, rhost);
+    WRITE_STRING(fp, tty),
     /* read the result entry */
-    READ_STRING(fp,resp->msg))
+    READ_STRING(fp, resp->msg)
+  )
 }
 
 /* do a session close nslcd request */
-static int nslcd_request_sess_c(pam_handle_t *pamh,struct pld_cfg *cfg,
-                               const char *username,const char *service,
-                               const char *ruser,const char *rhost,
-                               const char *tty,const char *sessid)
+static int nslcd_request_sess_c(pam_handle_t *pamh, struct pld_cfg *cfg,
+                                const char *username, const char *service,
+                                const char *ruser, const char *rhost,
+                                const char *tty, const char *sessid)
 {
-  PAM_REQUEST(NSLCD_ACTION_PAM_SESS_C,
+  PAM_REQUEST(
+    NSLCD_ACTION_PAM_SESS_C,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd session close; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd session close; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username);
-    WRITE_STRING(fp,service);
-    WRITE_STRING(fp,ruser);
-    WRITE_STRING(fp,rhost);
-    WRITE_STRING(fp,tty);
-    WRITE_STRING(fp,sessid),
-    /* no result entry to read */;)
+    WRITE_STRING(fp, username);
+    WRITE_STRING(fp, service);
+    WRITE_STRING(fp, ruser);
+    WRITE_STRING(fp, rhost);
+    WRITE_STRING(fp, tty);
+    WRITE_STRING(fp, sessid),
+    /* no result entry to read */ ;
+  )
 }
 
 /* do a password modification nslcd call */
-static int nslcd_request_pwmod(pam_handle_t *pamh,struct pld_cfg *cfg,
-                               const char *username,const char *service,
-                               const char *ruser,const char *rhost,
-                               const char *tty,
-                               int asroot,
-                               const char *oldpasswd,const char *newpasswd,
+static int nslcd_request_pwmod(pam_handle_t *pamh, struct pld_cfg *cfg,
+                               const char *username, const char *service,
+                               const char *ruser, const char *rhost,
+                               const char *tty, int asroot,
+                               const char *oldpasswd, const char *newpasswd,
                                struct nslcd_resp *resp)
 {
-  PAM_REQUEST(NSLCD_ACTION_PAM_PWMOD,
+  PAM_REQUEST(
+    NSLCD_ACTION_PAM_PWMOD,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd password modify; user=%s",username),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd password modify; user=%s", username),
     /* write the request parameters */
-    WRITE_STRING(fp,username);
-    WRITE_STRING(fp,service);
-    WRITE_STRING(fp,ruser);
-    WRITE_STRING(fp,rhost);
-    WRITE_STRING(fp,tty);
-    WRITE_INT32(fp,asroot);
-    WRITE_STRING(fp,oldpasswd);
-    WRITE_STRING(fp,newpasswd),
+    WRITE_STRING(fp, username);
+    WRITE_STRING(fp, service);
+    WRITE_STRING(fp, ruser);
+    WRITE_STRING(fp, rhost);
+    WRITE_STRING(fp, tty);
+    WRITE_INT32(fp, asroot);
+    WRITE_STRING(fp, oldpasswd);
+    WRITE_STRING(fp, newpasswd),
     /* read the result entry */
-    READ_PAM_CODE(fp,resp->res);
-    READ_STRING(fp,resp->msg);)
+    READ_PAM_CODE(fp, resp->res);
+    READ_STRING(fp, resp->msg);
+  )
 }
 
-static int nslcd_request_config_get(pam_handle_t *pamh,struct pld_cfg *cfg,
-                                    int cfgopt,struct nslcd_resp *resp)
+static int nslcd_request_config_get(pam_handle_t *pamh, struct pld_cfg *cfg,
+                                    int cfgopt, struct nslcd_resp *resp)
 {
-  PAM_REQUEST(NSLCD_ACTION_CONFIG_GET,
+  PAM_REQUEST(
+    NSLCD_ACTION_CONFIG_GET,
     /* log debug message */
-    pam_syslog(pamh,LOG_DEBUG,"nslcd request config (%d)",cfgopt),
+    pam_syslog(pamh, LOG_DEBUG, "nslcd request config (%d)", cfgopt),
     /* write the request parameter */
-    WRITE_INT32(fp,cfgopt),
+    WRITE_INT32(fp, cfgopt),
     /* read the result entry */
-    READ_STRING(fp,resp->msg);)
+    READ_STRING(fp, resp->msg);
+  )
 }
 
 /* remap the return code based on the configuration */
-static int remap_pam_rc(int rc,struct pld_cfg *cfg)
+static int remap_pam_rc(int rc, struct pld_cfg *cfg)
 {
-  if ((rc==PAM_AUTHINFO_UNAVAIL)&&cfg->ignore_authinfo_unavail)
+  if ((rc == PAM_AUTHINFO_UNAVAIL) && cfg->ignore_authinfo_unavail)
     return PAM_IGNORE;
-  if ((rc==PAM_USER_UNKNOWN)&&cfg->ignore_unknown_user)
+  if ((rc == PAM_USER_UNKNOWN) && cfg->ignore_unknown_user)
     return PAM_IGNORE;
   return rc;
 }
 
 /* PAM authentication check */
-int pam_sm_authenticate(pam_handle_t *pamh,int flags,int argc,const char 
**argv)
+int pam_sm_authenticate(pam_handle_t *pamh, int flags,
+                        int argc, const char **argv)
 {
   int rc;
   struct pld_cfg cfg;
   struct pld_ctx *ctx;
-  const char *username,*service;
-  const char *ruser=NULL,*rhost=NULL,*tty=NULL;
-  char *passwd=NULL;
+  const char *username, *service;
+  const char *ruser = NULL, *rhost = NULL, *tty = NULL;
+  char *passwd = NULL;
   struct nslcd_resp resp;
   /* set up configuration */
-  cfg_init(pamh,flags,argc,argv,&cfg);
-  rc=init(pamh,&cfg,&ctx,&username,&service,&ruser,&rhost,&tty);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  cfg_init(pamh, flags, argc, argv, &cfg);
+  rc = init(pamh, &cfg, &ctx, &username, &service, &ruser, &rhost, &tty);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* if service is "passwd" and pwdmod is not allowed alert user */
-  if (!strcmp(service,"passwd"))
+  if (!strcmp(service, "passwd"))
   {
-    
rc=nslcd_request_config_get(pamh,&cfg,NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE,&resp);
-    if ((rc==PAM_SUCCESS)&&(resp.msg!=NULL)&&(resp.msg[0]!='\0'))
+    rc = nslcd_request_config_get(pamh, &cfg, 
NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE,
+                                  &resp);
+    if ((rc == PAM_SUCCESS) && (resp.msg != NULL) && (resp.msg[0] != '\0'))
     {
       /* we silently ignore errors to get the configuration option */
-      pam_syslog(pamh,LOG_NOTICE,"password change prohibited: %s; 
user=%s",resp.msg,username);
+      pam_syslog(pamh, LOG_NOTICE, "password change prohibited: %s; user=%s",
+                 resp.msg, username);
       if (!cfg.no_warn)
-        pam_error(pamh,"%s",resp.msg);
-      return remap_pam_rc(PAM_PERM_DENIED,&cfg);
+        pam_error(pamh, "%s", resp.msg);
+      return remap_pam_rc(PAM_PERM_DENIED, &cfg);
     }
   }
   /* prompt the user for a password */
-  rc=pam_get_authtok(pamh,PAM_AUTHTOK,(const char **)&passwd,NULL);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_authtok(pamh, PAM_AUTHTOK, (const char **)&passwd, NULL);
+  if (rc != PAM_SUCCESS)
   {
-    pam_syslog(pamh,LOG_ERR,"failed to get password: 
%s",pam_strerror(pamh,rc));
+    pam_syslog(pamh, LOG_ERR, "failed to get password: %s",
+               pam_strerror(pamh, rc));
     return rc;
   }
   /* check password */
-  if (!cfg.nullok&&((passwd==NULL)||(passwd[0]=='\0')))
+  if (!cfg.nullok && ((passwd == NULL) || (passwd[0] == '\0')))
   {
     if (cfg.debug)
-      pam_syslog(pamh,LOG_DEBUG,"user has empty password, access denied");
+      pam_syslog(pamh, LOG_DEBUG, "user has empty password, access denied");
     return PAM_AUTH_ERR;
   }
   /* do the nslcd request */
-  
rc=nslcd_request_authc(pamh,&cfg,username,service,ruser,rhost,tty,passwd,&resp,&(ctx->saved_authz));
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  rc = nslcd_request_authc(pamh, &cfg, username, service, ruser, rhost, tty,
+                           passwd, &resp, &(ctx->saved_authz));
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* check the authentication result */
-  if (resp.res!=PAM_SUCCESS)
+  if (resp.res != PAM_SUCCESS)
   {
-    pam_syslog(pamh,LOG_NOTICE,"%s; 
user=%s",pam_strerror(pamh,resp.res),username);
-    return remap_pam_rc(resp.res,&cfg);
+    pam_syslog(pamh, LOG_NOTICE, "%s; user=%s",
+               pam_strerror(pamh, resp.res), username);
+    return remap_pam_rc(resp.res, &cfg);
   }
   /* debug log */
   if (cfg.debug)
-    pam_syslog(pamh,LOG_DEBUG,"authentication succeeded");
+    pam_syslog(pamh, LOG_DEBUG, "authentication succeeded");
   /* if password change is required, save old password in context */
-  if (resp.res==PAM_NEW_AUTHTOK_REQD)
-    ctx->oldpassword=strdup(passwd);
+  if (resp.res == PAM_NEW_AUTHTOK_REQD)
+    ctx->oldpassword = strdup(passwd);
   /* update caller's idea of the user name */
-  if ((resp.msg[0]!='\0') && (strcmp(resp.msg,username)!=0))
+  if ((resp.msg[0] != '\0') && (strcmp(resp.msg, username) != 0))
   {
-    pam_syslog(pamh,LOG_INFO,"username changed from %s to 
%s",username,resp.msg);
-    rc=pam_set_item(pamh,PAM_USER,resp.msg);
+    pam_syslog(pamh, LOG_INFO, "username changed from %s to %s",
+               username, resp.msg);
+    rc = pam_set_item(pamh, PAM_USER, resp.msg);
     /* empty the username in the context to not loose our context */
-    if (ctx->username==NULL)
+    if (ctx->username == NULL)
     {
       free(ctx->username);
-      ctx->username=NULL;
+      ctx->username = NULL;
     }
   }
   return rc;
 }
 
 /* called to update the authentication credentials */
-int pam_sm_setcred(pam_handle_t UNUSED(*pamh),int UNUSED(flags),
-                   int UNUSED(argc),const char UNUSED(**argv))
+int pam_sm_setcred(pam_handle_t UNUSED(*pamh), int UNUSED(flags),
+                   int UNUSED(argc), const char UNUSED(**argv))
 {
   /* we don't need to do anything here */
   return PAM_SUCCESS;
 }
 
 /* PAM authorisation check */
-int pam_sm_acct_mgmt(pam_handle_t *pamh,int flags,int argc,const char **argv)
+int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags,
+                     int argc, const char **argv)
 {
   int rc;
   struct pld_cfg cfg;
   struct pld_ctx *ctx;
-  const char *username,*service;
-  const char *ruser=NULL,*rhost=NULL,*tty=NULL;
+  const char *username, *service;
+  const char *ruser = NULL, *rhost = NULL, *tty = NULL;
   struct nslcd_resp authz_resp;
   const char *msg;
   /* set up configuration */
-  cfg_init(pamh,flags,argc,argv,&cfg);
-  rc=init(pamh,&cfg,&ctx,&username,&service,&ruser,&rhost,&tty);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  cfg_init(pamh, flags, argc, argv, &cfg);
+  rc = init(pamh, &cfg, &ctx, &username, &service, &ruser, &rhost, &tty);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* do the nslcd request */
-  
rc=nslcd_request_authz(pamh,&cfg,username,service,ruser,rhost,tty,&authz_resp);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  rc = nslcd_request_authz(pamh, &cfg, username, service, ruser, rhost, tty,
+                           &authz_resp);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* check the returned authorisation value and the value from authentication 
*/
-  if (authz_resp.res!=PAM_SUCCESS)
+  if (authz_resp.res != PAM_SUCCESS)
   {
-    rc=authz_resp.res;
-    msg=authz_resp.msg;
+    rc = authz_resp.res;
+    msg = authz_resp.msg;
   }
-  else if (ctx->saved_authz.res!=PAM_SUCCESS)
+  else if (ctx->saved_authz.res != PAM_SUCCESS)
   {
-    rc=ctx->saved_authz.res;
-    msg=ctx->saved_authz.msg;
+    rc = ctx->saved_authz.res;
+    msg = ctx->saved_authz.msg;
   }
-  if (rc!=PAM_SUCCESS)
+  if (rc != PAM_SUCCESS)
   {
     /* turn in to generic PAM error message if message is empty */
-    if ((msg==NULL)||(msg[0]=='\0'))
+    if ((msg == NULL) || (msg[0] == '\0'))
     {
-      msg=pam_strerror(pamh,rc);
-      pam_syslog(pamh,LOG_NOTICE,"%s; user=%s",msg,username);
+      msg = pam_strerror(pamh, rc);
+      pam_syslog(pamh, LOG_NOTICE, "%s; user=%s", msg, username);
     }
     else
-      pam_syslog(pamh,LOG_NOTICE,"%s; user=%s; 
err=%s",msg,username,pam_strerror(pamh,rc));
-    rc=remap_pam_rc(rc,&cfg);
-    if ((rc!=PAM_IGNORE)&&(!cfg.no_warn))
-      pam_error(pamh,"%s",msg);
+      pam_syslog(pamh, LOG_NOTICE, "%s; user=%s; err=%s",
+                 msg, username, pam_strerror(pamh, rc));
+    rc = remap_pam_rc(rc, &cfg);
+    if ((rc != PAM_IGNORE) && (!cfg.no_warn))
+      pam_error(pamh, "%s", msg);
     return rc;
   }
   if (cfg.debug)
-    pam_syslog(pamh,LOG_DEBUG,"authorization succeeded");
+    pam_syslog(pamh, LOG_DEBUG, "authorization succeeded");
   /* present any informational messages to the user */
-  if ((authz_resp.msg[0]!='\0')&&(!cfg.no_warn))
-    pam_info(pamh,"%s",authz_resp.msg);
-  if ((ctx->saved_authz.msg[0]!='\0')&&(!cfg.no_warn))
-    pam_info(pamh,"%s",ctx->saved_authz.msg);
+  if ((authz_resp.msg[0] != '\0') && (!cfg.no_warn))
+    pam_info(pamh, "%s", authz_resp.msg);
+  if ((ctx->saved_authz.msg[0] != '\0') && (!cfg.no_warn))
+    pam_info(pamh, "%s", ctx->saved_authz.msg);
   return PAM_SUCCESS;
 }
 
 /* PAM session open call */
-int pam_sm_open_session(pam_handle_t *pamh,int flags,int argc,const char 
**argv)
+int pam_sm_open_session(pam_handle_t *pamh, int flags,
+                        int argc, const char **argv)
 {
   int rc;
   struct pld_cfg cfg;
   struct pld_ctx *ctx;
-  const char *username,*service;
-  const char *ruser=NULL,*rhost=NULL,*tty=NULL;
+  const char *username, *service;
+  const char *ruser = NULL, *rhost = NULL, *tty = NULL;
   /* set up configuration */
-  cfg_init(pamh,flags,argc,argv,&cfg);
-  rc=init(pamh,&cfg,&ctx,&username,&service,&ruser,&rhost,&tty);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  cfg_init(pamh, flags, argc, argv, &cfg);
+  rc = init(pamh, &cfg, &ctx, &username, &service, &ruser, &rhost, &tty);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* do the nslcd request */
-  
rc=nslcd_request_sess_o(pamh,&cfg,username,service,ruser,rhost,tty,&(ctx->saved_session));
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  rc = nslcd_request_sess_o(pamh, &cfg, username, service, ruser, rhost,
+                            tty, &(ctx->saved_session));
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* debug log */
   if (cfg.debug)
-    pam_syslog(pamh,LOG_DEBUG,"session open succeeded; 
session_id=%s",ctx->saved_session.msg);
+    pam_syslog(pamh, LOG_DEBUG, "session open succeeded; session_id=%s",
+               ctx->saved_session.msg);
   return PAM_SUCCESS;
 }
 
 /* PAM session close call */
-int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc,const char 
**argv)
+int pam_sm_close_session(pam_handle_t *pamh, int flags,
+                         int argc, const char **argv)
 {
   int rc;
   struct pld_cfg cfg;
   struct pld_ctx *ctx;
-  const char *username,*service;
-  const char *ruser=NULL,*rhost=NULL,*tty=NULL;
+  const char *username, *service;
+  const char *ruser = NULL, *rhost = NULL, *tty = NULL;
   /* set up configuration */
-  cfg_init(pamh,flags,argc,argv,&cfg);
-  rc=init(pamh,&cfg,&ctx,&username,&service,&ruser,&rhost,&tty);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  cfg_init(pamh, flags, argc, argv, &cfg);
+  rc = init(pamh, &cfg, &ctx, &username, &service, &ruser, &rhost, &tty);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* do the nslcd request */
-  
rc=nslcd_request_sess_c(pamh,&cfg,username,service,ruser,rhost,tty,ctx->saved_session.msg);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  rc = nslcd_request_sess_c(pamh, &cfg, username, service, ruser, rhost,
+                            tty, ctx->saved_session.msg);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* debug log */
   if (cfg.debug)
-    pam_syslog(pamh,LOG_DEBUG,"session close succeeded; 
session_id=%s",ctx->saved_session.msg);
+    pam_syslog(pamh, LOG_DEBUG, "session close succeeded; session_id=%s",
+               ctx->saved_session.msg);
   return PAM_SUCCESS;
 }
 
 /* Change the password of the user. This function is first called with
-   PAM_PRELIM_CHECK set in the flags and then without the flag. In the first
-   pass it is determined whether we can contact the LDAP server and the
-   provided old password is valid. In the second pass we get the new
-   password and actually modify the password. */
-int pam_sm_chauthtok(pam_handle_t *pamh,int flags,int argc,const char **argv)
+ PAM_PRELIM_CHECK set in the flags and then without the flag. In the first
+ pass it is determined whether we can contact the LDAP server and the
+ provided old password is valid. In the second pass we get the new
+ password and actually modify the password. */
+int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
+                     int argc, const char **argv)
 {
   int rc;
   struct pld_cfg cfg;
   struct pld_ctx *ctx;
-  const char *username,*service;
-  const char *ruser=NULL,*rhost=NULL,*tty=NULL;
-  const char *oldpassword=NULL,*newpassword=NULL;
+  const char *username, *service;
+  const char *ruser = NULL, *rhost = NULL, *tty = NULL;
+  const char *oldpassword = NULL, *newpassword = NULL;
   struct passwd *pwent;
   uid_t myuid;
   struct nslcd_resp resp;
   const char *msg;
   /* set up configuration */
-  cfg_init(pamh,flags,argc,argv,&cfg);
-  rc=init(pamh,&cfg,&ctx,&username,&service,&ruser,&rhost,&tty);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  cfg_init(pamh, flags, argc, argv, &cfg);
+  rc = init(pamh, &cfg, &ctx, &username, &service, &ruser, &rhost, &tty);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* check if password modification is allowed */
-  
rc=nslcd_request_config_get(pamh,&cfg,NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE,&resp);
-  if ((rc==PAM_SUCCESS)&&(resp.msg!=NULL)&&(resp.msg[0]!='\0'))
+  rc = nslcd_request_config_get(pamh, &cfg, 
NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE,
+                                &resp);
+  if ((rc == PAM_SUCCESS) && (resp.msg != NULL) && (resp.msg[0] != '\0'))
   {
     /* we silently ignore errors to get the configuration option */
-    pam_syslog(pamh,LOG_NOTICE,"password change prohibited: %s; 
user=%s",resp.msg,username);
+    pam_syslog(pamh, LOG_NOTICE, "password change prohibited: %s; user=%s",
+               resp.msg, username);
     if (!cfg.no_warn)
-      pam_error(pamh,"%s",resp.msg);
-    return remap_pam_rc(PAM_PERM_DENIED,&cfg);
+      pam_error(pamh, "%s", resp.msg);
+    return remap_pam_rc(PAM_PERM_DENIED, &cfg);
   }
   /* see if we are dealing with an LDAP user first */
-  rc=nslcd_request_exists(pamh,ctx,&cfg,username);
-  if (rc!=PAM_SUCCESS)
-    return remap_pam_rc(rc,&cfg);
+  rc = nslcd_request_exists(pamh, ctx, &cfg, username);
+  if (rc != PAM_SUCCESS)
+    return remap_pam_rc(rc, &cfg);
   /* preliminary check, just see if we can authenticate with the current 
password */
-  if (flags&PAM_PRELIM_CHECK)
+  if (flags & PAM_PRELIM_CHECK)
   {
-    ctx->asroot=0;
+    ctx->asroot = 0;
     /* see if the user is trying to modify another user's password */
     /* TODO: perhaps this can be combined with the nslcd_request_exists() call 
above */
-    pwent=pam_modutil_getpwnam(args->pamh,username);
-    myuid=getuid();
-    if 
((pwent!=NULL)&&(pwent->pw_uid!=myuid)&&(!(flags&PAM_CHANGE_EXPIRED_AUTHTOK)))
+    pwent = pam_modutil_getpwnam(args->pamh, username);
+    myuid = getuid();
+    if ((pwent != NULL) && (pwent->pw_uid != myuid) && (!(flags & 
PAM_CHANGE_EXPIRED_AUTHTOK)))
     {
       /* we are root so we can test if nslcd will allow us to change the
          user's password without the admin password */
-      if (myuid==0)
+      if (myuid == 0)
       {
-        
rc=nslcd_request_authc(pamh,&cfg,"",service,ruser,rhost,tty,"",&resp,NULL);
-        if ((rc==PAM_SUCCESS)&&(resp.res==PAM_SUCCESS))
+        rc = nslcd_request_authc(pamh, &cfg, "", service, ruser, rhost, tty,
+                                 "", &resp, NULL);
+        if ((rc == PAM_SUCCESS) && (resp.res == PAM_SUCCESS))
         {
-          ctx->asroot=1;
-          return pam_set_item(pamh,PAM_OLDAUTHTOK,"");
+          ctx->asroot = 1;
+          return pam_set_item(pamh, PAM_OLDAUTHTOK, "");
         }
       }
       /* try to  authenticate with the LDAP administrator password by passing
          an empty username to the authc request */
-      rc=pam_get_authtok(pamh,PAM_OLDAUTHTOK,&oldpassword,"LDAP administrator 
password: ");
-      if (rc!=PAM_SUCCESS)
+      rc = pam_get_authtok(pamh, PAM_OLDAUTHTOK, &oldpassword,
+                           "LDAP administrator password: ");
+      if (rc != PAM_SUCCESS)
         return rc;
-      ctx->asroot=1;
-      username="";
+      ctx->asroot = 1;
+      username = "";
     }
-    else if ((ctx->oldpassword!=NULL)&&(*ctx->oldpassword!='\0'))
+    else if ((ctx->oldpassword != NULL) && (*ctx->oldpassword != '\0'))
       /* we already have an old password stored (from a previous
          authentication phase) so we'll use that */
-      oldpassword=ctx->oldpassword;
+      oldpassword = ctx->oldpassword;
     else
     {
       /* prompt the user for a password if needed */
-      rc=pam_get_authtok(pamh,PAM_OLDAUTHTOK,(const char 
**)&oldpassword,"(current) LDAP Password: ");
-      if (rc!=PAM_SUCCESS)
+      rc = pam_get_authtok(pamh, PAM_OLDAUTHTOK, (const char **)&oldpassword,
+                           "(current) LDAP Password: ");
+      if (rc != PAM_SUCCESS)
         return rc;
     }
     /* check for empty password */
-    if (!cfg.nullok&&((oldpassword==NULL)||(oldpassword[0]=='\0')))
+    if (!cfg.nullok && ((oldpassword == NULL) || (oldpassword[0] == '\0')))
     {
       if (cfg.debug)
-        pam_syslog(pamh,LOG_DEBUG,"user has empty password, access denied");
+        pam_syslog(pamh, LOG_DEBUG, "user has empty password, access denied");
       return PAM_AUTH_ERR;
     }
     /* try authenticating */
-    
rc=nslcd_request_authc(pamh,&cfg,username,service,ruser,rhost,tty,oldpassword,&resp,NULL);
-    if (rc!=PAM_SUCCESS)
-      return remap_pam_rc(rc,&cfg);
+    rc = nslcd_request_authc(pamh, &cfg, username, service, ruser, rhost,
+                             tty, oldpassword, &resp, NULL);
+    if (rc != PAM_SUCCESS)
+      return remap_pam_rc(rc, &cfg);
     /* handle authentication result */
-    if (resp.res!=PAM_SUCCESS)
-      pam_syslog(pamh,LOG_NOTICE,"%s; 
user=%s",pam_strerror(pamh,resp.res),username);
+    if (resp.res != PAM_SUCCESS)
+      pam_syslog(pamh, LOG_NOTICE, "%s; user=%s",
+                 pam_strerror(pamh, resp.res), username);
     else if (cfg.debug)
-      pam_syslog(pamh,LOG_DEBUG,"authentication succeeded");
+      pam_syslog(pamh, LOG_DEBUG, "authentication succeeded");
     /* store password (needed if oldpassword was retreived from context) */
-    if (resp.res==PAM_SUCCESS)
+    if (resp.res == PAM_SUCCESS)
     {
-      rc=pam_set_item(pamh,PAM_OLDAUTHTOK,oldpassword);
-      if (rc!=PAM_SUCCESS)
-        return remap_pam_rc(rc,&cfg);
+      rc = pam_set_item(pamh, PAM_OLDAUTHTOK, oldpassword);
+      if (rc != PAM_SUCCESS)
+        return remap_pam_rc(rc, &cfg);
     }
     /* remap error code */
-    return remap_pam_rc(resp.res,&cfg);
+    return remap_pam_rc(resp.res, &cfg);
   }
   /* get the old password (from the previous call) */
-  rc=pam_get_item(pamh,PAM_OLDAUTHTOK,(const void **)&oldpassword);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_item(pamh, PAM_OLDAUTHTOK, (const void **)&oldpassword);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* prompt for new password */
-  rc=pam_get_authtok(pamh,PAM_AUTHTOK,&newpassword,NULL);
-  if (rc!=PAM_SUCCESS)
+  rc = pam_get_authtok(pamh, PAM_AUTHTOK, &newpassword, NULL);
+  if (rc != PAM_SUCCESS)
     return rc;
   /* perform the password modification */
-  
rc=nslcd_request_pwmod(pamh,&cfg,username,service,ruser,rhost,tty,ctx->asroot,oldpassword,newpassword,&resp);
-  if (rc!=PAM_SUCCESS)
-    msg=pam_strerror(pamh,rc);
+  rc = nslcd_request_pwmod(pamh, &cfg, username, service, ruser, rhost, tty,
+                           ctx->asroot, oldpassword, newpassword, &resp);
+  if (rc != PAM_SUCCESS)
+    msg = pam_strerror(pamh, rc);
   else
   {
-    rc=resp.res;
-    msg=resp.msg;
+    rc = resp.res;
+    msg = resp.msg;
   }
   /* remap error code */
-  rc=remap_pam_rc(rc,&cfg);
+  rc = remap_pam_rc(rc, &cfg);
   /* check the returned value */
-  if (rc!=PAM_SUCCESS)
+  if (rc != PAM_SUCCESS)
   {
-    pam_syslog(pamh,LOG_NOTICE,"password change failed: %s; 
user=%s",msg,username);
-    if ((rc!=PAM_IGNORE)&&(!cfg.no_warn))
-      pam_error(pamh,"%s",msg);
+    pam_syslog(pamh, LOG_NOTICE, "password change failed: %s; user=%s",
+               msg, username);
+    if ((rc != PAM_IGNORE) && (!cfg.no_warn))
+      pam_error(pamh, "%s", msg);
     return rc;
   }
-  pam_syslog(pamh,LOG_NOTICE,"password changed for %s",username);
+  pam_syslog(pamh, LOG_NOTICE, "password changed for %s", username);
   return PAM_SUCCESS;
 }
 
 #ifdef PAM_STATIC
-struct pam_module _pam_ldap_modstruct={
+struct pam_module _pam_ldap_modstruct = {
   "pam_ldap",
   pam_sm_authenticate,
   pam_sm_setcred,

Modified: nss-pam-ldapd/tests/common.h
==============================================================================
--- nss-pam-ldapd/tests/common.h        Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/common.h        Sat Dec 22 22:38:26 2012        (r1873)
@@ -33,42 +33,45 @@
 #ifndef HAVE___ASSERT_FAIL
 /* for Solaris: */
 #ifdef sun
-#define __assert_fail(assertion,file,line,function) 
__assert(assertion,file,line)
+#define __assert_fail(assertion, file, line, function)                      \
+  __assert(assertion, file, line)
 #endif
 /* for FreeBSD: */
 #ifdef __FreeBSD__
-#define __assert_fail(assertion,file,line,function) 
__assert(assertion,file,line,function)
+#define __assert_fail(assertion, file, line, function)                      \
+  __assert(assertion, file, line, function)
 #endif
 #endif /* not HAVE___ASSERT_FAIL */
 
 /* extra assertion function that epxects both strings to be the same
    (special macro because strcmp() can be a macro that turns ugly in assert) */
-#define assertstreq(str1,str2) \
-  (assertstreq_impl(str1,str2,"strcmp(" __STRING(str1) "," __STRING(str2) 
")==0", \
+#define assertstreq(str1, str2)                                             \
+  (assertstreq_impl(str1, str2,                                             \
+                    "strcmp(" __STRING(str1) ", " __STRING(str2) ") == 0",  \
                     __FILE__, __LINE__, __ASSERT_FUNCTION))
 
-static inline void assertstreq_impl(const char *str1,const char *str2,
-                             const char *assertion,const char *file,
-                             int line,const char *function)
+static inline void assertstreq_impl(const char *str1, const char *str2,
+                                    const char *assertion, const char *file,
+                                    int line, const char *function)
 {
-  if (strcmp(str1,str2)!=0)
-    __assert_fail(assertion,file,line,function);
+  if (strcmp(str1, str2) != 0)
+    __assert_fail(assertion, file, line, function);
 }
 
 /* extra assertion function that expects expr to be valid and prints an
    error message that include errno otherwise */
-#define assertok(expr) \
-  ((expr) \
-   ? (void) (0) \
-   : __assertok_fail(__STRING(expr),__FILE__,__LINE__,__ASSERT_FUNCTION))
+#define assertok(expr)                                                      \
+  ((expr)                                                                   \
+   ? (void) (0)                                                             \
+   : __assertok_fail(__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
 
 
-static inline void __assertok_fail(const char *expr,const char *file,
-                            int line,const char *function)
+static inline void __assertok_fail(const char *expr, const char *file,
+                                   int line, const char *function)
 {
   char msg[120];
-  snprintf(msg,sizeof(msg),"%s (errno=\"%s\")",expr,strerror(errno));
-  __assert_fail(msg,file,line,function);
+  snprintf(msg, sizeof(msg), "%s (errno=\"%s\")", expr, strerror(errno));
+  __assert_fail(msg, file, line, function);
 }
 
 

Modified: nss-pam-ldapd/tests/test_cfg.c
==============================================================================
--- nss-pam-ldapd/tests/test_cfg.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_cfg.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_cfg.c - simple test for the cfg module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2009, 2011 Arthur de Jong
+   Copyright (C) 2007, 2009, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -33,15 +33,15 @@
 
 static void test_xstrdup(void)
 {
-  static const char *foo="testString123";
+  static const char *foo = "testString123";
   char *bar;
-  bar=xstrdup(foo);
+  bar = xstrdup(foo);
   /* we should have a new value */
-  assert(bar!=NULL);
+  assert(bar != NULL);
   /* the contents should be the same */
-  assertstreq(foo,bar);
+  assertstreq(foo, bar);
   /* but the pointer should be different */
-  assert(foo!=bar);
+  assert(foo != bar);
   /* free memory */
   free(bar);
 }
@@ -52,99 +52,107 @@
   int i;
   /* set up config */
   cfg_defaults(&cfg);
-  assert(cfg.ldc_uris[0].uri==NULL);
+  assert(cfg.ldc_uris[0].uri == NULL);
   /* add a uri */
-  add_uri(__FILE__,__LINE__,&cfg,"ldap://localhost";);
-  assert(cfg.ldc_uris[0].uri!=NULL);
-  assert(cfg.ldc_uris[1].uri==NULL);
+  add_uri(__FILE__, __LINE__, &cfg, "ldap://localhost";);
+  assert(cfg.ldc_uris[0].uri != NULL);
+  assert(cfg.ldc_uris[1].uri == NULL);
   /* add some more uris */
-  for (i=1;i<NSS_LDAP_CONFIG_URI_MAX;i++)
+  for (i = 1; i < NSS_LDAP_CONFIG_URI_MAX; i++)
   {
-    add_uri(__FILE__,__LINE__,&cfg,"ldap://localhost";);
-    assert(cfg.ldc_uris[i].uri!=NULL);
-    assert(cfg.ldc_uris[i+1].uri==NULL);
+    add_uri(__FILE__, __LINE__, &cfg, "ldap://localhost";);
+    assert(cfg.ldc_uris[i].uri != NULL);
+    assert(cfg.ldc_uris[i + 1].uri == NULL);
   }
   /* inserting one more entry should call exit():
-  add_uri(__FILE__,__LINE__,&cfg,"ldap://localhost";);
-  assert(cfg.ldc_uris[i]!=NULL);
-  assert(cfg.ldc_uris[i+1]==NULL); */
+     add_uri(__FILE__, __LINE__, &cfg, "ldap://localhost";);
+     assert(cfg.ldc_uris[i] != NULL);
+     assert(cfg.ldc_uris[i + 1] == NULL); */
   /* there is no cfg_free() so we have a memory leak here */
 }
 
 static void test_parse_boolean(void)
 {
-  assert(parse_boolean(__FILE__,__LINE__,"True")==1);
-  assert(parse_boolean(__FILE__,__LINE__,"faLSe")==0);
-  assert(parse_boolean(__FILE__,__LINE__,"1")==1);
-  assert(parse_boolean(__FILE__,__LINE__,"oFF")==0);
-  assert(parse_boolean(__FILE__,__LINE__,"Yes")==1);
-  assert(parse_boolean(__FILE__,__LINE__,"No")==0);
+  assert(parse_boolean(__FILE__, __LINE__, "True") == 1);
+  assert(parse_boolean(__FILE__, __LINE__, "faLSe") == 0);
+  assert(parse_boolean(__FILE__, __LINE__, "1") == 1);
+  assert(parse_boolean(__FILE__, __LINE__, "oFF") == 0);
+  assert(parse_boolean(__FILE__, __LINE__, "Yes") == 1);
+  assert(parse_boolean(__FILE__, __LINE__, "No") == 0);
   /* most other values should call exit():
-  assert(parse_boolean(__FILE__,__LINE__,"Foo")==0); */
+     assert(parse_boolean(__FILE__, __LINE__, "Foo") == 0); */
 }
 
 static void test_parse_scope(void)
 {
-  assert(parse_scope(__FILE__,__LINE__,"sUb")==LDAP_SCOPE_SUBTREE);
-  assert(parse_scope(__FILE__,__LINE__,"subtree")==LDAP_SCOPE_SUBTREE);
-  assert(parse_scope(__FILE__,__LINE__,"ONE")==LDAP_SCOPE_ONELEVEL);
-  assert(parse_scope(__FILE__,__LINE__,"oneLevel")==LDAP_SCOPE_ONELEVEL);
-  assert(parse_scope(__FILE__,__LINE__,"base")==LDAP_SCOPE_BASE);
-  assert(parse_scope(__FILE__,__LINE__,"bASe")==LDAP_SCOPE_BASE);
+  assert(parse_scope(__FILE__, __LINE__, "sUb") == LDAP_SCOPE_SUBTREE);
+  assert(parse_scope(__FILE__, __LINE__, "subtree") == LDAP_SCOPE_SUBTREE);
+  assert(parse_scope(__FILE__, __LINE__, "ONE") == LDAP_SCOPE_ONELEVEL);
+  assert(parse_scope(__FILE__, __LINE__, "oneLevel") == LDAP_SCOPE_ONELEVEL);
+  assert(parse_scope(__FILE__, __LINE__, "base") == LDAP_SCOPE_BASE);
+  assert(parse_scope(__FILE__, __LINE__, "bASe") == LDAP_SCOPE_BASE);
   /* most other values should call exit():
-  assert(parse_scope(__FILE__,__LINE__,"BSAE")==LDAP_SCOPE_BASE); */
+     assert(parse_scope(__FILE__, __LINE__, "BSAE") == LDAP_SCOPE_BASE); */
 }
 
 static void test_parse_map(void)
 {
   /* some general assertions */
-  
assert((LM_ALIASES!=LM_ETHERS)&&(LM_ALIASES!=LM_GROUP)&&(LM_ALIASES!=LM_HOSTS)&&
-         
(LM_ALIASES!=LM_NETGROUP)&&(LM_ALIASES!=LM_NETWORKS)&&(LM_ALIASES!=LM_PASSWD)&&
-         
(LM_ALIASES!=LM_PROTOCOLS)&&(LM_ALIASES!=LM_RPC)&&(LM_ALIASES!=LM_SERVICES)&&
-         (LM_ALIASES!=LM_SHADOW));
-  
assert((LM_ETHERS!=LM_GROUP)&&(LM_ETHERS!=LM_HOSTS)&&(LM_ETHERS!=LM_NETGROUP)&&
-         
(LM_ETHERS!=LM_NETWORKS)&&(LM_ETHERS!=LM_PASSWD)&&(LM_ETHERS!=LM_PROTOCOLS)&&
-         
(LM_ETHERS!=LM_RPC)&&(LM_ETHERS!=LM_SERVICES)&&(LM_ETHERS!=LM_SHADOW));
-  
assert((LM_GROUP!=LM_HOSTS)&&(LM_GROUP!=LM_NETGROUP)&&(LM_GROUP!=LM_NETWORKS)&&
-         (LM_GROUP!=LM_PASSWD)&&(LM_GROUP!=LM_PROTOCOLS)&&(LM_GROUP!=LM_RPC)&&
-         (LM_GROUP!=LM_SERVICES)&&(LM_GROUP!=LM_SHADOW));
-  
assert((LM_HOSTS!=LM_NETGROUP)&&(LM_HOSTS!=LM_NETWORKS)&&(LM_HOSTS!=LM_PASSWD)&&
-         
(LM_HOSTS!=LM_PROTOCOLS)&&(LM_HOSTS!=LM_RPC)&&(LM_HOSTS!=LM_SERVICES)&&
-         (LM_HOSTS!=LM_SHADOW));
-  
assert((LM_NETGROUP!=LM_NETWORKS)&&(LM_NETGROUP!=LM_PASSWD)&&(LM_NETGROUP!=LM_PROTOCOLS)&&
-         
(LM_NETGROUP!=LM_RPC)&&(LM_NETGROUP!=LM_SERVICES)&&(LM_NETGROUP!=LM_SHADOW));
-  
assert((LM_NETWORKS!=LM_PASSWD)&&(LM_NETWORKS!=LM_PROTOCOLS)&&(LM_NETWORKS!=LM_RPC)&&
-         (LM_NETWORKS!=LM_SERVICES)&&(LM_NETWORKS!=LM_SHADOW));
-  
assert((LM_PASSWD!=LM_PROTOCOLS)&&(LM_PASSWD!=LM_RPC)&&(LM_PASSWD!=LM_SERVICES)&&
-         (LM_PASSWD!=LM_SHADOW));
-  
assert((LM_PROTOCOLS!=LM_RPC)&&(LM_PROTOCOLS!=LM_SERVICES)&&(LM_PROTOCOLS!=LM_SHADOW));
-  assert((LM_RPC!=LM_SERVICES)&&(LM_RPC!=LM_SHADOW));
-  assert((LM_SERVICES!=LM_SHADOW));
+  assert((LM_ALIASES != LM_ETHERS) && (LM_ALIASES != LM_GROUP) &&
+         (LM_ALIASES != LM_HOSTS) && (LM_ALIASES != LM_NETGROUP) &&
+         (LM_ALIASES != LM_NETWORKS) && (LM_ALIASES != LM_PASSWD) &&
+         (LM_ALIASES != LM_PROTOCOLS) && (LM_ALIASES != LM_RPC) &&
+         (LM_ALIASES != LM_SERVICES) && (LM_ALIASES != LM_SHADOW));
+  assert((LM_ETHERS != LM_GROUP) && (LM_ETHERS != LM_HOSTS) &&
+         (LM_ETHERS != LM_NETGROUP) && (LM_ETHERS != LM_NETWORKS) &&
+         (LM_ETHERS != LM_PASSWD) && (LM_ETHERS != LM_PROTOCOLS) &&
+         (LM_ETHERS != LM_RPC) && (LM_ETHERS != LM_SERVICES) &&
+         (LM_ETHERS != LM_SHADOW));
+  assert((LM_GROUP != LM_HOSTS) && (LM_GROUP != LM_NETGROUP) &&
+         (LM_GROUP != LM_NETWORKS) && (LM_GROUP != LM_PASSWD) &&
+         (LM_GROUP != LM_PROTOCOLS) && (LM_GROUP != LM_RPC) &&
+         (LM_GROUP != LM_SERVICES) && (LM_GROUP != LM_SHADOW));
+  assert((LM_HOSTS != LM_NETGROUP) && (LM_HOSTS != LM_NETWORKS) &&
+         (LM_HOSTS != LM_PASSWD) && (LM_HOSTS != LM_PROTOCOLS) &&
+         (LM_HOSTS != LM_RPC) && (LM_HOSTS != LM_SERVICES) &&
+         (LM_HOSTS != LM_SHADOW));
+  assert((LM_NETGROUP != LM_NETWORKS) && (LM_NETGROUP != LM_PASSWD) &&
+         (LM_NETGROUP != LM_PROTOCOLS) && (LM_NETGROUP != LM_RPC) &&
+         (LM_NETGROUP != LM_SERVICES) && (LM_NETGROUP != LM_SHADOW));
+  assert((LM_NETWORKS != LM_PASSWD) && (LM_NETWORKS != LM_PROTOCOLS) &&
+         (LM_NETWORKS != LM_RPC) && (LM_NETWORKS != LM_SERVICES) &&
+         (LM_NETWORKS != LM_SHADOW));
+  assert((LM_PASSWD != LM_PROTOCOLS) && (LM_PASSWD != LM_RPC) &&
+         (LM_PASSWD != LM_SERVICES) && (LM_PASSWD != LM_SHADOW));
+  assert((LM_PROTOCOLS != LM_RPC) && (LM_PROTOCOLS != LM_SERVICES) &&
+         (LM_PROTOCOLS != LM_SHADOW));
+  assert((LM_RPC != LM_SERVICES) && (LM_RPC != LM_SHADOW));
+  assert((LM_SERVICES != LM_SHADOW));
   /* test supported names */
-  assert(parse_map("alIas")==LM_ALIASES);
-  assert(parse_map("AliasES")==LM_ALIASES);
-  assert(parse_map("ether")==LM_ETHERS);
-  assert(parse_map("ethers")==LM_ETHERS);
-  assert(parse_map("group")==LM_GROUP);
-  /* assert(parse_map("groups")==LM_GROUP); */
-  assert(parse_map("host")==LM_HOSTS);
-  assert(parse_map("hosts")==LM_HOSTS);
-  assert(parse_map("netgroup")==LM_NETGROUP);
-  /* assert(parse_map("netgroups")==LM_NETGROUP); */
-  assert(parse_map("network")==LM_NETWORKS);
-  assert(parse_map("networks")==LM_NETWORKS);
-  assert(parse_map("passwd")==LM_PASSWD);
-  /* assert(parse_map("passwds")==LM_PASSWD); */
-  assert(parse_map("protocol")==LM_PROTOCOLS);
-  assert(parse_map("protocols")==LM_PROTOCOLS);
-  assert(parse_map("rpc")==LM_RPC);
-  /* assert(parse_map("rpcs")==LM_RPC); */
-  assert(parse_map("service")==LM_SERVICES);
-  assert(parse_map("services")==LM_SERVICES);
-  assert(parse_map("shadow")==LM_SHADOW);
-  /* assert(parse_map("shadows")==LM_SHADOW); */
+  assert(parse_map("alIas") == LM_ALIASES);
+  assert(parse_map("AliasES") == LM_ALIASES);
+  assert(parse_map("ether") == LM_ETHERS);
+  assert(parse_map("ethers") == LM_ETHERS);
+  assert(parse_map("group") == LM_GROUP);
+  /* assert(parse_map("groups") == LM_GROUP); */
+  assert(parse_map("host") == LM_HOSTS);
+  assert(parse_map("hosts") == LM_HOSTS);
+  assert(parse_map("netgroup") == LM_NETGROUP);
+  /* assert(parse_map("netgroups") == LM_NETGROUP); */
+  assert(parse_map("network") == LM_NETWORKS);
+  assert(parse_map("networks") == LM_NETWORKS);
+  assert(parse_map("passwd") == LM_PASSWD);
+  /* assert(parse_map("passwds") == LM_PASSWD); */
+  assert(parse_map("protocol") == LM_PROTOCOLS);
+  assert(parse_map("protocols") == LM_PROTOCOLS);
+  assert(parse_map("rpc") == LM_RPC);
+  /* assert(parse_map("rpcs") == LM_RPC); */
+  assert(parse_map("service") == LM_SERVICES);
+  assert(parse_map("services") == LM_SERVICES);
+  assert(parse_map("shadow") == LM_SHADOW);
+  /* assert(parse_map("shadows") == LM_SHADOW); */
   /* most other values should call exit():
-  assert(parse_map("publickey")==LM_SERVICES); */
+     assert(parse_map("publickey") == LM_SERVICES); */
 }
 
 static void test_parse_map_statement(void)
@@ -155,19 +163,19 @@
 static void test_tokenize(void)
 {
   /* this leaks memory all over the place */
-  char *line=strdup("yes this is 1 simple line");
+  char *line = strdup("yes this is 1 simple line");
   char *str;
   int i;
-  get_boolean(__FILE__,__LINE__,__PRETTY_FUNCTION__,&line,&i);
-  assert(i==1);
-  get_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,&line,&str);
-  assertstreq(str,"this");
-  get_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,&line,&str);
-  assertstreq(str,"is");
-  get_int(__FILE__,__LINE__,__PRETTY_FUNCTION__,&line,&i);
-  assert(i==1);
-  get_restdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,&line,&str);
-  assertstreq(str,"simple line");
+  get_boolean(__FILE__, __LINE__, __PRETTY_FUNCTION__, &line, &i);
+  assert(i == 1);
+  get_strdup(__FILE__, __LINE__, __PRETTY_FUNCTION__, &line, &str);
+  assertstreq(str, "this");
+  get_strdup(__FILE__, __LINE__, __PRETTY_FUNCTION__, &line, &str);
+  assertstreq(str, "is");
+  get_int(__FILE__, __LINE__, __PRETTY_FUNCTION__, &line, &i);
+  assert(i == 1);
+  get_restdup(__FILE__, __LINE__, __PRETTY_FUNCTION__, &line, &str);
+  assertstreq(str, "simple line");
 }
 
 extern const char *passwd_bases[];
@@ -179,41 +187,41 @@
   FILE *fp;
   struct ldap_config cfg;
   /* write some stuff to a temporary file */
-  fp=fopen("temp.cfg","w");
-  assert(fp!=NULL);
-  fprintf(fp,"# a line of comments\n"
-             "uri ldap://127.0.0.1/\n";
-             "uri ldap:/// ldaps://127.0.0.1/\n"
-             "base dc=test, dc=tld\n"
-             "base passwd ou=Some People,dc=test,dc=tld\n"
-             "map\tpasswd uid\t\tsAMAccountName\n"
-             "map passwd homeDirectory \"${homeDirectory:-/home/$uid}\"\n"
-             "filter group (&(objeclClass=posixGroup)(gid=1*))\n"
-             "\n"
-             "scope passwd one\n");
+  fp = fopen("temp.cfg", "w");
+  assert(fp != NULL);
+  fprintf(fp, "# a line of comments\n"
+          "uri ldap://127.0.0.1/\n";
+          "uri ldap:/// ldaps://127.0.0.1/\n"
+          "base dc=test, dc=tld\n"
+          "base passwd ou=Some People,dc=test,dc=tld\n"
+          "map\tpasswd uid\t\tsAMAccountName\n"
+          "map passwd homeDirectory \"${homeDirectory:-/home/$uid}\"\n"
+          "filter group (&(objeclClass=posixGroup)(gid=1*))\n"
+          "\n"
+          "scope passwd one\n");
   fclose(fp);
   /* parse the file */
   cfg_defaults(&cfg);
-  cfg_read("temp.cfg",&cfg);
+  cfg_read("temp.cfg", &cfg);
   /* check results */
-  assert(cfg.ldc_uris[0].uri!=NULL);
-  assert(cfg.ldc_uris[1].uri!=NULL);
-  assert(cfg.ldc_uris[2].uri!=NULL);
-  assertstreq(cfg.ldc_uris[0].uri,"ldap://127.0.0.1/";);
-  assertstreq(cfg.ldc_uris[1].uri,"ldap:///";);
-  assertstreq(cfg.ldc_uris[2].uri,"ldaps://127.0.0.1/");
-  assert(cfg.ldc_uris[3].uri==NULL);
-  assertstreq(cfg.ldc_bases[0],"dc=test, dc=tld");
-  assertstreq(passwd_bases[0],"ou=Some People,dc=test,dc=tld");
-  assertstreq(attmap_passwd_uid,"sAMAccountName");
-  assertstreq(group_filter,"(&(objeclClass=posixGroup)(gid=1*))");
-  assert(passwd_scope==LDAP_SCOPE_ONELEVEL);
+  assert(cfg.ldc_uris[0].uri != NULL);
+  assert(cfg.ldc_uris[1].uri != NULL);
+  assert(cfg.ldc_uris[2].uri != NULL);
+  assertstreq(cfg.ldc_uris[0].uri, "ldap://127.0.0.1/";);
+  assertstreq(cfg.ldc_uris[1].uri, "ldap:///";);
+  assertstreq(cfg.ldc_uris[2].uri, "ldaps://127.0.0.1/");
+  assert(cfg.ldc_uris[3].uri == NULL);
+  assertstreq(cfg.ldc_bases[0], "dc=test, dc=tld");
+  assertstreq(passwd_bases[0], "ou=Some People,dc=test,dc=tld");
+  assertstreq(attmap_passwd_uid, "sAMAccountName");
+  assertstreq(group_filter, "(&(objeclClass=posixGroup)(gid=1*))");
+  assert(passwd_scope == LDAP_SCOPE_ONELEVEL);
   /* remove temporary file */
   remove("temp.cfg");
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   test_xstrdup();
   test_add_uris();

Modified: nss-pam-ldapd/tests/test_common.c
==============================================================================
--- nss-pam-ldapd/tests/test_common.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_common.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_common.c - simple test for the common module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2009, 2011 Arthur de Jong
+   Copyright (C) 2008, 2009, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -38,20 +38,20 @@
   assert(isvalidname("foo\\bar"));
   assert(!isvalidname("\\foo\\bar"));
   assert(!isvalidname("foo\\bar\\"));
-  assert(isvalidname("me")); /* try short name */
+  assert(isvalidname("me"));    /* try short name */
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   char *srcdir;
   char fname[100];
   /* build the name of the file */
-  srcdir=getenv("srcdir");
-  if (srcdir==NULL)
-    srcdir=".";
-  snprintf(fname,sizeof(fname),"%s/nslcd-test.conf",srcdir);
-  fname[sizeof(fname)-1]='\0';
+  srcdir = getenv("srcdir");
+  if (srcdir == NULL)
+    srcdir = ".";
+  snprintf(fname, sizeof(fname), "%s/nslcd-test.conf", srcdir);
+  fname[sizeof(fname) - 1] = '\0';
   /* initialize configuration */
   cfg_init(fname);
   /* partially initialize logging */

Modified: nss-pam-ldapd/tests/test_dict.c
==============================================================================
--- nss-pam-ldapd/tests/test_dict.c     Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_dict.c     Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_dict.c - simple test for the dict module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -36,39 +36,39 @@
 {
   DICT *dict;
   void *val;
-  static char *value1="value1";
-  static char *value2="value2";
-  static char *replace2="replace2";
+  static char *value1 = "value1";
+  static char *value2 = "value2";
+  static char *replace2 = "replace2";
   const char **keys;
   int i;
   /* initialize */
-  dict=dict_new();
+  dict = dict_new();
   /* store some entries */
-  dict_put(dict,"key1",value1);
-  dict_put(dict,"key2",value2);
-  dict_put(dict,"key3",dict);
-  dict_put(dict,"key2",replace2);
+  dict_put(dict, "key1", value1);
+  dict_put(dict, "key2", value2);
+  dict_put(dict, "key3", dict);
+  dict_put(dict, "key2", replace2);
   /* check dictionary contents */
-  val=dict_get(dict,"key1");
-  assert(val==value1);
-  val=dict_get(dict,"key2");
-  assert(val==replace2);
-  val=dict_get(dict,"key3");
-  assert(val==dict);
-  val=dict_get(dict,"key4");
-  assert(val==NULL);
-  val=dict_get(dict,"KEY1");
-  assert(val==NULL);
+  val = dict_get(dict, "key1");
+  assert(val == value1);
+  val = dict_get(dict, "key2");
+  assert(val == replace2);
+  val = dict_get(dict, "key3");
+  assert(val == dict);
+  val = dict_get(dict, "key4");
+  assert(val == NULL);
+  val = dict_get(dict, "KEY1");
+  assert(val == NULL);
   /* remove a key */
-  dict_put(dict,"key3",NULL);
-  val=dict_get(dict,"key3");
-  assert(val==NULL);
+  dict_put(dict, "key3", NULL);
+  val = dict_get(dict, "key3");
+  assert(val == NULL);
   /* loop over dictionary contents */
-  keys=dict_keys(dict);
-  for (i=0;keys[i]!=NULL;i++)
+  keys = dict_keys(dict);
+  for (i = 0; keys[i] != NULL; i++)
   {
-    val=dict_get(dict,keys[i]);
-    assert(((val==value1)||(val==replace2)));
+    val = dict_get(dict, keys[i]);
+    assert(((val == value1) || (val == replace2)));
   }
   /* free stuff */
   dict_free(dict);
@@ -80,38 +80,38 @@
 {
   DICT *dict;
   char buf[80];
-  int i,r;
+  int i, r;
   void *val;
   const char **keys;
   /* initialize */
-  dict=dict_new();
+  dict = dict_new();
   /* insert a number of entries */
-  for (i=0;i<1024;i++)
+  for (i = 0; i < 1024; i++)
   {
-    r=1+(int)(10000.0*(rand()/(RAND_MAX+1.0)));
-    sprintf(buf,"test%04d",r);
-    dict_put(dict,buf,&buf);
+    r = 1 + (int)(10000.0 * (rand() / (RAND_MAX + 1.0)));
+    sprintf(buf, "test%04d", r);
+    dict_put(dict, buf, &buf);
   }
   /* remove a number of entries */
-  for (i=0;i<100;i++)
+  for (i = 0; i < 100; i++)
   {
-    r=1+(int)(10000.0*(rand()/(RAND_MAX+1.0)));
-    sprintf(buf,"test%04d",r);
-    dict_put(dict,buf,NULL);
+    r = 1 + (int)(10000.0 * (rand() / (RAND_MAX + 1.0)));
+    sprintf(buf, "test%04d", r);
+    dict_put(dict, buf, NULL);
   }
   /* add some more entries */
-  for (i=0;i<1024;i++)
+  for (i = 0; i < 1024; i++)
   {
-    r=1+(int)(10000.0*(rand()/(RAND_MAX+1.0)));
-    sprintf(buf,"test%04d",r);
-    dict_put(dict,buf,&buf);
+    r = 1 + (int)(10000.0 * (rand() / (RAND_MAX + 1.0)));
+    sprintf(buf, "test%04d", r);
+    dict_put(dict, buf, &buf);
   }
   /* loop over dictionary contents */
-  keys=dict_keys(dict);
-  for (i=0;keys[i]!=NULL;i++)
+  keys = dict_keys(dict);
+  for (i = 0; keys[i] != NULL; i++)
   {
-    val=dict_get(dict,keys[i]);
-    assert(val==buf);
+    val = dict_get(dict, keys[i]);
+    assert(val == buf);
   }
   /* free stuff */
   dict_free(dict);
@@ -128,23 +128,23 @@
   const char **keys;
   int i;
   /* initialize */
-  dict=dict_new();
+  dict = dict_new();
   /* read file and insert all entries */
-  fp=fopen(fname,"r");
-  assert(fp!=NULL);
-  while (fgets(buf,sizeof(buf),fp)!=NULL)
+  fp = fopen(fname, "r");
+  assert(fp != NULL);
+  while (fgets(buf, sizeof(buf), fp) != NULL)
   {
     /* strip newline */
-    buf[strlen(buf)-1]='\0';
-    dict_put(dict,buf,&buf);
+    buf[strlen(buf) - 1] = '\0';
+    dict_put(dict, buf, &buf);
   }
   fclose(fp);
   /* loop over dictionary contents */
-  keys=dict_keys(dict);
-  for (i=0;keys[i]!=NULL;i++)
+  keys = dict_keys(dict);
+  for (i = 0; keys[i] != NULL; i++)
   {
-    val=dict_get(dict,keys[i]);
-    assert(val==buf);
+    val = dict_get(dict, keys[i]);
+    assert(val == buf);
   }
   /* free stuff */
   dict_free(dict);
@@ -155,39 +155,40 @@
 {
   DICT *dict;
   char buf[80];
-  int i,r;
+  int i, r;
   const char **keys;
   /* initialize */
-  dict=dict_new();
+  dict = dict_new();
   /* insert a number of entries */
-  for (i=0;i<num;i++)
+  for (i = 0; i < num; i++)
   {
-    r=1+(int)(10000.0*(rand()/(RAND_MAX+1.0)));
-    sprintf(buf,"%04dx%04d",i,r);
-    dict_put(dict,buf,&buf);
+    r = 1 + (int)(10000.0 * (rand() / (RAND_MAX + 1.0)));
+    sprintf(buf, "%04dx%04d", i, r);
+    dict_put(dict, buf, &buf);
   }
   /* loop over dictionary contents */
-  keys=dict_keys(dict);
-  for (i=0;keys[i]!=NULL;i++);
+  keys = dict_keys(dict);
+  for (i = 0; keys[i] != NULL; i++)
+    /* nothing */ ;
   /* we should have num elements */
-  assert(i==num);
+  assert(i == num);
   /* free stuff */
   dict_free(dict);
   free(keys);
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   char *srcdir;
   char fname[100];
   /* build the name of the file */
-  srcdir=getenv("srcdir");
-  if (srcdir==NULL)
-    strcpy(fname,"usernames.txt");
+  srcdir = getenv("srcdir");
+  if (srcdir == NULL)
+    strcpy(fname, "usernames.txt");
   else
-    snprintf(fname,sizeof(fname),"%s/usernames.txt",srcdir);
-  fname[sizeof(fname)-1]='\0';
+    snprintf(fname, sizeof(fname), "%s/usernames.txt", srcdir);
+  fname[sizeof(fname) - 1] = '\0';
   /* run the tests */
   test_simple();
   test_lotsofelements();

Modified: nss-pam-ldapd/tests/test_expr.c
==============================================================================
--- nss-pam-ldapd/tests/test_expr.c     Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_expr.c     Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_expr.c - simple tests for the expr module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2009, 2011 Arthur de Jong
+   Copyright (C) 2009, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -35,22 +35,22 @@
 {
   char buffer[20];
   int i;
-  i=0;
-  assert(parse_name("fooBar",&i,buffer,sizeof(buffer))!=NULL);
-  assert(i==6);
-  i=0;
-  
assert(parse_name("nameThatWillNotFitInBuffer",&i,buffer,sizeof(buffer))==NULL);
-  i=0;
-  assert(parse_name("foo Bar",&i,buffer,sizeof(buffer))!=NULL);
-  assert(i==3);
-  assertstreq(buffer,"foo");
+  i = 0;
+  assert(parse_name("fooBar", &i, buffer, sizeof(buffer)) != NULL);
+  assert(i == 6);
+  i = 0;
+  assert(parse_name("nameThatWillNotFitInBuffer", &i, buffer, sizeof(buffer)) 
== NULL);
+  i = 0;
+  assert(parse_name("foo Bar", &i, buffer, sizeof(buffer)) != NULL);
+  assert(i == 3);
+  assertstreq(buffer, "foo");
 }
 
-static const char *expanderfn(const char *name,void UNUSED(*expander_attr))
+static const char *expanderfn(const char *name, void UNUSED(*expander_attr))
 {
-  if (strcmp(name,"empty")==0)
+  if (strcmp(name, "empty") == 0)
     return "";
-  if (strcmp(name,"null")==0)
+  if (strcmp(name, "null") == 0)
     return NULL;
   else
     return "foobar";
@@ -59,82 +59,82 @@
 static void test_expr_parse(void)
 {
   char buffer[1024];
-  assert(expr_parse("$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar");
-  assert(expr_parse("\\$test1",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"$test1");
-  assert(expr_parse("$empty",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"");
-  
assert(expr_parse("$foo1$empty-$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar-foobar");
-  
assert(expr_parse("$foo1+$null+$foo2",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar++foobar");
-  
assert(expr_parse("${test1}\\$",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar$");
-  
assert(expr_parse("${test1:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar");
-  
assert(expr_parse("${empty:-default}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"default");
-  
assert(expr_parse("${test1:+setset}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"setset");
-  
assert(expr_parse("${empty:+setset}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"");
-  
assert(expr_parse("${empty:-$test1}",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"foobar");
-  assert(expr_parse("a/$test1/b",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"a/foobar/b");
-  assert(expr_parse("a/$empty/b",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"a//b");
-  assert(expr_parse("a${test1}b",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"afoobarb");
-  
assert(expr_parse("a${test1}b${test2:+${test3:-d$test4}e}c",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"afoobarbfoobarec");
-  
assert(expr_parse("a${test1}b${test2:+${empty:-d$test4}e}c",buffer,sizeof(buffer),expanderfn,NULL)!=NULL);
-  assertstreq(buffer,"afoobarbdfoobarec");
+  assert(expr_parse("$test1", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "foobar");
+  assert(expr_parse("\\$test1", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "$test1");
+  assert(expr_parse("$empty", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "");
+  assert(expr_parse("$foo1$empty-$foo2", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "foobar-foobar");
+  assert(expr_parse("$foo1+$null+$foo2", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "foobar++foobar");
+  assert(expr_parse("${test1}\\$", buffer, sizeof(buffer), expanderfn, NULL) 
!= NULL);
+  assertstreq(buffer, "foobar$");
+  assert(expr_parse("${test1:-default}", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "foobar");
+  assert(expr_parse("${empty:-default}", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "default");
+  assert(expr_parse("${test1:+setset}", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "setset");
+  assert(expr_parse("${empty:+setset}", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "");
+  assert(expr_parse("${empty:-$test1}", buffer, sizeof(buffer), expanderfn, 
NULL) != NULL);
+  assertstreq(buffer, "foobar");
+  assert(expr_parse("a/$test1/b", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "a/foobar/b");
+  assert(expr_parse("a/$empty/b", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "a//b");
+  assert(expr_parse("a${test1}b", buffer, sizeof(buffer), expanderfn, NULL) != 
NULL);
+  assertstreq(buffer, "afoobarb");
+  assert(expr_parse("a${test1}b${test2:+${test3:-d$test4}e}c", buffer, 
sizeof(buffer), expanderfn, NULL) != NULL);
+  assertstreq(buffer, "afoobarbfoobarec");
+  assert(expr_parse("a${test1}b${test2:+${empty:-d$test4}e}c", buffer, 
sizeof(buffer), expanderfn, NULL) != NULL);
+  assertstreq(buffer, "afoobarbdfoobarec");
   /* these are errors */
-  assert(expr_parse("$&",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
-  assert(expr_parse("${a",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
+  assert(expr_parse("$&", buffer, sizeof(buffer), expanderfn, NULL) == NULL);
+  assert(expr_parse("${a", buffer, sizeof(buffer), expanderfn, NULL) == NULL);
 }
 
 static void test_buffer_overflow(void)
 {
   char buffer[10];
-  
assert(expr_parse("$test1$empty$test1",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
-  assert(expr_parse("long test 
value",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
-  assert(expr_parse("${test1:-long test 
value}",buffer,sizeof(buffer),expanderfn,NULL)==NULL);
+  assert(expr_parse("$test1$empty$test1", buffer, sizeof(buffer), expanderfn, 
NULL) == NULL);
+  assert(expr_parse("long test value", buffer, sizeof(buffer), expanderfn, 
NULL) == NULL);
+  assert(expr_parse("${test1:-long test value}", buffer, sizeof(buffer), 
expanderfn, NULL) == NULL);
 }
 
 static void test_expr_vars(void)
 {
   SET *set;
   /* simple test */
-  set=set_new();
-  assert(expr_vars("$a",set)!=NULL);
-  assert(set_contains(set,"a"));
-  assert(!set_contains(set,"$a"));
+  set = set_new();
+  assert(expr_vars("$a", set) != NULL);
+  assert(set_contains(set, "a"));
+  assert(!set_contains(set, "$a"));
   set_free(set);
   /* more elaborate test */
-  set=set_new();
-  assert(expr_vars("\"${gecos:-$cn}\"",set)!=NULL);
-  assert(set_contains(set,"gecos"));
-  assert(set_contains(set,"cn"));
+  set = set_new();
+  assert(expr_vars("\"${gecos:-$cn}\"", set) != NULL);
+  assert(set_contains(set, "gecos"));
+  assert(set_contains(set, "cn"));
   set_free(set);
   /* more elaborate test */
-  set=set_new();
-  assert(expr_vars("\"${homeDirectory:-/home/$uidNumber/$uid}\"",set)!=NULL);
-  assert(set_contains(set,"homeDirectory"));
-  assert(set_contains(set,"uidNumber"));
-  assert(set_contains(set,"uid"));
+  set = set_new();
+  assert(expr_vars("\"${homeDirectory:-/home/$uidNumber/$uid}\"", set) != 
NULL);
+  assert(set_contains(set, "homeDirectory"));
+  assert(set_contains(set, "uidNumber"));
+  assert(set_contains(set, "uid"));
   set_free(set);
   /* a test with attribute options */
-  set=set_new();
-  assert(expr_vars("\"${homeDirectory;foo:-/home/something}\"",set)!=NULL);
-  assert(set_contains(set,"homeDirectory;foo"));
+  set = set_new();
+  assert(expr_vars("\"${homeDirectory;foo:-/home/something}\"", set) != NULL);
+  assert(set_contains(set, "homeDirectory;foo"));
   set_free(set);
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   test_parse_name();
   test_expr_parse();

Modified: nss-pam-ldapd/tests/test_getpeercred.c
==============================================================================
--- nss-pam-ldapd/tests/test_getpeercred.c      Fri Dec 21 22:00:30 2012        
(r1872)
+++ nss-pam-ldapd/tests/test_getpeercred.c      Sat Dec 22 22:38:26 2012        
(r1873)
@@ -2,7 +2,7 @@
    test_getpeercred.c - simple test for the peercred module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2011 Arthur de Jong
+   Copyright (C) 2008, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -46,20 +46,20 @@
   int sock;
   struct sockaddr_un addr;
   /* create a socket */
-  assertok((sock=socket(PF_UNIX,SOCK_STREAM,0))>=0);
+  assertok((sock = socket(PF_UNIX, SOCK_STREAM, 0)) >= 0);
   /* remove existing named socket */
   unlink(name);
   /* create socket address structure */
-  memset(&addr,0,sizeof(struct sockaddr_un));
-  addr.sun_family=AF_UNIX;
-  strncpy(addr.sun_path,name,sizeof(addr.sun_path));
-  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
+  memset(&addr, 0, sizeof(struct sockaddr_un));
+  addr.sun_family = AF_UNIX;
+  strncpy(addr.sun_path, name, sizeof(addr.sun_path));
+  addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
   /* bind to the named socket */
-  assertok(bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_un))==0);
+  assertok(bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) == 
0);
   /* close the file descriptor on exit */
-  assertok(fcntl(sock,F_SETFD,FD_CLOEXEC)>=0);
+  assertok(fcntl(sock, F_SETFD, FD_CLOEXEC) >= 0);
   /* start listening for connections */
-  assertok(listen(sock,SOMAXCONN)>=0);
+  assertok(listen(sock, SOMAXCONN) >= 0);
   /* we're done */
   return sock;
 }
@@ -72,11 +72,11 @@
   struct sockaddr_storage addr;
   socklen_t alen;
   /* accept a new connection */
-  alen=(socklen_t)sizeof(struct sockaddr_storage);
-  assertok((csock=accept(sock,(struct sockaddr *)&addr,&alen))>=0);
+  alen = (socklen_t)sizeof(struct sockaddr_storage);
+  assertok((csock = accept(sock, (struct sockaddr *)&addr, &alen)) >= 0);
   /* make sure O_NONBLOCK is not inherited */
-  assertok((j=fcntl(csock,F_GETFL,0))>=0);
-  assertok(fcntl(csock,F_SETFL,j&~O_NONBLOCK)>=0);
+  assertok((j = fcntl(csock, F_GETFL, 0)) >= 0);
+  assertok(fcntl(csock, F_SETFL, j & ~O_NONBLOCK) >= 0);
   /* return socket */
   return csock;
 }
@@ -87,27 +87,27 @@
   int sock;
   struct sockaddr_un addr;
   /* create a socket */
-  assertok((sock=socket(PF_UNIX,SOCK_STREAM,0))>=0);
+  assertok((sock = socket(PF_UNIX, SOCK_STREAM, 0)) >= 0);
   /* create socket address structure */
-  memset(&addr,0,sizeof(struct sockaddr_un));
-  addr.sun_family=AF_UNIX;
-  strncpy(addr.sun_path,name,sizeof(addr.sun_path));
-  addr.sun_path[sizeof(addr.sun_path)-1]='\0';
+  memset(&addr, 0, sizeof(struct sockaddr_un));
+  addr.sun_family = AF_UNIX;
+  strncpy(addr.sun_path, name, sizeof(addr.sun_path));
+  addr.sun_path[sizeof(addr.sun_path) - 1] = '\0';
   /* connect to the socket */
-  assertok(connect(sock,(struct sockaddr *)&addr,(socklen_t)sizeof(struct 
sockaddr_un))>=0);
+  assertok(connect(sock, (struct sockaddr *)&addr, (socklen_t)sizeof(struct 
sockaddr_un)) >= 0);
   /* return the socket */
   return sock;
 }
 
 #define SOCKETNAME "/tmp/test_getpeercred.sock"
 
-#define assertwarn(assertion) \
-  if (!(assertion)) \
-    fprintf(stderr,"test_getpeercred: %s:%d: %s: Assertion `%s' failed\n", \
+#define assertwarn(assertion)                                               \
+  if (!(assertion))                                                         \
+    fprintf(stderr, "test_getpeercred: %s:%d: %s: Assertion `%s' failed\n", \
             __FILE__, __LINE__, __ASSERT_FUNCTION, __STRING(assertion));
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   int ssock;
   int csock;
@@ -116,16 +116,16 @@
   gid_t gid;
   pid_t pid;
   /* create a socket to listen on */
-  ssock=create_socket(SOCKETNAME);
+  ssock = create_socket(SOCKETNAME);
   /* open a connection to the socket */
-  csock=open_socket(SOCKETNAME);
+  csock = open_socket(SOCKETNAME);
   /* get a connection from the server socket */
-  fsock=acceptconnection(ssock);
+  fsock = acceptconnection(ssock);
   /* look up client information */
-  assert(getpeercred(fsock,&uid,&gid,&pid)==0);
-  assert(uid==geteuid());
-  assertwarn(gid==getegid());
-  assertwarn(pid==getpid());
+  assert(getpeercred(fsock, &uid, &gid, &pid) == 0);
+  assert(uid == geteuid());
+  assertwarn(gid == getegid());
+  assertwarn(pid == getpid());
   /* remove the socket */
   unlink(SOCKETNAME);
   return 0;

Modified: nss-pam-ldapd/tests/test_myldap.c
==============================================================================
--- nss-pam-ldapd/tests/test_myldap.c   Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_myldap.c   Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_myldap.c - simple test for the myldap module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2009, 2011 Arthur de Jong
+   Copyright (C) 2007, 2008, 2009, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -55,44 +55,46 @@
   int rc;
   /* initialize session */
   printf("test_myldap: test_search(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
   printf("test_myldap: test_search(): doing search...\n");
-  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                       LDAP_SCOPE_SUBTREE,
-                       "(objectclass=posixAccount)",
-                       attrs,NULL);
-  assert(search!=NULL);
+  search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                         LDAP_SCOPE_SUBTREE,
+                         "(objectclass=posixAccount)", attrs, NULL);
+  assert(search != NULL);
   /* go over results */
   printf("test_myldap: test_search(): get results...\n");
-  for (i=0;(entry=myldap_get_entry(search,&rc))!=NULL;i++)
+  for (i = 0; (entry = myldap_get_entry(search, &rc)) != NULL; i++)
   {
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_search(): [%d] DN 
%s\n",i,myldap_get_dn(entry));
-    else if (i==MAXRESULTS)
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_search(): [%d] DN %s\n",
+             i, myldap_get_dn(entry));
+    else if (i == MAXRESULTS)
       printf("test_myldap: test_search(): ...\n");
   }
-  printf("test_myldap: test_search(): %d entries returned: 
%s\n",i,ldap_err2string(rc));
-  assert(rc==LDAP_SUCCESS);
+  printf("test_myldap: test_search(): %d entries returned: %s\n",
+         i, ldap_err2string(rc));
+  assert(rc == LDAP_SUCCESS);
   /* perform another search */
   printf("test_myldap: test_search(): doing search...\n");
-  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                       LDAP_SCOPE_SUBTREE,
-                       "(objectclass=posixGroup)",
-                       attrs,NULL);
-  assert(search!=NULL);
+  search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                         LDAP_SCOPE_SUBTREE,
+                         "(objectclass=posixGroup)", attrs, NULL);
+  assert(search != NULL);
   /* go over results */
   printf("test_myldap: test_search(): get results...\n");
-  for (i=0;(entry=myldap_get_entry(search,&rc))!=NULL;i++)
+  for (i = 0; (entry = myldap_get_entry(search, &rc)) != NULL; i++)
   {
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_search(): [%d] DN 
%s\n",i,myldap_get_dn(entry));
-    else if (i==MAXRESULTS)
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_search(): [%d] DN %s\n",
+             i, myldap_get_dn(entry));
+    else if (i == MAXRESULTS)
       printf("test_myldap: test_search(): ...\n");
   }
-  printf("test_myldap: test_search(): %d entries returned: 
%s\n",i,ldap_err2string(rc));
-  assert(rc==LDAP_SUCCESS);
+  printf("test_myldap: test_search(): %d entries returned: %s\n",
+         i, ldap_err2string(rc));
+  assert(rc == LDAP_SUCCESS);
   /* clean up */
   myldap_session_close(session);
 }
@@ -100,45 +102,44 @@
 static void test_get(void)
 {
   MYLDAP_SESSION *session;
-  MYLDAP_SEARCH *search1,*search2;
+  MYLDAP_SEARCH *search1, *search2;
   MYLDAP_ENTRY *entry;
   const char *attrs1[] = { "cn", "userPassword", "memberUid", "gidNumber", 
"member", NULL };
   const char *attrs2[] = { "uid", NULL };
   int rc;
   /* initialize session */
   printf("test_myldap: test_get(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
   printf("test_myldap: test_get(): doing search...\n");
-  search1=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                        LDAP_SCOPE_SUBTREE,
-                        
"(&(|(objectClass=posixGroup)(objectClass=groupOfNames))(cn=testgroup2))",
-                        attrs1,NULL);
-  assert(search1!=NULL);
+  search1 = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                          LDAP_SCOPE_SUBTREE,
+                          
"(&(|(objectClass=posixGroup)(objectClass=groupOfNames))(cn=testgroup2))",
+                          attrs1, NULL);
+  assert(search1 != NULL);
   /* get one entry */
-  entry=myldap_get_entry(search1,&rc);
-  assert(entry!=NULL);
-  printf("test_myldap: test_get(): got DN %s\n",myldap_get_dn(entry));
+  entry = myldap_get_entry(search1, &rc);
+  assert(entry != NULL);
+  printf("test_myldap: test_get(): got DN %s\n", myldap_get_dn(entry));
   /* get some attribute values */
-  (void)myldap_get_values(entry,"gidNumber");
-  (void)myldap_get_values(entry,"userPassword");
-  (void)myldap_get_values(entry,"memberUid");
-  (void)myldap_get_values(entry,"member");
+  (void)myldap_get_values(entry, "gidNumber");
+  (void)myldap_get_values(entry, "userPassword");
+  (void)myldap_get_values(entry, "memberUid");
+  (void)myldap_get_values(entry, "member");
   /* perform another search */
   printf("test_myldap: test_get(): doing get...\n");
-  search2=myldap_search(session,"cn=Test User2,ou=people,dc=test,dc=tld",
-                        LDAP_SCOPE_BASE,
-                        "(objectclass=posixAccount)",
-                        attrs2,NULL);
-  assert(search2!=NULL);
+  search2 = myldap_search(session, "cn=Test User2,ou=people,dc=test,dc=tld",
+                          LDAP_SCOPE_BASE,
+                          "(objectclass=posixAccount)", attrs2, NULL);
+  assert(search2 != NULL);
   /* get one entry */
-  entry=myldap_get_entry(search2,&rc);
-  assert(entry!=NULL);
-  printf("test_myldap: test_get(): got DN %s\n",myldap_get_dn(entry));
+  entry = myldap_get_entry(search2, &rc);
+  assert(entry != NULL);
+  printf("test_myldap: test_get(): got DN %s\n", myldap_get_dn(entry));
   /* test if searches are ok */
-  assert(myldap_get_entry(search1,&rc)==NULL);
-  assert(myldap_get_entry(search2,&rc)==NULL);
+  assert(myldap_get_entry(search1, &rc) == NULL);
+  assert(myldap_get_entry(search2, &rc) == NULL);
   /* clean up */
   myldap_session_close(session);
 }
@@ -155,45 +156,49 @@
   int i;
   /* initialize session */
   printf("test_myldap: test_get_values(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
-  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                          LDAP_SCOPE_SUBTREE,
-                          "(&(objectClass=posixAccount)(uid=*))",
-                          attrs,NULL);
-  assert(search!=NULL);
+  search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                         LDAP_SCOPE_SUBTREE,
+                         "(&(objectClass=posixAccount)(uid=*))", attrs, NULL);
+  assert(search != NULL);
   /* go over results */
-  for (i=0;(entry=myldap_get_entry(search,NULL))!=NULL;i++)
+  for (i = 0; (entry = myldap_get_entry(search, NULL)) != NULL; i++)
   {
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] DN 
%s\n",i,myldap_get_dn(entry));
-    else if (i==MAXRESULTS)
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] DN %s\n",
+             i, myldap_get_dn(entry));
+    else if (i == MAXRESULTS)
       printf("test_myldap: test_get_values(): ...\n");
     /* try to get uid from attribute */
-    vals=myldap_get_values(entry,"uidNumber");
-    assert((vals!=NULL)&&(vals[0]!=NULL));
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] uidNumber=%s\n",i,vals[0]);
+    vals = myldap_get_values(entry, "uidNumber");
+    assert((vals != NULL) && (vals[0] != NULL));
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] uidNumber=%s\n",
+             i, vals[0]);
     /* try to get gid from attribute */
-    vals=myldap_get_values(entry,"gidNumber");
-    assert((vals!=NULL)&&(vals[0]!=NULL));
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] gidNumber=%s\n",i,vals[0]);
+    vals = myldap_get_values(entry, "gidNumber");
+    assert((vals != NULL) && (vals[0] != NULL));
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] gidNumber=%s\n",
+             i, vals[0]);
     /* write LDF_STRING(PASSWD_NAME) */
-    vals=myldap_get_values(entry,"uid");
-    assert((vals!=NULL)&&(vals[0]!=NULL));
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] uid=%s\n",i,vals[0]);
+    vals = myldap_get_values(entry, "uid");
+    assert((vals != NULL) && (vals[0] != NULL));
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] uid=%s\n", i, vals[0]);
     /* get rdn values */
-    rdnval=myldap_get_rdn_value(entry,"cn");
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] 
cdrdn=%s\n",i,rdnval==NULL?"NULL":rdnval);
-    rdnval=myldap_get_rdn_value(entry,"uid");
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_get_values(): [%d] 
uidrdn=%s\n",i,rdnval==NULL?"NULL":rdnval);
+    rdnval = myldap_get_rdn_value(entry, "cn");
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] cdrdn=%s\n",
+             i, rdnval == NULL ? "NULL" : rdnval);
+    rdnval = myldap_get_rdn_value(entry, "uid");
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_get_values(): [%d] uidrdn=%s\n",
+             i, rdnval == NULL ? "NULL" : rdnval);
     /* check objectclass */
-    assert(myldap_has_objectclass(entry,"posixAccount"));
+    assert(myldap_has_objectclass(entry, "posixAccount"));
   }
   /* clean up */
   myldap_session_close(session);
@@ -209,29 +214,37 @@
   char buf[80];
   /* initialize session */
   printf("test_myldap: test_get_rdnvalues(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
   printf("test_myldap: test_get_rdnvalues(): doing search...\n");
-  search=myldap_search(session,"cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld",
-                       LDAP_SCOPE_BASE,
-                       "(objectClass=*)",
-                       attrs,NULL);
-  assert(search!=NULL);
+  search = myldap_search(session, "cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld",
+                    LDAP_SCOPE_BASE, "(objectClass=*)", attrs, NULL);
+  assert(search != NULL);
   /* get one entry */
-  entry=myldap_get_entry(search,&rc);
-  assert(entry!=NULL);
-  printf("test_myldap: test_get_rdnvalues(): got DN 
%s\n",myldap_get_dn(entry));
+  entry = myldap_get_entry(search, &rc);
+  assert(entry != NULL);
+  printf("test_myldap: test_get_rdnvalues(): got DN %s\n",
+         myldap_get_dn(entry));
   /* get some values from DN */
-  printf("test_myldap: test_get_rdnvalues(): 
DN.uid=%s\n",myldap_get_rdn_value(entry,"uid"));
-  printf("test_myldap: test_get_rdnvalues(): 
DN.cn=%s\n",myldap_get_rdn_value(entry,"cn"));
-  printf("test_myldap: test_get_rdnvalues(): 
DN.uidNumber=%s\n",myldap_get_rdn_value(entry,"uidNumber"));
+  printf("test_myldap: test_get_rdnvalues(): DN.uid=%s\n",
+         myldap_get_rdn_value(entry, "uid"));
+  printf("test_myldap: test_get_rdnvalues(): DN.cn=%s\n",
+         myldap_get_rdn_value(entry, "cn"));
+  printf("test_myldap: test_get_rdnvalues(): DN.uidNumber=%s\n",
+         myldap_get_rdn_value(entry, "uidNumber"));
   /* clean up */
   myldap_session_close(session);
   /* some tests */
-  printf("test_myldap: test_get_rdnvalues(): 
DN.uid=%s\n",myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld","uid",buf,sizeof(buf)));
-  printf("test_myldap: test_get_rdnvalues(): 
DN.cn=%s\n",myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld","cn",buf,sizeof(buf)));
-  printf("test_myldap: test_get_rdnvalues(): 
DN.uidNumber=%s\n",myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld","uidNumber",buf,sizeof(buf)));
+  printf("test_myldap: test_get_rdnvalues(): DN.uid=%s\n",
+         myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld",
+                               "uid", buf, sizeof(buf)));
+  printf("test_myldap: test_get_rdnvalues(): DN.cn=%s\n",
+         myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld",
+                              "cn", buf, sizeof(buf)));
+  printf("test_myldap: test_get_rdnvalues(): DN.uidNumber=%s\n",
+         myldap_cpy_rdn_value("cn=Aka 
Ashbach+uid=aashbach,ou=lotsofpeople,dc=test,dc=tld",
+                              "uidNumber", buf, sizeof(buf)));
 }
 
 /* this method tests to see if we can perform two searches within
@@ -239,56 +252,60 @@
 static void test_two_searches(void)
 {
   MYLDAP_SESSION *session;
-  MYLDAP_SEARCH *search1,*search2;
+  MYLDAP_SEARCH *search1, *search2;
   MYLDAP_ENTRY *entry;
   const char *attrs[] = { "uidNumber", "cn", "gidNumber", "uid", 
"objectClass", NULL };
   const char **vals;
   /* initialize session */
   printf("test_myldap: test_two_searches(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search1 */
-  search1=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                        LDAP_SCOPE_SUBTREE,
-                        "(&(objectClass=posixAccount)(uid=*))",
-                        attrs,NULL);
-  assert(search1!=NULL);
+  search1 = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                          LDAP_SCOPE_SUBTREE,
+                          "(&(objectClass=posixAccount)(uid=*))",
+                          attrs, NULL);
+  assert(search1 != NULL);
   /* get a result from search1 */
-  entry=myldap_get_entry(search1,NULL);
-  assert(entry!=NULL);
-  printf("test_myldap: test_two_searches(): [search1] DN 
%s\n",myldap_get_dn(entry));
-  vals=myldap_get_values(entry,"cn");
-  assert((vals!=NULL)&&(vals[0]!=NULL));
-  printf("test_myldap: test_two_searches(): [search1] cn=%s\n",vals[0]);
+  entry = myldap_get_entry(search1, NULL);
+  assert(entry != NULL);
+  printf("test_myldap: test_two_searches(): [search1] DN %s\n",
+         myldap_get_dn(entry));
+  vals = myldap_get_values(entry, "cn");
+  assert((vals != NULL) && (vals[0] != NULL));
+  printf("test_myldap: test_two_searches(): [search1] cn=%s\n", vals[0]);
   /* start a second search */
-  search2=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                        LDAP_SCOPE_SUBTREE,
-                        "(&(objectclass=posixGroup)(gidNumber=*))",
-                        attrs,NULL);
-  assert(search2!=NULL);
+  search2 = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                          LDAP_SCOPE_SUBTREE,
+                          "(&(objectclass=posixGroup)(gidNumber=*))",
+                          attrs, NULL);
+  assert(search2 != NULL);
   /* get a result from search2 */
-  entry=myldap_get_entry(search2,NULL);
-  assert(entry!=NULL);
-  printf("test_myldap: test_two_searches(): [search2] DN 
%s\n",myldap_get_dn(entry));
-  vals=myldap_get_values(entry,"cn");
-  assert((vals!=NULL)&&(vals[0]!=NULL));
-  printf("test_myldap: test_two_searches(): [search2] cn=%s\n",vals[0]);
+  entry = myldap_get_entry(search2, NULL);
+  assert(entry != NULL);
+  printf("test_myldap: test_two_searches(): [search2] DN %s\n",
+         myldap_get_dn(entry));
+  vals = myldap_get_values(entry, "cn");
+  assert((vals != NULL) && (vals[0] != NULL));
+  printf("test_myldap: test_two_searches(): [search2] cn=%s\n", vals[0]);
   /* get another result from search1 */
-  entry=myldap_get_entry(search1,NULL);
-  assert(entry!=NULL);
-  printf("test_myldap: test_two_searches(): [search1] DN 
%s\n",myldap_get_dn(entry));
-  vals=myldap_get_values(entry,"cn");
-  assert((vals!=NULL)&&(vals[0]!=NULL));
-  printf("test_myldap: test_two_searches(): [search1] cn=%s\n",vals[0]);
+  entry = myldap_get_entry(search1, NULL);
+  assert(entry != NULL);
+  printf("test_myldap: test_two_searches(): [search1] DN %s\n",
+         myldap_get_dn(entry));
+  vals = myldap_get_values(entry, "cn");
+  assert((vals != NULL) && (vals[0] != NULL));
+  printf("test_myldap: test_two_searches(): [search1] cn=%s\n", vals[0]);
   /* stop search1 */
   myldap_search_close(search1);
   /* get another result from search2 */
-  entry=myldap_get_entry(search2,NULL);
-  assert(entry!=NULL);
-  printf("test_myldap: test_two_searches(): [search2] DN 
%s\n",myldap_get_dn(entry));
-  vals=myldap_get_values(entry,"cn");
-  assert((vals!=NULL)&&(vals[0]!=NULL));
-  printf("test_myldap: test_two_searches(): [search2] cn=%s\n",vals[0]);
+  entry = myldap_get_entry(search2, NULL);
+  assert(entry != NULL);
+  printf("test_myldap: test_two_searches(): [search2] DN %s\n",
+         myldap_get_dn(entry));
+  vals = myldap_get_values(entry, "cn");
+  assert((vals != NULL) && (vals[0] != NULL));
+  printf("test_myldap: test_two_searches(): [search2] cn=%s\n", vals[0]);
   /* clean up */
   myldap_session_close(session);
 }
@@ -300,28 +317,29 @@
   MYLDAP_SEARCH *search;
   MYLDAP_ENTRY *entry;
   const char *attrs[] = { "uid", "cn", "gid", NULL };
-  struct worker_args *args=(struct worker_args *)arg;
+  struct worker_args *args = (struct worker_args *)arg;
   int i;
   int rc;
   /* initialize session */
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
-  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                       LDAP_SCOPE_SUBTREE,
-                       "(objectclass=posixAccount)",
-                       attrs,NULL);
-  assert(search!=NULL);
+  search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                         LDAP_SCOPE_SUBTREE,
+                         "(objectclass=posixAccount)", attrs, NULL);
+  assert(search != NULL);
   /* go over results */
-  for (i=0;(entry=myldap_get_entry(search,&rc))!=NULL;i++)
+  for (i = 0; (entry = myldap_get_entry(search, &rc)) != NULL; i++)
   {
-    if (i<MAXRESULTS)
-      printf("test_myldap: test_threads(): [worker %d] [%d] DN 
%s\n",args->id,i,myldap_get_dn(entry));
-    else if (i==MAXRESULTS)
-      printf("test_myldap: test_threads(): [worker %d] ...\n",args->id);
+    if (i < MAXRESULTS)
+      printf("test_myldap: test_threads(): [worker %d] [%d] DN %s\n",
+             args->id, i, myldap_get_dn(entry));
+    else if (i == MAXRESULTS)
+      printf("test_myldap: test_threads(): [worker %d] ...\n", args->id);
   }
-  printf("test_myldap: test_threads(): [worker %d] DONE: 
%s\n",args->id,ldap_err2string(rc));
-  assert(rc==LDAP_SUCCESS);
+  printf("test_myldap: test_threads(): [worker %d] DONE: %s\n",
+         args->id, ldap_err2string(rc));
+  assert(rc == LDAP_SUCCESS);
   /* clean up */
   myldap_session_close(session);
   return 0;
@@ -336,15 +354,15 @@
   int i;
   struct worker_args args[NUM_THREADS];
   /* start worker threads */
-  for (i=0;i<NUM_THREADS;i++)
+  for (i = 0; i < NUM_THREADS; i++)
   {
-    args[i].id=i;
-    assert(pthread_create(&my_threads[i],NULL,worker,&(args[i]))==0);
+    args[i].id = i;
+    assert(pthread_create(&my_threads[i], NULL, worker, &(args[i])) == 0);
   }
   /* wait for all threads to die */
-  for (i=0;i<NUM_THREADS;i++)
+  for (i = 0; i < NUM_THREADS; i++)
   {
-    assert(pthread_join(my_threads[i],NULL)==0);
+    assert(pthread_join(my_threads[i], NULL) == 0);
   }
 }
 
@@ -353,71 +371,70 @@
   MYLDAP_SESSION *session;
   MYLDAP_SEARCH *search;
   const char *attrs[] = { "uid", "cn", "gid", NULL };
-  char *old_uris[NSS_LDAP_CONFIG_URI_MAX+1];
+  char *old_uris[NSS_LDAP_CONFIG_URI_MAX + 1];
   int i;
   /* save the old URIs */
-  for (i=0;i<(NSS_LDAP_CONFIG_URI_MAX+1);i++)
+  for (i = 0; i < (NSS_LDAP_CONFIG_URI_MAX + 1); i++)
   {
-    old_uris[i]=nslcd_cfg->ldc_uris[i].uri;
-    nslcd_cfg->ldc_uris[i].uri=NULL;
+    old_uris[i] = nslcd_cfg->ldc_uris[i].uri;
+    nslcd_cfg->ldc_uris[i].uri = NULL;
   }
   /* set new URIs */
-  i=0;
-  nslcd_cfg->ldc_uris[i++].uri="ldapi://%2fdev%2fnull/";
-  nslcd_cfg->ldc_uris[i++].uri="ldap://10.10.10.10/";;
-  nslcd_cfg->ldc_uris[i++].uri="ldapi://%2fdev%2fnonexistent/";
-  nslcd_cfg->ldc_uris[i++].uri="ldap://nosuchhost/";;
-  nslcd_cfg->ldc_uris[i++].uri=NULL;
+  i = 0;
+  nslcd_cfg->ldc_uris[i++].uri = "ldapi://%2fdev%2fnull/";
+  nslcd_cfg->ldc_uris[i++].uri = "ldap://10.10.10.10/";;
+  nslcd_cfg->ldc_uris[i++].uri = "ldapi://%2fdev%2fnonexistent/";
+  nslcd_cfg->ldc_uris[i++].uri = "ldap://nosuchhost/";;
+  nslcd_cfg->ldc_uris[i++].uri = NULL;
   /* initialize session */
   printf("test_myldap: test_connections(): getting session...\n");
-  session=myldap_create_session();
-  assert(session!=NULL);
+  session = myldap_create_session();
+  assert(session != NULL);
   /* perform search */
   printf("test_myldap: test_connections(): doing search...\n");
-  search=myldap_search(session,nslcd_cfg->ldc_bases[0],
-                       LDAP_SCOPE_SUBTREE,
-                       "(objectclass=posixAccount)",
-                       attrs,NULL);
-  assert(search==NULL);
+  search = myldap_search(session, nslcd_cfg->ldc_bases[0],
+                         LDAP_SCOPE_SUBTREE,
+                         "(objectclass=posixAccount)", attrs, NULL);
+  assert(search == NULL);
   /* clean up */
   myldap_session_close(session);
   /* restore the old URIs */
-  for (i=0;i<(NSS_LDAP_CONFIG_URI_MAX+1);i++)
-    nslcd_cfg->ldc_uris[i].uri=old_uris[i];
+  for (i = 0; i < (NSS_LDAP_CONFIG_URI_MAX + 1); i++)
+    nslcd_cfg->ldc_uris[i].uri = old_uris[i];
 }
 
 /* test whether myldap_escape() handles buffer overlows correctly */
 static void test_escape(void)
 {
   char buffer[1024];
-  assert(myldap_escape("test",buffer,4)!=0);
-  assert(myldap_escape("t*st",buffer,5)!=0);
-  assert(myldap_escape("t*st",buffer,20)==0);
-  assertstreq(buffer,"t\\2ast");
+  assert(myldap_escape("test", buffer, 4) != 0);
+  assert(myldap_escape("t*st", buffer, 5) != 0);
+  assert(myldap_escape("t*st", buffer, 20) == 0);
+  assertstreq(buffer, "t\\2ast");
 }
 
 /* the main program... */
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
 {
   char *srcdir;
   char fname[100];
   struct sigaction act;
   /* build the name of the file */
-  srcdir=getenv("srcdir");
-  if (srcdir==NULL)
-    srcdir=".";
-  snprintf(fname,sizeof(fname),"%s/nslcd-test.conf",srcdir);
-  fname[sizeof(fname)-1]='\0';
+  srcdir = getenv("srcdir");
+  if (srcdir == NULL)
+    srcdir = ".";
+  snprintf(fname, sizeof(fname), "%s/nslcd-test.conf", srcdir);
+  fname[sizeof(fname) - 1] = '\0';
   /* initialize configuration */
   cfg_init(fname);
   /* partially initialize logging */
   log_setdefaultloglevel(LOG_DEBUG);
   /* ignore SIGPIPE */
-  memset(&act,0,sizeof(struct sigaction));
-  act.sa_handler=SIG_IGN;
+  memset(&act, 0, sizeof(struct sigaction));
+  act.sa_handler = SIG_IGN;
   sigemptyset(&act.sa_mask);
-  act.sa_flags=SA_RESTART|SA_NOCLDSTOP;
-  assert(sigaction(SIGPIPE,&act,NULL)==0);
+  act.sa_flags = SA_RESTART | SA_NOCLDSTOP;
+  assert(sigaction(SIGPIPE, &act, NULL) == 0);
   /* do tests */
   test_search();
   test_get();

Modified: nss-pam-ldapd/tests/test_set.c
==============================================================================
--- nss-pam-ldapd/tests/test_set.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_set.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_set.c - simple test for the set module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2009, 2010 Arthur de Jong
+   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -32,38 +32,37 @@
 
 static int isknownvalue(const char *value)
 {
-  return value!=NULL && (
-          (strcmp(value,"key1")==0) ||
-          (strcmp(value,"key2")==0) ||
-          (strcmp(value,"key3")==0) );
+  return value != NULL && (
+        (strcmp(value, "key1") == 0) || (strcmp(value, "key2") == 0) ||
+        (strcmp(value, "key3") == 0));
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   SET *set;
   const char **list;
   int i;
 
   /* initialize */
-  set=set_new();
+  set = set_new();
 
   /* store some entries */
-  set_add(set,"key1");
-  set_add(set,"key2");
-  set_add(set,"key3");
-  set_add(set,"key2");
+  set_add(set, "key1");
+  set_add(set, "key2");
+  set_add(set, "key3");
+  set_add(set, "key2");
 
   /* check set contents */
-  assert(set_contains(set,"key1"));
-  assert(set_contains(set,"key2"));
-  assert(set_contains(set,"key3"));
-  assert(!set_contains(set,"key4"));
-  assert(!set_contains(set,"KEY1"));
+  assert(set_contains(set, "key1"));
+  assert(set_contains(set, "key2"));
+  assert(set_contains(set, "key3"));
+  assert(!set_contains(set, "key4"));
+  assert(!set_contains(set, "KEY1"));
 
   /* loop over set contents */
-  list=set_tolist(set);
-  for (i=0;list[i]!=NULL;i++)
+  list = set_tolist(set);
+  for (i = 0; list[i] != NULL; i++)
   {
     assert(isknownvalue(list[i]));
   }
@@ -72,7 +71,7 @@
   assert(isknownvalue(set_pop(set)));
   assert(isknownvalue(set_pop(set)));
   assert(isknownvalue(set_pop(set)));
-  assert(set_pop(set)==NULL);
+  assert(set_pop(set) == NULL);
 
   /* free set */
   set_free(set);

Modified: nss-pam-ldapd/tests/test_tio.c
==============================================================================
--- nss-pam-ldapd/tests/test_tio.c      Fri Dec 21 22:00:30 2012        (r1872)
+++ nss-pam-ldapd/tests/test_tio.c      Sat Dec 22 22:38:26 2012        (r1873)
@@ -2,7 +2,7 @@
    test_tio.c - simple test for the tio module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2007, 2008, 2011 Arthur de Jong
+   Copyright (C) 2007, 2008, 2011, 2012 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -51,26 +51,27 @@
 static void *help_tiowriter(void *arg)
 {
   TFILE *fp;
-  size_t i,j,k;
+  size_t i, j, k;
   uint8_t *buf;
-  struct helper_args *hargs=(struct helper_args *)arg;
+  struct helper_args *hargs = (struct helper_args *)arg;
   /* allocate the buffer */
-  buf=(uint8_t *)malloc(hargs->blocksize);
-  assert(buf!=NULL);
+  buf = (uint8_t *)malloc(hargs->blocksize);
+  assert(buf != NULL);
   /* open the file */
-  
fp=tio_fdopen(hargs->fd,hargs->timeout*1000,hargs->timeout*1000,4*1024,8*1024,4*1024,8*1024);
-  assertok(fp!=NULL);
+  fp = tio_fdopen(hargs->fd, hargs->timeout * 1000, hargs->timeout * 1000,
+                  4 * 1024, 8 * 1024, 4 * 1024, 8 * 1024);
+  assertok(fp != NULL);
   /* write the blocks */
-  i=0;
-  for (k=0;k<hargs->blocks;k++)
+  i = 0;
+  for (k = 0; k < hargs->blocks; k++)
   {
     /* fill the buffer */
-    for (j=0;j<hargs->blocksize;j++)
-      buf[j]=i++;
-    assertok(tio_write(fp,buf,hargs->blocksize)==0);
+    for (j = 0; j < hargs->blocksize; j++)
+      buf[j] = i++;
+    assertok(tio_write(fp, buf, hargs->blocksize) == 0);
   }
   /* close the file flushing the buffer */
-  assertok(tio_close(fp)==0);
+  assertok(tio_close(fp) == 0);
   /* we're done */
   free(buf);
   return NULL;
@@ -79,26 +80,27 @@
 static void *help_tioreader(void *arg)
 {
   TFILE *fp;
-  size_t i,j,k;
+  size_t i, j, k;
   uint8_t *buf;
-  struct helper_args *hargs=(struct helper_args *)arg;
+  struct helper_args *hargs = (struct helper_args *)arg;
   /* allocate the buffer */
-  buf=(uint8_t *)malloc(hargs->blocksize);
-  assert(buf!=NULL);
+  buf = (uint8_t *)malloc(hargs->blocksize);
+  assert(buf != NULL);
   /* open the file */
-  
fp=tio_fdopen(hargs->fd,hargs->timeout*1000,hargs->timeout*1000,4*1024,8*1024,4*1024,8*1024);
-  assertok(fp!=NULL);
+  fp = tio_fdopen(hargs->fd, hargs->timeout * 1000, hargs->timeout * 1000,
+                  4 * 1024, 8 * 1024, 4 * 1024, 8 * 1024);
+  assertok(fp != NULL);
   /* read the blocks */
-  i=0;
-  for (k=0;k<hargs->blocks;k++)
+  i = 0;
+  for (k = 0; k < hargs->blocks; k++)
   {
-    assertok(tio_read(fp,buf,hargs->blocksize)==0);
+    assertok(tio_read(fp, buf, hargs->blocksize) == 0);
     /* check the buffer */
-    for (j=0;j<hargs->blocksize;j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < hargs->blocksize; j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* close the file */
-  assertok(tio_close(fp)==0);
+  assertok(tio_close(fp) == 0);
   /* we're done */
   free(buf);
   return NULL;
@@ -107,26 +109,26 @@
 static void *help_normwriter(void *arg)
 {
   FILE *fp;
-  size_t i,j,k;
+  size_t i, j, k;
   uint8_t *buf;
-  struct helper_args *hargs=(struct helper_args *)arg;
+  struct helper_args *hargs = (struct helper_args *)arg;
   /* allocate the buffer */
-  buf=(uint8_t *)malloc(hargs->blocksize);
-  assert(buf!=NULL);
+  buf = (uint8_t *)malloc(hargs->blocksize);
+  assert(buf != NULL);
   /* open the file */
-  fp=fdopen(hargs->fd,"wb");
-  assertok(fp!=NULL);
+  fp = fdopen(hargs->fd, "wb");
+  assertok(fp != NULL);
   /* write the blocks */
-  i=0;
-  for (k=0;k<hargs->blocks;k++)
+  i = 0;
+  for (k = 0; k < hargs->blocks; k++)
   {
     /* fill the buffer */
-    for (j=0;j<hargs->blocksize;j++)
-      buf[j]=i++;
-    assertok(fwrite(buf,hargs->blocksize,1,fp)==1);
+    for (j = 0; j < hargs->blocksize; j++)
+      buf[j] = i++;
+    assertok(fwrite(buf, hargs->blocksize, 1, fp) == 1);
   }
   /* close the file flushing the buffer */
-  assertok(fclose(fp)==0);
+  assertok(fclose(fp) == 0);
   /* we're done */
   free(buf);
   return NULL;
@@ -135,21 +137,21 @@
 static void *help_normreader(void *arg)
 {
   FILE *fp;
-  size_t i,j,k;
-  struct helper_args *hargs=(struct helper_args *)arg;
+  size_t i, j, k;
+  struct helper_args *hargs = (struct helper_args *)arg;
   /* open the file */
-  fp=fdopen(hargs->fd,"rb");
-  assertok(fp!=NULL);
+  fp = fdopen(hargs->fd, "rb");
+  assertok(fp != NULL);
   /* read the blocks */
-  i=0;
-  for (k=0;k<hargs->blocks;k++)
+  i = 0;
+  for (k = 0; k < hargs->blocks; k++)
   {
     /* check the buffer */
-    for (j=0;j<hargs->blocksize;j++)
-      assertok(fgetc(fp)==(uint8_t)(i++));
+    for (j = 0; j < hargs->blocksize; j++)
+      assertok(fgetc(fp) == (uint8_t)(i++));
   }
   /* close the file */
-  assertok(fclose(fp)==0);
+  assertok(fclose(fp) == 0);
   return NULL;
 }
 
@@ -162,28 +164,30 @@
 {
   int sp[2];
   pthread_t wthread, rthread;
-  struct helper_args wargs,rargs;
+  struct helper_args wargs, rargs;
   /* set up the socket pair */
-  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  assertok(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
   /* log */
-  printf("test_tio: writing %d blocks of %d bytes (%d 
total)\n",(int)wbl,(int)wbs,(int)(wbl*wbs));
-  printf("test_tio: reading %d blocks of %d bytes (%d 
total)\n",(int)rbl,(int)rbs,(int)(rbl*rbs));
+  printf("test_tio: writing %d blocks of %d bytes (%d total)\n",
+         (int)wbl, (int)wbs, (int)(wbl * wbs));
+  printf("test_tio: reading %d blocks of %d bytes (%d total)\n",
+         (int)rbl, (int)rbs, (int)(rbl * rbs));
   /* start the writer thread */
-  wargs.fd=sp[0];
-  wargs.blocksize=wbs;
-  wargs.blocks=wbl;
-  wargs.timeout=2;
-  assertok(pthread_create(&wthread,NULL,help_tiowriter,&wargs)==0);
+  wargs.fd = sp[0];
+  wargs.blocksize = wbs;
+  wargs.blocks = wbl;
+  wargs.timeout = 2;
+  assertok(pthread_create(&wthread, NULL, help_tiowriter, &wargs) == 0);
 /*  sleep(1); */
   /* start the reader thread */
-  rargs.fd=sp[1];
-  rargs.blocksize=rbs;
-  rargs.blocks=rbl;
-  rargs.timeout=2;
-  assertok(pthread_create(&rthread,NULL,help_tioreader,&rargs)==0);
+  rargs.fd = sp[1];
+  rargs.blocksize = rbs;
+  rargs.blocks = rbl;
+  rargs.timeout = 2;
+  assertok(pthread_create(&rthread, NULL, help_tioreader, &rargs) == 0);
   /* wait for all threads to die */
-  assertok(pthread_join(wthread,NULL)==0);
-  assertok(pthread_join(rthread,NULL)==0);
+  assertok(pthread_join(wthread, NULL) == 0);
+  assertok(pthread_join(rthread, NULL) == 0);
   /* we're done */
   return 0;
 }
@@ -194,74 +198,74 @@
   pthread_t wthread;
   struct helper_args wargs;
   TFILE *fp;
-  size_t i,j,k,save;
+  size_t i, j, k, save;
   uint8_t buf[20];
   /* set up the socket pair */
-  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  assertok(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
   /* start the writer thread */
-  wargs.fd=sp[0];
-  wargs.blocksize=4*1024;
-  wargs.blocks=10;
-  wargs.timeout=2;
-  assertok(pthread_create(&wthread,NULL,help_normwriter,&wargs)==0);
+  wargs.fd = sp[0];
+  wargs.blocksize = 4 * 1024;
+  wargs.blocks = 10;
+  wargs.timeout = 2;
+  assertok(pthread_create(&wthread, NULL, help_normwriter, &wargs) == 0);
   /* set up read handle */
-  fp=tio_fdopen(sp[1],2000,2000,2*1024,4*1024,2*1024,4*1024);
-  assertok(fp!=NULL);
+  fp = tio_fdopen(sp[1], 2000, 2000, 2 * 1024, 4 * 1024, 2 * 1024, 4 * 1024);
+  assertok(fp != NULL);
   /* perform 20 reads */
-  i=0;
-  for (k=0;k<20;k++)
+  i = 0;
+  for (k = 0; k < 20; k++)
   {
-    assertok(tio_read(fp,buf,sizeof(buf))==0);
+    assertok(tio_read(fp, buf, sizeof(buf)) == 0);
     /* check the buffer */
-    for (j=0;j<sizeof(buf);j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < sizeof(buf); j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* mark and perform another 2 reads */
   tio_mark(fp);
-  save=i;
-  for (k=20;k<22;k++)
+  save = i;
+  for (k = 20; k < 22; k++)
   {
-    assertok(tio_read(fp,buf,sizeof(buf))==0);
+    assertok(tio_read(fp, buf, sizeof(buf)) == 0);
     /* check the buffer */
-    for (j=0;j<sizeof(buf);j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < sizeof(buf); j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* check that we can reset */
-  assertok(tio_reset(fp)==0);
+  assertok(tio_reset(fp) == 0);
   /* perform 204 reads (partially the same as before) */
-  i=save;
-  for (k=20;k<224;k++)
+  i = save;
+  for (k = 20; k < 224; k++)
   {
-    assert(tio_read(fp,buf,sizeof(buf))==0);
+    assert(tio_read(fp, buf, sizeof(buf)) == 0);
     /* check the buffer */
-    for (j=0;j<sizeof(buf);j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < sizeof(buf); j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* check that we can reset */
-  assertok(tio_reset(fp)==0);
+  assertok(tio_reset(fp) == 0);
   /* perform 502 reads (partially the same) */
-  i=save;
-  for (k=20;k<522;k++)
+  i = save;
+  for (k = 20; k < 522; k++)
   {
-    assert(tio_read(fp,buf,sizeof(buf))==0);
+    assert(tio_read(fp, buf, sizeof(buf)) == 0);
     /* check the buffer */
-    for (j=0;j<sizeof(buf);j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < sizeof(buf); j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* check that reset is no longer possible */
-  assertok(tio_reset(fp)!=0);
+  assertok(tio_reset(fp) != 0);
   /* read the remainder of the data 1526 reads */
-  for (k=522;k<2048;k++)
+  for (k = 522; k < 2048; k++)
   {
-    assertok(tio_read(fp,buf,sizeof(buf))==0);
+    assertok(tio_read(fp, buf, sizeof(buf)) == 0);
     /* check the buffer */
-    for (j=0;j<sizeof(buf);j++)
-      assert(buf[j]==(uint8_t)(i++));
+    for (j = 0; j < sizeof(buf); j++)
+      assert(buf[j] == (uint8_t)(i++));
   }
   /* close the file */
-  assertok(tio_close(fp)==0);
+  assertok(tio_close(fp) == 0);
   /* wait for the writer thread to die */
-  assertok(pthread_join(wthread,NULL)==0);
+  assertok(pthread_join(wthread, NULL) == 0);
 }
 
 /* this test starts a reader and writer and does not write for a while */
@@ -271,32 +275,32 @@
   TFILE *rfp;
   FILE *wfp;
   uint8_t buf[20];
-  time_t start,end;
+  time_t start, end;
   int saved_errno;
   /* set up the socket pair */
-  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  assertok(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
   /* open the writer */
-  assertok((wfp=fdopen(sp[0],"wb"))!=NULL);
+  assertok((wfp = fdopen(sp[0], "wb")) != NULL);
   /* open the reader */
-  
assertok((rfp=tio_fdopen(sp[1],1100,1100,2*1024,4*1024,2*1024,4*1024))!=NULL);
+  assertok((rfp = tio_fdopen(sp[1], 1100, 1100, 2 * 1024, 4 * 1024, 2 * 1024, 
4 * 1024)) != NULL);
   printf("test_tio: test_timeout_reader: trying to read a block of %d bytes\n",
          (int)sizeof(buf));
   /* perform a read */
-  start=time(NULL);
-  errno=0;
-  assertok(tio_read(rfp,buf,sizeof(buf))!=0);
-  saved_errno=errno;
-  end=time(NULL);
+  start = time(NULL);
+  errno = 0;
+  assertok(tio_read(rfp, buf, sizeof(buf)) != 0);
+  saved_errno = errno;
+  end = time(NULL);
   printf("test_tio: test_timeout_reader: read 0 blocks of %d bytes in %d 
second(s) (%s)\n",
-         (int)sizeof(buf),(int)(end-start),strerror(saved_errno));
+         (int)sizeof(buf), (int)(end - start), strerror(saved_errno));
   /* since the read timeout is more than a second end time should be bigger
      than start time */
-  assert(end>start);
+  assert(end > start);
   /* the error should be timeout */
-  assert(saved_errno==ETIME);
+  assert(saved_errno == ETIME);
   /* close the files */
-  assertok(tio_close(rfp)==0);
-  assertok(fclose(wfp)==0);
+  assertok(tio_close(rfp) == 0);
+  assertok(fclose(wfp) == 0);
 }
 
 /* this test starts a writer and an idle reader */
@@ -307,55 +311,54 @@
   TFILE *wfp;
   int i;
   uint8_t buf[20];
-  time_t start,end;
-  int numblocks=10000;
+  time_t start, end;
+  int numblocks = 10000;
   int saved_errno;
   /* set up the socket pair */
-  assertok(socketpair(AF_UNIX,SOCK_STREAM,0,sp)==0);
+  assertok(socketpair(AF_UNIX, SOCK_STREAM, 0, sp) == 0);
   /* open the reader */
-  assertok((rfp=fdopen(sp[0],"rb"))!=NULL);
+  assertok((rfp = fdopen(sp[0], "rb")) != NULL);
   /* open the writer */
-  assertok((wfp=tio_fdopen(sp[1],1100,1100, /* fd, readtimeout, writetimeout */
-      2*1024,4*1024, /* read buffer sizes */
-      2*sizeof(buf),4*sizeof(buf)+1 /* write buffer sizes */
-      ))!=NULL);
+  assertok((wfp = tio_fdopen(sp[1], 1100, 1100, 2 * 1024, 4 * 1024,
+                             2 * sizeof(buf), 4 * sizeof(buf) + 1)) != NULL);
   printf("test_tio: test_timeout_writer: trying to write %d blocks of %d 
bytes\n",
-         numblocks,(int)sizeof(buf));
+         numblocks, (int)sizeof(buf));
   /* we perform a number of writes to the stream to see if they are buffered */
-  start=time(NULL);
-  errno=0;
-  for (i=0;(i<numblocks)&&(tio_write(wfp,buf,sizeof(buf))==0);i++);
-  saved_errno=errno;
-  end=time(NULL);
+  start = time(NULL);
+  errno = 0;
+  for (i = 0; (i < numblocks) && (tio_write(wfp, buf, sizeof(buf)) == 0); i++)
+    /* nothing */ ;
+  saved_errno = errno;
+  end = time(NULL);
   printf("test_tio: test_timeout_writer: written %d blocks of %d bytes in %d 
second(s) (%s)\n",
-         i,(int)sizeof(buf),(int)(end-start),strerror(saved_errno));
+       i, (int)sizeof(buf), (int)(end - start), strerror(saved_errno));
   /* at the very least 4 writes should be OK because they filled the tio 
buffer */
-  assert(i>=4);
+  assert(i >= 4);
   /* but at a certain point the writes should have failed */
-  assert(i<numblocks);
+  assert(i < numblocks);
   /* since the write timeout is more than a second end time should be bigger
      than start time */
-  assert(end>start);
+  assert(end > start);
   /* the error should be timeout */
-  assert(saved_errno==ETIME);
+  assert(saved_errno == ETIME);
   /* close the files */
-  assertok(tio_close(wfp)!=0); /* fails because of bufferred data */
-  assertok(fclose(rfp)==0);
+  assertok(tio_close(wfp) != 0); /* fails because of bufferred data */
+  assertok(fclose(rfp) == 0);
 }
 
 /* the main program... */
-int main(int UNUSED(argc),char UNUSED(*argv[]))
+int main(int UNUSED(argc), char UNUSED(*argv[]))
 {
   /* normal read-writes */
-  test_blocks(400,11,11,400);
-  test_blocks(10*1024,11,10*11,1024);
-  test_blocks(5*1023,20,20*1023,5);
+  test_blocks(400, 11, 11, 400);
+  test_blocks(10 * 1024, 11, 10 * 11, 1024);
+  test_blocks(5 * 1023, 20, 20 * 1023, 5);
   /* reader closes file sooner */
-/*  test_blocks(2*6*1023,20,20*1023,5); */
-/*  test_blocks(10,10,10,9); */
+/*  test_blocks(2 * 6 * 1023, 20, 20 * 1023, 5); */
+/*  test_blocks(10, 10, 10, 9); */
   /* writer closes file sooner */
-/*  test_blocks(4*1023,20,20*1023,5); */
-/*  test_blocks(10,9,10,10); */
+/*  test_blocks(4 * 1023, 20, 20 * 1023, 5); */
+/*  test_blocks(10, 9, 10, 10); */
   /* set tio_mark() and tio_reset() functions */
   test_reset();
   /* test timeout functionality */
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/