Hi everyone,

 After being thrown into migrating a netscape messaging server 3.5 to <just put 
something that holds data in db> i found this little piece of software that 
fitted the role perfectly.

 I can now say that DBmail works perfectly in this enviroment (well after a few 
days that i spent figuring how to migrate users+passwords/emails/etc from 
netscape server). We now have around 300 users that use IMAP/pop3/Horde-Imp on 
a :

P3 1ghz
768 mb ram
2 x 36 Gb U160 SCSI for mysql in RAID 1
1 x 9 Gb U2W SCSI for system
2 x 100 mbit ethernet

running SuSE 8.1 + apache1/php + mysql 4.0.13 + postfix

 One of the problems i came to was the absence of "netscape" type of encryption 
for passwords (SHA1) so i googled a bit and came up with a little patch so 
users dont even notice the server change. [attached 2 files, one is a ifelse 
addon for auth, and the other comparing function, mhash library is needed]

 Anyways great software, hope fixes and features keep on comming :)

Cheers from Slovenia and Croatia,

Denis
int netscape_sha1(char *pass, char *test)
{
        MHASH td;
        int bsize;
        unsigned char *hash_data;
        int hash;
        int data_len;
        int end;
        char mydata[27];

        bsize = mhash_get_block_size(hash);
        td = mhash_init(MHASH_SHA1);
        data_len = strlen(pass);
        mhash(td, pass, data_len);
        hash_data = mhash_end(td);

        base64encode(mydata, hash_data, strlen(hash_data));

        if(strncmp(mydata, test, 26) == 0)
        {
                return 1;
        }
        else
        {
                return 0;
        }
}

char b64string[] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

int base64encode (char *to, char *from, unsigned int len)
{
        char *fromp = from;
        char *top = to;
        unsigned char cbyte;
        unsigned char obyte;
        char end[3];

        for (; len >= 3; len -= 3)
        {
            cbyte = *fromp++;
                *top++ = b64string[(int)(cbyte >> 2)];
                obyte = (cbyte << 4) & 0x30;            /* 0011 0000 */

                cbyte = *fromp++;
                obyte |= (cbyte >> 4);                  /* 0000 1111 */
                *top++ = b64string[(int)obyte];
                obyte = (cbyte << 2) & 0x3C;            /* 0011 1100 */

                cbyte = *fromp++;
                obyte |= (cbyte >> 6);                  /* 0000 0011 */
                *top++ = b64string[(int)obyte];
                *top++ = b64string[(int)(cbyte & 0x3F)];/* 0011 1111 */
        }

        if (len) {
                end[0] = *fromp++;
                if (--len) end[1] = *fromp++; else end[1] = 0;
                end[2] = 0;

                cbyte = end[0];
                *top++ = b64string[(int)(cbyte >> 2)];
                obyte = (cbyte << 4) & 0x30;            /* 0011 0000 */

                cbyte = end[1];
                obyte |= (cbyte >> 4);
                *top++ = b64string[(int)obyte];
                obyte = (cbyte << 2) & 0x3C;            /* 0011 1100 */

                if (len) *top++ = b64string[(int)obyte];
                else *top++ = '=';
                *top++ = '=';
        }
        *top = 0;
        return top - to;
}
else if ( strcasecmp(__auth_row[2], "sha1") == 0)
        {
                trace (TRACE_MESSAGE,"auth_validate(): validation using 
Netscape SHA1 Passwords");

                if( netscape_sha1(password, __auth_row[1]) == 1 )
                {
                        is_validated = 1;
                        trace (TRACE_MESSAGE, "netscape sha1 : validated user 
everything ok");
                }
                else
                {
                        is_validated = 0;
                        trace (TRACE_MESSAGE, "netscape sha1 : user fejked the 
password");
                }
        }

Reply via email to