summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-11-25 15:56:58 +0000
committerArthur de Jong <arthur@arthurdejong.org>2012-11-25 15:56:58 +0000
commit25cb15f8e765ec2e197060acb5702af47ab85331 (patch)
tree36b0df118e28cf2e7077bf9a02fc30d63a326c2c
parentea55c22e2fd1872dffabc615e20cdf740f1558cb (diff)
if nsswitch.conf is missing a shadow entry, fall back to checking the passwd mapping
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1841 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/nsswitch.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/nslcd/nsswitch.c b/nslcd/nsswitch.c
index 7d488ff..4a9a864 100644
--- a/nslcd/nsswitch.c
+++ b/nslcd/nsswitch.c
@@ -128,6 +128,8 @@ static int shadow_uses_ldap(void)
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 @@ static int shadow_uses_ldap(void)
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 */