summaryrefslogtreecommitdiffstats
path: root/libexec/bugfiler
diff options
context:
space:
mode:
authorrgrimes <rgrimes@FreeBSD.org>1994-05-27 12:39:25 +0000
committerrgrimes <rgrimes@FreeBSD.org>1994-05-27 12:39:25 +0000
commit7d07d2de2f52d4e2eba169e5563165309a795128 (patch)
treec3590f60f61233b4a571cfe3bfc08f6ab6591c88 /libexec/bugfiler
parentf9ab90d9d6d02989a075d0f0074496d5b1045e4b (diff)
downloadFreeBSD-src-7d07d2de2f52d4e2eba169e5563165309a795128.zip
FreeBSD-src-7d07d2de2f52d4e2eba169e5563165309a795128.tar.gz
BSD 4.4 Lite Libexec Sources
Diffstat (limited to 'libexec/bugfiler')
-rw-r--r--libexec/bugfiler/Makefile17
-rw-r--r--libexec/bugfiler/bug.h92
-rw-r--r--libexec/bugfiler/bugfiler.8290
-rw-r--r--libexec/bugfiler/bugfiler.c167
-rw-r--r--libexec/bugfiler/bugformat32
-rw-r--r--libexec/bugfiler/error.c89
-rw-r--r--libexec/bugfiler/extern.h41
-rw-r--r--libexec/bugfiler/gethead.c165
-rw-r--r--libexec/bugfiler/pathnames.h38
-rw-r--r--libexec/bugfiler/process.c115
-rw-r--r--libexec/bugfiler/redist.c131
-rw-r--r--libexec/bugfiler/reply.c118
-rw-r--r--libexec/bugfiler/sendbug.185
-rw-r--r--libexec/bugfiler/sendbug.sh66
14 files changed, 1446 insertions, 0 deletions
diff --git a/libexec/bugfiler/Makefile b/libexec/bugfiler/Makefile
new file mode 100644
index 0000000..98489ad
--- /dev/null
+++ b/libexec/bugfiler/Makefile
@@ -0,0 +1,17 @@
+# @(#)Makefile 8.1 (Berkeley) 6/4/93
+
+PROG= bugfiler
+CFLAGS+=-I${.CURDIR}
+SRCS= bugfiler.c error.c gethead.c process.c redist.c reply.c
+BINOWN= root
+BINMODE=4555
+MAN1= sendbug.0
+MAN8= bugfiler.0
+
+beforeinstall:
+ install -c -o bin -g ${BINGRP} -m 555 \
+ ${.CURDIR}/sendbug.sh ${DESTDIR}/usr/bin/sendbug
+ install -c -o bin -g ${BINGRP} -m 444 ${.CURDIR}/bugformat \
+ ${DESTDIR}/usr/share/misc
+
+.include <bsd.prog.mk>
diff --git a/libexec/bugfiler/bug.h b/libexec/bugfiler/bug.h
new file mode 100644
index 0000000..69ea986
--- /dev/null
+++ b/libexec/bugfiler/bug.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 1986, 1987, 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.
+ *
+ * @(#)bug.h 8.1 (Berkeley) 6/4/93
+ */
+
+#define BUGS_HOME "owner-bugs@ucbvax.Berkeley.EDU"
+#define BUGS_ID "bugs"
+
+/*
+ * the METOO definition has the bugfiler exit with an error (-1) status
+ * if there's a problem. This causes sendmail to send off a copy of the
+ * report (as failed mail) to the "owner" of the mail alias that executed
+ * the bugfiler. This is great if you would have otherwise lost the bug
+ * report. It's not so great if you get a whole bunch of mail that you
+ * really don't want.
+ */
+#define METOO
+
+/* files */
+#define ACK_FILE "bug:ack" /* acknowledge file */
+#define DIST_FILE "bug:redist" /* redistribution file */
+#define ERROR_FILE "log" /* error file */
+#define LOCK_FILE "bug:lock" /* lock file name */
+#define SUMMARY_FILE "summary" /* summary file */
+#define TMP_BUG "errors/BUG_XXXXXX" /* tmp bug report */
+#define TMP_DIR "errors" /* tmp directory */
+
+#define CHN (char *)NULL /* null arg string */
+#define COMMENT '#' /* comment in redist file */
+#define EOS (char)NULL /* end of string */
+#define ERR -1 /* error return */
+#define MAXLINELEN 200 /* max line length in message */
+#define NO 0 /* no/false */
+#define OK 0 /* okay return */
+#define YES 1 /* yes/true */
+
+typedef struct {
+ short found, /* line number if found */
+ redist; /* if part of redist headers */
+ int (*valid)(); /* validation routine */
+ short len; /* length of tag */
+ char *tag, /* leading tag */
+ *line; /* actual line */
+} HEADER;
+extern HEADER mailhead[];
+
+#define DATE_TAG 0 /* "Date:" offset */
+#define FROM_TAG 1 /* "From " offset */
+#define CFROM_TAG 2 /* "From:" offset */
+#define INDX_TAG 3 /* "Index:" offset */
+#define MSG_TAG 4 /* "Message-Id:" offset */
+#define RPLY_TAG 5 /* "Reply-To:" offset */
+#define RET_TAG 6 /* "Return-Path:" offset */
+#define SUBJ_TAG 7 /* "Subject:" offset */
+#define TO_TAG 8 /* "To:" offset */
+#define APPAR_TO_TAG 9 /* "Apparently-To:" offset */
+
+/* so sizeof doesn't return 0 */
+extern char bfr[MAXBSIZE], /* general I/O buffer */
+ dir[MAXNAMLEN], /* subject and folder */
+ folder[MAXNAMLEN],
+ tmpname[sizeof(TMP_BUG) + 5]; /* temp bug file */
diff --git a/libexec/bugfiler/bugfiler.8 b/libexec/bugfiler/bugfiler.8
new file mode 100644
index 0000000..1fc86d2
--- /dev/null
+++ b/libexec/bugfiler/bugfiler.8
@@ -0,0 +1,290 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.\" @(#)bugfiler.8 8.2 (Berkeley) 12/11/93
+.\"
+.Dd December 11, 1993
+.Dt BUGFILER 8
+.Os BSD 4.2
+.Sh NAME
+.Nm bugfiler
+.Nd file bug reports in folders automatically
+.Sh SYNOPSIS
+.Nm bugfiler
+.Op Fl ar
+.Op Fl v Ar version
+.Sh DESCRIPTION
+.Nm Bugfiler
+is a program to automatically intercept, acknowledge,
+redistribute and store bug reports.
+.Nm Bugfiler
+is normally invoked
+by the mail delivery program with a line similar to the following in
+.Pa /etc/aliases .
+.Bd -literal -offset indent
+bugs: "|bugfiler"
+.Ed
+.Pp
+It should be noted that the login
+.Dq bugs
+must exist for the bugfiler
+to run. Unless otherwise noted all paths used by
+.Nm bugfiler
+are
+relative to the home directory of this login.
+.Nm Bugfiler
+also
+expects all of its files and directories to be owned by
+.Dq bugs .
+.Pp
+Available options.
+.Bl -tag -width Ds
+.It Fl a
+Do not send automatic mail acknowledgement to the bug report filer.
+(The default is to send the acknowledgement with the file
+.Pa ~bugs/version/bug:ack
+appended).
+.It Fl r
+Do not redistribute.
+.It Fl v Ar version
+Override the
+.Ar version
+provided within the bug report itself.
+.El
+.Pp
+For the bug report to be correctly filed, it must contain a line
+in the following format:
+.Pp
+.Bd -filled -offset indent -compact
+.Bl -column Index folder
+.It Index: Ta Em folder Ta Ar version
+.El
+.Ed
+.Pp
+The directories
+.Pa ~bugs/ Ns Ar version
+and
+.Pa ~bugs/ Ns Ar version/ Ns Em folder
+must exist before
+.Nm bugfiler
+attempts to store the bug report. Bug
+reports will be stored in files named by the concatenation of
+.Ar version ,
+.Em folder ,
+and sequential numbers, i.e. if
+.Ar version
+is
+.Dq 4.3 Tn BSD
+and
+.Em folder
+is
+.Dq ucb
+the first bug report will be placed in
+.Pa ~bugs/4.3BSD/ucb/1 .
+If
+.Em folder
+contains more than one component only
+the first one will be used, e.g. if
+.Em folder
+is
+.Dq bin/from.c
+or
+.Dq bin/adb/con.c
+it will be treated as if it were simply
+.Dq bin .
+.Pp
+.Pp
+If the
+.Fl r
+flag is not supplied, redistribution of the bug reports
+is done as specified in the file
+.Pa ~bugs/version/bug:redist .
+This file
+is in the format of the
+.Xr aliases 5
+file, including comments and
+entries requiring multiple lines, with the single exception that the
+.Em folder
+component of the
+.Dq Index:
+line replaces the name to alias.
+The special folder
+.Dq all:
+receives a redistribution of all bug reports
+sent to this
+.Ar version .
+For example, the
+.Pa bug:redist
+file
+.Pp
+.Bd -literal -offset indent -compact
+# bigbug gets a copy of everything
+all: bigbug
+# ucb folder redistribution list
+ucb: karels, kjd@coke.berkeley.edu
+ ra@beno.css.gov
+.Ed
+.Pp
+will send copies of all bug reports with
+.Dq ucb
+as the
+.Em folder
+to bigbug, karels, kjd, and ra.
+.Pp
+Reports that cannot be filed, due to an invalid
+.Dq Index:
+line or
+some other error, are placed in the directory
+.Pa ~bugs/errors .
+The
+.Nm bugfiler
+maintainer should correct these bug reports and then
+run
+.Nm bugfiler ,
+with the corrected report as its standard input,
+as bug reports with errors are neither acknowledged or redistributed.
+All reports that
+.Nm bugfiler
+handles are logged in
+.Pa ~bugs/log.
+.Pp
+Valid bugs are also logged in the file
+.Pa ~bugs/version/summary.
+This file has an entry for each bug report for
+.Ar version
+in the
+format:
+.Pp
+.Bd -literal -offset indent -compact
+Filename Date
+ Subject:
+ Index:
+ Owner: Bugs Bunny
+ Status: Received
+.Ed
+.Pp
+.Li Filename
+is the concatenation of
+.Ar version ,
+.Em folder ,
+and a number
+as described above.
+.Xr Date
+is the date as reported by the system
+clock, using
+.Xr ctime 3 .
+The
+.Li Subject:
+and
+.Li Index:
+lines are
+copies of the
+.Dq Subject:
+and
+.Dq index:
+lines contained in the bug
+report. The
+.Li Owner
+and
+.Li Status
+fields are intended to provide a
+rudimentary method of tracking the status of bug reports.
+.Pp
+The file
+.Pa ~bugs/bug:lock
+is the focus of all locking for
+.Nm bugfiler .
+If you wish to manipulate any of the log or error files, rename or remove
+it and
+.Nm bugfiler
+will treat all bug reports that it receives as if
+they were incorrectly formatted, i.e. it will place them in the directory
+.Pa ~bugs/errors ,
+for later recovery by the
+.Nm bugfiler
+maintainer.
+Obviously, this file must be created when you first install
+.Nm bugfiler .
+.Pp
+All errors that occur before
+.Pa ~bugs/log
+is found are logged into the system
+log file, using
+.Xr syslog 8 .
+.Sh FILES
+.Bl -tag -width /usr/share/misc/bugformatxx -compact
+.It Pa ~bugs/bug:ack
+the acknowledgement message
+.It Pa ~bugs/bug:redist
+the redistribution list
+.It Pa ~bugs/bug:lock
+the locking file
+.It Pa ~bugs/errors/BUG_??????
+bug reports with format errors
+.It Pa ~bugs/log
+the log file
+.It Pa ~bugs/folder/summary
+the summary files
+.It Pa /usr/sbin/sendmail
+the mail delivery program
+.It Pa /usr/share/misc/bugformat
+a sample bug report format
+.El
+.Sh SEE ALSO
+.Xr sendbug 1 ,
+.Xr aliases 5 ,
+.Xr syslog 8
+.Sh BUGS
+Since mail can be forwarded in a number of different ways,
+.Nm bugfiler
+does not recognize forwarded mail and will acknowledge to the forwarder
+instead of the original sender unless there is a
+.Dq Reply-To
+field in the
+header.
+.Pp
+This version of
+.Nm bugfiler
+is not compatible with the version
+released with
+.Bx 4.3
+in that it doesn't complain to the sender about
+incorrectly formatted bug reports.
+Frankly, we got tired of the profanity, not to mention the extended
+conversations
+.Nm bugfiler
+was holding with
+.Xr vacation 1 .
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 4.2 .
diff --git a/libexec/bugfiler/bugfiler.c b/libexec/bugfiler/bugfiler.c
new file mode 100644
index 0000000..75dbef3
--- /dev/null
+++ b/libexec/bugfiler/bugfiler.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 1983, 1986, 1987, 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) 1983, 1986, 1987, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)bugfiler.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/*
+ * Bug report processing program, designed to be invoked
+ * through aliases(5).
+ */
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "bug.h"
+#include "extern.h"
+
+char bfr[MAXBSIZE], /* general I/O buffer */
+ tmpname[sizeof(TMP_BUG) + 5]; /* temp bug file */
+
+static void logit __P((void));
+static void make_copy __P((void));
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ extern char *optarg; /* getopt arguments */
+ register struct passwd *pwd; /* bugs password entry */
+ register int ch; /* getopts char */
+ int do_ack, /* acknowledge bug report */
+ do_redist; /* redistribut BR */
+ char *argversion; /* folder name provided */
+
+ do_ack = do_redist = YES;
+ argversion = NULL;
+ while ((ch = getopt(argc, argv, "av:r")) != EOF)
+ switch(ch) {
+ case 'a':
+ do_ack = NO;
+ break;
+ case 'v':
+ argversion = optarg;
+ break;
+ case 'r':
+ do_redist = NO;
+ break;
+ case '?':
+ default:
+ fputs("usage: bugfiler [-ar] [-v version]\n", stderr);
+ error("usage: bugfiler [-ar] [-v version]", CHN);
+ }
+
+ if (!(pwd = getpwnam(BUGS_ID)))
+ error("can't find bugs login.", BUGS_ID);
+
+ if (chdir(pwd->pw_dir)) /* change to bugs home directory */
+ error("can't chdir to %s.", pwd->pw_dir);
+
+ if (seteuid(pwd->pw_uid))
+ error("can't set id to %s.", BUGS_ID);
+
+ (void)umask(02); /* everything is 664 */
+ seterr(); /* redirect to log file */
+ logit(); /* log report arrival */
+ make_copy(); /* save copy in case */
+ gethead(do_redist);
+
+ if (argversion) /* specific folder requested */
+ (void)strcpy(dir, argversion);
+
+ process();
+
+ if (seteuid(0))
+ error("can't set id to root.", CHN);
+ if (do_ack)
+ reply();
+ if (do_redist)
+ redist();
+ (void)unlink(tmpname);
+ exit(OK);
+}
+
+/*
+ * make_copy --
+ * make a copy of bug report in error folder
+ */
+static void
+make_copy()
+{
+ register int cnt, /* read return value */
+ tfd; /* temp file descriptor */
+
+ if (access(TMP_DIR, F_OK))
+ (void)mkdir(TMP_DIR, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
+ (void)strcpy(tmpname, TMP_BUG);
+ if (tfd = mkstemp(tmpname)) {
+ while ((cnt = read(fileno(stdin),
+ bfr, sizeof(bfr))) != ERR && cnt)
+ write(tfd, bfr, cnt);
+ (void)close(tfd);
+ return;
+ }
+ error("can't make copy using %s.", tmpname);
+}
+
+/*
+ * logit --
+ * log this run of the bugfiler
+ */
+static void
+logit()
+{
+ struct timeval tp;
+ char *C1, *C2;
+
+ if (gettimeofday(&tp, (struct timezone *)NULL))
+ error("can't get time of day.", CHN);
+ for (C1 = C2 = ctime(&tp.tv_sec); *C1 && *C1 != '\n'; ++C1);
+ *C1 = EOS;
+ fputs(C2, stderr);
+}
diff --git a/libexec/bugfiler/bugformat b/libexec/bugfiler/bugformat
new file mode 100644
index 0000000..97a767d
--- /dev/null
+++ b/libexec/bugfiler/bugformat
@@ -0,0 +1,32 @@
+Subject: Short summary of the problem (please make this meaningful!)
+Index: folder 4.4BSD-alpha
+
+Description:
+ Detailed description of the problem, suggestion, or complaint.
+Repeat-By:
+ Describe the sequence of events that causes the problem
+ to occur.
+Fix:
+ Description of how to fix the problem. If you don't know a
+ fix for the problem, don't include this section.
+
+-------- Remove this line and what's below it, for reference only. --------
+
+To ensure that your bug report is handled correctly by bugfiler(8),
+you must replace "folder" (on the line above starting with "Index:")
+with one of the following values:
+
+ folder ::= bin | doc | etc | games | ideas | include | lib
+ | local | man | misc | new | sys | ucb
+ | usr.bin | usr.lib
+
+If you're not running 4.3BSD, you should also replace "4.3BSD" on
+the same line with one of the following values.
+
+ version ::= 4.3BSD | 4.3BSD-tahoe | 4.3BSD-reno | net2
+ | 4.4BSD-alpha
+
+For example, if your bug concerns the program "/usr/bin/file" and
+you're currently running 4.3BSD-Reno, you should replace "folder"
+with "usr.bin/file", and "4.4BSD-alpha" with "4.3BSD-Reno". The folder
+"ideas" is for suggestions.
diff --git a/libexec/bugfiler/error.c b/libexec/bugfiler/error.c
new file mode 100644
index 0000000..bd00b2b
--- /dev/null
+++ b/libexec/bugfiler/error.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 1986, 1987, 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 sccsid[] = "@(#)error.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/param.h>
+
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+
+#include "bug.h"
+#include "extern.h"
+
+static short err_redir; /* stderr redirected */
+
+/*
+ * seterr --
+ * redirect stderr for error processing
+ */
+void
+seterr()
+{
+ if (!freopen(ERROR_FILE, "a", stderr))
+ error("can't open error file %s.", ERROR_FILE);
+ err_redir = YES;
+}
+
+/*
+ * error --
+ * write errors to log file and die
+ */
+void
+error(fmt, arg)
+ register char *fmt,
+ *arg;
+{
+ static char logmsg[MAXLINELEN]; /* syslog message */
+
+ if (err_redir) {
+ /* don't combine these, "fmt" may not require "arg" */
+ fprintf(stderr, "\t%s\n\t", tmpname);
+ fprintf(stderr, fmt, arg);
+ fputc('\n', stderr);
+ }
+ else {
+ sprintf(logmsg, "bugfiler: %s", fmt);
+ syslog(LOG_ERR, logmsg, arg);
+ }
+#ifdef METOO
+ exit(ERR);
+#else
+ exit(OK);
+#endif
+}
diff --git a/libexec/bugfiler/extern.h b/libexec/bugfiler/extern.h
new file mode 100644
index 0000000..b096f3d
--- /dev/null
+++ b/libexec/bugfiler/extern.h
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 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.
+ *
+ * @(#)extern.h 8.1 (Berkeley) 6/4/93
+ */
+
+void error __P((char *, char *));
+void gethead __P((int));
+int process __P((void));
+void redist __P((void));
+void reply __P((void));
+void seterr __P((void));
diff --git a/libexec/bugfiler/gethead.c b/libexec/bugfiler/gethead.c
new file mode 100644
index 0000000..ba7e361
--- /dev/null
+++ b/libexec/bugfiler/gethead.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 1986, 1987, 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 sccsid[] = "@(#)gethead.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "pathnames.h"
+#include "bug.h"
+#include "extern.h"
+
+static int chk1 __P((char *));
+static int pbuf __P((char *));
+
+#define ENT(X) sizeof(X) - 1, X
+HEADER mailhead[] = { /* mail headers */
+ { NO, YES, NULL, ENT("Date:"), },
+ { NO, NO, NULL, ENT("From "), },
+ { NO, YES, NULL, ENT("From:"), },
+ { NO, NO, chk1, ENT("Index:"), },
+ { NO, YES, NULL, ENT("Message-Id:"), },
+ { NO, YES, NULL, ENT("Reply-To:"), },
+ { NO, YES, NULL, ENT("Return-Path:"), },
+ { NO, NO, pbuf, ENT("Subject:"), },
+ { NO, YES, NULL, ENT("To:"), },
+ { NO, NO, NULL, ENT("Apparently-To:"), },
+ { ERR, }
+};
+
+FILE *dfp; /* distf file pointer */
+char dir[MAXNAMLEN], /* subject and folder */
+ folder[MAXNAMLEN];
+
+/*
+ * gethead --
+ * read mail and bug headers from bug report, construct redist headers
+ */
+void
+gethead(redist)
+ int redist;
+{
+ register HEADER *hp; /* mail header pointer */
+
+ if (redist) {
+ int fd;
+ char *distf;
+
+ distf = strdup(_PATH_TMP);
+ if (!(fd = mkstemp(distf)) || !(dfp = fdopen(fd, "w+")))
+ error("can't create redistribution file %s.", distf);
+ /* disappear after last reference is closed */
+ (void)unlink(distf);
+ free(distf);
+ }
+ if (!freopen(tmpname, "r", stdin))
+ error("can't read temporary bug file %s.", tmpname);
+
+ while (fgets(bfr, sizeof(bfr), stdin)) {
+ for (hp = mailhead; hp->found != ERR; ++hp)
+ if (!hp->found)
+ if (!strncmp(hp->tag, bfr, hp->len)) {
+ if (hp->valid && !((*(hp->valid))(bfr)))
+ break;
+ if (!(hp->line =
+ malloc((u_int)(strlen(bfr) + 1))))
+ error("malloc failed.", CHN);
+ (void)strcpy(hp->line, bfr);
+ hp->found = YES;
+ break;
+ }
+ if ((hp->found == ERR || hp->redist) && redist)
+ fputs(bfr, dfp);
+ }
+
+ if (!mailhead[INDX_TAG].found)
+ error("no readable \"Index:\" header in bug report.", CHN);
+}
+
+/*
+ * chk1 --
+ * parse the "Index:" line into folder and directory
+ */
+static int
+chk1(line)
+ char *line;
+{
+ register char *C; /* tmp pointer */
+ struct stat sbuf; /* existence check */
+
+ if (sscanf(line, " Index: %s %s ", folder, dir) != 2)
+ return(NO);
+ if (C = strchr(folder, '/')) { /* deal with "bin/from.c" */
+ if (C == folder)
+ return(NO);
+ *C = EOS;
+ }
+ if (stat(dir, &sbuf) || (sbuf.st_mode & S_IFMT) != S_IFDIR)
+ return(NO);
+ (void)pbuf(line);
+ return(YES);
+}
+
+/*
+ * pbuf --
+ * kludge so that summary file looks pretty
+ */
+static int
+pbuf(line)
+ char *line;
+{
+ register char *rp, /* tmp pointers */
+ *wp;
+
+ for (rp = line; *rp == ' ' || *rp == '\t'; ++rp);
+ for (wp = line; *rp; ++wp) {
+ if ((*wp = *rp++) != ' ' && *wp != '\t')
+ continue;
+ *wp = ' ';
+ while (*rp == ' ' || *rp == '\t')
+ ++rp;
+ }
+ if (wp[-1] == ' ') /* wp can't == line */
+ --wp;
+ *wp = EOS;
+ return(YES);
+}
diff --git a/libexec/bugfiler/pathnames.h b/libexec/bugfiler/pathnames.h
new file mode 100644
index 0000000..7ff5ab6
--- /dev/null
+++ b/libexec/bugfiler/pathnames.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1989, 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.
+ *
+ * @(#)pathnames.h 8.1 (Berkeley) 6/4/93
+ */
+
+#define MAIL_CMD "/usr/sbin/sendmail -i -t -F \"Bugs Bunny\" -f owner-bugs"
+#undef _PATH_TMP
+#define _PATH_TMP "/tmp/BUG_XXXXXX"
diff --git a/libexec/bugfiler/process.c b/libexec/bugfiler/process.c
new file mode 100644
index 0000000..6d376fd
--- /dev/null
+++ b/libexec/bugfiler/process.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 1986, 1987, 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 sccsid[] = "@(#)process.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "bug.h"
+#include "extern.h"
+
+char pfile[MAXPATHLEN]; /* permanent file name */
+
+static int getnext __P((void));
+
+/*
+ * process --
+ * copy report to permanent file,
+ * update summary file.
+ */
+int
+process()
+{
+ register int rval; /* read return value */
+ struct timeval tp; /* time of day */
+ int lfd; /* lock file descriptor */
+
+ if (access(LOCK_FILE, R_OK) || (lfd = open(LOCK_FILE, O_RDONLY, 0)) < 0)
+ error("can't find lock file %s.", LOCK_FILE);
+ if (flock(lfd, LOCK_EX))
+ error("can't get lock.", CHN);
+ sprintf(pfile, "%s/%s/%d", dir, folder, getnext());
+ fprintf(stderr, "\t%s\n", pfile);
+ if (!(freopen(pfile, "w", stdout)))
+ error("can't create %s.", pfile);
+ rewind(stdin);
+ while ((rval = read(fileno(stdin), bfr, sizeof(bfr))) != ERR && rval)
+ if (write(fileno(stdout), bfr, rval) != rval)
+ error("write to %s failed.", pfile);
+
+ /* append information to the summary file */
+ sprintf(bfr, "%s/%s", dir, SUMMARY_FILE);
+ if (!(freopen(bfr, "a", stdout)))
+ error("can't append to summary file %s.", bfr);
+ if (gettimeofday(&tp, (struct timezone *)NULL))
+ error("can't get time of day.", CHN);
+ printf("\n%s\t\t%s\t%s\t%s\tOwner: Bugs Bunny\n\tStatus: Received\n",
+ pfile, ctime(&tp.tv_sec), mailhead[INDX_TAG].line,
+ mailhead[SUBJ_TAG].found ? mailhead[SUBJ_TAG].line : "Subject:\n");
+ (void)flock(lfd, LOCK_UN);
+ (void)fclose(stdout);
+}
+
+/*
+ * getnext --
+ * get next file name (number)
+ */
+static int
+getnext()
+{
+ register struct dirent *d; /* directory structure */
+ register DIR *dirp; /* directory pointer */
+ register int highval, newval;
+ register char *p;
+
+ (void)sprintf(bfr, "%s/%s", dir, folder);
+ if (!(dirp = opendir(bfr)))
+ error("can't read folder directory %s.", bfr);
+ for (highval = -1; d = readdir(dirp);) {
+ for (p = d->d_name; *p && isdigit(*p); ++p);
+ if (!*p && (newval = atoi(d->d_name)) > highval)
+ highval = newval;
+ }
+ closedir(dirp);
+ return(++highval);
+}
diff --git a/libexec/bugfiler/redist.c b/libexec/bugfiler/redist.c
new file mode 100644
index 0000000..87a18b6
--- /dev/null
+++ b/libexec/bugfiler/redist.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 1986, 1987, 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 sccsid[] = "@(#)redist.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/param.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "bug.h"
+#include "pathnames.h"
+#include "extern.h"
+
+/*
+ * redist --
+ * Redistribute a bug report to those people indicated in the
+ * redistribution list file.
+ */
+void
+redist()
+{
+ extern FILE *dfp; /* dist file fp */
+ extern char pfile[]; /* permanent bug file */
+ register char *C1, *C2;
+ FILE *pf;
+ int group;
+
+ (void)sprintf(bfr, "%s/%s", dir, DIST_FILE);
+ if (!freopen(bfr, "r", stdin))
+ return;
+ for (pf = NULL, group = 0; fgets(bfr, sizeof(bfr), stdin);) {
+ if (C1 = strchr(bfr, '\n'))
+ *C1 = '\0';
+nextline: if (*bfr == COMMENT ||
+ isspace(*bfr) || !(C1 = index(bfr, ':')))
+ continue;
+ *C1 = EOS;
+ if (!strcmp(bfr, folder) || !strcmp(bfr, "all")) {
+ for (++C1; *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1);
+ if (!*C1) /* if empty list */
+ continue;
+ if (!pf) {
+ if (!(pf = popen(MAIL_CMD, "w")))
+ error("sendmail pipe failed.", CHN);
+ if (mailhead[SUBJ_TAG].found)
+ fprintf(pf,
+ "%s", mailhead[SUBJ_TAG].line);
+ else
+ fprintf(pf,
+ "Subject: Untitled Bug Report\n");
+ if (!mailhead[TO_TAG].line) {
+ if (mailhead[APPAR_TO_TAG].line)
+ fprintf(pf, "To%s",
+ strchr(mailhead[APPAR_TO_TAG].line,
+ ':'));
+ else
+ fprintf(pf, "To: %s\n", BUGS_ID);
+ }
+ fputs("Resent-To: ", pf);
+ }
+ /*
+ * write out first entry, then succeeding entries
+ * backward compatible, handles back slashes at end
+ * of line
+ */
+ if (group++)
+ fputs(", ", pf);
+ for (;;) {
+ if (C2 = strchr(C1, '\\'))
+ *C2 = EOS;
+ fputs(C1, pf);
+ if (!fgets(bfr, sizeof(bfr), stdin))
+ break;
+ if (C1 = strchr(bfr, '\n'))
+ *C1 = '\0';
+ if (*bfr != ' ' && *bfr != '\t')
+ goto nextline;
+ for (C1 = bfr;
+ *C1 && (*C1 == ' ' || *C1 == '\t'); ++C1);
+ }
+ }
+ }
+ if (!pf)
+ return;
+
+ putc('\n', pf);
+
+ rewind(dfp);
+ /* add Reference header and copy bug report out */
+ while (fgets(bfr, sizeof(bfr), dfp) && *bfr != '\n')
+ fputs(bfr, pf);
+ fprintf(pf, "\n%sReference: %s\n\n", mailhead[INDX_TAG].line, pfile);
+ while (fgets(bfr, sizeof(bfr), dfp))
+ fputs(bfr, pf);
+ (void)pclose(pf);
+}
diff --git a/libexec/bugfiler/reply.c b/libexec/bugfiler/reply.c
new file mode 100644
index 0000000..0f99401
--- /dev/null
+++ b/libexec/bugfiler/reply.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1986, 1987, 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 sccsid[] = "@(#)reply.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+#include <sys/param.h>
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "bug.h"
+#include "extern.h"
+#include "pathnames.h"
+
+/*
+ * reply --
+ * tell the user we got their silly little bug report
+ */
+void
+reply()
+{
+ register char *C, /* traveling pointer */
+ *to; /* who we're replying to */
+ register int afd, /* ack file descriptor */
+ rval; /* return value */
+ FILE *pf; /* pipe pointer */
+
+ if (mailhead[RPLY_TAG].found) {
+ for (C = mailhead[RPLY_TAG].line + mailhead[RPLY_TAG].len;
+ *C != '\n' && (*C == ' ' || *C == '\t');++C);
+ if (*C)
+ goto gotone;
+ }
+ if (mailhead[FROM_TAG].found) {
+ for (C = mailhead[FROM_TAG].line + mailhead[FROM_TAG].len;
+ *C != '\n' && (*C == ' ' || *C == '\t');++C);
+ if (*C)
+ goto gotone;
+ }
+ if (mailhead[CFROM_TAG].found) {
+ for (C = mailhead[CFROM_TAG].line + mailhead[CFROM_TAG].len;
+ *C != '\n' && (*C == ' ' || *C == '\t');++C);
+ if (*C)
+ goto gotone;
+ }
+ return;
+
+ /* if it's a foo <XXX>, get the XXX, else get foo (first string) */
+gotone: if (to = strchr(C, '<'))
+ for (C = ++to;
+ *C != '\n' && *C != ' ' && *C != '\t' && *C != '>';++C);
+ else {
+ to = C;
+ for (to = C++;*C != '\n' && *C != ' ' && *C != '\t';++C);
+ }
+ *C = EOS;
+
+ if (!(pf = popen(MAIL_CMD, "w")))
+ error("sendmail pipe failed.", CHN);
+
+ fprintf(pf, "Reply-To: %s\nFrom: %s (Bugs Bunny)\nTo: %s\n",
+ BUGS_HOME, BUGS_HOME, to);
+ if (mailhead[SUBJ_TAG].found)
+ fprintf(pf, "Subject: Re:%s",
+ mailhead[SUBJ_TAG].line + mailhead[SUBJ_TAG].len);
+ else
+ fputs("Subject: Bug report acknowledgement.\n", pf);
+ if (mailhead[DATE_TAG].found)
+ fprintf(pf, "In-Acknowledgement-Of: Your message of %s",
+ mailhead[DATE_TAG].line + mailhead[DATE_TAG].len);
+ if (mailhead[MSG_TAG].found)
+ fprintf(pf, "\t\t%s", mailhead[MSG_TAG].line);
+ fputs("Precedence: bulk\n\n", pf); /* vacation(1) uses this... */
+ fflush(pf);
+
+ (void)sprintf(bfr, "%s/%s", dir, ACK_FILE);
+ if ((afd = open(bfr, O_RDONLY, 0)) >= 0) {
+ while ((rval = read(afd, bfr, sizeof(bfr))) != ERR && rval)
+ (void)write(fileno(pf), bfr, rval);
+ (void)close(afd);
+ }
+ pclose(pf);
+}
diff --git a/libexec/bugfiler/sendbug.1 b/libexec/bugfiler/sendbug.1
new file mode 100644
index 0000000..31ca802
--- /dev/null
+++ b/libexec/bugfiler/sendbug.1
@@ -0,0 +1,85 @@
+.\" Copyright (c) 1983, 1990, 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.
+.\"
+.\" @(#)sendbug.1 8.1 (Berkeley) 6/4/93
+.\"
+.Dd June 4, 1993
+.Dt SENDBUG 1
+.Os BSD 4.2
+.Sh NAME
+.Nm sendbug
+.Nd mail a system bug report to 4bsd-bugs
+.Sh SYNOPSIS
+.Nm sendbug
+.Op Ar address
+.Sh DESCRIPTION
+Bug reports sent to `4bsd-bugs@Berkeley.EDU' are intercepted
+by a program which expects bug reports to conform to a standard format.
+.Nm Sendbug
+is a shell script to help the user compose and mail bug reports
+in the correct format.
+.Nm Sendbug
+works by invoking the editor specified by the environment variable
+.Ev EDITOR
+on a temporary copy of the bug report format outline. The user must fill in the
+appropriate fields and exit the editor.
+.Nm Sendbug
+then mails the completed report to `4bsd-bugs@Berkeley.EDU' or the
+.Ar address
+specified on the command line.
+.Sh ENVIRONMENT
+.Nm Sendbug
+will utilize the following environment variable if it exists:
+.Bl -tag -width EDITOR
+.It Ev EDITOR
+Specifies the preferred editor. If
+.Ev EDITOR
+is not set,
+.Nm
+defaults to
+.Xr vi 1 .
+.El
+.Sh FILES
+.Bl -tag -width /usr/share/misc/bugformat -compact
+.It Pa /usr/share/misc/bugformat
+Contains the bug report outline.
+.El
+.Sh SEE ALSO
+.Xr vi 1 ,
+.Xr environ 7 ,
+.Xr bugfiler 8 ,
+.Xr sendmail 8
+.Sh HISTORY
+The
+.Nm sendbug
+command
+appeared in
+.Bx 4.2 .
diff --git a/libexec/bugfiler/sendbug.sh b/libexec/bugfiler/sendbug.sh
new file mode 100644
index 0000000..911ef9d
--- /dev/null
+++ b/libexec/bugfiler/sendbug.sh
@@ -0,0 +1,66 @@
+#!/bin/sh -
+#
+# Copyright (c) 1983, 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.
+#
+# @(#)sendbug.sh 8.1 (Berkeley) 6/4/93
+#
+
+# create a bug report and mail it to '4bsd-bugs'.
+
+PATH=/bin:/sbin:/usr/sbin:/usr/bin
+export PATH
+
+TEMP=/tmp/bug$$
+FORMAT=/usr/share/misc/bugformat
+
+# uucp sites should use ": ${BUGADDR=ucbvax!4bsd-bugs}" with a suitable path.
+: ${BUGADDR=4bsd-bugs@CS.Berkeley.EDU}
+: ${EDITOR=vi}
+
+trap 'rm -f $TEMP ; exit 1' 1 2 3 13 15
+
+cp $FORMAT $TEMP
+chmod u+w $TEMP
+if $EDITOR $TEMP
+then
+ if cmp -s $FORMAT $TEMP
+ then
+ echo "File not changed, no bug report submitted."
+ exit
+ fi
+ case "$#" in
+ 0) sendmail -t -oi $BUGADDR < $TEMP ;;
+ *) sendmail -t -oi "$@" < $TEMP ;;
+ esac
+fi
+
+rm -f $TEMP
OpenPOWER on IntegriCloud