]> SAFE projects GIT repository - jmp/mailleur/commitdiff
idirect crypted channel (smtps) is working fine
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 3 May 2025 14:07:09 +0000 (10:07 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 3 May 2025 14:07:09 +0000 (10:07 -0400)
lib/devsoc.c
lib/devsoc.h
lib/lvleml.c
lib/lvleml.h

index 3411a0476856c92885e3269fadf0851157435411..d24c32419afc6936aceab1737aa2ef9fd0c16adc 100644 (file)
@@ -1309,7 +1309,7 @@ return data;
 /*      Procedure to close and release exchange socket  */
 /*                                                     */
 /********************************************************/
-SOCPTR *soc_release(SOCPTR *socptr)
+PUBLIC SOCPTR *soc_release(SOCPTR *socptr)
 
 {
 #define OPEP    "devsoc.c:soc_release"
@@ -1374,7 +1374,7 @@ return socptr;
 /*      crypted channel, return true is successful.     */
 /*                                                     */
 /********************************************************/
-_Bool soc_starttls(SOCPTR *socptr)
+PUBLIC _Bool soc_starttls(SOCPTR *socptr)
 
 {
 _Bool ok;
@@ -1402,3 +1402,45 @@ if ((soc!=(SOCTYP *)0)&&(soc->modtls==false)) {
   }
 return ok;
 }
+/*
+^L
+*/
+/********************************************************/
+/*                                                     */
+/*      Procedure to return true if sthe socket is      */
+/*      in crypted mode.                                */
+/*                                                     */
+/********************************************************/
+PUBLIC _Bool soc_iscrypted(SOCPTR *socptr)
+
+{
+_Bool iscrypted;
+
+iscrypted=false;
+if (socptr!=(SOCPTR *)0) 
+  iscrypted=((SOCTYP *)socptr)->modtls;
+return iscrypted;
+}
+/*
+^L
+*/
+/********************************************************/
+/*                                                     */
+/*      Procedure to return the socket mode as a string */
+/*                                                     */
+/********************************************************/
+PUBLIC const char *soc_getstrmode(SOCPTR *socptr)
+
+{
+const char *mode;
+SOCTYP *soc;
+
+mode="Unknown";
+soc=(SOCTYP *)socptr;
+if (soc!=(SOCTYP *)0) {
+  mode="cleartext";
+  if (soc->modtls==true)
+    mode="crypted";
+  }
+return mode;
+}
index d8cffbea328a263711acca533a216581616ae5cc..15df1dbf15c2c3e807d1c7bace4d305dd7dc0388 100644 (file)
@@ -78,4 +78,10 @@ extern SOCPTR *soc_release(SOCPTR *socptr);
 //procedure to initiate crypted mode on plain channel
 extern _Bool soc_starttls(SOCPTR *socptr);
 
+//return flag true if socet is in crypted mode
+extern _Bool soc_iscrypted(SOCPTR *socptr);
+
+//return line socket mode (cleartext, crypted)
+extern const char *soc_getstrmode(SOCPTR *socptr);
+
 #endif
index 7f9d0921426221ce61d36706a9acd7ca74af55d1..8d9da034d66089d8a959de568681f07b881a53a3 100644 (file)
@@ -81,18 +81,16 @@ va_end(args);
 static void signon(CONTYP *contact)
 
 {
-#define FMT     "%d %s ESMTP %s%s-%s; %s"
+#define FMT     "%d %s ESMTP (%s) %s-%s; %s"
 
 if (contact!=(CONTYP *)0) {
-  char strcrypt[20];
+  const char *mode;
   char signon[100];
 
-  (void) strcpy(strcrypt,"");
-  if (contact->tlsok==true)
-    (void) strcpy(strcrypt,"(crypted) ");
+  mode=soc_getstrmode(contact->socptr);
   (void) snprintf(signon,sizeof(signon),FMT,
                                         SIGNON,contact->locname,
-                                        strcrypt,
+                                        mode,
                                         appname,
                                         rou_getversion(),
                                         rou_ascsysstamp(time((time_t *)0)));
@@ -112,13 +110,11 @@ if (contact!=(CONTYP *)0) {
 static void linkready(CONTYP *contact)
 
 {
-char *crypted;
+const char *mode;
 
-crypted="cleartext";
-if (contact->tlsok==true) 
-  crypted="crypted";
+mode=soc_getstrmode(contact->socptr);
 (void) transmit(contact,"%d-%s, link (%s) ready, your IP/FQDN=[%s/%s]",
-                         CMDOK,contact->locname,crypted,
+                         CMDOK,contact->locname,mode,
                          contact->peerip,contact->peername);
 }
 /*
@@ -246,7 +242,7 @@ while (proceed==true) {
     case 1      :       //thereis an FQDN
       (void) linkready(contact);
       (void) transmit(contact,"%d-SIZE %ld",CMDOK,MXMSIZE);
-      if (contact->tlsok==true) 
+      if (soc_iscrypted(contact->socptr)==true) 
         strstart++;
       for (int i=strstart;ehlostr[i]!=(char *)0;i++) {
         (void) transmit(contact,"%d%s",CMDOK,ehlostr[i]);
@@ -423,7 +419,6 @@ while (proceed==true) {
     case c_starttls     :       //EHLO start encryptel link
       switch (soc_starttls(contact->socptr)) {
         case true       :       //link now in TLS crypted mode
-          contact->tlsok=true;
           (void) transmit(contact,"%d Link now encrypted",CMDOK);
           (void) rou_alert(0,"%s, CMDOK sent",OPEP);
           break;
index 5bde91b6fad4b237f20a47174696bfa513e6bc48..28e9158b3a89e43e312b25f92ce29fa4ba867cc0 100644 (file)
@@ -12,7 +12,7 @@
 
 typedef struct  {
         SOCPTR *socptr; //established contact context
-        _Bool tlsok;    //link is in crypted mode
+        //_Bool tlsok;    //link is in crypted mode
         char *fqdn;     //fully qualified domain from peer
         char *locname;  //socket local hostname
         char *locserv;  //local service port