]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Improving password exchnage logging information
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 2 Jul 2025 02:25:06 +0000 (22:25 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Wed, 2 Jul 2025 02:25:06 +0000 (22:25 -0400)
Makefile
Makefile.dbg
data-feed/feedxx.tst
lib/lvleml.c
lib/unipar.c

index 917d4f648725ab74b839a32cc55e9480cc10636d..6e7b9b252c29e7d30a1e6b563b5cd051d9fcf948 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -143,12 +143,13 @@ tlsref:
                        -cert certs/localhost-cert.pem  \
                        -key certs/localhost-key.pem    \
                        -starttls smtp                  \
-                       -connect $(TESTSRV):$(TESTPORT) 
+                       -connect courriel.colba.net:587
 
 #                      -connect mailprod1.safe.ca:587
 #                      -connect courriel.colba.net:25
 #                      -connect courriel.colba.net:587
 #                      -connect smtp.google.com:25
+#                      -connect $(TESTSRV):$(TESTPORT) 
 
 #--------------------------------------------------------------------
 #starting email receiver
index 55e3a791dbfb5ccb19586d4a356ba4e28601cafc..689df8db4628b2939607df63f5750adaf78961ec 100644 (file)
@@ -35,7 +35,7 @@ gorcvr        :  clean debug
                $(EMLPAR)$(TESTITER)
 
 
-onercvr        :  clean debug newtest
+onercvr        :  clean debug
           @                                            \
             ./bin/receiver                             \
                -f                                      \
index dd1fe1193f590131ef65eb9ac95c9ea639f2b311..e8299bba99d0fb576d07ce7bfe19e6213a24b443 100644 (file)
@@ -27,5 +27,9 @@ R:334 UGFzc3dvcmQ6
 #sending 'mailleur' as B64
 S:bWFpbGxldXI=
 R:235 5.7.5 Authentication successful
+S:AUTH PLAIN QmlncmVfYmlncmUgbm91c2Vy
+R:504 5.7.4 authentication failed
+S:AUTH PLAIN cG9zdG1hc3RlckBleGFtcGxlLmNvbSBub3Bhc3N3ZA==
+R:504 5.7.4 authentication failed
 S:QUIT
 R:221 2.0.0 Bye, closing connection...
index e6d8b7a0ac3c35e36b644549a1cd86272362bf5b..910a2643130de19b0e5b15f5dc4d2d99a851af81 100644 (file)
@@ -324,6 +324,7 @@ if (strlen(local)==0) {
   (void) transmit(contact,true,"%d 5.7.1 Please provide auth sequence",SENDB64);
   got=tcp_getline(contact->socptr,delay,&line);
   if (got>0) {
+    (void) log_fprintlog(contact->logptr,false,"%s",line);
     (void) strncpy(local,line,sizeof(local)-1);
     line=rou_freestr(line);
     }
@@ -365,6 +366,7 @@ for (int i=0;i<2;i++) {
      (void) transmit(contact,true,"%d 5.7.2 auth sequence missing",UKNUSER);
      break;                 //exiting from loop
      }
+  (void) log_fprintlog(contact->logptr,false,"%s",line);
   if ((ptr=cnv_getb64(line))!=(char *)0) {
     (void) rou_alert(0,"JMPDBG line[%d]=<%s> ptr=<%s>",i,line,ptr);
     (void) strncat(local,ptr,(sizeof(local)-1)-strlen(ptr));
@@ -436,24 +438,26 @@ return isok;
 /*      NULL if unable to extract login                 */
 /*                                                      */
 /********************************************************/
-static void getauth(CONTYP *contact,int delay,char *buffer)
+static _Bool getauth(CONTYP *contact,int delay,char *buffer)
 
 {
 #define OPEP    "lvleml.c:getauth,"
 
 static char *vocloc[]={"plain","login",(char *)0};
 
+_Bool isok;
 int code;
 char *decoded;
 char local[200];
 int phase;
 _Bool proceed;
 
+isok=false;
 code=-1;
 decoded=(char *)0;
 (void) memset(local,'\000',sizeof(memset));
 phase=0;
-proceed=(strlen(buffer)>0);
+proceed=true;
 while (proceed==true) {
   //(void) rou_alert(0,"%s JMPDBG phase='%d'",OPEP,phase);
   switch (phase) {
@@ -504,6 +508,18 @@ while (proceed==true) {
     case 4      :       //we have a decoded sequence, check password
       (void) rou_alert(0,"JMPDBG decoded=<%s>",decoded);
       if (checklogin(contact->sqlptr,decoded)==false) {
+        char *fmt;
+        char *user;
+        char *pass;
+
+        user=decoded;
+        if ((pass=strchr(decoded,' '))!=(char *)0) {
+          *pass='\000';
+          pass++;
+          }
+        fmt="Auth Rejected status='%d' for user=<%s> pass=<%s>";
+        (void) log_fprintlog(contact->logptr,true,fmt,BADAUTH,user,pass);
+        (void) sleep(2);
         (void) transmit(contact,true,"%d 5.7.4 authentication failed",BADAUTH);
         phase=999;
         }
@@ -511,6 +527,7 @@ while (proceed==true) {
       break;
     case 5      :       //everything is fine
       (void) transmit(contact,true,"%d 5.7.5 Authentication successful",IDOK);
+      isok=true;
       break;
     default     :       //SAFE Guard
       proceed=false;
@@ -518,7 +535,7 @@ while (proceed==true) {
     }
   phase++;
   }
-
+return isok;
 #undef  OPEP
 }
 /*
index 6e7f14c8491a3ea790b4e03177640b36c9bdb090..11e7d7387284000a39e0a5528a35c8b50d397911 100644 (file)
@@ -145,7 +145,6 @@ if ((shortname=strrchr(argv[0],'/'))==(char *)0)
   shortname=argv[0];
 else
   shortname++;
-(void) rou_setexecname(shortname);
 opterr=0;               //no error message from getopt library routine
 while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
   switch(c) {
@@ -190,6 +189,7 @@ while (((c=getopt(argc,argv,optstring))!=EOF)&&(params!=(ARGTYP *)0)) {
       break;
     }
   }
+(void) rou_setexecname(shortname);
 if ((params!=(ARGTYP *)0)&&(argc>optind)) {
   int i;