From: Jean-Marc Pigeon (Delson) Date: Thu, 3 Jul 2025 15:14:01 +0000 (-0400) Subject: Adding procedure cnv_tohexa X-Git-Tag: tag-0.12~40 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=f0a25c41f4ffa6c1d5d27c4365d1449f688abedc;p=jmp%2Fmailleur Adding procedure cnv_tohexa --- diff --git a/Makefile.dbg b/Makefile.dbg index 689df8d..4c30730 100644 --- a/Makefile.dbg +++ b/Makefile.dbg @@ -34,6 +34,14 @@ gorcvr : clean debug -f \ $(EMLPAR)$(TESTITER) +digest : clean debug + \ + ./bin/receiver \ + -f \ + -r $(TESTDIR) \ + -c ./conf/$(APPNAME).conf.dvl \ + -d 9 \ + "|192.219.254.70|1025|1" onercvr : clean debug @ \ diff --git a/lib/lvleml.c b/lib/lvleml.c index 86c3085..ffd14b9 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -341,8 +341,9 @@ return decoded; */ /********************************************************/ /* */ -/* Procedure to manage authentication in "cram-md5"*/ -/* mode, return a builded "decoded" string from */ +/* Procedure to manage authentication in */ +/* digest-md5 mode. */ +/* Return a builded "decoded" string from */ /* the exchange with the remote sereur */ /* */ /********************************************************/ @@ -366,7 +367,8 @@ decoded=(char *)0; cur.tv_nsec/=10000; //100 millisec //(void) rou_asprintf(&seq,"<%05d-%s@%s>", // cur.tv_nsec,contact->session->sessid,contact->locname); -seq=strdup("<49591-13093-20250702204841-0377-0000@mailpostg.example.com>"); +seq=strdup("<01234567890ABCDEFGHIJKLMNOPQRST@mailpostg.example.com>"); +//seq=strdup("username = "); (void) rou_alert(0,"%s JMPDBG SEQ=<%s>",OPEP,seq); code=(char *)0; usr=(USRTYP *)0; @@ -375,15 +377,15 @@ got=0; phase=0; proceed=true; while (proceed==true) { + (void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase); switch (phase) { case 0 : { //preparing a string an sending it char *b64; b64=cnv_setb64(seq); (void) transmit(contact,true,"%d %s",SENDB64,b64); - line=strdup("webmaster@example.com ef8d00466c1196c0f170c735e7ea7080"); - got=strlen(line); - //got=tcp_getline(contact->socptr,delay,&line); + got=tcp_getline(contact->socptr,delay,&line); + (void) rou_alert(0,"%s got<%s>",OPEP,line); if (got<0) phase=999; //Answer not received in due time b64=rou_freestr(b64); @@ -393,8 +395,8 @@ while (proceed==true) { char *name; //extracted name char *ptr; - //code=cnv_getb64(line); - code=strdup(line); + code=cnv_getb64(line); + (void) rou_alert(0,"%s JMPDBG md5 code=<%s>",OPEP,code); name=(char *)0; if ((ptr=strchr(code,' '))!=(char *)0) { *ptr='\000'; @@ -416,20 +418,14 @@ while (proceed==true) { break; case 2 : { //comparing hmac char *local; - char hexa[100]; + char *hexa; //local=cnv_hashmd5(usr->passwd,(unsigned char *)seq); local=cnv_hashmd5("mailleur",(unsigned char *)seq); - (void) strcpy(hexa,""); - for (int i=0;i hexa",hexa); + hexa=cnv_tohexa(local); + (void) rou_alert(0,"JMPDBG local =<%s>",hexa); (void) rou_alert(0,"JMPDBG remote=<%s>",code); + hexa=rou_freestr(hexa); local=rou_freestr(local); usr=sql_freeusr(usr); } @@ -572,7 +568,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",(char *)0}; _Bool isok; int code; @@ -627,7 +623,7 @@ while (proceed==true) { if ((decoded=get_auth_login(contact,delay))==(char *)0) phase=999; break; - case 2 : //AUTH CRAM-MD5 + case 2 : //AUTH DIGEST-MD5 if ((decoded=get_auth_md5(contact,delay))==(char *)0) phase=999; break; @@ -921,6 +917,8 @@ return tcp_smtp_command(rmt,(char ***)0,strloc); /* Return true, if everything is fine */ /* */ /************************************************/ +//NOTE +//MAIL FROM [BODY=7BIT|BODY=8BITMIME] [SIZE=number_of_bytes] static _Bool getdata(CONTYP *contact) { @@ -1083,7 +1081,7 @@ static char *ehlostr[]= { "-STARTTLS", "-8BITMIME", "-ENHANCEDSTATUSCODES", - " AUTH PLAIN LOGIN CRAM-MD5", + " AUTH CRAM-MD5 DIGEST-MD5", (char *)0 }; @@ -1985,6 +1983,8 @@ while (proceed==true) { break; case c_auth : //Auth request (void) getauth(contact,delay,line); + status=1; //JMPDBGevery thing fine + proceed=false; break; case c_rcpt : //Doing rpt scanning if (checkto(contact,line)==false) { diff --git a/lib/subcnv.c b/lib/subcnv.c index d469e01..5458d05 100644 --- a/lib/subcnv.c +++ b/lib/subcnv.c @@ -225,3 +225,33 @@ return hashmd5; #undef OPEP } +/* + +*/ +/********************************************************/ +/* */ +/* Procedure to convert a string of character as */ +/* an hexadecimale string sequence */ +/* */ +/********************************************************/ +PUBLIC char *cnv_tohexa(const char *str) + +{ +char *hexa; + +hexa=(char *)0; +if ((str!=(char *)0)&&(strlen(str)>0)) { + unsigned int taille; + + taille=strlen(str); + hexa=(char *)calloc((taille*2)+1,sizeof(char)); + for (int i=0;i