From 285930cbcc3e2074ed7fe78a47aec55e49749953 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sat, 6 Jun 2009 20:46:33 +0000 Subject: implement case-sensitive filtering for group, netgroup, passwd, protocols, rpc, services and shadow lookups git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@934 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/protocol.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'nslcd/protocol.c') diff --git a/nslcd/protocol.c b/nslcd/protocol.c index 595427b..fadb66f 100644 --- a/nslcd/protocol.c +++ b/nslcd/protocol.c @@ -100,7 +100,7 @@ void protocol_init(void) protocol_attrs[2]=NULL; } -static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry) +static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname) { int32_t tmpint32,tmp2int32,tmp3int32; const char *name; @@ -108,6 +108,7 @@ static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry) const char **protos; char *tmp; int proto; + int i; /* get the most canonical name */ name=myldap_get_rdn_value(entry,attmap_protocol_cn); /* get the other names for the protocol */ @@ -121,6 +122,14 @@ static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry) /* if the protocol name is not yet found, get the first entry */ if (name==NULL) name=aliases[0]; + /* check case of returned protocol entry */ + if ((reqname!=NULL)&&(strcmp(reqname,name)!=0)) + { + for (i=0;(aliases[i]!=NULL)&&(strcmp(reqname,aliases[i])!=0);i++) + /* nothing here */ ; + 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)) @@ -157,7 +166,7 @@ NSLCD_HANDLE( log_log(LOG_DEBUG,"nslcd_protocol_byname(%s)",name);, NSLCD_ACTION_PROTOCOL_BYNAME, mkfilter_protocol_byname(name,filter,sizeof(filter)), - write_protocol(fp,entry) + write_protocol(fp,entry,name) ) NSLCD_HANDLE( @@ -168,7 +177,7 @@ NSLCD_HANDLE( log_log(LOG_DEBUG,"nslcd_protocol_bynumber(%d)",protocol);, NSLCD_ACTION_PROTOCOL_BYNUMBER, mkfilter_protocol_bynumber(protocol,filter,sizeof(filter)), - write_protocol(fp,entry) + write_protocol(fp,entry,NULL) ) NSLCD_HANDLE( @@ -178,5 +187,5 @@ NSLCD_HANDLE( log_log(LOG_DEBUG,"nslcd_protocol_all()");, NSLCD_ACTION_PROTOCOL_ALL, (filter=protocol_filter,0), - write_protocol(fp,entry) + write_protocol(fp,entry,NULL) ) -- cgit v1.2.3