summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-08-02 18:46:42 +0000
committerbde <bde@FreeBSD.org>1997-08-02 18:46:42 +0000
commitd7d37d2613dfc3f61618da7c36af64d0fc652946 (patch)
tree4a088f698500247557a3f26a538423b44adb1720 /libexec
parent93bb6c4e7ec3c3ab39adfd3e28ed163c7f14cf18 (diff)
downloadFreeBSD-src-d7d37d2613dfc3f61618da7c36af64d0fc652946.zip
FreeBSD-src-d7d37d2613dfc3f61618da7c36af64d0fc652946.tar.gz
Import Lite2's src/libexec, except for makekey (which was spammed
by a repository copy from 1.1.5 and patched back to Lite1) and rbootd/bootdir/SYSHPBSD (which is binary). All changed files have already left the vendor branch.
Diffstat (limited to 'libexec')
-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
-rw-r--r--libexec/ftpd/ftpd.85
-rw-r--r--libexec/ftpd/ftpd.c4
-rw-r--r--libexec/kpasswdd/kpasswdd.860
-rw-r--r--libexec/kpasswdd/kpasswdd.c271
-rw-r--r--libexec/lfs_cleanerd/clean.h4
-rw-r--r--libexec/lfs_cleanerd/cleanerd.c135
-rw-r--r--libexec/lfs_cleanerd/library.c48
-rw-r--r--libexec/lfs_cleanerd/print.c26
-rw-r--r--libexec/mail.local/Makefile.dist14
-rw-r--r--libexec/mail.local/mail.local.c401
-rw-r--r--libexec/rexecd/rexecd.85
-rw-r--r--libexec/rlogind/rlogind.c15
-rw-r--r--libexec/talkd/announce.c13
-rw-r--r--libexec/telnetd/authenc.c91
-rw-r--r--libexec/telnetd/slc.c16
-rw-r--r--libexec/telnetd/state.c22
-rw-r--r--libexec/telnetd/sys_term.c230
-rw-r--r--libexec/telnetd/telnetd.86
-rw-r--r--libexec/telnetd/telnetd.c54
-rw-r--r--libexec/telnetd/termstat.c18
-rw-r--r--libexec/telnetd/utility.c34
34 files changed, 2698 insertions, 203 deletions
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
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index a7c5cae..eb93c38 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ftpd.8 8.2 (Berkeley) 4/19/94
+.\" @(#)ftpd.8 8.3 (Berkeley) 6/1/94
.\"
-.Dd April 19, 1994
+.Dd June 1, 1994
.Dt FTPD 8
.Os BSD 4.2
.Sh NAME
@@ -228,6 +228,7 @@ subtree be constructed with care, following these rules:
Make the home directory owned by
.Dq root
and unwritable by anyone.
+.ne 1i
.It Pa ~ftp/bin
Make this directory owned by
.Dq root
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 6e23bd7..875ec62 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94";
+static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
/*
@@ -483,7 +483,7 @@ checkuser(name)
*p = '\0';
if (line[0] == '#')
continue;
- if (strcmp(p, name) == 0) {
+ if (strcmp(line, name) == 0) {
found = 1;
break;
}
diff --git a/libexec/kpasswdd/kpasswdd.8 b/libexec/kpasswdd/kpasswdd.8
new file mode 100644
index 0000000..f6a401f
--- /dev/null
+++ b/libexec/kpasswdd/kpasswdd.8
@@ -0,0 +1,60 @@
+.\" Copyright (c) 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.
+.\"
+.\" @(#)kpasswdd.8 8.1 (Berkeley) 6/9/93
+.\"
+.Dd June 9, 1993
+.Dt KPASSWDD 8
+.Os
+.Sh NAME
+.Nm kpasswdd
+.Nd Kerberos password changing daemon
+.Sh SYNOPSIS
+.Nm kpasswdd
+.Sh DESCRIPTION
+.Nm Kpasswdd
+is the server for the
+.Xr passwd 1
+program.
+The server provides a remote password changing facility
+with Kerberos authentication.
+A user must provide the old Kerberos password, encrypted
+in a random session key, to the server.
+.Nm Kpasswdd
+runs only on the Kerberos server, as it directly updates the
+Kerberos database.
+.Sh SEE ALSO
+.Xr kerberos 1 ,
+.Xr passwd 1
+.Sh HISTORY
+The
+.Nm kpasswdd
+utility first appeared in 4.4BSD.
diff --git a/libexec/kpasswdd/kpasswdd.c b/libexec/kpasswdd/kpasswdd.c
new file mode 100644
index 0000000..23ff1f8
--- /dev/null
+++ b/libexec/kpasswdd/kpasswdd.c
@@ -0,0 +1,271 @@
+/*-
+ * Copyright (c) 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.
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)kpasswdd.c 8.1 (Berkeley) 6/4/93";
+#endif /* not lint */
+
+/*
+ * kpasswdd - update a principal's passwd field in the Kerberos
+ * database. Called from inetd.
+ * K. Fall
+ * 12-Dec-88
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/signal.h>
+#include <netinet/in.h>
+#include <pwd.h>
+#include <syslog.h>
+#include <kerberosIV/des.h>
+#include <kerberosIV/krb.h>
+#include <kerberosIV/krb_db.h>
+#include <stdio.h>
+#include "kpasswd_proto.h"
+
+static struct kpasswd_data kpwd_data;
+static des_cblock master_key, key;
+static Key_schedule master_key_schedule,
+ key_schedule, random_sched;
+long mkeyversion;
+AUTH_DAT kdata;
+static Principal principal_data;
+static struct update_data ud_data;
+
+char inst[INST_SZ];
+char version[9];
+KTEXT_ST ticket;
+
+char *progname; /* for the library */
+
+main()
+{
+ struct sockaddr_in foreign;
+ int foreign_len = sizeof(foreign);
+ int rval, more;
+ static char name[] = "kpasswdd";
+
+ static struct rlimit rl = { 0, 0 };
+
+ progname = name;
+ openlog("kpasswdd", LOG_CONS | LOG_PID, LOG_AUTH);
+
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ signal(SIGTSTP, SIG_IGN);
+ if (setrlimit(RLIMIT_CORE, &rl) < 0) {
+ syslog(LOG_ERR, "setrlimit: %m");
+ exit(1);
+ }
+
+ if (getpeername(0, &foreign, &foreign_len) < 0) {
+ syslog(LOG_ERR,"getpeername: %m");
+ exit(1);
+ }
+
+ strcpy(inst, "*");
+ rval = krb_recvauth(
+ 0L, /* options--!MUTUAL */
+ 0, /* file desc */
+ &ticket, /* client's ticket */
+ SERVICE, /* expected service */
+ inst, /* expected instance */
+ &foreign, /* foreign addr */
+ (struct sockaddr_in *) 0, /* local addr */
+ &kdata, /* returned krb data */
+ "", /* service keys file */
+ (bit_64 *) NULL, /* returned key schedule */
+ version
+ );
+
+
+ if (rval != KSUCCESS) {
+ syslog(LOG_NOTICE, "krb_recvauth: %s", krb_err_txt[rval]);
+ cleanup();
+ exit(1);
+ }
+
+ if (*version == '\0') {
+ /* indicates error on client's side (no tickets, etc.) */
+ cleanup();
+ exit(0);
+ } else if (strcmp(version, "KPWDV0.1") != 0) {
+ syslog(LOG_NOTICE,
+ "kpasswdd version conflict (recv'd %s)",
+ version);
+ cleanup();
+ exit(1);
+ }
+
+
+ /* get master key */
+ if (kdb_get_master_key(0, master_key, master_key_schedule) != 0) {
+ syslog(LOG_ERR, "couldn't get master key");
+ cleanup();
+ exit(1);
+ }
+
+ mkeyversion = kdb_get_master_key(NULL, master_key, master_key_schedule);
+
+ if (mkeyversion < 0) {
+ syslog(LOG_NOTICE, "couldn't verify master key");
+ cleanup();
+ exit(1);
+ }
+
+ /* get principal info */
+ rval = kerb_get_principal(
+ kdata.pname,
+ kdata.pinst,
+ &principal_data,
+ 1,
+ &more
+ );
+
+ if (rval < 0) {
+ syslog(LOG_NOTICE,
+ "error retrieving principal record for %s.%s",
+ kdata.pname, kdata.pinst);
+ cleanup();
+ exit(1);
+ }
+
+ if (rval != 1 || (more != 0)) {
+ syslog(LOG_NOTICE, "more than 1 dbase entry for %s.%s",
+ kdata.pname, kdata.pinst);
+ cleanup();
+ exit(1);
+ }
+
+ /* get the user's key */
+
+ bcopy(&principal_data.key_low, key, 4);
+ bcopy(&principal_data.key_high, ((long *) key) + 1, 4);
+ kdb_encrypt_key(key, key, master_key, master_key_schedule,
+ DECRYPT);
+ key_sched(key, key_schedule);
+ des_set_key(key, key_schedule);
+
+
+ /* get random key and send it over {random} Kperson */
+
+ random_key(kpwd_data.random_key);
+ strcpy(kpwd_data.secure_msg, SECURE_STRING);
+ if (des_write(0, &kpwd_data, sizeof(kpwd_data)) != sizeof(kpwd_data)) {
+ syslog(LOG_NOTICE, "error writing initial data");
+ cleanup();
+ exit(1);
+ }
+
+ bzero(key, sizeof(key));
+ bzero(key_schedule, sizeof(key_schedule));
+
+ /* now read update info: { info }Krandom */
+
+ key_sched(kpwd_data.random_key, random_sched);
+ des_set_key(kpwd_data.random_key, random_sched);
+ if (des_read(0, &ud_data, sizeof(ud_data)) != sizeof(ud_data)) {
+ syslog(LOG_NOTICE, "update aborted");
+ cleanup();
+ exit(1);
+ }
+
+ /* validate info string by looking at the embedded string */
+
+ if (strcmp(ud_data.secure_msg, SECURE_STRING) != 0) {
+ syslog(LOG_NOTICE, "invalid update from %s",
+ inet_ntoa(foreign.sin_addr));
+ cleanup();
+ exit(1);
+ }
+
+ /* produce the new key entry in the database { key }Kmaster */
+ string_to_key(ud_data.pw, key);
+ kdb_encrypt_key(key, key,
+ master_key, master_key_schedule,
+ ENCRYPT);
+ bcopy(key, &principal_data.key_low, 4);
+ bcopy(((long *) key) + 1,
+ &principal_data.key_high, 4);
+ bzero(key, sizeof(key));
+ principal_data.key_version++;
+ if (kerb_put_principal(&principal_data, 1)) {
+ syslog(LOG_ERR, "couldn't write new record for %s.%s",
+ principal_data.name, principal_data.instance);
+ cleanup();
+ exit(1);
+ }
+
+ syslog(LOG_NOTICE,"wrote new password field for %s.%s from %s",
+ principal_data.name,
+ principal_data.instance,
+ inet_ntoa(foreign.sin_addr)
+ );
+
+ send_ack(0, "Update complete.\n");
+ cleanup();
+ exit(0);
+}
+
+cleanup()
+{
+ bzero(&kpwd_data, sizeof(kpwd_data));
+ bzero(master_key, sizeof(master_key));
+ bzero(master_key_schedule, sizeof(master_key_schedule));
+ bzero(key, sizeof(key));
+ bzero(key_schedule, sizeof(key_schedule));
+ bzero(random_sched, sizeof(random_sched));
+ bzero(&principal_data, sizeof(principal_data));
+ bzero(&ud_data, sizeof(ud_data));
+}
+
+send_ack(remote, msg)
+ int remote;
+ char *msg;
+{
+ int cc;
+ cc = des_write(remote, msg, strlen(msg) + 1);
+ if (cc <= 0) {
+ syslog(LOG_NOTICE, "error writing ack");
+ cleanup();
+ exit(1);
+ }
+}
diff --git a/libexec/lfs_cleanerd/clean.h b/libexec/lfs_cleanerd/clean.h
index 0dd8775..f735ea1 100644
--- a/libexec/lfs_cleanerd/clean.h
+++ b/libexec/lfs_cleanerd/clean.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)clean.h 8.1 (Berkeley) 6/4/93
+ * @(#)clean.h 8.2 (Berkeley) 5/4/95
*/
/*
@@ -106,7 +106,7 @@ typedef struct fs_info {
__BEGIN_DECLS
int dump_summary __P((struct lfs *, SEGSUM *, u_long, daddr_t **));
void err __P((const int, const char *, ...));
-int fs_getmntinfo __P((struct statfs **, char *, int));
+int fs_getmntinfo __P((struct statfs **, char *, char *));
int get __P((int, off_t, void *, size_t));
FS_INFO *get_fs_info __P((struct statfs *, int));
int lfs_segmapv __P((FS_INFO *, int, caddr_t, BLOCK_INFO **, int *));
diff --git a/libexec/lfs_cleanerd/cleanerd.c b/libexec/lfs_cleanerd/cleanerd.c
index 515d2d5..6d06d75 100644
--- a/libexec/lfs_cleanerd/cleanerd.c
+++ b/libexec/lfs_cleanerd/cleanerd.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)cleanerd.c 8.2 (Berkeley) 1/13/94";
+static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
#endif /* not lint */
#include <sys/param.h>
@@ -57,7 +57,10 @@ static char sccsid[] = "@(#)cleanerd.c 8.2 (Berkeley) 1/13/94";
char *special = "cleanerd";
int do_small = 0;
int do_mmap = 0;
+int stat_report = 0;
struct cleaner_stats {
+ double util_tot;
+ double util_sos;
int blocks_read;
int blocks_written;
int segs_cleaned;
@@ -68,7 +71,7 @@ struct cleaner_stats {
struct seglist {
int sl_id; /* segment number */
int sl_cost; /* cleaning cost */
- char sl_empty; /* is segment empty */
+ char sl_bytes; /* bytes in segment */
};
struct tossstruct {
@@ -76,6 +79,8 @@ struct tossstruct {
int seg;
};
+#define CLEAN_BYTES 0x1
+
/* function prototypes for system calls; not sure where they should go */
int lfs_segwait __P((fsid_t *, struct timeval *));
int lfs_segclean __P((fsid_t *, u_long));
@@ -86,8 +91,8 @@ int lfs_markv __P((fsid_t *, BLOCK_INFO *, int));
int bi_tossold __P((const void *, const void *, const void *));
int choose_segments __P((FS_INFO *, struct seglist *,
int (*)(FS_INFO *, SEGUSE *)));
-void clean_fs __P((FS_INFO *, int (*)(FS_INFO *, SEGUSE *)));
-int clean_loop __P((FS_INFO *));
+void clean_fs __P((FS_INFO *, int (*)(FS_INFO *, SEGUSE *), int, long));
+int clean_loop __P((FS_INFO *, int, long));
int clean_segment __P((FS_INFO *, int));
int cost_benefit __P((FS_INFO *, SEGUSE *));
int cost_compare __P((const void *, const void *));
@@ -152,22 +157,37 @@ main(argc, argv)
struct statfs *lstatfsp; /* file system stats */
struct timeval timeout; /* sleep timeout */
fsid_t fsid;
- int i, nodaemon;
+ long clean_opts; /* cleaning options */
+ int i, nodaemon, segs_per_clean;
int opt, cmd_err;
char *fs_name; /* name of filesystem to clean */
extern int optind;
cmd_err = nodaemon = 0;
- while ((opt = getopt(argc, argv, "smd")) != EOF) {
+ clean_opts = 0;
+ segs_per_clean = 1;
+ while ((opt = getopt(argc, argv, "bdmn:r:s")) != EOF) {
switch (opt) {
- case 's': /* small writes */
- do_small = 1;
+ case 'b': /*
+ * Use live bytes to determine
+ * how many segs to clean.
+ */
+ clean_opts |= CLEAN_BYTES;
break;
- case 'm':
+ case 'd': /* Debug mode. */
+ nodaemon = 1;
+ break;
+ case 'm': /* Use mmap instead of read/write */
do_mmap = 1;
break;
- case 'd':
- nodaemon = 1;
+ case 'n': /* How many segs to clean at once */
+ segs_per_clean = atoi(optarg);
+ break;
+ case 'r': /* Report every stat_report segments */
+ stat_report = atoi(optarg);
+ break;
+ case 's': /* small writes */
+ do_small = 1;
break;
default:
++cmd_err;
@@ -183,7 +203,7 @@ main(argc, argv)
signal(SIGINT, sig_report);
signal(SIGUSR1, sig_report);
signal(SIGUSR2, sig_report);
- if (fs_getmntinfo(&lstatfsp, fs_name, MOUNT_LFS) == 0) {
+ if (fs_getmntinfo(&lstatfsp, fs_name, "lfs") == 0) {
/* didn't find the filesystem */
err(1, "lfs_cleanerd: filesystem %s isn't an LFS!", fs_name);
}
@@ -205,7 +225,7 @@ main(argc, argv)
* to make sure that some nasty process hasn't just
* filled the disk system up.
*/
- if (clean_loop(fsp))
+ if (clean_loop(fsp, segs_per_clean, clean_opts))
continue;
#ifdef VERBOSE
@@ -221,30 +241,42 @@ main(argc, argv)
/* return the number of segments cleaned */
int
-clean_loop(fsp)
+clean_loop(fsp, nsegs, options)
FS_INFO *fsp; /* file system information */
+ int nsegs;
+ long options;
{
double loadavg[MAXLOADS];
time_t now;
u_long max_free_segs;
+ u_long db_per_seg;
/*
* Compute the maximum possible number of free segments, given the
* number of free blocks.
*/
- max_free_segs = fsp->fi_statfsp->f_bfree / fsp->fi_lfs.lfs_ssize;
+ db_per_seg = fsbtodb(&fsp->fi_lfs, fsp->fi_lfs.lfs_ssize);
+ max_free_segs = fsp->fi_lfs.lfs_bfree / db_per_seg;
/*
* We will clean if there are not enough free blocks or total clean
* space is less than BUSY_LIM % of possible clean space.
*/
now = time((time_t *)NULL);
- if (fsp->fi_cip->clean < max_free_segs &&
+#ifdef VERBOSE
+ printf("db_er_seg = %d max_free_segs = %d, bfree = %d avail = %d ",
+ db_per_seg, max_free_segs, fsp->fi_lfs.lfs_bfree,
+ fsp->fi_lfs.lfs_avail);
+ printf("clean = %d\n", fsp->fi_cip->clean);
+#endif
+ if ((fsp->fi_lfs.lfs_bfree - fsp->fi_lfs.lfs_avail > db_per_seg &&
+ fsp->fi_lfs.lfs_avail < db_per_seg) ||
+ (fsp->fi_cip->clean < max_free_segs &&
(fsp->fi_cip->clean <= MIN_SEGS(&fsp->fi_lfs) ||
- fsp->fi_cip->clean < max_free_segs * BUSY_LIM)) {
+ fsp->fi_cip->clean < max_free_segs * BUSY_LIM))) {
printf("Cleaner Running at %s (%d of %d segments available)\n",
ctime(&now), fsp->fi_cip->clean, max_free_segs);
- clean_fs(fsp, cost_benefit);
+ clean_fs(fsp, cost_benefit, nsegs, options);
return (1);
} else {
/*
@@ -258,7 +290,7 @@ clean_loop(fsp)
}
if (loadavg[ONE_MIN] == 0.0 && loadavg[FIVE_MIN] &&
fsp->fi_cip->clean < max_free_segs * IDLE_LIM) {
- clean_fs(fsp, cost_benefit);
+ clean_fs(fsp, cost_benefit, nsegs, options);
printf("Cleaner Running at %s (system idle)\n",
ctime(&now));
return (1);
@@ -270,11 +302,14 @@ clean_loop(fsp)
void
-clean_fs(fsp, cost_func)
+clean_fs(fsp, cost_func, nsegs, options)
FS_INFO *fsp; /* file system information */
int (*cost_func) __P((FS_INFO *, SEGUSE *));
+ int nsegs;
+ long options;
{
struct seglist *segs, *sp;
+ int to_clean, cleaned_bytes;
int i;
if ((segs =
@@ -288,15 +323,33 @@ clean_fs(fsp, cost_func)
i, fsp->fi_statfsp->f_mntonname);
fflush(stdout);
#endif
- if (i)
- for (i = MIN(i, NUM_TO_CLEAN(fsp)), sp = segs; i-- ; ++sp) {
- if (clean_segment(fsp, sp->sl_id) < 0)
- perror("clean_segment failed");
- else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
- sp->sl_id) < 0)
- perror("lfs_segclean failed");
- printf("Completed cleaning segment %d\n", sp->sl_id);
- }
+ if (i) {
+ /* Check which cleaning algorithm to use. */
+ if (options & CLEAN_BYTES) {
+ cleaned_bytes = 0;
+ to_clean = nsegs <<
+ (fsp->fi_lfs.lfs_segshift + fsp->fi_lfs.lfs_bshift);
+ for (sp = segs; i && cleaned_bytes < to_clean;
+ i--, ++sp) {
+ if (clean_segment(fsp, sp->sl_id) < 0)
+ perror("clean_segment failed");
+ else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
+ sp->sl_id) < 0)
+ perror("lfs_segclean failed");
+ printf("Cleaned segment %d (%d bytes)\n",
+ sp->sl_id, sp->sl_bytes);
+ cleaned_bytes += sp->sl_bytes;
+ }
+ } else
+ for (i = MIN(i, nsegs), sp = segs; i-- ; ++sp) {
+ if (clean_segment(fsp, sp->sl_id) < 0)
+ perror("clean_segment failed");
+ else if (lfs_segclean(&fsp->fi_statfsp->f_fsid,
+ sp->sl_id) < 0)
+ perror("lfs_segclean failed");
+ printf("Completed cleaning segment %d\n", sp->sl_id);
+ }
+ }
free(segs);
}
@@ -349,7 +402,7 @@ choose_segments(fsp, seglist, cost_func)
#endif
sp->sl_cost = (*cost_func)(fsp, sup);
sp->sl_id = i;
- sp->sl_empty = sup->su_nbytes ? 0 : 1;
+ sp->sl_bytes = sup->su_nbytes;
++sp;
}
nsegs = sp - seglist;
@@ -371,6 +424,7 @@ clean_segment(fsp, id)
struct lfs *lfsp;
struct tossstruct t;
caddr_t seg_buf;
+ double util;
int num_blocks, maxblocks, clean_blocks;
lfsp = &fsp->fi_lfs;
@@ -437,8 +491,14 @@ clean_segment(fsp, id)
lp = (u_long *)_bip->bi_bp;
}
}
+
#endif
+ ++cleaner_stats.segs_cleaned;
cleaner_stats.blocks_written += num_blocks;
+ util = ((double)num_blocks / fsp->fi_lfs.lfs_ssize);
+ cleaner_stats.util_tot += util;
+ cleaner_stats.util_sos += util * util;
+
if (do_small)
maxblocks = MAXPHYS / fsp->fi_lfs.lfs_bsize - 1;
else
@@ -457,7 +517,8 @@ clean_segment(fsp, id)
free(block_array);
munmap_segment(fsp, seg_buf, do_mmap);
- ++cleaner_stats.segs_cleaned;
+ if (stat_report && cleaner_stats.segs_cleaned % stat_report == 0)
+ sig_report(SIGUSR1);
return (0);
}
@@ -480,18 +541,30 @@ void
sig_report(sig)
int sig;
{
+ double avg;
+
printf("lfs_cleanerd:\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n\t\t%s%d\n",
"blocks_read ", cleaner_stats.blocks_read,
"blocks_written ", cleaner_stats.blocks_written,
"segs_cleaned ", cleaner_stats.segs_cleaned,
"segs_empty ", cleaner_stats.segs_empty,
"seg_error ", cleaner_stats.segs_error);
+ printf("\t\t%s%5.2f\n\t\t%s%5.2f\n",
+ "util_tot ", cleaner_stats.util_tot,
+ "util_sos ", cleaner_stats.util_sos);
+ printf("\t\tavg util: %4.2f std dev: %9.6f\n",
+ avg = cleaner_stats.util_tot / cleaner_stats.segs_cleaned,
+ cleaner_stats.util_sos / cleaner_stats.segs_cleaned - avg * avg);
+
+
if (sig == SIGUSR2) {
cleaner_stats.blocks_read = 0;
cleaner_stats.blocks_written = 0;
cleaner_stats.segs_cleaned = 0;
cleaner_stats.segs_empty = 0;
cleaner_stats.segs_error = 0;
+ cleaner_stats.util_tot = 0.0;
+ cleaner_stats.util_sos = 0.0;
}
if (sig == SIGINT)
exit(0);
diff --git a/libexec/lfs_cleanerd/library.c b/libexec/lfs_cleanerd/library.c
index b825a02..32f7d37 100644
--- a/libexec/lfs_cleanerd/library.c
+++ b/libexec/lfs_cleanerd/library.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)library.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)library.c 8.3 (Berkeley) 5/24/95";
#endif /* not lint */
#include <sys/param.h>
@@ -73,7 +73,7 @@ int
fs_getmntinfo(buf, name, type)
struct statfs **buf;
char *name;
- int type;
+ char *type;
{
/* allocate space for the filesystem info */
*buf = (struct statfs *)malloc(sizeof(struct statfs));
@@ -87,7 +87,7 @@ fs_getmntinfo(buf, name, type)
}
/* check to see if it's the one we want */
- if (((*buf)->f_type != type) ||
+ if (strcmp((*buf)->f_fstypename, type) ||
strncmp(name, (*buf)->f_mntonname, MNAMELEN)) {
/* "this is not the filesystem you're looking for */
free(*buf);
@@ -264,7 +264,7 @@ lfs_segmapv(fsp, seg, seg_buf, blocks, bcount)
struct lfs *lfsp;
caddr_t s, segend;
daddr_t pseg_addr, seg_addr;
- int i, nelem, nblocks, sumsize;
+ int i, nelem, nblocks, nsegs, sumsize;
time_t timestamp;
lfsp = &fsp->fi_lfs;
@@ -281,19 +281,22 @@ lfs_segmapv(fsp, seg, seg_buf, blocks, bcount)
#endif /* VERBOSE */
*bcount = 0;
- for (segend = seg_buf + seg_size(lfsp), timestamp = 0; s < segend; ) {
+ for (nsegs = 0, timestamp = 0; nsegs < sup->su_nsums; nsegs++) {
sp = (SEGSUM *)s;
+ nblocks = pseg_valid(fsp, sp);
+ if (nblocks <= 0) {
+ printf("Warning: invalid segment summary at 0x%x\n",
+ pseg_addr);
+ break;
+ }
+
#ifdef VERBOSE
printf("\tpartial at: 0x%x\n", pseg_addr);
print_SEGSUM(lfsp, sp);
fflush(stdout);
#endif /* VERBOSE */
- nblocks = pseg_valid(fsp, sp);
- if (nblocks <= 0)
- break;
-
/* Check if we have hit old data */
if (timestamp > ((SEGSUM*)s)->ss_create)
break;
@@ -303,7 +306,7 @@ lfs_segmapv(fsp, seg, seg_buf, blocks, bcount)
/* Verfiy size of summary block */
sumsize = sizeof(SEGSUM) +
(sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
- for (fip = (FINFO *)(sp + 1); i < sp->ss_nfinfo; ++i) {
+ for (i = 0, fip = (FINFO *)(sp + 1); i < sp->ss_nfinfo; ++i) {
sumsize += sizeof(FINFO) +
(fip->fi_nblocks - 1) * sizeof(daddr_t);
fip = (FINFO *)(&fip->fi_blocks[fip->fi_nblocks]);
@@ -368,7 +371,9 @@ add_blocks (fsp, bip, countp, sp, seg_buf, segaddr, psegaddr)
caddr_t bp;
daddr_t *dp, *iaddrp;
int db_per_block, i, j;
+ int db_frag;
u_long page_size;
+long *lp;
#ifdef VERBOSE
printf("FILE INFOS\n");
@@ -400,8 +405,24 @@ add_blocks (fsp, bip, countp, sp, seg_buf, segaddr, psegaddr)
bip->bi_segcreate = (time_t)(sp->ss_create);
bip->bi_bp = bp;
bip->bi_version = ifp->if_version;
- psegaddr += db_per_block;
- bp += page_size;
+ if (fip->fi_lastlength == page_size) {
+ bip->bi_size = page_size;
+ psegaddr += db_per_block;
+ bp += page_size;
+ } else {
+ db_frag = fragstodb(&(fsp->fi_lfs),
+ numfrags(&(fsp->fi_lfs),
+ fip->fi_lastlength));
+#ifdef VERBOSE
+ printf("lastlength, frags: %d, %d, %d\n",
+ fip->fi_lastlength, temp,
+ bytetoda(fsp, temp));
+ fflush(stdout);
+#endif
+ bip->bi_size = fip->fi_lastlength;
+ bp += fip->fi_lastlength;
+ psegaddr += db_frag;
+ }
++bip;
++(*countp);
}
@@ -486,6 +507,9 @@ pseg_valid (fsp, ssp)
int i, nblocks;
u_long *datap;
+ if (ssp->ss_magic != SS_MAGIC)
+ return(0);
+
if ((nblocks = dump_summary(&fsp->fi_lfs, ssp, 0, NULL)) <= 0 ||
nblocks > fsp->fi_lfs.lfs_ssize - 1)
return(0);
diff --git a/libexec/lfs_cleanerd/print.c b/libexec/lfs_cleanerd/print.c
index 5c3863a..2978a0c 100644
--- a/libexec/lfs_cleanerd/print.c
+++ b/libexec/lfs_cleanerd/print.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)print.c 8.2 (Berkeley) 5/24/95";
#endif /* not lint */
#include <sys/param.h>
@@ -65,22 +65,32 @@ dump_summary(lfsp, sp, flags, iaddrp)
FINFO *fp;
int ck;
+ if (sp->ss_magic != SS_MAGIC)
+ return(-1);
+
if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
LFS_SUMMARY_SIZE - sizeof(sp->ss_sumsum))))
return(-1);
+ numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
+
+ /* Do some basic sanity checking. */
+ if (sp->ss_nfinfo > LFS_SUMMARY_SIZE / sizeof(FINFO) ||
+ numblocks > lfsp->lfs_ssize ||
+ numblocks > LFS_SUMMARY_SIZE / sizeof(daddr_t))
+ return(-1);
+
if (flags & DUMP_SUM_HEADER) {
- (void)printf(" %s0x%X\t%s%d\t%s%d\n %s0x%X\t%s0x%X",
+ (void)printf(" %s0x%X\t%s%d\t%s%d\n %s0x%X\t%s0x%X\t%s0x%X\n",
"next ", sp->ss_next,
"nfinfo ", sp->ss_nfinfo,
"ninos ", sp->ss_ninos,
"sumsum ", sp->ss_sumsum,
- "datasum ", sp->ss_datasum );
- (void)printf("\tcreate %s", ctime((time_t *)&sp->ss_create));
+ "datasum ", sp->ss_datasum,
+ "magic ", sp->ss_magic);
+ (void)printf(" create %s", ctime((time_t *)&sp->ss_create));
}
- numblocks = (sp->ss_ninos + INOPB(lfsp) - 1) / INOPB(lfsp);
-
/* Dump out inode disk addresses */
if (flags & DUMP_INODE_ADDRS)
printf(" Inode addresses:");
@@ -161,13 +171,13 @@ dump_super(lfsp)
"cleansz ", lfsp->lfs_cleansz,
"segtabsz ", lfsp->lfs_segtabsz);
- (void)printf("%s0x%X\t%s%d\t%s0x%X\t%s%d\n",
+ (void)printf("%s0x%X\t%s%d\t%s0x%qX\t%s%d\n",
"segmask ", lfsp->lfs_segmask,
"segshift ", lfsp->lfs_segshift,
"bmask ", lfsp->lfs_bmask,
"bshift ", lfsp->lfs_bshift);
- (void)printf("%s0x%X\t\t%s%d\t%s0x%X\t%s%d\n",
+ (void)printf("%s0x%qX\t\t%s%d\t%s0x%qX\t%s%d\n",
"ffmask ", lfsp->lfs_ffmask,
"ffshift ", lfsp->lfs_ffshift,
"fbmask ", lfsp->lfs_fbmask,
diff --git a/libexec/mail.local/Makefile.dist b/libexec/mail.local/Makefile.dist
new file mode 100644
index 0000000..25c4924
--- /dev/null
+++ b/libexec/mail.local/Makefile.dist
@@ -0,0 +1,14 @@
+# @(#)Makefile.dist 8.1 (Berkeley) 10/17/94
+
+BINDIR= ${DESTDIR}/usr/lib
+BINOWN= root
+BINMODE=4555
+
+mail.local: mail.local.c
+ ${CC} -O -o mail.local mail.local.c
+
+install: mail.local
+ install -s -o ${BINOWN} -m ${BINMODE} mail.local ${BINDIR}
+
+clean:
+ rm -f mail.local core a.out
diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c
index 0de8978..1ee4466 100644
--- a/libexec/mail.local/mail.local.c
+++ b/libexec/mail.local/mail.local.c
@@ -38,9 +38,18 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)mail.local.c 8.6 (Berkeley) 4/8/94";
+static char sccsid[] = "@(#)mail.local.c 8.22 (Berkeley) 6/21/95";
#endif /* not lint */
+/*
+ * This is not intended to compile on System V derived systems
+ * such as Solaris or HP-UX, since they use a totally different
+ * approach to mailboxes (essentially, they have a setgid program
+ * rather than setuid, and they rely on the ability to "give away"
+ * files to do their work). IT IS NOT A BUG that this doesn't
+ * compile on such architectures.
+ */
+
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -58,6 +67,7 @@ static char sccsid[] = "@(#)mail.local.c 8.6 (Berkeley) 4/8/94";
#include <syslog.h>
#include <time.h>
#include <unistd.h>
+#include <ctype.h>
#if __STDC__
#include <stdarg.h>
@@ -65,7 +75,55 @@ static char sccsid[] = "@(#)mail.local.c 8.6 (Berkeley) 4/8/94";
#include <varargs.h>
#endif
-#include "pathnames.h"
+#ifndef LOCK_EX
+# include <sys/file.h>
+#endif
+
+#ifdef BSD4_4
+# include "pathnames.h"
+#endif
+
+#ifndef __P
+# ifdef __STDC__
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# define const
+# endif
+#endif
+#ifndef __dead
+# if defined(__GNUC__) && (__GNUC__ < 2 || __GNUC_MINOR__ < 5) && !defined(__STRICT_ANSI__)
+# define __dead __volatile
+# else
+# define __dead
+# endif
+#endif
+
+#ifndef BSD4_4
+# define _BSD_VA_LIST_ va_list
+extern char *strerror __P((int));
+extern int snprintf __P((char *, int, const char *, ...));
+#endif
+
+/*
+ * If you don't have setreuid, and you have saved uids, and you have
+ * a seteuid() call that doesn't try to emulate using setuid(), then
+ * you can try defining USE_SETEUID.
+ */
+#ifdef USE_SETEUID
+# define setreuid(r, e) seteuid(e)
+#endif
+
+#ifndef _PATH_LOCTMP
+# define _PATH_LOCTMP "/tmp/local.XXXXXX"
+#endif
+#ifndef _PATH_MAILDIR
+# define _PATH_MAILDIR "/var/spool/mail"
+#endif
+
+#ifndef S_ISREG
+# define S_ISREG(mode) (((mode) & _S_IFMT) == S_IFREG)
+#endif
int eval = EX_OK; /* sysexits.h error value. */
@@ -87,8 +145,21 @@ main(argc, argv)
int ch, fd;
uid_t uid;
char *from;
+ extern char *optarg;
+ extern int optind;
+
+ /* make sure we have some open file descriptors */
+ for (fd = 10; fd < 30; fd++)
+ (void) close(fd);
+
+ /* use a reasonable umask */
+ (void) umask(0077);
+#ifdef LOG_MAIL
openlog("mail.local", 0, LOG_MAIL);
+#else
+ openlog("mail.local", 0);
+#endif
from = NULL;
while ((ch = getopt(argc, argv, "df:r:")) != EOF)
@@ -144,15 +215,15 @@ store(from)
FILE *fp;
time_t tval;
int fd, eline;
- char *tn, line[2048];
+ char line[2048];
+ char tmpbuf[sizeof _PATH_LOCTMP + 1];
- tn = strdup(_PATH_LOCTMP);
- if ((fd = mkstemp(tn)) == -1 || (fp = fdopen(fd, "w+")) == NULL) {
+ strcpy(tmpbuf, _PATH_LOCTMP);
+ if ((fd = mkstemp(tmpbuf)) == -1 || (fp = fdopen(fd, "w+")) == NULL) {
e_to_sys(errno);
err("unable to open temporary file");
}
- (void)unlink(tn);
- free(tn);
+ (void)unlink(tmpbuf);
(void)time(&tval);
(void)fprintf(fp, "From %s %s", from, ctime(&tval));
@@ -195,6 +266,7 @@ deliver(fd, name)
struct stat fsb, sb;
struct passwd *pw;
int mbfd, nr, nw, off;
+ char *p;
char biffmsg[100], buf[8*1024], path[MAXPATHLEN];
off_t curoff;
@@ -208,6 +280,25 @@ deliver(fd, name)
warn("unknown name: %s", name);
return;
}
+ endpwent();
+
+ /*
+ * Keep name reasonably short to avoid buffer overruns.
+ * This isn't necessary on BSD because of the proper
+ * definition of snprintf(), but it can cause problems
+ * on other systems.
+ * Also, clear out any bogus characters.
+ */
+
+ if (strlen(name) > 40)
+ name[40] = '\0';
+ for (p = name; *p != '\0'; p++)
+ {
+ if (!isascii(*p))
+ *p &= 0x7f;
+ else if (!isprint(*p))
+ *p = '.';
+ }
(void)snprintf(path, sizeof(path), "%s/%s", _PATH_MAILDIR, name);
@@ -233,6 +324,7 @@ deliver(fd, name)
* open(2) should support flock'ing the file.
*/
tryagain:
+ lockmbox(path);
if (lstat(path, &sb)) {
mbfd = open(path,
O_APPEND|O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR);
@@ -242,28 +334,31 @@ tryagain:
} else if (fchown(mbfd, pw->pw_uid, pw->pw_gid)) {
e_to_sys(errno);
warn("chown %u.%u: %s", pw->pw_uid, pw->pw_gid, name);
- return;
+ goto err1;
}
- } else if (sb.st_nlink != 1 || S_ISLNK(sb.st_mode)) {
+ } else if (sb.st_nlink != 1 || !S_ISREG(sb.st_mode)) {
e_to_sys(errno);
- warn("%s: linked file", path);
+ warn("%s: irregular file", path);
+ goto err0;
+ } else if (sb.st_uid != pw->pw_uid) {
+ warn("%s: wrong ownership (%d)", path, sb.st_uid);
+ unlockmbox();
return;
} else {
mbfd = open(path, O_APPEND|O_WRONLY, 0);
if (mbfd != -1 &&
(fstat(mbfd, &fsb) || fsb.st_nlink != 1 ||
- S_ISLNK(fsb.st_mode) || sb.st_dev != fsb.st_dev ||
- sb.st_ino != fsb.st_ino)) {
+ !S_ISREG(fsb.st_mode) || sb.st_dev != fsb.st_dev ||
+ sb.st_ino != fsb.st_ino || sb.st_uid != fsb.st_uid)) {
warn("%s: file changed after open", path);
- (void)close(mbfd);
- return;
+ goto err1;
}
}
if (mbfd == -1) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
- return;
+ goto err0;
}
/* Wait until we can get a lock on the file. */
@@ -275,7 +370,9 @@ tryagain:
/* Get the starting offset of the new message for biff. */
curoff = lseek(mbfd, (off_t)0, SEEK_END);
- (void)snprintf(biffmsg, sizeof(biffmsg), "%s@%qd\n", name, curoff);
+ (void)snprintf(biffmsg, sizeof(biffmsg),
+ sizeof curoff > sizeof(long) ? "%s@%qd\n" : "%s@%ld\n",
+ name, curoff);
/* Copy the message into the file. */
if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
@@ -283,25 +380,43 @@ tryagain:
warn("temporary file: %s", strerror(errno));
goto err1;
}
+ if (setreuid(0, pw->pw_uid) < 0) {
+ e_to_sys(errno);
+ warn("setreuid(0, %d): %s (r=%d, e=%d)",
+ pw->pw_uid, strerror(errno), getuid(), geteuid());
+ goto err1;
+ }
+#ifdef DEBUG
+ printf("new euid = %d\n", geteuid());
+#endif
while ((nr = read(fd, buf, sizeof(buf))) > 0)
- for (off = 0; off < nr; nr -= nw, off += nw)
- if ((nw = write(mbfd, buf + off, nr)) < 0) {
+ for (off = 0; off < nr; off += nw)
+ if ((nw = write(mbfd, buf + off, nr - off)) < 0) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
- goto err2;;
+ goto err3;
}
if (nr < 0) {
e_to_sys(errno);
warn("temporary file: %s", strerror(errno));
- goto err2;;
+ goto err3;
}
/* Flush to disk, don't wait for update. */
if (fsync(mbfd)) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
+err3:
+ if (setreuid(0, 0) < 0) {
+ e_to_sys(errno);
+ warn("setreuid(0, 0): %s", strerror(errno));
+ }
+#ifdef DEBUG
+ printf("reset euid = %d\n", geteuid());
+#endif
err2: (void)ftruncate(mbfd, curoff);
err1: (void)close(mbfd);
+err0: unlockmbox();
return;
}
@@ -309,12 +424,71 @@ err1: (void)close(mbfd);
if (close(mbfd)) {
e_to_sys(errno);
warn("%s: %s", path, strerror(errno));
+ unlockmbox();
return;
}
+ if (setreuid(0, 0) < 0) {
+ e_to_sys(errno);
+ warn("setreuid(0, 0): %s", strerror(errno));
+ }
+#ifdef DEBUG
+ printf("reset euid = %d\n", geteuid());
+#endif
+ unlockmbox();
notifybiff(biffmsg);
}
+/*
+ * user.lock files are necessary for compatibility with other
+ * systems, e.g., when the mail spool file is NFS exported.
+ * Alas, mailbox locking is more than just a local matter.
+ * EPA 11/94.
+ */
+
+char lockname[MAXPATHLEN];
+int locked = 0;
+
+lockmbox(path)
+ char *path;
+{
+ int statfailed = 0;
+
+ if (locked)
+ return;
+ sprintf(lockname, "%s.lock", path);
+ for (;; sleep(5)) {
+ int fd;
+ struct stat st;
+ time_t now;
+
+ fd = open(lockname, O_WRONLY|O_EXCL|O_CREAT, 0);
+ if (fd >= 0) {
+ locked = 1;
+ close(fd);
+ return;
+ }
+ if (stat(lockname, &st) < 0) {
+ if (statfailed++ > 5)
+ return;
+ continue;
+ }
+ statfailed = 0;
+ time(&now);
+ if (now < st.st_ctime + 300)
+ continue;
+ unlink(lockname);
+ }
+}
+
+unlockmbox()
+{
+ if (!locked)
+ return;
+ unlink(lockname);
+ locked = 0;
+}
+
void
notifybiff(msg)
char *msg;
@@ -334,7 +508,7 @@ notifybiff(msg)
return;
}
addr.sin_family = hp->h_addrtype;
- memmove(&addr.sin_addr, hp->h_addr, hp->h_length);
+ memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
addr.sin_port = sp->s_port;
}
if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
@@ -413,8 +587,17 @@ vwarn(fmt, ap)
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, "\n");
+#if !defined(ultrix) && !defined(__osf__)
/* Log the message to syslog. */
vsyslog(LOG_ERR, fmt, ap);
+#else
+ {
+ char fmtbuf[10240];
+
+ (void) sprintf(fmtbuf, fmt, ap);
+ syslog(LOG_ERR, "%s", fmtbuf);
+ }
+#endif
}
/*
@@ -499,7 +682,7 @@ e_to_sys(num)
#ifdef ETIMEDOUT
case ETIMEDOUT: /* Connection timed out */
#endif
-#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN && EWOULDBLOCK != EDEADLK
case EWOULDBLOCK: /* Operation would block. */
#endif
eval = EX_TEMPFAIL;
@@ -509,3 +692,177 @@ e_to_sys(num)
break;
}
}
+
+#ifndef BSD4_4
+
+# ifndef __osf__
+char *
+strerror(eno)
+ int eno;
+{
+ extern int sys_nerr;
+ extern char *sys_errlist[];
+ static char ebuf[60];
+
+ if (eno >= 0 && eno <= sys_nerr)
+ return sys_errlist[eno];
+ (void) sprintf(ebuf, "Error %d", eno);
+ return ebuf;
+}
+# endif
+
+# if __STDC__
+snprintf(char *buf, int bufsiz, const char *fmt, ...)
+# else
+snprintf(buf, bufsiz, fmt, va_alist)
+ char *buf;
+ int bufsiz;
+ const char *fmt;
+ va_dcl
+# endif
+{
+ va_list ap;
+
+# if __STDC__
+ va_start(ap, fmt);
+# else
+ va_start(ap);
+# endif
+ vsprintf(buf, fmt, ap);
+ va_end(ap);
+}
+
+#endif
+
+#ifdef ultrix
+
+/*
+ * Copyright (c) 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+
+static int _gettemp();
+
+mkstemp(path)
+ char *path;
+{
+ int fd;
+
+ return (_gettemp(path, &fd) ? fd : -1);
+}
+
+/*
+char *
+mktemp(path)
+ char *path;
+{
+ return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
+}
+*/
+
+static
+_gettemp(path, doopen)
+ char *path;
+ register int *doopen;
+{
+ extern int errno;
+ register char *start, *trv;
+ struct stat sbuf;
+ u_int pid;
+
+ pid = getpid();
+ for (trv = path; *trv; ++trv); /* extra X's get set to 0's */
+ while (*--trv == 'X') {
+ *trv = (pid % 10) + '0';
+ pid /= 10;
+ }
+
+ /*
+ * check the target directory; if you have six X's and it
+ * doesn't exist this runs for a *very* long time.
+ */
+ for (start = trv + 1;; --trv) {
+ if (trv <= path)
+ break;
+ if (*trv == '/') {
+ *trv = '\0';
+ if (stat(path, &sbuf))
+ return(0);
+ if (!S_ISDIR(sbuf.st_mode)) {
+ errno = ENOTDIR;
+ return(0);
+ }
+ *trv = '/';
+ break;
+ }
+ }
+
+ for (;;) {
+ if (doopen) {
+ if ((*doopen =
+ open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+ return(1);
+ if (errno != EEXIST)
+ return(0);
+ }
+ else if (stat(path, &sbuf))
+ return(errno == ENOENT ? 1 : 0);
+
+ /* tricky little algorithm for backward compatibility */
+ for (trv = start;;) {
+ if (!*trv)
+ return(0);
+ if (*trv == 'z')
+ *trv++ = 'a';
+ else {
+ if (isdigit(*trv))
+ *trv = 'a';
+ else
+ ++*trv;
+ break;
+ }
+ }
+ }
+ /*NOTREACHED*/
+}
+
+#endif
diff --git a/libexec/rexecd/rexecd.8 b/libexec/rexecd/rexecd.8
index 2dda22b..3035900 100644
--- a/libexec/rexecd/rexecd.8
+++ b/libexec/rexecd/rexecd.8
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rexecd.8 8.2 (Berkeley) 12/11/93
+.\" @(#)rexecd.8 8.3 (Berkeley) 6/1/94
.\"
-.Dd December 11, 1993
+.Dd June 1, 1994
.Dt REXECD 8
.Os BSD 4.2
.Sh NAME
@@ -117,6 +117,7 @@ list (as configured into the system).
No password file entry for the user name existed.
.It Sy Password incorrect.
The wrong password was supplied.
+.ne 1i
.It Sy \&No remote directory.
The
.Xr chdir
diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c
index 6f5f5e1..80d53d5 100644
--- a/libexec/rlogind/rlogind.c
+++ b/libexec/rlogind/rlogind.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)rlogind.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
/*
@@ -302,11 +302,11 @@ doit(f, fromp)
hostname);
#endif
- execl(_PATH_LOGIN, "login", "-p",
- "-h", hostname, "-f", lusername, (char *)NULL);
+ execle(_PATH_LOGIN, "login", "-p",
+ "-h", hostname, "-f", "--", lusername, NULL, env);
} else
- execl(_PATH_LOGIN, "login", "-p",
- "-h", hostname, lusername, (char *)NULL);
+ execle(_PATH_LOGIN, "login", "-p",
+ "-h", hostname, "--", lusername, NULL, env);
fatal(STDERR_FILENO, _PATH_LOGIN, 1);
/*NOTREACHED*/
}
@@ -348,7 +348,7 @@ control(pty, cp, n)
if (n < 4+sizeof (w) || cp[2] != 's' || cp[3] != 's')
return (0);
oobdata[0] &= ~TIOCPKT_WINDOW; /* we know he heard */
- bcopy(cp+4, (char *)&w, sizeof(w));
+ memmove(&w, cp+4, sizeof(w));
w.ws_row = ntohs(w.ws_row);
w.ws_col = ntohs(w.ws_col);
w.ws_xpixel = ntohs(w.ws_xpixel);
@@ -596,8 +596,6 @@ getstr(buf, cnt, errmsg)
} while (c != 0);
}
-extern char **environ;
-
void
setup_term(fd)
int fd;
@@ -636,7 +634,6 @@ setup_term(fd)
env[0] = term;
env[1] = 0;
- environ = env;
}
#ifdef KERBEROS
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c
index e8c9915..7c99ea4 100644
--- a/libexec/talkd/announce.c
+++ b/libexec/talkd/announce.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94";
+static char sccsid[] = "@(#)announce.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@@ -48,6 +48,7 @@ static char sccsid[] = "@(#)announce.c 8.2 (Berkeley) 1/7/94";
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <vis.h>
#include <paths.h>
extern char hostname[];
@@ -77,7 +78,7 @@ announce(request, remote_machine)
#define max(a,b) ( (a) > (b) ? (a) : (b) )
#define N_LINES 5
-#define N_CHARS 120
+#define N_CHARS 256
/*
* Build a block of characters containing the message.
@@ -99,7 +100,7 @@ print_mesg(tty, tf, request, remote_machine)
char line_buf[N_LINES][N_CHARS];
int sizes[N_LINES];
char big_buf[N_LINES*N_CHARS];
- char *bptr, *lptr, *ttymsg();
+ char *bptr, *lptr, *vis_user;
int i, j, max_size;
i = 0;
@@ -115,13 +116,15 @@ print_mesg(tty, tf, request, remote_machine)
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
+ vis_user = (char *) malloc(strlen(request->l_name) * 4 + 1);
+ strvis(vis_user, request->l_name, VIS_CSTYLE);
(void)sprintf(line_buf[i], "talk: connection requested by %s@%s",
- request->l_name, remote_machine);
+ vis_user, remote_machine);
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
(void)sprintf(line_buf[i], "talk: respond with: talk %s@%s",
- request->l_name, remote_machine);
+ vis_user, remote_machine);
sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]);
i++;
diff --git a/libexec/telnetd/authenc.c b/libexec/telnetd/authenc.c
new file mode 100644
index 0000000..ccb463c
--- /dev/null
+++ b/libexec/telnetd/authenc.c
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 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.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
+#endif /* not lint */
+
+#if defined(AUTHENTICATION) || defined(ENCRYPTION)
+#include "telnetd.h"
+#include <libtelnet/misc.h>
+
+ int
+net_write(str, len)
+ unsigned char *str;
+ int len;
+{
+ if (nfrontp + len < netobuf + BUFSIZ) {
+ memmove((void *)nfrontp, (void *)str, len);
+ nfrontp += len;
+ return(len);
+ }
+ return(0);
+}
+
+ void
+net_encrypt()
+{
+#ifdef ENCRYPTION
+ char *s = (nclearto > nbackp) ? nclearto : nbackp;
+ if (s < nfrontp && encrypt_output) {
+ (*encrypt_output)((unsigned char *)s, nfrontp - s);
+ }
+ nclearto = nfrontp;
+#endif /* ENCRYPTION */
+}
+
+ int
+telnet_spin()
+{
+ ttloop();
+ return(0);
+}
+
+ char *
+telnet_getenv(val)
+ char *val;
+{
+ extern char *getenv();
+ return(getenv(val));
+}
+
+ char *
+telnet_gets(prompt, result, length, echo)
+ char *prompt;
+ char *result;
+ int length;
+ int echo;
+{
+ return((char *)0);
+}
+#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
diff --git a/libexec/telnetd/slc.c b/libexec/telnetd/slc.c
index 145746a..6cbb7ab 100644
--- a/libexec/telnetd/slc.c
+++ b/libexec/telnetd/slc.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)slc.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -109,10 +109,10 @@ get_slc_defaults()
init_termbuf();
for (i = 1; i <= NSLC; i++) {
- slctab[i].defset.flag =
+ slctab[i].defset.flag =
spcset(i, &slctab[i].defset.val, &slctab[i].sptr);
- slctab[i].current.flag = SLC_NOSUPPORT;
- slctab[i].current.val = 0;
+ slctab[i].current.flag = SLC_NOSUPPORT;
+ slctab[i].current.val = 0;
}
} /* end of get_slc_defaults */
@@ -286,7 +286,7 @@ change_slc(func, flag, val)
register cc_t val;
{
register int hislevel, mylevel;
-
+
hislevel = flag & SLC_LEVELBITS;
mylevel = slctab[func].defset.flag & SLC_LEVELBITS;
/*
@@ -345,7 +345,7 @@ change_slc(func, flag, val)
* request as he asks.
*
* If our level is DEFAULT, then just ack whatever was
- * sent.
+ * sent.
*
* If he can't change and we can't change,
* then degenerate to NOSUPPORT.
@@ -372,7 +372,6 @@ change_slc(func, flag, val)
slctab[func].defset.val;
val = slctab[func].current.val;
}
-
}
add_slc(func, flag, val);
}
@@ -423,7 +422,6 @@ check_slc()
slctab[i].current.val);
}
}
-
} /* check_slc */
/*
@@ -465,7 +463,7 @@ do_opt_slc(ptr, len)
def_slcbuf = (unsigned char *)malloc((unsigned)len);
if (def_slcbuf == (unsigned char *)0)
return; /* too bad */
- bcopy(ptr, def_slcbuf, len);
+ memmove(def_slcbuf, ptr, len);
}
}
diff --git a/libexec/telnetd/state.c b/libexec/telnetd/state.c
index 2d327a5..4ee8bea 100644
--- a/libexec/telnetd/state.c
+++ b/libexec/telnetd/state.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)state.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -366,7 +366,7 @@ gotiac: switch (c) {
char xbuf2[BUFSIZ];
register char *cp;
int n = pfrontp - opfrontp, oc;
- bcopy(opfrontp, xptyobuf, n);
+ memmove(xptyobuf, opfrontp, n);
pfrontp = opfrontp;
pfrontp += term_input(xptyobuf, pfrontp, n, BUFSIZ+NETSLOP,
xbuf2, &oc, BUFSIZ);
@@ -388,7 +388,7 @@ gotiac: switch (c) {
* All state defaults are negative, and resp defaults to 0.
*
* When initiating a request to change state to new_state:
- *
+ *
* if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
* do nothing;
* } else {
@@ -716,7 +716,6 @@ wontoption(option)
*/
if (lmodetype != REAL_LINEMODE)
break;
- lmodetype = KLUDGE_LINEMODE;
# endif /* KLUDGELINEMODE */
clientstat(TELOPT_LINEMODE, WONT, 0);
break;
@@ -1520,8 +1519,8 @@ doclientstat()
clientstat(TELOPT_LINEMODE, WILL, 0);
}
-#define ADD(c) *ncp++ = c;
-#define ADD_DATA(c) { *ncp++ = c; if (c == SE) *ncp++ = c; }
+#define ADD(c) *ncp++ = c
+#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
void
send_status()
{
@@ -1550,14 +1549,10 @@ send_status()
if (my_want_state_is_will(i)) {
ADD(WILL);
ADD_DATA(i);
- if (i == IAC)
- ADD(IAC);
}
if (his_want_state_is_will(i)) {
ADD(DO);
ADD_DATA(i);
- if (i == IAC)
- ADD(IAC);
}
}
@@ -1572,15 +1567,14 @@ send_status()
ADD(SE);
if (restartany >= 0) {
- ADD(SB)
+ ADD(SB);
ADD(TELOPT_LFLOW);
if (restartany) {
ADD(LFLOW_RESTART_ANY);
} else {
ADD(LFLOW_RESTART_XON);
}
- ADD(SE)
- ADD(SB);
+ ADD(SE);
}
}
@@ -1593,8 +1587,6 @@ send_status()
ADD(TELOPT_LINEMODE);
ADD(LM_MODE);
ADD_DATA(editmode);
- if (editmode == IAC)
- ADD(IAC);
ADD(SE);
ADD(SB);
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c
index 1e50216..58d2e98 100644
--- a/libexec/telnetd/sys_term.c
+++ b/libexec/telnetd/sys_term.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)sys_term.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)sys_term.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -69,21 +69,16 @@ char wtmpf[] = "/etc/wtmp";
# ifdef CRAY
#include <tmpdir.h>
#include <sys/wait.h>
-# if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
- /*
- * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
- * use it to tell us to turn off all the socket security code,
- * since that is only used in UNICOS 7.0 and later.
- */
-# undef _SC_CRAY_SECURE_SYS
+# if (UNICOS_LVL == '7.0') || (UNICOS_LVL == '7.1')
+# define UNICOS7x
# endif
-# if defined(_SC_CRAY_SECURE_SYS)
+# ifdef UNICOS7x
#include <sys/sysv.h>
#include <sys/secstat.h>
extern int secflag;
extern struct sysv sysv;
-# endif /* _SC_CRAY_SECURE_SYS */
+# endif /* UNICOS7x */
# endif /* CRAY */
#endif /* NEWINIT */
@@ -215,7 +210,7 @@ copy_termbuf(cp, len)
{
if (len > sizeof(termbuf))
len = sizeof(termbuf);
- bcopy(cp, (char *)&termbuf, len);
+ memmove((char *)&termbuf, cp, len);
termbuf2 = termbuf;
}
#endif /* defined(LINEMODE) && defined(TIOCPKT_IOCTL) */
@@ -227,17 +222,19 @@ set_termbuf()
* Only make the necessary changes.
*/
#ifndef USE_TERMIO
- if (bcmp((char *)&termbuf.sg, (char *)&termbuf2.sg, sizeof(termbuf.sg)))
+ if (memcmp((char *)&termbuf.sg, (char *)&termbuf2.sg,
+ sizeof(termbuf.sg)))
(void) ioctl(pty, TIOCSETN, (char *)&termbuf.sg);
- if (bcmp((char *)&termbuf.tc, (char *)&termbuf2.tc, sizeof(termbuf.tc)))
+ if (memcmp((char *)&termbuf.tc, (char *)&termbuf2.tc,
+ sizeof(termbuf.tc)))
(void) ioctl(pty, TIOCSETC, (char *)&termbuf.tc);
- if (bcmp((char *)&termbuf.ltc, (char *)&termbuf2.ltc,
+ if (memcmp((char *)&termbuf.ltc, (char *)&termbuf2.ltc,
sizeof(termbuf.ltc)))
(void) ioctl(pty, TIOCSLTC, (char *)&termbuf.ltc);
if (termbuf.lflags != termbuf2.lflags)
(void) ioctl(pty, TIOCLSET, (char *)&termbuf.lflags);
#else /* USE_TERMIO */
- if (bcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
+ if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
# ifdef STREAMSPTY
(void) tcsetattr(ttyfd, TCSANOW, &termbuf);
# else
@@ -943,40 +940,87 @@ tty_iscrnl()
}
/*
+ * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
+ */
+#if B4800 != 4800
+#define DECODE_BAUD
+#endif
+
+#ifdef DECODE_BAUD
+
+/*
* A table of available terminal speeds
*/
struct termspeeds {
int speed;
int value;
} termspeeds[] = {
- { 0, B0 }, { 50, B50 }, { 75, B75 },
- { 110, B110 }, { 134, B134 }, { 150, B150 },
- { 200, B200 }, { 300, B300 }, { 600, B600 },
- { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
- { 4800, B4800 }, { 9600, B9600 }, { 19200, B9600 },
- { 38400, B9600 }, { -1, B9600 }
+ { 0, B0 }, { 50, B50 }, { 75, B75 },
+ { 110, B110 }, { 134, B134 }, { 150, B150 },
+ { 200, B200 }, { 300, B300 }, { 600, B600 },
+ { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
+ { 4800, B4800 },
+#ifdef B7200
+ { 7200, B7200 },
+#endif
+ { 9600, B9600 },
+#ifdef B14400
+ { 14400, B14400 },
+#endif
+#ifdef B19200
+ { 19200, B19200 },
+#endif
+#ifdef B28800
+ { 28800, B28800 },
+#endif
+#ifdef B38400
+ { 38400, B38400 },
+#endif
+#ifdef B57600
+ { 57600, B57600 },
+#endif
+#ifdef B115200
+ { 115200, B115200 },
+#endif
+#ifdef B230400
+ { 230400, B230400 },
+#endif
+ { -1, 0 }
};
+#endif /* DECODE_BUAD */
void
tty_tspeed(val)
int val;
{
+#ifdef DECODE_BAUD
register struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
+ if (tp->speed == -1) /* back up to last valid value */
+ --tp;
cfsetospeed(&termbuf, tp->value);
+#else /* DECODE_BUAD */
+ cfsetospeed(&termbuf, val);
+#endif /* DECODE_BUAD */
}
void
tty_rspeed(val)
int val;
{
+#ifdef DECODE_BAUD
register struct termspeeds *tp;
for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
;
+ if (tp->speed == -1) /* back up to last valid value */
+ --tp;
cfsetispeed(&termbuf, tp->value);
+#else /* DECODE_BAUD */
+ cfsetispeed(&termbuf, val);
+#endif /* DECODE_BAUD */
}
#if defined(CRAY2) && defined(UNICOS5)
@@ -1076,7 +1120,7 @@ getptyslave()
#ifdef USE_TERMIO
ttyfd = t;
#endif
- if (ioctl(t, I_PUSH, "ptem") < 0)
+ if (ioctl(t, I_PUSH, "ptem") < 0)
fatal(net, "I_PUSH ptem");
if (ioctl(t, I_PUSH, "ldterm") < 0)
fatal(net, "I_PUSH ldterm");
@@ -1092,7 +1136,7 @@ getptyslave()
init_termbuf();
# ifdef TIOCGWINSZ
if (def_row || def_col) {
- bzero((char *)&ws, sizeof(ws));
+ memset((char *)&ws, 0, sizeof(ws));
ws.ws_col = def_col;
ws.ws_row = def_row;
(void)ioctl(t, TIOCSWINSZ, (char *)&ws);
@@ -1172,9 +1216,9 @@ cleanopen(line)
char *line;
{
register int t;
-#if defined(_SC_CRAY_SECURE_SYS)
+#ifdef UNICOS7x
struct secstat secbuf;
-#endif /* _SC_CRAY_SECURE_SYS */
+#endif /* UNICOS7x */
#ifndef STREAMSPTY
/*
@@ -1188,7 +1232,7 @@ cleanopen(line)
# if !defined(CRAY) && (BSD > 43)
(void) revoke(line);
# endif
-#if defined(_SC_CRAY_SECURE_SYS)
+#ifdef UNICOS7x
if (secflag) {
if (secstat(line, &secbuf) < 0)
return(-1);
@@ -1197,18 +1241,18 @@ cleanopen(line)
if (setucmp(secbuf.st_compart) < 0)
return(-1);
}
-#endif /* _SC_CRAY_SECURE_SYS */
+#endif /* UNICOS7x */
t = open(line, O_RDWR|O_NOCTTY);
-#if defined(_SC_CRAY_SECURE_SYS)
+#ifdef UNICOS7x
if (secflag) {
if (setulvl(sysv.sy_minlvl) < 0)
return(-1);
if (setucmp(0) < 0)
return(-1);
}
-#endif /* _SC_CRAY_SECURE_SYS */
+#endif /* UNICOS7x */
if (t < 0)
return(-1);
@@ -1231,9 +1275,8 @@ cleanopen(line)
(void) signal(SIGHUP, SIG_IGN);
(void) ioctl(t, TCVHUP, (char *)0);
(void) signal(SIGHUP, SIG_DFL);
- setpgrp();
-#if defined(_SC_CRAY_SECURE_SYS)
+#ifdef UNICOS7x
if (secflag) {
if (secstat(line, &secbuf) < 0)
return(-1);
@@ -1242,18 +1285,18 @@ cleanopen(line)
if (setucmp(secbuf.st_compart) < 0)
return(-1);
}
-#endif /* _SC_CRAY_SECURE_SYS */
+#endif /* UNICOS7x */
i = open(line, O_RDWR);
-#if defined(_SC_CRAY_SECURE_SYS)
+#ifdef UNICOS7x
if (secflag) {
if (setulvl(sysv.sy_minlvl) < 0)
return(-1);
if (setucmp(0) < 0)
return(-1);
}
-#endif /* _SC_CRAY_SECURE_SYS */
+#endif /* UNICOS7x */
if (i < 0)
return(-1);
@@ -1302,7 +1345,11 @@ login_tty(t)
* setsid() call above may have set our pgrp, so clear
* it out before opening the tty...
*/
+# ifndef SOLARIS
(void) setpgrp(0, 0);
+# else
+ (void) setpgrp();
+# endif
close(open(line, O_RDWR));
# endif
if (t != 0)
@@ -1513,7 +1560,7 @@ start_login(host, autologin, name)
* Create utmp entry for child
*/
- bzero(&utmpx, sizeof(utmpx));
+ memset(&utmpx, 0, sizeof(utmpx));
SCPYN(utmpx.ut_user, ".telnet");
SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
utmpx.ut_pid = pid;
@@ -1523,8 +1570,8 @@ start_login(host, autologin, name)
utmpx.ut_id[3] = SC_WILDC;
utmpx.ut_type = LOGIN_PROCESS;
(void) time(&utmpx.ut_tv.tv_sec);
- if (makeutx(&utmpx) == NULL)
- fatal(net, "makeutx failed");
+ if (pututxline(&utmpx) == NULL)
+ fatal(net, "pututxline failed");
#endif
/*
@@ -1568,6 +1615,19 @@ start_login(host, autologin, name)
#if !defined(NO_LOGIN_P)
argv = addarg(argv, "-p");
#endif
+#ifdef LINEMODE
+ /*
+ * Set the environment variable "LINEMODE" to either
+ * "real" or "kludge" if we are operating in either
+ * real or kludge linemode.
+ */
+ if (lmodetype == REAL_LINEMODE)
+ setenv("LINEMODE", "real", 1);
+# ifdef KLUDGELINEMODE
+ else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)
+ setenv("LINEMODE", "kludge", 1);
+# endif
+#endif
#ifdef BFTPDAEMON
/*
* Are we working as the bftp daemon? If so, then ask login
@@ -1576,7 +1636,7 @@ start_login(host, autologin, name)
if (bftpd) {
argv = addarg(argv, "-e");
argv = addarg(argv, BFTPPATH);
- } else
+ } else
#endif
#if defined (SecurID)
/*
@@ -1688,11 +1748,27 @@ start_login(host, autologin, name)
*/
unsetenv("USER");
}
+#ifdef SOLARIS
+ else {
+ char **p;
+
+ argv = addarg(argv, ""); /* no login name */
+ for (p = environ; *p; p++) {
+ argv = addarg(argv, *p);
+ }
+ }
+#endif /* SOLARIS */
#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
if (pty > 2)
close(pty);
#endif
closelog();
+ /*
+ * This sleep(1) is in here so that telnetd can
+ * finish up with the tty. There's a race condition
+ * the login banner message gets lost...
+ */
+ sleep(1);
execv(_PATH_LOGIN, argv);
syslog(LOG_ERR, "%s: %m\n", _PATH_LOGIN);
@@ -1722,7 +1798,7 @@ addarg(argv, val)
if (cpp == &argv[(int)argv[-1]]) {
--argv;
*argv = (char *)((int)(*argv) + 10);
- argv = (char **)realloc(argv, (int)(*argv) + 2);
+ argv = (char **)realloc(argv, sizeof(*argv)*((int)(*argv) + 2));
if (argv == NULL)
return(NULL);
argv++;
@@ -1775,6 +1851,8 @@ cleanup(sig)
# ifdef CRAY
static int incleanup = 0;
register int t;
+ int child_status; /* status of child process as returned by waitpid */
+ int flags = WNOHANG|WUNTRACED;
/*
* 1: Pick up the zombie, if we are being called
@@ -1785,9 +1863,17 @@ cleanup(sig)
* 5: Close down the network and pty connections.
* 6: Finish up the TMPDIR cleanup, if needed.
*/
- if (sig == SIGCHLD)
- while (waitpid(-1, 0, WNOHANG) > 0)
+ if (sig == SIGCHLD) {
+ while (waitpid(-1, &child_status, flags) > 0)
; /* VOID */
+ /* Check if the child process was stopped
+ * rather than exited. We want cleanup only if
+ * the child has died.
+ */
+ if (WIFSTOPPED(child_status)) {
+ return;
+ }
+ }
t = sigblock(sigmask(SIGCHLD));
if (incleanup) {
sigsetmask(t);
@@ -1795,6 +1881,7 @@ cleanup(sig)
}
incleanup = 1;
sigsetmask(t);
+#ifdef UNICOS7x
if (secflag) {
/*
* We need to set ourselves back to a null
@@ -1804,6 +1891,7 @@ cleanup(sig)
setulvl(sysv.sy_minlvl);
setucmp((long)0);
}
+#endif /* UNICOS7x */
t = cleantmp(&wtmp);
setutent(); /* just to make sure */
@@ -1904,6 +1992,28 @@ sigjob(sig)
}
/*
+ * jid_getutid:
+ * called by jobend() before calling cleantmp()
+ * to find the correct $TMPDIR to cleanup.
+ */
+
+ struct utmp *
+jid_getutid(jid)
+ int jid;
+{
+ struct utmp *cur = NULL;
+
+ setutent(); /* just to make sure */
+ while (cur = getutent()) {
+ if ( (cur->ut_type != NULL) && (jid == cur->ut_jid) ) {
+ return(cur);
+ }
+ }
+
+ return(0);
+}
+
+/*
* Clean up the TMPDIR that login created.
* The first time this is called we pick up the info
* from the utmp. If the job has already gone away,
@@ -1959,9 +2069,27 @@ jobend(jid, path, user)
register char *user;
{
static int saved_jid = 0;
+ static int pty_saved_jid = 0;
static char saved_path[sizeof(wtmp.ut_tpath)+1];
static char saved_user[sizeof(wtmp.ut_user)+1];
+ /*
+ * this little piece of code comes into play
+ * only when ptyreconnect is used to reconnect
+ * to an previous session.
+ *
+ * this is the only time when the
+ * "saved_jid != jid" code is executed.
+ */
+
+ if ( saved_jid && saved_jid != jid ) {
+ if (!path) { /* called from signal handler */
+ pty_saved_jid = jid;
+ } else {
+ pty_saved_jid = saved_jid;
+ }
+ }
+
if (path) {
strncpy(saved_path, path, sizeof(wtmp.ut_tpath));
strncpy(saved_user, user, sizeof(wtmp.ut_user));
@@ -1972,6 +2100,24 @@ jobend(jid, path, user)
saved_jid = jid;
return(0);
}
+
+ /* if the jid has changed, get the correct entry from the utmp file */
+
+ if ( saved_jid != jid ) {
+ struct utmp *utp = NULL;
+ struct utmp *jid_getutid();
+
+ utp = jid_getutid(pty_saved_jid);
+
+ if (utp == 0) {
+ syslog(LOG_ERR, "Can't get /etc/utmp entry to clean TMPDIR");
+ return(-1);
+ }
+
+ cleantmpdir(jid, utp->ut_tpath, utp->ut_user);
+ return(1);
+ }
+
cleantmpdir(jid, saved_path, saved_user);
return(1);
}
@@ -2061,7 +2207,7 @@ rmut()
if (statbf.st_size && utmp) {
nutmp = read(f, (char *)utmp, (int)statbf.st_size);
nutmp /= sizeof(struct utmp);
-
+
for (u = utmp ; u < &utmp[nutmp] ; u++) {
if (SCMPN(u->ut_line, line+5) ||
u->ut_name[0]==0)
diff --git a/libexec/telnetd/telnetd.8 b/libexec/telnetd/telnetd.8
index fee5526..f618385 100644
--- a/libexec/telnetd/telnetd.8
+++ b/libexec/telnetd/telnetd.8
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)telnetd.8 8.3 (Berkeley) 3/1/94
+.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
.\"
-.Dd March 1, 1994
+.Dd June 1, 1994
.Dt TELNETD 8
.Os BSD 4.2
.Sh NAME
@@ -308,6 +308,7 @@ indicates that only dotted decimal addresses
should be put into the
.Pa utmp
file.
+.ne 1i
.It Fl U
This option causes
.Nm telnetd
@@ -424,6 +425,7 @@ Whenever a
command is received, it is always responded
to with a
.Dv WILL TIMING-MARK
+.ne 1i
.It "WILL LOGOUT"
When a
.Dv DO LOGOUT
diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c
index 6860534..70c0fc0 100644
--- a/libexec/telnetd/telnetd.c
+++ b/libexec/telnetd/telnetd.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -451,7 +451,7 @@ main(argc, argv)
int szi = sizeof(int);
#endif /* SO_SEC_MULTI */
- bzero((char *)&dv, sizeof(dv));
+ memset((char *)&dv, 0, sizeof(dv));
if (getsysv(&sysv, sizeof(struct sysv)) != 0) {
perror("getsysv");
@@ -637,34 +637,40 @@ getterminaltype(name)
static unsigned char sb[] =
{ IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
- bcopy(sb, nfrontp, sizeof sb);
+ memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
+ DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_XDISPLOC)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC, SE };
- bcopy(sb, nfrontp, sizeof sb);
+ memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
+ DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_SEND, IAC, SE };
- bcopy(sb, nfrontp, sizeof sb);
+ memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
+ DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
else if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
static unsigned char sb[] =
{ IAC, SB, TELOPT_OLD_ENVIRON, TELQUAL_SEND, IAC, SE };
- bcopy(sb, nfrontp, sizeof sb);
+ memmove(nfrontp, sb, sizeof sb);
nfrontp += sizeof sb;
+ DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
}
if (his_state_is_will(TELOPT_TTYPE)) {
- bcopy(ttytype_sbbuf, nfrontp, sizeof ttytype_sbbuf);
+ memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
nfrontp += sizeof ttytype_sbbuf;
+ DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
+ sizeof ttytype_sbbuf - 2););
}
if (his_state_is_will(TELOPT_TSPEED)) {
while (sequenceIs(tspeedsubopt, baseline))
@@ -737,8 +743,10 @@ _gettermname()
if (his_state_is_wont(TELOPT_TTYPE))
return;
settimer(baseline);
- bcopy(ttytype_sbbuf, nfrontp, sizeof ttytype_sbbuf);
+ memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
nfrontp += sizeof ttytype_sbbuf;
+ DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
+ sizeof ttytype_sbbuf - 2););
while (sequenceIs(ttypesubopt, baseline))
ttloop();
}
@@ -816,7 +824,7 @@ doit(who)
#if defined(_SC_CRAY_SECURE_SYS)
/*
- * set ttyp line security label
+ * set ttyp line security label
*/
if (secflag) {
char slave_dev[16];
@@ -836,9 +844,10 @@ doit(who)
if (hp == NULL && registerd_host_only) {
fatal(net, "Couldn't resolve your address into a host name.\r\n\
- Please contact your net administrator");
+ Please contact your net administrator");
} else if (hp &&
- (strlen(hp->h_name) <= ((utmp_len < 0) ? -utmp_len : utmp_len))) {
+ (strlen(hp->h_name) <= (unsigned int)((utmp_len < 0) ? -utmp_len
+ : utmp_len))) {
host = hp->h_name;
} else {
host = inet_ntoa(who->sin_addr);
@@ -927,6 +936,7 @@ telnet(f, p, host)
char *HN;
char *IM;
void netflush();
+ int nfd;
/*
* Initialize the slc mapping table.
@@ -1156,6 +1166,7 @@ telnet(f, p, host)
startslave(host);
#endif
+ nfd = ((f > p) ? f : p) + 1;
for (;;) {
fd_set ibits, obits, xbits;
register int c;
@@ -1187,7 +1198,7 @@ telnet(f, p, host)
if (!SYNCHing) {
FD_SET(f, &xbits);
}
- if ((c = select(16, &ibits, &obits, &xbits,
+ if ((c = select(nfd, &ibits, &obits, &xbits,
(struct timeval *)0)) < 1) {
if (c == -1) {
if (errno == EINTR) {
@@ -1326,6 +1337,9 @@ telnet(f, p, host)
*nfrontp++ = IAC;
*nfrontp++ = DM;
neturg = nfrontp-1; /* off by one XXX */
+ DIAG(TD_OPTIONS,
+ printoption("td: send IAC", DM));
+
#endif
}
if (his_state_is_will(TELOPT_LFLOW) &&
@@ -1342,6 +1356,9 @@ telnet(f, p, host)
: LFLOW_OFF,
IAC, SE);
nfrontp += 6;
+ DIAG(TD_OPTIONS, printsub('>',
+ (unsigned char *)nfrontp-4,
+ 4););
}
}
pcc--;
@@ -1400,7 +1417,7 @@ telnet(f, p, host)
}
cleanup(0);
} /* end of telnet */
-
+
#ifndef TCSIG
# ifdef TIOCSIG
# define TCSIG TIOCSIG
@@ -1476,7 +1493,7 @@ int readstream(p, ibuf, bufsize)
tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
vstop = tp->c_cc[VSTOP];
vstart = tp->c_cc[VSTART];
- ixon = tp->c_iflag & IXON;
+ ixon = tp->c_iflag & IXON;
break;
default:
errno = EAGAIN;
@@ -1507,6 +1524,14 @@ interrupt()
{
ptyflush(); /* half-hearted */
+#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
+ /* Streams PTY style ioctl to post a signal */
+ {
+ int sig = SIGINT;
+ (void) ioctl(pty, TIOCSIGNAL, &sig);
+ (void) ioctl(pty, I_FLUSH, FLUSHR);
+ }
+#else
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
@@ -1514,6 +1539,7 @@ interrupt()
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
+#endif
}
/*
diff --git a/libexec/telnetd/termstat.c b/libexec/telnetd/termstat.c
index a3f6931..ebc843a 100644
--- a/libexec/telnetd/termstat.c
+++ b/libexec/telnetd/termstat.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)termstat.c 8.1 (Berkeley) 6/4/93";
+static char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include "telnetd.h"
@@ -320,7 +320,7 @@ localstat()
nfrontp += 7;
editmode = useeditmode;
}
-
+
/*
* Check for changes to special characters in use.
@@ -422,7 +422,7 @@ clientstat(code, parm1, parm2)
uselinemode = 1;
}
}
-
+
/*
* Quit now if we can't do it.
*/
@@ -463,7 +463,7 @@ clientstat(code, parm1, parm2)
send_will(TELOPT_ECHO, 1);
}
break;
-
+
case LM_MODE:
{
register int ack, changed;
@@ -512,7 +512,7 @@ clientstat(code, parm1, parm2)
IAC, SE);
nfrontp += 7;
}
-
+
editmode = useeditmode;
}
@@ -546,9 +546,9 @@ clientstat(code, parm1, parm2)
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
}
#endif /* TIOCSWINSZ */
-
+
break;
-
+
case TELOPT_TSPEED:
{
def_tspeed = parm1;
@@ -613,7 +613,7 @@ _termstat()
*
* Some things should not be done until after the login process has started
* and all the pty modes are set to what they are supposed to be. This
- * function is called when the pty state has been processed for the first time.
+ * function is called when the pty state has been processed for the first time.
* It calls other functions that do things that were deferred in each module.
*/
void
@@ -632,7 +632,7 @@ defer_terminit()
if (def_col || def_row) {
struct winsize ws;
- bzero((char *)&ws, sizeof(ws));
+ memset((char *)&ws, 0, sizeof(ws));
ws.ws_col = def_col;
ws.ws_row = def_row;
(void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
diff --git a/libexec/telnetd/utility.c b/libexec/telnetd/utility.c
index 8c08bdc..9553d58 100644
--- a/libexec/telnetd/utility.c
+++ b/libexec/telnetd/utility.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)utility.c 8.2 (Berkeley) 12/15/93";
+static char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
#endif /* not lint */
#define PRINTOPTIONS
@@ -220,7 +220,7 @@ netclear()
next = nextitem(next);
} while (wewant(next) && (nfrontp > next));
length = next-thisitem;
- bcopy(thisitem, good, length);
+ memmove(good, thisitem, length);
good += length;
thisitem = next;
} else {
@@ -327,7 +327,7 @@ writenet(ptr, len)
netflush();
}
- bcopy(ptr, nfrontp, len);
+ memmove(nfrontp, ptr, len);
nfrontp += len;
} /* end of writenet */
@@ -368,7 +368,7 @@ fatalperror(f, msg)
{
char buf[BUFSIZ], *strerror();
- (void) sprintf(buf, "%s: %s\r\n", msg, strerror(errno));
+ (void) sprintf(buf, "%s: %s", msg, strerror(errno));
fatal(f, buf);
}
@@ -449,9 +449,9 @@ putf(cp, where)
time_t t;
char db[100];
#ifdef STREAMSPTY
- extern char *index();
+ extern char *strchr();
#else
- extern char *rindex();
+ extern char *strrchr();
#endif
putlocation = where;
@@ -466,9 +466,9 @@ putf(cp, where)
case 't':
#ifdef STREAMSPTY
/* names are like /dev/pts/2 -- we want pts/2 */
- slash = index(line+1, '/');
+ slash = strchr(line+1, '/');
#else
- slash = rindex(line, '/');
+ slash = strrchr(line, '/');
#endif
if (slash == (char *) 0)
putstr(line);
@@ -522,7 +522,7 @@ printsub(direction, pointer, length)
register int i;
char buf[512];
- if (!(diagnostic & TD_OPTIONS))
+ if (!(diagnostic & TD_OPTIONS))
return;
if (direction) {
@@ -713,7 +713,7 @@ printsub(direction, pointer, length)
break;
}
break;
-
+
case LM_SLC:
sprintf(nfrontp, "SLC");
nfrontp += strlen(nfrontp);
@@ -863,7 +863,7 @@ printsub(direction, pointer, length)
nfrontp += strlen(nfrontp);
break;
-
+
default:
sprintf(nfrontp, " %d", pointer[i]);
nfrontp += strlen(nfrontp);
@@ -966,7 +966,7 @@ printsub(direction, pointer, length)
case TELOPT_AUTHENTICATION:
sprintf(nfrontp, "AUTHENTICATION");
nfrontp += strlen(nfrontp);
-
+
if (length < 2) {
sprintf(nfrontp, " (empty suboption??\?)");
nfrontp += strlen(nfrontp);
@@ -1134,9 +1134,9 @@ printsub(direction, pointer, length)
default:
if (TELOPT_OK(pointer[0]))
- sprintf(nfrontp, "%s (unknown)", TELOPT(pointer[0]));
+ sprintf(nfrontp, "%s (unknown)", TELOPT(pointer[0]));
else
- sprintf(nfrontp, "%d (unknown)", pointer[i]);
+ sprintf(nfrontp, "%d (unknown)", pointer[i]);
nfrontp += strlen(nfrontp);
for (i = 1; i < length; i++) {
sprintf(nfrontp, " %d", pointer[i]);
@@ -1171,13 +1171,13 @@ printdata(tag, ptr, cnt)
nfrontp += strlen(nfrontp);
for (i = 0; i < 20 && cnt; i++) {
sprintf(nfrontp, "%02x", *ptr);
- nfrontp += strlen(nfrontp);
+ nfrontp += strlen(nfrontp);
if (isprint(*ptr)) {
xbuf[i] = *ptr;
} else {
xbuf[i] = '.';
}
- if (i % 2) {
+ if (i % 2) {
*nfrontp = ' ';
nfrontp++;
}
@@ -1187,6 +1187,6 @@ printdata(tag, ptr, cnt)
xbuf[i] = '\0';
sprintf(nfrontp, " %s\r\n", xbuf );
nfrontp += strlen(nfrontp);
- }
+ }
}
#endif /* DIAGNOSTICS */
OpenPOWER on IntegriCloud