lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1841 - nss-pam-ldapd/nslcd

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

nss-pam-ldapd commit: r1841 - nss-pam-ldapd/nslcd



Author: arthur
Date: Sun Nov 25 16:56:58 2012
New Revision: 1841
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1841&view=revision

Log:
if nsswitch.conf is missing a shadow entry, fall back to checking the passwd 
mapping

Modified:
   nss-pam-ldapd/nslcd/nsswitch.c

Modified: nss-pam-ldapd/nslcd/nsswitch.c
==============================================================================
--- nss-pam-ldapd/nslcd/nsswitch.c      Sun Nov 25 16:51:10 2012        (r1840)
+++ nss-pam-ldapd/nslcd/nsswitch.c      Sun Nov 25 16:56:58 2012        (r1841)
@@ -128,6 +128,8 @@
   int lnr=0;
   char linebuf[MAX_LINE_LENGTH];
   const char *services;
+  int shadow_found=0;
+  int passwd_has_ldap=0;
   /* open config file */
   if ((fp=fopen(NSSWITCH_FILE,"r"))==NULL)
   {
@@ -138,15 +140,26 @@
   while (fgets(linebuf,sizeof(linebuf),fp)!=NULL)
   {
     lnr++;
+    /* see if we have a shadow line */
     services=find_db(linebuf,"shadow");
-    if ((services!=NULL)&&has_service(services,"ldap",NSSWITCH_FILE,lnr))
+    if (services!=NULL)
     {
-      fclose(fp);
-      return 1;
+      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);
   }
   fclose(fp);
-  return 0;
+  if (shadow_found)
+    return 0;
+  return passwd_has_ldap;
 }
 
 /* check whether shadow lookups are configured to use ldap */
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/