summaryrefslogtreecommitdiff
path: root/debian/sensible-mda.c
diff options
context:
space:
mode:
Diffstat (limited to 'debian/sensible-mda.c')
-rw-r--r--debian/sensible-mda.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/sensible-mda.c b/debian/sensible-mda.c
new file mode 100644
index 0000000..e9afa31
--- /dev/null
+++ b/debian/sensible-mda.c
@@ -0,0 +1,62 @@
+/*
+ * sensible-mda.c
+ * Copyright (c) 1998, Johnie Ingram.
+ * Copyright (c) 1998, Richard Nelson <cowboy@debian.org>.
+ * Time-stamp: <1998/06/16 14:28:33 cowboy>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+// TODO: declare -x TCPREMOTEIP="$3"
+
+#define PROCMAIL "/usr/bin/procmail"
+#define DELIVER "/usr/bin/deliver"
+
+static struct stat MDA_stat;
+static int done = 1;
+
+int
+main (int argc, char *argv[])
+{
+
+ if (!stat(PROCMAIL, &MDA_stat)) {
+ if (MDA_stat.st_mode & S_ISUID) {
+ done = 0;
+ execl (PROCMAIL, PROCMAIL, "-t", "-Y", "-f",
+ argv[1], "-d", argv[2], NULL);
+ }
+ else
+ fprintf(stderr, "Ack!?! %s is not setuid!\n", PROCMAIL);
+ }
+
+ if (done && !stat(DELIVER, &MDA_stat)) {
+ if (MDA_stat.st_mode & S_ISUID) {
+ done = 0;
+ execl (DELIVER, DELIVER, "-r", argv[1], argv[2], NULL);
+ }
+ else
+ fprintf(stderr, "Ack!?! %s is not setuid!\n", DELIVER);
+ }
+
+ fprintf (stderr, "Huh? Neither %s nor %s was found (or was suid)!\n",
+ PROCMAIL, DELIVER);
+
+ return (75);
+}