s/qmail 4.3.20
Next generation secure email transport
Loading...
Searching...
No Matches
Macros | Functions | Variables
qmail-remote.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "sig.h"
#include "stralloc.h"
#include "buffer.h"
#include "scan.h"
#include "case.h"
#include "byte.h"
#include "qmail.h"
#include "auto_qmail.h"
#include "control.h"
#include "dns.h"
#include "alloc.h"
#include "genalloc.h"
#include "quote.h"
#include "fmt.h"
#include "ip.h"
#include "ipalloc.h"
#include "ipme.h"
#include "str.h"
#include "now.h"
#include "exit.h"
#include "constmap.h"
#include "tcpto.h"
#include "timeout.h"
#include "timeoutconn.h"
#include "base64.h"
#include "socket_if.h"
#include "ucspissl.h"
#include "tls_remote.h"
#include "tls_errors.h"
#include "tls_timeoutio.h"
#include "uint_t.h"
#include "hmac_md5.h"
Include dependency graph for qmail-remote.c:

Go to the source code of this file.

Macros

#define WHO   "qmail-remote"
 
#define QMTP_MAX   200000000 /* 190 MB for QMTP */
 
#define HUGESMTPTEXT   1000 /* RFC 5322; was 5000 chars/line */
 
#define PORT_SMTP   25 /* silly rabbit, /etc/services is for users */
 
#define PORT_QMTP   209
 
#define PORT_SMTPS   465
 
#define PORT_SUBMISSION   587
 
#define PORT_QMTPS   6209
 
#define VERIFYDEPTH   1
 
#define TCP_TIMEOUT   60
 
#define SMTP_TIMEOUT   1200
 

