]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Small improvement on the cram-md5 and digest-md5
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 4 Jul 2025 00:39:29 +0000 (20:39 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 4 Jul 2025 00:39:29 +0000 (20:39 -0400)
lib/lvleml.c

index ffd14b931645845e751e6a18e493db262ad0587b..243959b87b126f06c4e0832838aa25602b038253 100644 (file)
@@ -358,6 +358,7 @@ char *seq;
 char *code;
 USRTYP *usr;
 char *line;
+char *name;       //extracted name
 int got;
 int phase;
 _Bool proceed;
@@ -372,6 +373,7 @@ seq=strdup("<01234567890ABCDEFGHIJKLMNOPQRST@mailpostg.example.com>");
 (void) rou_alert(0,"%s JMPDBG SEQ=<%s>",OPEP,seq);
 code=(char *)0;
 usr=(USRTYP *)0;
+name=(char *)0;
 line=(char *)0;
 got=0;
 phase=0;
@@ -392,7 +394,6 @@ while (proceed==true) {
       }
       break;
     case 1      :  {    //extracting code
-      char *name;       //extracted name
       char *ptr;
 
       code=cnv_getb64(line);
@@ -407,10 +408,11 @@ while (proceed==true) {
       if (name!=(char *)0) {
         (void) sql_mngusr(contact->sqlptr,sql_select,name,&usr);
         (void) rou_alert(0,"%s JMPDBG md5 name=<%s>",OPEP,name);
-        name=rou_freestr(name);
         }
       if (usr==(USRTYP *)0) {
         code=rou_freestr(code);
+        (void) rou_asprintf(&decoded,"%s%s%s%s",
+                                      IOBNULL,name,IOBNULL,(char *)0);
         phase=999;
         }
       line=rou_freestr(line);
@@ -421,10 +423,16 @@ while (proceed==true) {
       char *hexa;
 
       //local=cnv_hashmd5(usr->passwd,(unsigned char *)seq); 
+      (void) rou_asprintf(&decoded,"%s%s%s%s",IOBNULL,name,IOBNULL,(char *)0);
       local=cnv_hashmd5("mailleur",(unsigned char *)seq); 
       hexa=cnv_tohexa(local);
-      (void) rou_alert(0,"JMPDBG local =<%s>",hexa);
-      (void) rou_alert(0,"JMPDBG remote=<%s>",code);
+      (void) rou_alert(0,"%s code=<%s>",OPEP,code);
+      (void) rou_alert(0,"%s hexa=<%s>",OPEP,hexa);
+      if (strcmp(hexa,code)==0) {
+        (void) rou_asprintf(&decoded,"%s%s%s%s",
+                                      IOBNULL,usr->email,IOBNULL,"mailleur");
+        (void) rou_alert(0,"JMPDBG decoded=<%s>",decoded);
+        }
       hexa=rou_freestr(hexa);
       local=rou_freestr(local);
       usr=sql_freeusr(usr);
@@ -435,7 +443,9 @@ while (proceed==true) {
     }
   phase++;
   }
+name=rou_freestr(name);
 seq=rou_freestr(seq);
+(void) rou_alert(0,"%s JMPDBG decoded=<%s>",OPEP,decoded);
 return decoded;
 
 #undef  OPEP
@@ -568,7 +578,7 @@ static _Bool getauth(CONTYP *contact,int delay,char *buffer)
 {
 #define OPEP    "lvleml.c:getauth,"
 
-static char *vocloc[]={"PLAIN","LOGIN","CRAM-MD5",(char *)0};
+static char *vocloc[]={"PLAIN","LOGIN","CRAM-MD5","DIGEST-MD5",(char *)0};
 
 _Bool isok;
 int code;
@@ -623,7 +633,8 @@ while (proceed==true) {
           if ((decoded=get_auth_login(contact,delay))==(char *)0)
             phase=999;
           break;
-        case 2          :       //AUTH DIGEST-MD5
+        case 2          :       //AUTH CRAM-MD5
+        case 3          :       //AUTH DIGEST-MD5
           if ((decoded=get_auth_md5(contact,delay))==(char *)0)
             phase=999;
           break;