summaryrefslogtreecommitdiff
path: root/praliases
diff options
context:
space:
mode:
Diffstat (limited to 'praliases')
-rw-r--r--praliases/Makefile9
-rw-r--r--praliases/Makefile.dist85
-rw-r--r--praliases/praliases.027
-rw-r--r--praliases/praliases.841
-rw-r--r--praliases/praliases.c138
5 files changed, 300 insertions, 0 deletions
diff --git a/praliases/Makefile b/praliases/Makefile
new file mode 100644
index 0000000..4285a5b
--- /dev/null
+++ b/praliases/Makefile
@@ -0,0 +1,9 @@
+# @(#)Makefile 8.2 (Berkeley) 9/21/96
+
+PROG= praliases
+MAN8= praliases.0
+CFLAGS+=-I${.CURDIR}/../src
+DPADD= ${LIBDBM}
+
+.include "../../Makefile.inc"
+.include <bsd.prog.mk>
diff --git a/praliases/Makefile.dist b/praliases/Makefile.dist
new file mode 100644
index 0000000..093f6ab
--- /dev/null
+++ b/praliases/Makefile.dist
@@ -0,0 +1,85 @@
+#
+# This Makefile is designed to work on the old "make" program. It does
+# not use the obj subdirectory. It also does not install documentation
+# automatically -- think of it as a quick start for sites that have the
+# old make program (I recommend that you get and port the new make if you
+# are going to be doing any signficant work on sendmail).
+#
+# @(#)Makefile.dist 8.2 (Berkeley) 9/21/96
+#
+
+# use O=-O (usual) or O=-g (debugging)
+O= -O
+
+# location of sendmail source directory
+SRCDIR= ../src
+
+# define the database mechanisms available for map & alias lookups:
+# -DNDBM -- use new DBM
+# -DNEWDB -- use new Berkeley DB
+# The really old (V7) DBM library is no longer supported.
+#
+DBMDEF= -DNDBM -DNEWDB
+
+# environment definitions (e.g., -D_AIX3)
+ENVDEF=
+
+# see also conf.h for additional compilation flags
+
+# include directories
+INCDIRS=-I${SRCDIR} -I/usr/sww/include/db
+
+# loader options
+LDOPTS=
+
+# library directories
+LIBDIRS=-L/usr/sww/lib
+
+# libraries required on your system
+LIBS= -ldb -ldbm
+
+# location of praliases binary (usually /usr/sbin or /usr/etc)
+BINDIR= ${DESTDIR}/usr/sbin
+
+# additional .o files needed
+OBJADD=
+
+################### end of user configuration flags ######################
+
+CFLAGS= -I. $O ${INCDIRS} ${DBMDEF} ${ENVDEF}
+
+OBJS= praliases.o ${OBJADD}
+
+LINKS= ${DESTDIR}/usr/ucb/newaliases ${DESTDIR}/usr/ucb/mailq
+BINOWN= bin
+BINGRP= bin
+BINMODE=555
+
+ALL= praliases praliases.0
+
+all: ${ALL}
+
+praliases: ${BEFORE} ${OBJS}
+ ${CC} -o praliases ${LDOPTS} ${OBJS} ${LIBDIRS} ${LIBS}
+
+#NROFF= nroff -h
+NROFF= groff -Tascii
+MANDOC= -mandoc
+
+praliases.0: praliases.8
+ ${NROFF} ${MANDOC} praliases.8 > praliases.0
+
+install: install-praliases install-docs
+
+install-praliases: praliases
+ install -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} praliases ${BINDIR}
+
+# doesn't actually install them -- you may want to install pre-nroff versions
+install-docs: praliases.0
+
+clean:
+ rm -f ${OBJS} praliases praliases.0
+
+# dependencies
+# gross overkill, and yet still not quite enough....
+${OBJS}: ${SRCDIR}/conf.h
diff --git a/praliases/praliases.0 b/praliases/praliases.0
new file mode 100644
index 0000000..6b53e1d
--- /dev/null
+++ b/praliases/praliases.0
@@ -0,0 +1,27 @@
+PRALIASES(1) BSD Reference Manual PRALIASES(1)
+
+NNAAMMEE
+ pprraalliiaasseess - display system mail aliases
+
+SSYYNNOOPPSSIISS
+ pprraalliiaasseess [--ff _f_i_l_e]
+
+DDEESSCCRRIIPPTTIIOONN
+ The pprraalliiaasseess utility displays the current system aliases, one per line,
+ in no particular order.
+
+ The options are as follows:
+
+ --ff Read the specified file instead of the default sseennddmmaaiill system
+ aliases file.
+
+ The pprraalliiaasseess utility exits 0 on success, and >0 if an error occurs.
+
+FFIILLEESS
+ /etc/aliases The default sseennddmmaaiill system aliases file.
+ /etc/aliases.db The database version of the _/_e_t_c_/_a_l_i_a_s_e_s file.
+
+SSEEEE AALLSSOO
+ mailq(1), sendmail(8)
+
+3rd Berkeley Distribution April 25, 1996 1
diff --git a/praliases/praliases.8 b/praliases/praliases.8
new file mode 100644
index 0000000..46082ba
--- /dev/null
+++ b/praliases/praliases.8
@@ -0,0 +1,41 @@
+.\" @(#)praliases.8 8.1 (Berkeley) 9/21/96
+.Dd April 25, 1996
+.Dt PRALIASES 1
+.Os BSD 3
+.Sh NAME
+.Nm praliases
+.Nd display system mail aliases
+.Sh SYNOPSIS
+.Nm praliases
+.Op Fl f Ar file
+.Sh DESCRIPTION
+The
+.Nm praliases
+utility displays the current system aliases,
+one per line, in no particular order.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl f
+Read the specified file instead of the default
+.Nm sendmail
+system aliases file.
+.El
+.Pp
+The
+.Nm praliases
+utility exits 0 on success, and >0 if an error occurs.
+.Sh FILES
+.Bl -tag -width /var/log/sendmail.stXX -compact
+.It Pa /etc/aliases
+The default
+.Nm sendmail
+system aliases file.
+.It Pa /etc/aliases.db
+The database version of the
+.Pa /etc/aliases
+file.
+.El
+.Sh SEE ALSO
+.Xr mailq 1 ,
+.Xr sendmail 8
diff --git a/praliases/praliases.c b/praliases/praliases.c
new file mode 100644
index 0000000..361edac
--- /dev/null
+++ b/praliases/praliases.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1983 Eric P. Allman
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)praliases.c 8.5 (Berkeley) 5/28/97";
+#endif /* not lint */
+
+#include <ndbm.h>
+#define NOT_SENDMAIL
+#include <sendmail.h>
+#ifdef NEWDB
+#include <db.h>
+#endif
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ extern char *optarg;
+ extern int optind;
+ DBM *dbp;
+ datum content, key;
+ char *filename;
+ int ch;
+#ifdef NEWDB
+ const DB *db;
+ DBT newdbkey, newdbcontent;
+ char buf[MAXNAME];
+#endif
+
+ filename = "/etc/aliases";
+ while ((ch = getopt(argc, argv, "f:")) != EOF)
+ switch((char)ch) {
+ case 'f':
+ filename = optarg;
+ break;
+ case '?':
+ default:
+ (void)fprintf(stderr, "usage: praliases [-f file]\n");
+ exit(EX_USAGE);
+ }
+ argc -= optind;
+ argv += optind;
+
+#ifdef NEWDB
+ if (strlen(filename) + 4 >= sizeof buf)
+ {
+ fprintf(stderr, "Alias filename too long: %.30s...\n", filename);
+ exit(EX_USAGE);
+ }
+ (void) strcpy(buf, filename);
+ (void) strcat(buf, ".db");
+ if (db = dbopen(buf, O_RDONLY, 0444 , DB_HASH, NULL)) {
+ if (!argc) {
+ while(!db->seq(db, &newdbkey, &newdbcontent, R_NEXT))
+ printf("%.*s:%.*s\n",
+ newdbkey.size, newdbkey.data,
+ newdbcontent.size, newdbcontent.data);
+ }
+ else for (; *argv; ++argv) {
+ newdbkey.data = *argv;
+ newdbkey.size = strlen(*argv) + 1;
+ if (!db->get(db, &newdbkey, &newdbcontent, 0))
+ printf("%s:%.*s\n", newdbkey.data,
+ newdbcontent.size, newdbcontent.data);
+ else
+ printf("%s: No such key\n",
+ newdbkey.data);
+ }
+ }
+ else {
+#endif
+ if ((dbp = dbm_open(filename, O_RDONLY, 0)) == NULL) {
+ (void)fprintf(stderr,
+ "praliases: %s: %s\n", filename, strerror(errno));
+ exit(EX_OSFILE);
+ }
+ if (!argc)
+ for (key = dbm_firstkey(dbp);
+ key.dptr != NULL; key = dbm_nextkey(dbp)) {
+ content = dbm_fetch(dbp, key);
+ (void)printf("%.*s:%.*s\n",
+ key.dsize, key.dptr,
+ content.dsize, content.dptr);
+ }
+ else for (; *argv; ++argv) {
+ key.dptr = *argv;
+ key.dsize = strlen(*argv) + 1;
+ content = dbm_fetch(dbp, key);
+ if (!content.dptr)
+ (void)printf("%s: No such key\n", key.dptr);
+ else
+ (void)printf("%s:%.*s\n", key.dptr,
+ content.dsize, content.dptr);
+ }
+#ifdef NEWDB
+ }
+#endif
+ exit(EX_OK);
+}