]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adding procedure cnv_tohexa
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 3 Jul 2025 15:14:01 +0000 (11:14 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Thu, 3 Jul 2025 15:14:01 +0000 (11:14 -0400)
Makefile.dbg
lib/lvleml.c
lib/subcnv.c
lib/subcnv.h

index 689df8db4628b2939607df63f5750adaf78961ec..4c30730c387312a22a01021678f6773c3b207a25 100644 (file)
@@ -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
           @                                            \
index 86c30856765eec17ee334e79ce9613474d610e9c..ffd14b931645845e751e6a18e493db262ad0587b 100644 (file)
@@ -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 = <jmp@safe.ca>");
 (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<strlen(local);i++) {
-        char convert[10];
-
-        (void) strcat(convert,"---");
-        (void) snprintf(convert,sizeof(convert),"%02hhX",local[i]);
-        (void) strcat(hexa,convert);
-        }
-      (void) rou_alert(0,"JMPDBG local=<%s> 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 <sender> [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) {
index d469e013150ca62a11dd22d27a0e74afb42b01dc..5458d05e4e04b19d52cd0722aae4867a470ba8f4 100644 (file)
@@ -225,3 +225,33 @@ return hashmd5;
 
 #undef  OPEP
 }
+/*
+\f
+*/
+/********************************************************/
+/*                                                      */
+/*      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<taille;i++) {
+    char convert[5];
+  
+    (void) snprintf(convert,sizeof(convert),"%02hhx",str[i]);
+    (void) strcat(hexa,convert);
+    }
+  }
+return hexa;
+}
+
index 6d78b542783b94503b15fadd27b43cf40596cea9..b22920e56eb13bdccb411fdc2825519c367a703e 100644 (file)
@@ -22,4 +22,6 @@ extern char *cnv_setb64(const char *str);
 //Procedure to calculate a MD5 hash function
 extern char *cnv_hashmd5(const void *key,unsigned char *seq);
 
+//Procedure to convert a string of character as an HEXA string
+extern char *cnv_tohexa(const char *str);
 #endif