From 96a58b2a60c4e7731141d5740552a4f9677de77b Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 16 Nov 2006 00:49:20 +0000 Subject: [PATCH] more uucp cleanup --- libexec/Makefile | 4 +- libexec/getty/Makefile | 6 +- libexec/uucpd/Makefile | 10 -- libexec/uucpd/pathnames.h | 36 ----- libexec/uucpd/uucpd.8 | 72 --------- libexec/uucpd/uucpd.c | 317 -------------------------------------- 6 files changed, 5 insertions(+), 440 deletions(-) delete mode 100644 libexec/uucpd/Makefile delete mode 100644 libexec/uucpd/pathnames.h delete mode 100644 libexec/uucpd/uucpd.8 delete mode 100644 libexec/uucpd/uucpd.c diff --git a/libexec/Makefile b/libexec/Makefile index 297968c5168e..8cd6b18a485e 100644 --- a/libexec/Makefile +++ b/libexec/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.50 2006/11/12 01:27:29 christos Exp $ +# $NetBSD: Makefile,v 1.51 2006/11/16 00:49:20 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 .include @@ -6,7 +6,7 @@ SUBDIR= atrun comsat fingerd ftpd getNAME getty identd ld.aout_so \ ld.elf_so lfs_cleanerd mail.local makekey makewhatis rexecd \ rlogind rshd rpc.rquotad rpc.rstatd rpc.rusersd rpc.rwalld \ - rpc.sprayd talkd telnetd tftpd utmp_update uucpd + rpc.sprayd talkd telnetd tftpd utmp_update .if (${MKKERBEROS} != "no") # Heimdal/KTH Kerberos diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile index 1133f599e304..5cd22bddb1ce 100644 --- a/libexec/getty/Makefile +++ b/libexec/getty/Makefile @@ -1,13 +1,13 @@ -# $NetBSD: Makefile,v 1.14 2006/05/11 23:16:29 mrg Exp $ +# $NetBSD: Makefile,v 1.15 2006/11/16 00:49:20 christos Exp $ # from: @(#)Makefile 8.1 (Berkeley) 6/4/93 PROG= getty -LINKS= ${BINDIR}/getty ${BINDIR}/uugetty +LINKS= ${BINDIR}/getty SRCS= main.c init.c subr.c DPADD+= ${LIBUTIL} ${LIBTERMCAP} LDADD+= -lutil -ltermcap MAN= getty.8 gettytab.5 ttys.5 -MLINKS+=getty.8 uugetty.8 +MLINKS+=getty.8 .include diff --git a/libexec/uucpd/Makefile b/libexec/uucpd/Makefile deleted file mode 100644 index 88bd6d814ec2..000000000000 --- a/libexec/uucpd/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile,v 1.9 2002/08/20 14:01:49 christos Exp $ -# from: @(#)Makefile 8.1 (Berkeley) 6/4/93 - -PROG= uucpd -MAN= uucpd.8 -LDADD+= -lcrypt -lutil -DPADD+= ${LIBCRYPT} ${LIBUTIL} -CPPFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX - -.include diff --git a/libexec/uucpd/pathnames.h b/libexec/uucpd/pathnames.h deleted file mode 100644 index cb2872524853..000000000000 --- a/libexec/uucpd/pathnames.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: pathnames.h,v 1.4 2003/08/07 09:46:53 agc Exp $ */ - -/* - * Copyright (c) 1989 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. 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. - * - * from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90 - */ - -#include - -#define _PATH_UUCICO "/usr/libexec/uucp/uucico" diff --git a/libexec/uucpd/uucpd.8 b/libexec/uucpd/uucpd.8 deleted file mode 100644 index 44416cd6206f..000000000000 --- a/libexec/uucpd/uucpd.8 +++ /dev/null @@ -1,72 +0,0 @@ -.\" $NetBSD: uucpd.8,v 1.5 2002/01/15 02:29:01 wiz Exp $ -.\" -.\" Copyright (c) 1998 Matthew R. Green -.\" 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. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd July 4, 1998 -.Dt UUCPD 8 -.Os -.Sh NAME -.Nm uucpd -.Nd unix to unix copy protocol daemon -.Sh SYNOPSIS -.Nm -.Op Fl l -.Sh DESCRIPTION -The -.Nm -daemon reads a username and password, and then executes -.Xr uucico 8 , -the -.Tn UUCP -file transfer daemon, if the following conditions are met: -.Bl -enum -.It -the username and password match a valid account -.It -the accounts shell is -.Dq /usr/libexec/uucp/uucico . -.El -.Pp -.Nm -is started by -.Xr inetd 8 . -.Sh OPTIONS -.Bl -tag -width 12345 -.It Fl l -The -.Fl l -option logs all connections via -.Xr syslog 3 . -.El -.Sh SEE ALSO -.Xr inetd 8 , -.Xr uucico 8 -.Sh HISTORY -The -.Nm -program was first made available in -.Bx 4.2 . diff --git a/libexec/uucpd/uucpd.c b/libexec/uucpd/uucpd.c deleted file mode 100644 index b633c7adac75..000000000000 --- a/libexec/uucpd/uucpd.c +++ /dev/null @@ -1,317 +0,0 @@ -/* $NetBSD: uucpd.c,v 1.24 2006/05/09 20:18:08 mrg Exp $ */ - -/* - * Copyright (c) 1985 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Adams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the 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. - */ - -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1985 The Regents of the University of California.\n\ - All rights reserved.\n"); -#if 0 -static char sccsid[] = "from: @(#)uucpd.c 5.10 (Berkeley) 2/26/91"; -#else -__RCSID("$NetBSD: uucpd.c,v 1.24 2006/05/09 20:18:08 mrg Exp $"); -#endif -#endif /* not lint */ - -/* - * 4.2BSD TCP/IP server for uucico - * uucico's TCP channel causes this server to be run at the remote end. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef SUPPORT_UTMP -#include -#endif -#ifdef SUPPORT_UTMPX -#include -#endif - -#include "pathnames.h" - -struct sockaddr_storage hisctladdr; -socklen_t hisaddrlen = sizeof hisctladdr; -int mypid; - -char Logname[64], Username[64]; -char *nenv[] = { - Logname, - Username, - NULL, -}; -int dolog; - -extern char **environ; - -void dologout __P((void)); -void dologin __P((struct passwd *, struct sockaddr *)); -void doit __P((struct sockaddr *)); -int readline __P((char *, int)); -int main __P((int, char **)); - -int -main(argc, argv) - int argc; - char **argv; -{ - int ch; - - while ((ch = getopt(argc, argv, "l")) != -1) - switch (ch) { - case 'l': - dolog = 1; - break; - default: - exit(1); - } - - if (dolog) - openlog("uucpd", LOG_PID, LOG_AUTH); - environ = nenv; - close(1); - close(2); - dup(0); - dup(0); - hisaddrlen = sizeof (hisctladdr); - if (getpeername(0, (struct sockaddr *)&hisctladdr, &hisaddrlen) < 0) { - fprintf(stderr, "%s: ", argv[0]); - perror("getpeername"); - if (dolog) - syslog(LOG_ERR, "getpeername failed: %m"); - exit(1); - } - switch (fork()) { - case -1: - break; - case 0: - doit((struct sockaddr *)&hisctladdr); - break; - default: - dologout(); - } - exit(1); -} - -void -doit(sa) - struct sockaddr *sa; -{ - char user[64], passwd[64]; - char *xpasswd = NULL; /* XXX gcc */ - struct passwd *pw; - - alarm(60); - do { - printf("login: "); - fflush(stdout); - if (readline(user, sizeof user) < 0) { - fprintf(stderr, "user read\n"); - if (dolog) - syslog(LOG_ERR, "user read failed: %m"); - return; - } - } while (user[0] == '\0'); - /* ensure username is NUL-terminated */ - user[sizeof(user)-1] = '\0'; - pw = getpwnam(user); - if (pw == NULL || (pw->pw_passwd && *pw->pw_passwd != '\0')) { - printf("Password: "); - fflush(stdout); - if (readline(passwd, sizeof passwd) < 0) { - fprintf(stderr, "passwd read\n"); - if (dolog) - syslog(LOG_ERR, "passwd read failed: %m"); - return; - } - if (pw != NULL) - xpasswd = crypt(passwd, pw->pw_passwd); - - if (pw == NULL || strcmp(xpasswd, pw->pw_passwd)) { - fprintf(stderr, "Login incorrect.\n"); - if (dolog) - syslog(LOG_ERR, "incorrect password from %s", - user); - return; - } - } else - (void)crypt("dummy password", "PA"); /* must always crypt */ - if (strcmp(pw->pw_shell, _PATH_UUCICO)) { - fprintf(stderr, "Login incorrect.\n"); - if (dolog) - syslog(LOG_ERR, "incorrect shell for %s", user); - return; - } - alarm(0); - snprintf(Logname, sizeof(Logname), "LOGNAME=%s", user); - snprintf(Username, sizeof(Username), "USER=%s", user); - dologin(pw, sa); - if (initgroups(pw->pw_name, pw->pw_gid) < 0 || - setgid(pw->pw_gid) < 0 || - chdir(pw->pw_dir) < 0 || - setsid() < 0 || - setlogin(user) < 0 || - setuid(pw->pw_uid) < 0) { - fprintf(stderr, "Could not set permissions.\n"); - if (dolog) - syslog(LOG_ERR,"couldn't set user %s's permissions: %m", - user); - return; - } - if (dolog) - syslog(LOG_INFO, "%s has logged in", user); - execl(_PATH_UUCICO, "uucico", (char *)0); - perror("uucico server: execl"); - if (dolog) - syslog(LOG_ERR, "execl failed: %m"); -} - -int -readline(p, n) - char *p; - int n; -{ - char c; - - while (n-- > 0) { - if (read(0, &c, 1) <= 0) - return(-1); - c &= 0177; - if (c == '\r') { - *p = '\0'; - return(0); - } - if (c != '\n') - *p++ = c; - } - return (-1); -} - -/* Note that SCPYN is only used on strings that may not be nul terminated */ -#define SCPYN(a, b) strncpy(a, b, sizeof (a)) - -#ifdef SUPPORT_UTMP -struct utmp utmp; -#endif -#ifdef SUPPORT_UTMPX -struct utmpx utmpx; -#endif - -void -dologout() -{ -#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX) - int status; - char line[MAXPATHLEN]; - pid_t pid; - - while ((pid = wait(&status)) > 0) { - snprintf(line, sizeof(line), "uucp%.4d", pid); -#ifdef SUPPORT_UTMPX - if (logoutx(line, status, DEAD_PROCESS)) - logwtmpx(line, "", "", status, DEAD_PROCESS); -#endif -#ifdef SUPPORT_UTMP - if (logout(line)) - logwtmp(line, "", ""); -#endif - } -#endif -} - -/* - * Record login in wtmp file. - */ -void -dologin(pw, sa) - struct passwd *pw; - struct sockaddr *sa; -{ -#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX) - char hbuf[NI_MAXHOST]; - struct timeval tv; - char line[MAXPATHLEN]; - pid_t pid = getpid(); - - /* hack, but must be unique and no tty line */ - snprintf(line, sizeof(line), "uucp%.4d", pid = getpid()); - (void)gettimeofday(&tv, NULL); - if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0, 0)) - (void)strlcpy(hbuf, "?", sizeof(hbuf)); -#endif -#ifdef SUPPORT_UTMPX - SCPYN(utmpx.ut_line, line); - SCPYN(utmpx.ut_name, pw->pw_name); - SCPYN(utmpx.ut_host, hbuf); - if (strlen(line) > sizeof(utmpx.ut_id)) { - SCPYN(utmpx.ut_id, line + strlen(line) - sizeof(utmpx.ut_id)); - } else { - SCPYN(utmpx.ut_id, line); - } - utmpx.ut_tv = tv; - utmpx.ut_type = USER_PROCESS; - utmpx.ut_pid = pid; - (void)memcpy(&utmpx.ut_ss, sa, sizeof(*sa)); - loginx(&utmpx); - logwtmpx(line, pw->pw_name, hbuf, 0, USER_PROCESS); -#endif -#ifdef SUPPORT_UTMP - SCPYN(utmp.ut_line, line); - SCPYN(utmp.ut_name, pw->pw_name); - SCPYN(utmp.ut_host, hbuf); - utmp.ut_time = (time_t)tv.tv_sec; - login(&utmp); - logwtmp(line, pw->pw_name, hbuf); -#endif -}