case 'R' : //Remote delivery
(void) eml_remote_email(tra);
break;
+ case 'W' : //Remote delivery
+ (void) eml_rebounce_email(tra);
+ break;
default :
(void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*tra)->code);
status=false;
(void) sig_modeunisig(true);
(void) sig_trapsignal(true,sig_alrm);
(void) rou_setappname(SORTER);
+ (void) dns_set_local_smtp();
(void) rou_loadconfig(config,true);
(void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
if (foreground==false) {
break;
default : //end of task
params=par_freeparams(params);
- (void) rou_loadconfig(config,false);
+ (void) dns_drop_local_smtp();
+ (void) rou_loadconfig(config,false);
(void) sig_trapsignal(false,sig_alrm);
(void) sig_modeunisig(false);
(void) rou_modesubrou(false);
#undef OPEP
}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to rebounce an email which was NOT */
+/* deliverable. */
+/* */
+/********************************************************/
+PUBLIC void eml_rebounce_email(TRATYP **tra)
+
+{
+}
+
//sending email to remote recipents
extern void eml_remote_email(TRATYP **tra);
+//Rebouncing Email to the first originator
+extern void eml_rebounce_email(TRATYP **tra);
+
#endif
u_char buf[B64K]; //according US Cert VU#738331
}RSPTYP;
+//list of SMTP local IPV4
+in_addr_t *local_ipv4=(in_addr_t *)0;
+int num_ipv4=0; //number of IP within local_ipv4
+
/*
\f
*/
return match;
#undef OPEP
}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to collect IP binded to listen SMTP */
+/* port. */
+/* */
+/********************************************************/
+PUBLIC void dns_set_local_smtp()
+
+{
+#define OPEP "unidns.c:dns_set_local_smtp,"
+#define MXIP 20
+#define TCP "/proc/net/tcp"
+
+int numip;
+FILE *fichier;
+int phase;
+_Bool proceed;
+
+numip=0;
+fichier=(FILE *)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //Opening the netstat directory
+ if ((fichier=fopen(TCP,"r"))==(FILE *)0) {
+ (void) rou_alert(0,"%s Unable to open <%s> (error=<%s>)",
+ OPEP,strerror(errno));
+ (void) rou_alert(0,"%s (not an linux system? exiting!)",OPEP);
+ (void) exit(-1);//BIG BIG trouble
+ }
+ break;
+ case 1 : //scanning netstat file
+ int numline;
+ char line[200];
+
+ numline=0;
+ local_ipv4=calloc(MXIP,sizeof(in_addr_t));
+ while (fgets(line,sizeof(line),fichier)!=(char *)0) {
+ int seq;
+ int addr;
+ int port;
+
+ numline++;
+ if (numline==1)
+ continue; //discarding first line
+ if (sscanf(line,"%d: %8x:%4x",&seq,&addr,&port)==3) {
+ (void) fprintf(stdout,"JMPDBG seq=%d addr=%x port=%d\n",seq,addr,port);
+ numip++;
+ }
+ }
+ break;
+ case 2 : //closing file
+ (void) fclose(fichier);
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+
+#undef TCP
+#undef MXIP
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Procedure to free memory used by SMTP local IP */
+/* */
+/********************************************************/
+PUBLIC void dns_drop_local_smtp()
+
+{
+if (local_ipv4!=(in_addr_t *)0) {
+ (void) free(local_ipv4);
+ num_ipv4=0;
+ local_ipv4=(in_addr_t *)0;
+ }
+}
//defining an MX structure
typedef struct {
- int preference; /*MX preference */
- char *mxname; /*MX hostname */
+ int preference; //MX preference
+ char *mxname; //MX hostname
+ char **mxip; //MX IPNUM list
}MXTYP;
//Procedure to get ONE SPF entry within domain dns
//of domain A record list
extern _Bool dns_matchiprec(char *hostname,AFNTYP *afnnum,int mask);
+//procedure to create the list of local IP used to listen
+//the smtp protocol
+extern void dns_set_local_smtp();
+
+//procedure to free the list of local IP used to listen
+//the smtp protocol
+extern void dns_drop_local_smtp();
+
+//procedure to detect if a domain is served by a local
+//smtp server
+extern _Bool dns_is_domain_local(const char *domain);
+
#endif