]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Adding helo entry tag-0.4.1
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 11 Aug 2024 19:23:30 +0000 (15:23 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sun, 11 Aug 2024 19:23:30 +0000 (15:23 -0400)
lib/lvleml.c
lib/subrou.c
lib/unieml.c
lib/unieml.h
lib/unitls.h

index cea9470c5bd44183559f075442c3d567b2aa6f94..d56911fee9e7048a75395ac4d768a003c6e4211d 100644 (file)
@@ -45,7 +45,54 @@ va_end(args);
 /*     if EHLO message is not accepted.        */
 /*                                             */
 /************************************************/
-static _Bool doehlo(CONTYP *contact,char *line)
+static _Bool dohelo(CONTYP *contact,char *keyword,char *parameter)
+
+{
+#define        OPEP    "unieml.c:dohelo"
+#define DETAIL  "HELO argument is mandatory, closing connection"
+
+_Bool done;
+int phase;
+_Bool proceed;
+
+done=false;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  switch (phase) {
+    case 0      :       //checking need parameter
+      if ((parameter==(char *)0)||(strlen(parameter)==0)) {
+        (void) transmit(contact,"%d 5.5.4 %s.",BADPAR,DETAIL);
+        phase=999;      //Trouble trouble
+        }
+      break;
+    case 1      :       //thereis an FQDN
+      contact->fqdn=rou_freestr(contact->fqdn);
+      contact->fqdn=strdup(parameter);
+      (void) transmit(contact,"%d-%s ready, your IP=[%s]",
+                              CMDOK,contact->locname,contact->peerip);
+      done=true;
+      break;
+    default     :       //SAFE guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return done;
+#undef  DETAIL
+#undef  OPEP
+}
+/*
+\f
+*/
+/************************************************/
+/*                                             */
+/*     Procedure to send an "HELO" message     */
+/*     if EHLO message is not accepted.        */
+/*                                             */
+/************************************************/
+static _Bool doehlo(CONTYP *contact,char *keyword,char *parameter)
 
 {
 static char *ehlostr[]= {
@@ -58,35 +105,28 @@ static char *ehlostr[]= {
         };
 
 #define        OPEP    "unieml.c:doehlo"
-#define DETAIL  "syntax error (domain part missing), disconnecting"
+#define DETAIL  "syntax error (domain part missing), closing connection"
 
 _Bool done;
-char *fqdn;
 int strstart;
 int phase;
 _Bool proceed;
 
 done=false;
-fqdn=(char *)0;
 strstart=0;
 phase=0;
 proceed=true;
 while (proceed==true) {
   switch (phase) {
-    case 0      :       //Do we have 
-      fqdn=strchr(line,' ');
-      if (fqdn!=(char *)0) {
-        while ((*fqdn==' ')||(*fqdn=='\t'))
-          fqdn++;
-        }
-      if ((fqdn==(char *)0)||(strlen(fqdn)==0)) {
-        (void) transmit(contact,"%d 5.5.4 %s",BADPAR,DETAIL);
+    case 0      :       //Do we have a parameter
+      if ((parameter==(char *)0)||(strlen(parameter)==0)) {
+        (void) transmit(contact,"%d 5.5.4 %s.",BADPAR,DETAIL);
         phase=999;      //Trouble trouble
         }
       break;
     case 1      :       //thereis an FQDN
       contact->fqdn=rou_freestr(contact->fqdn);
-      contact->fqdn=strdup(fqdn);
+      contact->fqdn=strdup(parameter);
       (void) transmit(contact,"%d-%s ready, your IP=[%s]",
                               CMDOK,contact->locname,contact->peerip);
       (void) transmit(contact,"%d-SIZE %ld",CMDOK,MXMSIZE);
@@ -130,16 +170,29 @@ status=1;
 proceed=true;
 while (proceed==true) {
   char *line;
+  char *parameter;
   TIMESPEC attend;
 
   attend.tv_sec=60;
   attend.tv_nsec=0;
   status=tcp_getline(contact,&attend,&line);
+  parameter=strchr(line,' ');
+  if (parameter==(char *)0)
+  parameter=strchr(line,'\t');
+  if (parameter!=(char *)0) {
+    *parameter='\000';
+    parameter++;
+    while ((*parameter==' ')||(*parameter=='\t')) 
+      parameter++;
+    }
   if (status<=0)        //timeout or trouble?
     break;              //no need to go further
   switch (eml_getcode(line)) {
+    case c_helo         :       //HELO SMTP protocol
+      proceed=dohelo(contact,line,parameter);
+      break;
     case c_ehlo         :       //EHLO SMTP protocol
-      proceed=doehlo(contact,line);
+      proceed=doehlo(contact,line,parameter);
       break;
     case c_quit         :       //QUIT SMTP protocol
       (void) transmit(contact,"%d 2.0.0 Bye, closing connection",QUITOK);
index 2299b979ce1fe49257a1f84d89dcdeb1364fbddd..36f1e24d28f2c9bc00cefccada3cbec8090454f2 100644 (file)
@@ -20,7 +20,7 @@
 
 //version definition 
 #define VERSION "0.4"
-#define RELEASE "1"
+#define RELEASE "2"
 
 //Public variables
 PUBLIC  int debug=0;            //debug level
index 4f6c17ca5c2877e727fa5bfef2a0e919523b61e0..9aebca394d6e54fcb9e5388df8912f924f339d24 100644 (file)
@@ -21,6 +21,7 @@ typedef struct  {
 
 //this list order by key length
 static VOCTYP vocsmtp[]={
+                {c_helo,"HELO"},
                 {c_ehlo,"EHLO"},
                 {c_quit,"QUIT"},
                 {c_starttls,"STARTTLS"},
@@ -42,7 +43,7 @@ VOCTYP *ptr;
 
 code=c_unknown;
 for (ptr=vocsmtp;ptr->code!=c_unknown;ptr++) {
-  if (strncasecmp(ptr->key,keyword,strlen(ptr->key))==0) {
+  if (strncasecmp(ptr->key,keyword,strlen(keyword))==0) {
     code=ptr->code;
     break;
     }
index 004d605a9dde5c75b5cd5bf7d3ebff61deb28ddd..c37cbcc70d9af4808e8ba317f64489485f19d572 100644 (file)
@@ -18,6 +18,7 @@
 
 //list of keyword
 typedef enum    {               //list of SMTP protocol keyword
+                c_helo,         //Basic Helo command
                 c_ehlo,         //EHLO command
                 c_quit,         //quit exchange
                 c_starttls,     //Starting a TLS crypted link
index e1de541db9b766abae32268f4939dba4c21e2067..b26a85eda522177e4e0ceb3b6bc757ad703022b2 100644 (file)
@@ -20,7 +20,6 @@ typedef struct  {
         char *locport;  //local Port number
         SSL_CTX *ctx;   //SSL context
         SSL *ssl;       //SSL link
-        //BIO *bio;       //SSL Basic input output
         }TLSTYP;
 
 //procedure to open an tls channel