AIX portability problem in samba3 passdb/pdb_ldap.c

David Collier-Brown davec-b at rogers.com
Sun Aug 13 22:19:12 GMT 2006


   Numerous strptimes require whitespace, so one often parses
such date-stamps with sscanf, as we did before strptime was invented.

   If you can't use the glibc version for some reason, I can
happily write you a strptime implemented by rewriting the
date string into a sscanf string.

--dave (who is doing porting libraries in his Copious Spare Time) c-b


Chris Cowan wrote:
> 
> 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 @@
>                         temp))
>                 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;
> +
>         tzset();
>         return timegm(&tm);
>  }
> ===================================================================
> 
> The only occurrence of strptime I found in Samba 4 (kdc/hdb-ldb.c) properly
> checks the rc.
> 
> Regards,
> --
> CC

-- 
David Collier-Brown,         | Always do right. This will gratify
System Programmer and Author | some people and astonish the rest
davecb at spamcop.net           |                      -- Mark Twain
(416) 223-5943


More information about the samba-technical mailing list