AIX portability problem in samba3 passdb/pdb_ldap.c

Chris Cowan cc at
Fri Aug 11 20:34:20 GMT 2006

Just ran across this problem with the Samba 3 LDAP passdb code on AIX.   I
was getting intermittent failures authenticating on AIX 5.2 and total
failure on AIX 5.3.

The code is checking the modifyTimestamp attribute in ldap and then parsing
the string into struct tm with strptime().    My ldap servers return the
timestamp in the format "20060810153445Z."  strptime() on AIX wants the
fields in the buffer to be delimited.  (e.g. with whitespace like "2006 08
10 15 34 45Z")    The glib2 version on Linux doesn't require this.  Of
course, there is also a question of whether you should have this
definition, too:
    #define _XOPEN_SOURCE

The quickest and dirtiest patch  was to check the rc and return (time_t) 0
if it fails.

Index: pdb_ldap.c
--- pdb_ldap.c  (revision 17498)
+++ pdb_ldap.c  (working copy)
@@ -455,7 +455,12 @@
                return (time_t) 0;

-       strptime(temp, "%Y%m%d%H%M%SZ", &tm);
+       char *rc;
+       rc = strptime(temp, "%Y%m%d%H%M%SZ", &tm);
+       if ( rc == NULL )
+         return (time_t) 0;
        return timegm(&tm);

The only occurrence of strptime I found in Samba 4 (kdc/hdb-ldb.c) properly
checks the rc.


More information about the samba-technical mailing list