arthurdejong / nss-pam-ldapd

NSS and PAM modules for lookups using LDAP

Home Page:https://arthurdejong.org/nss-pam-ldapd/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The comparison of strings does not work in shadow.c

VictorPavlushin opened this issue · comments

Version 0.8.13, because such in RHEL 7, but also in later versions, is not changed.

--- nss-pam-ldapd-0.8.13/nslcd/shadow.c 2013-02-24 04:24:00.000000000 +0700
+++ nss-pam-ldapd-0.8.13-AD/nslcd/shadow.c      2018-07-17 09:11:29.037490301 +0700
@@ -122,7 +122,8 @@
   char *tmp;
   size_t l;
   /* do some special handling for date values on AD */
-  if (strcasecmp(attr,"pwdLastSet")==0)
+  char pwds[] = "pwdLastSet";
+  if (strcasecmp(attr,pwds)==0)
   {
     /* we expect an AD 64-bit datetime value;
        we should do date=date/864000000000-134774

I don't think I understand the question. Also, your diff does not seem to do anything unless I'm missing something.
The 0.8.14 release does fix one issue related to pwdLastSet in c1c4c3f.

Note that the 0.8 version will only security updates and fixes for major bugs and generally only to the latest 0.8 version.

Comparing if (strcasecmp (attr, "pwdLastSet") == 0) does not work in CentOS 7.
Different types of variables ..
sizeof (attr) = 8
sizeof ("pwdLastSet") = 11
in to_date.

[root@host ~]# getent shadow domainuser
domainuser:*:-713764940::::::0
[root@host ~]# cat /etc/nslcd.conf | grep pwd
map shadow shadowLastChange pwdLastSet
in ldap pwdLastSet=131756885436911761

The difference you see can be explained by the fix in 0.8.14. It is expected that sizeof() differs because attr is a char * and the literal string is a char []. The char [] is used as char * in most cases in C (except sizeof()).

Both strlen() and strcasecmp() should treat char * and char [] the same.