From: Jean-Marc Pigeon (Delson) Date: Fri, 14 Mar 2025 12:42:41 +0000 (-0400) Subject: Removing init sequence X-Git-Tag: tag-0.6^0 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=7cd2358a5c38045d04ffbf74973bcb7ea2c8a61b;p=jmp%2Fmailleur Removing init sequence --- diff --git a/app/emlrcvr.c b/app/emlrcvr.c index 1762290..f2eb989 100644 --- a/app/emlrcvr.c +++ b/app/emlrcvr.c @@ -55,10 +55,8 @@ while (proceed==true) { (void) prc_preptitle(argc,argv,environ); (void) rou_setappname(RECNAME); (void) rou_modesubrou(true); - (void) par_modeunipar(true); (void) prc_modeuniprc(true); (void) sig_modeunisig(true); - (void) rec_modemodrec(true); (void) sig_trapsignal(true,sig_alrm); break; case 2 : //doing main task @@ -68,10 +66,8 @@ while (proceed==true) { (void) prc_cleantitle(); params=par_freeparams(params); (void) sig_trapsignal(false,sig_alrm); - (void) rec_modemodrec(false); (void) sig_modeunisig(false); (void) prc_modeuniprc(false); - (void) par_modeunipar(false); (void) rou_modesubrou(false); break; default : //end of task diff --git a/app/maild.c b/app/maild.c index f8ada53..3390888 100644 --- a/app/maild.c +++ b/app/maild.c @@ -139,7 +139,6 @@ while (proceed==true) { case 2 : //initialising process (void) prc_preptitle(argc,argv,environ); (void) rou_modesubrou(true); - (void) par_modeunipar(true); (void) prc_modeuniprc(true); (void) sig_modeunisig(true); (void) sig_trapsignal(true,sig_alrm); @@ -156,7 +155,6 @@ while (proceed==true) { (void) sig_trapsignal(false,sig_alrm); (void) sig_modeunisig(false); (void) prc_modeuniprc(false); - (void) par_modeunipar(false); (void) rou_modesubrou(false); break; default : //end of task diff --git a/lib/devlog.c b/lib/devlog.c index 055a0f8..f06f4f4 100644 --- a/lib/devlog.c +++ b/lib/devlog.c @@ -24,7 +24,6 @@ typedef struct { TIMESPEC start; //log start time }LOGTYP; -static _Bool modopen; //boolean module open/close /* ^L */ @@ -220,38 +219,3 @@ va_end(args); return taille; #undef OPEP } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -PUBLIC int log_modedevlog(_Bool mode) - -{ -#define OPEP "devlog.c:log_modedevlog" - -int status; - -status=0; -if (mode!=modopen) { - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/devlog.h b/lib/devlog.h index b3d2650..fc294f7 100644 --- a/lib/devlog.h +++ b/lib/devlog.h @@ -25,7 +25,4 @@ extern int log_fprintlog(LOGPTR *logptr,_Bool suite,const char *format,...); //current daily log extern int log_mergelog(char *logname); -//homework to be done before starting/stopping module. -extern int log_modedevlog(_Bool mode); - #endif diff --git a/lib/devsoc.c b/lib/devsoc.c index 888f915..5b42147 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -47,7 +47,6 @@ typedef struct { int iteration; //number of soc slot used on the IP }SOCTYP; -static _Bool modopen; //module open/close status /* */ @@ -1102,49 +1101,6 @@ return socptr; ^L */ /********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -int soc_modedevsoc(_Bool mode) - -{ -#define OPEP "unidoc.c:soc_modeunisoc" - -int status; - -status=0; -if (mode!=modopen) { - switch ((int)mode) { - case true : - (void) rou_modesubrou(mode); - (void) eml_modeunieml(mode); - (void) prc_modeuniprc(mode); - (void) tls_modeunitls(mode); - break; - case false : - (void) tls_modeunitls(mode); - (void) prc_modeuniprc(mode); - (void) eml_modeunieml(mode); - (void) rou_modesubrou(mode); - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} -/* -^L -*/ -/********************************************************/ /* */ /* Procedure to switch a plain socket channel to */ /* crypted channel, return true is successful. */ diff --git a/lib/devsoc.h b/lib/devsoc.h index c5c3118..c79278d 100644 --- a/lib/devsoc.h +++ b/lib/devsoc.h @@ -71,7 +71,4 @@ extern SOCPTR *soc_release(SOCPTR *socptr); //procedure to initiate crypted mode on plain channel extern _Bool soc_starttls(SOCPTR *socptr,const char *peerip); -//homework to be done before starting/stopping module. -extern int soc_modedevsoc(_Bool mode); - #endif diff --git a/lib/gesspf.c b/lib/gesspf.c index 2f4d298..c54da7b 100644 --- a/lib/gesspf.c +++ b/lib/gesspf.c @@ -33,7 +33,6 @@ typedef enum { //mechanism definition mch_unknown //unknown mechanism }MCHTYP; -static _Bool modopen; //module open/close status /* */ @@ -634,40 +633,3 @@ return spf; #undef OPEP } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -int spf_modegesspf(_Bool mode) - -{ -#define OPEP "unidoc.c:soc_modeunisoc" - -int status; - -status=0; -if (mode!=modopen) { - (void) rou_modesubrou(mode); - (void) afn_modesubafn(mode); - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/gesspf.h b/lib/gesspf.h index f8093e0..7eed2c0 100644 --- a/lib/gesspf.h +++ b/lib/gesspf.h @@ -27,7 +27,4 @@ extern const char *spf_spfASCII(SPFENU spf); //get the SPF status for a specific domain and a remote peer IP extern SPFENU spf_getstatus(int *try,char *domain,AFNTYP *afnnum); -//homework to be done before starting/stopping module. -extern int spf_modegesspf(_Bool mode); - #endif diff --git a/lib/gestcp.c b/lib/gestcp.c index f408ba0..1ca136d 100644 --- a/lib/gestcp.c +++ b/lib/gestcp.c @@ -1,7 +1,7 @@ // vim: smarttab tabstop=8 shiftwidth=2 expandtab /********************************************************/ /* */ -/* Module for signal handling level */ +/* Module to handle TCP communication */ /* */ /********************************************************/ #include @@ -20,7 +20,6 @@ #include "uniprc.h" #include "gestcp.h" -static _Bool modopen; //boolean module open/close /* ^L */ @@ -242,48 +241,3 @@ while (proceed==true) { return contact; #undef OPEP } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -PUBLIC int tcp_modegestcp(_Bool mode) - -{ -#define OPEP "unisig.c:sig_modeunisig" - -int status; - -status=0; -if (mode!=modopen) { - switch ((int)mode) { - case true : - (void) rou_modesubrou(mode); - (void) sig_modeunisig(mode); - (void) prc_modeuniprc(mode); - (void) eml_modeunieml(mode); - (void) soc_modedevsoc(mode); - break; - case false : - (void) soc_modedevsoc(mode); - (void) eml_modeunieml(mode); - (void) sig_modeunisig(mode); - (void) prc_modeuniprc(mode); - (void) rou_modesubrou(mode); - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/gestcp.h b/lib/gestcp.h index 3abb019..19aa785 100644 --- a/lib/gestcp.h +++ b/lib/gestcp.h @@ -39,7 +39,4 @@ extern CONTYP *tcp_getcontact(SOCPTR *socptr,int pos); //drop contact established by remote extern CONTYP *tcp_dropcontact(CONTYP *contact); -//homework to be done before starting/stopping module. -extern int tcp_modegestcp(_Bool mode); - #endif diff --git a/lib/lvleml.c b/lib/lvleml.c index 3504738..3c4167e 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -15,8 +15,6 @@ #include "lvleml.h" - -static _Bool modopen; //module open/close status /* ^L */ @@ -80,7 +78,7 @@ if (contact!=(CONTYP *)0) { /* if EHLO message is not accepted. */ /* */ /************************************************/ -static _Bool dohelo(CONTYP *contact,char *keyword,char *parameter) +static _Bool dohelo(CONTYP *contact,char *parameter) { #define OPEP "unieml.c:dohelo" @@ -128,7 +126,7 @@ return done; /* if EHLO message is not accepted. */ /* */ /************************************************/ -static _Bool doehlo(CONTYP *contact,char *keyword,char *parameter) +static _Bool doehlo(CONTYP *contact,char *parameter) { static char *ehlostr[]= { @@ -192,7 +190,7 @@ return done; /* Procedure to rset the current session */ /* */ /************************************************/ -static _Bool doreset(CONTYP *contact,char *keyword,char *parameter) +static _Bool doreset(CONTYP *contact,char *parameter) { (void) transmit(contact,"%d 2.0.0 Flushed session %s",CMDOK,contact->cursesid); @@ -225,7 +223,6 @@ proceed=true; (void) signon(contact); while (proceed==true) { char *line; - char *parameter; TIMESPEC attend; attend.tv_sec=60; @@ -234,31 +231,23 @@ while (proceed==true) { if (status<=0) //timeout or trouble? break; //no need to go further (void) log_fprintlog(contact->logptr,false,"%s",line); - if (line!=(char *)0) { - parameter=strchr(line,' '); - if (parameter==(char *)0) - parameter=strchr(line,'\t'); - if (parameter!=(char *)0) { - *parameter='\000'; - parameter++; - while ((*parameter==' ')||(*parameter=='\t')) - parameter++; - } - } switch (eml_getcode(line)) { case c_helo : //HELO SMTP protocol - proceed=dohelo(contact,line,parameter); + proceed=dohelo(contact,line); break; case c_ehlo : //EHLO SMTP protocol - proceed=doehlo(contact,line,parameter); + proceed=doehlo(contact,line); break; case c_quit : //QUIT SMTP protocol (void) transmit(contact,"%d 2.0.0 Bye, closing connection %s", QUITOK,contact->mainsesid); proceed=false; break; + case c_mail : //MAIL FROM: checking originator + (void) rou_alert(0,"JMPDBG parameter=<%s>",line); + break; case c_rset : //Doing session reset - proceed=doreset(contact,line,parameter); + proceed=doreset(contact,line); break; case c_starttls : //EHLO start encryptel link switch (soc_starttls(contact->socptr,contact->peerip)) { @@ -289,44 +278,3 @@ while (proceed==true) { return status; #undef OPEP } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -int eml_modelvleml(_Bool mode) - -{ -#define OPEP "unidoc.c:soc_modeunisoc" - -int status; - -status=0; -if (mode!=modopen) { - switch ((int)mode) { - case true : - (void) rou_modesubrou(mode); - (void) eml_modeunieml(mode); - (void) log_modedevlog(mode); - break; - case false : - (void) log_modedevlog(mode); - (void) eml_modeunieml(mode); - (void) rou_modesubrou(mode); - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/lvleml.h b/lib/lvleml.h index 6172c1a..12f51e3 100644 --- a/lib/lvleml.h +++ b/lib/lvleml.h @@ -13,7 +13,4 @@ //procedure to extract line and proceed with peer contact extern int eml_docontact(CONTYP *contact); -//homework to be done before starting/stopping module. -extern int eml_modelvleml(_Bool mode); - #endif diff --git a/lib/modrec.c b/lib/modrec.c index 9803545..b23bba8 100644 --- a/lib/modrec.c +++ b/lib/modrec.c @@ -21,7 +21,6 @@ #include "lvleml.h" #include "modrec.h" -static _Bool modopen; //boolean module open/close #define DFLTIP "127.0.10.25" //smtp test IP #define SMTPORT "1025" //smtp test port /* @@ -56,7 +55,7 @@ for (int i=0;i -//procedure to receive email form outside +//procedure to receive email from outside extern void rec_handlesmtp(int argc,char *argv[]); -//homework to be done before starting/stoping module. -extern int rec_modemodrec(_Bool mode); - #endif diff --git a/lib/subafn.c b/lib/subafn.c index 35d2458..e24c278 100644 --- a/lib/subafn.c +++ b/lib/subafn.c @@ -15,7 +15,6 @@ #define PUBLIC //to specify public variable -static _Bool modopen; //module open/close status /* */ @@ -378,38 +377,3 @@ while (proceed==true) { } return areequal; } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -PUBLIC int afn_modesubafn(_Bool mode) - -{ -#define OPEP "subafn.c:afn_modesubafn" - -int status; - -status=0; -if (mode!=modopen) { - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/subafn.h b/lib/subafn.h index 9363104..4c84d90 100644 --- a/lib/subafn.h +++ b/lib/subafn.h @@ -46,7 +46,4 @@ extern AFNTYP *afn_getipnum(char *cleanipstr); //procedure to compare 2 same class IP according a mask value extern int afn_cmpipnum(AFNTYP *afnnum1,AFNTYP *afnnum2,int mask); -//homework to be done before starting/stoping module. -extern int afn_modesubafn(_Bool mode); - #endif diff --git a/lib/unidns.c b/lib/unidns.c index 2a7ffae..20b416a 100644 --- a/lib/unidns.c +++ b/lib/unidns.c @@ -26,7 +26,6 @@ typedef union { u_char buf[B64K]; //according US Cert VU#738331 }RSPTYP; -static _Bool modopen; //module open/close status /* */ @@ -380,42 +379,6 @@ while (proceed==true) { } return mxlist; -#undef OPEP -} -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -int dns_modeunidns(_Bool mode) - -{ -#define OPEP "unidoc.c:soc_modeunisoc" - -int status; - -status=0; -if (mode!=modopen) { - (void) rou_modesubrou(mode); - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; #undef OPEP } /* diff --git a/lib/unidns.h b/lib/unidns.h index 6c0b1fa..689d706 100644 --- a/lib/unidns.h +++ b/lib/unidns.h @@ -30,7 +30,4 @@ extern MXTYP **dns_getmx(char *domain); //of domain A record list extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask); -//homework to be done before starting/stopping module. -extern int dns_modeunidns(_Bool mode); - #endif diff --git a/lib/unieml.c b/lib/unieml.c index df4d934..9617913 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -13,8 +13,6 @@ #include "subrou.h" #include "unieml.h" -static _Bool modopen; //module open/close status - typedef struct { CODTYP code; //keyword code const char *key; //keyword itself @@ -26,6 +24,7 @@ static VOCTYP vocsmtp[]={ {c_ehlo,"EHLO"}, {c_quit,"QUIT"}, {c_rset,"RSET"}, + {c_mail,MAILF}, {c_starttls,"STARTTLS"}, {c_unknown,(const char *)0} }; @@ -92,46 +91,16 @@ VOCTYP *ptr; code=c_unknown; for (ptr=vocsmtp;ptr->code!=c_unknown;ptr++) { - if (strncasecmp(ptr->key,keyword,strlen(keyword))==0) { + if (strncasecmp(ptr->key,keyword,strlen(ptr->key))==0) { + char *par; + code=ptr->code; + par=keyword+strlen(ptr->key); + while ((*par==' ')||(*par=='\t')) + par++; + (void) strcpy(keyword,par); break; } } return code; } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -int eml_modeunieml(_Bool mode) - -{ -#define OPEP "unidoc.c:soc_modeunisoc" - -int status; - -status=0; -if (mode!=modopen) { - (void) rou_modesubrou(mode); - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/unieml.h b/lib/unieml.h index b168b0b..ebcf180 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -16,12 +16,17 @@ #define BADPAR 501 //error in parameters #define CMDBAD 502 //command not implemented + +//SMTP avail command +#define MAILF "MAIL FROM:" //Mail from a sender + //list of keyword typedef enum { //list of SMTP protocol keyword c_helo, //Basic Helo command c_ehlo, //EHLO command c_quit, //quit exchange c_rset, //resetting session + c_mail, //mail from sequence detected c_starttls, //Starting a TLS crypted link c_unknown //key word unknown }CODTYP; @@ -35,7 +40,4 @@ extern char *eml_getcursesid(char *mainid,int numreset); //convert SMTP keyword to CODTYP extern CODTYP eml_getcode(char *keyword); -//homework to be done before starting/stopping module. -extern int eml_modeunieml(_Bool mode); - #endif diff --git a/lib/unipar.c b/lib/unipar.c index 72ec658..7c9b609 100644 --- a/lib/unipar.c +++ b/lib/unipar.c @@ -14,7 +14,6 @@ #include "subrou.h" #include "unipar.h" -static _Bool modopen; //module open/close status /* ^L */ @@ -156,39 +155,3 @@ if ((params!=(ARGTYP *)0)&&(argc>optind)) { } return params; } -/* -^L -*/ -/********************************************************/ -/* */ -/* Procedure to "open/close" module and do */ -/* homework purpose */ -/* return zero if everything right */ -/* */ -/********************************************************/ -PUBLIC int par_modeunipar(_Bool mode) - -{ -#define OPEP "unipar.c:uni_modeunipar" - -int status; - -status=0; -if (mode!=modopen) { - (void) rou_modesubrou(mode); - switch ((int)mode) { - case true : - break; - case false : - break; - default : - (void) fprintf(stderr,"Calling %s with wrong mode='%d' (Bug?!):", - OPEP,(int)mode); - status=-1; - break; - } - modopen=mode; - } -return status; -#undef OPEP -} diff --git a/lib/unipar.h b/lib/unipar.h index e992c9f..a66672b 100644 --- a/lib/unipar.h +++ b/lib/unipar.h @@ -23,7 +23,4 @@ extern ARGTYP *par_freeparams(ARGTYP *params); //allocated memory and parse an argment list extern ARGTYP *par_getparams(int argc,char * const argv[],const char *optstring); -//homework to be done before starting/stopping module. -extern int par_modeunipar(_Bool mode); - #endif