Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The comparison of strings does not work in shadow.c #28

Open
VictorPavlushin opened this issue Jul 17, 2018 · 4 comments
Open

The comparison of strings does not work in shadow.c #28

VictorPavlushin opened this issue Jul 17, 2018 · 4 comments

Comments

@VictorPavlushin
Copy link

VictorPavlushin commented Jul 17, 2018

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

@arthurdejong
Copy link
Owner

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.

@VictorPavlushin
Copy link
Author

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.

@VictorPavlushin
Copy link
Author

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

@arthurdejong
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants