diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2017-08-09 07:56:11 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2017-08-09 07:56:11 +0000 |
commit | e9c2dd6da6169a29672ab1956e1b76b0e7677758 (patch) | |
tree | f34df0705e03f4ffee6fc646afb3c1ebc510a640 /usr.sbin/smtpd | |
parent | 2a3522c15208ba735224da4aebebef8a1beda545 (diff) |
add mail.mda MDA in charge of running a third-party MDA, not linked yet
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/mail.mda.8 | 35 | ||||
-rw-r--r-- | usr.sbin/smtpd/mail.mda.c | 55 | ||||
-rw-r--r-- | usr.sbin/smtpd/mail/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/smtpd/mail/mail.mda/Makefile | 21 |
4 files changed, 113 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/mail.mda.8 b/usr.sbin/smtpd/mail.mda.8 new file mode 100644 index 00000000000..61fed7333e1 --- /dev/null +++ b/usr.sbin/smtpd/mail.mda.8 @@ -0,0 +1,35 @@ +.\" $OpenBSD: mail.mda.8,v 1.1 2017/08/09 07:56:10 gilles Exp $ +.\" +.\" Copyright (c) 2017 Gilles Chehade <gilles@poolp.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: August 9 2017 $ +.Dt MAIL.MDA 8 +.Os +.Sh NAME +.Nm mail.mda +.Nd deliver mail to a program +.Sh SYNOPSIS +.Nm mail.mda +.Ar program +.Sh DESCRIPTION +.Nm +executes the program and its parameters. +The program must read from the standard input up to an end-of-file +and acknowledge delivery success or failure with its exit status. +.Sh EXIT STATUS +.Ex -std mail.mda +.Sh SEE ALSO +.Xr mail 1 , +.Xr smtpd 8 diff --git a/usr.sbin/smtpd/mail.mda.c b/usr.sbin/smtpd/mail.mda.c new file mode 100644 index 00000000000..6853b0409ca --- /dev/null +++ b/usr.sbin/smtpd/mail.mda.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017 Gilles Chehade <gilles@poolp.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/types.h> +#include <sys/stat.h> + +#include <ctype.h> +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <netdb.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +extern char **environ; + +int +main(int argc, char *argv[]) +{ + int ch; + + if (! geteuid()) + errx(1, "mail.mda: may not be executed as root"); + + while ((ch = getopt(argc, argv, "")) != -1) { + switch (ch) { + default: + break; + } + } + argc -= optind; + argv += optind; + + if (argc == 0) + errx(1, "mail.mda: command required"); + + execve(argv[0], argv, environ); + err(1, NULL); +} diff --git a/usr.sbin/smtpd/mail/Makefile b/usr.sbin/smtpd/mail/Makefile index e83da45179a..78e46ff4614 100644 --- a/usr.sbin/smtpd/mail/Makefile +++ b/usr.sbin/smtpd/mail/Makefile @@ -1,9 +1,10 @@ -# $OpenBSD: Makefile,v 1.3 2017/02/14 16:48:30 gilles Exp $ +# $OpenBSD: Makefile,v 1.4 2017/08/09 07:56:10 gilles Exp $ .include <bsd.own.mk> SUBDIR = mail.lmtp SUBDIR+= mail.file SUBDIR+= mail.maildir +SUBDIR+= mail.mda .include <bsd.subdir.mk> diff --git a/usr.sbin/smtpd/mail/mail.mda/Makefile b/usr.sbin/smtpd/mail/mail.mda/Makefile new file mode 100644 index 00000000000..5f28c4305e0 --- /dev/null +++ b/usr.sbin/smtpd/mail/mail.mda/Makefile @@ -0,0 +1,21 @@ +.PATH: ${.CURDIR}/../.. + +PROG= mail.mda +BINOWN= root +BINGRP= wheel + +BINMODE?=0555 + +BINDIR= /usr/libexec +MAN= mail.mda.8 + +CFLAGS+= -fstack-protector-all +CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes +CFLAGS+= -Wmissing-declarations +CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual +CFLAGS+= -Wsign-compare +CFLAGS+= -Werror-implicit-function-declaration + +SRCS= mail.mda.c + +.include <bsd.prog.mk> |