|
Qsmtp
0.23svn
|
main part of Qsmtpd More...
#include <sys/types.h>#include <sys/queue.h>#include <sys/stat.h>#include <sys/statvfs.h>#include <sys/socket.h>#include <sys/wait.h>#include <sys/mman.h>#include <sys/file.h>#include <netinet/in.h>#include <arpa/inet.h>#include <assert.h>#include <stdlib.h>#include <strings.h>#include <string.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#include <syslog.h>#include <dirent.h>#include <signal.h>#include "antispam.h"#include "log.h"#include "netio.h"#include "qdns.h"#include "control.h"#include "userfilters.h"#include "tls.h"#include "sstring.h"#include "qsmtpd.h"#include "version.h"#include "vpop.h"#include "qsauth.h"#include "qsdata.h"#include "xtext.h"#include "fmt.h"#include "qmaildir.h"#include "syntax.h"Defines | |
| #define | _C(c, l, m, f, s, o) { .name = c, .len = l, .mask = m, .func = f, .state = s, .flags = o } |
| #define | MAXRCPT 500 |
Functions | |
| int | smtp_noop (void) |
| int | smtp_quit (void) |
| int | smtp_rset (void) |
| int | smtp_helo (void) |
| int | smtp_ehlo (void) |
| int | smtp_from (void) |
| int | smtp_rcpt (void) |
| int | smtp_vrfy (void) |
| int | smtp_starttls (void) |
| int | http_post (void) |
| int | err_control (const char *fn) |
| write and log error message if opening config file leads to an error | |
| void | dieerror (int error) |
| void | freedata (void) |
| free all ressources allocated for mail transaction | |
| pid_t | fork_clean () |
| fork() but clean up internal structures | |
| void | conn_cleanup (const int rc) |
| clean up the allocated data and exit the process | |
| int | main (int argc, char **argv) |
Variables | |
| struct smtpcomm | commands [] |
| int | relayclient |
| unsigned long | sslauth |
| unsigned long | databytes |
| unsigned int | goodrcpt |
| int | badbounce |
| struct xmitstat | xmitstat |
| char * | protocol |
| const char * | auth_host |
| const char * | auth_check |
| const char ** | auth_sub |
| const char ** | globalconf |
| string | heloname |
| string | msgidhost |
| string | liphost |
| int | socketd = 1 |
| long | comstate = 0x001 |
| int | authhide |
| int | submission_mode |
| struct recip * | thisrecip |
main part of Qsmtpd
This file contains the main function and the basic commands of Qsmtpd SMTP server.
| #define MAXRCPT 500 |
maximum number of recipients in a single mail
| void conn_cleanup | ( | const int | rc | ) |
clean up the allocated data and exit the process
| rc | desired return code of the process |
| void dieerror | ( | int | error | ) |
log error message and terminate program
| error | error code that caused the program termination |
| int err_control | ( | const char * | fn | ) |
write and log error message if opening config file leads to an error
| fn | name of the file that caused the error |
| pid_t fork_clean | ( | ) |
fork() but clean up internal structures
This will work exactly like fork(). If it returns 0 (i.e. you are the child) it will also clean the memory mappings etc. of the Qsmtpd process that the child doesn't need.
| int http_post | ( | void | ) |
http_post - handle HTTP POST request
This has nothing to do with SMTP at all. But I have seen many proxy attempts trying to send spam and beginning the connection with a sequence like this:
> POST / HTTP/1.0 > Via: 1.0 SERVEUR > Host: mail.sf-mail.de:25 > Content-Length: 1255 > Content-Type: text/plain > Connection: Keep-Alive > > RSET
This function is only there to handle this connections and drop them as early as possible to save our traffic.
| int smtp_starttls | ( | void | ) |
initialize STARTTLS mode
| const char* auth_check |
checkpassword or one of his friends for auth
| const char* auth_host |
hostname for auth
| const char** auth_sub |
subprogram to be invoked by auth_check (usually /bin/true)
| int authhide |
hide source of authenticated mail
| int badbounce |
bounce message with more than one recipient
{
_C("NOOP", 4, 0xffff, smtp_noop, -1, 0),
_C("QUIT", 4, 0xfffd, smtp_quit, 0, 0),
_C("RSET", 4, 0xfffd, smtp_rset, 0x1, 0),
_C("HELO", 4, 0xfffd, smtp_helo, 0, 1),
_C("EHLO", 4, 0xfffd, smtp_ehlo, 0, 1),
_C("MAIL FROM:",10, 0x0018, smtp_from, 0, 3),
_C("RCPT TO:", 8, 0x0060, smtp_rcpt, 0, 1),
_C("DATA", 4, 0x0040, smtp_data, 0x10, 0),
_C("STARTTLS", 8, 0x0010, smtp_starttls, 0x1, 0),
_C("AUTH", 4, 0x0010, smtp_auth, -1, 1),
_C("VRFY", 4, 0xffff, smtp_vrfy, -1, 1),
_C("POST", 4, 0xffff, http_post, -1, 1)
}
all supported SMTP commands
| long comstate = 0x001 |
status of the command state machine, initialized to noop
| unsigned long databytes |
maximum message size
| const char** globalconf |
contents of the global "filterconf" file (or NULL)
| unsigned int goodrcpt |
number of valid recipients
| char* protocol |
the protocol string to use (e.g. "ESMTP")
| int relayclient |
flag if this client is allowed to relay by IP: 0 unchecked, 1 allowed, 2 denied
| int socketd = 1 |
the descriptor where messages to network are written to
| unsigned long sslauth |
if SMTP AUTH is only allowed after STARTTLS
| int submission_mode |
if we should act as message submission agent
1.7.6.1