From 9a2292fc31350efa848f935d45527c69f66a6a70 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Tue, 1 Jul 2025 22:25:06 -0400 Subject: [PATCH] Improving password exchnage logging information --- Makefile | 3 ++- Makefile.dbg | 2 +- data-feed/feedxx.tst | 4 ++++ lib/lvleml.c | 23 ++++++++++++++++++++--- lib/unipar.c | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 917d4f6..6e7b9b2 100644 --- 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 diff --git a/Makefile.dbg b/Makefile.dbg index 55e3a79..689df8d 100644 --- a/Makefile.dbg +++ b/Makefile.dbg @@ -35,7 +35,7 @@ gorcvr : clean debug $(EMLPAR)$(TESTITER) -onercvr : clean debug newtest +onercvr : clean debug @ \ ./bin/receiver \ -f \ diff --git a/data-feed/feedxx.tst b/data-feed/feedxx.tst index dd1fe11..e8299bb 100644 --- a/data-feed/feedxx.tst +++ b/data-feed/feedxx.tst @@ -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... diff --git a/lib/lvleml.c b/lib/lvleml.c index e6d8b7a..910a264 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -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 } /* diff --git a/lib/unipar.c b/lib/unipar.c index 6e7f14c..11e7d73 100644 --- a/lib/unipar.c +++ b/lib/unipar.c @@ -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; -- 2.47.3