* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $DragonFly: src/libexec/dma/dma.h,v 1.1 2008/02/02 18:20:51 matthias Exp $
*/
#ifndef DMA_H
#define DMA_H
-#ifdef HAVE_CRYPTO
-#include <openssl/ssl.h>
-#endif /* HAVE_CRYPTO */
-
+#include <sys/types.h>
#include <sys/queue.h>
-#include <stdio.h>
-
+#include <sys/socket.h>
+#include <arpa/nameser.h>
+#include <arpa/inet.h>
+#include <openssl/ssl.h>
+#include <netdb.h>
-#define VERSION "DragonFly Mail Agent 1.0"
+#define VERSION "DragonFly Mail Agent " DMA_VERSION
#define BUF_SIZE 2048
+#define ERRMSG_SIZE 200
+#define USERNAME_SIZE 50
#define MIN_RETRY 300 /* 5 minutes */
#define MAX_RETRY (3*60*60) /* retry at least every 3 hours */
#define MAX_TIMEOUT (5*24*60*60) /* give up after 5 days */
+#ifndef PATH_MAX
#define PATH_MAX 1024 /* Max path len */
-#define CONF_PATH "/etc/dma/dma.conf" /* /etc/dma/dma.conf */
-#define SMTP_PORT 25 /* default SMTP port */
-#define CON_TIMEOUT 120 /* Connection timeout */
+#endif
+#define SMTP_PORT 25 /* Default SMTP port */
+#define CON_TIMEOUT (5*60) /* Connection timeout per RFC5321 */
+
+#define STARTTLS 0x002 /* StartTLS support */
+#define SECURETRANS 0x004 /* SSL/TLS in general */
+#define NOSSL 0x008 /* Do not use SSL */
+#define DEFER 0x010 /* Defer mails */
+#define INSECURE 0x020 /* Allow plain login w/o encryption */
+#define FULLBOUNCE 0x040 /* Bounce the full message */
+#define TLS_OPP 0x080 /* Opportunistic STARTTLS */
+
+#ifndef CONF_PATH
+#define CONF_PATH "/etc/dma/dma.conf" /* Default path to dma.conf */
+#endif
+
+#ifndef LIBEXEC_PATH
+#error Please define LIBEXEC_PATH
+#endif
+
+#define DMA_ROOT_USER "mail"
+#define DMA_GROUP "mail"
-#define VIRTUAL 0x1 /* Support for address rewrites */
-#define STARTTLS 0x2 /* StartTLS support */
-#define SECURETRANS 0x4 /* SSL/TLS in general */
-#define TLSINIT 0x8 /* Flag for TLS init phase */
-#define DEFER 0x10 /* Defer mails */
struct stritem {
SLIST_ENTRY(stritem) next;
const char *sender;
char *addr;
char *queuefn;
+ char *mailfn;
char *queueid;
FILE *queuef;
- off_t hdrlen;
+ FILE *mailf;
int remote;
};
LIST_HEAD(queueh, qitem);
struct queue {
struct queueh queue;
- uintmax_t id;
- int mailfd;
+ char *id;
+ FILE *mailf;
char *tmpf;
+ const char *sender;
};
struct config {
- char *smarthost;
+ const char *smarthost;
int port;
- char *aliases;
- char *spooldir;
- char *virtualpath;
- char *authpath;
- char *certfile;
+ const char *aliases;
+ const char *spooldir;
+ const char *authpath;
+ const char *certfile;
int features;
-#ifdef HAVE_CRYPTO
+ const char *mailname;
+
+ /* XXX does not belong into config */
SSL *ssl;
-#endif /* HAVE_CRYPTO */
};
-struct virtuser {
- SLIST_ENTRY(virtuser) next;
- char *login;
- char *address;
-};
-SLIST_HEAD(virtusers, virtuser);
-
struct authuser {
SLIST_ENTRY(authuser) next;
char *login;
};
SLIST_HEAD(authusers, authuser);
+
+struct mx_hostentry {
+ char host[MAXDNAME];
+ char addr[INET6_ADDRSTRLEN];
+ int pref;
+ struct addrinfo ai;
+ struct sockaddr_storage sa;
+};
+
+
+/* global variables */
extern struct aliases aliases;
+extern struct config config;
+extern struct strlist tmpfs;
+extern struct authusers authusers;
+extern char username[USERNAME_SIZE];
+extern uid_t useruid;
+extern const char *logident_base;
+
+extern char neterr[ERRMSG_SIZE];
+extern char errmsg[ERRMSG_SIZE];
/* aliases_parse.y */
-extern int yyparse(void);
+int yyparse(void);
extern FILE *yyin;
/* conf.c */
-extern void trim_line(char *);
-extern int parse_conf(const char *, struct config *);
-extern int parse_virtuser(const char *);
-extern int parse_authfile(const char *);
+void trim_line(char *);
+void parse_conf(const char *);
+void parse_authfile(const char *);
/* crypto.c */
-#ifdef HAVE_CRYPTO
-extern int smtp_init_crypto(struct qitem *, int, int);
-#endif /* HAVE_CRYPTO */
+void hmac_md5(unsigned char *, int, unsigned char *, int, unsigned char *);
+int smtp_auth_md5(int, char *, char *);
+int smtp_init_crypto(int, int);
+
+/* dns.c */
+int dns_get_mx_list(const char *, int, struct mx_hostentry **, int);
/* net.c */
-extern int check_for_smtp_error(int, char *);
-extern ssize_t send_remote_command(int, const char*, ...);
-extern int deliver_remote(struct qitem *, const char **);
+char *ssl_errstr(void);
+int read_remote(int, int, char *);
+ssize_t send_remote_command(int, const char*, ...);
+int deliver_remote(struct qitem *);
/* base64.c */
-extern int base64_encode(const void *, int, char **);
+int base64_encode(const void *, int, char **);
+int base64_decode(const char *, void *);
/* dma.c */
-extern char * hostname(void);
+int add_recp(struct queue *, const char *, int);
+void run_queue(struct queue *);
+
+/* spool.c */
+int newspoolf(struct queue *);
+int linkspool(struct queue *);
+int load_queue(struct queue *);
+void delqueue(struct qitem *);
+int acquirespool(struct qitem *);
+void dropspool(struct queue *, struct qitem *);
+
+/* local.c */
+int deliver_local(struct qitem *);
+
+/* mail.c */
+void bounce(struct qitem *, const char *);
+int readmail(struct queue *, int, int);
+
+/* util.c */
+const char *hostname(void);
+void setlogident(const char *, ...);
+void errlog(int, const char *, ...);
+void errlogx(int, const char *, ...);
+void set_username(void);
+void deltmp(void);
+int do_timeout(int, int);
+int open_locked(const char *, int, ...);
+char *rfc822date(void);
+int strprefixcmp(const char *, const char *);
+void init_random(void);
+
#endif