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
- From: Commits of the nss-pam-ldapd project	<nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1841 - nss-pam-ldapd/nslcd
- Date: Sun, 25 Nov 2012 16:56:59 +0100 (CET)
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/
- nss-pam-ldapd commit: r1841 - nss-pam-ldapd/nslcd,
Commits of the nss-pam-ldapd project