Functions

 GEN_ALLOC_typedef (GEN_ALLOC_readyplus(saa, GEN_ALLOC_readyplus(stralloc, GEN_ALLOC_readyplus(sa, GEN_ALLOC_readyplus(len, GEN_ALLOC_readyplus(a)
 
void out (char *s)
 
void zero ()
 
void zerodie ()
 
void outsafe (stralloc *sa)
 
void temp_noip ()
 
void temp_nomem ()
 
void temp_oserr ()
 
void temp_osip ()
 
void temp_noconn ()
 
void temp_qmtpnoc ()
 
void temp_read ()
 
void temp_dnscanon ()
 
void temp_dns ()
 
void temp_nomx ()
 
void temp_chdir ()
 
void temp_control ()
 
void perm_partialline ()
 
void temp_proto ()
 
void perm_usage ()
 
void perm_dns ()
 
void perm_nomx ()
 
void perm_nullmx ()
 
void perm_ambigmx ()
 
void err_authprot ()
 
void outhost ()
 
void dropped ()
 
ssize_t saferead (int fd, char *buf, int len)
 
ssize_t safewrite (int fd, char *buf, int len)
 
void get (char *ch)
 
unsigned long smtpcode ()
 
void outsmtptext ()
 
void quit (char *prepend, char *append)
 
void blast ()
 
void tls_init ()
 
int ehlo_starttls ()
 
void tls_peercheck ()
 
int utf8string (unsigned char *ch, int len)
 
int utf8received ()
 
int ehlo_size ()
 
void smtp_greeting ()
 
void smtp_starttls ()
 
void mailfrom ()
 
int xtext (stralloc *sa, char *s, int len)
 
void mailfrom_xtext ()
 
int mailfrom_plain ()
 
int mailfrom_login ()
 
int mailfrom_cram ()
 
void ehlo_auth ()
 
void smtp ()
 
void qmtp ()
 
void addrmangle (stralloc *saout, char *address, int *flagalias, int flagcname)
 
void getcontrols ()
 
int main (int argc, char *const *argv)
 

Variables

unsigned long port = PORT_SMTP
 
int flagauth = 0
 
int flagsmtps = 0
 
int flagtlsdomain = 0
 
int flagtls = 0
 
int flagverify = 0
 
int flagutf8 = 0
 
stralloc helohost = {0}
 
stralloc eaihost = {0}
 
stralloc host = {0}
 
stralloc idnhost = {0}
 
stralloc sender = {0}
 
stralloc canonhost = {0}
 
stralloc remotehost = {0}
 
stralloc canonbox = {0}
 
stralloc senddomain = {0}
 
stralloc sendip = {0}
 
stralloc domainips = {0}
 
struct constmap mapdomainips
 
char ip4 [4]
 
char ip6 [16]
 
uint32 ifidx = 0
 
char * authsender = 0
 
stralloc smtproutes = {0}
 
struct constmap mapsmtproutes
 
stralloc qmtproutes = {0}
 
struct constmap mapqmtproutes
 
saa reciplist = {0}
 
stralloc recip = {0}
 
char msgsize [FMT_ULONG]
 
unsigned long msize = 0
 
struct ip_mx partner
 
SSL * ssl
 
SSL_CTX * ctx
 
char bufsmall [BUFFER_SMALL]
 
buffer bs = BUFFER_INIT(buffer_unixwrite,1,bufsmall,sizeof(bufsmall))
 
int flagcritical = 0
 
unsigned long timeoutconnect = TCP_TIMEOUT
 
unsigned long timeout = SMTP_TIMEOUT
 
int smtpfd
 
char inbuf [BUFFER_MTUSIZE]
 
buffer bi = BUFFER_INIT(buffer_unixread,0,inbuf,sizeof(inbuf))
 
char outbuf [BUFFER_MTUSIZE]
 
buffer bo = BUFFER_INIT(safewrite,-1,outbuf,sizeof(outbuf))
 
char frombuf [BUFFER_SMALL]
 
buffer bf = BUFFER_INIT(saferead,-1,frombuf,sizeof(frombuf))
 
stralloc cafile = {0}
 
stralloc cadir = {0}
 
stralloc certfile = {0}
 
stralloc keyfile = {0}
 
stralloc keypwd = {0}
 
stralloc ciphers = {0}
 
char * tlsdestinfo = 0
 
char * tlsdomaininfo = 0
 
stralloc domaincerts = {0}
 
struct constmap mapdomaincerts
 
stralloc tlsdestinations = {0}
 
struct constmap maptlsdestinations
 
unsigned long verifydepth = VERIFYDEPTH
 
unsigned long code
 
int flagsize = 0
 
stralloc authsenders = {0}
 
struct constmap mapauthsenders
 
stralloc user = {0}
 
stralloc pass = {0}
 
stralloc auth = {0}
 
stralloc chal = {0}
 
stralloc slop = {0}
 
stralloc plain = {0}
 
stralloc xuser = {0}
 
int qmtpsend = 0
 

Detailed Description

-- versatile SMTP(S)/QMTP(S) client

Definition in file qmail-remote.c.

Macro Definition Documentation

◆ HUGESMTPTEXT

#define HUGESMTPTEXT   1000 /* RFC 5322; was 5000 chars/line */

Definition at line 46 of file qmail-remote.c.

◆ PORT_QMTP

#define PORT_QMTP   209

Definition at line 48 of file qmail-remote.c.

◆ PORT_QMTPS

#define PORT_QMTPS   6209

Definition at line 51 of file qmail-remote.c.

◆ PORT_SMTP

#define PORT_SMTP   25 /* silly rabbit, /etc/services is for users */

Definition at line 47 of file qmail-remote.c.

◆ PORT_SMTPS

#define PORT_SMTPS   465

Definition at line 49 of file qmail-remote.c.

◆ PORT_SUBMISSION

#define PORT_SUBMISSION   587

Definition at line 50 of file qmail-remote.c.

◆ QMTP_MAX

#define QMTP_MAX   200000000 /* 190 MB for QMTP */

Definition at line 45 of file qmail-remote.c.

◆ SMTP_TIMEOUT

#define SMTP_TIMEOUT   1200

Definition at line 54 of file qmail-remote.c.

◆ TCP_TIMEOUT

#define TCP_TIMEOUT   60

Definition at line 53 of file qmail-remote.c.

◆ VERIFYDEPTH

#define VERIFYDEPTH   1

Definition at line 52 of file qmail-remote.c.

◆ WHO

#define WHO   "qmail-remote"

Definition at line 43 of file qmail-remote.c.

Function Documentation

◆ addrmangle()

void addrmangle ( stralloc *  saout,
char *  address,
int flagalias,
int  flagcname 
)

Definition at line 1055 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ blast()

void blast ( )

Definition at line 385 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dropped()

void dropped ( )

Definition at line 280 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ehlo_auth()

void ehlo_auth ( )

Definition at line 824 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ehlo_size()

int ehlo_size ( )

Definition at line 606 of file qmail-remote.c.

Here is the caller graph for this function:

◆ ehlo_starttls()

int ehlo_starttls ( )

Definition at line 483 of file qmail-remote.c.

Here is the caller graph for this function:

◆ err_authprot()

void err_authprot ( )

Definition at line 258 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GEN_ALLOC_typedef()

GEN_ALLOC_typedef ( GEN_ALLOC_readyplus saa,
GEN_ALLOC_readyplus stralloc,
GEN_ALLOC_readyplus sa,
GEN_ALLOC_readyplus len,
GEN_ALLOC_readyplus a 
)

Definition at line 73 of file qmail-remote.c.

◆ get()

void get ( char *  ch)

Definition at line 330 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getcontrols()

void getcontrols ( void  )

Definition at line 1089 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailfrom()

void mailfrom ( )

Definition at line 655 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailfrom_cram()

int mailfrom_cram ( )

Definition at line 779 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailfrom_login()

int mailfrom_login ( )

Definition at line 749 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailfrom_plain()

int mailfrom_plain ( )

Definition at line 723 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailfrom_xtext()

void mailfrom_xtext ( )

Definition at line 706 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Definition at line 1129 of file qmail-remote.c.

Here is the call graph for this function:

◆ out()

void out ( char *  s)

Definition at line 113 of file qmail-remote.c.

Here is the call graph for this function:

◆ outhost()

void outhost ( )

Definition at line 264 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ outsafe()

void outsafe ( stralloc *  sa)

Definition at line 131 of file qmail-remote.c.

Here is the caller graph for this function:

◆ outsmtptext()

void outsmtptext ( )

Definition at line 361 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_ambigmx()

void perm_ambigmx ( )

Definition at line 252 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_dns()

void perm_dns ( )

Definition at line 231 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_nomx()

void perm_nomx ( )

Definition at line 238 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_nullmx()

void perm_nullmx ( )

Definition at line 245 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_partialline()

void perm_partialline ( )

Definition at line 216 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm_usage()

void perm_usage ( )

Definition at line 226 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qmtp()

void qmtp ( )

Definition at line 940 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quit()

void quit ( char *  prepend,
char *  append 
)

Definition at line 373 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saferead()

ssize_t saferead ( int  fd,
char *  buf,
int  len 
)

Definition at line 294 of file qmail-remote.c.

Here is the call graph for this function:

◆ safewrite()

ssize_t safewrite ( int  fd,
char *  buf,
int  len 
)

Definition at line 307 of file qmail-remote.c.

Here is the call graph for this function:

◆ smtp()

void smtp ( )

Definition at line 847 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smtp_greeting()

void smtp_greeting ( )

Definition at line 618 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smtp_starttls()

void smtp_starttls ( )

Definition at line 639 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smtpcode()

unsigned long smtpcode ( )

Definition at line 338 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_chdir()

void temp_chdir ( )

Definition at line 206 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_control()

void temp_control ( )

Definition at line 211 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_dns()

void temp_dns ( )

Definition at line 192 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_dnscanon()

void temp_dnscanon ( )

Definition at line 185 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_noconn()

void temp_noconn ( )

Definition at line 166 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_noip()

void temp_noip ( )

Definition at line 144 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_nomem()

void temp_nomem ( void  )

Definition at line 149 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_nomx()

void temp_nomx ( )

Definition at line 199 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_oserr()

void temp_oserr ( )

Definition at line 154 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_osip()

void temp_osip ( )

Definition at line 159 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_proto()

void temp_proto ( )

Definition at line 221 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_qmtpnoc()

void temp_qmtpnoc ( )

Definition at line 173 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ temp_read()

void temp_read ( )

Definition at line 180 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tls_init()

void tls_init ( )

Definition at line 443 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tls_peercheck()

void tls_peercheck ( )

Definition at line 495 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8received()

int utf8received ( )

Definition at line 563 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utf8string()

int utf8string ( unsigned char *  ch,
int  len 
)

Definition at line 555 of file qmail-remote.c.

Here is the caller graph for this function:

◆ xtext()

int xtext ( stralloc *  sa,
char *  s,
int  len 
)

Definition at line 685 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero()

void zero ( )

Definition at line 118 of file qmail-remote.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zerodie()

void zerodie ( void  )

Definition at line 123 of file qmail-remote.c.

Here is the caller graph for this function:

Variable Documentation

◆ auth

stralloc auth = {0}

Definition at line 677 of file qmail-remote.c.

◆ authsender

char* authsender = 0

Definition at line 93 of file qmail-remote.c.

◆ authsenders

stralloc authsenders = {0}

Definition at line 672 of file qmail-remote.c.

◆ bf

buffer bf = BUFFER_INIT(saferead,-1,frombuf,sizeof(frombuf))

Definition at line 325 of file qmail-remote.c.

◆ bi

buffer bi = BUFFER_INIT(buffer_unixread,0,inbuf,sizeof(inbuf))

Definition at line 321 of file qmail-remote.c.

◆ bo

buffer bo = BUFFER_INIT(safewrite,-1,outbuf,sizeof(outbuf))

Definition at line 323 of file qmail-remote.c.

◆ bs

buffer bs = BUFFER_INIT(buffer_unixwrite,1,bufsmall,sizeof(bufsmall))

Definition at line 111 of file qmail-remote.c.

◆ bufsmall

char bufsmall[BUFFER_SMALL]

Definition at line 110 of file qmail-remote.c.

◆ cadir

stralloc cadir = {0}

Definition at line 428 of file qmail-remote.c.

◆ cafile

stralloc cafile = {0}

Definition at line 427 of file qmail-remote.c.

◆ canonbox

stralloc canonbox = {0}

Definition at line 84 of file qmail-remote.c.

◆ canonhost

stralloc canonhost = {0}

Definition at line 82 of file qmail-remote.c.

◆ certfile

stralloc certfile = {0}

Definition at line 429 of file qmail-remote.c.

◆ chal

stralloc chal = {0}

Definition at line 678 of file qmail-remote.c.

◆ ciphers

stralloc ciphers = {0}

Definition at line 432 of file qmail-remote.c.

◆ code

unsigned long code

Definition at line 603 of file qmail-remote.c.

◆ ctx

SSL_CTX* ctx

Definition at line 108 of file qmail-remote.c.

◆ domaincerts

stralloc domaincerts = {0}

Definition at line 437 of file qmail-remote.c.

◆ domainips

stralloc domainips = {0}

Definition at line 88 of file qmail-remote.c.

◆ eaihost

stralloc eaihost = {0}

Definition at line 78 of file qmail-remote.c.

◆ flagauth

int flagauth = 0

Definition at line 60 of file qmail-remote.c.

◆ flagcritical

int flagcritical = 0

Definition at line 278 of file qmail-remote.c.

◆ flagsize

int flagsize = 0

Definition at line 604 of file qmail-remote.c.

◆ flagsmtps

int flagsmtps = 0

Definition at line 61 of file qmail-remote.c.

◆ flagtls

int flagtls = 0

Definition at line 63 of file qmail-remote.c.

◆ flagtlsdomain

int flagtlsdomain = 0

Definition at line 62 of file qmail-remote.c.

◆ flagutf8

int flagutf8 = 0

Definition at line 71 of file qmail-remote.c.

◆ flagverify

int flagverify = 0

Definition at line 69 of file qmail-remote.c.

◆ frombuf

char frombuf[BUFFER_SMALL]

Definition at line 324 of file qmail-remote.c.

◆ helohost

stralloc helohost = {0}

Definition at line 77 of file qmail-remote.c.

◆ host

stralloc host = {0}

Definition at line 79 of file qmail-remote.c.

◆ idnhost

stralloc idnhost = {0}

Definition at line 80 of file qmail-remote.c.

◆ ifidx

uint32 ifidx = 0

Definition at line 92 of file qmail-remote.c.

◆ inbuf

char inbuf[BUFFER_MTUSIZE]

Definition at line 320 of file qmail-remote.c.

◆ ip4

char ip4[4]

Definition at line 90 of file qmail-remote.c.

◆ ip6

char ip6[16]

Definition at line 91 of file qmail-remote.c.

◆ keyfile

stralloc keyfile = {0}

Definition at line 430 of file qmail-remote.c.

◆ keypwd

stralloc keypwd = {0}

Definition at line 431 of file qmail-remote.c.

◆ mapauthsenders

struct constmap mapauthsenders

Definition at line 673 of file qmail-remote.c.

◆ mapdomaincerts

struct constmap mapdomaincerts

Definition at line 438 of file qmail-remote.c.

◆ mapdomainips

struct constmap mapdomainips

Definition at line 89 of file qmail-remote.c.

◆ mapqmtproutes

struct constmap mapqmtproutes

Definition at line 98 of file qmail-remote.c.

◆ mapsmtproutes

struct constmap mapsmtproutes

Definition at line 96 of file qmail-remote.c.

◆ maptlsdestinations

struct constmap maptlsdestinations

Definition at line 440 of file qmail-remote.c.

◆ msgsize

char msgsize[FMT_ULONG]

Definition at line 103 of file qmail-remote.c.

◆ msize

unsigned long msize = 0

Definition at line 104 of file qmail-remote.c.

◆ outbuf

char outbuf[BUFFER_MTUSIZE]

Definition at line 322 of file qmail-remote.c.

◆ partner

struct ip_mx partner

Definition at line 105 of file qmail-remote.c.

◆ pass

stralloc pass = {0}

Definition at line 676 of file qmail-remote.c.

◆ plain

stralloc plain = {0}

Definition at line 680 of file qmail-remote.c.

◆ port

unsigned long port = PORT_SMTP

Definition at line 56 of file qmail-remote.c.

◆ qmtproutes

stralloc qmtproutes = {0}

Definition at line 97 of file qmail-remote.c.

◆ qmtpsend

int qmtpsend = 0

Definition at line 938 of file qmail-remote.c.

◆ recip

stralloc recip = {0}

Definition at line 101 of file qmail-remote.c.

◆ reciplist

saa reciplist = {0}

Definition at line 100 of file qmail-remote.c.

◆ remotehost

stralloc remotehost = {0}

Definition at line 83 of file qmail-remote.c.

◆ senddomain

stralloc senddomain = {0}

Definition at line 85 of file qmail-remote.c.

◆ sender

stralloc sender = {0}

Definition at line 81 of file qmail-remote.c.

◆ sendip

stralloc sendip = {0}

Definition at line 86 of file qmail-remote.c.

◆ slop

stralloc slop = {0}

Definition at line 679 of file qmail-remote.c.

◆ smtpfd

int smtpfd

Definition at line 292 of file qmail-remote.c.

◆ smtproutes

stralloc smtproutes = {0}

Definition at line 95 of file qmail-remote.c.

◆ ssl

SSL* ssl

Definition at line 107 of file qmail-remote.c.

◆ timeout

unsigned long timeout = SMTP_TIMEOUT

Definition at line 291 of file qmail-remote.c.

◆ timeoutconnect

unsigned long timeoutconnect = TCP_TIMEOUT

Definition at line 290 of file qmail-remote.c.

◆ tlsdestinations

stralloc tlsdestinations = {0}

Definition at line 439 of file qmail-remote.c.

◆ tlsdestinfo

char* tlsdestinfo = 0

Definition at line 434 of file qmail-remote.c.

◆ tlsdomaininfo

char* tlsdomaininfo = 0

Definition at line 435 of file qmail-remote.c.

◆ user

stralloc user = {0}

Definition at line 675 of file qmail-remote.c.

◆ verifydepth

unsigned long verifydepth = VERIFYDEPTH

Definition at line 441 of file qmail-remote.c.

◆ xuser

stralloc xuser = {0}

Definition at line 681 of file qmail-remote.c.