Autoconf crypt test for Samba 2.0

Jeremy Allison jallison at cthulhu.engr.sgi.com
Wed Dec 16 20:01:04 GMT 1998


I have had a couple of people come and say that HPUX
needs a salt string truncated after 2 characters in
order to do a password crypt correctly, and someone
else say that FreeBSD 2.7 needs more than 2 characters
do to a password crypt correctly. Can people running
HPUX and FreeBSD run the following program (a varient
of which I'm intending to use as an autoconf test)
and let me know the results.

I tried it on HPUX 10.x and FreeBSD 2.6 which I have here
and both reported the same output for a crypt run with
no salt truncation and a crypt run with 2 char salt
truncation.

The current code in Samba 2.0 truncates salt at
2 chars and that's what I'm going to leave as the default
I think.

Cheers,

	Jeremy Allison,
	Samba Team.

-----------------cut here-------------------------------
#include <unistd.h>
#include <sys/types.h>

#ifdef HAVE_STRING_H
#include <string.h>
#endif

#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif


main()
{
    char passwd[9];
    char salt[9];
    char c_out1[256];
    char c_out2[256];

    strcpy(passwd, "12345678");
    strcpy(salt, "12345678");

    strcpy(c_out1, crypt(passwd, salt));

    salt[2] = '\0';
    strcpy(c_out2, crypt(passwd, salt));

    /* This line will be removed in the autoconf test. */
    printf("%s %s\n", c_out1, c_out2);

    exit(strcmp(c_out1, c_out2) == 0 ? 1 : 0);
}
----------------------end test-----------------------
-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba-technical mailing list