summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorAlexander Pyhalov <apyhalov@gmail.com>2014-09-16 12:37:54 +0400
committerRobert Mustacchi <rm@joyent.com>2014-10-06 09:24:24 -0700
commit287247a826fa2ab8d01f6c8f276d405eb08420f8 (patch)
treecb83a85364f2a33bfafebf64b7f9cf6333fd4901 /usr/src
parent3e0831a90c729a9b8266ce68233ba63a32ffaa4c (diff)
downloadillumos-joyent-287247a826fa2ab8d01f6c8f276d405eb08420f8.tar.gz
5166 sendmail package should be replaceable
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com> Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/Makefile.lint1
-rw-r--r--usr/src/cmd/Makefile1
-rw-r--r--usr/src/cmd/fm/notify/smtp-notify/common/smtp-notify.xml1
-rw-r--r--usr/src/cmd/mailwrapper/Makefile100
-rw-r--r--usr/src/cmd/mailwrapper/THIRDPARTYLICENSE93
-rw-r--r--usr/src/cmd/mailwrapper/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/cmd/mailwrapper/compat.h50
-rw-r--r--usr/src/cmd/mailwrapper/fgetln.c83
-rw-r--r--usr/src/cmd/mailwrapper/fparseln.c210
-rw-r--r--usr/src/cmd/mailwrapper/mailer.conf9
-rw-r--r--usr/src/cmd/mailwrapper/mailwrapper.c169
-rw-r--r--usr/src/cmd/mailwrapper/pathnames.h38
-rw-r--r--usr/src/cmd/mailx/names.c131
-rw-r--r--usr/src/cmd/sendmail/Makefile.cmd8
-rw-r--r--usr/src/cmd/sendmail/aux/Makefile11
-rw-r--r--usr/src/cmd/sendmail/aux/mailq.c2
-rw-r--r--usr/src/cmd/sendmail/src/Makefile6
-rw-r--r--usr/src/cmd/svc/shell/sendmail_include.sh2
-rw-r--r--usr/src/man/man1m/Makefile1
-rw-r--r--usr/src/man/man1m/mailwrapper.1m130
-rw-r--r--usr/src/man/man4/Makefile1
-rw-r--r--usr/src/man/man4/mailer.conf.4107
-rw-r--r--usr/src/pkg/manifests/SUNWcs.mf4
-rw-r--r--usr/src/pkg/manifests/developer-build-onbld.mf2
-rw-r--r--usr/src/pkg/manifests/service-network-smtp-sendmail.mf20
-rw-r--r--usr/src/pkg/manifests/system-network-mailwrapper.mf45
-rw-r--r--usr/src/tools/scripts/hgsetup.sh5
27 files changed, 1146 insertions, 85 deletions
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint
index 5658202a2f..b158a923af 100644
--- a/usr/src/Makefile.lint
+++ b/usr/src/Makefile.lint
@@ -195,6 +195,7 @@ COMMON_SUBDIRS = \
cmd/luxadm \
cmd/lvm \
cmd/machid \
+ cmd/mailwrapper \
cmd/makekey \
cmd/mdb \
cmd/mesg \
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index 5e2b65379b..c59e370d47 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -250,6 +250,7 @@ COMMON_SUBDIRS= \
mach \
machid \
mail \
+ mailwrapper \
mailx \
makekey \
man \
diff --git a/usr/src/cmd/fm/notify/smtp-notify/common/smtp-notify.xml b/usr/src/cmd/fm/notify/smtp-notify/common/smtp-notify.xml
index 4e55e0fd83..4e6437a924 100644
--- a/usr/src/cmd/fm/notify/smtp-notify/common/smtp-notify.xml
+++ b/usr/src/cmd/fm/notify/smtp-notify/common/smtp-notify.xml
@@ -60,7 +60,6 @@
type='service'>
<service_fmri value='svc:/milestone/multi-user:default' />
<service_fmri value='svc:/system/fmd:default' />
- <service_fmri value='svc:/network/sendmail-client:default' />
</dependency>
<exec_method
diff --git a/usr/src/cmd/mailwrapper/Makefile b/usr/src/cmd/mailwrapper/Makefile
new file mode 100644
index 0000000000..0e66a47b93
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/Makefile
@@ -0,0 +1,100 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2014 Alexander Pyhalov
+#
+
+
+LIBPROG= mailwrapper
+
+PROG= $(LIBPROG)
+
+include ../Makefile.cmd
+
+MWOBJS= fgetln.o fparseln.o mailwrapper.o
+
+CLOBBERFILES= $(PROG)
+CLEANFILES= $(MWOBJS)
+
+SRCS= $(MWOBJS:%.o=%.c)
+
+CPROG= mailwrapper
+CPROGSRC= $(CPROG:%=_%.c)
+
+CFS= mailer.conf
+
+ROOTETCFILES=$(CFS:%=$(ROOTETC)/%)
+
+$(ROOTETCFILES) := FILEMODE = 0644
+
+# installed modules
+ROOTLIBPROG= $(LIBPROG:%=$(ROOTLIB)/%)
+
+ROOTSYMLINKS= $(ROOTBIN)/mailq \
+ $(ROOTLIB)/sendmail \
+ $(ROOTUSRSBIN)/newaliases \
+ $(ROOTUSRSBIN)/sendmail
+
+CPPFLAGS = -I. $(CPPFLAGS.master)
+
+LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
+
+# conditional assignments
+#
+all:= TARGET= all
+install:= TARGET= install
+clean:= TARGET= clean
+clobber:= TARGET= clobber
+lint:= TARGET= lint
+
+# install rules
+$(ROOTINC)/% : %
+ $(INS.file)
+
+.KEEP_STATE:
+
+.PARALLEL: $(MWOBJS) $(OBJS)
+
+all: $(PROG)
+
+mailwrapper: $(MWOBJS)
+ $(LINK.c) -o $@ $(MWOBJS) $(LDLIBS)
+ $(POST_PROCESS)
+
+install: all .WAIT $(ROOTLIBPROG) $(ROOTSYMLINKS) $(ROOTETCFILES)
+
+# ROOTSYMLINKS
+#
+$(ROOTBIN)/mailq:
+ $(RM) $@; $(SYMLINK) ../lib/mailwrapper $@
+
+$(ROOTLIB)/sendmail:
+ $(RM) $@; $(SYMLINK) mailwrapper $@
+
+$(ROOTUSRSBIN)/newaliases:
+ $(RM) $@; $(SYMLINK) ../lib/mailwrapper $@
+
+$(ROOTUSRSBIN)/sendmail:
+ $(RM) $@; $(SYMLINK) ../lib/mailwrapper $@
+
+$(ROOTETCMAIL)/%: %
+ $(INS.file)
+
+lint:
+ $(LINT.c) $(SRCS)
+
+clean:
+ $(RM) $(OBJS) $(MWOBJS) mailwrapper
+
+clobber: clean
+ $(RM) $(ROOTSYMLINKS) $(ROOTLIBPROG) $(ROOTETCFILES)
diff --git a/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE b/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE
new file mode 100644
index 0000000000..39fa9c9c5a
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE
@@ -0,0 +1,93 @@
+fgetln.c is provided under the following license
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, 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.
+ */
+fparseln.c is provided under the following license
+/*
+ * Copyright (c) 1997 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+ */
+mailwrapper.c is provided under the following license
+/*
+ * Copyright (c) 1998
+ * Perry E. Metzger. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgment:
+ * This product includes software developed for the NetBSD Project
+ * by Perry E. Metzger.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+ */
+
diff --git a/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE.descrip b/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE.descrip
new file mode 100644
index 0000000000..5d732c483f
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/THIRDPARTYLICENSE.descrip
@@ -0,0 +1 @@
+mailwrapper and BSD compatibilty functions
diff --git a/usr/src/cmd/mailwrapper/compat.h b/usr/src/cmd/mailwrapper/compat.h
new file mode 100644
index 0000000000..d1bcd467c5
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/compat.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1996 Peter Wemm <peter@FreeBSD.org>.
+ * All rights reserved.
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * Portions of this software were developed for the FreeBSD Project by
+ * ThinkSec AS and NAI Labs, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, is permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, 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.
+ */
+
+/* This file contains extracts from FreeBSD libc and libutil headers */
+#ifndef _COMPAT_H
+#define _COMPAT_H
+#include <stdio.h>
+
+#define FPARSELN_UNESCESC 0x01
+#define FPARSELN_UNESCCONT 0x02
+#define FPARSELN_UNESCCOMM 0x04
+#define FPARSELN_UNESCREST 0x08
+#define FPARSELN_UNESCALL 0x0f
+
+char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
+char *fgetln(FILE *, size_t *);
+#endif /* _COMPAT_H */
diff --git a/usr/src/cmd/mailwrapper/fgetln.c b/usr/src/cmd/mailwrapper/fgetln.c
new file mode 100644
index 0000000000..f0af70711a
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/fgetln.c
@@ -0,0 +1,83 @@
+/* $Id$ */
+/* $NetBSD: fgetln.c,v 1.3 2007/08/07 02:06:58 lukem Exp $ */
+
+/*
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, 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.
+ */
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *
+fgetln(FILE *fp, size_t *len)
+{
+ static char *buf = NULL;
+ static size_t bufsiz = 0;
+ char *ptr;
+
+
+ if (buf == NULL) {
+ bufsiz = BUFSIZ;
+ if ((buf = malloc(bufsiz)) == NULL)
+ return (NULL);
+ }
+
+ if (fgets(buf, bufsiz, fp) == NULL)
+ return (NULL);
+
+ *len = 0;
+ while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
+ size_t nbufsiz = bufsiz + BUFSIZ;
+ char *nbuf = realloc(buf, nbufsiz);
+
+ if (nbuf == NULL) {
+ int oerrno = errno;
+ free(buf);
+ errno = oerrno;
+ buf = NULL;
+ return (NULL);
+ } else
+ buf = nbuf;
+
+ *len = bufsiz;
+ if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
+ return (buf);
+
+ bufsiz = nbufsiz;
+ }
+
+ *len = (ptr - buf) + 1;
+ return (buf);
+}
diff --git a/usr/src/cmd/mailwrapper/fparseln.c b/usr/src/cmd/mailwrapper/fparseln.c
new file mode 100644
index 0000000000..147e1d0b76
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/fparseln.c
@@ -0,0 +1,210 @@
+/* $NetBSD: fparseln.c,v 1.9 1999/09/20 04:48:06 lukem Exp $ */
+
+/*
+ * Copyright (c) 1997 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <compat.h>
+
+static int isescaped(const char *, const char *, int);
+
+/*
+ * isescaped():
+ * Return true if the character in *p that belongs to a string
+ * that starts in *sp, is escaped by the escape character esc.
+ */
+static int
+isescaped(const char *sp, const char *p, int esc)
+{
+ const char *cp;
+ size_t ne;
+
+ /* No escape character */
+ if (esc == '\0')
+ return (1);
+
+ /* Count the number of escape characters that precede ours */
+ for (ne = 0, cp = p; --cp >= sp && *cp == esc; ne++)
+ continue;
+
+ /* Return true if odd number of escape characters */
+ return ((ne & 1) != 0);
+}
+
+
+/*
+ * fparseln():
+ * Read a line from a file parsing continuations ending in \
+ * and eliminating trailing newlines, or comments starting with
+ * the comment char.
+ */
+char *
+fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3], int flags)
+{
+ static const char dstr[3] = { '\\', '\\', '#' };
+
+ size_t s, len;
+ char *buf;
+ char *ptr, *cp;
+ int cnt;
+ char esc, con, nl, com;
+
+ len = 0;
+ buf = NULL;
+ cnt = 1;
+
+ if (str == NULL)
+ str = dstr;
+
+ esc = str[0];
+ con = str[1];
+ com = str[2];
+ /*
+ * XXX: it would be cool to be able to specify the newline character,
+ * but unfortunately, fgetln does not let us
+ */
+ nl = '\n';
+
+ while (cnt) {
+ cnt = 0;
+
+ if (lineno)
+ (*lineno)++;
+
+ if ((ptr = fgetln(fp, &s)) == NULL)
+ break;
+
+ if (s && com) { /* Check and eliminate comments */
+ for (cp = ptr; cp < ptr + s; cp++)
+ if (*cp == com && !isescaped(ptr, cp, esc)) {
+ s = cp - ptr;
+ cnt = s == 0 && buf == NULL;
+ break;
+ }
+ }
+
+ if (s && nl) { /* Check and eliminate newlines */
+ cp = &ptr[s - 1];
+
+ if (*cp == nl)
+ s--; /* forget newline */
+ }
+
+ if (s && con) { /* Check and eliminate continuations */
+ cp = &ptr[s - 1];
+
+ if (*cp == con && !isescaped(ptr, cp, esc)) {
+ s--; /* forget escape */
+ cnt = 1;
+ }
+ }
+
+ if (s == 0 && buf != NULL)
+ continue;
+
+ if ((cp = realloc(buf, len + s + 1)) == NULL) {
+ free(buf);
+ return (NULL);
+ }
+ buf = cp;
+
+ (void) memcpy(buf + len, ptr, s);
+ len += s;
+ buf[len] = '\0';
+ }
+
+ if ((flags & FPARSELN_UNESCALL) != 0 && esc && buf != NULL &&
+ strchr(buf, esc) != NULL) {
+ ptr = cp = buf;
+ while (cp[0] != '\0') {
+ int skipesc;
+
+ while (cp[0] != '\0' && cp[0] != esc)
+ *ptr++ = *cp++;
+ if (cp[0] == '\0' || cp[1] == '\0')
+ break;
+
+ skipesc = 0;
+ if (cp[1] == com)
+ skipesc += (flags & FPARSELN_UNESCCOMM);
+ if (cp[1] == con)
+ skipesc += (flags & FPARSELN_UNESCCONT);
+ if (cp[1] == esc)
+ skipesc += (flags & FPARSELN_UNESCESC);
+ if (cp[1] != com && cp[1] != con && cp[1] != esc)
+ skipesc = (flags & FPARSELN_UNESCREST);
+
+ if (skipesc)
+ cp++;
+ else
+ *ptr++ = *cp++;
+ *ptr++ = *cp++;
+ }
+ *ptr = '\0';
+ len = strlen(buf);
+ }
+
+ if (size) {
+ *size = len;
+ }
+ return (buf);
+}
+
+#ifdef TEST
+
+int
+main(int argc, char *argv[])
+{
+ char *ptr;
+ size_t size, line;
+
+ line = 0;
+ while ((ptr = fparseln(stdin, &size, &line, NULL,
+ FPARSELN_UNESCALL)) != NULL) {
+ printf("line %d (%d) |%s|\n", line, size, ptr);
+ }
+ return (0);
+}
+
+/*
+ * # This is a test
+ * line 1
+ * line 2 \
+ * line 3 # Comment
+ * line 4 \# Not comment \\\\
+ *
+ * # And a comment \
+ * line 5 \\\
+ * line 6
+ *
+ */
+
+#endif /* TEST */
diff --git a/usr/src/cmd/mailwrapper/mailer.conf b/usr/src/cmd/mailwrapper/mailer.conf
new file mode 100644
index 0000000000..fc17c7e16d
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/mailer.conf
@@ -0,0 +1,9 @@
+#
+# This file configures mailwrapper(1M).
+# For details see mailer.conf(4).
+# The following configuration is correct for sendmail(1M).
+#
+
+sendmail /usr/lib/smtp/sendmail/sendmail
+newaliases /usr/lib/smtp/sendmail/sendmail
+mailq /usr/lib/smtp/sendmail/mailq
diff --git a/usr/src/cmd/mailwrapper/mailwrapper.c b/usr/src/cmd/mailwrapper/mailwrapper.c
new file mode 100644
index 0000000000..57a3fb0b4d
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/mailwrapper.c
@@ -0,0 +1,169 @@
+/* $OpenBSD: mailwrapper.c,v 1.18 2007/11/06 14:39:19 otto Exp $ */
+/* $NetBSD: mailwrapper.c,v 1.9 2003/03/09 08:10:43 mjl Exp $ */
+
+/*
+ * Copyright (c) 1998
+ * Perry E. Metzger. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgment:
+ * This product includes software developed for the NetBSD Project
+ * by Perry E. Metzger.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+ */
+
+#include <compat.h>
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <syslog.h>
+#include <limits.h>
+
+#include "pathnames.h"
+
+struct arglist {
+ size_t argc, maxc;
+ char **argv;
+};
+
+int main(int, char *[], char *[]);
+
+static void initarg(struct arglist *);
+static void addarg(struct arglist *, const char *);
+
+static void
+initarg(struct arglist *al)
+{
+ al->argc = 0;
+ al->maxc = 10;
+ if ((al->argv = calloc(al->maxc, sizeof (char *))) == NULL)
+ err(EX_TEMPFAIL, "calloc");
+}
+
+static void
+addarg(struct arglist *al, const char *arg)
+{
+
+ if (al->argc == al->maxc) {
+ al->maxc <<= 1;
+ al->argv = realloc(al->argv, al->maxc * sizeof (char *));
+ if (al->argv == NULL)
+ err(EX_TEMPFAIL, "realloc");
+ }
+ if (arg == NULL)
+ al->argv[al->argc++] = NULL;
+ else if ((al->argv[al->argc++] = strdup(arg)) == NULL)
+ err(EX_TEMPFAIL, "strdup");
+}
+
+int
+main(int argc, char *argv[], char *envp[])
+{
+ FILE *config;
+ char *line, *cp, *from, *to, *ap;
+ char progname[PATH_MAX+1];
+ const char *name;
+ size_t len, lineno = 0;
+ int i;
+ struct arglist al;
+
+ /* change __progname to mailwrapper so we get sensible error messages */
+ name = getprogname();
+ if (name) {
+ strncpy(progname, name, sizeof (progname));
+ } else {
+ err(EX_OSERR, "cannot get program name");
+ }
+ setprogname("mailwrapper");
+
+ initarg(&al);
+ addarg(&al, argv[0]);
+
+ if ((config = fopen(_PATH_MAILERCONF, "r")) == NULL) {
+ addarg(&al, NULL);
+ openlog(getprogname(), LOG_PID, LOG_MAIL);
+ syslog(LOG_INFO, "cannot open %s, using %s as default MTA",
+ _PATH_MAILERCONF, _PATH_DEFAULTMTA);
+ closelog();
+ execve(_PATH_DEFAULTMTA, al.argv, envp);
+ err(EX_OSERR, "cannot exec %s", _PATH_DEFAULTMTA);
+ /*NOTREACHED*/
+ }
+
+ for (;;) {
+ if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) {
+ if (feof(config))
+ errx(EX_CONFIG, "no mapping for %s in %s",
+ progname, _PATH_MAILERCONF);
+ err(EX_CONFIG, "cannot parse line %lu",
+ (ulong_t)lineno);
+ }
+
+#define WS " \t\n"
+ cp = line;
+
+ cp += strspn(cp, WS);
+ if (cp[0] == '\0') {
+ /* empty line */
+ free(line);
+ continue;
+ }
+
+ if ((from = strsep(&cp, WS)) == NULL || cp == NULL)
+ goto parse_error;
+
+ cp += strspn(cp, WS);
+
+ if ((to = strsep(&cp, WS)) == NULL)
+ goto parse_error;
+
+ if (strcmp(from, progname) == 0) {
+ for (ap = strsep(&cp, WS); ap != NULL;
+ ap = strsep(&cp, WS)) {
+ if (*ap)
+ addarg(&al, ap);
+ }
+ break;
+ }
+
+ free(line);
+ }
+
+ (void) fclose(config);
+
+ for (i = 1; i < argc; i++)
+ addarg(&al, argv[i]);
+
+ addarg(&al, NULL);
+ execve(to, al.argv, envp);
+ err(EX_OSERR, "cannot exec %s", to);
+ /*NOTREACHED*/
+parse_error:
+ errx(EX_CONFIG, "parse error in %s at line %lu",
+ _PATH_MAILERCONF, (ulong_t)lineno);
+ /*NOTREACHED*/
+ return (0);
+}
diff --git a/usr/src/cmd/mailwrapper/pathnames.h b/usr/src/cmd/mailwrapper/pathnames.h
new file mode 100644
index 0000000000..e5aee8e282
--- /dev/null
+++ b/usr/src/cmd/mailwrapper/pathnames.h
@@ -0,0 +1,38 @@
+/* $FreeBSD$ */
+
+/*
+ * Copyright (c) 1998
+ * Perry E. Metzger. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgment:
+ * This product includes software developed for the NetBSD Project
+ * by Perry E. Metzger.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+ */
+
+#ifndef _PATHNAMES_H
+#define _PATHNAMES_H
+#define _PATH_MAILERCONF "/etc/mailer.conf"
+#define _PATH_DEFAULTMTA "/usr/lib/smtp/sendmail/sendmail"
+#endif /* _PATHNAMES_H */
diff --git a/usr/src/cmd/mailx/names.c b/usr/src/cmd/mailx/names.c
index 0a5cf1d937..7616630f79 100644
--- a/usr/src/cmd/mailx/names.c
+++ b/usr/src/cmd/mailx/names.c
@@ -38,8 +38,6 @@
* contributors.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
@@ -53,8 +51,10 @@
static struct name *nalloc(char str[]);
static int isfileaddr(char *name);
static int lengthof(struct name *name);
-static struct name *gexpand(struct name *nlist, struct grouphead *gh, int metoo, int arg_ntype);
-static char *norm(register char *user, register char *ubuf, int nbangs);
+static struct name *gexpand(struct name *nlist, struct grouphead *gh,
+ int metoo, int arg_ntype);
+static char *norm(register char *user, register char *ubuf,
+ int nbangs);
static struct name *put(struct name *list, struct name *node);
/*
@@ -68,13 +68,13 @@ nalloc(char str[])
{
register struct name *np;
- np = (struct name *) salloc(sizeof *np);
+ np = (struct name *)salloc(sizeof (*np));
np->n_flink = NIL;
np->n_blink = NIL;
np->n_type = -1;
np->n_full = savestr(str);
np->n_name = skin(np->n_full);
- return(np);
+ return (np);
}
/*
@@ -88,10 +88,10 @@ tailof(struct name *name)
np = name;
if (np == NIL)
- return(NIL);
+ return (NIL);
while (np->n_flink != NIL)
np = np->n_flink;
- return(np);
+ return (np);
}
/*
@@ -110,7 +110,7 @@ extract(char line[], int arg_ntype)
int comma;
if (line == NOSTR || strlen(line) == 0)
- return(NIL);
+ return (NIL);
comma = docomma(line);
top = NIL;
np = NIL;
@@ -119,12 +119,12 @@ extract(char line[], int arg_ntype)
if (np != NIL && equal(nbuf, "at")) {
nstrcpy(abuf, sizeof (abuf), nbuf);
if ((cp = yankword(cp, nbuf, sizeof (nbuf),
- comma)) == NOSTR) {
+ comma)) == NOSTR) {
nstrcpy(nbuf, sizeof (nbuf), abuf);
goto normal;
}
snprintf(abuf, sizeof (abuf), "%s@%s", np->n_name,
- nbuf);
+ nbuf);
np->n_name = savestr(abuf);
continue;
}
@@ -138,7 +138,7 @@ normal:
t->n_blink = np;
np = t;
}
- return(top);
+ return (top);
}
/*
@@ -153,28 +153,28 @@ detract(register struct name *np, int ntype)
register struct name *p;
if (np == NIL)
- return(NOSTR);
+ return (NOSTR);
s = 0;
for (p = np; p != NIL; p = p->n_flink) {
- if ((ntype && (p->n_type & GMASK) != ntype)
- || (p->n_type & GDEL))
+ if ((ntype && (p->n_type & GMASK) != ntype) ||
+ (p->n_type & GDEL))
continue;
s += strlen(p->n_full) + 2;
}
if (s == 0)
- return(NOSTR);
+ return (NOSTR);
top = (char *)salloc((unsigned)(++s));
cp = top;
for (p = np; p != NIL; p = p->n_flink) {
- if ((ntype && (p->n_type & GMASK) != ntype)
- || (p->n_type & GDEL))
+ if ((ntype && (p->n_type & GMASK) != ntype) ||
+ (p->n_type & GDEL))
continue;
cp = copy(p->n_full, cp);
*cp++ = ',';
*cp++ = ' ';
}
*cp = 0;
- return(top);
+ return (top);
}
struct name *
@@ -185,7 +185,7 @@ outpre(struct name *to)
for (np = to; np; np = np->n_flink)
if (isfileaddr(np->n_name))
np->n_type |= GDEL;
- return to;
+ return (to);
}
/*
@@ -207,7 +207,7 @@ outof(struct name *names, FILE *fo)
FILE *fout, *fin;
int ispipe;
int nout = 0;
- int fd = 0;
+ int fd = 0;
#ifdef preSVr4
char line[BUFSIZ];
#endif
@@ -229,10 +229,10 @@ outof(struct name *names, FILE *fo)
if (image < 0) {
fd = open(tempEdit, O_CREAT|O_EXCL|O_APPEND|O_WRONLY,
- 0600);
+ 0600);
if ((fd < 0) && (errno == EEXIST)) {
if ((fd = open(tempEdit, O_APPEND|O_WRONLY,
- 0600)) < 0) {
+ 0600)) < 0) {
perror(tempEdit);
senderr++;
goto cant;
@@ -282,9 +282,11 @@ outof(struct name *names, FILE *fo)
dup(image);
close(image);
lseek(0, 0L, 0);
- if ((shell = value("SHELL")) == NOSTR || *shell=='\0')
+ if ((shell = value("SHELL")) == NOSTR ||
+ *shell == '\0')
shell = SHELL;
- (void) execlp(shell, shell, "-c", fname, (char *)0);
+ (void) execlp(shell, shell, "-c", fname,
+ (char *)0);
perror(shell);
exit(1);
break;
@@ -294,8 +296,7 @@ outof(struct name *names, FILE *fo)
senderr++;
goto cant;
}
- }
- else {
+ } else {
if ((fout = fopen(fname, "a")) == NULL) {
perror(fname);
senderr++;
@@ -312,8 +313,8 @@ outof(struct name *names, FILE *fo)
rewind(fin);
#ifdef preSVr4
putc(getc(fin), fout);
- while (fgets(line, sizeof line, fin)) {
- if (!strncmp(line, "From ", 5))
+ while (fgets(line, sizeof (line), fin)) {
+ if (strncmp(line, "From ", 5) == 0)
putc('>', fout);
fputs(line, fout);
}
@@ -361,7 +362,7 @@ cant:
close(image);
image = -1;
}
- return(nout);
+ return (nout);
}
/*
@@ -371,27 +372,27 @@ cant:
* If "fcc" has been unset, then short-circuit those tests, but not
* the +... test.
*/
-static int
+static int
isfileaddr(char *name)
{
register char *cp;
char *fcc = value("fcc");
if (any('@', name))
- return(0);
+ return (0);
if (*name == '+')
- return(1);
+ return (1);
if (fcc == NOSTR)
- return(0);
+ return (0);
for (cp = name; *cp; cp++) {
if (*cp == '.')
continue;
if (any(*cp, metanet))
- return(0);
+ return (0);
if (*cp == '/')
- return(1);
+ return (1);
}
- return(0);
+ return (0);
}
/*
@@ -426,7 +427,7 @@ usermap(struct name *names)
newnames = put(newnames, np);
np = cp;
}
- return(newnames);
+ return (newnames);
}
/*
@@ -448,7 +449,7 @@ gexpand(struct name *nlist, struct grouphead *gh, int metoo, int arg_ntype)
if (depth > MAXEXP) {
printf(gettext("Expanding alias to depth larger than %d\n"),
MAXEXP);
- return(nlist);
+ return (nlist);
}
depth++;
for (gp = gh->g_list; gp != NOGE; gp = gp->ge_link) {
@@ -476,7 +477,7 @@ skip:
nlist = put(nlist, np);
}
depth--;
- return(nlist);
+ return (nlist);
}
/*
@@ -488,7 +489,8 @@ norm(register char *user, register char *ubuf, int nbangs)
register char *cp;
int inubuf = 0;
- while (*user++ == '!');
+ while (*user++ == '!')
+ ;
user--;
if (!strchr(user, '!')) {
snprintf(ubuf, BUFSIZ, "%s!%s", host, user);
@@ -498,7 +500,8 @@ norm(register char *user, register char *ubuf, int nbangs)
if (nbangs) {
cp = user + strlen(user);
while (nbangs--)
- while (cp > user && *--cp != '!');
+ while (cp > user && *--cp != '!')
+ ;
user = (cp > user) ? ++cp : cp;
/*
* Now strip off all Internet-type
@@ -515,18 +518,18 @@ norm(register char *user, register char *ubuf, int nbangs)
*cp = '\0';
}
}
- return user;
+ return (user);
}
/*
* Implement allnet options.
*/
-int
+int
samebody(register char *user, register char *addr, int fuzzy)
{
char ubuf[BUFSIZ], abuf[BUFSIZ];
char *allnet = value("allnet");
- int nbangs = allnet ? !strcmp(allnet, "uucp") ? 2 : 1 : 0;
+ int nbangs = allnet ? (strcmp(allnet, "uucp") == 0) ? 2 : 1 : 0;
if (fuzzy && value("fuzzymatch")) {
int i;
@@ -541,14 +544,14 @@ samebody(register char *user, register char *addr, int fuzzy)
}
user = norm(user, ubuf, nbangs);
addr = norm(addr, abuf, nbangs);
- return strcmp(user, addr) == 0;
+ return (strcmp(user, addr) == 0);
}
/*
* Compute the length of the passed name list and
* return it.
*/
-static int
+static int
lengthof(struct name *name)
{
register struct name *np;
@@ -556,7 +559,7 @@ lengthof(struct name *name)
for (c = 0, np = name; np != NIL; c++, np = np->n_flink)
;
- return(c);
+ return (c);
}
/*
@@ -569,13 +572,13 @@ cat(struct name *n1, struct name *n2)
register struct name *tail;
if (n1 == NIL)
- return(n2);
+ return (n2);
if (n2 == NIL)
- return(n1);
+ return (n1);
tail = tailof(n1);
tail->n_flink = n2;
n2->n_blink = tail;
- return(n1);
+ return (n1);
}
/*
@@ -599,7 +602,7 @@ unpack(struct name *np)
* Compute the number of extra arguments we will need.
* We need at least 2 extra -- one for "mail" and one for
* the terminating 0 pointer.
- * Additional spots may be needed to pass along -r and -f to
+ * Additional spots may be needed to pass along -r and -f to
* the host mailer.
*/
@@ -607,7 +610,6 @@ unpack(struct name *np)
if (rflag != NOSTR)
extra += 2;
-#ifdef SENDMAIL
extra++;
metoo = value("metoo") != NOSTR;
if (metoo)
@@ -617,15 +619,13 @@ unpack(struct name *np)
extra++;
if (hflag)
extra += 2;
-#endif /* SENDMAIL */
- top = (char **) salloc((t + extra) * sizeof (char *));
+ top = (char **)salloc((t + extra) * sizeof (char *));
ap = top;
- *ap++ = "mail";
+ *ap++ = "sendmail";
if (rflag != NOSTR) {
*ap++ = "-r";
*ap++ = rflag;
}
-#ifdef SENDMAIL
*ap++ = "-i";
if (metoo)
*ap++ = "-m";
@@ -636,7 +636,6 @@ unpack(struct name *np)
snprintf(hbuf, sizeof (hbuf), "%d", hflag);
*ap++ = savestr(hbuf);
}
-#endif /* SENDMAIL */
while (n != NIL) {
if (n->n_type & GDEL) {
n = n->n_flink;
@@ -646,7 +645,7 @@ unpack(struct name *np)
n = n->n_flink;
}
*ap = NOSTR;
- return(top);
+ return (top);
}
/*
@@ -655,7 +654,7 @@ unpack(struct name *np)
* selfsent so that we avoid removing his mailbox.
*/
-void
+void
mechk(struct name *names)
{
register struct name *np;
@@ -681,7 +680,7 @@ elide(struct name *names)
struct name *x;
if (names == NIL)
- return(NIL);
+ return (NIL);
newnames = names;
np = names;
np = np->n_flink;
@@ -752,7 +751,7 @@ elide(struct name *names)
t = np;
type = np->n_type;
- while (t->n_flink!=NIL &&
+ while (t->n_flink != NIL &&
strcmp(np->n_name, t->n_flink->n_name) == 0) {
t = t->n_flink;
/* "To" before "Cc" before "Bcc" */
@@ -775,7 +774,7 @@ elide(struct name *names)
np->n_type = type;
np = np->n_flink;
}
- return(newnames);
+ return (newnames);
}
/*
@@ -790,7 +789,7 @@ put(struct name *list, struct name *node)
node->n_blink = NIL;
if (list != NIL)
list->n_blink = node;
- return(node);
+ return (node);
}
@@ -818,7 +817,7 @@ delname(register struct name *np, char name[])
p->n_blink->n_flink = p->n_flink;
p->n_flink->n_blink = p->n_blink;
}
- return(np);
+ return (np);
}
/*
@@ -826,7 +825,7 @@ delname(register struct name *np, char name[])
* list, replacing said value if need be.
*/
-void
+void
mapf(register struct name *np, char *from)
{
register struct name *p;
diff --git a/usr/src/cmd/sendmail/Makefile.cmd b/usr/src/cmd/sendmail/Makefile.cmd
index c06ca1f5c2..52cd520885 100644
--- a/usr/src/cmd/sendmail/Makefile.cmd
+++ b/usr/src/cmd/sendmail/Makefile.cmd
@@ -33,3 +33,11 @@ CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-empty-body
CERRWARN += -_gcc=-Wno-unused-variable
DBMDEF= -DNDBM -DNEWDB -DNIS -DUSERDB -DMAP_REGEX -DLDAPMAP
+
+ROOTLIBSMTPSM = $(ROOTLIB)/smtp/sendmail
+
+$(ROOTLIBSMTPSM):
+ $(INS.dir)
+
+$(ROOTLIBSMTPSM)/%: $(ROOTLIBSMTPSM) %
+ $(INS.file)
diff --git a/usr/src/cmd/sendmail/aux/Makefile b/usr/src/cmd/sendmail/aux/Makefile
index e1e9ac24c5..5e9b873df3 100644
--- a/usr/src/cmd/sendmail/aux/Makefile
+++ b/usr/src/cmd/sendmail/aux/Makefile
@@ -27,12 +27,14 @@
include ../../Makefile.cmd
include ../Makefile.cmd
-PROG= mailstats mconnect vacation mailcompat praliases mailq
+PROG= mailstats mconnect vacation mailcompat praliases
LIBPROG= mail.local smrsh
USRSBINPROG= etrn makemap editmap
+LIBSMTPSMPROG= mailq
+
# $(PROG) by default
CLOBBERFILES= $(LIBPROG) $(USRSBINPROG)
@@ -51,7 +53,7 @@ mconnect := LDLIBS += -lsocket -lnsl
praliases := LDLIBS += -lldap
smrsh := LDLIBS += -lldap
vacation := LDLIBS += -lldap
-$(ROOTBIN)/mailq := FILEMODE = 4555
+$(ROOTLIBSMTPSM)/mailq := FILEMODE = 4555
INCPATH= -I../src -I../db -I../include
@@ -67,7 +69,7 @@ LDFLAGS += $(MAPFILE.NGB:%=-M%)
.KEEP_STATE:
-all: $(PROG) $(LIBPROG) $(USRSBINPROG)
+all: $(PROG) $(LIBSMTPSMPROG) $(LIBPROG) $(USRSBINPROG)
convtime.o: ../src/convtime.c
$(COMPILE.c) ../src/convtime.c
@@ -111,7 +113,8 @@ mailstats: mailstats.o ../libsmutil/libsmutil.a ../libsm/libsm.a
$(POST_PROCESS)
install: all $(ROOTPROG) $(ROOTLIB)/mail.local $(ROOTLIB)/smrsh \
- $(ROOTUSRSBIN)/makemap $(ROOTUSRSBIN)/etrn $(ROOTUSRSBIN)/editmap
+ $(ROOTLIBSMTPSM)/mailq $(ROOTUSRSBIN)/makemap \
+ $(ROOTUSRSBIN)/etrn $(ROOTUSRSBIN)/editmap
clean:
$(RM) $(OBJS) *.o
diff --git a/usr/src/cmd/sendmail/aux/mailq.c b/usr/src/cmd/sendmail/aux/mailq.c
index 6f95cd8dc7..4fadd88ff0 100644
--- a/usr/src/cmd/sendmail/aux/mailq.c
+++ b/usr/src/cmd/sendmail/aux/mailq.c
@@ -34,7 +34,7 @@
#include <errno.h>
#include <auth_list.h>
-#define _PATH_SENDMAIL_BIN "/usr/lib/sendmail"
+#define _PATH_SENDMAIL_BIN "/usr/lib/smtp/sendmail/sendmail"
int
main(int argc, char *argv[], char *envp[])
diff --git a/usr/src/cmd/sendmail/src/Makefile b/usr/src/cmd/sendmail/src/Makefile
index 92223ef71a..14793754fd 100644
--- a/usr/src/cmd/sendmail/src/Makefile
+++ b/usr/src/cmd/sendmail/src/Makefile
@@ -59,7 +59,7 @@ CPPFLAGS = $(INCPATH) $(ENVDEF) $(SUNENVDEF) $(DBMDEF) $(CPPFLAGS.sm)
FILEMODE= 2555
-ROOTSYMLINKS= $(ROOTUSRSBIN)/newaliases $(ROOTUSRSBIN)/sendmail
+ROOTSYMLINKS= $(ROOTLIBSMTPSM)/newaliases
# build rule
#
@@ -74,10 +74,10 @@ $(PROG): $(OBJS) $(MAPFILES) \
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)
-install: $(ROOTLIBPROG) $(ROOTSYMLINKS)
+install: $(ROOTLIBSMTPSM)/sendmail $(ROOTSYMLINKS)
$(ROOTSYMLINKS):
- $(RM) $@; $(SYMLINK) ../lib/sendmail $@
+ $(RM) $@; $(SYMLINK) sendmail $@
clean:
$(RM) $(PROG) $(OBJS)
diff --git a/usr/src/cmd/svc/shell/sendmail_include.sh b/usr/src/cmd/svc/shell/sendmail_include.sh
index 31b527825e..f10b2fff96 100644
--- a/usr/src/cmd/svc/shell/sendmail_include.sh
+++ b/usr/src/cmd/svc/shell/sendmail_include.sh
@@ -23,7 +23,7 @@
# Use is subject to license terms.
DEFAULT_FILE="/etc/default/sendmail"
-SENDMAIL="/usr/lib/sendmail"
+SENDMAIL="/usr/lib/smtp/sendmail/sendmail"
PATH="/usr/bin:/usr/sbin:/usr/ccs/bin"
export PATH
diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile
index 56fc2ebb09..4d7a492855 100644
--- a/usr/src/man/man1m/Makefile
+++ b/usr/src/man/man1m/Makefile
@@ -296,6 +296,7 @@ _MANFILES= 6to4relay.1m \
lpusers.1m \
luxadm.1m \
mail.local.1m \
+ mailwrapper.1m \
makedbm.1m \
makemap.1m \
mdmonitord.1m \
diff --git a/usr/src/man/man1m/mailwrapper.1m b/usr/src/man/man1m/mailwrapper.1m
new file mode 100644
index 0000000000..90cc4ea26a
--- /dev/null
+++ b/usr/src/man/man1m/mailwrapper.1m
@@ -0,0 +1,130 @@
+.\" $OpenBSD: mailwrapper.8,v 1.10 2009/02/07 16:58:23 martynas Exp $
+.\" $NetBSD: mailwrapper.8,v 1.11 2002/02/08 01:38:50 ross Exp $
+.\" $FreeBSD: releng/9.1/usr.sbin/mailwrapper/mailwrapper.8 205938 2010-03-30 21:54:25Z delphij $
+.\"
+.\" Copyright (c) 1998
+.\" Perry E. Metzger. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgment:
+.\" This product includes software developed for the NetBSD Project
+.\" by Perry E. Metzger.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+.\"
+.Dd August 7, 2006
+.Dt MAILWRAPPER 1M
+.Os
+.Sh NAME
+.Nm \fB/usr/lib/mailwrapper\fR
+.Nd invoke appropriate MTA software based on configuration file
+.Sh SYNOPSIS
+Special.
+See below.
+.Sh DESCRIPTION
+At one time, the only Mail Transfer Agent (MTA) software easily available
+was
+.Xr sendmail 1M .
+As a result of this, most Mail User Agents (MUAs) such as
+.Xr mail 1
+had the path and calling conventions expected by
+.Xr sendmail 1M
+compiled in.
+.Pp
+Times have changed, however.
+On a modern
+.Ux
+system, the administrator may wish to use one of several
+available MTAs.
+.Pp
+It would be difficult to modify all MUA software typically available
+on a system, so most of the authors of alternative MTAs have written
+their front end message submission programs so that they use the same
+calling conventions as
+.Xr sendmail 1M
+and may be put into place instead of
+.Xr sendmail 1M
+in
+.Pa /usr/lib/sendmail .
+.Pp
+.Xr sendmail 1M
+also typically has aliases named
+.Xr mailq 1
+and
+.Xr newaliases 1M
+linked to it.
+The program knows to behave differently when its
+.Va argv[0]
+is
+.Dq mailq
+or
+.Dq newaliases
+and behaves appropriately.
+Typically, replacement MTAs provide similar
+functionality, either through a program that also switches behavior
+based on calling name, or through a set of programs that provide
+similar functionality.
+.Pp
+Although having drop-in replacements for
+.Xr sendmail 1M
+helps in installing alternative MTAs, it essentially makes the
+configuration of the system depend on hand installing new programs in
+.Pa /usr .
+This leads to configuration problems for many administrators, since
+they may wish to install a new MTA without altering the system
+provided
+.Pa /usr .
+(This may be, for example, to avoid having upgrade problems when a new
+version of the system is installed over the old.)
+They may also have a shared
+.Pa /usr
+among several
+machines, and may wish to avoid placing implicit configuration
+information in a read-only
+.Pa /usr .
+.Pp
+The
+.Nm
+utility is designed to replace
+.Pa /usr/lib/sendmail
+and to invoke an appropriate MTA instead of
+.Xr sendmail 1M
+based on configuration information placed in
+.Pa /etc/mailer.conf .
+This permits the administrator to configure which MTA is to be invoked on
+the system at run time.
+.Pp
+Other configuration files may need to be altered when replacing
+.Xr sendmail 1M .
+.Sh EXIT STATUS
+.Ex -std
+.Sh DIAGNOSTICS
+The
+.Nm
+will print a diagnostic if its configuration file is missing or malformed,
+or does not contain a mapping for the name under which it was invoked.
+.Sh SEE ALSO
+.Xr mail 1 ,
+.Xr mailq 1 ,
+.Xr newaliases 1M ,
+.Xr mailer.conf 4 ,
+.Xr sendmail 1M
diff --git a/usr/src/man/man4/Makefile b/usr/src/man/man4/Makefile
index cb69ee7dad..62543e8913 100644
--- a/usr/src/man/man4/Makefile
+++ b/usr/src/man/man4/Makefile
@@ -103,6 +103,7 @@ _MANFILES= Intro.4 \
logindevperm.4 \
loginlog.4 \
magic.4 \
+ mailer.conf.4 \
md.tab.4 \
mddb.cf.4 \
mech.4 \
diff --git a/usr/src/man/man4/mailer.conf.4 b/usr/src/man/man4/mailer.conf.4
new file mode 100644
index 0000000000..dcf52807bf
--- /dev/null
+++ b/usr/src/man/man4/mailer.conf.4
@@ -0,0 +1,107 @@
+.\" $NetBSD: mailer.conf.5,v 1.2 1999/05/29 18:18:30 christos Exp $
+.\"
+.\" Copyright (c) 1998
+.\" Perry E. Metzger. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgment:
+.\" This product includes software developed for the NetBSD Project
+.\" by Perry E. Metzger.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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.
+.\"
+.\" $FreeBSD: releng/9.1/share/man/man5/mailer.conf.5 213609 2010-10-08 20:13:12Z markm $
+.\"
+.Dd October 8, 2010
+.Dt MAILER.CONF 4
+.Os
+.Sh NAME
+.Nm mailer.conf
+.Nd configuration file for
+.Xr mailwrapper 1M
+.Sh DESCRIPTION
+The file
+.Pa /etc/mailer.conf
+contains a series of lines of the form
+.Pp
+.Ar name
+.Ar program
+.Op Ar arguments ...
+.Pp
+The first word of each line is the
+.Ar name
+of a program invoking
+.Xr mailwrapper 1M .
+(For example, on a typical system
+.Pa /usr/lib/sendmail
+would be a symbolic link to
+.Xr mailwrapper 1M ,
+as would
+.Xr newaliases 1M
+and
+.Xr mailq 1 .
+Thus,
+.Ar name
+might be
+.Dq Li sendmail
+or
+.Dq Li newaliases
+etc.)
+.Pp
+The second word of each line is the name of the
+.Ar program
+to actually execute when the first name is invoked.
+.Pp
+The further
+.Ar arguments ,
+if any, are passed to the
+.Ar program ,
+followed by the arguments
+.Xr mailwrapper 1M
+was called with.
+.Pp
+The file may also contain comment lines, denoted by a
+.Ql #
+mark in the first column of any line.
+.Sh FILES
+/etc/mail/mailer.conf
+.Sh EXAMPLES
+This example shows how to set up
+.Nm
+to invoke the traditional
+.Xr sendmail 1M
+program:
+.Bd -literal -offset indent
+# Execute the "real" sendmail program located in
+# /usr/lib/smtp/sendmail/sendmail
+sendmail /usr/lib/smtp/sendmail/sendmail
+mailq /usr/lib/smtp/sendmail/sendmail
+newaliases /usr/lib/smtp/sendmail/sendmail
+.Ed
+.Sh SEE ALSO
+.Xr mail 1 ,
+.Xr mailq 1 ,
+.Xr newaliases 1M ,
+.Xr mailwrapper 1M ,
+.Xr sendmail 1M
+.Sh AUTHORS
+.An Perry E. Metzger Aq perry@piermont.com
diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf
index 14f457a1d0..1c688a8739 100644
--- a/usr/src/pkg/manifests/SUNWcs.mf
+++ b/usr/src/pkg/manifests/SUNWcs.mf
@@ -1900,3 +1900,7 @@ depend fmri=system/data/terminfo type=require
# Depend on zoneinfo data.
#
depend fmri=system/data/zoneinfo type=require
+#
+# The mailx binary calls /usr/lib/sendmail provided by mailwrapper
+#
+depend fmri=system/network/mailwrapper type=require
diff --git a/usr/src/pkg/manifests/developer-build-onbld.mf b/usr/src/pkg/manifests/developer-build-onbld.mf
index a3c825732e..eda7320511 100644
--- a/usr/src/pkg/manifests/developer-build-onbld.mf
+++ b/usr/src/pkg/manifests/developer-build-onbld.mf
@@ -228,7 +228,5 @@ link path=opt/onbld/lib/python target=python2.6
link path=opt/onbld/man/man1/git-nits.1 target=git-pbchk.1
# webrev(1) requires ps2pdf
depend fmri=print/filter/ghostscript type=require
-# hgsetup(1) uses check-hostname(1) and nightly sendmail(1M)
-depend fmri=service/network/smtp/sendmail type=require
# nightly(1) uses wget
depend fmri=web/wget type=require
diff --git a/usr/src/pkg/manifests/service-network-smtp-sendmail.mf b/usr/src/pkg/manifests/service-network-smtp-sendmail.mf
index 436742d3e6..6862d415ed 100644
--- a/usr/src/pkg/manifests/service-network-smtp-sendmail.mf
+++ b/usr/src/pkg/manifests/service-network-smtp-sendmail.mf
@@ -56,6 +56,8 @@ dir path=usr/lib/help
dir path=usr/lib/help/auths
dir path=usr/lib/help/auths/locale
dir path=usr/lib/help/auths/locale/C
+dir path=usr/lib/smtp
+dir path=usr/lib/smtp/sendmail
dir path=usr/sbin
dir path=usr/share/man
dir path=usr/share/man/man1
@@ -167,7 +169,6 @@ file path=lib/svc/method/sendmail-client mode=0555
file path=lib/svc/method/smtp-sendmail mode=0555
file path=lib/svc/share/sendmail_include.sh mode=0444
file path=usr/bin/mailcompat mode=0555
-file path=usr/bin/mailq mode=4555
file path=usr/bin/mailstats mode=0555
file path=usr/bin/mconnect mode=0555
file path=usr/bin/praliases mode=0555
@@ -181,8 +182,9 @@ file path=usr/lib/libmilter.so.1
file path=usr/lib/llib-lmilter
file path=usr/lib/llib-lmilter.ln
file path=usr/lib/mail.local mode=0555
-file path=usr/lib/sendmail group=smmsp mode=2555
file path=usr/lib/smrsh mode=0555
+file path=usr/lib/smtp/sendmail/mailq mode=4555
+file path=usr/lib/smtp/sendmail/sendmail group=smmsp mode=2555
file path=usr/sbin/check-hostname group=mail mode=0555
file path=usr/sbin/check-permissions group=mail mode=0555
file path=usr/sbin/editmap mode=0555
@@ -212,7 +214,8 @@ license cr_Sun license=cr_Sun
license lic_CDDL license=lic_CDDL
license usr/src/cmd/sendmail/THIRDPARTYLICENSE \
license=usr/src/cmd/sendmail/THIRDPARTYLICENSE
-link path=etc/aliases target=./mail/aliases
+link path=etc/aliases mediator=mta mediator-implementation=sendmail \
+ target=./mail/aliases
link path=etc/mail/cf/cf/main.cf target=sendmail.cf
link path=etc/mail/cf/cf/main.mc target=sendmail.mc
link path=etc/mail/cf/cf/subsidiary.cf target=sendmail.cf
@@ -224,10 +227,17 @@ link path=etc/mail/cf/sh/check-permissions \
link path=etc/mail/main.cf target=sendmail.cf
link path=etc/mail/sendmail.hf target=helpfile
link path=etc/mail/subsidiary.cf target=sendmail.cf
+link path=usr/bin/mailq mediator=mta mediator-implementation=sendmail \
+ target=../lib/smtp/sendmail/mailq
link path=usr/lib/libmilter.so target=libmilter.so.1
link path=usr/lib/mail target=../../etc/mail/cf
-link path=usr/sbin/newaliases target=../lib/sendmail
-link path=usr/sbin/sendmail target=../lib/sendmail
+link path=usr/lib/sendmail mediator=mta mediator-implementation=sendmail \
+ target=../lib/smtp/sendmail/sendmail
+link path=usr/lib/smtp/sendmail/newaliases target=sendmail
+link path=usr/sbin/newaliases mediator=mta mediator-implementation=sendmail \
+ target=../lib/smtp/sendmail/newaliases
+link path=usr/sbin/sendmail mediator=mta mediator-implementation=sendmail \
+ target=../lib/smtp/sendmail/sendmail
link path=usr/share/man/man4/addresses.4 target=aliases.4
link path=usr/share/man/man4/forward.4 target=aliases.4
link path=usr/share/man/man4/sendmail.cf.4 target=sendmail.4
diff --git a/usr/src/pkg/manifests/system-network-mailwrapper.mf b/usr/src/pkg/manifests/system-network-mailwrapper.mf
new file mode 100644
index 0000000000..fa855da7e0
--- /dev/null
+++ b/usr/src/pkg/manifests/system-network-mailwrapper.mf
@@ -0,0 +1,45 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet
+# at http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2014, Alexander Pyhalov
+#
+
+set name=pkg.fmri value=pkg:/system/network/mailwrapper@$(PKGVERS)
+set name=pkg.description \
+ value="utility to invoke appropriate MTA software based on configuration file"
+set name=pkg.summary value=mailwrapper
+set name=info.classification \
+ value="org.opensolaris.category.2008:System/Administration and Configuration"
+set name=variant.arch value=$(ARCH)
+dir path=etc group=sys
+dir path=etc/mail group=mail
+dir path=usr/bin
+dir path=usr/lib
+dir path=usr/sbin
+dir path=usr/share/man
+dir path=usr/share/man/man1m
+dir path=usr/share/man/man4
+file path=etc/mailer.conf group=sys preserve=true
+file path=usr/lib/mailwrapper mode=0555
+file path=usr/share/man/man1m/mailwrapper.1m
+file path=usr/share/man/man4/mailer.conf.4
+license usr/src/cmd/mailwrapper/THIRDPARTYLICENSE \
+ license=usr/src/cmd/mailwrapper/THIRDPARTYLICENSE
+link path=usr/bin/mailq mediator=mta mediator-implementation=mailwrapper \
+ target=../lib/mailwrapper
+link path=usr/lib/sendmail mediator=mta mediator-implementation=mailwrapper \
+ target=mailwrapper
+link path=usr/sbin/newaliases mediator=mta mediator-implementation=mailwrapper \
+ target=../lib/mailwrapper
+link path=usr/sbin/sendmail mediator=mta mediator-implementation=mailwrapper \
+ target=../lib/mailwrapper
+depend fmri=service/network/smtp/sendmail type=require
diff --git a/usr/src/tools/scripts/hgsetup.sh b/usr/src/tools/scripts/hgsetup.sh
index 282a748a00..ba087a9c76 100644
--- a/usr/src/tools/scripts/hgsetup.sh
+++ b/usr/src/tools/scripts/hgsetup.sh
@@ -122,8 +122,9 @@ fi
if [[ -z $email ]]; then
my_id=$(id -un)
- my_checkhostname=$(check-hostname)
- my_fqhn=${my_checkhostname##* }
+ my_hostname=$(hostname)
+ possible_fqhns=$(getent hosts $my_hostname | cut -f 2-)
+ my_fqhn=`for i in $possible_fqhns; do case $i in *.*) echo $i; break;; esac; done`
email="$my_id@$my_fqhn"
echo "No e-mail address provided, defaulting to $email"
fi