auth_md5.c | auth_md5.c | |||
---|---|---|---|---|
/* ======================================================================== | ||||
* Copyright 1988-2006 University of Washington | ||||
* | ||||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||||
* you may not use this file except in compliance with the License. | ||||
* You may obtain a copy of the License at | ||||
* | ||||
* http://www.apache.org/licenses/LICENSE-2.0 | ||||
* | ||||
* | ||||
* ======================================================================== | ||||
*/ | ||||
/* | /* | |||
* Program: CRAM-MD5 authenticator | * Program: CRAM-MD5 authenticator | |||
* | * | |||
* Author: Mark Crispin | * Author: Mark Crispin | |||
* Networks and Distributed Computing | * Networks and Distributed Computing | |||
* Computing & Communications | * Computing & Communications | |||
* University of Washington | * University of Washington | |||
* Administration Building, AG-44 | * Administration Building, AG-44 | |||
* Seattle, WA 98195 | * Seattle, WA 98195 | |||
* Internet: MRC@CAC.Washington.EDU | * Internet: MRC@CAC.Washington.EDU | |||
* | * | |||
* Date: 21 October 1998 | * Date: 21 October 1998 | |||
* Last Edited: 4 January 2005 | * Last Edited: 30 August 2006 | |||
* | ||||
* The IMAP toolkit provided in this Distribution is | ||||
* Copyright 1988-2005 University of Washington. | ||||
* The full text of our legal notices is contained in the file called | ||||
* CPYRIGHT, included with this Distribution. | ||||
*/ | */ | |||
/* MD5 context */ | /* MD5 context */ | |||
#define MD5BLKLEN 64 /* MD5 block length */ | #define MD5BLKLEN 64 /* MD5 block length */ | |||
#define MD5DIGLEN 16 /* MD5 digest length */ | #define MD5DIGLEN 16 /* MD5 digest length */ | |||
typedef struct { | typedef struct { | |||
unsigned long chigh; /* high 32bits of byte count */ | unsigned long chigh; /* high 32bits of byte count */ | |||
unsigned long clow; /* low 32bits of byte count */ | unsigned long clow; /* low 32bits of byte count */ | |||
unsigned long state[4]; /* state (ABCD) */ | unsigned long state[4]; /* state (ABCD) */ | |||
skipping to change at line 181 | skipping to change at line 189 | |||
char *auth_md5_pwd (char *user) | char *auth_md5_pwd (char *user) | |||
{ | { | |||
struct stat sbuf; | struct stat sbuf; | |||
int fd = open (MD5ENABLE,O_RDONLY,NIL); | int fd = open (MD5ENABLE,O_RDONLY,NIL); | |||
unsigned char *s,*t,*buf,*lusr,*lret; | unsigned char *s,*t,*buf,*lusr,*lret; | |||
char *ret = NIL; | char *ret = NIL; | |||
if (fd >= 0) { /* found the file? */ | if (fd >= 0) { /* found the file? */ | |||
fstat (fd,&sbuf); /* yes, slurp it into memory */ | fstat (fd,&sbuf); /* yes, slurp it into memory */ | |||
read (fd,buf = (char *) fs_get (sbuf.st_size + 1),sbuf.st_size); | read (fd,buf = (char *) fs_get (sbuf.st_size + 1),sbuf.st_size); | |||
/* see if any uppercase characters in user * / | /* see if any uppercase characters in user * / | |||
for (s = user; *s && !isupper (*s); s++); | for (s = user; *s && ((*s < 'A') || (*s > 'Z')); s++); | |||
/* yes, make lowercase copy */ | /* yes, make lowercase copy */ | |||
lusr = *s ? lcase (cpystr (user)) : NIL; | lusr = *s ? lcase (cpystr (user)) : NIL; | |||
for (s = strtok (buf,"\015\012"),lret = NIL; s; | for (s = strtok (buf,"\015\012"),lret = NIL; s; | |||
s = ret ? NIL : strtok (NIL,"\015\012")) | s = ret ? NIL : strtok (NIL,"\015\012")) | |||
/* must be valid entry line */ | /* must be valid entry line */ | |||
if (*s && (*s != '#') && (t = strchr (s,'\t')) && t[1]) { | if (*s && (*s != '#') && (t = strchr (s,'\t')) && t[1]) { | |||
*t++ = '\0'; /* found tab, tie off user, point to pwd */ | *t++ = '\0'; /* found tab, tie off user, point to pwd */ | |||
if (!strcmp (s,user)) ret = cpystr (t); | if (!strcmp (s,user)) ret = cpystr (t); | |||
else if (lusr && !lret) if (!strcmp (s,lusr)) lret = t; | else if (lusr && !lret) if (!strcmp (s,lusr)) lret = t; | |||
} | } | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 15 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |