diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 1995-06-13 18:05:17 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 1995-06-13 18:05:17 +0000 |
| commit | e506c6f0ea9f3b267e874555538b2f22b5778b8f (patch) | |
| tree | 667af903b5ab768677daab8b52896b8663cb0543 /libexec | |
| parent | d3628763db3974826e46a036aa54333147fbe238 (diff) | |
Notes
Diffstat (limited to 'libexec')
31 files changed, 0 insertions, 4692 deletions
diff --git a/libexec/atrun/atrun.8 b/libexec/atrun/atrun.8 deleted file mode 100644 index ed6e359bfa2a..000000000000 --- a/libexec/atrun/atrun.8 +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright (c) 1993 Christopher G. Demetriou -.\" 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 Christopher G. Demetriou. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software withough specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $Id: atrun.8,v 1.1 1994/01/05 01:02:58 nate Exp $ -.\" -.Dd December 5, 1993 -.Dt ATRUN 8 -.Os FreeBSD 1.1 -.Sh NAME -.Nm atrun -.Nd run jobs queued for later execution -.\" -.Sh SYOPSIS -.Nm atrun -.Sh DESCRIPTION -The -.Nm atrun -utility runs commands queued by -.Xr at 1 . -It is usually invoked by -.Xr crond 8 -every ten minutes. -.Sh FILES -.Bl -tag -width /var/at/lockfile -compact -.It Pa /var/at/jobs -Directory containing job files -.It Pa /var/at/spool -Directory containing output spool files -.It Pa /var/at/lockfile -Job-creation lock file. -.El -.Sh SEE ALSO -.Xr crond 8 , -.Xr at 1 -.Sh AUTHOR -.Bl -tag -Thomas Koenig, ig25@rz.uni-karlsruhe.de -.El -.Sh BUGS -The functionality of -.Nm atrun -should arguaby be merged into -.Xr crond 8 . -.Sh CAVEATS -Since the default configuration causes -.Nm atrun -to be invoked every ten minutes, -commands queued by -.Xr at 1 -may end up being executed up to nine minutes -later than would be otherwise expected. diff --git a/libexec/atrun/atrun.h b/libexec/atrun/atrun.h deleted file mode 100644 index be0588a78e45..000000000000 --- a/libexec/atrun/atrun.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 1993 Christopher G. Demetriou - * 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 Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: atrun.h,v 1.1 1993/12/05 11:36:45 cgd Exp $ - */ - -#define ATRUN_MAXLOAD 1.5 diff --git a/libexec/bugfiler/Makefile b/libexec/bugfiler/Makefile deleted file mode 100644 index fb7763353155..000000000000 --- a/libexec/bugfiler/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/4/93 - -PROG= bugfiler -CFLAGS+=-I${.CURDIR} -SRCS= bugfiler.c error.c gethead.c process.c redist.c reply.c -BINOWN= root -BINMODE=4555 -MAN1= sendbug.1 -MAN8= bugfiler.8 - -beforeinstall: - install -c -o bin -g ${BINGRP} -m 555 \ - ${.CURDIR}/sendbug.sh ${DESTDIR}/usr/bin/sendbug - install -c -o bin -g ${BINGRP} -m 444 ${.CURDIR}/bugformat \ - ${DESTDIR}/usr/share/misc - -.include <bsd.prog.mk> diff --git a/libexec/bugfiler/bug.h b/libexec/bugfiler/bug.h deleted file mode 100644 index 69ea9864294a..000000000000 --- a/libexec/bugfiler/bug.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1fc86d25f450..000000000000 --- a/libexec/bugfiler/bugfiler.8 +++ /dev/null @@ -1,290 +0,0 @@ -.\" 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 deleted file mode 100644 index 75dbef38b0b1..000000000000 --- a/libexec/bugfiler/bugfiler.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 deleted file mode 100644 index 97a767d7288c..000000000000 --- a/libexec/bugfiler/bugformat +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index bd00b2bf7511..000000000000 --- a/libexec/bugfiler/error.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 deleted file mode 100644 index b096f3d35ddf..000000000000 --- a/libexec/bugfiler/extern.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * 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 deleted file mode 100644 index ba7e361717ba..000000000000 --- a/libexec/bugfiler/gethead.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7ff5ab6f211f..000000000000 --- a/libexec/bugfiler/pathnames.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6d376fdf9d07..000000000000 --- a/libexec/bugfiler/process.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 deleted file mode 100644 index 87a18b6dd6e2..000000000000 --- a/libexec/bugfiler/redist.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0f9940181a25..000000000000 --- a/libexec/bugfiler/reply.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 deleted file mode 100644 index 31ca8028a2eb..000000000000 --- a/libexec/bugfiler/sendbug.1 +++ /dev/null @@ -1,85 +0,0 @@ -.\" 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 deleted file mode 100644 index 911ef9d99b53..000000000000 --- a/libexec/bugfiler/sendbug.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/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/getty/extern.h b/libexec/getty/extern.h deleted file mode 100644 index 644f93f10747..000000000000 --- a/libexec/getty/extern.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - */ - -struct delayval; - -int adelay __P((int, struct delayval *)); -char *autobaud __P((void)); -int delaybits __P((void)); -void edithost __P((char *)); -void gendefaults __P((void)); -int getent __P((char *, char *)); -int getflag __P((char *)); -long getnum __P((char *)); -char *getstr __P((char *, char **)); -void gettable __P((char *, char *)); -void makeenv __P((char *[])); -char *portselector __P((void)); -void set_ttydefaults __P((int)); -void setchars __P((void)); -void setdefaults __P((void)); -long setflags __P((int)); -int speed __P((int)); - -int login_tty __P((int)); /* From libutil. */ diff --git a/libexec/getty/fbtab_stuff.c b/libexec/getty/fbtab_stuff.c deleted file mode 100644 index 2ae5394dbc34..000000000000 --- a/libexec/getty/fbtab_stuff.c +++ /dev/null @@ -1,93 +0,0 @@ -#include <sys/types.h> -#include <stdio.h> -#include <syslog.h> -#include <string.h> -#include <errno.h> -#include <dirent.h> - -#include "pathnames.h" - -#define WSPACE " \t\n" - -void reset_fbtab __P((char *tty)); -void reset_protect __P((char *table, char *path, int mask)); - -/* - * reset_fbtab - reset ownership to root/wheel and apply protections - * specified in /etc/fbtab or logindevperm - */ - -void -reset_fbtab(tty) -char *tty; -{ - FILE *fp; - char buf[BUFSIZ]; - char *devname; - char *cp; - int prot; - char *table; - - if ((fp = fopen(table = _PATH_FBTAB, "r")) == 0 - && (fp = fopen(table = _PATH_LOGINDEVPERM, "r")) == 0) - return; - - while (fgets(buf, sizeof(buf), fp)) { - if (cp = strchr(buf, '#')) - *cp = 0; /* strip comment */ - if ((cp = devname = strtok(buf, WSPACE)) == 0) - continue; /* empty or comment */ - if (strncmp(devname, "/dev/", 5) != 0 - || (cp = strtok((char *) 0, WSPACE)) == 0 - || *cp != '0' - || sscanf(cp, "%o", &prot) == 0 - || prot == 0 - || (prot & 0777) != prot - || (cp = strtok((char *) 0, WSPACE)) == 0) { - syslog(LOG_ERR, "%s: bad entry: %s", table, cp ? cp : "(null)"); - continue; - } - if (strcmp(devname, tty) == 0) { - for (cp = strtok(cp, ":"); cp; cp = strtok((char *) 0, ":")) { - reset_protect(table, cp, prot); - } - } - } - fclose(fp); -} - -/* reset_protect - protect one device entry */ - -void -reset_protect(table, path, mask) -char *table; -char *path; -int mask; -{ - char buf[BUFSIZ]; - int pathlen = strlen(path); - struct dirent *ent; - DIR *dir; - - if (strcmp("/*", path + pathlen - 2) != 0) { - if (chmod(path, mask) && errno != ENOENT) - syslog(LOG_ERR, "%s: chmod(%s): %m", table, path); - if (chown(path, 0, 0) && errno != ENOENT) - syslog(LOG_ERR, "%s: chown(%s): %m", table, path); - } else { - strcpy(buf, path); - buf[pathlen - 1] = 0; - if ((dir = opendir(buf)) == 0) { - syslog(LOG_ERR, "%s: opendir(%s): %m", table, path); - } else { - while ((ent = readdir(dir)) != 0) { - if (strcmp(ent->d_name, ".") != 0 - && strcmp(ent->d_name, "..") != 0) { - strcpy(buf + pathlen - 1, ent->d_name); - reset_protect(table, buf, mask); - } - } - closedir(dir); - } - } -} diff --git a/libexec/getty/ttydefaults.c b/libexec/getty/ttydefaults.c deleted file mode 100644 index 518f41ba0f60..000000000000 --- a/libexec/getty/ttydefaults.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * 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 sccsid[] = "@(#)ttydefaults.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -#include <sys/termios.h> - -#include "extern.h" - -void -set_ttydefaults(fd) - int fd; -{ - struct termios term; - - tcgetattr(fd, &term); - term.c_iflag = TTYDEF_IFLAG; - term.c_oflag = TTYDEF_OFLAG; - term.c_lflag = TTYDEF_LFLAG; - term.c_cflag = TTYDEF_CFLAG; - tcsetattr(fd, TCSAFLUSH, &term); -} diff --git a/libexec/kpasswdd/Makefile b/libexec/kpasswdd/Makefile deleted file mode 100644 index edb9482c4cdb..000000000000 --- a/libexec/kpasswdd/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/4/93 -# -# We do still make this one conditional on kerberos, in case -# the libraries do not exist - -.if exists(${DESTDIR}/usr/lib/libkrb.a) && (defined(MAKE_KERBEROS) \ - || defined(MAKE_EBONES)) - -PROG= kpasswdd -SRCS= kpasswdd.c -CFLAGS+=-DCRYPT -DKERBEROS -I${.CURDIR}/../../usr.bin/passwd -DPADD= ${LIBKDB} ${LIBKRB} ${LIBDES} -LDADD= -lkdb -lkrb -ldes -.PATH: ${.CURDIR}/../../usr.bin/rlogin -MAN8= kpasswdd.8 -DISTRIBUTION= krb - -.endif - -.include <bsd.prog.mk> diff --git a/libexec/kpasswdd/kpasswdd.8 b/libexec/kpasswdd/kpasswdd.8 deleted file mode 100644 index f6a401f8c0fe..000000000000 --- a/libexec/kpasswdd/kpasswdd.8 +++ /dev/null @@ -1,60 +0,0 @@ -.\" 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 deleted file mode 100644 index 23ff1f864494..000000000000 --- a/libexec/kpasswdd/kpasswdd.c +++ /dev/null @@ -1,271 +0,0 @@ -/*- - * 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/rtld-aout/Makefile b/libexec/rtld-aout/Makefile deleted file mode 100644 index 7c8114545d14..000000000000 --- a/libexec/rtld-aout/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# $Id: Makefile,v 1.13 1994/09/18 19:41:38 swallace Exp $ - -PROG= ld.so -SRCS= mdprologue.S rtld.c malloc.c shlib.c etc.c md.c -NOMAN= noman -LDDIR?= $(.CURDIR)/.. -PICFLAG=-fpic -CFLAGS+=-I$(LDDIR) -I$(.CURDIR) -I$(LDDIR)/$(MACHINE) $(PICFLAG) -DRTLD -LDFLAGS+=-Bshareable -Bsymbolic -assert nosymbolic -ASFLAGS+=-k -DPADD+= ${LIBC:S/c.a/c_pic.a/} ${LIBC:S/c.a/gcc_pic.a/} -LDADD+= -lc_pic -lgcc_pic -BINDIR= /usr/libexec -INSTALLFLAGS+= -fschg - -.PATH: $(LDDIR) $(LDDIR)/$(MACHINE) - -$(PROG): ${OBJS} ${DPADD} - $(LD) -o $(PROG) $(LDFLAGS) $(OBJS) $(LDADD) - -.include <bsd.prog.mk> diff --git a/libexec/rtld-aout/i386/md-static-funcs.c b/libexec/rtld-aout/i386/md-static-funcs.c deleted file mode 100644 index 47416856e4e9..000000000000 --- a/libexec/rtld-aout/i386/md-static-funcs.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * $Id: md-static-funcs.c,v 1.2 1993/12/08 10:14:44 pk Exp $ - * - * Called by ld.so when onanating. - * This *must* be a static function, so it is not called through a jmpslot. - */ - -static void -md_relocate_simple(r, relocation, addr) -struct relocation_info *r; -long relocation; -char *addr; -{ -if (r->r_relative) - *(long *)addr += relocation; -} - diff --git a/libexec/rtld-aout/i386/md.c b/libexec/rtld-aout/i386/md.c deleted file mode 100644 index 07271fc344ad..000000000000 --- a/libexec/rtld-aout/i386/md.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: md.c,v 1.11 1994/12/23 22:31:12 nate Exp $ - */ - -#include <sys/param.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <err.h> -#include <fcntl.h> -#include <a.out.h> -#include <stab.h> -#include <string.h> - -#include "ld.h" - -/* - * Get relocation addend corresponding to relocation record RP - * from address ADDR - */ -long -md_get_addend(rp, addr) -struct relocation_info *rp; -unsigned char *addr; -{ - switch (RELOC_TARGET_SIZE(rp)) { - case 0: - return get_byte(addr); - case 1: - return get_short(addr); - case 2: - return get_long(addr); - default: - errx(1, "Unsupported relocation size: %x", - RELOC_TARGET_SIZE(rp)); - } -} - -/* - * Put RELOCATION at ADDR according to relocation record RP. - */ -void -md_relocate(rp, relocation, addr, relocatable_output) -struct relocation_info *rp; -long relocation; -unsigned char *addr; -int relocatable_output; -{ - switch (RELOC_TARGET_SIZE(rp)) { - case 0: - put_byte(addr, relocation); - break; - case 1: - put_short(addr, relocation); - break; - case 2: - put_long(addr, relocation); - break; - default: - errx(1, "Unsupported relocation size: %x", - RELOC_TARGET_SIZE(rp)); - } -} - -/* - * Machine dependent part of claim_rrs_reloc(). - * Set RRS relocation type. - */ -int -md_make_reloc(rp, r, type) -struct relocation_info *rp, *r; -int type; -{ - /* Relocation size */ - r->r_length = rp->r_length; - - if (RELOC_PCREL_P(rp)) - r->r_pcrel = 1; - - if (type & RELTYPE_RELATIVE) - r->r_relative = 1; - - if (type & RELTYPE_COPY) - r->r_copy = 1; - - return 0; -} - -/* - * Set up a transfer from jmpslot at OFFSET (relative to the PLT table) - * to the binder slot (which is at offset 0 of the PLT). - */ -void -md_make_jmpslot(sp, offset, index) -jmpslot_t *sp; -long offset; -long index; -{ - /* - * i386 PC-relative "fixed point" is located right after the - * instruction it pertains to. - */ - u_long fudge = - (sizeof(sp->opcode) + sizeof(sp->addr) + offset); - - sp->opcode = CALL; -#if 0 - sp->addr = fudge; -#else - sp->addr[0] = fudge & 0xffff; - sp->addr[1] = fudge >> 16; -#endif - sp->reloc_index = index; -} - -/* - * Set up a "direct" transfer (ie. not through the run-time binder) from - * jmpslot at OFFSET to ADDR. Used by `ld' when the SYMBOLIC flag is on, - * and by `ld.so' after resolving the symbol. - * On the i386, we use the JMP instruction which is PC relative, so no - * further RRS relocations will be necessary for such a jmpslot. - */ -void -md_fix_jmpslot(sp, offset, addr) -jmpslot_t *sp; -long offset; -u_long addr; -{ - u_long fudge = addr - (sizeof(sp->opcode) + sizeof(sp->addr) + offset); - - sp->opcode = JUMP; -#if 0 - sp->addr = fudge; -#else - sp->addr[0] = fudge & 0xffff; - sp->addr[1] = fudge >> 16; -#endif - sp->reloc_index = 0; -} - -/* - * Update the relocation record for a RRS jmpslot. - */ -void -md_make_jmpreloc(rp, r, type) -struct relocation_info *rp, *r; -int type; -{ - jmpslot_t *sp; - - /* - * Fix relocation address to point to the correct - * location within this jmpslot. - */ - r->r_address += sizeof(sp->opcode); - - /* Relocation size */ - r->r_length = 2; - - /* Set relocation type */ - r->r_jmptable = 1; - if (type & RELTYPE_RELATIVE) - r->r_relative = 1; - -} - -/* - * Set relocation type for a RRS GOT relocation. - */ -void -md_make_gotreloc(rp, r, type) -struct relocation_info *rp, *r; -int type; -{ - r->r_baserel = 1; - if (type & RELTYPE_RELATIVE) - r->r_relative = 1; - - /* Relocation size */ - r->r_length = 2; -} - -/* - * Set relocation type for a RRS copy operation. - */ -void -md_make_cpyreloc(rp, r) -struct relocation_info *rp, *r; -{ - /* Relocation size */ - r->r_length = 2; - - r->r_copy = 1; -} - -void -md_set_breakpoint(where, savep) -long where; -long *savep; -{ - *savep = *(long *)where; - *(char *)where = TRAP; -} - -#ifndef RTLD - -#ifdef __FreeBSD__ -int netzmagic; -#endif - -/* - * Initialize (output) exec header such that useful values are - * obtained from subsequent N_*() macro evaluations. - */ -void -md_init_header(hp, magic, flags) -struct exec *hp; -int magic, flags; -{ -#ifdef NetBSD - if (oldmagic || magic == QMAGIC) - hp->a_midmag = magic; - else - N_SETMAGIC((*hp), magic, MID_I386, flags); -#endif -#ifdef __FreeBSD__ - if (oldmagic) - hp->a_midmag = magic; - else if (netzmagic) - N_SETMAGIC_NET((*hp), magic, MID_I386, flags); - else - N_SETMAGIC((*hp), magic, MID_I386, flags); -#endif - - /* TEXT_START depends on the value of outheader.a_entry. */ - if (!(link_mode & SHAREABLE)) - hp->a_entry = PAGSIZ; -} -#endif /* RTLD */ - - -#ifdef NEED_SWAP -/* - * Byte swap routines for cross-linking. - */ - -void -md_swapin_exec_hdr(h) -struct exec *h; -{ - int skip = 0; - - if (!N_BADMAG(*h)) - skip = 1; - - swap_longs((long *)h + skip, sizeof(*h)/sizeof(long) - skip); -} - -void -md_swapout_exec_hdr(h) -struct exec *h; -{ - /* NetBSD: Always leave magic alone */ - int skip = 1; -#if 0 - if (N_GETMAGIC(*h) == OMAGIC) - skip = 0; -#endif - - swap_longs((long *)h + skip, sizeof(*h)/sizeof(long) - skip); -} - - -void -md_swapin_reloc(r, n) -struct relocation_info *r; -int n; -{ - int bits; - - for (; n; n--, r++) { - r->r_address = md_swap_long(r->r_address); - bits = ((int *)r)[1]; - r->r_symbolnum = md_swap_long(bits) & 0x00ffffff; - r->r_pcrel = (bits & 1); - r->r_length = (bits >> 1) & 3; - r->r_extern = (bits >> 3) & 1; - r->r_baserel = (bits >> 4) & 1; - r->r_jmptable = (bits >> 5) & 1; - r->r_relative = (bits >> 6) & 1; -#ifdef N_SIZE - r->r_copy = (bits >> 7) & 1; -#endif - } -} - -void -md_swapout_reloc(r, n) -struct relocation_info *r; -int n; -{ - int bits; - - for (; n; n--, r++) { - r->r_address = md_swap_long(r->r_address); - bits = md_swap_long(r->r_symbolnum) & 0xffffff00; - bits |= (r->r_pcrel & 1); - bits |= (r->r_length & 3) << 1; - bits |= (r->r_extern & 1) << 3; - bits |= (r->r_baserel & 1) << 4; - bits |= (r->r_jmptable & 1) << 5; - bits |= (r->r_relative & 1) << 6; -#ifdef N_SIZE - bits |= (r->r_copy & 1) << 7; -#endif - ((int *)r)[1] = bits; - } -} - -void -md_swapout_jmpslot(j, n) -jmpslot_t *j; -int n; -{ - for (; n; n--, j++) { - j->opcode = md_swap_short(j->opcode); - j->addr[0] = md_swap_short(j->addr[0]); - j->addr[1] = md_swap_short(j->addr[1]); - j->reloc_index = md_swap_short(j->reloc_index); - } -} - -#endif /* NEED_SWAP */ diff --git a/libexec/rtld-aout/i386/md.h b/libexec/rtld-aout/i386/md.h deleted file mode 100644 index da5283de4645..000000000000 --- a/libexec/rtld-aout/i386/md.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: md.h,v 1.11 1994/12/23 22:31:14 nate Exp $ - */ - - -#if defined(CROSS_LINKER) && defined(XHOST) && XHOST==sparc -#define NEED_SWAP -#endif - -#define MAX_ALIGNMENT (sizeof (long)) - -#ifdef NetBSD -#define PAGSIZ __LDPGSZ -#else -#define PAGSIZ 4096 -#endif - -#if defined(NetBSD) || defined(CROSS_LINKER) - -#define N_SET_FLAG(ex,f) (oldmagic || N_GETMAGIC(ex)==QMAGIC ? (0) : \ - N_SETMAGIC(ex, \ - N_GETMAGIC(ex), \ - MID_MACHINE, \ - N_GETFLAG(ex)|(f))) - -#define N_IS_DYNAMIC(ex) ((N_GETFLAG(ex) & EX_DYNAMIC)) - -#define N_BADMID(ex) \ - (N_GETMID(ex) != 0 && N_GETMID(ex) != MID_MACHINE) - -#endif - -/* - * FreeBSD does it differently - */ -#ifdef __FreeBSD__ -#define N_SET_FLAG(ex,f) (oldmagic ? (0) : \ - (netzmagic == 0 ? \ - N_SETMAGIC(ex, \ - N_GETMAGIC(ex), \ - MID_MACHINE, \ - N_GETFLAG(ex)|(f)) : \ - N_SETMAGIC_NET(ex, \ - N_GETMAGIC_NET(ex), \ - MID_MACHINE, \ - N_GETFLAG_NET(ex)|(f)) )) - -#define N_IS_DYNAMIC(ex) ((N_GETMAGIC_NET(ex) == ZMAGIC) ? \ - ((N_GETFLAG_NET(ex) & EX_DYNAMIC)) : \ - ((N_GETFLAG(ex) & EX_DYNAMIC) )) -#define N_BADMID(ex) 0 -#endif - -/* - * Should be handled by a.out.h ? - */ -#define N_ADJUST(ex) (((ex).a_entry < PAGSIZ) ? -PAGSIZ : 0) -#define TEXT_START(ex) (N_TXTADDR(ex) + N_ADJUST(ex)) -#define DATA_START(ex) (N_DATADDR(ex) + N_ADJUST(ex)) - -#define RELOC_STATICS_THROUGH_GOT_P(r) (0) -#define JMPSLOT_NEEDS_RELOC (0) - -#define md_got_reloc(r) (0) - -#define md_get_rt_segment_addend(r,a) md_get_addend(r,a) - -/* Width of a Global Offset Table entry */ -#define GOT_ENTRY_SIZE 4 -typedef long got_t; - -typedef struct jmpslot { - u_short opcode; - u_short addr[2]; - u_short reloc_index; -#define JMPSLOT_RELOC_MASK 0xffff -} jmpslot_t; - -#define NOP 0x90 -#define CALL 0xe890 /* NOP + CALL opcode */ -#define JUMP 0xe990 /* NOP + JMP opcode */ -#define TRAP 0xcc /* INT 3 */ - -/* - * Byte swap defs for cross linking - */ - -#if !defined(NEED_SWAP) - -#define md_swapin_exec_hdr(h) -#define md_swapout_exec_hdr(h) -#define md_swapin_symbols(s,n) -#define md_swapout_symbols(s,n) -#define md_swapin_zsymbols(s,n) -#define md_swapout_zsymbols(s,n) -#define md_swapin_reloc(r,n) -#define md_swapout_reloc(r,n) -#define md_swapin__dynamic(l) -#define md_swapout__dynamic(l) -#define md_swapin_section_dispatch_table(l) -#define md_swapout_section_dispatch_table(l) -#define md_swapin_so_debug(d) -#define md_swapout_so_debug(d) -#define md_swapin_rrs_hash(f,n) -#define md_swapout_rrs_hash(f,n) -#define md_swapin_sod(l,n) -#define md_swapout_sod(l,n) -#define md_swapout_jmpslot(j,n) -#define md_swapout_got(g,n) -#define md_swapin_ranlib_hdr(h,n) -#define md_swapout_ranlib_hdr(h,n) - -#endif /* NEED_SWAP */ - -#ifdef CROSS_LINKER - -#define get_byte(p) ( ((unsigned char *)(p))[0] ) - -#define get_short(p) ( ( ((unsigned char *)(p))[0] << 8) | \ - ( ((unsigned char *)(p))[1] ) \ - ) - -#define get_long(p) ( ( ((unsigned char *)(p))[0] << 24) | \ - ( ((unsigned char *)(p))[1] << 16) | \ - ( ((unsigned char *)(p))[2] << 8 ) | \ - ( ((unsigned char *)(p))[3] ) \ - ) - -#define put_byte(p, v) { ((unsigned char *)(p))[0] = ((unsigned long)(v)); } - -#define put_short(p, v) { ((unsigned char *)(p))[0] = \ - ((((unsigned long)(v)) >> 8) & 0xff); \ - ((unsigned char *)(p))[1] = \ - ((((unsigned long)(v)) ) & 0xff); } - -#define put_long(p, v) { ((unsigned char *)(p))[0] = \ - ((((unsigned long)(v)) >> 24) & 0xff); \ - ((unsigned char *)(p))[1] = \ - ((((unsigned long)(v)) >> 16) & 0xff); \ - ((unsigned char *)(p))[2] = \ - ((((unsigned long)(v)) >> 8) & 0xff); \ - ((unsigned char *)(p))[3] = \ - ((((unsigned long)(v)) ) & 0xff); } - -#ifdef NEED_SWAP - -/* Define IO byte swapping routines */ - -void md_swapin_exec_hdr __P((struct exec *)); -void md_swapout_exec_hdr __P((struct exec *)); -void md_swapin_reloc __P((struct relocation_info *, int)); -void md_swapout_reloc __P((struct relocation_info *, int)); -void md_swapout_jmpslot __P((jmpslot_t *, int)); - -#define md_swapin_symbols(s,n) swap_symbols(s,n) -#define md_swapout_symbols(s,n) swap_symbols(s,n) -#define md_swapin_zsymbols(s,n) swap_zsymbols(s,n) -#define md_swapout_zsymbols(s,n) swap_zsymbols(s,n) -#define md_swapin__dynamic(l) swap__dynamic(l) -#define md_swapout__dynamic(l) swap__dynamic(l) -#define md_swapin_section_dispatch_table(l) swap_section_dispatch_table(l) -#define md_swapout_section_dispatch_table(l) swap_section_dispatch_table(l) -#define md_swapin_so_debug(d) swap_so_debug(d) -#define md_swapout_so_debug(d) swap_so_debug(d) -#define md_swapin_rrs_hash(f,n) swap_rrs_hash(f,n) -#define md_swapout_rrs_hash(f,n) swap_rrs_hash(f,n) -#define md_swapin_sod(l,n) swapin_sod(l,n) -#define md_swapout_sod(l,n) swapout_sod(l,n) -#define md_swapout_got(g,n) swap_longs((long*)(g),n) -#define md_swapin_ranlib_hdr(h,n) swap_ranlib_hdr(h,n) -#define md_swapout_ranlib_hdr(h,n) swap_ranlib_hdr(h,n) - -#define md_swap_short(x) ( (((x) >> 8) & 0xff) | (((x) & 0xff) << 8) ) - -#define md_swap_long(x) ( (((x) >> 24) & 0xff ) | (((x) >> 8 ) & 0xff00 ) | \ - (((x) << 8 ) & 0xff0000) | (((x) << 24) & 0xff000000)) - -#else /* We need not swap, but must pay attention to alignment: */ - -#define md_swap_short(x) (x) -#define md_swap_long(x) (x) - -#endif /* NEED_SWAP */ - -#else /* Not a cross linker: use native */ - -#define md_swap_short(x) (x) -#define md_swap_long(x) (x) - -#define get_byte(where) (*(char *)(where)) -#define get_short(where) (*(short *)(where)) -#define get_long(where) (*(long *)(where)) - -#define put_byte(where,what) (*(char *)(where) = (what)) -#define put_short(where,what) (*(short *)(where) = (what)) -#define put_long(where,what) (*(long *)(where) = (what)) - -#endif /* CROSS_LINKER */ diff --git a/libexec/rtld-aout/i386/mdprologue.S b/libexec/rtld-aout/i386/mdprologue.S deleted file mode 100644 index 1de0f7200f1a..000000000000 --- a/libexec/rtld-aout/i386/mdprologue.S +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: mdprologue.S,v 1.7 1994/12/04 07:42:44 mycroft Exp $ - */ - -/* - * i386 run-time link editor entry points. - */ - -#include <sys/syscall.h> - - .text - .globl _binder, _binder_entry - -/* - * _rtl(int version, struct crt_ldso *crtp) - */ - -_rtl: # crt0 calls us here - pushl %ebp # Allocate stack frame - movl %esp,%ebp - pushl %ebx - - call 1f # PIC function prologue -1: - popl %ebx - addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx - - movl 12(%ebp),%eax # Extract data from interface structure - movl (%eax),%eax # base address of ld.so (first field) - # setup arguments for rtld() - movl (%ebx),%ecx # 1st entry in GOT is our __DYNAMIC - addl %eax,%ecx # add load address - pushl %ecx # 3rd arg - pushl 12(%ebp) # 2nd arg == &crt. - pushl 8(%ebp) # 1st arg == version - addl _rtld@GOT(%ebx),%eax # relocate address of function - call %eax # _rtld(version, crtp, DYNAMIC) - addl $12,%esp # pop arguments - - popl %ebx - leave # remove stack frame - ret - - # First call to a procedure generally comes through here for - # binding. - -_binder_entry: - pushl %ebp # setup a stack frame - movl %esp,%ebp - pusha # save all regs - - xorl %eax,%eax # clear - movl 4(%ebp),%esi # return address in PLT - movw (%esi),%ax # get hold of relocation number - subl $6,%esi # make it point to the jmpslot - - pushl %eax # pushd arguments - pushl %esi # - call _binder@PLT # _binder(rpc, index) - addl $8,%esp # pop arguments - movl %eax,4(%ebp) # return value from _binder() == actual - # address of function - popa # restore regs - leave # remove our stack frame - ret diff --git a/libexec/rtld-aout/md-prologue.c b/libexec/rtld-aout/md-prologue.c deleted file mode 100644 index dae455e02375..000000000000 --- a/libexec/rtld-aout/md-prologue.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * rtld entry pseudo code - turn into assembler and tweak it - */ - -#include <sys/types.h> -#include <sys/types.h> -#include <a.out.h> -#include "link.h" -#include "md.h" - -extern long _GOT_[]; -extern void (*rtld)(); -extern void (*binder())(); - -void -rtld_entry(version, crtp) -int version; -struct crt *crtp; -{ - register struct link_dynamic *dp; - register void (*f)(); - - /* __DYNAMIC is first entry in GOT */ - dp = (struct link_dynamic *) (_GOT_[0]+crtp->crt_ba); - - f = (void (*)())((long)rtld + crtp->crt_ba); - (*f)(version, crtp, dp); -} - -void -binder_entry() -{ - extern int PC; - struct jmpslot *sp; - void (*func)(); - - func = binder(PC, sp->reloc_index & 0x003fffff); - (*func)(); -} diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c deleted file mode 100644 index e0547af76d32..000000000000 --- a/libexec/rtld-aout/rtld.c +++ /dev/null @@ -1,1456 +0,0 @@ -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: rtld.c,v 1.23 1995/04/21 04:57:50 nate Exp $ - */ - -#include <sys/param.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/file.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/errno.h> -#include <sys/mman.h> -#ifndef MAP_COPY -#define MAP_COPY MAP_PRIVATE -#endif -#include <err.h> -#include <fcntl.h> -#include <a.out.h> -#include <stab.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -#include "ld.h" - -#ifndef MAP_ANON -#define MAP_ANON 0 -#define anon_open() do { \ - if ((anon_fd = open("/dev/zero", O_RDWR, 0)) == -1) \ - err("open: %s", "/dev/zero"); \ -} while (0) -#define anon_close() do { \ - (void)close(anon_fd); \ - anon_fd = -1; \ -} while (0) -#else -#define anon_open() -#define anon_close() -#endif - -/* - * Loader private data, hung off <so_map>->som_spd - */ -struct somap_private { - int spd_version; - struct so_map *spd_parent; - int spd_refcount; - int spd_flags; -#define RTLD_MAIN 1 -#define RTLD_RTLD 2 -#define RTLD_DL 4 - unsigned long a_text; /* text size, if known */ - unsigned long a_data; /* initialized data size */ - unsigned long a_bss; /* uninitialized data size */ - -#ifdef SUN_COMPAT - long spd_offset; /* Correction for Sun main programs */ -#endif -}; - -#define LM_PRIVATE(smp) ((struct somap_private *)(smp)->som_spd) - -#ifdef SUN_COMPAT -#define LM_OFFSET(smp) (LM_PRIVATE(smp)->spd_offset) -#else -#define LM_OFFSET(smp) (0) -#endif - -/* Base address for section_dispatch_table entries */ -#define LM_LDBASE(smp) (smp->som_addr + LM_OFFSET(smp)) - -/* Start of text segment */ -#define LM_TXTADDR(smp) (smp->som_addr == (caddr_t)0 ? PAGSIZ : 0) - -/* Start of run-time relocation_info */ -#define LM_REL(smp) ((struct relocation_info *) \ - (smp->som_addr + LM_OFFSET(smp) + LD_REL((smp)->som_dynamic))) - -/* Start of symbols */ -#define LM_SYMBOL(smp, i) ((struct nzlist *) \ - (smp->som_addr + LM_OFFSET(smp) + LD_SYMBOL((smp)->som_dynamic) + \ - i * (LD_VERSION_NZLIST_P(smp->som_dynamic->d_version) ? \ - sizeof(struct nzlist) : sizeof(struct nlist)))) - -/* Start of hash table */ -#define LM_HASH(smp) ((struct rrs_hash *) \ - ((smp)->som_addr + LM_OFFSET(smp) + LD_HASH((smp)->som_dynamic))) - -/* Start of strings */ -#define LM_STRINGS(smp) ((char *) \ - ((smp)->som_addr + LM_OFFSET(smp) + LD_STRINGS((smp)->som_dynamic))) - -/* End of text */ -#define LM_ETEXT(smp) ((char *) \ - ((smp)->som_addr + LM_TXTADDR(smp) + LD_TEXTSZ((smp)->som_dynamic))) - -/* Needed shared objects */ -#define LM_NEED(smp) ((struct sod *) \ - ((smp)->som_addr + LM_TXTADDR(smp) + LD_NEED((smp)->som_dynamic))) - -/* PLT is in data segment, so don't use LM_OFFSET here */ -#define LM_PLT(smp) ((jmpslot_t *) \ - ((smp)->som_addr + LD_PLT((smp)->som_dynamic))) - -/* Parent of link map */ -#define LM_PARENT(smp) (LM_PRIVATE(smp)->spd_parent) - -char **environ; -char *__progname; -int errno; - -static uid_t uid, euid; -static gid_t gid, egid; -static int careful; -static char __main_progname[] = "main"; -static char *main_progname = __main_progname; -static char us[] = "/usr/libexec/ld.so"; -static int anon_fd = -1; - -struct so_map *link_map_head, *main_map; -struct so_map **link_map_tail = &link_map_head; -struct rt_symbol *rt_symbol_head; - -static void *__dlopen __P((char *, int)); -static int __dlclose __P((void *)); -static void *__dlsym __P((void *, char *)); -static char *__dlerror __P((void)); - -static struct ld_entry ld_entry = { - __dlopen, __dlclose, __dlsym, __dlerror -}; - - void xprintf __P((char *, ...)); -static void load_objects __P(( struct crt_ldso *, - struct _dynamic *)); -static struct so_map *map_object __P((struct sod *, struct so_map *)); -static int unmap_object __P((struct so_map *)); -static struct so_map *alloc_link_map __P(( char *, struct sod *, - struct so_map *, caddr_t, - struct _dynamic *)); -static inline int check_text_reloc __P(( struct relocation_info *, - struct so_map *, - caddr_t)); -static int reloc_map __P((struct so_map *)); -static void reloc_copy __P((struct so_map *)); -static void init_map __P((struct so_map *, char *)); -static char *rtfindlib __P((char *, int, int, int *)); -void binder_entry __P((void)); -long binder __P((jmpslot_t *)); -static struct nzlist *lookup __P((char *, struct so_map **, int)); -static inline struct rt_symbol *lookup_rts __P((char *)); -static struct rt_symbol *enter_rts __P((char *, long, int, caddr_t, - long, struct so_map *)); -static void generror __P((char *, ...)); -static void maphints __P((void)); -static void unmaphints __P((void)); - -static int dl_cascade __P((struct so_map *)); - -static inline int -strcmp (register const char *s1, register const char *s2) -{ - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} - -#include "md-static-funcs.c" - -/* - * Called from assembler stub that has set up crtp (passed from crt0) - * and dp (our __DYNAMIC). - */ -int -rtld(version, crtp, dp) -int version; -struct crt_ldso *crtp; -struct _dynamic *dp; -{ - int n; - int nreloc; /* # of ld.so relocations */ - struct relocation_info *reloc; - struct so_debug *ddp; - struct so_map *smp; - - /* Check version */ - if (version != CRT_VERSION_BSD_2 && - version != CRT_VERSION_BSD_3 && - version != CRT_VERSION_SUN) - return -1; - - /* Fixup __DYNAMIC structure */ - (long)dp->d_un.d_sdt += crtp->crt_ba; - - /* Divide by hand to avoid possible use of library division routine */ - for (nreloc = 0, n = LD_RELSZ(dp); - n > 0; - n -= sizeof(struct relocation_info) ) nreloc++; - - - /* Relocate ourselves */ - for (reloc = (struct relocation_info *)(LD_REL(dp) + crtp->crt_ba); - nreloc; - nreloc--, reloc++) { - - register long addr = reloc->r_address + crtp->crt_ba; - - md_relocate_simple(reloc, crtp->crt_ba, addr); - } - - __progname = "ld.so"; - if (version >= CRT_VERSION_BSD_3) - main_progname = crtp->crt_prog; - - /* Setup out (private) environ variable */ - environ = crtp->crt_ep; - - /* Get user and group identifiers */ - uid = getuid(); euid = geteuid(); - gid = getgid(); egid = getegid(); - - careful = (uid != euid) || (gid != egid); - - if (careful) { - unsetenv("LD_LIBRARY_PATH"); - unsetenv("LD_PRELOAD"); - } - - /* Setup directory search */ - add_search_path(getenv("LD_LIBRARY_PATH")); - if (getenv("LD_NOSTD_PATH") == NULL) - std_search_path(); - - anon_open(); - /* Load required objects into the process address space */ - load_objects(crtp, dp); - - /* Relocate all loaded objects according to their RRS segments */ - for (smp = link_map_head; smp; smp = smp->som_next) { - if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD) - continue; - if (reloc_map(smp) < 0) - return -1; - } - - /* Copy any relocated initialized data. */ - for (smp = link_map_head; smp; smp = smp->som_next) { - if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD) - continue; - reloc_copy(smp); - } - - /* Call any object initialization routines. */ - for (smp = link_map_head; smp; smp = smp->som_next) { - if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD) - continue; - init_map(smp, ".init"); - } - - /* Fill in some field in main's __DYNAMIC structure */ - crtp->crt_dp->d_entry = &ld_entry; - crtp->crt_dp->d_un.d_sdt->sdt_loaded = link_map_head->som_next; - - ddp = crtp->crt_dp->d_debug; - ddp->dd_cc = rt_symbol_head; - if (ddp->dd_in_debugger) { - caddr_t addr = (caddr_t)((long)crtp->crt_bp & (~(PAGSIZ - 1))); - - /* Set breakpoint for the benefit of debuggers */ - if (mprotect(addr, PAGSIZ, - PROT_READ|PROT_WRITE|PROT_EXEC) == -1) { - err(1, "Cannot set breakpoint (%s)", main_progname); - } - md_set_breakpoint((long)crtp->crt_bp, (long *)&ddp->dd_bpt_shadow); - if (mprotect(addr, PAGSIZ, PROT_READ|PROT_EXEC) == -1) { - err(1, "Cannot re-protect breakpoint (%s)", - main_progname); - } - - ddp->dd_bpt_addr = crtp->crt_bp; - if (link_map_head) - ddp->dd_sym_loaded = 1; - } - - /* Close the hints file */ - unmaphints(); - - /* Close our file descriptor */ - (void)close(crtp->crt_ldfd); - anon_close(); - return 0; -} - - -static void -load_objects(crtp, dp) -struct crt_ldso *crtp; -struct _dynamic *dp; -{ - struct so_map *smp; - int tracing = (int)getenv("LD_TRACE_LOADED_OBJECTS"); - - /* Handle LD_PRELOAD's here */ - - /* Make an entry for the main program */ - smp = alloc_link_map(main_progname, (struct sod *)0, (struct so_map *)0, - (caddr_t)0, crtp->crt_dp); - LM_PRIVATE(smp)->spd_refcount++; - LM_PRIVATE(smp)->spd_flags |= RTLD_MAIN; - - /* Make an entry for ourselves */ - smp = alloc_link_map(us, (struct sod *)0, (struct so_map *)0, - (caddr_t)crtp->crt_ba, dp); - LM_PRIVATE(smp)->spd_refcount++; - LM_PRIVATE(smp)->spd_flags |= RTLD_RTLD; - - for (smp = link_map_head; smp; smp = smp->som_next) { - struct sod *sodp; - long next = 0; - - if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD) - continue; - - if (smp->som_dynamic) - next = LD_NEED(smp->som_dynamic); - - while (next) { - struct so_map *newmap; - - sodp = (struct sod *)(LM_LDBASE(smp) + next); - if ((newmap = map_object(sodp, smp)) == NULL) { - if (!tracing) { - char *name = (char *) - (sodp->sod_name + LM_LDBASE(smp)); - char *fmt = sodp->sod_library ? - "%s: lib%s.so.%d.%d" : - "%s: %s"; - err(1, fmt, main_progname, name, - sodp->sod_major, - sodp->sod_minor); - } - newmap = alloc_link_map(NULL, sodp, smp, 0, 0); - } - LM_PRIVATE(newmap)->spd_refcount++; - next = sodp->sod_next; - } - } - - if (! tracing) - return; - - for (smp = link_map_head; smp; smp = smp->som_next) { - struct sod *sodp; - char *name, *path; - - if ((sodp = smp->som_sod) == NULL) - continue; - name = sodp->sod_name + LM_LDBASE(LM_PARENT(smp)); - - if ((path = smp->som_path) == NULL) - path = "not found"; - - if (sodp->sod_library) - printf("\t-l%s.%d => %s (%p)\n", name, - sodp->sod_major, path, smp->som_addr); - else - printf("\t%s => %s (%p)\n", name, path, smp->som_addr); - } - - exit(0); -} - -/* - * Allocate a new link map for shared object NAME loaded at ADDR as a - * result of the presence of link object LOP in the link map PARENT. - */ - static struct so_map * -alloc_link_map(path, sodp, parent, addr, dp) - char *path; - struct sod *sodp; - struct so_map *parent; - caddr_t addr; - struct _dynamic *dp; -{ - struct so_map *smp; - struct somap_private *smpp; - size_t smp_size; - - /* - * Allocate so_map and private area with a single malloc. Round - * up the size of so_map so the private area is aligned. - */ - smp_size = ((((sizeof(struct so_map)) + sizeof (void *) - 1) / - sizeof (void *)) * sizeof (void *)); - - smp = (struct so_map *)xmalloc(smp_size + - sizeof (struct somap_private)); - smpp = (struct somap_private *) (((caddr_t) smp) + smp_size); - smp->som_next = NULL; - *link_map_tail = smp; - link_map_tail = &smp->som_next; - - smp->som_addr = addr; - if (path == NULL) - smp->som_path = NULL; - else - smp->som_path = strdup(path); - smp->som_sod = sodp; - smp->som_dynamic = dp; - smp->som_spd = (caddr_t)smpp; - -/*XXX*/ if (addr == 0) main_map = smp; - - smpp->spd_refcount = 0; - smpp->spd_flags = 0; - smpp->spd_parent = parent; - smpp->a_text = 0; - smpp->a_data = 0; - smpp->a_bss = 0; -#ifdef SUN_COMPAT - smpp->spd_offset = - (addr==0 && dp && dp->d_version==LD_VERSION_SUN) ? PAGSIZ : 0; -#endif - return smp; -} - -/* - * Map object identified by link object LOP which was found - * in link map LMP. - */ - static struct so_map * -map_object(sodp, smp) - struct sod *sodp; - struct so_map *smp; -{ - struct _dynamic *dp; - char *path, *name = (char *)(sodp->sod_name + LM_LDBASE(smp)); - int fd; - caddr_t addr; - struct exec hdr; - int usehints = 0; - struct so_map *p; - struct somap_private *smpp; - - if (sodp->sod_library) { - usehints = 1; -again: - path = rtfindlib(name, sodp->sod_major, - sodp->sod_minor, &usehints); - if (path == NULL) { - generror ("Can't find shared library \"%s\"", - name); - return NULL; - } - } else { - if (careful && *name != '/') { - generror ("Shared library path must start with \"/\" for \"%s\"", - name); - return NULL; - } - path = name; - } - - /* Check if already loaded */ - for (p = link_map_head; p; p = p->som_next) - if (p->som_path && strcmp(p->som_path, path) == 0) - break; - - if (p != NULL) - return p; - - if ((fd = open(path, O_RDONLY, 0)) == -1) { - if (usehints) { - usehints = 0; - goto again; - } - generror ("open failed for \"%s\" : %s", - path, strerror (errno)); - return NULL; - } - - if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) { - generror ("header read failed for \"%s\"", path); - (void)close(fd); - return NULL; - } - - if (N_BADMAG(hdr)) { - generror ("bad magic number in \"%s\"", path); - (void)close(fd); - return NULL; - } - - if ((addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss, - PROT_READ|PROT_EXEC, - MAP_COPY, fd, 0)) == (caddr_t)-1) { - generror ("mmap failed for \"%s\" : %s", - path, strerror (errno)); - (void)close(fd); - return NULL; - } - - if (mprotect(addr + hdr.a_text, hdr.a_data, - PROT_READ|PROT_WRITE|PROT_EXEC) != 0) { - generror ("mprotect failed for \"%s\" : %s", - path, strerror (errno)); - (void)close(fd); - return NULL; - } - - if (mmap(addr + hdr.a_text + hdr.a_data, hdr.a_bss, - PROT_READ|PROT_WRITE|PROT_EXEC, - MAP_ANON|MAP_COPY|MAP_FIXED, - anon_fd, 0) == (caddr_t)-1) { - generror ("mmap failed for \"%s\" : %s", - path, strerror (errno)); - (void)close(fd); - return NULL; - } - - (void)close(fd); - - /* Assume _DYNAMIC is the first data item */ - dp = (struct _dynamic *)(addr+hdr.a_text); - - /* Fixup __DYNAMIC structure */ - (long)dp->d_un.d_sdt += (long)addr; - - p = alloc_link_map(path, sodp, smp, addr, dp); - - /* save segment sizes for unmap. */ - smpp = LM_PRIVATE(p); - smpp->a_text = hdr.a_text; - smpp->a_data = hdr.a_data; - smpp->a_bss = hdr.a_bss; - return p; -} - -/* - * Unmap an object that is nolonger in use. - */ - static int -unmap_object(smp) - struct so_map *smp; -{ - struct so_map *prev, *p; - struct somap_private *smpp; - - /* Find the object in the list and unlink it */ - - for (prev = NULL, p = link_map_head; - p != smp; - prev = p, p = p->som_next) continue; - - if (prev == NULL) { - link_map_head = smp->som_next; - if (smp->som_next == NULL) - link_map_tail = &link_map_head; - } else { - prev->som_next = smp->som_next; - if (smp->som_next == NULL) - link_map_tail = &prev->som_next; - } - - /* Unmap the sections we have mapped */ - - smpp = LM_PRIVATE(smp); - - if (munmap(smp->som_addr, smpp->a_text + smpp->a_data) < 0) { - generror ("munmap failed: %s", strerror (errno)); - return -1; - } - if (smpp->a_bss > 0) { - if (munmap(smp->som_addr + smpp->a_text + smpp->a_data, - smpp->a_bss) < 0) { - generror ("munmap failed: %s", strerror (errno)); - return -1; - } - } - free((caddr_t) smp->som_sod->sod_name); - free(smp->som_sod); - free(smp); - return 0; -} - -static inline int -check_text_reloc(r, smp, addr) -struct relocation_info *r; -struct so_map *smp; -caddr_t addr; -{ - char *sym; - - if (addr >= LM_ETEXT(smp)) - return 0; - - if (RELOC_EXTERN_P(r)) - sym = LM_STRINGS(smp) + - LM_SYMBOL(smp, RELOC_SYMBOL(r))->nz_strx; - else - sym = ""; - - if (getenv("LD_SUPPRESS_WARNINGS") == NULL && - getenv("LD_WARN_NON_PURE_CODE") != NULL) - warnx("warning: non pure code in %s at %x (%s)", - smp->som_path, r->r_address, sym); - - if (smp->som_write == 0 && - mprotect(smp->som_addr + LM_TXTADDR(smp), - LD_TEXTSZ(smp->som_dynamic), - PROT_READ|PROT_WRITE|PROT_EXEC) == -1) { - generror ("mprotect failed for \"%s\" : %s", - smp->som_path, strerror (errno)); - return -1; - } - - smp->som_write = 1; - return 0; -} - -static int -reloc_map(smp) - struct so_map *smp; -{ - struct _dynamic *dp = smp->som_dynamic; - struct relocation_info *r = LM_REL(smp); - struct relocation_info *rend = r + LD_RELSZ(dp)/sizeof(*r); - long symbolbase = (long)LM_SYMBOL(smp, 0); - char *stringbase = LM_STRINGS(smp); - int symsize = LD_VERSION_NZLIST_P(dp->d_version) ? - sizeof(struct nzlist) : - sizeof(struct nlist); - - if (LD_PLTSZ(dp)) - md_fix_jmpslot(LM_PLT(smp), - (long)LM_PLT(smp), (long)binder_entry); - - for (; r < rend; r++) { - char *sym; - caddr_t addr = smp->som_addr + r->r_address; - - if (check_text_reloc(r, smp, addr) < 0) - return -1; - - if (RELOC_EXTERN_P(r)) { - struct so_map *src_map = NULL; - struct nzlist *p, *np; - long relocation = md_get_addend(r, addr); - - if (RELOC_LAZY_P(r)) - continue; - - p = (struct nzlist *) - (symbolbase + symsize * RELOC_SYMBOL(r)); - - if (p->nz_type == (N_SETV + N_EXT)) - src_map = smp; - - sym = stringbase + p->nz_strx; - - np = lookup(sym, &src_map, 0/*XXX-jumpslots!*/); - if (np == NULL) { - generror ("Undefined symbol \"%s\" in %s:%s", - sym, main_progname, smp->som_path); - return -1; - } - /* - * Found symbol definition. - * If it's in a link map, adjust value - * according to the load address of that map. - * Otherwise it's a run-time allocated common - * whose value is already up-to-date. - */ - relocation += np->nz_value; - if (src_map) - relocation += (long)src_map->som_addr; - - if (RELOC_PCREL_P(r)) - relocation -= (long)smp->som_addr; - - if (RELOC_COPY_P(r) && src_map) { - (void)enter_rts(sym, - (long)addr, - N_DATA + N_EXT, - src_map->som_addr + np->nz_value, - np->nz_size, src_map); - continue; - } - md_relocate(r, relocation, addr, 0); - - } else { - md_relocate(r, -#ifdef SUN_COMPAT - md_get_rt_segment_addend(r, addr) -#else - md_get_addend(r, addr) -#endif - + (long)smp->som_addr, addr, 0); - } - - } - - if (smp->som_write) { - if (mprotect(smp->som_addr + LM_TXTADDR(smp), - LD_TEXTSZ(smp->som_dynamic), - PROT_READ|PROT_EXEC) == -1) { - generror ("mprotect failed for \"%s\" : %s", - smp->som_path, strerror (errno)); - return -1; - } - smp->som_write = 0; - } - return 0; -} - -static void -reloc_copy(smp) - struct so_map *smp; -{ - struct rt_symbol *rtsp; - - for (rtsp = rt_symbol_head; rtsp; rtsp = rtsp->rt_next) - if ((rtsp->rt_smp == NULL || rtsp->rt_smp == smp) && - rtsp->rt_sp->nz_type == N_DATA + N_EXT) { - bcopy(rtsp->rt_srcaddr, (caddr_t)rtsp->rt_sp->nz_value, - rtsp->rt_sp->nz_size); - } -} - -static void -init_map(smp, sym) - struct so_map *smp; - char *sym; -{ - struct so_map *src_map = smp; - struct nzlist *np; - - np = lookup(sym, &src_map, 1); - if (np) - (*(void (*)())(src_map->som_addr + np->nz_value))(); -} - -/* - * Run-time common symbol table. - */ - -#define RTC_TABSIZE 57 -static struct rt_symbol *rt_symtab[RTC_TABSIZE]; - -/* - * Compute hash value for run-time symbol table - */ - static inline int -hash_string(key) - char *key; -{ - register char *cp; - register int k; - - cp = key; - k = 0; - while (*cp) - k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff; - - return k; -} - -/* - * Lookup KEY in the run-time common symbol table. - */ - - static inline struct rt_symbol * -lookup_rts(key) - char *key; -{ - register int hashval; - register struct rt_symbol *rtsp; - - /* Determine which bucket. */ - - hashval = hash_string(key) % RTC_TABSIZE; - - /* Search the bucket. */ - - for (rtsp = rt_symtab[hashval]; rtsp; rtsp = rtsp->rt_link) - if (strcmp(key, rtsp->rt_sp->nz_name) == 0) - return rtsp; - - return NULL; -} - - static struct rt_symbol * -enter_rts(name, value, type, srcaddr, size, smp) - char *name; - long value; - int type; - caddr_t srcaddr; - long size; - struct so_map *smp; -{ - register int hashval; - register struct rt_symbol *rtsp, **rpp; - - /* Determine which bucket */ - hashval = hash_string(name) % RTC_TABSIZE; - - /* Find end of bucket */ - for (rpp = &rt_symtab[hashval]; *rpp; rpp = &(*rpp)->rt_link) - continue; - - /* Allocate new common symbol */ - rtsp = (struct rt_symbol *)malloc(sizeof(struct rt_symbol)); - rtsp->rt_sp = (struct nzlist *)malloc(sizeof(struct nzlist)); - rtsp->rt_sp->nz_name = strdup(name); - rtsp->rt_sp->nz_value = value; - rtsp->rt_sp->nz_type = type; - rtsp->rt_sp->nz_size = size; - rtsp->rt_srcaddr = srcaddr; - rtsp->rt_smp = smp; - rtsp->rt_link = NULL; - - /* Link onto linear list as well */ - rtsp->rt_next = rt_symbol_head; - rt_symbol_head = rtsp; - - *rpp = rtsp; - - return rtsp; -} - - -/* - * Lookup NAME in the link maps. The link map producing a definition - * is returned in SRC_MAP. If SRC_MAP is not NULL on entry the search is - * confined to that map. If STRONG is set, the symbol returned must - * have a proper type (used by binder()). - */ - static struct nzlist * -lookup(name, src_map, strong) - char *name; - struct so_map **src_map; /* IN/OUT */ - int strong; -{ - long common_size = 0; - struct so_map *smp; - struct rt_symbol *rtsp; - - if ((rtsp = lookup_rts(name)) != NULL) - return rtsp->rt_sp; - - /* - * Search all maps for a definition of NAME - */ - for (smp = link_map_head; smp; smp = smp->som_next) { - int buckets; - long hashval; - struct rrs_hash *hp; - char *cp; - struct nzlist *np; - - /* Some local caching */ - long symbolbase; - struct rrs_hash *hashbase; - char *stringbase; - int symsize; - - if (*src_map && smp != *src_map) - continue; - - if ((buckets = LD_BUCKETS(smp->som_dynamic)) == 0) - continue; - - if (LM_PRIVATE(smp)->spd_flags & RTLD_RTLD) - continue; - -restart: - /* - * Compute bucket in which the symbol might be found. - */ - for (hashval = 0, cp = name; *cp; cp++) - hashval = (hashval << 1) + *cp; - - hashval = (hashval & 0x7fffffff) % buckets; - - hashbase = LM_HASH(smp); - hp = hashbase + hashval; - if (hp->rh_symbolnum == -1) - /* Nothing in this bucket */ - continue; - - symbolbase = (long)LM_SYMBOL(smp, 0); - stringbase = LM_STRINGS(smp); - symsize = LD_VERSION_NZLIST_P(smp->som_dynamic->d_version)? - sizeof(struct nzlist) : - sizeof(struct nlist); - while (hp) { - np = (struct nzlist *) - (symbolbase + hp->rh_symbolnum * symsize); - cp = stringbase + np->nz_strx; - if (strcmp(cp, name) == 0) - break; - if (hp->rh_next == 0) - hp = NULL; - else - hp = hashbase + hp->rh_next; - } - if (hp == NULL) - /* Nothing in this bucket */ - continue; - - /* - * We have a symbol with the name we're looking for. - */ - if (np->nz_type == N_INDR+N_EXT) { - /* - * Next symbol gives the aliased name. Restart - * search with new name and confine to this map. - */ - name = stringbase + (++np)->nz_strx; - *src_map = smp; - goto restart; - } - - if (np->nz_value == 0) - /* It's not a definition */ - continue; - - if (np->nz_type == N_UNDF+N_EXT && np->nz_value != 0) { - if (np->nz_other == AUX_FUNC) { - /* It's a weak function definition */ - if (strong) - continue; - } else { - /* It's a common, note value and continue search */ - if (common_size < np->nz_value) - common_size = np->nz_value; - continue; - } - } - - *src_map = smp; - return np; - } - - if (common_size == 0) - /* Not found */ - return NULL; - - /* - * It's a common, enter into run-time common symbol table. - */ - rtsp = enter_rts(name, (long)calloc(1, common_size), - N_UNDF + N_EXT, 0, common_size, NULL); - -#if DEBUG - xprintf("Allocating common: %s size %d at %#x\n", name, common_size, - rtsp->rt_sp->nz_value); -#endif - - return rtsp->rt_sp; -} - - -/* - * This routine is called from the jumptable to resolve - * procedure calls to shared objects. - */ - long -binder(jsp) - jmpslot_t *jsp; -{ - struct so_map *smp, *src_map = NULL; - long addr; - char *sym; - struct nzlist *np; - int index; - - /* - * Find the PLT map that contains JSP. - */ - for (smp = link_map_head; smp; smp = smp->som_next) { - if (LM_PLT(smp) < jsp && - jsp < LM_PLT(smp) + LD_PLTSZ(smp->som_dynamic)/sizeof(*jsp)) - break; - } - - if (smp == NULL) - errx(1, "Call to binder from unknown location: %#x\n", jsp); - - index = jsp->reloc_index & JMPSLOT_RELOC_MASK; - - /* Get the local symbol this jmpslot refers to */ - sym = LM_STRINGS(smp) + - LM_SYMBOL(smp,RELOC_SYMBOL(&LM_REL(smp)[index]))->nz_strx; - - np = lookup(sym, &src_map, 1); - if (np == NULL) - errx(1, "Undefined symbol \"%s\" called from %s:%s at %#x", - sym, main_progname, smp->som_path, jsp); - - /* Fixup jmpslot so future calls transfer directly to target */ - addr = np->nz_value; - if (src_map) - addr += (long)src_map->som_addr; - - md_fix_jmpslot(jsp, (long)jsp, addr); - -#if DEBUG - xprintf(" BINDER: %s located at = %#x in %s\n", sym, addr, - src_map->som_path); -#endif - return addr; -} - - -static int hfd; -static long hsize; -static struct hints_header *hheader; -static struct hints_bucket *hbuckets; -static char *hstrtab; - -#define HINTS_VALID (hheader != NULL && hheader != (struct hints_header *)-1) - - static void -maphints __P((void)) -{ - caddr_t addr; - - if ((hfd = open(_PATH_LD_HINTS, O_RDONLY, 0)) == -1) { - hheader = (struct hints_header *)-1; - return; - } - - hsize = PAGSIZ; - addr = mmap(0, hsize, PROT_READ, MAP_COPY, hfd, 0); - - if (addr == (caddr_t)-1) { - close(hfd); - hheader = (struct hints_header *)-1; - return; - } - - hheader = (struct hints_header *)addr; - if (HH_BADMAG(*hheader)) { - munmap(addr, hsize); - close(hfd); - hheader = (struct hints_header *)-1; - return; - } - - if (hheader->hh_version != LD_HINTS_VERSION_1) { - munmap(addr, hsize); - close(hfd); - hheader = (struct hints_header *)-1; - return; - } - - if (hheader->hh_ehints > hsize) { - if (mmap(addr+hsize, hheader->hh_ehints - hsize, - PROT_READ, MAP_COPY|MAP_FIXED, - hfd, hsize) != (caddr_t)(addr+hsize)) { - - munmap((caddr_t)hheader, hsize); - close(hfd); - hheader = (struct hints_header *)-1; - return; - } - } - - hbuckets = (struct hints_bucket *)(addr + hheader->hh_hashtab); - hstrtab = (char *)(addr + hheader->hh_strtab); -} - - static void -unmaphints() -{ - - if (HINTS_VALID) { - munmap((caddr_t)hheader, hsize); - close(hfd); - hheader = NULL; - } -} - - int -hinthash(cp, vmajor) - char *cp; - int vmajor; -{ - int k = 0; - - while (*cp) - k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff; - - k = (((k << 1) + (k >> 14)) ^ (vmajor*257)) & 0x3fff; - - return k; -} - -#undef major -#undef minor - - static char * -findhint(name, major, minor, preferred_path) - char *name; - int major, minor; - char *preferred_path; -{ - struct hints_bucket *bp; - - bp = hbuckets + (hinthash(name, major) % hheader->hh_nbucket); - - while (1) { - /* Sanity check */ - if (bp->hi_namex >= hheader->hh_strtab_sz) { - warnx("Bad name index: %#x\n", bp->hi_namex); - break; - } - if (bp->hi_pathx >= hheader->hh_strtab_sz) { - warnx("Bad path index: %#x\n", bp->hi_pathx); - break; - } - - if (strcmp(name, hstrtab + bp->hi_namex) == 0) { - /* It's `name', check version numbers */ - if (bp->hi_major == major && - (bp->hi_ndewey < 2 || bp->hi_minor >= minor)) { - if (preferred_path == NULL || - strcmp(preferred_path, - hstrtab + bp->hi_pathx) == 0) { - return hstrtab + bp->hi_pathx; - } - } - } - - if (bp->hi_next == -1) - break; - - /* Move on to next in bucket */ - bp = &hbuckets[bp->hi_next]; - } - - /* No hints available for name */ - return NULL; -} - - static char * -rtfindlib(name, major, minor, usehints) - char *name; - int major, minor; - int *usehints; -{ - char *cp, *ld_path = getenv("LD_LIBRARY_PATH"); - int realminor; - - if (hheader == NULL) - maphints(); - - if (!HINTS_VALID || !(*usehints)) - goto lose; - - if (ld_path != NULL) { - /* Prefer paths from LD_LIBRARY_PATH */ - while ((cp = strsep(&ld_path, ":")) != NULL) { - - cp = findhint(name, major, minor, cp); - if (ld_path) - *(ld_path-1) = ':'; - if (cp) - return cp; - } - /* Not found in hints, try directory search */ - realminor = -1; - cp = (char *)findshlib(name, &major, &realminor, 0); - if (cp && realminor >= minor) - return cp; - } - - /* No LD_LIBRARY_PATH or lib not found in there; check default */ - cp = findhint(name, major, minor, NULL); - if (cp) - return cp; - -lose: - /* No hints available for name */ - *usehints = 0; - realminor = -1; - cp = (char *)findshlib(name, &major, &realminor, 0); - if (cp) { - if (realminor < minor && getenv("LD_SUPPRESS_WARNINGS") == NULL) - warnx("warning: lib%s.so.%d.%d: " - "minor version < %d expected, using it anyway", - name, major, realminor, minor); - return cp; - } - generror ("Can't find shared library \"%s\"", - name); - return NULL; -} - -static struct somap_private dlmap_private = { - 0, - (struct so_map *)0, - 0, -#ifdef SUN_COMPAT - 0, -#endif -}; - -static struct so_map dlmap = { - (caddr_t)0, - "internal", - (struct so_map *)0, - (struct sod *)0, - (caddr_t)0, - (u_int)0, - (struct _dynamic *)0, - (caddr_t)&dlmap_private -}; - -/* - * Buffer for error messages and a pointer that is set to point to the buffer - * when a error occurs. It acts as a last error flag, being set to NULL - * after an error is returned. - */ -#define DLERROR_BUF_SIZE 512 -static char dlerror_buf [DLERROR_BUF_SIZE]; -static char *dlerror_msg = NULL; - - static void * -__dlopen(name, mode) - char *name; - int mode; -{ - struct sod *sodp; - struct so_map *smp; - - /* - * A NULL argument returns the current set of mapped objects. - */ - if (name == NULL) { - LM_PRIVATE(link_map_head)->spd_refcount++; - return link_map_head; - } - if ((sodp = (struct sod *)malloc(sizeof(struct sod))) == NULL) { - generror ("malloc failed: %s", strerror (errno)); - return NULL; - } - - sodp->sod_name = (long)strdup(name); - sodp->sod_library = 0; - sodp->sod_major = sodp->sod_minor = 0; - - if ((smp = map_object(sodp, &dlmap)) == NULL) { -#ifdef DEBUG - xprintf("%s: %s\n", name, dlerror_buf); -#endif - return NULL; - } - - if (dl_cascade(smp) == 0) - return NULL; - - if (LM_PRIVATE(smp)->spd_refcount++ == 0) { - LM_PRIVATE(smp)->spd_flags |= RTLD_DL; - if (reloc_map(smp) < 0) - return NULL; - reloc_copy(smp); - init_map(smp, ".init"); - init_map(smp, "_init"); - } - - return smp; -} - - static int -__dlclose(fd) - void *fd; -{ - struct so_map *smp = (struct so_map *)fd; - -#ifdef DEBUG - xprintf("dlclose(%s): refcount = %d\n", smp->som_path, - LM_PRIVATE(smp)->spd_refcount); -#endif - if (--LM_PRIVATE(smp)->spd_refcount != 0) - return 0; - - /* Dismantle shared object map and descriptor */ - init_map(smp, "_fini"); - - if (unmap_object(smp) < 0) - return -1; - - return 0; -} - - static void * -__dlsym(fd, sym) - void *fd; - char *sym; -{ - struct so_map *smp = (struct so_map *)fd, *src_map = NULL; - struct nzlist *np; - long addr; - - /* - * Restrict search to passed map if dlopen()ed. - */ - if (smp && LM_PRIVATE(smp)->spd_flags & RTLD_DL) - src_map = smp; - - np = lookup(sym, &src_map, 1); - if (np == NULL) { - generror ("Symbol \"%s\" not found", sym); - return NULL; - } - /* Fixup jmpslot so future calls transfer directly to target */ - addr = np->nz_value; - if (src_map) - addr += (long)src_map->som_addr; - - return (void *)addr; -} - - static char * -__dlerror __P((void)) -{ - char *err; - - err = dlerror_msg; - dlerror_msg = NULL; /* Next call will return NULL */ - - return err; -} - -/* - * Generate an error message that can be later be retrieved via dlerror. - */ -static void -#if __STDC__ -generror(char *fmt, ...) -#else -generror(fmt, va_alist) -char *fmt; -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - vsnprintf (dlerror_buf, DLERROR_BUF_SIZE, fmt, ap); - dlerror_msg = dlerror_buf; - - va_end(ap); -} - -void -#if __STDC__ -xprintf(char *fmt, ...) -#else -xprintf(fmt, va_alist) -char *fmt; -#endif -{ - char buf[256]; - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - - vsprintf(buf, fmt, ap); - (void)write(1, buf, strlen(buf)); - va_end(ap); -} - -static int -dl_cascade(smp) - struct so_map *smp; -{ - struct sod *sodp; - struct so_map *smp2; - long next; - - next = LD_NEED(smp->som_dynamic); - - while (next) { - sodp = (struct sod *)(LM_LDBASE(smp) + next); - if ((smp2 = map_object(sodp, smp)) == NULL) { -#ifdef DEBUG -xprintf("ld.so: map_object failed on cascaded %s %s (%d.%d): %s\n", - smp->sod_library ? "library" : "file", smp->sod_name, - smp->sod_major, smp->sod_minor, strerror(errno)); -#endif - return 0; - } -#if 0 - /* - * XXX - this doesn't work for some reason. not - * at all sure why. -mrg - */ - if (dl_cascade(smp2) == 0) - return 0; -#endif - - if (LM_PRIVATE(smp2)->spd_refcount++ == 0) { - LM_PRIVATE(smp2)->spd_flags |= RTLD_DL; - reloc_map(smp2); - reloc_copy(smp2); - init_map(smp2, ".init"); - init_map(smp2, "_init"); - } - - next = sodp->sod_next; - } - return 1; -} diff --git a/libexec/rtld-aout/shlib.c b/libexec/rtld-aout/shlib.c deleted file mode 100644 index f256508b55d7..000000000000 --- a/libexec/rtld-aout/shlib.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 1993 Paul Kranenburg - * 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 Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $Id: shlib.c,v 1.12 1995/03/04 17:46:09 nate Exp $ - */ - -#include <sys/param.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/file.h> -#include <sys/time.h> -#include <err.h> -#include <fcntl.h> -#include <string.h> -#include <ctype.h> -#include <dirent.h> -#include <a.out.h> - -#include "ld.h" - -#ifdef SUNOS4 -char *strsep(); -#endif - -/* - * Standard directories to search for files specified by -l. - */ -#ifndef STANDARD_SEARCH_DIRS -#define STANDARD_SEARCH_DIRS "/usr/lib" -#endif - -/* - * Actual vector of library search directories, - * including `-L'ed and LD_LIBARAY_PATH spec'd ones. - */ -char **search_dirs; -int n_search_dirs; - -char *standard_search_dirs[] = { - STANDARD_SEARCH_DIRS -}; - - -void -add_search_dir(name) - char *name; -{ - n_search_dirs++; - search_dirs = (char **) - xrealloc(search_dirs, n_search_dirs * sizeof(char *)); - search_dirs[n_search_dirs - 1] = strdup(name); -} - -void -add_search_path(path) -char *path; -{ - register char *cp; - - if (path == NULL) - return; - - /* Add search directories from `paths' */ - while ((cp = strsep(&path, ":")) != NULL) { - add_search_dir(cp); - if (path) - *(path-1) = ':'; - } -} - -void -std_search_path() -{ - int i, n; - - /* Append standard search directories */ - n = sizeof standard_search_dirs / sizeof standard_search_dirs[0]; - for (i = 0; i < n; i++) - add_search_dir(standard_search_dirs[i]); -} - -/* - * Return true if CP points to a valid dewey number. - * Decode and leave the result in the array DEWEY. - * Return the number of decoded entries in DEWEY. - */ - -int -getdewey(dewey, cp) -int dewey[]; -char *cp; -{ - int i, n; - - for (n = 0, i = 0; i < MAXDEWEY; i++) { - if (*cp == '\0') - break; - - if (*cp == '.') cp++; - if (!isdigit(*cp)) - return 0; - - dewey[n++] = strtol(cp, &cp, 10); - } - - return n; -} - -/* - * Compare two dewey arrays. - * Return -1 if `d1' represents a smaller value than `d2'. - * Return 1 if `d1' represents a greater value than `d2'. - * Return 0 if equal. - */ -int -cmpndewey(d1, n1, d2, n2) -int d1[], d2[]; -int n1, n2; -{ - register int i; - - for (i = 0; i < n1 && i < n2; i++) { - if (d1[i] < d2[i]) - return -1; - if (d1[i] > d2[i]) - return 1; - } - - if (n1 == n2) - return 0; - - if (i == n1) - return -1; - - if (i == n2) - return 1; - - errx(1, "cmpndewey: cant happen"); - return 0; -} - -/* - * Search directories for a shared library matching the given - * major and minor version numbers. - * - * MAJOR == -1 && MINOR == -1 --> find highest version - * MAJOR != -1 && MINOR == -1 --> find highest minor version - * MAJOR == -1 && MINOR != -1 --> invalid - * MAJOR != -1 && MINOR != -1 --> find highest micro version - */ - -/* Not interested in devices right now... */ -#undef major -#undef minor - -char * -findshlib(name, majorp, minorp, do_dot_a) -char *name; -int *majorp, *minorp; -int do_dot_a; -{ - int dewey[MAXDEWEY]; - int ndewey; - int tmp[MAXDEWEY]; - int i; - int len; - char *lname, *path = NULL; - int major = *majorp, minor = *minorp; - - len = strlen(name); - lname = (char *)alloca(len + sizeof("lib")); - sprintf(lname, "lib%s", name); - len += 3; - - ndewey = 0; - - for (i = 0; i < n_search_dirs; i++) { - DIR *dd = opendir(search_dirs[i]); - struct dirent *dp; - int found_dot_a = 0; - - if (dd == NULL) - continue; - - while ((dp = readdir(dd)) != NULL) { - int n, might_take_it = 0; - - if (do_dot_a && path == NULL && - dp->d_namlen == len + 2 && - strncmp(dp->d_name, lname, len) == 0 && - (dp->d_name+len)[0] == '.' && - (dp->d_name+len)[1] == 'a') { - - path = concat(search_dirs[i], "/", dp->d_name); - found_dot_a = 1; - } - - if (dp->d_namlen < len + 4) - continue; - if (strncmp(dp->d_name, lname, len) != 0) - continue; - if (strncmp(dp->d_name+len, ".so.", 4) != 0) - continue; - - if ((n = getdewey(tmp, dp->d_name+len+4)) == 0) - continue; - - if (major != -1 && found_dot_a) { /* XXX */ - free(path); - path = NULL; - found_dot_a = 0; - } - - if (major == -1 && minor == -1) { - might_take_it = 1; - } else if (major != -1 && minor == -1) { - if (tmp[0] == major) - might_take_it = 1; - } else if (major != -1 && minor != -1) { - if (tmp[0] == major) - if (n == 1 || tmp[1] >= minor) - might_take_it = 1; - } - - if (!might_take_it) - continue; - - if (cmpndewey(tmp, n, dewey, ndewey) <= 0) - continue; - - /* We have a better version */ - if (path) - free(path); - path = concat(search_dirs[i], "/", dp->d_name); - found_dot_a = 0; - bcopy(tmp, dewey, sizeof(dewey)); - ndewey = n; - *majorp = dewey[0]; - *minorp = dewey[1]; - } - closedir(dd); - - if (found_dot_a) - /* - * There's a .a archive here. - */ - return path; - } - - return path; -} diff --git a/libexec/telnetd/authenc.c b/libexec/telnetd/authenc.c deleted file mode 100644 index fcd17fcf73b6..000000000000 --- a/libexec/telnetd/authenc.c +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * 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.1 (Berkeley) 6/4/93"; -#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) { - bcopy((void *)str, (void *)nfrontp, 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) */ |
