summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-10-18 20:54:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-10-18 20:54:01 +0000
commite0dcfc0bedc994f72870a6c3848c179b696e97b0 (patch)
tree40ad9c9baabc343eb524970f2c33e3e678284bae /usr.bin
parent23e49d650f7fe01d0e3d4e18a4569690170f8f05 (diff)
sup is no longer used. reminded by pirofti and jmc
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sup/Makefile5
-rw-r--r--usr.bin/sup/Makefile.inc5
-rw-r--r--usr.bin/sup/src/Makefile.save144
-rw-r--r--usr.bin/sup/src/Makefile.sunos5.gcc131
-rw-r--r--usr.bin/sup/src/atoo.c58
-rw-r--r--usr.bin/sup/src/c.h81
-rw-r--r--usr.bin/sup/src/crypt.diffs87
-rw-r--r--usr.bin/sup/src/crypt.info15
-rw-r--r--usr.bin/sup/src/errmsg.c75
-rw-r--r--usr.bin/sup/src/expand.c418
-rw-r--r--usr.bin/sup/src/ffilecopy.c93
-rw-r--r--usr.bin/sup/src/filecopy.c72
-rw-r--r--usr.bin/sup/src/libc.h232
-rw-r--r--usr.bin/sup/src/log.c168
-rw-r--r--usr.bin/sup/src/netcryptvoid.c90
-rw-r--r--usr.bin/sup/src/nxtarg.c85
-rw-r--r--usr.bin/sup/src/path.c112
-rw-r--r--usr.bin/sup/src/quit.c61
-rw-r--r--usr.bin/sup/src/run.c305
-rw-r--r--usr.bin/sup/src/scan.c1050
-rw-r--r--usr.bin/sup/src/scm.c660
-rw-r--r--usr.bin/sup/src/scmio.c821
-rw-r--r--usr.bin/sup/src/skipto.c90
-rw-r--r--usr.bin/sup/src/snprintf.c67
-rw-r--r--usr.bin/sup/src/stree.c398
-rw-r--r--usr.bin/sup/src/sup.1859
-rw-r--r--usr.bin/sup/src/sup.h250
-rw-r--r--usr.bin/sup/src/supcdefs.h126
-rw-r--r--usr.bin/sup/src/supcmain.c748
-rw-r--r--usr.bin/sup/src/supcmeat.c1561
-rw-r--r--usr.bin/sup/src/supcmisc.c358
-rw-r--r--usr.bin/sup/src/supcname.c124
-rw-r--r--usr.bin/sup/src/supcparse.c276
-rw-r--r--usr.bin/sup/src/supcvers.c75
-rw-r--r--usr.bin/sup/src/supextern.h183
-rw-r--r--usr.bin/sup/src/supfilesrv.c2123
-rw-r--r--usr.bin/sup/src/supmsg.c786
-rw-r--r--usr.bin/sup/src/supmsg.h186
-rw-r--r--usr.bin/sup/src/supscan.c424
-rw-r--r--usr.bin/sup/src/supservers.8261
-rw-r--r--usr.bin/sup/src/sysent.h134
-rw-r--r--usr.bin/sup/src/time.h66
-rw-r--r--usr.bin/sup/src/unvis.c244
-rw-r--r--usr.bin/sup/src/vis.c179
-rw-r--r--usr.bin/sup/src/vis/vis.h79
-rw-r--r--usr.bin/sup/src/vprintf.c136
-rw-r--r--usr.bin/sup/sup/Makefile16
-rw-r--r--usr.bin/sup/supfilesrv/Makefile19
-rw-r--r--usr.bin/sup/supscan/Makefile15
49 files changed, 0 insertions, 14551 deletions
diff --git a/usr.bin/sup/Makefile b/usr.bin/sup/Makefile
deleted file mode 100644
index 76803ba28e8..00000000000
--- a/usr.bin/sup/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile,v 1.2 1996/06/26 05:39:35 deraadt Exp $
-
-SUBDIR= sup supscan supfilesrv
-
-.include <bsd.subdir.mk>
diff --git a/usr.bin/sup/Makefile.inc b/usr.bin/sup/Makefile.inc
deleted file mode 100644
index bb38c550a89..00000000000
--- a/usr.bin/sup/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile.inc,v 1.5 2001/05/04 22:16:14 millert Exp $
-
-
-CFLAGS+=-UCMUCS -UCMU -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR \
- -DHAS_LOGIN_CAP -DLIBWRAP -DHAS_STRERROR
diff --git a/usr.bin/sup/src/Makefile.save b/usr.bin/sup/src/Makefile.save
deleted file mode 100644
index 494c1ee1fdb..00000000000
--- a/usr.bin/sup/src/Makefile.save
+++ /dev/null
@@ -1,144 +0,0 @@
-# $OpenBSD: Makefile.save,v 1.3 1997/08/31 06:57:25 deraadt Exp $
-
-# Copyright (c) 1992,1991 Carnegie Mellon University
-# All Rights Reserved.
-#
-# Permission to use, copy, modify and distribute this software and its
-# documentation is hereby granted, provided that both the copyright
-# notice and this permission notice appear in all copies of the
-# software, derivative works or modified versions, and any portions
-# thereof, and that both notices appear in supporting documentation.
-#
-# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
-# CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
-# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
-#
-# Carnegie Mellon requests users of this software to return to
-#
-# Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
-# School of Computer Science
-# Carnegie Mellon University
-# Pittsburgh PA 15213-3890
-#
-# any improvements or extensions that they make and grant Carnegie the rights
-# to redistribute these changes.
-######################################################################
-# Makefile to build sup (the client side), supfilesrv (the repository
-# side, and supscan (used by the repository. If you only want to sup
-# files from CMU, just build sup.
-# The header files: c.h, libc.h and sysent.h are only
-# necessary if you are compiling on a non-Mach system. Likewise the
-# files in libextra.a are normally found in libcs.a on a Mach system.
-# DOPRINT_VA is used by vprintf.c and should be defined if your version
-# of libc/doprnt.c defines the routine _doprnt_va. If it defines _doprnt
-# instead, leave DORPINT_VA undefined.
-######################################################################
-#
-# If you need to build a sup for export outside of North America use
-# "make EXPORTABLE_SYSTEM=true"
-# this will remove (not use) any vestiges of crypt code that is present
-# on the system.
-#
-# If you have crypt/crypt.c and /usr/lib/libcrypt.a, you will be building
-# a system that uses the SUP crypt mechanism by default.
-#
-SITE = NETBSD
-#SITE = CMUCS
-NETBSD_DEFINES = -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR
-SOLARIS_DEFINES = -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR -DNEED_VSNPRINTF -DHAS_VFPRINTF
-AFS_DEFINES = -DAFS -I/usr/afsws/include
-OSF_DEFINES = -UMACH -DOSF -D_BSD -noshrlib -g -DNEED_VSNPRINTF -DVAR_TMP
-CMUCS_DEFINES = -DMACH -DDOPRINT_VA -DNEED_VPRINTF
-NON_MACH_DEFINES = -UMACH
-#DEFS = -UCMUCS -UCMU ${${SITE}_DEFINES}
-#DEFS = -UCMUCS -UCMU ${SOLARIS_DEFINES}
-DEFS = -UCMUCS -UCMU ${NETBSD_DEFINES}
-
-#INSTALLATION PARAMETERS
-NETBSD_BINDIR = /usr/local/sbin
-NETBSD_MAN1 = /usr/local/man/man1
-NETBSD_MAN8 = /usr/local/man/man8
-
-CFLAGS = ${DEFS} -O -I.
-
-SUPCL = supcmain.o supcvers.o supcparse.o supcname.o \
- supcmisc.o supcmeat.o
-SUPS = scm.o scmio.o stree.o log.o supmsg.o netcrypt.o
-EXTRA = atoo.o errmsg.o expand.o ffilecopy.o filecopy.o nxtarg.o \
- path.o quit.o run.o salloc.o skipto.o vprintf.o
-
-
-PROGRAMS = sup supscan supfilesrv
-MAN1 = sup.1
-MAN8 = supservers.8
-
-AFS_LIBPATH = /usr/afs/lib
-AFS_LIBS = -L${AFS_LIBPATH}/afs -lkauth -lprot -L${AFS_LIBPATH} -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcmd -lcom_err -lc ${AFS_LIBPATH}/afs/util.a
-
-.if exists(/usr/lib/libcrypt.a) && exists(${.CURDIR}/crypt/crypt.c) && !defined(EXPORTABLE_SYSTEM)
-USE_CRYPT = yes
-.endif
-
-NETBSD_LIBS = -lcrypt -lutil
-SOLARIS_LIBS = -lcrypt -lsocket -lnsl
-CMUCS_LIBS = -lsys
-OSF_LIBS = -lbsd
-LIBS = libextra.a
-sup_OFILES = ${SUPCL} ${SUPS}
-supfilesrv_OFILES = supfilesrv.o scan.o ${SUPS}
-supfilesrv_LIBS = libextra.a
-supscan_OFILES = supscan.o stree.o scan.o
-
-OS_LIBS = ${NETBSD_LIBS}
-#OS_LIBS = ${SOLARIS_LIBS}
-
-
-all: ${PROGRAMS}
-.if defined(USE_CRYPT)
- @echo "WARNING: You have built a NON-exportable version of sup because it uses crypt()!"
- @echo " To build a crypt-clean version define EXPORTABLE_SYSTEM=true and make."
-.endif
-
-sup: ${sup_OFILES} ${LIBS}
- ${CC} ${CFLAGS} -o sup ${sup_OFILES} ${LIBS} ${OS_LIBS}
-
-supfilesrv: ${supfilesrv_OFILES} ${supfilesrv_LIBS}
- ${CC} ${CFLAGS} -o supfilesrv ${supfilesrv_OFILES} ${supfilesrv_LIBS} ${OS_LIBS}
-
-supscan: ${supscan_OFILES} ${LIBS}
- ${CC} ${CFLAGS} -o supscan ${supscan_OFILES} ${LIBS} ${OS_LIBS}
-
-libextra.a: ${EXTRA}
- ar r libextra.a $?
- ranlib libextra.a
-
-clean cleandir:
- rm -f ${PROGRAMS} libextra.a netcrypt.c *.o core a.out
-
-install: ${PROGRAMS}
- install -cs -m 555 -o bin -g bin ${PROGRAMS} ${NETBSD_BINDIR}
- install -c -m 444 -o bin -g bin ${MAN1} ${NETBSD_MAN1}
- install -c -m 444 -o bin -g bin ${MAN8} ${NETBSD_MAN8}
-
-netcrypt.c: crypt.diffs
-.if defined(USE_CRYPT)
- ed - crypt/crypt.c < crypt.diffs
-.else
- @echo "[ Using netcryptvoid.c ]"
- cp netcryptvoid.c netcrypt.c
-.endif
-
-scan.o: sup.h
-scm.o: sup.h
-scmio.o: sup.h supmsg.h
-stree.o: sup.h
-supcmain.o: sup.h supmsg.h supcdefs.h
-supcmeat.o: sup.h supmsg.h supcdefs.h
-supcmisc.o: sup.h supmsg.h supcdefs.h
-supcname.o: sup.h supmsg.h supcdefs.h
-supcparse.o: sup.h supmsg.h supcdefs.h
-supfilesrv.o: sup.h supmsg.h
-supmsg.o: sup.h supmsg.h
-supscan.o: sup.h
-netcryptvoid.o: sup.h supmsg.h
-netcrypt.o: sup.h supmsg.h
diff --git a/usr.bin/sup/src/Makefile.sunos5.gcc b/usr.bin/sup/src/Makefile.sunos5.gcc
deleted file mode 100644
index 9dba17abe27..00000000000
--- a/usr.bin/sup/src/Makefile.sunos5.gcc
+++ /dev/null
@@ -1,131 +0,0 @@
-# $OpenBSD: Makefile.sunos5.gcc,v 1.3 2001/05/05 15:56:04 millert Exp $
-
-# Copyright (c) 1992,1991 Carnegie Mellon University
-# All Rights Reserved.
-#
-# Permission to use, copy, modify and distribute this software and its
-# documentation is hereby granted, provided that both the copyright
-# notice and this permission notice appear in all copies of the
-# software, derivative works or modified versions, and any portions
-# thereof, and that both notices appear in supporting documentation.
-#
-# CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
-# CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
-# ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
-#
-# Carnegie Mellon requests users of this software to return to
-#
-# Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
-# School of Computer Science
-# Carnegie Mellon University
-# Pittsburgh PA 15213-3890
-#
-# any improvements or extensions that they make and grant Carnegie the rights
-# to redistribute these changes.
-######################################################################
-# Makefile to build sup (the client side), supfilesrv (the repository
-# side, and supscan (used by the repository. If you only want to sup
-# files from CMU, just build sup.
-# The header files: c.h, libc.h and sysent.h are only
-# necessary if you are compiling on a non-Mach system. Likewise the
-# files in libextra.a are normally found in libcs.a on a Mach system.
-# DOPRINT_VA is used by vprintf.c and should be defined if your version
-# of libc/doprnt.c defines the routine _doprnt_va. If it defines _doprnt
-# instead, leave DORPINT_VA undefined.
-######################################################################
-#
-# If you need to build a sup for export outside of North America use
-# "make EXPORTABLE_SYSTEM=true"
-# this will remove (not use) any vestiges of crypt code that is present
-# on the system.
-#
-# If you have crypt/crypt.c and /usr/lib/libcrypt.a, you will be building
-# a system that uses the SUP crypt mechanism by default.
-#
-SITE = NETBSD
-#SITE = CMUCS
-NETBSD_DEFINES = -UMACH -DVAR_TMP -DHAS_DAEMON -DHAS_POSIX_DIR
-SOLARIS_DEFINES = -UMACH -DNO_SETLOGIN -DVAR_TMP -DHAS_POSIX_DIR -DNEED_VIS -DUSE_LOCKF -DHAS_STRERROR -D__EXTENSIONS__
-AFS_DEFINES = -DAFS -I/usr/afsws/include
-OSF_DEFINES = -UMACH -DOSF -D_BSD -noshrlib -g -DNEED_VSNPRINTF -DVAR_TMP
-CMUCS_DEFINES = -DMACH -DDOPRINT_VA -DNEED_VPRINTF
-NON_MACH_DEFINES = -UMACH
-#DEFS = -UCMUCS -UCMU ${${SITE}_DEFINES}
-DEFS = -UCMUCS -UCMU ${SOLARIS_DEFINES}
-#DEFS = -UCMUCS -UCMU ${NETBSD_DEFINES}
-
-#INSTALLATION PARAMETERS
-NETBSD_BINDIR = /usr/OpenBSD/sbin
-NETBSD_MAN1 = /usr/OpenBSD/man/man1
-NETBSD_MAN8 = /usr/OpenBSD/man/man8
-
-CFLAGS = ${DEFS} -O -g -I.
-
-SUPCL = supcmain.o supcvers.o supcparse.o supcname.o \
- supcmisc.o supcmeat.o
-SUPS = scm.o scmio.o stree.o log.o supmsg.o netcryptvoid.o
-EXTRA = atoo.o errmsg.o expand.o ffilecopy.o filecopy.o nxtarg.o \
- path.o quit.o run.o skipto.o vprintf.o snprintf.o vis.o unvis.o
-
-
-PROGRAMS = sup supscan supfilesrv
-MAN1 = sup.1
-MAN8 = supservers.8
-
-AFS_LIBPATH = /usr/afs/lib
-AFS_LIBS = -L${AFS_LIBPATH}/afs -lkauth -lprot -L${AFS_LIBPATH} -lubik -lauth -lrxkad -lsys -ldes -lrx -llwp -lcmd -lcom_err -lc ${AFS_LIBPATH}/afs/util.a
-
-
-NETBSD_LIBS = -lcrypt -lutil
-SOLARIS_LIBS = -lcrypt -lsocket -lnsl
-CMUCS_LIBS = -lsys
-OSF_LIBS = -lbsd
-LIBS = libextra.a
-sup_OFILES = ${SUPCL} ${SUPS}
-supfilesrv_OFILES = supfilesrv.o scan.o ${SUPS}
-supfilesrv_LIBS = libextra.a
-supscan_OFILES = supscan.o stree.o scan.o
-
-#OS_LIBS = ${NETBSD_LIBS}
-OS_LIBS = ${SOLARIS_LIBS}
-
-
-all: ${PROGRAMS}
-
-sup: ${sup_OFILES} ${LIBS}
- ${CC} ${CFLAGS} -o sup ${sup_OFILES} ${LIBS} ${OS_LIBS}
-
-supfilesrv: ${supfilesrv_OFILES} ${supfilesrv_LIBS}
- ${CC} ${CFLAGS} -o supfilesrv ${supfilesrv_OFILES} ${supfilesrv_LIBS} ${OS_LIBS}
-
-supscan: ${supscan_OFILES} ${LIBS}
- ${CC} ${CFLAGS} -o supscan ${supscan_OFILES} ${LIBS} ${OS_LIBS}
-
-libextra.a: ${EXTRA}
- ar r libextra.a $?
- ranlib libextra.a
-
-clean cleandir:
- rm -f ${PROGRAMS} libextra.a netcrypt.c *.o core a.out
-
-install: ${PROGRAMS}
- install -cs -m 555 -o bin -g bin ${PROGRAMS} ${NETBSD_BINDIR}
- install -c -m 444 -o bin -g bin ${MAN1} ${NETBSD_MAN1}
- install -c -m 444 -o bin -g bin ${MAN8} ${NETBSD_MAN8}
-
-netcrypt.c: crypt.diffs
-
-scan.o: sup.h
-scm.o: sup.h
-scmio.o: sup.h supmsg.h
-stree.o: sup.h
-supcmain.o: sup.h supmsg.h supcdefs.h
-supcmeat.o: sup.h supmsg.h supcdefs.h
-supcmisc.o: sup.h supmsg.h supcdefs.h
-supcname.o: sup.h supmsg.h supcdefs.h
-supcparse.o: sup.h supmsg.h supcdefs.h
-supfilesrv.o: sup.h supmsg.h
-supmsg.o: sup.h supmsg.h
-supscan.o: sup.h
-netcryptvoid.o: sup.h supmsg.h
-netcrypt.o: sup.h supmsg.h
diff --git a/usr.bin/sup/src/atoo.c b/usr.bin/sup/src/atoo.c
deleted file mode 100644
index 0fa1652484c..00000000000
--- a/usr.bin/sup/src/atoo.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: atoo.c,v 1.4 2001/05/04 22:16:14 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* atoo -- convert ascii to octal
- *
- * Usge: i = atoo (string);
- * unsigned int i;
- * char *string;
- *
- * Atoo converts the value contained in "string" into an
- * unsigned integer, assuming that the value represents
- * an octal number.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX.
- *
- */
-#include "supcdefs.h"
-#include "supextern.h"
-
-unsigned int atoo(ap)
- char *ap;
-{
- unsigned int n;
- char *p;
-
- p = ap;
- n = 0;
- while (*p == ' ' || *p == '\t')
- p++;
- while (*p >= '0' && *p <= '7')
- n = n * 8 + *p++ - '0';
- return(n);
-}
diff --git a/usr.bin/sup/src/c.h b/usr.bin/sup/src/c.h
deleted file mode 100644
index 07ce8eb05b4..00000000000
--- a/usr.bin/sup/src/c.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* $OpenBSD: c.h,v 1.3 2001/04/29 18:14:09 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * Standard C macros
- *
- **********************************************************************
- * HISTORY
- * 02-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check to allow multiple or recursive inclusion of this
- * file. Added bool enum from machine/types.h for regular users
- * that want a real boolean type.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Also change spacing of MAX and MIN to coincide with that of
- * sys/param.h.
- *
- * 19-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed the number of tabs between TRUE, FALSE and their
- * respective values to match those in sys/types.h.
- *
- * 17-Dec-84 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Only define TRUE and FALSE if not defined. Added caseE macro
- * for using enumerated types in switch statements.
- *
- * 23-Apr-81 Mike Accetta (mja) at Carnegie-Mellon University
- * Added "sizeofS" and "sizeofA" macros which expand to the size
- * of a string constant and array respectively.
- *
- **********************************************************************
- */
-
-#ifndef _C_INCLUDE_
-#define _C_INCLUDE_
-
-#define ABS(x) ((x)>=0?(x):-(x))
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#define CERROR (-1)
-
-#ifndef bool
-typedef enum { false = 0, true = 1 } bool;
-#endif
-
-#define sizeofS(string) (sizeof(string) - 1)
-#define sizeofA(array) (sizeof(array)/sizeof(array[0]))
-
-#define caseE(enum_type) case (int)(enum_type)
-
-#endif /* _C_INCLUDE_ */
diff --git a/usr.bin/sup/src/crypt.diffs b/usr.bin/sup/src/crypt.diffs
deleted file mode 100644
index c1201ceccd3..00000000000
--- a/usr.bin/sup/src/crypt.diffs
+++ /dev/null
@@ -1,87 +0,0 @@
-118,$c
-void encode (in,out,count)
-char *in,*out;
-int count;
-{
- decode (in,out,count);
-}
-.
-109,113c
- nr2 = n2;
-.
-103c
- *outp++ = i;
-.
-95,101c
- while(count -- > 0) {
- i = *inp++;
- nr1 = n1;
-.
-93a
- inp = in;
- outp = out;
-.
-86,90c
- return (SCMOK);
-}
-
-void decode (in,out,count)
-char *in,*out;
-register int count;
-{
- register i, n1, n2, nr1, nr2;
- char *inp, *outp;
-.
-81,84c
- if (cryptflag == 0) {
- if (cryptsize > 0) free (cryptbuf);
- cryptsize = 0;
- } else if (x > cryptsize) {
- if (cryptsize > 0) free (cryptbuf);
- cryptbuf = malloc ((unsigned)x+1);
- if (cryptbuf == NULL)
- return (scmerr (-1,"Can't allocate encryption buffer"));
- cryptsize = x;
-.
-78,79c
- static int cryptsize = 0; /* size of current cryptbuf */
-.
-75,76c
-int getcryptbuf (x)
-int x;
-.
-72a
- return (SCMOK);
-.
-54d
-42,48c
- cryptflag = 1;
- for (i=0; i<ROTORSZ; i++) t1[i] = t2[i] = t3[i] = 0;
- (void) strncpy(buf, pw, 8);
- (void) strncpy(buf, crypt(buf, buf), 13);
-.
-27,40c
- if (pw == NULL) {
- cryptflag = 0;
- (void) getcryptbuf (0);
- return (SCMOK);
-.
-23d
-19c
-netcrypt(pw)
-.
-12,17c
-static char t1[ROTORSZ];
-static char t2[ROTORSZ];
-static char t3[ROTORSZ];
-static char buf[13];
-int cryptflag = 0; /* whether to encrypt/decrypt data */
-char *cryptbuf; /* buffer for data encryption/decryption */
-.
-9a
-#include "sup.h"
-
-extern char *malloc();
-
-.
-w netcrypt.c
diff --git a/usr.bin/sup/src/crypt.info b/usr.bin/sup/src/crypt.info
deleted file mode 100644
index badffccf328..00000000000
--- a/usr.bin/sup/src/crypt.info
+++ /dev/null
@@ -1,15 +0,0 @@
-The sup programs can be built with or without crypting functionality.
-If the file netcryptvoid.c is used no crypting code will be used.
-If the file netcrypt.c is used, an engima engine crypting scheme
-taken from the BSD 4.3 (1/25/85) file /usr/bin/crypt.c will be used. Since,
-this code is both licensed and under U.S. foreign trade restrictions,
-we cannot make this code available for anonymous FTP.
-
-If you want to build a sup client which can encrypt data and you
-are a domestic site who has a 4.3 BSD license, we can mail you
-a copy of then netcrypt.c file. Just send mail to mach@cs.cmu.edu
-requesting the file.
-
-If you have a crypt.c file available, copy it to the directory
-./crypt and the makefile file apply the diff in crypt.diffs to
-generate the netcrypt.c file.
diff --git a/usr.bin/sup/src/errmsg.c b/usr.bin/sup/src/errmsg.c
deleted file mode 100644
index 94a73263b8b..00000000000
--- a/usr.bin/sup/src/errmsg.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* $OpenBSD: errmsg.c,v 1.8 2002/02/16 21:27:54 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*****************************************************************
- * HISTORY
- * 04-Mar-85 Rudy Nedved (ern) at Carnegie-Mellon University
- * Create a CMU version of the BBN errmsg routine from scratch. It
- * differs from the BBN errmsg routine in the fact that it uses a
- * negative value to indicate using the current errno value...the
- * BBN uses a negative OR zero value.
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-#ifndef HAS_STRERROR
-static char *itoa(char *, unsigned int);
-
-static char *itoa(p, n)
- char *p;
- unsigned int n;
-{
- if (n >= 10)
- p = itoa(p, n/10);
- *p++ = (n % 10) + '0';
- return(p);
-}
-#endif
-
-const char *errmsg(cod)
- int cod;
-{
-#ifndef HAS_STRERROR
- extern int errno;
- extern int sys_nerr;
- extern char *sys_errlist[];
- static char unkmsg[] = "Unknown error ";
- static char unk[sizeof(unkmsg)+11]; /* trust us */
-
- if (cod < 0) cod = errno;
-
- if((cod >= 0) && (cod < sys_nerr))
- return(sys_errlist[cod]);
-
- strlcpy(unk,unkmsg,sizeof unk);
- *itoa(&unk[sizeof(unkmsg)-1],cod) = '\0';
-
- return(unk);
-#else
- return strerror(cod < 0 ? errno : cod);
-#endif
-}
diff --git a/usr.bin/sup/src/expand.c b/usr.bin/sup/src/expand.c
deleted file mode 100644
index bcbabdfee6a..00000000000
--- a/usr.bin/sup/src/expand.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* $OpenBSD: expand.c,v 1.15 2004/04/05 14:30:51 aaron Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * expand - expand wildcard filename specifications
- *
- * Usage:
- * int expand(spec, buffer, bufsize);
- * char *spec, **buffer;
- * int bufsize;
- *
- * Expand takes a file specification, and expands it into filenames
- * by resolving the characters '*', '?', '[', ']', '{', '}' and '~'
- * in the same manner as the shell. You provide "buffer", which is
- * an array of char *'s, and you tell how big it is in bufsize.
- * Expand will compute the corresponding filenames, and will fill up
- * the entries of buffer with pointers to malloc'd strings.
- *
- * The value returned by expand is the number of filenames found. If
- * this value is -1, then malloc failed to allocate a string. If the
- * value is bufsize + 1, then too many names were found and you can try
- * again with a bigger buffer.
- *
- * This routine was basically created from the csh sh.glob.c file with
- * the following intended differences:
- *
- * Filenames are not sorted.
- * All expanded filenames returned exist.
- *
- **********************************************************************
- * HISTORY
- * 13-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Replaced a stat() with lstat() and changed glob() to only call
- * matchdir() for directories.
- *
- * 20-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created from csh glob() function and 4.1 expand() function.
- *
- **********************************************************************
- */
-#include <sys/param.h>
-#include <sys/stat.h>
-#ifdef HAS_POSIX_DIR
-#include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif
-#include <pwd.h>
-#include <ctype.h>
-#include <libc.h>
-#include <setjmp.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static jmp_buf sjbuf;
-
-static char pathbuf[MAXPATHLEN];
-static char *path, *pathp, *lastpathp;
-
-static char *globchars = "{[*?"; /* meta characters */
-static char *entp; /* current dir entry pointer */
-
-static char **BUFFER; /* pointer to the buffer */
-static int BUFSIZE; /* maximum number in buffer */
-static int bufcnt; /* current number in buffer */
-
-#define fixit(a) (a[0] ? a : ".")
-
-int expand(char *, char **, int);
-static void glob(char *);
-static void matchdir(char *);
-static int execbrc(char *, char *);
-static int match(char *, char *);
-static int amatch(char *, char *);
-static void addone(char *, char *);
-static int addpath(int);
-static int gethdir(char *, size_t);
-
-int
-expand(spec, buffer, bufsize)
- char *spec;
- char **buffer;
- int bufsize;
-{
- pathp = path = pathbuf;
- *pathp = 0;
- lastpathp = &path[MAXPATHLEN - 2];
- BUFFER = buffer;
- BUFSIZE = bufsize;
- bufcnt = 0;
- if (setjmp(sjbuf) == 0)
- glob(spec);
- return(bufcnt);
-}
-
-static void
-glob(as)
- char *as;
-{
- char *cs;
- char *spathp, *oldcs;
- char *home;
- struct stat stb;
-
- if ((home = getenv("HOME")) != NULL && *home == '\0')
- home = NULL;
-
- spathp = pathp;
- cs = as;
- if (*cs == '~' && home && pathp == path) {
- if (addpath('~'))
- goto endit;
- for (cs++; isalnum((unsigned char) *cs) || *cs == '_' || *cs == '-';)
- if (addpath(*cs++))
- goto endit;
- if (!*cs || *cs == '/') {
- if (pathp != path + 1) {
- *pathp = 0;
- if (gethdir(path + 1, sizeof pathbuf - 1))
- goto endit;
- memmove(path, path + 1, strlen(path));
- } else
- strlcpy(path, home, sizeof pathbuf);
- pathp = path + strlen(path);
- }
- }
- while (*cs == 0 || strchr(globchars, *cs) == 0) {
- if (*cs == 0) {
- if (lstat(fixit(path), &stb) >= 0)
- addone(path, "");
- goto endit;
- }
- if (addpath(*cs++))
- goto endit;
- }
- oldcs = cs;
- while (cs > as && *cs != '/')
- cs--, pathp--;
- if (*cs == '/')
- cs++, pathp++;
- *pathp = 0;
- if (*oldcs == '{') {
- execbrc(cs, NULL);
- return;
- }
- /* this should not be an lstat */
- if (stat(fixit(path), &stb) >= 0 && S_ISDIR(stb.st_mode))
- matchdir(cs);
-endit:
- pathp = spathp;
- *pathp = 0;
- return;
-}
-
-static void matchdir(pattern)
- char *pattern;
-{
-#ifdef HAS_POSIX_DIR
- struct dirent *dp;
-#else
- struct direct *dp;
-#endif
- DIR *dirp;
-
- dirp = opendir(fixit(path));
- if (dirp == NULL)
- return;
- while ((dp = readdir(dirp)) != NULL) {
-#if defined(HAS_POSIX_DIR) && !defined(__SVR4)
- if (dp->d_fileno == 0)
- continue;
-#else
- if (dp->d_ino == 0)
- continue;
-#endif
- if (match(dp->d_name, pattern))
- addone(path, dp->d_name);
- }
- closedir(dirp);
- return;
-}
-
-static int execbrc(p, s)
- char *p, *s;
-{
- char restbuf[MAXPATHLEN + 1];
- char *pe, *pm, *pl;
- int brclev = 0;
- char *lm, savec, *spathp;
-
- for (lm = restbuf; *p != '{'; *lm++ = *p++)
- continue;
- for (pe = ++p; *pe; pe++) {
- switch (*pe) {
- case '{':
- brclev++;
- continue;
- case '}':
- if (brclev == 0)
- goto pend;
- brclev--;
- continue;
- case '[':
- for (pe++; *pe && *pe != ']'; pe++)
- continue;
- if (!*pe)
- break;
- continue;
- }
- }
-pend:
- if (brclev || !*pe)
- return (0);
- for (pl = pm = p; pm <= pe; pm++) {
- switch (*pm & 0177) {
- case '{':
- brclev++;
- continue;
- case '}':
- if (brclev) {
- brclev--;
- continue;
- }
- goto doit;
- case ',':
- if (brclev) continue;
-doit:
- savec = *pm;
- *pm = 0;
- snprintf(lm, sizeof(restbuf) - (lm - restbuf),
- "%s%s", pl, pe + 1);
- *pm = savec;
- if (s == 0) {
- spathp = pathp;
- glob(restbuf);
- pathp = spathp;
- *pathp = 0;
- } else if (amatch(s, restbuf))
- return (1);
- pl = pm + 1;
- continue;
-
- case '[':
- for (pm++; *pm && *pm != ']'; pm++)
- continue;
- if (!*pm)
- break;
- continue;
- }
- }
- return (0);
-}
-
-static int
-match(s, p)
- char *s, *p;
-{
- int c;
- char *sentp;
-
- if (*s == '.' && *p != '.')
- return(0);
- sentp = entp;
- entp = s;
- c = amatch(s, p);
- entp = sentp;
- return (c);
-}
-
-static int
-amatch(s, p)
- char *s, *p;
-{
- int scc;
- int ok, lc;
- char *spathp;
- struct stat stb;
- int c, cc;
-
- for (;;) {
- scc = *s++ & 0177;
- switch (c = *p++) {
- case '{':
- return (execbrc(p - 1, s - 1));
- case '[':
- ok = 0;
- lc = 077777;
- while ((cc = *p++) != 0) {
- if (cc == ']') {
- if (ok)
- break;
- return (0);
- }
- if (cc == '-') {
- if (lc <= scc && scc <= *p++)
- ok++;
- } else
- if (scc == (lc = cc))
- ok++;
- }
- if (cc == 0)
- return (0);
- continue;
- case '*':
- if (!*p)
- return (1);
- if (*p == '/') {
- p++;
- goto slash;
- }
- for (s--; *s; s++)
- if (amatch(s, p))
- return (1);
- return (0);
- case 0:
- return (scc == 0);
- default:
- if (c != scc)
- return (0);
- continue;
- case '?':
- if (scc == 0)
- return (0);
- continue;
- case '/':
- if (scc)
- return (0);
-slash:
- s = entp;
- spathp = pathp;
- while (*s) {
- if (addpath(*s++))
- goto pathovfl;
- }
- if (addpath('/'))
- goto pathovfl;
- if (stat(fixit(path), &stb) >= 0 &&
- S_ISDIR(stb.st_mode)) {
- if (*p == 0)
- addone(path, "");
- else
- glob(p);
- }
-pathovfl:
- pathp = spathp;
- *pathp = 0;
- return (0);
- }
- }
-}
-
-static void
-addone(s1, s2)
- char *s1, *s2;
-{
- char *ep;
-
- if (bufcnt >= BUFSIZE) {
- bufcnt = BUFSIZE + 1;
- longjmp(sjbuf, 1);
- }
- ep = (char *)malloc(strlen(s1) + strlen(s2) + 1);
- if (ep == 0) {
- bufcnt = -1;
- longjmp(sjbuf, 1);
- }
- BUFFER[bufcnt++] = ep;
- while (*s1)
- *ep++ = *s1++;
- while ((*ep++ = *s2++) != '\0')
- continue;
-}
-
-static int
-addpath(c)
- char c;
-{
- if (pathp >= lastpathp)
- return(1);
- *pathp++ = c;
- *pathp = 0;
- return(0);
-}
-
-static int gethdir(home, homelen)
- char *home;
- size_t homelen;
-{
- struct passwd *pp = getpwnam(home);
-
- if (pp == 0)
- return(1);
- strlcpy(home, pp->pw_dir, homelen);
- return(0);
-}
diff --git a/usr.bin/sup/src/ffilecopy.c b/usr.bin/sup/src/ffilecopy.c
deleted file mode 100644
index 444b142a970..00000000000
--- a/usr.bin/sup/src/ffilecopy.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* $OpenBSD: ffilecopy.c,v 1.6 2001/05/04 22:16:15 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* ffilecopy -- very fast buffered file copy
- *
- * Usage: i = ffilecopy (here,there)
- * int i;
- * FILE *here, *there;
- *
- * Ffilecopy is a very fast routine to copy the rest of a buffered
- * input file to a buffered output file. Here and there are open
- * buffers for reading and writing (respectively); ffilecopy
- * performs a file-copy faster than you should expect to do it
- * yourself. Ffilecopy returns 0 if everything was OK; EOF if
- * there was any error. Normally, the input file will be left in
- * EOF state (feof(here) will return TRUE), and the output file will be
- * flushed (i.e. all data on the file rather in the core buffer).
- * It is not necessary to flush the output file before ffilecopy.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for VAX.
- *
- */
-
-#include <stdio.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-int
-ffilecopy(here,there)
- FILE *here, *there;
-{
- int i, herefile, therefile;
-
- herefile = fileno(here);
- therefile = fileno(there);
-
- if (fflush(there) == EOF) /* flush pending output */
- return (EOF);
-
-#ifdef _FSTDIO
- if ((here->_r) > 0) { /* flush buffered input */
- i = write(therefile, here->_p, here->_r);
- if (i != here->_r)
- return (EOF);
- here->_p = here->_bf._base;
- here->_r = 0;
- }
-#else
- if ((here->_cnt) > 0) { /* flush buffered input */
- i = write(therefile, here->_ptr, here->_cnt);
- if (i != here->_cnt)
- return (EOF);
- here->_ptr = here->_base;
- here->_cnt = 0;
- }
-#endif /* _FSTDIO */
-
- i = filecopy(herefile, therefile); /* fast file copy */
- if (i < 0)
- return (EOF);
-
-#ifdef _FSTDIO
- (here->_flags) |= __SEOF; /* indicate EOF */
-#else
- (here->_flag) |= _IOEOF; /* indicate EOF */
-#endif
- return (0);
-}
diff --git a/usr.bin/sup/src/filecopy.c b/usr.bin/sup/src/filecopy.c
deleted file mode 100644
index 5dbd2ff4913..00000000000
--- a/usr.bin/sup/src/filecopy.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* $OpenBSD: filecopy.c,v 1.4 2001/05/04 22:16:15 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* filecopy -- copy a file from here to there
- *
- * Usage: i = filecopy (here,there);
- * int i, here, there;
- *
- * Filecopy performs a fast copy of the file "here" to the
- * file "there". Here and there are both file descriptors of
- * open files; here is open for input, and there for output.
- * Filecopy returns 0 if all is OK; -1 on error.
- *
- * I have performed some tests for possible improvements to filecopy.
- * Using a buffer size of 10240 provides about a 1.5 times speedup
- * over 512 for a file of about 200,000 bytes. Of course, other
- * buffer sized should also work; this is a rather arbitrary choice.
- * I have also tried inserting special startup code to attempt
- * to align either the input or the output file to lie on a
- * physical (512-byte) block boundary prior to the big loop,
- * but this presents only a small (about 5% speedup, so I've
- * canned that code. The simple thing seems to be good enough.
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX; same as "filcopy" on PDP-11. Bigger buffer
- * size (20 physical blocks) seems to be a big win; aligning things
- * on block boundaries seems to be a negligible improvement at
- * considerable cost in complexity.
- *
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-#define BUFFERSIZE 10240
-
-int
-filecopy (here, there)
- int here, there;
-{
- int kount;
- char buffer[BUFFERSIZE];
-
- kount = 0;
- while (kount == 0 && (kount = read(here, buffer, BUFFERSIZE)) > 0)
- kount -= write(there, buffer, kount);
- return (kount ? -1 : 0);
-}
diff --git a/usr.bin/sup/src/libc.h b/usr.bin/sup/src/libc.h
deleted file mode 100644
index 79d92cdb718..00000000000
--- a/usr.bin/sup/src/libc.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/* $OpenBSD: libc.h,v 1.8 2002/02/19 19:39:39 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
-
- * Revision 1.7 89/04/03 11:10:45 vanryzin
- * Changed definition of qsort for c++ to indicate the procedure
- * passed to qsort has parameters. Since we were unsure if ANSI C
- * could handle the syntax I placed the new definition within #if
- * defined(c_plusplus) conditionals. This may not be necessary
- * and perhaps should be fixed at a later time.
- * [89/04/03 vanryzin]
- *
- * Revision 1.6 89/02/05 15:55:57 gm0w
- * Added extern char *errmsg().
- * [89/02/04 gm0w]
- *
- * Revision 1.5 89/01/20 15:34:40 gm0w
- * Moved all of the STDC changes to other existing include files
- * back into this one. Added non-STDC extern declarations for
- * all functions without int return values to match those defined
- * by STDC. Added include of sysent.h. Removed obsolete cdate
- * extern declaration.
- * [88/12/17 gm0w]
- *
- * Revision 1.4 88/12/22 16:58:56 mja
- * Correct __STDC__ parameter type for getenv().
- * [88/12/20 dld]
- *
- * Revision 1.3 88/12/14 23:31:42 mja
- * Made file reentrant. Added declarations for __STDC__.
- * [88/01/06 jjk]
- *
- * 30-Apr-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added pathof() extern.
- *
- * 01-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added getname() extern.
- *
- * 29-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added lseek() extern.
- *
- * 02-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added salloc() extern.
- *
- * 14-Aug-81 Mike Accetta (mja) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#ifndef _LIBC_H_
-#define _LIBC_H_ 1
-
-#ifndef _TYPES_
-#include <sys/types.h>
-#endif /* _TYPES_ */
-
-#ifndef _SYSENT_H_
-#include <sysent.h>
-#endif /* _SYSENT_H_ */
-
-#ifndef FILE
-#include <stdio.h>
-#endif /* FILE */
-
-#ifndef _STRING_H_
-#include <string.h>
-#endif /* _STRING_H_ */
-
-#ifndef _TIME_H_
-#include <time.h>
-#endif /* _TIME_H_ */
-
-/* CMU stdio additions */
-extern FILE *fopenp(const char*, const char*, char*, char*);
-extern FILE *fwantread(const char*, const char*, const char*, const char*);
-extern FILE *fwantwrite(const char*, const char*, const char*, const char*,
- int);
-
-/* CMU string routines */
-extern char* foldup(char*, const char*);
-extern char* folddown(char*, const char*);
-extern char* sindex(const char*, const char*);
-extern char _argbreak;
-extern char* getstr(const char*, char*, char*);
-extern int getstab(const char*, const char**, const char*);
-extern int getsearch(const char*, const char**, const char*);
-extern char* strarg(const char**, const char*, const char*, char*, char*);
-extern int stabarg(const char**, const char*, const char*, const char**,
- const char*);
-extern int searcharg(const char**, const char*, const char*, const char**,
- const char*);
-extern int getint(const char*, int, int, int);
-extern int intarg(const char**, const char*, const char*, int, int, int);
-extern long getlong(const char*, long, long, long);
-extern long longarg(const char**, const char*, const char*, long, long, long);
-extern short getshort(const char*, short, short, short);
-extern short shortarg(const char**, const char*, const char*,
- short, short, short);
-extern float getfloat(const char*, float, float, float);
-extern float floatarg(const char**, const char*, const char*,
- float, float, float);
-extern double getdouble(const char*, double, double, double);
-extern double doublearg(const char**, const char*, const char*,
- double, double, double);
-extern unsigned int getoct(const char*, unsigned int, unsigned int,
- unsigned int);
-extern unsigned int octarg(const char**, const char*, const char*,
- unsigned int, unsigned int, unsigned int);
-extern unsigned int gethex(const char*, unsigned int, unsigned int,
- unsigned int);
-extern unsigned int hexarg(const char**, const char*, const char*,
- unsigned int, unsigned int, unsigned int);
-extern unsigned int atoh(const char*);
-extern char *concat(const char*, int, ...);
-
-/* CMU library routines */
-extern char *getname(int);
-extern char *pathof(char *);
-extern const char *errmsg(int);
-
-/* CMU time additions */
-extern long gtime(const struct tm*);
-extern long atot(const char*);
-
-/* 4.3 BSD standard library routines; taken from man(3) */
-#if 0
-typedef int (*PFI)();
-#endif
-#if defined(c_plusplus)
-typedef int (*PFI2)(...);
-#endif /* c_plusplus */
-#if 0
-extern void abort(void);
-extern int abs(int);
-extern double atof(const char *);
-extern int atoi(const char *);
-extern long atol(const char *);
-extern void memcpy(void *, const void *, size_t);
-extern void memmove(void *, const void *, size_t);
-extern int memcmp(const void *, const void *, size_t);
-extern void memset(void *, int, size_t);
-extern int ffs(int);
-extern char *crypt(const char *, const char *);
-extern void setkey(char *);
-extern void encrypt(char *, int);
-extern char *ecvt(double, int, int *, int *);
-extern char *fcvt(double, int, int *, int *);
-extern char *gcvt(double, int, char *);
-extern int execl(const char *, ...);
-extern int execv(const char *, const char **);
-extern int execle(const char *, ...);
-extern int exect(const char *, const char **, const char **);
-extern void exit(int);
-extern char *getenv(const char *);
-extern char *getlogin(void);
-extern int getopt(int, const char **, const char *);
-extern char *getpass(const char *);
-extern char *getusershell(void);
-extern void setusershell(void);
-extern void endusershell(void);
-extern char *getwd(char *);
-extern int initgroups(const char *, gid_t);
-extern void *malloc(unsigned);
-extern void free(void *);
-extern void *realloc(void *, unsigned);
-extern void *calloc(unsigned, unsigned);
-extern void *alloca(int);
-extern char *mktemp(char *);
-extern int mkstemp(char *);
-extern void monitor(PFI, PFI, short *, int, int);
-extern void monstartup(PFI, PFI);
-extern void moncontrol(int);
-extern int pause(void);
-#if defined(c_plusplus)
-extern void qsort(void *, int, int, PFI2);
-#else /* c_plusplus */
-extern void qsort(void *, int, int, PFI);
-#endif /* c_plusplus */
-extern long random(void);
-extern int srandom(int);
-extern void *initstate(unsigned, void *, int);
-extern void *setstate(void *);
-extern int rcmd(char **, int, const char *, const char *, const char *, int);
-extern int rresvport(int *);
-extern int ruserok(char *, int, const char *, const char *);
-extern char *re_comp(char *);
-extern int re_exec(char *);
-extern int rexec(char **, int, const char *, const char *, const char *,
- int *);
-extern int setuid(uid_t);
-extern int seteuid(uid_t);
-extern int setruid(uid_t);
-extern int setgid(gid_t);
-extern int setegid(gid_t);
-extern int setrgid(gid_t);
-extern void sleep(unsigned);
-extern void swab(void *, void *, int);
-extern int system(const char *);
-extern char *ttyname(int);
-extern int isatty(int);
-extern int ttyslot(void);
-extern unsigned ualarm(unsigned, unsigned);
-extern void usleep(unsigned);
-#endif
-#endif /* not _LIBC_H_ */
diff --git a/usr.bin/sup/src/log.c b/usr.bin/sup/src/log.c
deleted file mode 100644
index cfd184b28d5..00000000000
--- a/usr.bin/sup/src/log.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* $OpenBSD: log.c,v 1.8 2002/02/19 19:39:39 millert Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * Logging support for SUP
- **********************************************************************
- * HISTORY
- * Revision 1.5 92/08/11 12:03:43 mrt
- * Brad's delinting and variable argument list usage
- * changes. Added copyright.
- *
- * Revision 1.3 89/08/15 15:30:37 bww
- * Updated to use v*printf() in place of _doprnt().
- * From "[89/04/19 mja]" at CMU.
- * [89/08/15 bww]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check to allow logopen() to be called multiple times.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include <syslog.h>
-#include <c.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-static int opened = 0;
-
-void
-logopen(program)
- char *program;
-{
- if (opened)
- return;
- openlog(program, LOG_PID, LOG_DAEMON);
- opened++;
-}
-
-void
-logquit(int retval, char *fmt, ...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap,fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog(LOG_ERR, "%s", buf);
- closelog();
- exit(retval);
- }
- quit(retval, "SUP: %s\n", buf);
-}
-
-void
-logerr(char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap,fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog(LOG_ERR, "%s", buf);
- return;
- }
- fprintf(stderr, "SUP: %s\n", buf);
- (void) fflush(stderr);
-}
-
-void
-loginfo(char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap,fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog(LOG_INFO, "%s", buf);
- return;
- }
- printf ("%s\n", buf);
- (void) fflush(stdout);
-}
-
-#ifdef LIBWRAP
-#include <tcpd.h>
-#ifndef LIBWRAP_ALLOW_FACILITY
-# define LIBWRAP_ALLOW_FACILITY LOG_AUTH
-#endif
-#ifndef LIBWRAP_ALLOW_SEVERITY
-# define LIBWRAP_ALLOW_SEVERITY LOG_INFO
-#endif
-#ifndef LIBWRAP_DENY_FACILITY
-# define LIBWRAP_DENY_FACILITY LOG_AUTH
-#endif
-#ifndef LIBWRAP_DENY_SEVERITY
-# define LIBWRAP_DENY_SEVERITY LOG_WARNING
-#endif
-int allow_severity = LIBWRAP_ALLOW_FACILITY|LIBWRAP_ALLOW_SEVERITY;
-int deny_severity = LIBWRAP_DENY_FACILITY|LIBWRAP_DENY_SEVERITY;
-
-void
-logdeny(char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap,fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog(deny_severity, "%s", buf);
- return;
- }
- printf("%s\n", buf);
- (void) fflush(stdout);
-}
-
-void
-logallow(char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap,fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (opened) {
- syslog(allow_severity, "%s", buf);
- return;
- }
- printf("%s\n",buf);
- (void) fflush(stdout);
-}
-#endif /* LIBWRAP */
diff --git a/usr.bin/sup/src/netcryptvoid.c b/usr.bin/sup/src/netcryptvoid.c
deleted file mode 100644
index ad349619778..00000000000
--- a/usr.bin/sup/src/netcryptvoid.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $OpenBSD: netcryptvoid.c,v 1.6 2001/05/04 22:16:15 millert Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/**********************************************************************
- * HISTORY
- * Revision 2.2 92/09/09 22:04:34 mrt
- * Created.
- * [92/09/09 mrt]
- *
- */
-/*
- * DATA ENCRYPTION
- * netcrypt (key) turn on/off encryption of strings and files
- * char *key; encryption key
- *
- */
-
-/*
- * Replacement for subroutine version of "crypt" program
- * for foreign and non-BSD-licensed sites. With this code
- * you can only run unencrypted sups
- */
-
-#include <libc.h>
-#include "supcdefs.h"
-#include "supextern.h"
-#include "supmsg.h"
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-int cryptflag; /* whether to encrypt/decrypt data */
-char *cryptbuf; /* buffer for data encryption/decryption */
-
-int netcrypt (pword)
- char *pword;
-{
- if (pword == NULL || (strcmp(pword,PSWDCRYPT) == 0)) {
- cryptflag = 0;
- (void) getcryptbuf(0);
- return (SCMOK);
- }
- return (SCMERR);
-}
-
-int getcryptbuf(x)
- int x;
-{
- if (cryptflag == 0)
- return(SCMOK);
- else
- return (SCMERR);
-}
-
-void decode (in,out,count)
- char *in,*out;
- int count;
-{
-}
-
-
-void encode (in,out,count)
- char *in,*out;
- int count;
-{
-}
diff --git a/usr.bin/sup/src/nxtarg.c b/usr.bin/sup/src/nxtarg.c
deleted file mode 100644
index 657392f2f75..00000000000
--- a/usr.bin/sup/src/nxtarg.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $OpenBSD: nxtarg.c,v 1.6 2003/03/10 03:53:32 david Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * nxtarg -- strip off arguments from a string
- *
- * Usage: p = nxtarg (&q,brk);
- * char *p,*q,*brk;
- * extern char _argbreak;
- *
- * q is pointer to next argument in string
- * after call, p points to string containing argument,
- * q points to remainder of string
- *
- * Leading blanks and tabs are skipped; the argument ends at the
- * first occurrence of one of the characters in the string "brk".
- * When such a character is found, it is put into the external
- * variable "_argbreak", and replaced by a null character; if the
- * arg string ends before that, then the null character is
- * placed into _argbreak;
- * If "brk" is 0, then " " is substituted.
- *
- * HISTORY
- * 01-Jul-83 Steven Shafer (sas) at Carnegie-Mellon University
- * Bug fix: added check for "back >= front" in loop to chop trailing
- * white space.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Rewritten for VAX. By popular demand, a table of break characters
- * has been added (implemented as a string passed into nxtarg).
- *
- * Originally from klg (Ken Greer); IUS/SUS UNIX.
- */
-#include "supcdefs.h"
-#include "supextern.h"
-
-char _argbreak;
-
-char *nxtarg (q,brk)
- char **q,*brk;
-{
- char *front, *back;
-
- front = *q; /* start of string */
- /* leading blanks and tabs */
- while (*front && (*front == ' ' || *front == '\t'))
- front++;
- /* find break character at end */
- if (brk == 0)
- brk = " ";
- back = skipto (front, brk);
- _argbreak = *back;
- *q = (*back ? back+1 : back); /* next arg start loc */
- /* elim trailing blanks and tabs */
- back -= 1;
- while ((back >= front) && (*back == ' ' || *back == '\t'))
- back--;
- back++;
- if (*back)
- *back = '\0';
- return (front);
-}
diff --git a/usr.bin/sup/src/path.c b/usr.bin/sup/src/path.c
deleted file mode 100644
index c0904a6892d..00000000000
--- a/usr.bin/sup/src/path.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* $OpenBSD: path.c,v 1.6 2003/04/15 07:21:09 deraadt Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* path -- break filename into directory and file
- *
- * path (filename,direc,file,filen);
- * char *filename,*direc,*file;
- * int filen;
- * filename is input; direc and file are output (user-supplied).
- * file will not have any trailing /; direc might.
- * filen is the length of the file buffer.
- * Note these rules:
- * 1. trailing / are ignored (except as first character)
- * 2. x/y is x;y where y contains no / (x may contain /)
- * 3. /y is /;y where y contains no /
- * 4. y is .;y where y contains no /
- * 5. is .;. (null filename)
- * 6. / is /;. (the root directory)
- *
- * Algorithm is this:
- * 1. delete trailing / except in first position
- * 2. if any /, find last one; change to null; y++
- * else y = x; (x is direc; y is file)
- * 3. if y is null, y = .
- * 4. if x equals y, x = .
- * else if x is null, x = /
- *
- * HISTORY
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Copied verbatim from PDP-11. Still as messy as ever.
- * Some people have asked for a modification (I think that's a better
- * idea than a new routine) which will change the directory name
- * into an absolute pathname if it isn't one already. The change
- * involves doing a getwd() and prepending that if appropriate, with
- * a "/" in between that and the directory part of the path.
- * If you want to be cute, you can also resolve ".."s at that time.
- *
- * XXX - this is horrible code (millert)
- */
-#include "supcdefs.h"
-#include "supextern.h"
-
-void
-path(original, direc, direclen, file, filen)
- char *original, *direc;
- int direclen;
- char *file;
- int filen;
-{
- char *y;
- /* x is direc */
- char *p;
-
- /* copy and note the end */
- p = original;
- y = direc;
- while ((*y++ = *p++) != '\0')
- ; /* copy string */
- /* y now points to first char after null */
- --y; /* y now points to null */
- --y; /* y now points to last char of string before null */
-
- /* chop off trailing / except as first character */
- while (y>direc && *y == '/')
- --y; /* backpedal past / */
- /* y now points to char before first trailing / or null */
- *(++y) = 0; /* chop off end of string */
- /* y now points to null */
-
- /* find last /, if any. If found, change to null and bump y */
- while (y>direc && *y != '/')
- --y;
- /* y now points to / or direc. Note *direc may be / */
- if (*y == '/')
- *y++ = 0;
-
- /* find file name part */
- if (*y)
- strlcpy(file, y, filen);
- else
- strlcpy(file, ".", filen);
-
- /* find directory part */
- if (direc == y)
- strlcpy(direc, ".", direclen);
- else if (*direc == 0)
- strlcpy(direc, "/", direclen);
- /* else direc already has proper value */
-}
diff --git a/usr.bin/sup/src/quit.c b/usr.bin/sup/src/quit.c
deleted file mode 100644
index b1db270374f..00000000000
--- a/usr.bin/sup/src/quit.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* $OpenBSD: quit.c,v 1.5 2002/02/19 19:39:39 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * quit -- print message and exit
- *
- * Usage: quit (status,format [,arg]...);
- * int status;
- * (... format and arg[s] make up a printf-arglist)
- *
- * Quit is a way to easily print an arbitrary message and exit.
- * It is most useful for error exits from a program:
- * if (open (...) < 0) then quit (1,"Can't open...",file);
- *
- **********************************************************************
- * HISTORY
- * Revision 1.2 88/12/13 13:52:41 gm0w
- * Rewritten to use varargs.
- * [88/12/13 gm0w]
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-void
-quit (int status, char * fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- fflush(stdout);
- (void) vfprintf(stderr, fmt, args);
- va_end(args);
- exit(status);
-}
diff --git a/usr.bin/sup/src/run.c b/usr.bin/sup/src/run.c
deleted file mode 100644
index c96a592dfa8..00000000000
--- a/usr.bin/sup/src/run.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/* $OpenBSD: run.c,v 1.14 2005/07/04 01:54:10 djm Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/* run, runv, runp, runvp -- execute process and wait for it to exit
- *
- * Usage:
- * i = run (file, arg1, arg2, ..., argn, 0);
- * i = runv (file, arglist);
- * i = runp (file, arg1, arg2, ..., argn, 0);
- * i = runvp (file, arglist);
- * i = runio (argv, in, out, err);
- *
- * Run, runv, runp and runvp have argument lists exactly like the
- * corresponding routines, execl, execv, execlp, execvp. The run
- * routines perform a fork, then:
- * IN THE NEW PROCESS, an execl[p] or execv[p] is performed with the
- * specified arguments. The process returns with a -1 code if the
- * exec was not successful.
- * IN THE PARENT PROCESS, the signals SIGQUIT and SIGINT are disabled,
- * the process waits until the newly forked process exits, the
- * signals are restored to their original status, and the return
- * status of the process is analyzed.
- * All run routines return: -1 if the exec failed or if the child was
- * terminated abnormally; otherwise, the exit code of the child is
- * returned.
- *
- **********************************************************************
- * HISTORY
- * Revision 1.1 89/10/14 19:53:39 rvb
- * Initial revision
- *
- * Revision 1.2 89/08/03 14:36:46 mja
- * Update run() and runp() to use <varargs.h>.
- * [89/04/19 mja]
- *
- * 23-Sep-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged old runv and runvp modules.
- *
- * 22-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check and kill if child process was stopped.
- *
- * 30-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Adapted for 4.2 BSD UNIX: Conforms to new signals and wait.
- *
- * 15-July-82 Mike Accetta (mja) and Neal Friedman (naf)
- * at Carnegie-Mellon University
- * Added a return(-1) if vfork fails. This should only happen
- * if there are no more processes available.
- *
- * 28-Jan-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Added setuid and setgid for system programs' use.
- *
- * 21-Jan-80 Steven Shafer (sas) at Carnegie-Mellon University
- * Changed fork to vfork.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for VAX. The proper way to fork-and-execute a system
- * program is now by "runvp" or "runp", with the program name
- * (rather than an absolute pathname) as the first argument;
- * that way, the "PATH" variable in the environment does the right
- * thing. Too bad execvp and execlp (hence runvp and runp) don't
- * accept a pathlist as an explicit argument.
- *
- **********************************************************************
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-static int dorun(char *, char **, int);
-static char **makearglist(va_list);
-
-static char **
-makearglist(ap)
- va_list ap;
-{
- static size_t ns = 0;
- static char **np = NULL;
- int i = 0;
-
- do {
- if (i >= ns) {
- ns += 20;
- if ((np = realloc(np, ns)) == NULL)
- return NULL;
- }
- np[i] = va_arg(ap, char *);
- }
- while (np[i++] != NULL)
- ;
- return np;
-}
-
-int
-run(char *name, ...)
-{
- int val;
- va_list ap;
- char **argv;
- va_start(ap, name);
-
- if ((argv = makearglist(ap)) == NULL)
- return -1;
- val = runv (name, argv);
- va_end(ap);
- return(val);
-}
-
-int runv (name,argv)
-char *name,**argv;
-{
- return (dorun(name, argv, 0));
-}
-
-int
-runp(char *name, ...)
-{
- int val;
- va_list ap;
- char **argv;
-
- va_start(ap, name);
- if ((argv = makearglist(ap)) == NULL)
- return -1;
- val = runvp (name, argv);
- va_end(ap);
- return (val);
-}
-
-int runvp (name, argv)
- char *name, **argv;
-{
- return (dorun(name, argv, 1));
-}
-
-static int
-dorun(name, argv, usepath)
- char *name,**argv;
- int usepath;
-{
- pid_t wpid;
- pid_t pid;
- struct sigaction ignoresig, intsig, quitsig;
- int status;
- uid_t uid;
- gid_t gid;
-
- if ((pid = fork()) == -1)
- return(-1); /* no more process's, so exit with error */
-
- if (pid == 0) { /* child process */
- uid = getuid();
- gid = getgid();
- if (setgroups(1, &gid) == -1 ||
- setresgid(gid, gid, gid) == -1 ||
- setresuid(uid, uid, uid) == -1)
- _exit(0377);
- if (usepath)
- execvp(name,argv);
- else
- execv(name,argv);
- fprintf (stderr,"run: can't exec %s: %s\n",name,
- strerror(errno));
- _exit(0377);
- }
-
- memset(&ignoresig, 0, sizeof ignoresig);
- ignoresig.sa_handler = SIG_IGN; /* ignore INT and QUIT signals */
- sigemptyset(&ignoresig.sa_mask);
- ignoresig.sa_flags = 0;
- sigaction(SIGINT, &ignoresig, &intsig);
- sigaction(SIGQUIT, &ignoresig, &quitsig);
- do {
- wpid = waitpid(-1, &status, WUNTRACED);
- if (WIFSTOPPED(status)) {
- kill(0, SIGTSTP);
- wpid = 0;
- }
- } while (wpid != pid && wpid != -1);
- sigaction (SIGINT, &intsig, 0); /* restore signals */
- sigaction (SIGQUIT, &quitsig, 0);
-
- if (WIFSIGNALED(status) || WEXITSTATUS(status) == 0377)
- return (-1);
-
- return (WEXITSTATUS(status));
-}
-
-/*
- * Like system(3), but with an argument list and explicit redirections
- * that does not use the shell
- */
-int
-runio(argv, infile, outfile, errfile)
- char *const argv[];
- const char *infile;
- const char *outfile;
- const char *errfile;
-{
- int fd;
- pid_t pid;
- int status;
-
- switch ((pid = fork())) {
- case -1:
- return -1;
-
- case 0:
- if (infile) {
- (void) close(0);
- if ((fd = open(infile, O_RDONLY)) == -1)
- exit(1);
- if (fd != 0)
- (void) dup2(fd, 0);
- }
-
- if (outfile) {
- (void) close(1);
- if ((fd = open(outfile, O_RDWR|O_CREAT|O_TRUNC,
- 0666)) == -1)
- exit(1);
- if (fd != 1)
- (void) dup2(fd, 1);
- }
-
- if (errfile) {
- (void) close(2);
- if ((fd = open(errfile, O_RDWR|O_CREAT|O_TRUNC,
- 0666)) == -1)
- exit(1);
- if (fd != 2)
- (void) dup2(fd, 2);
- }
- execvp(argv[0], argv);
- exit(1);
- /*NOTREACHED*/
- return 0;
-
- default:
- if (waitpid(pid, &status, 0) == -1)
- return -1;
- return status;
- }
-}
-
-/*
- * Like runio, but works with filedescriptors instead of filenames
- */
-int
-runiofd(argv, infile, outfile, errfile)
- char *const argv[];
- const int infile;
- const int outfile;
- const int errfile;
-{
- pid_t pid;
- int status;
-
- switch ((pid = fork())) {
- case -1:
- return -1;
-
- case 0:
- if (infile != 0) dup2(infile, 0);
- if (outfile != 1) dup2(outfile,1);
- if (errfile != 2) dup2(errfile,2);
- execvp(argv[0], argv);
- exit(1);
- /*NOTREACHED*/
- return 0;
-
- default:
- if (waitpid(pid, &status, 0) == -1)
- return -1;
- return status;
- }
-}
diff --git a/usr.bin/sup/src/scan.c b/usr.bin/sup/src/scan.c
deleted file mode 100644
index 5b4d5996ed3..00000000000
--- a/usr.bin/sup/src/scan.c
+++ /dev/null
@@ -1,1050 +0,0 @@
-/* $OpenBSD: scan.c,v 1.16 2007/09/11 15:47:17 gilles Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * scan.c - sup list file scanner
- *
- **********************************************************************
- * HISTORY
- * Revision 1.8 92/08/11 12:04:28 mrt
- * Brad's changes: delinted, added forward declarations of static
- * functions.Added Copyright.
- * [92/07/24 mrt]
- *
- * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added host=<hostfile> support to releases file.
- *
- * 11-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added "rsymlink" recursive symbolic link quoting directive.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support.
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Lets see if we'll be able to write the scan file BEFORE
- * we collect the data for it. Include sys/file.h and use
- * new definitions for access check codes.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added type casting information for lint.
- *
- * 21-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check for newonly upgrade when lasttime is the same as
- * scantime. This will save us the trouble of parsing the scanfile
- * when the client has successfully received everything in the
- * scanfile already.
- *
- * 16-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Clear Texec pointers in execT so that Tfree of execT will not
- * free command trees associated with files in listT.
- *
- * 06-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to omit scanned files from list if we want new files
- * only and they are old.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. Added version numbers to
- * scan file. Also added mode of file in addition to flags.
- * Execute commands are now immediately after file information.
- *
- * 13-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added comments to list file format.
- *
- * 08-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to implement omitany. Currently doesn't know about
- * {a,b,c} patterns.
- *
- * 07-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <c.h>
-#include <stdlib.h>
-#include <vis.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#ifdef HAS_POSIX_DIR
-#include <dirent.h>
-#else
-#include <sys/dir.h>
-#endif
-#include <sys/file.h>
-#include <unistd.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-#define SPECNUMBER 1000
- /* number of filenames produced by a single spec in the list file */
-
-/*******************************************
- *** D A T A S T R U C T U R E S ***
- *******************************************/
-
-typedef enum { /* release options */
- ONEXT, OPREFIX, OLIST, OSCAN,
- OHOST
-} OPTION;
-
-static char *options[] = {
- "next", "prefix", "list", "scan",
- "host",
- 0
-};
-
-typedef enum { /* <collection>/list file lines */
- LUPGRADE, LOMIT, LBACKUP, LEXECUTE,
- LINCLUDE, LNOACCT, LOMITANY, LALWAYS,
- LSYMLINK, LRSYMLINK
-} LISTTYPE;
-
-static char *ltname[] = {
- "upgrade", "omit", "backup", "execute",
- "include", "noaccount", "omitany", "always",
- "symlink", "rsymlink",
- 0
-};
-
-#define FALWAYS FUPDATE
-
-/* list file lines */
-static TREE *upgT; /* files to upgrade */
-static TREE *flagsT; /* special flags: BACKUP NOACCT */
-static TREE *omitT; /* recursize file omition list */
-static TREE *omanyT; /* non-recursize file omition list */
-static TREE *symT; /* symbolic links to quote */
-static TREE *rsymT; /* recursive symbolic links to quote */
-static TREE *execT; /* execute command list */
-
-/*************************
- *** E X T E R N ***
- *************************/
-
-#ifdef lint
-static char _argbreak;
-#else
-extern char _argbreak; /* break character from nxtarg */
-#endif
-
-extern TREELIST *listTL; /* list of trees for scanning */
-extern TREE *listT; /* final list of files in collection */
-extern TREE *refuseT; /* files refused by client */
-
-extern char *collname; /* collection name */
-extern char *basedir; /* base directory name */
-extern char *prefix; /* collection pathname prefix */
-extern time_t lasttime; /* time of last upgrade */
-extern time_t scantime; /* time of this scan */
-extern int trace; /* trace directories */
-extern int newonly; /* new files only */
-
-#ifdef RCSSTAT
-extern char *rcs_branch;
-extern int candorcs;
-#endif
-
-/*************************************************
- *** STATIC R O U T I N E S ***
- *************************************************/
-static void passdelim(char **, int );
-static char *parserelease(TREELIST **, char *, char *);
-static int scanone(TREE *, void *);
-static void makescan(char *, char *);
-static void getscan(char *, char *);
-static void doscan(char *);
-static void readlistfile(char *);
-static void expTinsert(char *, TREE **, int, char *);
-static int listone(TREE *, void *);
-static void listentry(char *, char *, char *, int);
-static void listname(char *, struct stat *);
-static void listdir(char *, int);
-static int omitanyone(TREE *, void *);
-static int anyglob(char *, char *);
-static int getscanfile(char *);
-static void chkscanfile(char *);
-static void makescanfile(char *);
-static int recordone(TREE *, void *);
-static int recordexec(TREE *, void *);
-
-
-/*************************************************
- *** L I S T S C A N R O U T I N E S ***
- *************************************************/
-
-static void
-passdelim(ptr,delim) /* skip over delimiter */
- char **ptr, delim;
-{
-
- *ptr = skipover (*ptr, " \t");
- if (_argbreak != delim && **ptr == delim) {
- (*ptr)++;
- *ptr = skipover (*ptr, " \t");
- }
-}
-
-static char *
-parserelease(tlp, relname, args)
- TREELIST **tlp;
- char *relname, *args;
-{
- TREELIST *tl;
- char *arg;
- OPTION option;
- int opno;
- char *nextrel;
-
- tl = (TREELIST *) malloc(sizeof(TREELIST));
- if ((*tlp = tl) == NULL)
- goaway("Couldn't allocate TREELIST");
- tl->TLnext = NULL;
- tl->TLname = strdup(relname);
- tl->TLprefix = NULL;
- tl->TLlist = NULL;
- tl->TLscan = NULL;
- tl->TLhost = NULL;
- nextrel = NULL;
- args = skipover(args, " \t");
- while (*(arg = nxtarg(&args, " \t="))) {
- for (opno = 0; options[opno] != NULL; opno++)
- if (strcmp(arg, options[opno]) == 0)
- break;
- if (options[opno] == NULL)
- goaway("Invalid release option %s for release %s",
- arg, relname);
- option = (OPTION) opno;
- switch (option) {
- case ONEXT:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- nextrel = strdup(arg);
- break;
- case OPREFIX:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- tl->TLprefix = strdup(arg);
- break;
- case OLIST:
- passdelim(&args,'=');
- arg = nxtarg(&args, " \t");
- tl->TLlist = strdup(arg);
- break;
- case OSCAN:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- tl->TLscan = strdup(arg);
- break;
- case OHOST:
- passdelim(&args, '=');
- arg = nxtarg (&args, " \t");
- tl->TLhost = strdup(arg);
- break;
- }
- }
- return (nextrel);
-}
-
-int
-getrelease (release)
- char *release;
-{
- TREELIST *tl;
- char buf[STRINGLENGTH];
- char *p,*q;
- int rewound;
- FILE *f;
-
- if (release == NULL)
- release = strdup(DEFRELEASE);
- listTL = NULL;
-
- (void) snprintf(buf, sizeof buf, FILERELEASES, collname);
- f = fopen(buf, "r");
- if (f != NULL) {
- rewound = TRUE;
- for (;;) {
- p = fgets(buf, sizeof(buf), f);
- if (p == NULL) {
- if (rewound)
- break;
- rewind(f);
- rewound = TRUE;
- continue;
- }
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t");
- if (strcmp(q, release) != 0)
- continue;
- release = parserelease(&tl, release, p);
- if (tl->TLprefix == NULL)
- tl->TLprefix = prefix;
- else if (chdir(tl->TLprefix) < 0)
- return (FALSE);
- else
- (void) chdir(basedir);
- tl->TLnext = listTL;
- listTL = tl;
- if (release == NULL)
- break;
- rewound = FALSE;
- }
- (void) fclose(f);
- }
- if (release == NULL)
- return (TRUE);
- if (strcmp(release, DEFRELEASE) != 0)
- return (FALSE);
- (void) parserelease(&tl, release, "");
- tl->TLprefix = prefix;
- tl->TLnext = listTL;
- listTL = tl;
- return (TRUE);
-}
-
-void
-makescanlists()
-{
- TREELIST *tl;
- char buf[STRINGLENGTH];
- char *p,*q;
- FILE *f;
- char *saveprefix = prefix;
- int count = 0;
-
- (void) snprintf(buf, sizeof buf, FILERELEASES, collname);
- f = fopen(buf, "r");
- if (f != NULL) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t");
- (void) parserelease(&tl, q, p);
- if ((prefix = tl->TLprefix) == NULL)
- prefix = saveprefix;
- if (prefix != NULL) {
- if (chdir(prefix) < 0)
- goaway("Can't chdir to %s", prefix);
- (void) chdir(basedir);
- }
- makescan(tl->TLlist, tl->TLscan);
- free(tl);
- count++;
- }
- (void) fclose(f);
- }
- if (count == 0)
- makescan(NULL, NULL);
-}
-
-static int
-scanone(t, v)
- TREE *t;
- void *v;
-{
- TREE *newt;
-
- if (newonly && (t->Tflags&FNEW) == 0)
- return (SCMOK);
- newt = Tinsert (&listT, t->Tname, FALSE);
- if (newt == NULL)
- return (SCMOK);
- newt->Tmode = t->Tmode;
- newt->Tflags = t->Tflags;
- newt->Tmtime = t->Tmtime;
- return (SCMOK);
-}
-
-void
-getscanlists()
-{
- TREELIST *tl,*stl;
-
- stl = listTL;
- listTL = NULL;
- while ((tl = stl) != NULL) {
- prefix = tl->TLprefix;
- getscan(tl->TLlist, tl->TLscan);
- tl->TLtree = listT;
- stl = tl->TLnext;
- tl->TLnext = listTL;
- listTL = tl;
- }
- listT = NULL;
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- (void) Tprocess(tl->TLtree, scanone, NULL);
-}
-
-static void
-makescan(listfile, scanfile)
- char *listfile, *scanfile;
-{
- listT = NULL;
- chkscanfile(scanfile); /* can we can write a scan file? */
- doscan(listfile); /* read list file and scan disk */
- makescanfile(scanfile); /* record names in scan file */
- Tfree(&listT); /* free file list tree */
-}
-
-static void
-getscan(listfile, scanfile)
- char *listfile, *scanfile;
-{
- listT = NULL;
- if (!getscanfile(scanfile)) { /* check for pre-scanned file list */
- scantime = time(NULL);
- doscan(listfile); /* read list file and scan disk */
- }
-}
-
-static void
-doscan (listfile)
- char *listfile;
-{
- char buf[STRINGLENGTH];
-
- upgT = NULL;
- flagsT = NULL;
- omitT = NULL;
- omanyT = NULL;
- execT = NULL;
- symT = NULL;
- rsymT = NULL;
- if (listfile == NULL)
- listfile = FILELISTDEF;
- (void) snprintf(buf, sizeof buf, FILELIST, collname, listfile);
- readlistfile(buf); /* get contents of list file */
- (void) Tprocess(upgT, listone, NULL); /* build list of files specified */
- cdprefix(NULL);
- Tfree(&upgT);
- Tfree(&flagsT);
- Tfree(&omitT);
- Tfree(&omanyT);
- Tfree(&execT);
- Tfree(&symT);
- Tfree(&rsymT);
-}
-
-static void
-readlistfile(fname)
- char *fname;
-{
- char buf[STRINGLENGTH+MAXPATHLEN*4+1], *p;
- char *q, *r;
- FILE *f;
- int ltn, n, i, flags;
- TREE **t = NULL;
- LISTTYPE lt;
- char *speclist[SPECNUMBER];
-
- f = fopen(fname,"r");
- if (f == NULL)
- goaway("Can't read list file %s", fname);
- cdprefix(prefix);
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg (&p, " \t");
- if (*q == '\0')
- continue;
- for (ltn = 0; ltname[ltn] && strcmp(q, ltname[ltn]) != 0; ltn++)
- ;
- if (ltname[ltn] == NULL)
- goaway("Invalid list file keyword %s", q);
- lt = (LISTTYPE) ltn;
- flags = 0;
- switch (lt) {
- case LUPGRADE:
- t = &upgT;
- break;
- case LBACKUP:
- t = &flagsT;
- flags = FBACKUP;
- break;
- case LNOACCT:
- t = &flagsT;
- flags = FNOACCT;
- break;
- case LSYMLINK:
- t = &symT;
- break;
- case LRSYMLINK:
- t = &rsymT;
- break;
- case LOMIT:
- t = &omitT;
- break;
- case LOMITANY:
- t = &omanyT;
- break;
- case LALWAYS:
- t = &upgT;
- flags = FALWAYS;
- break;
- case LINCLUDE:
- while (*(q = nxtarg(&p, " \t"))) {
- cdprefix(NULL);
- n = expand(q, speclist, SPECNUMBER);
- for (i = 0; i < n && i < SPECNUMBER; i++) {
- readlistfile(speclist[i]);
- cdprefix(NULL);
- free(speclist[i]);
- }
- cdprefix(prefix);
- }
- continue;
- case LEXECUTE:
- r = p = q = skipover(p, " \t");
- do {
- q = p = skipto(p, " \t(");
- p = skipover(p, " \t");
- } while (*p != '(' && *p != '\0');
- if (*p++ == '(') {
- *q = '\0';
- do {
- q = nxtarg(&p, " \t)");
- if (*q == 0)
- _argbreak = ')';
- else
- expTinsert(q, &execT, 0, r);
- } while (_argbreak != ')');
- continue;
- }
- /* fall through */
- default:
- goaway("Error in handling list file keyword %d", ltn);
- }
- while (*(q = nxtarg(&p, " \t"))) {
- if (lt == LOMITANY)
- (void) Tinsert(t, q, FALSE);
- else
- expTinsert(q, t, flags, NULL);
- }
- }
- (void) fclose(f);
-}
-
-static void
-expTinsert(p, t, flags, exec)
- char *p;
- TREE **t;
- int flags;
- char *exec;
-{
- int n, i;
- TREE *newt;
- char *speclist[SPECNUMBER];
- char buf[STRINGLENGTH];
-
- n = expand(p, speclist, SPECNUMBER);
- for (i = 0; i < n && i < SPECNUMBER; i++) {
- newt = Tinsert(t, speclist[i], TRUE);
- newt->Tflags |= flags;
- if (exec) {
- (void) snprintf(buf, sizeof buf, exec, speclist[i]);
- (void) Tinsert(&newt->Texec, buf, FALSE);
- }
- free(speclist[i]);
- }
-}
-
-static int
-listone (t, v) /* expand and add one name from upgrade list */
- TREE *t;
- void *v;
-{
-
- listentry(t->Tname, t->Tname, NULL, (t->Tflags&FALWAYS) != 0);
- return (SCMOK);
-}
-
-static void
-listentry(name, fullname, updir, always)
- char *name, *fullname, *updir;
- int always;
-{
- struct stat statbuf;
- int link = 0;
-
- if (Tlookup (refuseT, fullname))
- return;
- if (!always) {
- if (Tsearch (omitT, fullname))
- return;
- if (Tprocess (omanyT, omitanyone, fullname) != SCMOK)
- return;
- }
- if (lstat(name, &statbuf) < 0)
- return;
- if (S_ISLNK(statbuf.st_mode)) {
- if (Tsearch(symT, fullname)) {
- listname(fullname, &statbuf);
- return;
- }
- if (Tlookup(rsymT, fullname)) {
- listname(fullname, &statbuf);
- return;
- }
- if (updir)
- link++;
- if (stat(name, &statbuf) < 0)
- return;
- }
- if (S_ISDIR(statbuf.st_mode)) {
- if (access(name, R_OK|X_OK) < 0)
- return;
- if (chdir(name) < 0)
- return;
- listname(fullname, &statbuf);
- if (trace) {
- printf("Scanning directory %s\n", fullname);
- (void) fflush(stdout);
- }
- listdir (fullname, always);
- if (updir == 0 || link) {
- (void) chdir(basedir);
- if (prefix)
- (void) chdir(prefix);
- if (updir && *updir)
- (void) chdir(updir);
- } else
- (void) chdir("..");
- return;
- }
- if (access(name, R_OK) < 0)
- return;
-#ifdef RCSSTAT
- if (candorcs) {
- char rcs_release[STRINGLENGTH];
- int status;
-
- if (rcs_branch != NULL)
-#ifdef CVS
- snprintf(rcs_release, sizeof rcs_release,
- "-r %s", rcs_branch);
-#else
- snprintf(rcs_release, sizeof rcs_release,
- "-r%s", rcs_branch);
-#endif
- else
- rcs_release[0] = '\0';
-#ifdef CVS
- snprintf(sys_com, sizeof sys_com,
- "cvs -d %s -r -l -Q co -p %s %s > %s\n", cvs_root,
- rcs_release, name, rcs_file);
-#else
- status = runp("rcsstat", "rcsstat", "-q", rcs_release, name, 0);
-#endif
- if (status != 0)
- return;
- }
-#endif
- listname(fullname, &statbuf);
-}
-
-static void
-listname(name,st)
- char *name;
- struct stat *st;
-{
- TREE *t, *ts;
- int new;
- TREELIST *tl;
-
- new = st->st_ctime > lasttime;
- if (newonly && !new) {
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- if ((ts = Tsearch(tl->TLtree, name)) != NULL)
- ts->Tflags &= ~FNEW;
- return;
- }
- t = Tinsert(&listT, name, FALSE);
- if (t == NULL)
- return;
- t->Tmode = st->st_mode;
- t->Tctime = st->st_ctime;
- t->Tmtime = st->st_mtime;
- if (new)
- t->Tflags |= FNEW;
- if ((ts = Tsearch (flagsT, name)) != NULL)
- t->Tflags |= ts->Tflags;
- if ((ts = Tsearch (execT, name)) != NULL) {
- t->Texec = ts->Texec;
- ts->Texec = NULL;
- }
-}
-
-static void
-listdir(name,always) /* expand directory */
- char *name;
- int always;
-{
-#ifdef HAS_POSIX_DIR
- struct dirent *dentry;
-#else
- struct direct *dentry;
-#endif
- DIR *dirp;
- char ename[STRINGLENGTH], newname[STRINGLENGTH], filename[STRINGLENGTH];
- char *p, *newp;
- int i;
-
- dirp = opendir(".");
- if (dirp == 0)
- return; /* unreadable: probably protected */
-
- p = name; /* punt leading ./ and trailing / */
- newp = newname;
- if (p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/')
- p++;
- }
- while ((*newp++ = *p++) != '\0')
- ; /* copy string */
- --newp; /* trailing null */
- while (newp > newname && newp[-1] == '/')
- --newp; /* trailing / */
- *newp = 0;
- if (strcmp(newname, ".") == 0)
- newname[0] = 0; /* "." ==> "" */
-
- while ((dentry=readdir(dirp)) != NULL) {
- if (dentry->d_ino == 0 || strcmp(dentry->d_name, ".") == 0 ||
- strcmp(dentry->d_name, "..") == 0)
- continue;
- for (i=0; i <= MAXNAMLEN && dentry->d_name[i]; i++)
- ename[i] = dentry->d_name[i];
- ename[i] = 0;
- if (*newname)
- (void) snprintf(filename, sizeof filename, "%s/%s",
- newname, ename);
- else
- (void) strlcpy(filename, ename, sizeof filename);
- listentry(ename, filename, newname, always);
- }
- closedir(dirp);
-}
-
-static int
-omitanyone(t,fv)
- TREE *t;
- void *fv;
-{
- char *filename = fv;
-
- if (anyglob(t->Tname, filename))
- return (SCMERR);
- return (SCMOK);
-}
-
-static int
-anyglob(pattern, match)
- char *pattern, *match;
-{
- char *p, *m;
- char *pb, *pe;
-
- p = pattern;
- m = match;
- while (*m && *p == *m ) {
- p++;
- m++;
- }
- if (*p == '\0' && *m == '\0')
- return (TRUE);
- switch (*p++) {
- case '*':
- for (;;) {
- if (*p == '\0')
- return (TRUE);
- if (*m == '\0')
- return (*p == '\0');
- if (anyglob (p, ++m))
- return (TRUE);
- }
- case '?':
- return (anyglob(p, ++m));
- case '[':
- pb = p;
- while (*(++p) != ']')
- if (*p == '\0')
- return (FALSE);
- pe = p;
- for (p = pb + 1; p != pe; p++) {
- switch (*p) {
- case '-':
- if (p == pb && *m == '-') {
- p = pe + 1;
- return (anyglob(p, ++m));
- }
- if (p == pb)
- continue;
- if ((p + 1) == pe)
- return (FALSE);
- if (*m > *(p - 1) &&
- *m <= *(p + 1)) {
- p = pe + 1;
- return (anyglob(p, ++m));
- }
- continue;
- default:
- if (*m == *p) {
- p = pe + 1;
- return (anyglob(p, ++m));
- }
- }
- }
- return (FALSE);
- default:
- return (FALSE);
- }
-}
-
-/*****************************************
- *** R E A D S C A N F I L E ***
- *****************************************/
-
-static
-int getscanfile(scanfile)
- char *scanfile;
-{
- char buf[STRINGLENGTH];
- char fname[MAXPATHLEN];
- struct stat sbuf;
- FILE *f;
- TREE ts;
- char *p, *q;
- TREE *tmp, *t = NULL;
- int notwanted;
- TREELIST *tl;
-
- if (scanfile == NULL)
- scanfile = FILESCANDEF;
- (void) snprintf(buf, sizeof buf, FILESCAN, collname, scanfile);
- if (stat(buf, &sbuf) < 0)
- return (FALSE);
- if ((f = fopen(buf, "r")) == NULL)
- return (FALSE);
- if ((p = fgets (buf, sizeof(buf), f)) == NULL) {
- (void) fclose(f);
- return (FALSE);
- }
-
- p[strcspn(p, "\n")] = '\0';
-
- if (*p++ != 'V') {
- (void) fclose(f);
- return (FALSE);
- }
- if (atoi (p) != SCANVERSION) {
- (void) fclose(f);
- return (FALSE);
- }
- scantime = sbuf.st_mtime; /* upgrade time is time of supscan,
- * i.e. time of creation of scanfile */
- if (newonly && scantime == lasttime) {
- (void) fclose(f);
- return (TRUE);
- }
- notwanted = FALSE;
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- ts.Tflags = 0;
- if (*p == 'X') {
- if (notwanted)
- continue;
- if (t == NULL)
- goaway("scanfile format inconsistent");
- (void) Tinsert(&t->Texec, ++p, FALSE);
- continue;
- }
- notwanted = FALSE;
- if (*p == 'B') {
- p++;
- ts.Tflags |= FBACKUP;
- }
- if (*p == 'N') {
- p++;
- ts.Tflags |= FNOACCT;
- }
- if ((q = strchr(p, ' ')) == NULL)
- goaway("scanfile format inconsistent");
- *q++ = '\0';
- ts.Tmode = atoo(p);
- p = q;
- if ((q = strchr(p, ' ')) == NULL)
- goaway("scanfile format inconsistent");
- *q++ = '\0';
- ts.Tctime = atoi(p);
- p = q;
- if ((q = strchr(p, ' ')) == NULL)
- goaway("scanfile format inconsistent");
- *q++ = 0;
- ts.Tmtime = atoi(p);
- (void) strunvis(fname, q);
- if (ts.Tctime > lasttime)
- ts.Tflags |= FNEW;
- else if (newonly) {
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- if ((tmp = Tsearch(tl->TLtree, fname)) != NULL)
- tmp->Tflags &= ~FNEW;
- notwanted = TRUE;
- continue;
- }
- if (Tlookup(refuseT, fname)) {
- notwanted = TRUE;
- continue;
- }
- t = Tinsert(&listT, fname, TRUE);
- t->Tmode = ts.Tmode;
- t->Tflags = ts.Tflags;
- t->Tctime = ts.Tctime;
- t->Tmtime = ts.Tmtime;
- }
- (void) fclose(f);
- return (TRUE);
-}
-
-/*******************************************
- *** W R I T E S C A N F I L E ***
- *******************************************/
-
-static void chkscanfile(scanfile)
-char *scanfile;
-{
- char tname[STRINGLENGTH], fname[STRINGLENGTH];
- FILE *f;
-
- if (scanfile == NULL)
- scanfile = FILESCANDEF;
- (void) snprintf(fname, sizeof fname, FILESCAN, collname, scanfile);
- (void) snprintf(tname, sizeof tname, "%s.temp", fname);
- if ((f = fopen(tname, "w")) == NULL)
- goaway("Can't test scan file temp %s for %s", tname, collname);
- else {
- (void) unlink(tname);
- (void) fclose(f);
- }
-}
-
-static void makescanfile(scanfile)
- char *scanfile;
-{
- char tname[STRINGLENGTH],fname[STRINGLENGTH];
- struct timeval tbuf[2];
- FILE *scanF; /* output file for scanned file list */
-
- if (scanfile == NULL)
- scanfile = FILESCANDEF;
- (void) snprintf(fname, sizeof fname, FILESCAN, collname, scanfile);
- (void) snprintf(tname, sizeof tname, "%s.temp", fname);
- scanF = fopen(tname, "w");
- if (scanF == NULL)
- goaway("Can't write scan file temp %s for %s", tname, collname);
- fprintf(scanF, "V%d\n", SCANVERSION);
- (void) Tprocess(listT, recordone, scanF);
- (void) fclose(scanF);
- if (rename(tname, fname) < 0)
- goaway("Can't change %s to %s", tname, fname);
- (void) unlink(tname);
- tbuf[0].tv_sec = time(NULL);
- tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = scantime;
- tbuf[1].tv_usec = 0;
- (void) utimes(fname, tbuf);
-}
-
-static int
-recordone(t,v)
- TREE *t;
- void *v;
-{
- FILE *scanF = v;
- char fname[MAXPATHLEN*4+1];
-
- if (t->Tflags&FBACKUP)
- fprintf(scanF, "B");
- if (t->Tflags&FNOACCT)
- fprintf(scanF, "N");
- strnvis(fname, t->Tname, sizeof fname, VIS_WHITE);
- fprintf(scanF, "%o %d %d %s\n", t->Tmode, t->Tctime, t->Tmtime, fname);
- (void) Tprocess(t->Texec, recordexec, scanF);
- return (SCMOK);
-}
-
-static int
-recordexec(t,v)
- TREE *t;
- void *v;
-{
- FILE *scanF = v;
- char fname[MAXPATHLEN*4+1];
-
- strlcpy(fname, t->Tname, sizeof fname);
- fprintf(scanF, "X%s\n", fname);
- return (SCMOK);
-}
-
-void
-cdprefix(prefix)
- char *prefix;
-{
- static char *curprefix = NULL;
-
- if (curprefix == NULL) {
- if (prefix == NULL)
- return;
- (void) chdir(prefix);
- curprefix = prefix;
- return;
- }
- if (prefix == NULL) {
- (void) chdir(basedir);
- curprefix = NULL;
- return;
- }
- if (prefix == curprefix)
- return;
- if (strcmp (prefix, curprefix) == 0) {
- curprefix = prefix;
- return;
- }
- (void) chdir(basedir);
- (void) chdir(prefix);
- curprefix = prefix;
-}
diff --git a/usr.bin/sup/src/scm.c b/usr.bin/sup/src/scm.c
deleted file mode 100644
index 7093440863a..00000000000
--- a/usr.bin/sup/src/scm.c
+++ /dev/null
@@ -1,660 +0,0 @@
-/* $OpenBSD: scm.c,v 1.19 2007/09/02 15:19:35 deraadt Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * SUP Communication Module for 4.3 BSD
- *
- * SUP COMMUNICATION MODULE SPECIFICATIONS:
- *
- * IN THIS MODULE:
- *
- * CONNECTION ROUTINES
- *
- * FOR SERVER
- * servicesetup (port) establish TCP port connection
- * char *port; name of service
- * service () accept TCP port connection
- * servicekill () close TCP port in use by another process
- * serviceprep () close temp ports used to make connection
- * serviceend () close TCP port
- *
- * FOR CLIENT
- * request (port,hostname,retry) establish TCP port connection
- * char *port,*hostname; name of service and host
- * int retry; true if retries should be used
- * requestend () close TCP port
- *
- * HOST NAME CHECKING
- * p = remotehost () remote host name (if known)
- * char *p;
- * i = samehost () whether remote host is also this host
- * int i;
- * i = matchhost (name) whether remote host is same as name
- * int i;
- * char *name;
- *
- * RETURN CODES
- * All procedures return values as indicated above. Other routines
- * normally return SCMOK on success, SCMERR on error.
- *
- * COMMUNICATION PROTOCOL
- *
- * Described in scmio.c.
- *
- **********************************************************************
- * HISTORY
- * 2-Oct-92 Mary Thompson (mrt) at Carnegie-Mellon University
- * Added conditional declarations of INADDR_NONE and INADDR_LOOPBACK
- * since Tahoe version of <netinet/in.h> does not define them.
- *
- * Revision 1.13 92/08/11 12:05:35 mrt
- * Added changes from stump:
- * Allow for multiple interfaces, and for numeric addresses.
- * Changed to use builtin port for the "supfiledbg"
- * service when getservbyname() cannot find it.
- * Added forward static declatations, delinted.
- * Updated variable argument usage.
- * [92/08/08 mrt]
- *
- * Revision 1.12 92/02/08 19:01:11 mja
- * Add (struct sockaddr *) casts for HC 2.1.
- * [92/02/08 18:59:09 mja]
- *
- * Revision 1.11 89/08/03 19:49:03 mja
- * Updated to use v*printf() in place of _doprnt().
- * [89/04/19 mja]
- *
- * 11-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Moved sleep into computeBackoff, renamed to dobackoff.
- *
- * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added timeout to backoff.
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed nameserver support.
- *
- * 09-Sep-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed to depend less upon having name of remote host.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon Universtiy
- * Extracted backoff/sleeptime computation from "request" and
- * created "computeBackoff" so that I could use it in sup.c when
- * trying to get to nameservers as a group.
- *
- * 21-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Merged divergent CS and EE versions.
- *
- * 02-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added some bullet-proofing code around hostname calls.
- *
- * 31-Mar-87 Dan Nydick (dan) at Carnegie-Mellon University
- * Fixed for 4.3.
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to use known values for well-known ports if they are
- * not found in the host table.
- *
- * 19-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed setsockopt SO_REUSEADDR to be non-fatal. Added fourth
- * parameter as described in 4.3 manual entry.
- *
- * 15-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added call of readflush() to requestend() routine.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. All read/write and crypt
- * routines are now in scmio.c.
- *
- * 14-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added setsockopt SO_REUSEADDR call.
- *
- * 01-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed code to "gracefully" handle unexpected messages. This
- * seems reasonable since it didn't work anyway, and should be
- * handled at a higher level anyway by adhering to protocol version
- * number conventions.
- *
- * 26-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed scm.c to free space for remote host name when connection
- * is closed.
- *
- * 07-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed 4.2 retry code to reload sin values before retry.
- *
- * 22-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to retry initial connection open request.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 21-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Add close() calls after pipe() call.
- *
- * 12-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Converted for 4.2 sockets; added serviceprep() routine.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#ifndef SIOCGIFCONF
-#include <sys/sockio.h>
-#endif
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <stdarg.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff /* -1 return */
-#endif
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK (u_long)0x7f000001 /* 127.0.0.1 */
-#endif
-
-char scmversion[] = "4.3 BSD";
-extern int silent;
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-/* networking parameters */
-#define NCONNECTS 5
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-extern char program[]; /* name of program we are running */
-extern pid_t progpid; /* process id to display */
-
-int netfile = -1; /* network file descriptor */
-
-static int sock = -1; /* socket used to make connection */
-static struct in_addr remoteaddr; /* remote host address */
-static char *remotename = NULL; /* remote host name */
-static int swapmode; /* byte-swapping needed on server? */
-
-
-static char *myhost(void);
-
-/***************************************************
- *** C O N N E C T I O N R O U T I N E S ***
- *** F O R S E R V E R ***
- ***************************************************/
-
-/*
- * Mark that we are servicing a connection from host at ia. We do
- * this by getting an exclusive lock on a file that is "ia" in
- * dotted decimal, in directory "lockdir". For convienence's sake we
- * write our process ID in there. Should be called from servicing
- * child, so lock goes away on exit. Must be called after service()
- * sets global remoteaddr (above).
- *
- * Returns fd for file on success, -1 on failure.
- */
-int
-lock_host_file(lockdir)
- char *lockdir;
-{
- char *dd, *lpath;
- int fd;
- FILE *f;
-
- dd = strdup(inet_ntoa(remoteaddr));
- if (dd == NULL) {
- syslog(LOG_ERR, "Malloc failed in lock_host_file()");
- return(-1);
- }
- if (asprintf(&lpath, "%s/%s", lockdir, dd) == -1) {
- syslog(LOG_ERR, "Malloc failed in lock_host_file()");
- free(dd);
- return(-1);
- }
- free(dd);
- if ((fd = open(lpath, O_CREAT | O_WRONLY, 0600)) < 0) {
- syslog(LOG_ERR, "Couldn't open/create lock file %s (%m)", lpath);
- free(lpath);
- return(-1);
- }
-#ifdef USE_LOCKF
- if (lockf(fd, F_TLOCK, 0) != 0)
-#else
- if (flock(fd, LOCK_EX | LOCK_NB ) != 0)
-#endif
- {
- syslog(LOG_DEBUG, "Can't get lock on %s.", lpath);
- free(lpath);
- close(fd);
- return(-1);
- }
- if (ftruncate(fd, 0) < 0) {
- syslog(LOG_ERR,
- "Couldn't ftruncate fd %d for lock file %s (%m)",
- fd, lpath);
- free(lpath);
- close(fd);
- return(-1);
- }
- f = fdopen(fd, "w");
- if (f == NULL) {
- syslog(LOG_ERR, "Couldn't fopen fd %d for lock file %s (%m)",
- fd, lpath);
- free(lpath);
- close(fd);
- return(-1);
- }
- (void)fprintf(f, "%ld\n", (long) getpid());
- fflush(f);
- free(lpath);
- return(fd);
-}
-
-int
-servicesetup(server) /* listen for clients */
- char *server;
-{
- struct sockaddr_in sin;
- struct servent *sp;
- short port;
- int one = 1;
-
- if (myhost() == NULL)
- return (scmerr(-1, "Local hostname not known"));
- if ((sp = getservbyname(server, "tcp")) == 0) {
- if (strcmp(server, FILEPORT) == 0)
- port = htons((u_short)FILEPORTNUM);
- else if (strcmp(server, DEBUGFPORT) == 0)
- port = htons((u_short)DEBUGFPORTNUM);
- else
- return (scmerr(-1, "Can't find %s server description",
- server));
- (void) scmerr(-1, "%s/tcp: unknown service: using port %d",
- server, ntohs(port));
- } else
- port = sp->s_port;
- endservent();
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- return (scmerr(errno, "Can't create socket for connections"));
- if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(int)) < 0)
- (void) scmerr (errno,"Can't set SO_REUSEADDR socket option");
- (void) memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_port = port;
- if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)
- return (scmerr(errno, "Can't bind socket for connections"));
- if (listen(sock, NCONNECTS) < 0)
- return (scmerr(errno, "Can't listen on socket"));
- return (SCMOK);
-}
-
-int
-service()
-{
- struct sockaddr_in from;
- int x, len;
-
-again:
- remotename = NULL;
- len = sizeof(from);
- do {
- netfile = accept(sock, (struct sockaddr *)&from, &len);
- } while (netfile < 0 && errno == EINTR);
- if (netfile < 0)
- return (scmerr(errno, "Can't accept connections"));
-
- /* protection against ftp bounce attack */
- if (from.sin_port == htons(20)) {
- close(netfile);
- goto again;
- }
- remoteaddr = from.sin_addr;
- if (read(netfile, (char *)&x, sizeof(int)) != sizeof(int))
- return (scmerr(errno, "Can't transmit data on connection"));
- if (x == 0x01020304)
- swapmode = 0;
- else if (x == 0x04030201)
- swapmode = 1;
- else
- return (scmerr(-1, "Unexpected byteswap mode %x", x));
- return (SCMOK);
-}
-
-int
-serviceprep() /* kill temp socket in daemon */
-{
-
- if (sock >= 0) {
- (void) close (sock);
- sock = -1;
- }
- return (SCMOK);
-}
-
-int
-servicekill() /* kill net file in daemon's parent */
-{
-
- if (netfile >= 0) {
- (void) close(netfile);
- netfile = -1;
- }
- if (remotename) {
- free(remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-int
-serviceend() /* kill net file after use in daemon */
-{
-
- if (netfile >= 0) {
- (void) close(netfile);
- netfile = -1;
- }
- if (remotename) {
- free(remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-/***************************************************
- *** C O N N E C T I O N R O U T I N E S ***
- *** F O R C L I E N T ***
- ***************************************************/
-
-int dobackoff(t, b)
- int *t, *b;
-{
- struct timeval tt;
- unsigned s;
-
- if (*t == 0)
- return (0);
- s = *b * 30;
- if (gettimeofday(&tt, NULL) >= 0)
- s += (tt.tv_usec >> 8) % s;
- if (*b < 32)
- *b <<= 1;
- if (*t != -1) {
- if (s > *t)
- s = *t;
- *t -= s;
- }
- if (!silent)
- (void) scmerr(-1, "Will retry in %d seconds", s);
- sleep(s);
- return (1);
-}
-
-int
-request(server, hostname, retry) /* connect to server */
- char *server;
- char *hostname;
- int *retry;
-{
- int x, backoff;
- struct hostent *h;
- struct servent *sp;
- struct sockaddr_in sin, tin;
- short port;
-
- if ((sp = getservbyname(server,"tcp")) == 0) {
- if (strcmp(server, FILEPORT) == 0)
- port = htons((u_short)FILEPORTNUM);
- else if (strcmp(server, DEBUGFPORT) == 0)
- port = htons((u_short)DEBUGFPORTNUM);
- else
- return (scmerr (-1, "Can't find %s server description",
- server));
- if (!silent)
- (void) scmerr (-1, "%s/tcp: unknown service: using port %d",
- server, ntohs(port));
- } else
- port = sp->s_port;
- (void) memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = inet_addr(hostname);
- if (sin.sin_addr.s_addr == (u_long) INADDR_NONE) {
- if ((h = gethostbyname(hostname)) == NULL)
- return (scmerr(-1, "Can't find host entry for %s",
- hostname));
- hostname = h->h_name;
- (void) memcpy(&sin.sin_addr, h->h_addr, h->h_length);
- }
- sin.sin_port = port;
- backoff = 1;
- for (;;) {
- netfile = socket(AF_INET, SOCK_STREAM, 0);
- if (netfile < 0)
- return (scmerr(errno, "Can't create socket"));
- tin = sin;
- if (connect(netfile, (struct sockaddr *)&tin, sizeof(tin)) >= 0)
- break;
- (void) scmerr (errno,"Can't connect to server for %s", server);
- (void) close(netfile);
- if (!dobackoff(retry,&backoff))
- return (SCMERR);
- }
- remoteaddr = sin.sin_addr;
- remotename = strdup(hostname);
- x = 0x01020304;
- (void) write (netfile, (char *)&x, sizeof(int));
- swapmode = 0; /* swap only on server, not client */
- return (SCMOK);
-}
-
-int
-requestend() /* end connection to server */
-{
-
- (void) readflush();
- if (netfile >= 0) {
- (void) close(netfile);
- netfile = -1;
- }
- if (remotename) {
- free(remotename);
- remotename = NULL;
- }
- return (SCMOK);
-}
-
-/*************************************************
- *** H O S T N A M E C H E C K I N G ***
- *************************************************/
-
-static char *
-myhost() /* find my host name */
-{
- struct hostent *h;
- static char name[MAXHOSTNAMELEN];
-
- if (name[0] == '\0') {
- if (gethostname(name,sizeof name) < 0)
- return (NULL);
- if ((h = gethostbyname(name)) == NULL)
- return (NULL);
- (void) strlcpy(name, h->h_name, sizeof name);
- }
- return (name);
-}
-
-char *
-remotehost() /* remote host name (if known) */
-{
- struct hostent *h;
-
- if (remotename == NULL) {
- h = gethostbyaddr((char *)&remoteaddr, sizeof(remoteaddr),
- AF_INET);
- remotename = strdup(h ? h->h_name : inet_ntoa(remoteaddr));
- if (remotename == NULL)
- return("UNKNOWN");
- }
- return (remotename);
-}
-
-int
-thishost(host)
- char *host;
-{
- struct hostent *h;
- char *name;
-
- if ((name = myhost()) == NULL)
- logquit (1, "Can't find my host entry '%s'", myhost());
- h = gethostbyname(host);
- if (h == NULL)
- return (0);
- return (strcasecmp(name, h->h_name) == 0);
-}
-
-int
-samehost() /* is remote host same as local host? */
-{
- static struct in_addr *intp;
- static int nint = 0;
- struct in_addr *ifp;
- int n;
-
- if (nint <= 0) {
- int s;
- char buf[BUFSIZ];
- struct ifconf ifc;
- struct ifreq *ifr;
- struct sockaddr_in sin;
-
- if ((s = socket (AF_INET,SOCK_DGRAM,0)) < 0)
- logquit (1,"Can't create socket for SIOCGIFCONF");
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0)
- logquit(1,"SIOCGIFCONF failed");
- (void) close(s);
- if ((nint = ifc.ifc_len / sizeof(struct ifreq)) <= 0)
- return (0);
- intp = (struct in_addr *)
- calloc (nint, sizeof(struct in_addr));
- if ((ifp = intp) == 0)
- logquit (1, "no space for interfaces");
- for (ifr = ifc.ifc_req, n = nint; n > 0; --n, ifr++) {
- (void) memcpy(&sin, &ifr->ifr_addr, sizeof(sin));
- *ifp++ = sin.sin_addr;
- }
- }
- if (remoteaddr.s_addr == htonl(INADDR_LOOPBACK))
- return (1);
- for (ifp = intp, n = nint; n > 0; --n, ifp++)
- if (remoteaddr.s_addr == ifp->s_addr)
- return (1);
- return (0);
-}
-
-int
-matchhost(name) /* is this name of remote host? */
- char *name;
-{
- struct hostent *h;
- struct in_addr addr;
- char **ap;
-
- if ((addr.s_addr = inet_addr(name)) != (u_long) INADDR_NONE)
- return (addr.s_addr == remoteaddr.s_addr);
- if ((h = gethostbyname(name)) == 0)
- return (0);
- if (h->h_addrtype != AF_INET || h->h_length != sizeof(struct in_addr))
- return (0);
- for (ap = h->h_addr_list; *ap; ap++)
- if (memcmp(&remoteaddr, *ap, h->h_length) == 0)
- return (1);
- return (0);
-}
-
-int scmerr(int error,char *fmt,...)
-{
- va_list ap;
-
- va_start(ap,fmt);
- (void) fflush(stdout);
- if (progpid > 0)
- fprintf(stderr, "%s %ld: ", program, (long)progpid);
- else
- fprintf(stderr,"%s: ", program);
-
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (error >= 0)
- fprintf(stderr, ": %s\n", errmsg(error));
- else
- fprintf(stderr, "\n");
- (void) fflush(stderr);
- return (SCMERR);
-}
-
-/*******************************************************
- *** I N T E G E R B Y T E - S W A P P I N G ***
- *******************************************************/
-
-union intchar {
- int ui;
- char uc[sizeof(int)];
-};
-
-int byteswap(in)
- int in;
-{
- union intchar x,y;
- int ix,iy;
-
- if (swapmode == 0)
- return (in);
- x.ui = in;
- iy = sizeof(int);
- for (ix=0; ix < sizeof(int); ix++) {
- --iy;
- y.uc[iy] = x.uc[ix];
- }
- return (y.ui);
-}
diff --git a/usr.bin/sup/src/scmio.c b/usr.bin/sup/src/scmio.c
deleted file mode 100644
index 84cbeccefa1..00000000000
--- a/usr.bin/sup/src/scmio.c
+++ /dev/null
@@ -1,821 +0,0 @@
-/* $OpenBSD: scmio.c,v 1.15 2003/11/08 19:17:29 jmc Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * SUP Communication Module for 4.3 BSD
- *
- * SUP COMMUNICATION MODULE SPECIFICATIONS:
- *
- * IN THIS MODULE:
- *
- * OUTPUT TO NETWORK
- *
- * MESSAGE START/END
- * writemsg (msg) start message
- * int msg; message type
- * writemend () end message and flush data to network
- *
- * MESSAGE DATA
- * writeint (i) write int
- * int i; integer to write
- * writestring (p) write string
- * char *p; string pointer
- * writefile (f) write open file
- * int f; open file descriptor
- *
- * COMPLETE MESSAGE (start, one data block, end)
- * writemnull (msg) write message with no data
- * int msg; message type
- * writemint (msg,i) write int message
- * int msg; message type
- * int i; integer to write
- * writemstr (msg,p) write string message
- * int msg; message type
- * char *p; string pointer
- *
- * INPUT FROM NETWORK
- * MESSAGE START/END
- * readflush () flush any unread data (close)
- * readmsg (msg) read specified message type
- * int msg; message type
- * readmend () read message end
- *
- * MESSAGE DATA
- * readskip () skip over one input data block
- * readint (i) read int
- * int *i; pointer to integer
- * readstring (p) read string
- * char **p; pointer to string pointer
- * readfile (f) read into open file
- * int f; open file descriptor
- *
- * COMPLETE MESSAGE (start, one data block, end)
- * readmnull (msg) read message with no data
- * int msg; message type
- * readmint (msg,i) read int message
- * int msg; message type
- * int *i; pointer to integer
- * readmstr (msg,p) read string message
- * int msg; message type
- * char **p; pointer to string pointer
- *
- * RETURN CODES
- * All routines normally return SCMOK. SCMERR may be returned
- * by any routine on abnormal (usually fatal) errors. An
- * unexpected MSGGOAWAY will result in SCMEOF being returned.
- *
- * COMMUNICATION PROTOCOL
- * Messages always alternate, with the first message after
- * connecting being sent by the client process.
- *
- * At the end of the conversation, the client process will
- * send a message to the server telling it to go away. Then,
- * both processes will close the network connection.
- *
- * Any time a process receives a message it does not expect,
- * the "readmsg" routine will send a MSGGOAWAY message and
- * return SCMEOF.
- *
- * Each message has this format:
- * ---------- ------------ ------------ ----------
- * |msg type| |count|data| |count|data| ... |ENDCOUNT|
- * ---------- ------------ ------------ ----------
- * size: int int var. int var. int
- *
- * All ints are assumed to be 32-bit quantities. A message
- * with no data simply has a message type followed by ENDCOUNT.
- *
- **********************************************************************
- * HISTORY
- * Revision 1.7 92/09/09 22:04:41 mrt
- * Removed the data encryption routines from here to netcrypt.c
- * [92/09/09 mrt]
- *
- * Revision 1.6 92/08/11 12:05:57 mrt
- * Brad's changes: Delinted,Added forward declarations of
- * static functions. Added copyright.
- * [92/07/24 mrt]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Found error in debugging code for readint().
- *
- * 01-Apr-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to readdata to "push" data back into the data buffer.
- * Added prereadcount() to return the message count size after
- * reading it and then pushing it back into the buffer. Clear
- * any encryption when a GOAWAY message is detected before reading
- * the reason string. [V5.19]
- *
- * 02-Oct-86 Rudy Nedved (ern) at Carnegie-Mellon University
- * Put a timeout on reading from the network.
- *
- * 25-May-86 Jonathan J. Chew (jjc) at Carnegie-Mellon University
- * Renamed "howmany" parameter to routines "encode" and "decode" from
- * to "count" to avoid conflict with 4.3BSD macro.
- *
- * 15-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added readflush() to flush any unread data from the input
- * buffer. Called by requestend() in scm.c module.
- *
- * 19-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added register variables to decode() for speedup. Added I/O
- * buffering to reduce the number or read/write system calls.
- * Removed readmfil/writemfil routines which were not used and were
- * not compatible with the other similarly defined routines anyway.
- *
- * 19-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created from scm.c I/O and crypt routines.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include "supcdefs.h"
-#include "supextern.h"
-#include "supmsg.h"
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-/* end of message */
-#define ENDCOUNT (-1) /* end of message marker */
-#define NULLCOUNT (-2) /* used for sending NULL pointer */
-
-#define RETRIES 15 /* # of times to retry io */
-#define FILEXFER 2048 /* block transfer size */
-#define XFERSIZE(count) ((count > FILEXFER) ? FILEXFER : count)
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-extern int netfile; /* network file descriptor */
-
-int scmdebug; /* scm debug flag */
-
-int cryptflag; /* whether to encrypt/decrypt data */
-char *cryptbuf; /* buffer for data encryption/decryption */
-
-extern char *goawayreason; /* reason for goaway message */
-
-struct buf {
- char b_data[FILEXFER]; /* buffered data */
- char *b_ptr; /* pointer to end of buffer */
- int b_cnt; /* number of bytes in buffer */
-} buffers[2];
-struct buf *bufptr; /* buffer pointer */
-
-static int writedata(int, char *);
-static int writeblock(int, char *);
-static int readdata(int, char *);
-static int readcount(int *);
-
-
-/***********************************************
- *** O U T P U T T O N E T W O R K ***
- ***********************************************/
-
-static int
-writedata (count, data) /* write raw data to network */
- int count;
- char *data;
-{
- int x, tries;
- struct buf *bp;
-
- if (bufptr) {
- if (bufptr->b_cnt + count <= FILEXFER) {
- memcpy(bufptr->b_ptr, data ,count);
- bufptr->b_cnt += count;
- bufptr->b_ptr += count;
- return (SCMOK);
- }
- bp = (bufptr == buffers) ? &buffers[1] : buffers;
- memcpy(bp->b_data, data, count);
- bp->b_cnt = count;
- bp->b_ptr = bp->b_data + count;
- data = bufptr->b_data;
- count = bufptr->b_cnt;
- bufptr->b_cnt = 0;
- bufptr->b_ptr = bufptr->b_data;
- bufptr = bp;
- }
- tries = 0;
- for (;;) {
- errno = 0;
- x = write(netfile, data, count);
- if (x > 0)
- break;
- if (errno)
- break;
- if (++tries > RETRIES)
- break;
- if (scmdebug > 0)
- logerr("SCM Retrying failed network write");
- }
- if (x <= 0) {
- if (errno == EPIPE)
- return (scmerr(-1, "Network write timed out"));
- if (errno)
- return (scmerr(errno, "Write error on network"));
- return (scmerr(-1, "Write retries failed"));
- }
- if (x != count)
- return (scmerr(-1, "Write error on network returned %d on write of %d", x, count));
- return (SCMOK);
-}
-
-static int
-writeblock (count, data) /* write data block */
- int count;
- char *data;
-{
- int x;
- int y = byteswap(count);
-
- x = writedata(sizeof(int), (char *)&y);
- if (x == SCMOK)
- x = writedata(count, data);
- return (x);
-}
-
-int
-writemsg(msg) /* write start of message */
- int msg;
-{
- int x;
-
- if (scmdebug > 1)
- loginfo("SCM Writing message %d", msg);
- if (bufptr)
- return (scmerr(-1, "Buffering already enabled"));
- bufptr = buffers;
- bufptr->b_ptr = bufptr->b_data;
- bufptr->b_cnt = 0;
- x = byteswap (msg);
- return (writedata(sizeof(int), (char *)&x));
-}
-
-int
-writemend() /* write end of message */
-{
- int count;
- char *data;
- int x;
-
- x = byteswap(ENDCOUNT);
- x = writedata(sizeof(int), (char *)&x);
- if (x != SCMOK)
- return (x);
- if (bufptr == NULL)
- return (scmerr(-1, "Buffering already disabled"));
- if (bufptr->b_cnt == 0) {
- bufptr = NULL;
- return (SCMOK);
- }
- data = bufptr->b_data;
- count = bufptr->b_cnt;
- bufptr = NULL;
- return (writedata(count, data));
-}
-
-int
-writeint(i) /* write int as data block */
- int i;
-{
- int x;
- if (scmdebug > 2)
- loginfo("SCM Writing integer %d", i);
- x = byteswap(i);
- return (writeblock(sizeof(int), (char *)&x));
-}
-
-int
-writestring(p) /* write string as data block */
- char *p;
-{
- int len, x;
-
- if (p == NULL) {
- int y = byteswap(NULLCOUNT);
- if (scmdebug > 2)
- loginfo("SCM Writing string NULL");
- return (writedata(sizeof(int), (char *)&y));
- }
- if (scmdebug > 2)
- loginfo("SCM Writing string %s", p);
- len = strlen(p);
- if (cryptflag) {
- x = getcryptbuf(len+1);
- if (x != SCMOK)
- return (x);
- encode(p, cryptbuf, len);
- p = cryptbuf;
- }
- return (writeblock(len, p));
-}
-
-int
-writefile(f) /* write open file as a data block */
-int f;
-{
- char buf[FILEXFER];
- int number, sum, filesize, x, y;
- struct stat statbuf;
-
- /*
- * XXX - st_size is really 64 bits but if we change things to support
- * files > 2gig we become incompatible with everyone else.
- */
- number = sum = 0;
- if (fstat(f, &statbuf) < 0)
- return (scmerr(errno, "Can't access open file for message"));
- filesize = statbuf.st_size;
- y = byteswap(filesize);
- x = writedata(sizeof(int), (char *)&y);
-
- if (cryptflag)
- x = getcryptbuf(FILEXFER);
-
- if (x == SCMOK) {
- sum = 0;
- do {
- number = read(f, buf, FILEXFER);
- if (number > 0) {
- if (cryptflag) {
- encode(buf, cryptbuf, number);
- x = writedata(number, cryptbuf);
- } else {
- x = writedata(number,buf);
- }
- sum += number;
- }
- } while (x == SCMOK && number > 0);
- }
- if (sum != filesize)
- return (scmerr(-1, "File size error on output message"));
- if (number < 0)
- return (scmerr(errno, "Read error on file output message"));
- return (x);
-}
-
-int
-writemnull(msg) /* write message with no data */
- int msg;
-{
- int x;
-
- x = writemsg(msg);
- if (x == SCMOK)
- x = writemend();
- return (x);
-}
-
-int
-writemint(msg, i) /* write message of one int */
- int msg, i;
-{
- int x;
-
- x = writemsg(msg);
- if (x == SCMOK)
- x = writeint(i);
- if (x == SCMOK)
- x = writemend();
- return (x);
-}
-
-int
-writemstr(msg, p) /* write message of one string */
- int msg;
- char *p;
-{
- int x;
-
- x = writemsg(msg);
- if (x == SCMOK)
- x = writestring(p);
- if (x == SCMOK)
- x = writemend();
- return (x);
-}
-
-/*************************************************
- *** I N P U T F R O M N E T W O R K ***
- *************************************************/
-
-static int
-readdata(count, data) /* read raw data from network */
- int count;
- char *data;
-{
- char *p;
- int n, m, x;
- int tries;
- struct timeval timout;
- static size_t rfdsize;
- static fd_set *readfds;
- static int bufcnt = 0;
- static char *bufptr;
- static char buffer[FILEXFER];
-
- if (count < 0) {
- if (bufptr + count < buffer)
- return (scmerr(-1, "No space in buffer %d", count));
- bufptr += count;
- bufcnt -= count;
- memcpy(bufptr, data, -count);
- return (SCMOK);
- }
- if (count == 0 && data == NULL) {
- bufcnt = 0;
- return (SCMOK);
- }
- if (count <= bufcnt) {
- memcpy(data, bufptr, count);
- bufptr += count;
- bufcnt -= count;
- return (SCMOK);
- }
- if (bufcnt > 0) {
- memcpy(data, bufptr, bufcnt);
- data += bufcnt;
- count -= bufcnt;
- }
- if (rfdsize < howmany(netfile+1, NFDBITS) * sizeof(fd_mask)) {
- rfdsize = howmany(netfile+1, NFDBITS) * sizeof(fd_mask);
- p = readfds ? realloc(readfds, rfdsize) : malloc(rfdsize);
- if (p == NULL) {
- free(readfds);
- rfdsize = 0;
- return (SCMERR);
- }
- readfds = (fd_set *) p;
- }
- memset(readfds, 0, rfdsize);
- bufptr = buffer;
- bufcnt = 0;
- timout.tv_usec = 0;
- timout.tv_sec = 2*60*60;
- p = buffer;
- n = FILEXFER;
- m = count;
- while (m > 0) {
- tries = 0;
- for (;;) {
- FD_SET(netfile, readfds);
- if (select(netfile+1, readfds, NULL, NULL, &timout)
- == -1) {
- if (errno == EINTR || errno == EAGAIN)
- continue;
- return (scmerr(errno, "Select error on network"));
- }
- errno = 0;
- if (FD_ISSET(netfile, readfds))
- x = read(netfile, p, n);
- else
- return (scmerr(-1, "Timeout on network input"));
- if (x > 0)
- break;
- if (x == 0)
- return (scmerr(-1, "Premature EOF on network input"));
- if (errno)
- break;
- if (++tries > RETRIES)
- break;
- if (scmdebug > 0)
- loginfo("SCM Retrying failed network read");
- }
- if (x < 0) {
- if (errno)
- return (scmerr(errno, "Read error on network"));
- return (scmerr(-1, "Read retries failed"));
- }
- p += x;
- n -= x;
- m -= x;
- bufcnt += x;
- }
- memcpy(data, bufptr, count);
- bufptr += count;
- bufcnt -= count;
- return (SCMOK);
-}
-
-static int
-readcount(count) /* read count of data block */
- int *count;
-{
- int x, y;
-
- x = readdata(sizeof(int), (char *)&y);
- if (x != SCMOK)
- return (x);
- *count = byteswap(y);
- return (SCMOK);
-}
-
-int
-prereadcount(count) /* preread count of data block */
- int *count;
-{
- int x, y;
-
- x = readdata(sizeof(int), (char *)&y);
- if (x != SCMOK)
- return (x);
- x = readdata(- ((int)(sizeof(int))), (char *)&y);
- if (x != SCMOK)
- return (x);
- *count = byteswap(y);
- return (SCMOK);
-}
-
-int
-readflush()
-{
-
- return (readdata(0, NULL));
-}
-
-int
-readmsg(msg) /* read header for expected message */
- int msg; /* if message is unexpected, send back SCMHUH */
-{
- int x;
- int m;
-
- if (scmdebug > 1)
- loginfo("SCM Reading message %d", msg);
- x = readdata(sizeof(int), (char *)&m); /* msg type */
- if (x != SCMOK)
- return (x);
- m = byteswap(m);
- if (m == msg)
- return (x);
-
- /* check for MSGGOAWAY in case he noticed problems first */
- if (m != MSGGOAWAY)
- return (scmerr(-1, "Received unexpected message %d", m));
- (void) netcrypt(NULL);
- (void) readstring(&goawayreason);
- (void) readmend();
- if (goawayreason == NULL)
- return (SCMEOF);
- logerr("SCM GOAWAY %s", goawayreason);
- return (SCMEOF);
-}
-
-int
-readmend()
-{
- int x, y;
-
- x = readdata(sizeof(int), (char *)&y);
- y = byteswap(y);
- if (x == SCMOK && y != ENDCOUNT)
- return (scmerr(-1, "Error reading end of message"));
- return (x);
-}
-
-int
-readskip() /* skip over one input block */
-{
- int x;
- int n;
- char buf[FILEXFER];
-
- x = readcount(&n);
- if (x != SCMOK)
- return (x);
- if (n < 0)
- return (scmerr(-1, "Invalid message count %d", n));
- while (x == SCMOK && n > 0) {
- x = readdata(XFERSIZE(n), buf);
- n -= XFERSIZE(n);
- }
- return (x);
-}
-
-int readint(buf) /* read int data block */
- int *buf;
-{
- int x;
- int y;
-
- x = readcount(&y);
- if (x != SCMOK)
- return (x);
- if (y < 0)
- return (scmerr(-1, "Invalid message count %d",y));
- if (y != sizeof(int))
- return (scmerr(-1, "Size error for int message is %d", y));
- x = readdata(sizeof(int), (char *)&y);
- (*buf) = byteswap(y);
- if (scmdebug > 2)
- loginfo("SCM Reading integer %d", *buf);
- return (x);
-}
-
-int readstring(buf) /* read string data block */
- char **buf;
-{
- int x;
- int count;
- char *p;
-
- x = readcount(&count);
- if (x != SCMOK)
- return (x);
- if (count == NULLCOUNT) {
- if (scmdebug > 2)
- loginfo("SCM Reading string NULL");
- *buf = NULL;
- return (SCMOK);
- }
- if (count < 0)
- return (scmerr(-1, "Invalid message count %d", count));
- if (scmdebug > 3)
- loginfo("SCM Reading string count %d", count);
- if ((p = (char *)malloc(count + 1)) == NULL)
- return (scmerr(-1, "Can't malloc %d bytes for string", count));
- if (cryptflag) {
- x = getcryptbuf(count+1);
- if (x == SCMOK)
- x = readdata(count, cryptbuf);
- if (x != SCMOK) {
- free(p);
- return (x);
- }
- if (scmdebug > 3)
- printf("SCM Reading encrypted string %s\n", cryptbuf);
- decode(cryptbuf, p, count);
- } else {
- x = readdata(count,p);
- if (x != SCMOK) {
- free(p);
- return (x);
- }
- }
- p[count] = 0; /* NULL at end of string */
- *buf = p;
- if (scmdebug > 2)
- loginfo("SCM Reading string %s", *buf);
- return (SCMOK);
-}
-
-int
-readfile(f) /* read data block into open file */
- int f;
-{
- int x;
- int count;
- char buf[FILEXFER];
-
- if (cryptflag) {
- x = getcryptbuf(FILEXFER);
- if (x != SCMOK)
- return (x);
- }
- x = readcount(&count);
- if (x != SCMOK)
- return (x);
- if (count < 0)
- return (scmerr(-1, "Invalid message count %d", count));
- while (x == SCMOK && count > 0) {
- if (cryptflag) {
- x = readdata(XFERSIZE(count), cryptbuf);
- if (x == SCMOK)
- decode(cryptbuf, buf, XFERSIZE(count));
- } else
- x = readdata(XFERSIZE(count), buf);
- if (x == SCMOK) {
- (void) write(f, buf, XFERSIZE(count));
- count -= XFERSIZE(count);
- }
- }
- return (x);
-}
-
-int
-readmnull(msg) /* read null message */
- int msg;
-{
- int x;
-
- x = readmsg(msg);
- if (x == SCMOK)
- x = readmend();
- return (x);
-}
-
-int
-readmint(msg, buf) /* read int message */
- int msg, *buf;
-{
- int x;
-
- x = readmsg(msg);
- if (x == SCMOK)
- x = readint(buf);
- if (x == SCMOK)
- x = readmend();
- return (x);
-}
-
-int readmstr(msg, buf) /* read string message */
- int msg;
- char **buf;
-{
- int x;
-
- x = readmsg(msg);
- if (x == SCMOK)
- x = readstring(buf);
- if (x == SCMOK)
- x = readmend();
- return (x);
-}
-
-/**********************************
- *** C R O S S P A T C H ***
- **********************************/
-
-void
-crosspatch()
-{
- fd_set *readfds;
- size_t rfdsize;
- int c;
- char buf[STRINGLENGTH];
-
- rfdsize = howmany(netfile+1, NFDBITS) * sizeof(fd_mask);
- if ((readfds = (fd_set *) malloc(rfdsize)) == NULL)
- return;
- for (;;) {
- memset(readfds, 0, rfdsize);
- FD_SET(0, readfds);
- FD_SET(netfile, readfds);
- if ((c = select(netfile+1, readfds, NULL, NULL, NULL)) < 1) {
- if (c == -1) {
- if (errno == EINTR || errno == EAGAIN)
- continue;
- }
- sleep (5);
- continue;
- }
- if (FD_ISSET(netfile, readfds)) {
- c = read(netfile, buf, sizeof (buf));
- if (c < 0 && errno == EWOULDBLOCK)
- c = 0;
- else {
- if (c <= 0)
- break;
- (void) write(1, buf, c);
- }
- }
- if (FD_ISSET(0, readfds)) {
- c = read(0, buf, sizeof (buf));
- if (c < 0 && errno == EWOULDBLOCK)
- c = 0;
- else {
- if (c <= 0)
- break;
- (void) write(netfile, buf, c);
- }
- }
- }
- free(readfds);
-}
diff --git a/usr.bin/sup/src/skipto.c b/usr.bin/sup/src/skipto.c
deleted file mode 100644
index 31f2d7ade71..00000000000
--- a/usr.bin/sup/src/skipto.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $NetBSD: skipto.c,v 1.4 1997/06/17 21:38:25 christos Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/************************************************************************
- * skipover and skipto -- skip over characters in string
- *
- * Usage: p = skipto (string,charset);
- * p = skipover (string,charset);
- *
- * char *p,*charset,*string;
- *
- * Skipto returns a pointer to the first character in string which
- * is in the string charset; it "skips until" a character in charset.
- * Skipover returns a pointer to the first character in string which
- * is not in the string charset; it "skips over" characters in charset.
- ************************************************************************
- * HISTORY
- * 26-Jun-81 David Smith (drs) at Carnegie-Mellon University
- * Skipover, skipto rewritten to avoid inner loop at expense of space.
- *
- * 20-Nov-79 Steven Shafer (sas) at Carnegie-Mellon University
- * Skipover, skipto adapted for VAX from skip() and skipx() on the PDP-11
- * (from Ken Greer). The names are more mnemonic.
- *
- * Sindex adapted for VAX from indexs() on the PDP-11 (thanks to Ralph
- * Guggenheim). The name has changed to be more like the index()
- * and rindex() functions from Bell Labs; the return value (pointer
- * rather than integer) has changed partly for the same reason,
- * and partly due to popular usage of this function.
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-static char tab[256];
-
-char *
-skipto(string, charset)
- char *string, *charset;
-{
- char *setp, *strp;
-
- tab[0] = 1; /* Stop on a null, too. */
- for (setp = charset; *setp; setp++)
- tab[(unsigned char) *setp] = 1;
- for (strp = string; tab[(unsigned char) *strp] == 0; strp++)
- ;
- for (setp = charset; *setp; setp++)
- tab[(unsigned char) *setp] = 0;
- return (strp);
-}
-
-char *
-skipover(string, charset)
- char *string, *charset;
-{
- char *setp, *strp;
-
- tab[0] = 0; /* Do not skip over nulls. */
- for (setp = charset; *setp; setp++)
- tab[(unsigned char) *setp] = 1;
- for (strp = string; tab[(unsigned char) *strp]; strp++)
- ;
- for (setp = charset; *setp; setp++)
- tab[(unsigned char) *setp] = 0;
- return (strp);
-}
diff --git a/usr.bin/sup/src/snprintf.c b/usr.bin/sup/src/snprintf.c
deleted file mode 100644
index 79efc01371e..00000000000
--- a/usr.bin/sup/src/snprintf.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Chris Torek.
- *
- * 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: snprintf.c,v 1.3 2003/06/03 02:56:17 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#ifdef _IOSTRG
-#define STRFLAG (_IOSTRG|_IOWRT) /* no _IOWRT: avoid stdio bug */
-#else
-#define STRFLAG (_IOREAD) /* XXX: Assume svr4 stdio */
-#endif
-
-#ifdef NEED_SNPRINTF
-snprintf(char *str, size_t n, char const *fmt, ...)
-{
- int ret;
- va_list ap;
- FILE f;
-
- if ((int)n < 1)
- return (EOF);
- va_start(ap, fmt);
- f._flag = STRFLAG;
- f._base = f._ptr = str;
- f._cnt = n-1;
- f._file = -1;
- _doprnt(fmt, ap, &f);
- f._cnt++;
- putc('\0', &f);
- if (f._cnt<0)
- f._cnt = 0;
- va_end(ap);
- return(n-f._cnt-1);
-}
-#endif /* NEED_SNPRINTF */
diff --git a/usr.bin/sup/src/stree.c b/usr.bin/sup/src/stree.c
deleted file mode 100644
index 25019fa7672..00000000000
--- a/usr.bin/sup/src/stree.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* $OpenBSD: stree.c,v 1.11 2009/05/09 12:02:17 chl Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * stree.c -- SUP Tree Routines
- *
- **********************************************************************
- * HISTORY
- * Revision 1.4 92/08/11 12:06:32 mrt
- * Added copyright. Delinted
- * [92/08/10 mrt]
- *
- *
- * Revision 1.3 89/08/15 15:30:57 bww
- * Changed code in Tlookup to Tsearch for each subpart of path.
- * Added indent formatting code to Tprint.
- * From "[89/06/24 gm0w]" at CMU.
- * [89/08/15 bww]
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to please lint.
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to initialize new fields. Added Tfree routine.
- *
- * 27-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <c.h>
-#include <sys/param.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-#define Static static /* comment for debugging */
-
-Static TREE *Tmake(char *);
-Static TREE *Trotll(TREE *, TREE *);
-Static TREE *Trotlh(TREE *, TREE *);
-Static TREE *Trothl(TREE *, TREE *);
-Static TREE *Trothh(TREE *, TREE *);
-Static void Tbalance(TREE **);
-Static TREE *Tinsertavl(TREE **, char *, int, int *);
-Static int Tsubprocess(TREE *, int, int (*f )(TREE *, void *), void *);
-#ifdef DEBUG
-Static int Tprintone(TREE *, void *);
-#endif
-
-
-/*************************************************************
- *** T R E E P R O C E S S I N G R O U T I N E S ***
- *************************************************************/
-
-void
-Tfree(t)
- TREE **t;
-{
- if (*t == NULL)
- return;
- Tfree(&((*t)->Tlink));
- Tfree(&((*t)->Texec));
- Tfree(&((*t)->Tlo));
- Tfree(&((*t)->Thi));
- if ((*t)->Tname)
- free((*t)->Tname);
- if ((*t)->Tuser)
- free((*t)->Tuser);
- if ((*t)->Tgroup)
- free((*t)->Tgroup);
- free(*t);
- *t = NULL;
-}
-
-Static TREE *
-Tmake(p)
- char *p;
-{
- TREE *t;
-
- t = (TREE *) malloc(sizeof(TREE));
- if (t != NULL) {
- t->Tname = (p == NULL) ? NULL : strdup(p);
- t->Tflags = 0;
- t->Tuid = 0;
- t->Tgid = 0;
- t->Tuser = NULL;
- t->Tgroup = NULL;
- t->Tmode = 0;
- t->Tctime = 0;
- t->Tmtime = 0;
- t->Tlink = NULL;
- t->Texec = NULL;
- t->Tbf = 0;
- t->Tlo = NULL;
- t->Thi = NULL;
- }
- return (t);
-}
-
-Static TREE *
-Trotll(tp, tl)
- TREE *tp, *tl;
-{
-
- tp->Tlo = tl->Thi;
- tl->Thi = tp;
- tp->Tbf = tl->Tbf = 0;
- return(tl);
-}
-
-Static TREE *
-Trotlh (tp,tl)
- TREE *tp, *tl;
-{
- TREE *th;
-
- th = tl->Thi;
- tp->Tlo = th->Thi;
- tl->Thi = th->Tlo;
- th->Thi = tp;
- th->Tlo = tl;
- tp->Tbf = tl->Tbf = 0;
- if (th->Tbf == 1)
- tp->Tbf = -1;
- else if (th->Tbf == -1)
- tl->Tbf = 1;
- th->Tbf = 0;
- return (th);
-}
-
-Static TREE *
-Trothl(tp, th)
- TREE *tp, *th;
-{
- TREE *tl;
-
- tl = th->Tlo;
- tp->Thi = tl->Tlo;
- th->Tlo = tl->Thi;
- tl->Tlo = tp;
- tl->Thi = th;
- tp->Tbf = th->Tbf = 0;
- if (tl->Tbf == -1)
- tp->Tbf = 1;
- else if (tl->Tbf == 1)
- th->Tbf = -1;
- tl->Tbf = 0;
- return (tl);
-}
-
-Static TREE *
-Trothh(tp, th)
- TREE *tp, *th;
-{
-
- tp->Thi = th->Tlo;
- th->Tlo = tp;
- tp->Tbf = th->Tbf = 0;
- return (th);
-}
-
-Static void
-Tbalance(t)
- TREE **t;
-{
-
- if ((*t)->Tbf < 2 && (*t)->Tbf > -2)
- return;
- if ((*t)->Tbf > 0) {
- if ((*t)->Tlo->Tbf > 0)
- *t = Trotll(*t, (*t)->Tlo);
- else
- *t = Trotlh(*t, (*t)->Tlo);
- } else {
- if ((*t)->Thi->Tbf > 0)
- *t = Trothl(*t, (*t)->Thi);
- else
- *t = Trothh(*t, (*t)->Thi);
- }
-}
-
-Static TREE *
-Tinsertavl(t, p, find, dh)
- TREE **t;
- char *p;
- int find;
- int *dh;
-{
- TREE *newt;
- int cmp;
- int deltah;
-
- if (*t == NULL) {
- if ((*t = Tmake(p)) != NULL)
- *dh = 1;
- return (*t);
- }
- if ((cmp = strcmp(p, (*t)->Tname)) == 0) {
- if (!find)
- return (NULL); /* node already exists */
- *dh = 0;
- return (*t);
- } else if (cmp < 0) {
- if ((newt = Tinsertavl(&((*t)->Tlo), p, find, &deltah)) == NULL)
- return (NULL);
- (*t)->Tbf += deltah;
- } else {
- if ((newt = Tinsertavl(&((*t)->Thi), p, find, &deltah)) == NULL)
- return (NULL);
- (*t)->Tbf -= deltah;
- }
- Tbalance(t);
- if ((*t)->Tbf == 0)
- deltah = 0;
- *dh = deltah;
- return (newt);
-}
-
-TREE *
-Tinsert(t, p, find)
- TREE **t;
- char *p;
- int find;
-{
- int deltah;
-
- if (p != NULL && p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/')
- p++;
- if (*p == 0)
- p = ".";
- }
- return (Tinsertavl(t, p, find, &deltah));
-}
-
-TREE *
-Tsearch(t, p)
- TREE *t;
- char *p;
-{
- TREE *x;
- int cmp;
-
- x = t;
- while (x) {
- cmp = strcmp(p, x->Tname);
- if (cmp == 0)
- return (x);
- if (cmp < 0)
- x = x->Tlo;
- else
- x = x->Thi;
- }
- return (NULL);
-}
-
-TREE *
-Tlookup (t, p)
- TREE *t;
- char *p;
-{
- TREE *x;
- char buf[MAXPATHLEN];
-
- if (p == NULL)
- return (NULL);
- if (p[0] == '.' && p[1] == '/') {
- p += 2;
- while (*p == '/')
- p++;
- if (*p == 0)
- p = ".";
- }
- if ((x = Tsearch(t, p)) != NULL)
- return (x);
- if (*p != '/' && (x = Tsearch(t, ".")) != NULL)
- return (x);
- (void) strlcpy(buf, p, sizeof(buf));
- while ((p = strrchr(buf, '/')) != NULL) {
- while (p >= buf && *(p-1) == '/')
- p--;
- if (p == buf)
- *(p+1) = '\0';
- else
- *p = '\0';
- if ((x = Tsearch(t, buf)) != NULL)
- return (x);
- if (p == buf)
- break;
- }
- return (NULL);
-}
-
-Static int process_level;
-
-Static int
-Tsubprocess (t, reverse, f, argp)
- TREE *t;
- int reverse;
- int (*f)(TREE *, void *);
- void *argp;
-{
- int x = SCMOK;
-
- process_level++;
- if (reverse ? t->Thi : t->Tlo)
- x = Tsubprocess(reverse ? t->Thi : t->Tlo, reverse, f, argp);
- if (x == SCMOK) {
- x = (*f)(t, argp);
- if (x == SCMOK) {
- if (reverse ? t->Tlo : t->Thi)
- x = Tsubprocess (reverse ? t->Tlo : t->Thi,
- reverse, f, argp);
- }
- }
- process_level--;
- return (x);
-}
-
-/* VARARGS2 */
-int
-Trprocess(t, f, args)
- TREE *t;
- int (*f)(TREE *, void *);
- void *args;
-{
- if (t == NULL)
- return (SCMOK);
- process_level = 0;
- return (Tsubprocess(t, TRUE, f, args));
-}
-
-/* VARARGS2 */
-int
-Tprocess(t, f, args)
- TREE *t;
- int (*f)(TREE *, void *);
- void *args;
-{
- if (t == NULL)
- return (SCMOK);
- process_level = 0;
- return (Tsubprocess(t, FALSE, f, args));
-}
-
-#if DEBUG
-Static int
-Tprintone(t, v)
- TREE *t;
- void *v;
-{
- int i;
- for (i = 0; i < (process_level*2); i++)
- (void) putchar(' ');
- printf("Node at %p name '%s' flags %o hi %p lo %p\n",
- t, t->Tname, t->Tflags, t->Thi, t->Tlo);
- return (SCMOK);
-}
-
-void
-Tprint(t, p) /* print tree -- for debugging */
- TREE *t;
- char *p;
-{
-
- printf("%s\n",p);
- (void) Tprocess(t,Tprintone, NULL);
- printf("End of tree\n");
- (void) fflush(stdout);
-}
-#endif
diff --git a/usr.bin/sup/src/sup.1 b/usr.bin/sup/src/sup.1
deleted file mode 100644
index edaf19b25ae..00000000000
--- a/usr.bin/sup/src/sup.1
+++ /dev/null
@@ -1,859 +0,0 @@
-.\" $OpenBSD: sup.1,v 1.16 2008/01/03 08:13:09 chl Exp $
-.\"
-.\" Copyright (c) 1992 Carnegie Mellon University
-.\" All Rights Reserved.
-.\"
-.\" Permission to use, copy, modify and distribute this software and its
-.\" documentation is hereby granted, provided that both the copyright
-.\" notice and this permission notice appear in all copies of the
-.\" software, derivative works or modified versions, and any portions
-.\" thereof, and that both notices appear in supporting documentation.
-.\"
-.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
-.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
-.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
-.\"
-.\" Carnegie Mellon requests users of this software to return to
-.\"
-.\" Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
-.\" School of Computer Science
-.\" Carnegie Mellon University
-.\" Pittsburgh PA 15213-3890
-.\"
-.\" any improvements or extensions that they make and grant Carnegie Mellon
-.\" the rights to redistribute these changes.
-.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" HISTORY
-.\" Revision 1.4 92/08/11 12:08:40 mrt
-.\" Add description of releases and use-rel-suffix
-.\" [92/07/31 mrt]
-.\"
-.\" Revision 1.3 92/02/08 18:24:31 mja
-.\" Added description of -k and -K switches and "keep" option.
-.\" [92/01/17 vdelvecc]
-.\"
-.\" 10-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
-.\" Replaced reference to /usr/cmu with /usr/cs.
-.\"
-.\" 29-Mar-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
-.\" Updated manual entry to version 5.14 of sup.
-.\"
-.\" 14-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
-.\" Updated manual entry to version 5.7 of sup.
-.\"
-.\" 04-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
-.\" Created.
-.\"
-.TH SUP 1 02/08/92
-.CM 4
-.SH "NAME"
-sup \- software upgrade protocol
-.SH "SYNOPSIS"
-\fBsup\fR [ \fIflags\fR ] [ \fIsupfile\fR ] [ \fIcollection\fR ...]
-.SH "DESCRIPTION"
-.I Sup
-is a program used for upgrading collections of files from other machines
-to your machine. You execute
-.IR sup ,
-the
-.I client
-program, which talks over the network using IP/TCP to a
-.I file server
-process.
-The file server process cooperates with
-.I sup
-to determine which files of the collection need to be upgraded on
-your machine.
-
-Sup collections can have multiple releases. One use for such releases is
-to provide different versions of the same files. At CMU, for example,
-system binaries have alpha, beta and default release corresponding to
-different staging levels of the software. We also use release names
-default and minimal to provide complete releases or subset releases.
-In both of these cases, it only makes sense to sup one release of the
-collections. Releases have also been used in private or external sups to
-provide subsets of collections where it makes sense to pick up several
-of the releases. For example the Mach 3.0 kernel sources has a default
-release of machine independent sources and separate releases of
-machine dependent sources for each supported platform.
-
-In performing an upgrade, the file server constructs a list of
-files included in the specified release of the collection. The list is sent to your machine,
-which determines which files are needed. Those files are then sent
-from the file server.
-It will be most useful to run
-.I sup
-as a daemon each night so you will continually have the latest version of the
-files in the needed collections.
-
-The only required argument to
-.I sup
-is the name of a supfile. It must either be given explicitly on the command
-line, or the
-.B -s
-flag must be specified. If the
-.B -s
-flag is given, the system supfile will be used and a supfile command argument
-should not be specified. The list of collections is optional and if specified
-will be the only collections upgraded. The following flags affect all
-collections specified:
-.TP
-.B -s
-As described above.
-.TP
-.B -t
-When this flag is given,
-.I sup
-will print the time
-that each collection was last upgraded, rather than
-performing actual upgrades.
-.TP
-.B -u
-When this flag is given,
-.I sup
-will not try to restore the user access and modified times of files in
-the collections from the server.
-.TP
-.B -S
-Operate silently printing messages only on errors.
-.TP
-.B -N
-.I Sup
-will trace network messages sent and received that implement the
-.I sup
-network protocol.
-.TP
-.B -P
-Sup will use a set of non-privileged network
-ports reserved for debugging purposes.
-.i0
-.DT
-.PP
-
-The remaining flags affect all collections unless an explicit list
-of collections are given with the flags. Multiple flags may be
-specified together that affect the same collections. For the sake
-of convenience, any flags that always affect all collections can be
-specified with flags that affect only some collections. For
-example,
-.B sup -sde=coll1,coll2
-would perform a system upgrade,
-and the first two collections would allow both file deletions and
-command executions. Note that this is not the same command as
-.B sup -sde=coll1 coll2,
-which would perform a system upgrade of
-just the coll2 collection and would ignore the flags given for the
-coll1 collection.
-.TP
-.B -a
-All files in the collection will be copied from
-the repository, regardless of their status on the
-current machine. Because of this, it is a very
-expensive operation and should only be done for
-small collections if data corruption is suspected
-and been confirmed. In most cases, the
-.B -o
-flag should be sufficient.
-.TP
-.B -b
-If the
-.B -b
-flag if given, or the
-.B backup
-supfile
-option is specified, the contents of regular files
-on the local system will be saved before they are
-overwritten with new data. The file collection maintainer
-can designate specific files to be
-worthy of backing up whenever they are upgraded.
-However, such
-backup will only take place if you specify this flag or the
-.B backup
-option to allow
-backups for a file collection on your machine.
-The backup mechanism
-will create a copy of the current version of a file immediately
-before a new copy is received from the file server; the copy is
-given the same name as the original file but is put into a directory
-called
-.B
-BACKUP
-within the directory containing the original file.
-For example,
-.B
-/usr/sas/src/foo.c
-would have a backup copy called
-.B
-/usr/sas/src/BACKUP/foo.c.
-There is no provision for automatically maintaining multiple old
-versions of files; you would have to do this yourself.
-.TP
-.B -B
-The
-.B -B
-flag overrides and disables the
-.B -b
-flag and the
-.B backup
-supfile option.
-.TP
-.B -d
-Files that are no longer in the collection on the
-repository will be deleted if present on the local
-machine and were put there by a previous sup.
-This may also be specified in a supfile with the
-.B delete
-option.
-.TP
-.B -D
-The
-.B -D
-flag overrides and disables the
-.B -d
-flag and the
-.B delete
-supfile option.
-.TP
-.B -e
-Sup will execute commands sent from the repository
-that should be run when a file is upgraded. If
-the
-.B -e
-flag is omitted, Sup will print a message
-that specifies the command to execute. This may
-also be specified in a supfile with the
-.B execute
-option.
-.TP
-.B -E
-The
-.B -E
-flag overrides and disables the
-.B -e
-flag and the
-.B execute
-supfile option.
-.TP
-.B -f
-A
-.I list-only
-upgrade will be performed. Messages
-will be printed that indicate what would happen if
-an actual upgrade were done.
-.TP
-.B -k
-.I Sup
-will check the modification times of
-files on the local disk before updating them. Only files which are
-newer on the repository than on the local disk will be updated;
-files that are newer on the local disk will be kept as they are.
-This may also be specified in a supfile with the
-.B keep
-option.
-.TP
-.B -K
-The
-.B -K
-flag overrides and disables the
-.B -k
-flag and the
-.B keep
-supfile option.
-.TP
-.B -l
-Normally,
-.I sup
-will not upgrade a collection if the
-repository is on the same machine. This allows
-users to run upgrades on all machines without
-having to make special checks for the repository
-machine. If the
-.B -l
-flag is specified, collections
-will be upgraded even if the repository is local.
-.TP
-.B -m
-Normally,
-.I sup
-used standard output for messages.
-If the
-.B -m
-flag if given,
-.I sup
-will send mail to the user running
-.IR sup ,
-or a user specified with the
-.B notify
-supfile option, that contains messages
-printed by
-.IR sup .
-.TP
-.B -o
-.I Sup
-will normally only upgrade files that have
-changed on the repository since the last time an
-upgrade was performed. That is, if the file in the
-repository is newer than the date stored in the
-.I when
-file on the client. The
-.B -o
-flag, or the
-.B old
-supfile option, will cause
-.I sup
-to check all files
-in the collection for changes instead of just the
-new ones.
-.TP
-.B -O
-The
-.B -O
-flag overrides and disables the
-.B -o
-flag and the
-.B old
-supfile option.
-.TP
-.B -z
-Normally sup transfers files directly without any
-other processing, but with the
-.B -z
-flag, or the
-.B compress
-supfile option, sup will compress the file
-before sending it across the network and
-uncompress it and restore all the correct
-file attributes at the receiving end.
-.TP
-.B -Z
-The
-.B -Z
-flag overrides and disables the
-.B -z
-flag and the
-.B compress
-supfile option.
-.TP
-.B -V
-Normally,
-.I sup
-will only print messages if there
-are problems. This flag causes
-.I sup
-to also print
-messages during normal progress showing what
-.I sup
-is doing.
-.TP
-.B -v
-With this option
-.I sup
-only shows the updated files and created directories.
-.i0
-.DT
-.PP
-.SH "SETTING UP UPGRADES"
-Each file collection to be upgraded must have a
-.I base directory
-which contains a subdirectory called
-.B sup
-that will be used by the
-.I sup
-program; it will be created automatically if you do not create it.
-.I Sup
-will put subdirectories and files into this directory as needed.
-
-.I Sup
-will look for a subdirectory with the same name as the
-collection within the
-.B sup
-subdirectory of the
-.I base directory.
-If it exists it may contain any of the following files:
-.TP
-.B when.<rel-suffix>
-This file is automatically updated by
-.I sup
-when a collection is successfully upgraded and contains the
-time that the file server, or possibly
-.IR supscan ,
-created the list of files in the upgrade list.
-.I Sup
-will send this time to the file server for generating the list
-of files that have been changed on the repository machine.
-.TP
-.B refuse
-This file contains a list of files and directories, one per line, that
-the client is not interested in that should not be upgraded.
-.TP
-.B lock
-This file is used by
-.I sup
-to lock a collection while it is being upgraded.
-.I Sup
-will get exclusive access to the lock file using
-.IR flock (2),
-preventing more than one
-.I sup
-from upgrading the same collection at the same time.
-.TP
-.B last.<rel-suffix>
-This file contains a list of files and directories, one per line, that
-have been upgraded by
-.I sup
-in the past. This information is used when the
-.B delete
-option, or the
-.B -d
-flag is used to locate files previously upgraded that are no longer
-in the collection that should be deleted.
-.i0
-.DT
-.PP
-
-Each file collection must also be described in one or more supfiles.
-When
-.I sup
-is executed, it reads the specified supfile to determine what file
-collections and releases to upgrade.
-Each collection-release set is described by a single
-line of text in the supfile; this line must contain the name of the
-collection, and possibly one or more options separated by spaces.
-The options are:
-.TP
-.BI release= releasename
-If a collection contains multiple releases, you need to specify which
-release you want. You can only specify one release per line, so
-if you want multiple releases from the same collections, you will need
-to specify the collection more than once. In this case, you should use
-the
-.I use-rel-suffix
-option in the supfile
-to keep the last and when files for the two releases separate.
-.TP
-.BI base= directory
-The usual default name of the base directory for a collection is
-described below (see FILES); if you want to specify another
-directory name, use this option specifying the desired
-directory.
-.TP
-.BI prefix= directory
-Each collection may also have an associated
-.I prefix directory
-which is used instead of the base directory to specify in what
-directory files within the collection will be placed.
-.TP
-.BI host= hostname
-.br
-.ns
-.TP
-.BI hostbase= directory
-.br
-.I System
-collections are supported by the system maintainers, and
-.I sup
-will automatically find out the name of the host machine and
-base directory on that machine.
-However, you can also upgrade
-.I private
-collections; you simply specify with these options
-the
-.I hostname
-of the machine containing the files and the
-.I directory
-used as a base directory for the file server on that machine.
-Details of setting up a file collection are given in the section
-below.
-.TP
-.BI login= accountid
-.br
-.ns
-.TP
-.BI password= password
-.br
-.br
-.ns
-.TP
-.BI crypt= key
-.br
-Files on the file server may be protected, and network transmissions
-may be encrypted.
-This prevents unauthorized access to files via
-.IR sup .
-When files are not accessible to the default account (e.g.,
-the
-.B anon
-anonymous account), you can specify an alternative
-.I accountid
-and
-.I password
-for the file server to use on the repository host.
-Network
-transmission of the password will be always encrypted.
-You can
-also have the actual file data encrypted by specifying a
-.IR key ;
-the file collection on the repository must specify the same key
-or else
-.I sup
-will not be able to upgrade files from that collection.
-In this case, the default account used by the file server on the
-repository machine will be the owner of the encryption key
-file (see FILES) rather than the
-.B anon
-anonymous account.
-.TP
-.BI notify= address
-If you use the
-.B
--m
-option to receive log messages by mail, you can have the mail
-sent to different user, possibly on another host, than the user
-running the sup program.
-Messages will be sent to the specified
-.IR address ,
-which can be any legal netmail address.
-In particular, a
-project maintainer can be designated to receive mail for that
-project's file collection from all users running
-.I sup
-to upgrade that collection.
-.TP
-.B backup
-As described above under the
-.B -b
-flag.
-.TP
-.B delete
-As described above under the
-.B -d
-flag.
-.TP
-.B execute
-As described above under the
-.B -e
-flag.
-.TP
-.B keep
-As described above under the
-.B -k
-flag.
-.TP
-.B old
-As described above under the
-.B -o
-flag.
-.TP
-.B use-rel-suffix
-Causes the release name to be used as a suffix to the
-.I last
-and
-.I when
-files. This is necessary whenever you are supping more than one
-release in the same collection.
-.i0
-.DT
-.PP
-.SH "PREPARING A FILE COLLECTION REPOSITORY"
-A set of files residing on a repository must be prepared before
-.I sup
-client processes can upgrade those files.
-The collection must
-be given a
-.I name
-and a
-.I base directory.
-If it is a private collection, client users
-must be told the name of the collection, repository host, and
-base directory;
-these will be specified in the supfile via the
-.B host
-and
-.B hostbase
-options.
-For a system-maintained file collection, entries must be
-placed into the host list file and directory list file as described
-in
-.IR supservers (8).
-
-Within the base directory, a subdirectory must be created called
-.B sup .
-Within this directory there must be a subdirectory for each
-collection using that base directory, whose name is the name of the
-collection; within each of these directories will be a
-list file and possibly a prefix file, a host file, an encryption key
-file, a log file and
-a scan file.
-The filenames are listed under FILES below.
-.TP
-.B prefix
-Normally, all files in the collection are relative to the base directory.
-This file contains a single line which is the name of a directory to be
-used in place of the base directory for file references.
-.TP
-.B host
-Normally,
-all remote host machines are allowed access to a file collection.
-If you wish to restrict access to specific remote hosts for this
-collection,
-put each allowed hostname on a
-separate line of text in this file.
-If a host has more than one name, only one of its names needs to be
-listed.
-The name
-.B LOCAL
-can be used to grant access to all hosts on the local
-network. The host name may be a numeric network address
-or a network name. If a crypt appears on the same line as
-the host name, that crypt will be used for that host. Otherwise,
-the crypt appearing in the
-.I crypt
-file, if any will be used.
-.TP
-.B crypt
-If you wish to use the
-.I sup
-data encryption mechanism, create an encryption file containing,
-on a single line of text, the desired encryption key.
-Client
-processes must then specify the same key with the
-.B crypt
-option in the supfile or they will be denied access to the files.
-In addition, actual network transmission of file contents and
-filenames will be encrypted.
-.TP
-.B list
-This file describes the actual list of files to be included in this
-file collection, in a format described below.
-.TP
-.B releases
-This file describes any releases that the collection may have. Each
-line starts with the release name and then may specify any of the following
-files:
-.I prefix=<dirname>
-to use a different parent directory for the files in this release.
-.I list=<listname>
-to specify the list of files in the release.
-.I scan=<scanfile>
-must be used in multi-release collections that are scanned to keep
-the scan files for the different releases separate.
-.I host=<hostfile>
-to allow different host restrictions for this release.
-.I next=<release>
-used to chain releases together. This has the effect of making one release
-be a combination of several other releases. If the same file appears in
-more than one chained release, the first one found will be used.
-If these files are not specified for a release the default names:
-prefix,list,scan and host will be used.
-.TP
-.B scan
-This file, created by
-.IR supscan ,
-is the list of filenames that correspond to the instructions in the
-list file. The scan file is only used for frequently updated file
-collections; it makes the file server run much faster. See
-.IR supservers (8)
-for more information.
-.TP
-.B lock
-As previously mentioned, this file is used to indicate that the
-collection should be locked while upgrades are in progress. All
-file servers will try to get shared access to the lock file with
-.IR flock (2).
-.TP
-.B logfile
-If a log file exists in the collection directory, the file server
-will append the last time an upgrade was successfully completed,
-the time the last upgrade started and finished, and the name of
-the host requesting the upgrade.
-.i0
-.DT
-.PP
-It should be noted that
-.I sup
-allows several different named collections to use the same base
-directory. Separate encryption, remote host access, and file lists
-are used for each collection, since these files reside in subdirectories
-.I <basedir>/sup/<coll.name>.
-
-The list file is a text file with one command on each line.
-Each command
-contains a keyword and a number of operands separated by spaces.
-All filenames in the list file are evaluated on the repository machine
-relative to the host's base directory, or prefix directory if one is
-specified, and on your machine with respect
-to the base, or prefix, directory for the client.
-The
-.I filenames
-below (except \fIexec-command\fR)
-may all include wild-cards and meta-characters as used by
-.IR csh (1)
-including *, ?, [...], and {...}. The commands are:
-.TP
-\fBupgrade\fR \fIfilename\fR ...
-The specified file(s) (or directories) will be included in the list
-of files to be upgraded.
-If a directory name is given, it recursively
-includes all subdirectories and files within that directory.
-.TP
-\fBalways\fR \fIfilename\fR ...
-The always command is identical to upgrade, except that omit and
-omitany commands do not affect filenames specified with the always
-command.
-.TP
-\fBomit\fR \fIfilename\fR ...
-The specified file(s) (or directories) will be excluded from the
-list of files to be upgraded.
-For example, by specifying
-.B upgrade /usr/vision
-and
-.B omit /usr/vision/exp,
-the generated list
-of files would include all subdirectories and files of /usr/vision
-except /usr/vision/exp (and its subdirectories and files).
-.TP
-\fBomitany\fR \fIpattern\fR ...
-The specified patterns are compared against the files in the upgrade
-list. If a pattern matches, the file is omitted. The omitany command
-currently supports all wild-card patterns except {...}. Also, the
-pattern must match the entire filename, so a leading */, or a trailing /*,
-may be necessary in the pattern.
-.TP
-\fBbackup\fR \fIfilename\fR ...
-The specified file(s) are marked for backup; if they are upgraded
-and the client has specified the
-.B backup
-option in the corresponding
-line of the supfile, then backup copies will be created as described
-above.
-Directories may not be specified, and no recursive filename
-construction is performed; you must specify the names of the specific
-files to be backed up before upgrading.
-.TP
-\fBnoaccount\fR \fIfilename\fR ...
-The accounting information of the specified file(s) will not be
-preserved by
-.IR sup .
-Accounting information consists of the owner,
-group, mode and modified time of a file.
-.TP
-\fBsymlink\fR \fIfilename\fR ...
-The specified file(s) are to be treated as symbolic links
-and will be transferred as such and not followed. By default,
-.I sup
-will follow symbolic links.
-.TP
-\fBrsymlink\fR \fIdirname\fR ...
-All symbolic links in the specified directory and its
-subdirectories are to be treated as symbolic links. That
-is the links will be transferred and not the files to which
-they point.
-.TP
-\fBexecute\fR \fIexec-command\fR (\fIfilename\fR ...)
-The
-.I exec-command
-you specified will be executed on the client process
-whenever any of the files listed in parentheses are upgraded.
-A special token,
-.B %s,
-may be specified in the
-.I exec-command
-and will be replaced by the name of the file that was upgraded.
-For example, if you say
-\fBexecute ranlib %s (libc.a)\fR,
-then whenever libc.a is upgraded, the client machine will execute
-.B
-ranlib libc.a.
-As described above, the client must invoke
-.I sup
-with the
-.B -e
-flag to allow the automatic execution of command files.
-.TP
-\fBinclude\fR \fIlistfile\fR ...
-The specified
-.I listfiles
-will be read at this point. This is useful
-when one collection subsumes other collections; the larger collection
-can simply specify the listfiles for the smaller collections contained
-within it.
-.i0
-.DT
-.PP
-The order in which the command lines appear in the list file does not
-matter. Blank lines may appear freely in the list file.
-.SH "FILES"
-Files on the client machine for
-.IR sup :
-.TP
-.B /usr/lib/supfiles/coll.list
-supfile used for -s flag
-.TP
-.B /usr/lib/supfiles/coll.what
-supfile used for -s flag when -t flag is also specified
-.TP
-.B /usr/lib/supfiles/coll.host
-host name list for system collections
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/last\fR<\fI.release\fR>
-recorded list of files in collection as of last upgrade
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/lock
-file used to lock collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/refuse
-list of files to refuse in collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/when\fR<\fI.release\fR>
-recorded time of last upgrade
-.TP
-\fB/usr/sup/\fR<\fIcollection\fR>
-default base directory for file collection
-.i0
-.DT
-.PP
-
-Files needed on each repository machine for the file server:
-.TP
-.B /usr/lib/supfiles/coll.dir
-base directory list for system
-collections
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/crypt
-data encryption key for a
-collection. the owner of this file is the
-default account used when data encryption is specified
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/host
-list of remote hosts allowed to
-upgrade a collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/list
-list file for a collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/lock
-lock file for a collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/logfile
-log file for a collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/prefix
-file containing the name of the prefix directory
-for a collection
-.TP
-<\fIbase-directory\fR>\fB/sup/\fR<\fIcollection\fR>\fB/scan
-scan file for a collection
-.TP
-\fB/usr/\fR<\fIcollection\fR>
-default base directory for a file collection
-.i0
-.DT
-.PP
-.SH "SEE ALSO"
-.IR supservers (8)
-.br
-\fIThe SUP Software Upgrade Protocol\fR, S. A. Shafer,
-CMU Computer Science Department, 1985.
-.SH "BUGS"
-The encryption mechanism should be strengthened, although it's
-not trivial.
diff --git a/usr.bin/sup/src/sup.h b/usr.bin/sup/src/sup.h
deleted file mode 100644
index d4e8512c780..00000000000
--- a/usr.bin/sup/src/sup.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/* $OpenBSD: sup.h,v 1.9 2002/02/19 19:39:39 millert Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/* sup.h -- declarations for sup, supnamesrv, supfilesrv
- *
- * VERSION NUMBER for any program is given by: a.b (c)
- * where a = PROTOVERSION is the protocol version #
- * b = PGMVERSION is program # within protocol
- * c = scmversion is communication module version
- * (i.e. operating system for which scm is configured)
- **********************************************************************
- * HISTORY
- * 13-Sep-92 Mary Thompson (mrt) at Carnegie-Mellon University
- * Changed name of DEFDIR from /usr/cs to /usr.
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.10 92/08/11 12:06:42 mrt
- * Added definition for DEBUGFPORTNUM, the debugging port number.
- * Changed so that last and when file names could include
- * the relase name if any.
- * [92/07/23 mrt]
- *
- * Revision 1.9 91/04/29 14:39:03 mja
- * Reduce MAXCHILDREN from 8 to 3.
- *
- * Revision 1.8 89/08/23 14:55:30 gm0w
- * Moved coll.dir from supservers to supfiles.
- * [89/08/23 gm0w]
- *
- * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added host=<hostfile> support to releases file.
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Removed nameserver support.
- *
- * 27-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added TREELIST and other changes for "release" support.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Version 6 of the network protocol, better support to reflect errors
- * back to server logfile.
- *
- * 21-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Merged divergent CS and EE versions.
- *
- * 19-Sep-86 Mike Accetta (mja) at Carnegie-Mellon University
- * Added FILESUPTDEFAULT definition.
- *
- * 07-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed FILESRVBUSYWAIT. Now uses exponential backoff.
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added numeric port numbers to use when port names are not in the
- * host table.
- *
- * 04-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Update protocol version to 5 for name server protocol change to
- * allow multiple repositories per collection. Added FILESRVBUSYWAIT
- * of 5 minutes. Added FILELOCK file to indicate collections that
- * should be exclusively locked when upgraded.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-/* PGMVERSION is defined separately in each program */
-extern char scmversion[]; /* string version of scm */
-#define PROTOVERSION 8 /* version of network protocol */
-#define SCANVERSION 2 /* version of scan file format */
-
-/* TCP servers for name server and file server */
-#define FILEPORT "supfilesrv"
-#define FILEPORTNUM 871
-#define DEBUGFPORT "supfiledbg"
-#define DEBUGFPORTNUM 1127
-
-/* Data files used in scan.c */
-#define FILELIST "sup/%s/%s"
-#define FILESCAN "sup/%s/%s"
-#define FILEHOST "sup/%s/%s"
-#define FILELISTDEF "list"
-#define FILESCANDEF "scan"
-#define FILEHOSTDEF "host"
-#define DEFRELEASE "default"
-
-/* Data files used in sup.c */
-#define FILEBASEDEFAULT "/usr/%s" /* also supfilesrv and supscan */
-#ifdef EE_XXX
-#define FILESUPDEFAULT "%s/supfiles/coll.list"
-#define FILESUPTDEFAULT "%s/supfiles/coll.what"
-#define FILEHOSTS "%s/supfiles/coll.host"
-#else /* EE_XXX */
-#define FILESUPDEFAULT "%s/lib/supfiles/coll.list"
-#define FILESUPTDEFAULT "%s/lib/supfiles/coll.what"
-#define FILEHOSTS "%s/lib/supfiles/coll.host"
-#endif /* EE_XXX */
-#define FILEBKDIR "%s/BACKUP"
-#define FILEBACKUP "%s/BACKUP/%s"
-#define FILELAST "sup/%s/last%s"
-#define FILELASTTEMP "sup/%s/last%s.temp"
-#define FILELOCK "sup/%s/lock" /* also supfilesrv */
-#define FILEREFUSE "sup/%s/refuse"
-#define FILEWHEN "sup/%s/when%s"
-
-/* Data files used in supfilesrv.c */
-#define FILEXPATCH "%s/sup/xpatch.host"
-#ifdef EE_XXX
-#define FILEDIRS "%s/supfiles/coll.dir" /* also supscan */
-#else /* EE_XXX */
-#define FILEDIRS "%s/lib/supfiles/coll.dir" /* also supscan */
-#endif /* EE_XXX */
-#define FILECRYPT "sup/%s/crypt"
-#define FILELOGFILE "sup/%s/logfile"
-#define FILEPREFIX "sup/%s/prefix" /* also supscan */
-#define FILERELEASES "sup/%s/releases" /* also supscan */
-
-/* String length */
-#define STRINGLENGTH 2000
-
-/* Password transmission encryption key */
-#define PSWDCRYPT "SuperMan"
-/* Test string for encryption */
-#define CRYPTTEST "Hello there, Sailor Boy!"
-
-/* Default directory for system sup information */
-#ifndef DEFDIR
-#ifdef EE_XXX
-#define DEFDIR "/etc"
-#else /* EE_XXX */
-#define DEFDIR "/usr"
-#endif /* EE_XXX */
-#endif /* DEFDIR */
-
-/* Default login account for file server */
-#ifndef DEFUSER
-#define DEFUSER "anon"
-#endif /* DEFUSER */
-
-/* subroutine return codes */
-#define SCMOK (1) /* routine performed correctly */
-#define SCMEOF (0) /* read EOF on network connection */
-#define SCMERR (-1) /* error occurred during routine */
-
-/* data structure for describing a file being upgraded */
-
-struct treestruct {
-/* fields for file information */
- char *Tname; /* path component name */
- int Tflags; /* flags of file */
- int Tmode; /* st_mode of file */
- char *Tuser; /* owner of file */
- uid_t Tuid; /* owner id of file */
- char *Tgroup; /* group of file */
- gid_t Tgid; /* group id of file */
- int Tctime; /* inode modification time */
- int Tmtime; /* data modification time */
- struct treestruct *Tlink; /* tree of link names */
- struct treestruct *Texec; /* tree of execute commands */
-/* fields for sibling AVL tree */
- int Tbf; /* balance factor */
- struct treestruct *Tlo,*Thi; /* ordered sibling tree */
-};
-typedef struct treestruct TREE;
-
-/* data structure to represent a list of trees to upgrade */
-
-struct tliststruct {
- struct tliststruct *TLnext; /* next entry in tree list */
-/* fields for tree information */
- char *TLname; /* release name for tree */
- char *TLprefix; /* prefix of tree */
- char *TLlist; /* name of list file */
- char *TLscan; /* name of scan file */
- char *TLhost; /* name of host file */
- TREE *TLtree; /* tree of files to upgrade */
-};
-typedef struct tliststruct TREELIST;
-
-/* bitfield not defined in stat.h */
-#define S_IMODE 07777 /* part of st_mode that chmod sets */
-
-/* flag bits for files */
-#define FNEW 01 /* ctime of file has changed */
-#define FBACKUP 02 /* backup of file is allowed */
-#define FNOACCT 04 /* don't set file information */
-#define FUPDATE 010 /* only set file information */
-#define FNEEDED 0100000 /* file needed for upgrade */
-
-/* version 3 compatability */
-#define FCOMPAT 0010000 /* Added to detect execute commands to send */
-
-/* message types now obsolete */
-#define MSGFEXECQ (115)
-#define MSGFEXECNAMES (116)
-
-/* flag bits for files in list of all files */
-#define ALLNEW 01
-#define ALLBACKUP 02
-#define ALLEND 04
-#define ALLDIR 010
-#define ALLNOACCT 020
-#define ALLSLINK 0100
-
-/* flag bits for file mode word */
-#define MODELINK 010000
-#define MODEDIR 040000
-#define MODESYM 0100000
-#define MODENOACCT 0200000
-#define MODEUPDATE 01000000
-
-/* blocking factor for filenames in list of all file names */
-#define BLOCKALL 32
-
-/* end version 3 compatability */
-
-#define MAXCHILDREN 3 /* maximum number of children allowed
- to sup at the same time */
-
-#include <stdarg.h>
diff --git a/usr.bin/sup/src/supcdefs.h b/usr.bin/sup/src/supcdefs.h
deleted file mode 100644
index 4dd4ef97d19..00000000000
--- a/usr.bin/sup/src/supcdefs.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $OpenBSD: supcdefs.h,v 1.8 2005/04/27 18:13:16 mickey Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * supcdefs.h -- Declarations shared by the collection of files
- * that build the sup client.
- *
- **********************************************************************
- * HISTORY
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.6 92/08/11 12:06:52 mrt
- * Added CFURELSUF - use-release-suffix flag
- * Made rpause code conditional on MACH rather than CMUCS
- * [92/07/26 mrt]
- *
- * Revision 1.5 92/02/08 18:23:57 mja
- * Added CFKEEP flag.
- * [92/01/17 vdelvecc]
- *
- * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added timeout for backoff.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added Crelease for "release" support.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-#include <errno.h>
-#include <libc.h>
-#include <netdb.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <pwd.h>
-#include <grp.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#if MACH /* used by resource pausing code only */
-#include <sys/ioctl.h>
-#include <sys/resource.h>
-#endif /* MACH */
-#include <c.h>
-#include "sup.h"
-#include "supmsg.h"
-
-extern int PGMVERSION;
-
-/*******************************************
- *** D A T A S T R U C T U R E S ***
- *******************************************/
-
-struct collstruct { /* one per collection to be upgraded */
- char *Cname; /* collection name */
- TREE *Chost; /* attempted host for collection */
- TREE *Chtree; /* possible hosts for collection */
- char *Cbase; /* local base directory */
- char *Chbase; /* remote base directory */
- char *Cprefix; /* local collection pathname prefix */
- char *Crelease; /* release name */
- char *Cnotify; /* user to notify of status */
- char *Clogin; /* remote login name */
- char *Cpswd; /* remote password */
- char *Ccrypt; /* data encryption key */
- int Ctimeout; /* timeout for backoff */
- int Cflags; /* collection flags */
- int Cnogood; /* upgrade no good, "when" unchanged */
- int Clockfd; /* >= 0 if collection is locked */
- struct collstruct *Cnext; /* next collection */
-};
-typedef struct collstruct COLLECTION;
-
-#define CFALL 00001
-#define CFBACKUP 00002
-#define CFDELETE 00004
-#define CFEXECUTE 00010
-#define CFLIST 00020
-#define CFLOCAL 00040
-#define CFMAIL 00100
-#define CFOLD 00200
-#define CFVERBOSE 00400
-#define CFKEEP 01000
-#define CFURELSUF 02000
-#define CFCOMPRESS 04000
-#define CFSILENT 10000
-#define CFVERBOSE2 20000
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-#define vnotify if (thisC->Cflags & CFVERBOSE) notify
-#define v2notify if (thisC->Cflags & (CFVERBOSE|CFVERBOSE2) == (CFVERBOSE|CFVERBOSE2)) notify
diff --git a/usr.bin/sup/src/supcmain.c b/usr.bin/sup/src/supcmain.c
deleted file mode 100644
index e9d1c6436a4..00000000000
--- a/usr.bin/sup/src/supcmain.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/* $OpenBSD: supcmain.c,v 1.23 2007/11/25 16:40:03 jmc Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * sup -- Software Upgrade Protocol client process
- *
- * Usage: sup [ flags ] [ supfile ] [ collection ... ]
- *
- * The only required argument to sup is the name of a supfile. It
- * must either be given explicitly on the command line, or the -s
- * flag must be specified. If the -s flag is given, the system
- * supfile will be used and a supfile command argument should not be
- * specified. The list of collections is optional and if specified
- * will be the only collections upgraded. The following flags affect
- * all collections specified.
- *
- * -s "system upgrade" flag
- * As described above.
- *
- * -t "upgrade time" flag
- * When this flag is given, Sup will print the time
- * that each collection was last upgraded, rather than
- * performing actual upgrades.
- *
- * -u "utimes" flag
- * When this flag is given sup will not attempt to
- * restore access and modification files on the
- * collection files from the server.
- *
- * -R "resource pause" flag
- * Sup will not disable resource pausing and will not
- * make filesystem space checks.
- *
- * -N "debug network" flag
- * Sup will trace messages sent and received that
- * implement the Sup network protocol.
- *
- * -P "debug ports" flag
- * Sup will use a set of non-privileged network
- * ports reserved for debugging purposes.
- *
- * -X "crosspatch" flag
- * Sup is being run remotely with a crosspatch.
- * Need to be careful as we may be running as root
- * instead of collection owner.
- *
- * The remaining flags affect all collections unless an explicit list
- * of collections are given with the flags. Multiple flags may be
- * specified together that affect the same collections. For the sake
- * of convenience, any flags that always affect all collections can be
- * specified with flags that affect only some collections. For
- * example, "sup -sde=coll1,coll2" would perform a system upgrade,
- * and the first two collections would allow both file deletions and
- * command executions. Note that this is not the same command as
- * "sup -sde=coll1 coll2", which would perform a system upgrade of
- * just the coll2 collection and would ignore the flags given for the
- * coll1 collection.
- *
- * -a "all files" flag
- * All files in the collection will be copied from
- * the repository, regardless of their status on the
- * current machine. Because of this, it is a very
- * expensive operation and should only be done for
- * small collections if data corruption is suspected
- * and been confirmed. In most cases, the -o flag
- * should be sufficient.
- *
- * -b "backup files" flag
- * If the -b flag if given, or the "backup" supfile
- * option is specified, the contents of regular files
- * on the local system will be saved before they are
- * overwritten with new data. The data will be saved
- * in a subdirectory called "BACKUP" in the directory
- * containing the original version of the file, in a
- * file with the same non-directory part of the file
- * name. The files to backup are specified by the
- * list file on the repository.
- *
- * -B "don't backup files" flag
- * The -B flag overrides and disables the -b flag and
- * the "backup" supfile option.
- *
- * -d "delete files" flag
- * Files that are no longer in the collection on the
- * repository will be deleted if present on the local
- * machine. This may also be specified in a supfile
- * with the "delete" option.
- *
- * -D "don't delete files" flag
- * The -D flag overrides and disables the -d flag and
- * the "delete" supfile option.
- *
- * -e "execute files" flag
- * Sup will execute commands sent from the repository
- * that should be run when a file is upgraded. If
- * the -e flag is omitted, Sup will print a message
- * that specifies the command to execute. This may
- * also be specified in a supfile with the "execute"
- * option.
- *
- * -E "don't execute files" flag
- * The -E flag overrides and disables the -e flag and
- * the "execute" supfile option.
- *
- * -f "file listing" flag
- * A "list-only" upgrade will be performed. Messages
- * will be printed that indicate what would happen if
- * an actual upgrade were done.
- *
- * -k "keep newer files" flag
- * The -k flag, or "keep" supfile option, will cause
- * Sup to check to see whether there is a newer file on
- * the local disk before updating files. Only files
- * which are newer on the repository will be updated.
- *
- * -K "don't keep newer files" flag
- * The -K flag overrides and disables the -k flag and
- * the "keep" supfile option.
- *
- * -l "local upgrade" flag
- * Normally, Sup will not upgrade a collection if the
- * repository is on the same machine. This allows
- * users to run upgrades on all machines without
- * having to make special checks for the repository
- * machine. If the -l flag is specified, collections
- * will be upgraded even if the repository is local.
- *
- * -m "mail" flag
- * Normally, Sup used standard output for messages.
- * If the -m flag if given, Sup will send mail to the
- * user running Sup, or a user specified with the
- * "notify" supfile option, that contains messages
- * printed by Sup.
- *
- * -o "old files" flag
- * Sup will normally only upgrade files that have
- * changed on the repository since the last time an
- * upgrade was performed. The -o flag, or the "old"
- * supfile option, will cause Sup to check all files
- * in the collection for changes instead of just the
- * new ones.
- *
- * -O "not old files" flag
- * The -O flag overrides and disables the -o flag and
- * the "old" supfile option.
- *
- * -v "verbose" flag
- * Normally, Sup will only print messages if there
- * are problems. This flag causes Sup to also print
- * messages during normal progress showing what Sup
- * is doing.
- *
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.6 92/08/11 12:06:59 mrt
- * Merged in Brad's changes. Made resource pausing code conditional
- * on MACH, rather than CMUCS. Fixed some calls to sprintf to
- * return void.
- * [92/08/09 mrt]
- *
- * Revision 1.5 92/02/08 19:01:18 mja
- * Correct oldsigsys type when ANSI C.
- * [92/02/08 18:59:47 mja]
- *
- * Revision 1.4 92/02/08 18:24:01 mja
- * Added -k and -K switches.
- * [92/01/17 vdelvecc]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support (is currently ignored).
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split into several files. This is the main program and
- * command line processing and old history log. [V5.21]
- *
- * 21-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Merged divergent CS and ECE versions. ifdeffed out the resource
- * pausing code - only compiled in if CMUCS defined. [V5.21a]
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed support for version 3 of SUP protocol. Added changes
- * to make lint happy. Added calls to new logging routines. [V5.20]
- *
- * 01-Apr-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added -R switch to reenable resource pausing, which is currently
- * disabled by default. Added code to check for free disk space
- * available on the target filesystem so that sup shouldn't run the
- * system out of disk space as frequently. [V5.19]
- *
- * 19-Sep-86 Mike Accetta (mja) at Carnegie-Mellon University
- * Changed default supfile name for system collections when -t
- * is specified to use FILESUPTDEFAULT; added missing new-line
- * in retry message. [V5.18]
- *
- * 21-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Missed a caller to a routine which had an extra argument added
- * to it last edit. [V5.17]
- *
- * 07-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed getcoll() so that fatal errors are checked immediately
- * instead of after sleeping for a little while. Changed all
- * rm -rf commands to rmdir since the Mach folks keep deleting
- * their root and /usr directory trees. Reversed the order of
- * delete commands to that directories will possibly empty so
- * that the rmdir's work. [V5.16]
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed temporary file names to #n.sup format. [V5.15]
- *
- * 19-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Moved PGMVERSION to supvers.c module. [V5.14]
- *
- * 06-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added check for file type before unlink when receiving a
- * symbolic link. Now runs "rm -rf" if the file type is a
- * directory. [V5.13]
- *
- * 03-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed small bug in signon that didn't retry connections if an
- * error occurred on the first attempt to connect. [V5.12]
- *
- * 26-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * New command interface. Added -bBDEO flags and "delete",
- * "execute" and "old" supfile options. Changed -d to work
- * correctly without implying -o. [V5.11]
- *
- * 21-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fix incorrect check for supfile changing. Flush output buffers
- * before restart. [V5.10]
- *
- * 17-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Add call to requestend() after connection errors are retried to
- * free file descriptors. [V5.9]
- *
- * 15-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fix SERIOUS merge error from previous edit. Added notify
- * when execute command fails. [V5.8]
- *
- * 11-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed ugconvert to clear setuid/setgid bits if it doesn't use
- * the user and group specified by the remote system. Changed
- * execute code to invalidate collection if execute command returns
- * with a non-zero exit status. Added support for execv() of
- * original arguments of supfile is upgraded successfully. Changed
- * copyfile to always use a temp file if possible. [V5.7]
- *
- * 04-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added support for fileserver busy messages and new nameserver
- * protocol to support multiple repositories per collection.
- * Added code to lock collections with lock files. [V5.6]
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. [V4.5]
- *
- * 12-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed to check for DIFFERENT mtime (again). [V3.4]
- *
- * 08-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Replaced [ug]convert routines with ugconvert routine so that an
- * appropriate group will be used if the default user is used.
- * Changed switch parsing to allow multiple switches to be specified
- * at the same time. [V3.3]
- *
- * 04-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added test to request a new copy of an old file that already
- * exists if the mtime is different. [V3.2]
- *
- * 24-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added -l switch to enable upgrades from local repositories.
- *
- * 03-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Minor change in order -t prints so that columns line up.
- *
- * 22-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to implement retry flag and pass this on to request().
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-#define MSGFILE
-#include "supcdefs.h"
-#if MACH
-#include <sys/syscall.h>
-#ifndef SYS_rpause
-#define SYS_rpause (-5)
-#endif
-#endif
-#include "supextern.h"
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-char program[] = "SUP"; /* program name for SCM messages */
-pid_t progpid = -1; /* and process id */
-
-COLLECTION *firstC, *thisC; /* collection list pointer */
-
-extern int dontjump; /* disable longjmp */
-extern int scmdebug; /* SCM debugging flag */
-
-int silent; /* silent run, print only errors */
-int sysflag; /* system upgrade flag */
-int timeflag; /* print times flag */
-int noutime; /* don't preserve utimes */
-#if MACH
-int rpauseflag; /* don't disable resource pausing */
-#endif /* MACH */
-int xpatchflag; /* crosspatched with remote system */
-int portdebug; /* network debugging ports */
-
-int main(int, char **);
-static int checkcoll(TREE *, void *);
-static void doswitch(char *, TREE **, int *, int *);
-static char *init(int, char **);
-
-/*************************************
- *** M A I N R O U T I N E ***
- *************************************/
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- char *progname, *supfname;
- int restart, sfdev = 0, sfino = 0, sfmtime = 0;
- struct stat sbuf;
- struct sigaction ign;
-
- /* initialize global variables */
- pgmversion = PGMVERSION; /* export version number */
- server = FALSE; /* export that we're not a server */
- collname = NULL; /* no current collection yet */
- dontjump = TRUE; /* clear setjmp buffer */
- progname = strdup(argv[0]);
-
- supfname = init(argc, argv);
- restart = -1; /* don't make restart checks */
- if (*progname == '/' && *supfname == '/') {
- if (stat(supfname, &sbuf) < 0) {
- logerr("Can't stat supfile %s", supfname);
- } else {
- sfdev = sbuf.st_dev;
- sfino = sbuf.st_ino;
- sfmtime = sbuf.st_mtime;
- restart = 0;
- }
- }
- if (timeflag) {
- for (thisC = firstC; thisC; thisC = thisC->Cnext)
- prtime();
- } else {
- /* ignore network pipe signals */
- memset(&ign, 0, sizeof ign);
- ign.sa_handler = SIG_IGN;
- ign.sa_flags = 0;
- sigemptyset(&ign.sa_mask);
- (void) sigaction(SIGPIPE,&ign,NULL);
- getnams(); /* find unknown repositories */
- for (thisC = firstC; thisC; thisC = thisC->Cnext) {
- getcoll(); /* upgrade each collection */
- if (restart == 0) {
- if (stat(supfname,&sbuf) < 0)
- logerr("Can't stat supfile %s",
- supfname);
- else if (sfmtime != sbuf.st_mtime ||
- sfino != sbuf.st_ino ||
- sfdev != sbuf.st_dev) {
- restart = 1;
- break;
- }
- }
- }
- endpwent(); /* close /etc/passwd */
- endgrent(); /* close /etc/group */
- if (restart == 1) {
- if (!silent)
- loginfo("SUP Restarting %s with new supfile %s",
- progname, supfname);
- closefrom(4);
- execv(progname, argv);
- logquit(1, "Restart failed");
- }
- }
- while ((thisC = firstC) != NULL) {
- firstC = firstC->Cnext;
- free(thisC->Cname);
- Tfree(&thisC->Chtree);
- free(thisC->Cbase);
- if (thisC->Chbase)
- free(thisC->Chbase);
- if (thisC->Cprefix)
- free(thisC->Cprefix);
- if (thisC->Crelease)
- free(thisC->Crelease);
- if (thisC->Cnotify)
- free(thisC->Cnotify);
- if (thisC->Clogin)
- free(thisC->Clogin);
- if (thisC->Cpswd)
- free(thisC->Cpswd);
- if (thisC->Ccrypt)
- free(thisC->Ccrypt);
- free (thisC);
- }
- exit (0);
-}
-
-/*****************************************
- *** I N I T I A L I Z A T I O N ***
- *****************************************/
-/*
- * Set up collection list from supfile. Check all fields except
- * hostname to be sure they make sense.
- */
-
-#define Toflags Tflags
-#define Taflags Tmode
-#define Twant Tuid
-#define Tcount Tgid
-
-static void
-doswitch(argp, collTp, oflagsp, aflagsp)
- char *argp;
- TREE **collTp;
- int *oflagsp, *aflagsp;
-{
- TREE *t;
- char *coll;
- int oflags,aflags;
-
- oflags = aflags = 0;
- for (;;) {
- switch (*argp) {
- default:
- logerr("Invalid flag '%c' ignored", *argp);
- break;
- case '\0':
- case '=':
- if (*argp++ == '\0' || *argp == '\0') {
- *oflagsp |= oflags;
- *oflagsp &= ~aflags;
- *aflagsp |= aflags;
- *aflagsp &= ~oflags;
- return;
- }
- do {
- coll = nxtarg(&argp, ", \t");
- t = Tinsert(collTp, coll, TRUE);
- t->Toflags |= oflags;
- t->Toflags &= ~aflags;
- t->Taflags |= aflags;
- t->Taflags &= ~oflags;
- argp = skipover(argp, ", \t");
- } while (*argp);
- return;
- case 'N':
- scmdebug++;
- break;
- case 'P':
- portdebug = TRUE;
- break;
- case 'R':
-#if MACH
- rpauseflag = TRUE;
-#endif /* MACH */
- break;
- case 'X':
- xpatchflag = TRUE;
- break;
- case 'S':
- silent = TRUE;
- break;
- case 's':
- sysflag = TRUE;
- break;
- case 't':
- timeflag = TRUE;
- break;
- case 'a':
- oflags |= CFALL;
- break;
- case 'b':
- oflags |= CFBACKUP;
- aflags &= ~CFBACKUP;
- break;
- case 'B':
- oflags &= ~CFBACKUP;
- aflags |= CFBACKUP;
- break;
- case 'd':
- oflags |= CFDELETE;
- aflags &= ~CFDELETE;
- break;
- case 'D':
- oflags &= ~CFDELETE;
- aflags |= CFDELETE;
- break;
- case 'e':
- oflags |= CFEXECUTE;
- aflags &= ~CFEXECUTE;
- break;
- case 'E':
- oflags &= ~CFEXECUTE;
- aflags |= CFEXECUTE;
- break;
- case 'f':
- oflags |= CFLIST;
- break;
- case 'k':
- oflags |= CFKEEP;
- aflags &= ~CFKEEP;
- break;
- case 'K':
- oflags &= ~CFKEEP;
- aflags |= CFKEEP;
- break;
- case 'l':
- oflags |= CFLOCAL;
- break;
- case 'm':
- oflags |= CFMAIL;
- break;
- case 'o':
- oflags |= CFOLD;
- aflags &= ~CFOLD;
- break;
- case 'O':
- oflags &= ~CFOLD;
- aflags |= CFOLD;
- break;
- case 'u':
- noutime = TRUE;
- break;
- case 'v':
- oflags |= CFVERBOSE;
- break;
- case 'V':
- oflags |= CFVERBOSE|CFVERBOSE2;
- break;
- case 'z':
- oflags |= CFCOMPRESS;
- break;
- case 'Z':
- oflags &= ~CFCOMPRESS;
- break;
- }
- argp++;
- }
-}
-
-static char *
-init(argc, argv)
- int argc;
- char **argv;
-{
- char buf[STRINGLENGTH], *p;
- char username[STRINGLENGTH];
- char *supfname, *arg;
- COLLECTION *c, *lastC;
- FILE *f;
- int bogus;
- struct passwd *pw;
- TREE *t;
- TREE *collT; /* collections we are interested in */
- time_t timenow; /* startup time */
- int oflags, aflags;
- int cwant;
-#ifdef MACH
- void (*oldsigsys)();
-#endif /* MACH */
-
- sysflag = FALSE; /* not system upgrade */
- timeflag = FALSE; /* don't print times */
-#if MACH
- rpauseflag = FALSE; /* don't disable resource pausing */
-#endif /* MACH */
- xpatchflag = FALSE; /* not normally crosspatched */
- scmdebug = 0; /* level zero, no SCM debugging */
- portdebug = FALSE; /* no debugging ports */
-
- collT = NULL;
- oflags = aflags = 0;
- while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') {
- doswitch(&argv[1][1], &collT, &oflags, &aflags);
- --argc;
- argv++;
- }
- if (argc == 1 && !sysflag)
- logquit (1, "Need either -s or supfile");
-#if MACH
- oldsigsys = signal(SIGSYS,SIG_IGN);
- if (rpauseflag != TRUE)
- if (syscall(SYS_rpause, ENOSPC, RPAUSE_ALL, RPAUSE_DISABLE) < 0)
- rpauseflag = TRUE;
- (void) signal(SIGSYS, oldsigsys);
-#endif /* MACH */
- if (sysflag) {
- (void) snprintf (buf, sizeof buf,
- timeflag ? FILESUPTDEFAULT : FILESUPDEFAULT, DEFDIR);
- supfname = buf;
- } else {
- supfname = argv[1];
- if (strcmp(supfname, "-") == 0)
- supfname = "";
- --argc;
- argv++;
- }
- cwant = argc > 1;
- while (argc > 1) {
- t = Tinsert(&collT, argv[1], TRUE);
- t->Twant = TRUE;
- --argc;
- argv++;
- }
- if ((p = getlogin()) ||
- ((pw = getpwuid(getuid())) && (p = pw->pw_name))) {
- (void) strlcpy(username, p, sizeof username);
- } else
- *username = '\0';
- if (*supfname) {
- f = fopen(supfname, "r");
- if (f == NULL)
- logquit(1, "Can't open supfile %s", supfname);
- } else
- f = stdin;
- firstC = NULL;
- lastC = NULL;
- bogus = FALSE;
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- arg = nxtarg (&p, " \t");
- if (*arg == '\0') {
- logerr("Missing collection name in supfile");
- bogus = TRUE;
- continue;
- }
- if (cwant) {
- TREE *t;
- if ((t = Tsearch(collT, arg)) == NULL)
- continue;
- t->Tcount++;
- }
- c = (COLLECTION *) malloc(sizeof(COLLECTION));
- if (firstC == NULL)
- firstC = c;
- if (lastC != NULL)
- lastC->Cnext = c;
- lastC = c;
- if (parsecoll(c,arg,p) < 0) {
- bogus = TRUE;
- continue;
- }
- c->Cflags |= oflags;
- c->Cflags &= ~aflags;
- if ((t = Tsearch(collT, c->Cname)) != NULL) {
- c->Cflags |= t->Toflags;
- c->Cflags &= ~t->Taflags;
- }
- if ((c->Cflags&CFMAIL) && c->Cnotify == NULL) {
- if (*username == '\0')
- logerr("User unknown, notification disabled");
- else
- c->Cnotify = strdup(username);
- }
- if (c->Cbase == NULL) {
- (void) snprintf(buf, sizeof buf,
- FILEBASEDEFAULT, c->Cname);
- c->Cbase = strdup(buf);
- }
- }
- if (bogus)
- logquit(1, "Aborted due to supfile errors");
- if (f != stdin)
- (void) fclose(f);
- if (cwant)
- (void) Tprocess(collT, checkcoll, NULL);
- Tfree (&collT);
- if (firstC == NULL)
- logquit(1, "No collections to upgrade");
- timenow = time(NULL);
- if (*supfname == '\0')
- p = "standard input";
- else if (sysflag)
- p = "system software";
- else {
- (void) snprintf(buf, sizeof buf, "file %s", supfname);
- p = buf;
- }
- if (!silent)
- loginfo("SUP %d.%d (%s) for %s at %s", PROTOVERSION, PGMVERSION,
- scmversion, p, fmttime(timenow));
- return (strdup(supfname));
-}
-
-static int
-checkcoll(t, dummy)
- TREE *t;
- void *dummy;
-{
- if (!t->Twant)
- return (SCMOK);
- if (t->Tcount == 0)
- logerr("Collection %s not found",t->Tname);
- if (t->Tcount > 1)
- logerr("Collection %s found more than once", t->Tname);
- return (SCMOK);
-}
diff --git a/usr.bin/sup/src/supcmeat.c b/usr.bin/sup/src/supcmeat.c
deleted file mode 100644
index 31fc1c8eb77..00000000000
--- a/usr.bin/sup/src/supcmeat.c
+++ /dev/null
@@ -1,1561 +0,0 @@
-/* $OpenBSD: supcmeat.c,v 1.23 2007/09/14 14:29:20 chl Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * sup "meat" routines
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.16 92/09/09 22:04:51 mrt
- * Really added bww's recvone changes this time.
- * Added code to support non-crypting version of sup.
- * [92/09/01 mrt]
- *
- * Revision 1.15 92/08/11 12:07:09 mrt
- * Added support to add release to FILEWHEN name.
- * Updated variable arguemnt list usage - bww
- * Updated recvone() to take a va_list - bww
- * Changed conditional for rpausing code from CMUCS to MACH
- * [92/07/24 mrt]
- *
- * Revision 1.14 92/02/08 18:24:12 mja
- * Only apply "keep" mode when local file is strictly newer
- * otherwise allow update as before if necessary.
- * [92/02/08 18:09:00 mja]
- *
- * Added support for -k (keep) option to needone(). Rewrote and
- * commented other parts of needone().
- * [92/01/17 vdelvecc]
- *
- * Revision 1.13 91/05/16 14:49:41 ern
- * Add timestap to fileserver.
- * Drop day of the week from 5 messages.
- * [91/05/16 14:47:53 ern]
- *
- * Revision 1.12 89/08/23 14:55:44 gm0w
- * Changed msgf routines to msg routines.
- * [89/08/23 gm0w]
- *
- * Revision 1.11 89/08/03 19:49:10 mja
- * Updated to use v*printf() in place of _doprnt().
- * [89/04/19 mja]
- *
- * Revision 1.10 89/06/18 14:41:27 gm0w
- * Fixed up some notify messages of errors to use "SUP:" prefix.
- * [89/06/18 gm0w]
- *
- * Revision 1.9 89/06/10 15:12:17 gm0w
- * Changed to always use rename to install targets. This breaks hard
- * links and recreates those known to sup, other links will be orphaned.
- * [89/06/10 gm0w]
- *
- * Revision 1.8 89/05/24 15:04:23 gm0w
- * Added code to check for EINVAL from FSPARAM ioctl for disk
- * space check failures when the ioctl is not implemented.
- * [89/05/24 gm0w]
- *
- * Revision 1.7 89/01/16 18:22:28 gm0w
- * Changed needone() to check that mode of files match before
- * setting update if times also match.
- * [89/01/16 gm0w]
- *
- * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added timeout to backoff.
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support.
- *
- * 09-Sep-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to be less verbose when updating files that have
- * already been successfully upgraded.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support.
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Converted to end connection with more information.
- * Added done routine. Modified goaway routine to free old
- * goawayreason.
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Use computeBackoff from scm instead of doing it ourselves.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split off from sup.c and reindented goaway calls.
- *
- **********************************************************************
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-#include <sys/param.h>
-#include <sys/wait.h>
-
-TREE *lastT; /* last filenames in collection */
-jmp_buf sjbuf; /* jump location for network errors */
-int dontjump; /* flag to void sjbuf */
-int cancompress = FALSE; /* Can we do compression? */
-int docompress = FALSE; /* Do we do compression? */
-
-extern COLLECTION *thisC; /* collection list pointer */
-extern int rpauseflag; /* don't disable resource pausing */
-extern int portdebug; /* network debugging ports */
-extern int noutime; /* don't set utimes */
-
-/*************************************************
- *** U P G R A D E C O L L E C T I O N ***
- *************************************************/
-
-static int needone(TREE *, void *);
-static int recvone(TREE *, va_list);
-static int denyone(TREE *, void *);
-static int deleteone(TREE *, void *);
-static int linkone(TREE *, void *);
-static int execone(TREE *, void *);
-static int finishone(TREE *, void *);
-
-
-/*
- * The next two routines define the fsm to support multiple fileservers
- * per collection.
- */
-int
-getonehost(t, v)
- TREE *t;
- void *v;
-{
- long *state = v;
-
- if (t->Tflags != *state)
- return (SCMOK);
- if (*state != 0 && t->Tmode == SCMEOF) {
- t->Tflags = 0;
- return (SCMOK);
- }
- if (*state == 2)
- t->Tflags--;
- else
- t->Tflags++;
- thisC->Chost = t;
- return (SCMEOF);
-}
-
-TREE *
-getcollhost(tout, backoff, state, nhostsp)
- int *tout, *backoff, *nhostsp;
- long *state;
-{
- static long laststate = 0;
- static int nhosts = 0;
-
- if (*state != laststate) {
- *nhostsp = nhosts;
- laststate = *state;
- nhosts = 0;
- }
- if (Tprocess(thisC->Chtree, getonehost, state) == SCMEOF) {
- if (*state != 0 && nhosts == 0 && !dobackoff(tout, backoff))
- return (NULL);
- nhosts++;
- return (thisC->Chost);
- }
- if (nhosts == 0)
- return (NULL);
- if (*state == 2)
- (*state)--;
- else
- (*state)++;
- return (getcollhost(tout, backoff, state, nhostsp));
-}
-
-/*
- * Upgrade a collection from the file server on the appropriate
- * host machine.
- */
-void
-getcoll(void)
-{
- TREE *t;
- int x;
- int tout, backoff, nhosts;
- long state;
-
- collname = thisC->Cname;
- tout = thisC->Ctimeout;
- lastT = NULL;
- backoff = 2;
- state = 0;
- nhosts = 0;
- for (;;) {
- t = getcollhost(&tout, &backoff, &state, &nhosts);
- if (t == NULL) {
- finishup(SCMEOF);
- notify(NULL);
- return;
- }
- t->Tmode = SCMEOF;
- dontjump = FALSE;
- if (!setjmp(sjbuf) && !signon(t, nhosts, &tout) && !setup(t))
- break;
- (void) requestend();
- }
- dontjump = FALSE;
- if (setjmp(sjbuf))
- x = SCMERR;
- else {
- suplogin();
- listfiles();
- recvfiles();
- x = SCMOK;
- }
- if (thisC->Clockfd >= 0) {
- (void) close(thisC->Clockfd);
- thisC->Clockfd = -1;
- }
- finishup(x);
- notify(NULL);
-}
-
-/*** Sign on to file server ***/
-
-int signon (t, nhosts, tout)
- TREE *t;
- int nhosts;
- int *tout;
-{
- int x;
- int timeout;
- time_t tloc;
-
- if ((thisC->Cflags&CFLOCAL) == 0 && thishost(thisC->Chost->Tname)) {
- vnotify("SUP: Skipping local collection %s\n", collname);
- t->Tmode = SCMEOF;
- return (TRUE);
- }
- if (nhosts == 1)
- timeout = *tout;
- else
- timeout = 0;
- x = request(portdebug ? DEBUGFPORT : FILEPORT, thisC->Chost->Tname,
- &timeout);
- if (nhosts == 1)
- *tout = timeout;
- if (x != SCMOK) {
- if (nhosts) {
- notify("SUP: Can't connect to host %s\n",
- thisC->Chost->Tname);
- t->Tmode = SCMEOF;
- } else
- t->Tmode = SCMOK;
- return (TRUE);
- }
- xpatch = FALSE;
- x = msgsignon(); /* signon to fileserver */
- if (x != SCMOK)
- goaway("Error sending signon request to fileserver");
- x = msgsignonack(); /* receive signon ack from fileserver */
- if (x != SCMOK)
- goaway("Error reading signon reply from fileserver");
- tloc = time(NULL);
- vnotify("SUP Fileserver %d.%d (%s) %ld on %s at %.8s\n", protver,
- pgmver, scmver, (long)fspid, remotehost(), ctime(&tloc) + 11);
- free(scmver);
- scmver = NULL;
- if (protver < 4) {
- dontjump = TRUE;
- goaway("Fileserver sup protocol version is obsolete.");
- notify("SUP: This version of sup can only communicate with a fileserver using at least\n");
- notify("SUP: version 4 of the sup network protocol. You should either run a newer\n");
- notify("SUP: version of the sup fileserver or find an older version of sup.\n");
- t->Tmode = SCMEOF;
- return (TRUE);
- }
- /* If protocol is > 7 then try compression */
- if (protver > 7) {
- cancompress = TRUE;
- }
- return (FALSE);
-}
-
-/*** Tell file server what to connect to ***/
-
-int
-setup(t)
- TREE *t;
-{
- char relsufix[STRINGLENGTH];
- int x;
- struct stat sbuf;
-
- if (chdir(thisC->Cbase) < 0)
- goaway("Can't change to base directory %s", thisC->Cbase);
- if (stat ("sup", &sbuf) < 0) {
- (void) mkdir("sup", 0755);
- if (stat("sup",&sbuf) < 0)
- goaway("Can't create directory %s/sup", thisC->Cbase);
- vnotify("SUP Created directory %s/sup\n", thisC->Cbase);
- }
- if (thisC->Cprefix && chdir(thisC->Cprefix) < 0)
- goaway("Can't change to %s from base directory %s",
- thisC->Cprefix, thisC->Cbase);
- if (stat(".", &sbuf) < 0)
- goaway("Can't stat %s directory %s",
- thisC->Cprefix ? "prefix" : "base",
- thisC->Cprefix ? thisC->Cprefix : thisC->Cbase);
- if (thisC->Cprefix)
- (void) chdir(thisC->Cbase);
- /* read time of last upgrade from when file */
-
- if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) snprintf(relsufix, sizeof relsufix, ".%s",
- thisC->Crelease);
- else
- relsufix[0] = '\0';
- lasttime = getwhen(collname, relsufix);
- /* setup for msgsetup */
- basedir = thisC->Chbase;
- basedev = sbuf.st_dev;
- baseino = sbuf.st_ino;
- listonly = (thisC->Cflags&CFLIST);
- newonly = ((thisC->Cflags&(CFALL|CFDELETE|CFOLD)) == 0);
- release = thisC->Crelease;
- x = msgsetup();
- if (x != SCMOK)
- goaway ("Error sending setup request to file server");
- x = msgsetupack();
- if (x != SCMOK)
- goaway("Error reading setup reply from file server");
- if (setupack == FSETUPOK) {
- /* Test encryption */
- if (netcrypt(thisC->Ccrypt) != SCMOK)
- goaway("Running non-crypting sup");
- crypttest = CRYPTTEST;
- x = msgcrypt();
- if (x != SCMOK)
- goaway("Error sending encryption test request");
- x = msgcryptok();
- if (x == SCMEOF)
- goaway("Data encryption test failed");
- if (x != SCMOK)
- goaway("Error reading encryption test reply");
- return (FALSE);
- }
- switch (setupack) {
- case FSETUPSAME:
- notify("SUP: Attempt to upgrade from same host to same directory\n");
- done(FDONESRVERROR, "Overwrite error");
- case FSETUPHOST:
- notify("SUP: This host has no permission to access %s\n",
- collname);
- done(FDONESRVERROR, "Permission denied");
- case FSETUPOLD:
- notify("SUP: This version of SUP is too old for the fileserver\n");
- done(FDONESRVERROR, "Obsolete client");
- case FSETUPRELEASE:
- notify("SUP: Invalid release %s for collection %s\n",
- release == NULL ? DEFRELEASE : release, collname);
- done(FDONESRVERROR, "Invalid release");
- case FSETUPBUSY:
- vnotify("SUP Fileserver is currently busy\n");
- t->Tmode = SCMOK;
- doneack = FDONESRVERROR;
- donereason = "Fileserver is busy";
- (void) netcrypt(NULL);
- (void) msgdone();
- return (TRUE);
- default:
- goaway("Unrecognized file server setup status %d", setupack);
- }
- /* NOTREACHED */
- return (FALSE);
-}
-
-/*** Tell file server what account to use ***/
-
-void
-suplogin(void)
-{
- char buf[STRINGLENGTH];
- int f, x;
-
- /* lock collection if desired */
- (void) snprintf(buf, sizeof buf, FILELOCK, collname);
- f = open(buf, O_RDONLY, 0);
- if (f >= 0) {
-
-#if defined(LOCK_EX)
-# define TESTLOCK(f) flock(f, LOCK_EX|LOCK_NB)
-# define SHARELOCK(f) flock(f, LOCK_SH|LOCK_NB)
-# define WAITLOCK(f) flock(f, LOCK_EX)
-#elif defined(F_LOCK)
-# define TESTLOCK(f) lockf(f, F_TLOCK, 0)
-# define SHARELOCK(f) 1
-# define WAITLOCK(f) lockf(f, F_LOCK, 0)
-#else
-# define TESTLOCK(f) (close(f), f = -1, 1)
-# define SHARELOCK(f) 1
-# define WAITLOCK(f) 1
-#endif
- if (TESTLOCK(f) < 0) {
- if (errno != EWOULDBLOCK && errno != EAGAIN) {
- (void) close(f);
- goaway("Can't lock collection %s", collname);
- }
- if (SHARELOCK(f) < 0) {
- (void) close(f);
- if (errno == EWOULDBLOCK && errno != EAGAIN)
- goaway("Collection %s is locked by another sup",collname);
- goaway("Can't lock collection %s", collname);
- }
- vnotify("SUP Waiting for exclusive access lock\n");
- if (WAITLOCK(f) < 0) {
- (void) close(f);
- goaway("Can't lock collection %s", collname);
- }
- }
- thisC->Clockfd = f;
- vnotify("SUP Locked collection %s for exclusive access\n",
- collname);
- }
- logcrypt = NULL;
- loguser = thisC->Clogin;
- logpswd = thisC->Cpswd;
-
-#ifndef CRYPTING /* Define CRYPTING for backwards compatibility with old supfileservers */
- if (thisC->Clogin != NULL) /* othewise we only encrypt if there is a login id */
-#endif /* CRYPTING */
- {
- logcrypt = CRYPTTEST;
- (void) netcrypt(PSWDCRYPT); /* encrypt password data */
- }
- x = msglogin();
-#ifndef CRYPTING
- if (thisC->Clogin != NULL)
-#endif
- (void) netcrypt(NULL); /* turn off encryption */
- if (x != SCMOK)
- goaway("Error sending login request to file server");
- x = msglogack();
- if (x != SCMOK)
- goaway("Error reading login reply from file server");
- if (logack == FLOGNG) {
- notify("SUP: %s\n", logerror);
- free(logerror);
- logerror = NULL;
- notify("SUP: Improper login to %s account",
- thisC->Clogin ? thisC->Clogin : "default");
- done(FDONESRVERROR, "Improper login");
- }
- if (netcrypt (thisC->Ccrypt) != SCMOK) /* restore encryption */
- goaway("Running non-crypting sup");
-}
-
-/*
- * Send list of files that we are not interested in. Receive list of
- * files that are on the repository that could be upgraded. Find the
- * ones that we need. Receive the list of files that the server could
- * not access. Delete any files that have been upgraded in the past
- * which are no longer on the repository.
- */
-void
-listfiles()
-{
- char buf[STRINGLENGTH];
- char relsufix[STRINGLENGTH];
- char *p;
- FILE *f;
- int x;
-
- if ((thisC->Cflags&CFURELSUF) && release)
- (void) snprintf(relsufix, sizeof relsufix, ".%s", release);
- else
- relsufix[0] = '\0';
- (void) snprintf(buf, sizeof buf, FILELAST, collname, relsufix);
- f = fopen(buf, "r");
- if (f) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- (void) Tinsert(&lastT, p, FALSE);
- }
- (void) fclose(f);
- }
- refuseT = NULL;
- (void) snprintf(buf, sizeof buf, FILEREFUSE, collname);
- f = fopen(buf, "r");
- if (f) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- (void) Tinsert(&refuseT, p, FALSE);
- }
- (void) fclose(f);
- }
- vnotify("SUP Requesting changes since %s", ctime(&lasttime) + 4);
- x = msgrefuse();
- if (x != SCMOK)
- goaway ("Error sending refuse list to file server");
- listT = NULL;
- x = msglist();
- if (x != SCMOK)
- goaway("Error reading file list from file server");
- if (thisC->Cprefix)
- (void) chdir(thisC->Cprefix);
- needT = NULL;
- (void) Tprocess(listT, needone, NULL);
- Tfree(&listT);
- x = msgneed();
- if (x != SCMOK)
- goaway("Error sending needed files list to file server");
- Tfree(&needT);
- denyT = NULL;
- x = msgdeny();
- if (x != SCMOK)
- goaway("Error reading denied files list from file server");
- if (thisC->Cflags&CFVERBOSE)
- (void) Tprocess(denyT, denyone, NULL);
- Tfree(&denyT);
- if (thisC->Cflags&(CFALL|CFDELETE|CFOLD))
- (void) Trprocess(lastT, deleteone, NULL);
- Tfree(&refuseT);
-}
-
-static int
-needone(t, dummy)
- TREE *t;
- void *dummy;
-{
- TREE *newt;
- int exists, fetch;
- struct stat sbuf;
-
- newt = Tinsert (&lastT,t->Tname,TRUE);
- if (!newt)
- return (SCMERR);
- newt->Tflags |= FUPDATE;
- fetch = TRUE;
- if ((thisC->Cflags&CFALL) == 0) {
- if ((t->Tflags&FNEW) == 0 && (thisC->Cflags&CFOLD) == 0)
- return (SCMOK);
- if (S_ISLNK(t->Tmode))
- exists = (lstat(t->Tname,&sbuf) == 0);
- else
- exists = (stat(t->Tname,&sbuf) == 0);
- /*
- * This is moderately complicated:
- * If the file is the wrong type or doesn't exist, we need to
- * fetch the whole file. If the file is a special file, we
- * rely solely on the server: if the file changed, we do an
- * update; otherwise nothing. If the file is a normal file,
- * we check timestamps. If we are in "keep" mode, we fetch if
- * the file on the server is newer, and do nothing otherwise.
- * Otherwise, we fetch if the timestamp is wrong; if the file
- * changed on the server but the timestamp is right, we do an
- * update. (Update refers to updating stat information, i.e.
- * timestamp, owner, mode bits, etc.)
- */
- if (exists && (sbuf.st_mode&S_IFMT) == (t->Tmode&S_IFMT)) {
- if (!S_ISREG(t->Tmode)) {
- if (t->Tflags&FNEW)
- fetch = FALSE;
- else
- return (SCMOK);
- } else if ((thisC->Cflags&CFKEEP) &&
- sbuf.st_mtime > t->Tmtime) {
- return (SCMOK);
- } else if (sbuf.st_mtime == t->Tmtime) {
- if (t->Tflags&FNEW)
- fetch = FALSE;
- else
- return (SCMOK);
- }
- }
- }
- /* If we get this far, we're either doing an update or a full fetch. */
- newt = Tinsert(&needT, t->Tname, TRUE);
- if (!newt)
- return (SCMERR);
- if (!fetch && S_ISREG(t->Tmode))
- newt->Tflags |= FUPDATE;
- return (SCMOK);
-}
-
-static int
-denyone(t, v)
- TREE *t;
- void *v;
-{
-
- vnotify("SUP: Access denied to %s\n", t->Tname);
- return (SCMOK);
-}
-
-static int
-deleteone(t, v)
- TREE *t;
- void *v;
-{
- struct stat sbuf, pbuf;
- int x;
- char *name = t->Tname;
- char pname[MAXPATHLEN];
-
- if (t->Tflags&FUPDATE) /* in current upgrade list */
- return (SCMOK);
- if (lstat(name, &sbuf) < 0) /* doesn't exist */
- return (SCMOK);
- /* is it a symbolic link ? */
- if (S_ISLNK(sbuf.st_mode)) {
- if (Tlookup(refuseT, name)) {
- vnotify("SUP Would not delete symbolic link %s\n",
- name);
- return (SCMOK);
- }
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would delete symbolic link %s\n", name);
- return (SCMOK);
- }
- if ((thisC->Cflags&CFDELETE) == 0) {
- notify("SUP Please delete symbolic link %s\n", name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- x = unlink(name);
- if (x < 0) {
- notify("SUP: Unable to delete symbolic link %s\n",
- name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- vnotify("SUP Deleted symbolic link %s\n", name);
- return (SCMOK);
- }
- /* is it a directory ? */
- if (S_ISDIR(sbuf.st_mode)) {
- if (Tlookup(refuseT, name)) {
- vnotify("SUP Would not delete directory %s\n", name);
- return (SCMOK);
- }
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would delete directory %s\n", name);
- return (SCMOK);
- }
- if ((thisC->Cflags&CFDELETE) == 0) {
- notify("SUP Please delete directory %s\n", name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- if (rmdir(name) < 0) {
- (void) chmod(name, sbuf.st_mode|S_IRWXU);
- if (snprintf(pname, sizeof(pname), "%s/..", name) <
- sizeof(pname)) {
- if (stat(pname, &pbuf) == 0)
- (void) chmod(pname,
- pbuf.st_mode|S_IRWXU);
- }
- runp("rm", "rm", "-rf", name, 0);
- }
- if (lstat(name, &sbuf) == 0) {
- notify("SUP: Unable to delete directory %s\n", name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- vnotify("SUP Deleted directory %s\n", name);
- return (SCMOK);
- }
- /* it is a file */
- if (Tlookup(refuseT, name)) {
- vnotify("SUP Would not delete file %s\n", name);
- return (SCMOK);
- }
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would delete file %s\n", name);
- return (SCMOK);
- }
- if ((thisC->Cflags&CFDELETE) == 0) {
- notify("SUP Please delete file %s\n", name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- x = unlink(name);
- if (x < 0) {
- notify("SUP: Unable to delete file %s\n", name);
- t->Tflags |= FUPDATE;
- return (SCMOK);
- }
- vnotify("SUP Deleted file %s\n", name);
- return (SCMOK);
-}
-
-/***************************************
- *** R E C E I V E F I L E S ***
- ***************************************/
-
-/*
- * Note for these routines, return code SCMOK generally means
- * NETWORK communication is OK; it does not mean that the current
- * file was correctly received and stored. If a file gets messed
- * up, too bad, just print a message and go on to the next one;
- * but if the network gets messed up, the whole sup program loses
- * badly and best just stop the program as soon as possible.
- */
-void recvfiles (void)
-{
- int x;
- int recvmore;
-
- /* Does the protocol support compression */
- if (cancompress) {
- /* Check for compression on sending files */
- docompress = (thisC->Cflags&CFCOMPRESS);
- x = msgcompress();
- if ( x != SCMOK)
- goaway("Error sending compression check to server");
- if (docompress)
- vnotify("SUP Using compressed file transfer\n");
- }
- recvmore = TRUE;
- upgradeT = NULL;
- do {
- x = msgsend();
- if (x != SCMOK)
- goaway("Error sending receive file request to file server");
- (void) Tinsert(&upgradeT, NULL, FALSE);
- x = msgrecv(recvone, &recvmore);
- if (x != SCMOK)
- goaway("Error receiving file from file server");
- Tfree(&upgradeT);
- } while (recvmore);
-}
-
-/* prepare the target, if necessary */
-int
-prepare(name, mode, newp, statp)
- char *name;
- int mode, *newp;
- struct stat *statp;
-{
- char *type;
- char pname[MAXPATHLEN];
- struct stat pbuf;
-
- if (mode == S_IFLNK)
- *newp = (lstat(name, statp) < 0);
- else
- *newp = (stat(name, statp) < 0);
- if (*newp) {
- if (thisC->Cflags&CFLIST)
- return (FALSE);
- if (establishdir(name))
- return (TRUE);
- return (FALSE);
- }
- if (mode == (statp->st_mode&S_IFMT))
- return (FALSE);
- *newp = TRUE;
- switch (statp->st_mode&S_IFMT) {
- case S_IFDIR:
- type = "directory";
- break;
- case S_IFLNK:
- type = "symbolic link";
- break;
- case S_IFREG:
- type = "regular file";
- break;
- default:
- type = "unknown file";
- break;
- }
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would remove %s %s\n", type, name);
- return (FALSE);
- }
- if (S_ISDIR(statp->st_mode)) {
- if (rmdir (name) < 0) {
- (void) chmod(name, statp->st_mode|S_IRWXU);
- if (snprintf(pname, sizeof(pname), "%s/..", name) <
- sizeof(pname)) {
- if (stat(pname, &pbuf) == 0)
- (void) chmod(pname,
- pbuf.st_mode|S_IRWXU);
- }
- runp ("rm", "rm", "-rf", name, 0);
- }
- } else
- (void) unlink(name);
- if (stat(name, statp) < 0) {
- vnotify("SUP Removed %s %s\n", type, name);
- return (FALSE);
- }
- notify("SUP: Couldn't remove %s %s\n", type, name);
- return (TRUE);
-}
-
-static int
-recvone(t, ap)
- TREE *t;
- va_list ap;
-{
- int x = 0;
- int new;
- struct stat sbuf;
- int *recvmore;
-
- recvmore = va_arg(ap, int *);
- va_end(ap);
- /* check for end of file list */
- if (t == NULL) {
- *recvmore = FALSE;
- return (SCMOK);
- }
- /* check for failed access at fileserver */
- if (t->Tmode == 0) {
- notify("SUP: File server unable to transfer file %s\n",
- t->Tname);
- thisC->Cnogood = TRUE;
- return (SCMOK);
- }
- if (prepare(t->Tname, t->Tmode&S_IFMT, &new, &sbuf)) {
- notify("SUP: Can't prepare path for %s\n", t->Tname);
- if (S_ISREG(t->Tmode)) {
- x = readskip(); /* skip over file */
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- }
- thisC->Cnogood = TRUE;
- return (SCMOK);
- }
- /* make file mode specific changes */
- switch (t->Tmode&S_IFMT) {
- case S_IFDIR:
- x = recvdir(t, new, &sbuf);
- break;
- case S_IFLNK:
- x = recvsym(t, new, &sbuf);
- break;
- case S_IFREG:
- x = recvreg(t, new, &sbuf);
- break;
- default:
- goaway("Unknown file type %o\n", t->Tmode&S_IFMT);
- }
- if (x) {
- thisC->Cnogood = TRUE;
- return (SCMOK);
- }
- if (S_ISREG(t->Tmode))
- (void) Tprocess(t->Tlink, linkone, t->Tname);
- (void) Tprocess(t->Texec, execone, NULL);
- return (SCMOK);
-}
-
-int
-recvdir(t, new, statp) /* receive directory from network */
- TREE *t;
- int new;
- struct stat *statp;
-{
- struct timeval tbuf[2];
-
- if (new) {
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would create directory %s\n", t->Tname);
- return (FALSE);
- }
- if (makedir(t->Tname, 0755, statp) == -1) {
- vnotify("SUP: Can't create directory %s\n", t->Tname);
- return TRUE;
- }
- }
- if ((t->Tflags&FNOACCT) == 0) {
- /* convert user and group names to local ids */
- ugconvert(t->Tuser, t->Tgroup, &t->Tuid, &t->Tgid, &t->Tmode);
- }
- if (!new && (t->Tflags&FNEW) == 0 && statp->st_mtime == t->Tmtime) {
- if (t->Tflags&FNOACCT)
- return (FALSE);
- if (statp->st_uid == t->Tuid && statp->st_gid == t->Tgid)
- return (FALSE);
- }
- if (thisC->Cflags&CFLIST) {
- vnotify ("SUP Would update directory %s\n", t->Tname);
- return (FALSE);
- }
- if ((t->Tflags&FNOACCT) == 0) {
- (void) chown(t->Tname, t->Tuid, t->Tgid);
- (void) chmod(t->Tname, t->Tmode&S_IMODE);
- }
- tbuf[0].tv_sec = time(NULL);
- tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = t->Tmtime;
- tbuf[1].tv_usec = 0;
- if (!noutime)
- (void) utimes(t->Tname, tbuf);
- if (new)
- vnotify("SUP Created directory %s\n", t->Tname);
- else
- v2notify("SUP Updated directory %s\n", t->Tname);
- return (FALSE);
-}
-
-int
-recvsym(t, new, statp) /* receive symbolic link */
- TREE *t;
- int new;
- struct stat *statp;
-{
- char buf[STRINGLENGTH];
- int n;
- char *linkname;
-
- if (t->Tlink == NULL || t->Tlink->Tname == NULL) {
- notify("SUP: Missing linkname for symbolic link %s\n",
- t->Tname);
- return (TRUE);
- }
- linkname = t->Tlink->Tname;
- memset(buf, 0, sizeof(buf));
- if (!new && (t->Tflags&FNEW) == 0 &&
- (n = readlink(t->Tname, buf, sizeof(buf)-1)) >= 0 &&
- (n == strlen(linkname)) && (strncmp (linkname, buf, n) == 0))
- return (FALSE);
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would %s symbolic link %s to %s\n",
- new ? "create" : "update", t->Tname, linkname);
- return (FALSE);
- }
- if (!new)
- (void) unlink(t->Tname);
- if (symlink(linkname, t->Tname) < 0 || lstat(t->Tname, statp) < 0) {
- notify("SUP: Unable to create symbolic link %s\n", t->Tname);
- return (TRUE);
- }
- vnotify("SUP Created symbolic link %s to %s\n", t->Tname, linkname);
- return (FALSE);
-}
-
-int
-recvreg(t, new, statp) /* receive file from network */
- TREE *t;
- int new;
- struct stat *statp;
-{
- FILE *fin, *fout;
- char dirpart[STRINGLENGTH], filepart[STRINGLENGTH];
- char filename[STRINGLENGTH], buf[STRINGLENGTH];
- struct timeval tbuf[2];
- int x;
- char *p;
-
- if (t->Tflags&FUPDATE) {
- if ((t->Tflags&FNOACCT) == 0) {
- /* convert user and group names to local ids */
- ugconvert(t->Tuser, t->Tgroup, &t->Tuid, &t->Tgid,
- &t->Tmode);
- }
- if (!new && (t->Tflags&FNEW) == 0 &&
- statp->st_mtime == t->Tmtime) {
- if (t->Tflags&FNOACCT)
- return (FALSE);
- if (statp->st_uid == t->Tuid &&
- statp->st_gid == t->Tgid)
- return (FALSE);
- }
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would update file %s\n", t->Tname);
- return (FALSE);
- }
- vnotify("SUP Updating file %s\n", t->Tname);
- if ((t->Tflags&FNOACCT) == 0) {
- (void) chown(t->Tname, t->Tuid, t->Tgid);
- (void) chmod(t->Tname, t->Tmode&S_IMODE);
- }
- tbuf[0].tv_sec = time(NULL);
- tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = t->Tmtime;
- tbuf[1].tv_usec = 0;
- if (!noutime)
- (void) utimes(t->Tname, tbuf);
- return (FALSE);
- }
- if (thisC->Cflags&CFLIST) {
- if (new)
- p = "create";
- else if (statp->st_mtime < t->Tmtime)
- p = "receive new";
- else if (statp->st_mtime > t->Tmtime)
- p = "receive old";
- else
- p = "receive";
- vnotify("SUP Would %s file %s\n", p, t->Tname);
- return (FALSE);
- }
- vnotify("SUP Receiving file %s\n", t->Tname);
- if (!new && S_ISREG(t->Tmode) &&
- (t->Tflags&FBACKUP) && (thisC->Cflags&CFBACKUP)) {
- fin = fopen(t->Tname, "r"); /* create backup */
- if (fin == NULL) {
- x = readskip(); /* skip over file */
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- notify("SUP: Can't open %s to create backup\n",
- t->Tname);
- return (TRUE); /* mark upgrade as nogood */
- }
- path(t->Tname, dirpart, sizeof dirpart, filepart, sizeof filepart);
- (void) snprintf(filename, sizeof filename, FILEBACKUP,
- dirpart, filepart);
- fout = fopen(filename, "w");
- if (fout == NULL) {
- (void) snprintf(buf, sizeof buf, FILEBKDIR, dirpart);
- (void) mkdir(buf, 0755);
- fout = fopen(filename, "w");
- }
- if (fout == NULL) {
- x = readskip(); /* skip over file */
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- notify("SUP: Can't create %s for backup\n", filename);
- (void) fclose(fin);
- return (TRUE);
- }
- ffilecopy(fin, fout);
- (void) fclose(fin);
- (void) fclose(fout);
- vnotify("SUP Backup of %s created\n", t->Tname);
- }
- x = copyfile(t->Tname, NULL);
- if (x)
- return (TRUE);
- if ((t->Tflags&FNOACCT) == 0) {
- /* convert user and group names to local ids */
- ugconvert(t->Tuser, t->Tgroup, &t->Tuid, &t->Tgid, &t->Tmode);
- (void) chown(t->Tname, t->Tuid, t->Tgid);
- (void) chmod(t->Tname, t->Tmode&S_IMODE);
- }
- tbuf[0].tv_sec = time(NULL);
- tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = t->Tmtime;
- tbuf[1].tv_usec = 0;
- if (!noutime)
- (void) utimes(t->Tname, tbuf);
- return (FALSE);
-}
-
-static int
-linkone(t, fv) /* link to file already received */
- TREE *t;
- void *fv;
-{
- char *fname = fv;
- struct stat fbuf,sbuf;
- char *name = t->Tname;
- int new,x;
- char *type;
-
- if (stat(fname, &fbuf) < 0) { /* source file */
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would link %s to %s\n", name, fname);
- return (SCMOK);
- }
- notify("SUP: Can't link %s to missing file %s\n", name, fname);
- thisC->Cnogood = TRUE;
- return (SCMOK);
- }
- if (prepare(name,S_IFREG, &new, &sbuf)) {
- notify("SUP: Can't prepare path for link %s\n", name);
- thisC->Cnogood = TRUE;
- return (SCMOK);
- }
- if (!new && (t->Tflags&FNEW) == 0 &&
- fbuf.st_dev == sbuf.st_dev && fbuf.st_ino == sbuf.st_ino)
- return (SCMOK);
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would link %s to %s\n", name, fname);
- return (SCMOK);
- }
- (void) unlink(name);
- type = "";
- if ((x = link(fname,name)) < 0) {
- type = "symbolic ";
- x = symlink(fname, name);
- }
- if (x < 0 || lstat(name, &sbuf) < 0) {
- notify ("SUP: Unable to create %slink %s\n", type, name);
- return (TRUE);
- }
- vnotify("SUP Created %slink %s to %s\n", type, name, fname);
- return (SCMOK);
-}
-
-static int
-execone(t, v) /* execute command for file */
- TREE *t;
- void *v;
-{
- int w;
-
- if (thisC->Cflags&CFLIST) {
- vnotify("SUP Would execute %s\n", t->Tname);
- return (SCMOK);
- }
- if ((thisC->Cflags&CFEXECUTE) == 0) {
- notify("SUP Please execute %s\n", t->Tname);
- return (SCMOK);
- }
- vnotify("SUP Executing %s\n", t->Tname);
-
- w = system(t->Tname);
- if (WIFEXITED(w) && WEXITSTATUS(w) != 0) {
- notify("SUP: Execute command returned failure status %#o\n",
- WEXITSTATUS(w));
- thisC->Cnogood = TRUE;
- } else if (WIFSIGNALED(w)) {
- notify("SUP: Execute command killed by signal %d\n",
- WTERMSIG(w));
- thisC->Cnogood = TRUE;
- } else if (WIFSTOPPED(w)) {
- notify("SUP: Execute command stopped by signal %d\n",
- WSTOPSIG(w));
- thisC->Cnogood = TRUE;
- }
- return (SCMOK);
-}
-
-int
-copyfile(to, from)
- char *to;
- char *from; /* 0 if reading from network */
-{
- int fromf, tof, istemp, x;
- char dpart[STRINGLENGTH], fpart[STRINGLENGTH];
- char tname[MAXPATHLEN];
- static int true = 1;
- static pid_t thispid = 0; /* process id # */
-
- if (from) { /* reading file */
- fromf = open(from, O_RDONLY, 0);
- if (fromf < 0) {
- notify("SUP: Can't open %s to copy to %s: %s\n",
- from, to, errmsg(-1));
- return (TRUE);
- }
- } else /* reading network */
- fromf = -1;
- istemp = TRUE; /* try to create temp file */
- lockout(TRUE); /* block interrupts */
- if (thispid == 0)
- thispid = getpid();
- /* Now try hard to find a temp file name. Try VERY hard. */
- for (;;) {
- /* try destination directory */
- path(to, dpart, sizeof dpart, fpart, sizeof fpart);
- (void) snprintf(tname, sizeof tname, "%s/#%ld.sup.XXXXXXXXXX",
- dpart, (long)thispid);
- tof = mkstemp(tname);
- if (tof >= 0)
- break;
- /* try sup directory */
- if (thisC->Cprefix)
- (void) chdir (thisC->Cbase);
- (void) snprintf(tname, sizeof tname, "sup/#%ld.sup.XXXXXXXXXX",
- (long)thispid);
- tof = mkstemp(tname);
- if (tof >= 0) {
- if (thisC->Cprefix)
- (void) chdir(thisC->Cprefix);
- break;
- }
- /* try base directory */
- (void) snprintf(tname, sizeof tname, "#%ld.sup.XXXXXXXXXX",
- (long)thispid);
- tof = mkstemp(tname);
- if (thisC->Cprefix)
- (void) chdir(thisC->Cprefix);
- if (tof >= 0)
- break;
-#ifdef VAR_TMP
- /* try /var/tmp */
- (void) snprintf(tname, sizeof tname,
- "/var/tmp/#%ld.sup.XXXXXXXXXX", (long)thispid);
- tof = mkstemp(tname);
- if (tof >= 0)
- break;
-#else
- /* try /usr/tmp */
- (void) snprintf(tname, sizeof tname,
- "/usr/tmp/#%ld.sup.XXXXXXXXXX", (long)thispid);
- tof = mkstemp(tname);
- if (tof >= 0)
- break;
-#endif
- /* try /tmp */
- (void) snprintf(tname, sizeof tname,
- "/tmp/#%ld.sup.XXXXXXXXXX", (long)thispid);
- tof = mkstemp(tname);
- if (tof >= 0)
- break;
- istemp = FALSE;
- /* give up: try to create output file */
- if (!docompress)
- tof = open(to, (O_WRONLY|O_CREAT|O_TRUNC), 0600);
- if (tof >= 0)
- break;
- /* no luck */
- notify("SUP: Can't create %s or temp file for it\n", to);
- lockout (FALSE);
- if (fromf >= 0)
- (void) close (fromf);
- else {
- x = readskip();
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- }
- if (true)
- return (TRUE);
- }
- if (fromf >= 0) { /* read file */
- x = filecopy(fromf, tof);
- (void) close(fromf);
- (void) close(tof);
- if (x < 0) {
- notify("SUP: Error in copying %s to %s\n", from, to);
- if (istemp)
- (void) unlink(tname);
- lockout(FALSE);
- return (TRUE);
- }
- } else { /* read network */
-#if MACH
- if (!rpauseflag) {
- int fsize;
- struct fsparam fsp;
-
- x = prereadcount(&fsize);
- if (x != SCMOK) {
- if (istemp)
- (void) unlink(tname);
- lockout(FALSE);
- x = readskip();
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- goaway("Error in server space check");
- logquit(1, "Error in server space check");
- }
- errno = 0;
- if (ioctl(tof, FIOCFSPARAM, (char *)&fsp) < 0 &&
- errno != EINVAL) {
- if (istemp)
- (void) unlink(tname);
- lockout(FALSE);
- x = readskip();
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- goaway("Error in disk space check");
- logquit(1, "Error in disk space check");
- }
- if (errno == 0) {
- fsize = (fsize + 1023) / 1024;
- x = fsp.fsp_size * MAX (fsp.fsp_minfree, 1) / 100;
- fsp.fsp_free -= x;
- if (fsize > MAX (fsp.fsp_free, 0)) {
- if (istemp)
- (void) unlink(tname);
- lockout(FALSE);
- x = readskip();
- if (x != SCMOK)
- goaway("Can't skip file transfer");
- goaway("No disk space for file %s", to);
- logquit (1, "No disk space for file %s",
- to);
- }
- }
- }
-#endif /* MACH */
- x = readfile(tof);
- (void) close(tof);
- if (x != SCMOK) {
- if (istemp)
- (void) unlink(tname);
- lockout(FALSE);
- goaway("Error in receiving %s\n", to);
- }
- }
- if (!istemp) { /* no temp file used */
- lockout(FALSE);
- return (FALSE);
- }
- /*
- * If the file is compressed, uncompress it in place. We open the
- * temp file for reading, unlink the file, and then open the same
- * file again for writing. Then we pipe through gzip. When
- * finished the temp file contains the uncompressed version and we
- * can continue as before.
- *
- * Since sup prefers to write close to the original file the
- * benefits of atomic updates probably outweigh the cost of the
- * extra filecopy which occurs when the temp file is on a different
- * filesystem from the original.
- */
- if (docompress) {
- char *av[4];
- int ac = 0;
- int infd = -1;
- int outfd = -1;
- av[ac++] = "gzip";
- av[ac++] = "-d";
- av[ac++] = NULL;
- /* XXX - race between unlink and re-open */
- if ((infd = open(tname, O_RDONLY, 0)) == -1 ||
- unlink(tname) == -1 ||
- (outfd = open(tname, O_WRONLY|O_CREAT|O_EXCL, 0600)) == -1 ||
- runiofd(av, infd, outfd, 2) != 0 ) {
- notify("SUP: Error in uncompressing file %s (%s)\n",
- to, tname);
- (void) unlink(tname);
- if (infd != -1)
- (void) close(infd);
- if (outfd != -1)
- (void) close(outfd);
- lockout(FALSE);
- return(TRUE);
- }
- (void) close(infd);
- (void) close(outfd);
- }
- /* move to destination */
- if (rename(tname, to) == 0) {
- (void) unlink(tname);
- lockout(FALSE);
- return(FALSE);
- }
- fromf = open(tname, O_RDONLY, 0);
- if (fromf < 0) {
- notify ("SUP: Error in moving temp file to %s: %s\n",
- to, errmsg (-1));
- (void) unlink(tname);
- lockout(FALSE);
- return (TRUE);
- }
- tof = open(to, O_WRONLY|O_CREAT|O_TRUNC, 0600);
- if (tof < 0) {
- (void) close(fromf);
- notify("SUP: Can't create %s from temp file: %s\n",
- to, errmsg(-1));
- (void) unlink(tname);
- lockout(FALSE);
- return (TRUE);
- }
- x = filecopy(fromf, tof);
- (void) close(fromf);
- (void) close(tof);
- (void) unlink(tname);
- lockout(FALSE);
- if (x < 0) {
- notify("SUP: Error in storing data in %s\n", to);
- return (TRUE);
- }
- return (FALSE);
-}
-
-/*** Finish connection with file server ***/
-
-void
-finishup(x)
- int x;
-{
- char tname[STRINGLENGTH], fname[STRINGLENGTH];
- char relsufix[STRINGLENGTH];
- char collrelname[STRINGLENGTH];
- time_t tloc;
- FILE *finishfile; /* record of all filenames */
-
- if ((thisC->Cflags&CFURELSUF) && release) {
- (void) snprintf(relsufix, sizeof relsufix, ".%s", release);
- (void) snprintf(collrelname, sizeof collrelname,
- "%s-%s", collname, release);
- } else {
- relsufix[0] = '\0';
- (void) strlcpy(collrelname, collname, sizeof collrelname);
- }
- dontjump = TRUE; /* once here, no more longjmp */
- (void) netcrypt(NULL);
- if (protver < 6) {
- /* done with server */
- if (x == SCMOK)
- goaway(NULL);
- (void) requestend();
- }
- tloc = time(NULL);
- if (x != SCMOK) {
- notify("SUP: Upgrade of %s aborted at %s", collrelname,
- ctime(&tloc) + 4);
- Tfree(&lastT);
- if (protver < 6)
- return;
- /* if we've not been blown off, make sure he is! */
- if (x != SCMEOF)
- goaway("Aborted");
- (void) requestend();
- return;
- }
- if (thisC->Cnogood) {
- notify("SUP: Upgrade of %s completed with errors at %s",
- collrelname, ctime(&tloc) + 4);
- notify("SUP: Upgrade time will not be updated\n");
- Tfree(&lastT);
- if (protver < 6)
- return;
- done(FDONEUSRERROR, "Completed with errors");
- (void) requestend();
- return;
- }
- if (thisC->Cprefix)
- (void) chdir(thisC->Cbase);
- vnotify("SUP Upgrade of %s completed at %s", collrelname,
- ctime(&tloc) + 4);
- if (thisC->Cflags&CFLIST) {
- Tfree(&lastT);
- if (protver < 6)
- return;
- done(FDONEDONTLOG, "List only");
- (void) requestend();
- return;
- }
- (void) snprintf(fname, sizeof fname, FILEWHEN, collname, relsufix);
- if (establishdir(fname)) {
- notify("SUP: Can't create directory for upgrade timestamp\n");
- Tfree(&lastT);
- if (protver < 6)
- return;
- done(FDONEUSRERROR, "Couldn't timestamp");
- (void) requestend();
- return;
- }
- if (!putwhen(fname, scantime)) {
- notify("SUP: Can't record current time in %s: %s\n",
- fname,errmsg (-1));
- Tfree(&lastT);
- if (protver < 6)
- return;
- done(FDONEUSRERROR,"Couldn't timestamp");
- (void) requestend();
- return;
- }
- if (protver >= 6) {
- /*
- * At this point we have let the server go
- * "I'm sorry, we've had to let you go"
- */
- done(FDONESUCCESS, "Success");
- (void) requestend();
- }
- (void) snprintf(tname, sizeof tname, FILELASTTEMP, collname, relsufix);
- finishfile = fopen(tname, "w");
- if (finishfile == NULL) {
- notify("SUP: Can't record list of all files in %s\n", tname);
- Tfree(&lastT);
- return;
- }
- (void) Tprocess(lastT, finishone, finishfile);
- (void) fclose(finishfile);
- (void) snprintf(fname, sizeof fname, FILELAST, collname, relsufix);
- if (rename(tname, fname) < 0)
- notify("SUP: Can't change %s to %s\n", tname, fname);
- (void) unlink(tname);
- Tfree(&lastT);
-}
-
-int
-finishone(t, fv)
- TREE *t;
- void *fv;
-{
- FILE *finishfile = fv;
-
- if ((thisC->Cflags&CFDELETE) == 0 || (t->Tflags&FUPDATE))
- fprintf(finishfile, "%s\n", t->Tname);
- return (SCMOK);
-}
-
-void
-done (int value,char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap, fmt);
- (void) netcrypt(NULL);
-
- if (fmt)
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- if (protver < 6) {
- if (goawayreason)
- free(goawayreason);
- goawayreason = (fmt) ? strdup(buf) : NULL;
- (void) msggoaway();
- }
- else {
- doneack = value;
- donereason = (fmt) ? buf : NULL;
- (void) msgdone();
- }
- if (!dontjump)
- longjmp(sjbuf, TRUE);
-}
-
-void
-goaway (char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap, fmt);
- (void) netcrypt (NULL);
- if (fmt) {
- vsnprintf(buf, sizeof(buf), fmt, ap);
- goawayreason = buf;
- } else
- goawayreason = NULL;
- va_end(ap);
- (void) msggoaway();
- if (fmt) {
- if (thisC)
- notify("SUP: %s\n", buf);
- else
- printf("SUP: %s\n", buf);
- }
- if (!dontjump)
- longjmp(sjbuf,TRUE);
-}
diff --git a/usr.bin/sup/src/supcmisc.c b/usr.bin/sup/src/supcmisc.c
deleted file mode 100644
index a98344c473e..00000000000
--- a/usr.bin/sup/src/supcmisc.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/* $OpenBSD: supcmisc.c,v 1.16 2007/05/17 11:00:37 moritz Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * sup misc. routines, include list processing.
- **********************************************************************
- * HISTORY
- * Revision 1.5 92/08/11 12:07:22 mrt
- * Added release to FILEWHEN name.
- * Brad's changes: delinted and updated variable argument usage.
- * [92/07/26 mrt]
- *
- * Revision 1.3 89/08/15 15:31:28 bww
- * Updated to use v*printf() in place of _doprnt().
- * From "[89/04/19 mja]" at CMU.
- * [89/08/15 bww]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed bug in ugconvert() which left pw uninitialized.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split off from sup.c and changed goaway to use printf
- * instead of notify if thisC is NULL.
- *
- **********************************************************************
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-#include <limits.h>
-
-#ifndef UID_MAX
-#define UID_MAX ((uid_t)-1)
-#endif
-
-struct liststruct { /* uid and gid lists */
- char *Lname; /* name */
- int Lnumber; /* uid or gid */
- struct liststruct *Lnext;
-};
-typedef struct liststruct LIST;
-
-#define HASHBITS 4
-#define HASHSIZE (1<<HASHBITS)
-#define HASHMASK (HASHSIZE-1)
-#define LISTSIZE (HASHSIZE*HASHSIZE)
-
-static LIST *uidL[LISTSIZE]; /* uid and gid lists */
-static LIST *gidL[LISTSIZE];
-
-extern COLLECTION *thisC; /* collection list pointer */
-
-static int Lhash(char *);
-static void Linsert(LIST **, char *, int);
-static LIST *Llookup(LIST **, char *);
-
-/*************************************************
- *** P R I N T U P D A T E T I M E S ***
- *************************************************/
-
-void
-prtime()
-{
- char buf[STRINGLENGTH];
- char relsufix[STRINGLENGTH];
- time_t twhen;
-
- if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) snprintf(relsufix, sizeof relsufix, ".%s",
- thisC->Crelease);
- else
- relsufix[0] = '\0';
- if (chdir(thisC->Cbase) < 0)
- logerr("Can't change to base directory %s for collection %s",
- thisC->Cbase, thisC->Cname);
- twhen = getwhen(thisC->Cname, relsufix);
- (void) strlcpy(buf, ctime(&twhen), sizeof buf);
- buf[strlen(buf)-1] = '\0'; /* strip newline */
- loginfo("Last update occurred at %s for collection %s%s",
- buf, thisC->Cname, relsufix);
-}
-
-int
-establishdir(fname)
- char *fname;
-{
- char dpart[STRINGLENGTH], fpart[STRINGLENGTH];
-
- path(fname, dpart, sizeof dpart, fpart, sizeof fpart);
- return (estabd(fname, dpart));
-}
-
-int
-makedir(fname, mode, statp)
- char *fname;
- int mode;
- struct stat *statp;
-{
- if (lstat(fname, statp) != -1 && !S_ISDIR(statp->st_mode)) {
- if (unlink(fname) == -1) {
- notify("SUP: Can't delete %s\n", fname);
- return (-1);
- }
- }
-
- (void) mkdir(fname, 0755);
-
- return (stat(fname, statp));
-}
-
-int
-estabd(fname, dname)
- char *fname, *dname;
-{
- char dpart[STRINGLENGTH], fpart[STRINGLENGTH];
- struct stat sbuf;
- int x;
-
- if (stat(dname, &sbuf) >= 0)
- return (FALSE); /* exists */
- path(dname, dpart, sizeof dpart, fpart, sizeof fpart);
- if (strcmp(fpart,".") == 0) { /* dname is / or . */
- notify("SUP: Can't create directory %s for %s\n", dname, fname);
- return (TRUE);
- }
- x = estabd(fname, dpart);
- if (x)
- return (TRUE);
- if (makedir(dname, 0755, &sbuf) < 0) {
- vnotify("SUP: Can't create directory %s for %s\n",
- dname, fname);
- return TRUE;
- }
- vnotify("SUP Created directory %s for %s\n", dname, fname);
- return (FALSE);
-}
-
-/***************************************
- *** L I S T R O U T I N E S ***
- ***************************************/
-
-/*
- * Hash function is: HASHSIZE * (strlen mod HASHSIZE)
- * + (char mod HASHSIZE)
- * where "char" is last character of name (if name is non-null).
- */
-static int
-Lhash(name)
- char *name;
-{
- int len;
- char c;
-
- len = strlen(name);
- if (len > 0)
- c = name[len-1];
- else
- c = 0;
- return (((len&HASHMASK)<<HASHBITS)|(((int)c)&HASHMASK));
-}
-
-static void
-Linsert(table, name, number)
- LIST **table;
- char *name;
- int number;
-{
- LIST *l;
- int lno;
- lno = Lhash(name);
- l = (LIST *) malloc(sizeof(LIST));
- l->Lname = name;
- l->Lnumber = number;
- l->Lnext = table[lno];
- table[lno] = l;
-}
-
-static LIST *
-Llookup(table, name)
- LIST **table;
- char *name;
-{
- int lno;
- LIST *l;
-
- lno = Lhash(name);
- for (l = table[lno]; l && strcmp(l->Lname,name) != 0; l = l->Lnext)
- ;
- return (l);
-}
-
-void
-ugconvert(uname, gname, uid, gid, mode)
- char *uname, *gname;
- uid_t *uid;
- gid_t *gid;
- int *mode;
-{
- LIST *u, *g;
- struct passwd *pw;
- struct group *gr;
- struct stat sbuf;
- static uid_t defuid = UID_MAX;
- static gid_t defgid;
- static int first = TRUE;
-
- if (first) {
- memset(uidL, 0, sizeof(uidL));
- memset(gidL, 0, sizeof(gidL));
- first = FALSE;
- }
- pw = NULL;
- if ((u = Llookup(uidL, uname)) != NULL)
- *uid = (uid_t) u->Lnumber;
- else if ((pw = getpwnam(uname)) != NULL) {
- Linsert(uidL, strdup(uname), pw->pw_uid);
- *uid = pw->pw_uid;
- }
- if (u || pw) {
- if ((g = Llookup(gidL, gname)) != NULL) {
- *gid = (gid_t) g->Lnumber;
- return;
- }
- if ((gr = getgrnam(gname)) != NULL) {
- Linsert(gidL, strdup(gname), gr->gr_gid);
- *gid = gr->gr_gid;
- return;
- }
- if (pw == NULL && (pw = getpwnam(uname)) == NULL)
- goto defids;
- *mode &= ~S_ISGID;
- *gid = pw->pw_gid;
- return;
- }
-defids:
- *mode &= ~(S_ISUID|S_ISGID);
- if (defuid != UID_MAX) {
- *uid = defuid;
- *gid = defgid;
- return;
- }
- if (stat(".", &sbuf) < 0) {
- *uid = defuid = getuid();
- *gid = defgid = getgid();
- return;
- }
- *uid = defuid = sbuf.st_uid;
- *gid = defgid = sbuf.st_gid;
-}
-
-
-/*********************************************
- *** U T I L I T Y R O U T I N E S ***
- *********************************************/
-
-void
-notify (char *fmt,...) /* record error message */
-{
- char buf[STRINGLENGTH];
- char collrelname[STRINGLENGTH];
- time_t tloc;
- static FILE *noteF = NULL; /* mail program on pipe */
- va_list ap;
-
- va_start(ap, fmt);
- if (fmt == NULL) {
- if (noteF && noteF != stdout)
- (void) pclose(noteF);
- noteF = NULL;
- return;
- }
- if ((thisC->Cflags&CFURELSUF) && thisC->Crelease)
- (void) snprintf(collrelname, sizeof collrelname, "%s-%s",
- collname, thisC->Crelease);
- else
- (void) strlcpy(collrelname, collname, sizeof collrelname);
-
- if (noteF == NULL) {
- /* XXX - it would be nicer to run sendmail directly (millert) */
- if ((thisC->Cflags&CFMAIL) && thisC->Cnotify) {
- (void) snprintf(buf, sizeof buf,
- "mail -s \"SUP Upgrade of %s\" %s >/dev/null",
- collrelname, thisC->Cnotify);
- noteF = popen(buf, "w");
- if (noteF == NULL) {
- logerr ("Can't send mail to %s for %s",
- thisC->Cnotify, collrelname);
- noteF = stdout;
- }
- } else
- noteF = stdout;
- tloc = time(NULL);
- fprintf(noteF, "SUP Upgrade of %s at %s", collrelname,
- ctime(&tloc));
- (void) fflush(noteF);
- }
- vfprintf(noteF, fmt, ap);
- va_end(ap);
- (void) fflush(noteF);
-}
-
-void
-lockout(on) /* lock out interrupts */
- int on;
-{
- static sigset_t oset;
- sigset_t nset;
-
- if (on) {
- sigemptyset(&nset);
- sigaddset(&nset, SIGHUP);
- sigaddset(&nset, SIGINT);
- sigaddset(&nset, SIGTERM);
- sigaddset(&nset, SIGQUIT);
- (void) sigprocmask(SIG_BLOCK, &nset, &oset);
- } else {
- (void) sigprocmask(SIG_SETMASK, &oset, NULL);
- }
-}
-
-char *
-fmttime(time)
- time_t time;
-{
- static char buf[16];
- char *p;
-
- /*
- * Copy ctime to buf, stripping day of week, year, and newline.
- * E.g.: "Thu Nov 24 18:22:48 1986\n" -> "Nov 24 18:22:48"
- */
- p = ctime(&time) + 4;
- (void) strlcpy(buf, p, sizeof(buf));
- return (buf);
-}
diff --git a/usr.bin/sup/src/supcname.c b/usr.bin/sup/src/supcname.c
deleted file mode 100644
index fd468bd2974..00000000000
--- a/usr.bin/sup/src/supcname.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* $OpenBSD: supcname.c,v 1.8 2007/09/11 15:47:17 gilles Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * sup client name server interface
- **********************************************************************
- * HISTORY
- * Revision 1.4 92/08/11 12:07:32 mrt
- * Added copyright.
- * [92/08/10 mrt]
- *
- * 21-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed to no longer use a name server.
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Changed getnams and added several new routines to change the
- * way that sup finds nameservers. It now builds a tree of
- * servers to check. It walks over the tree. At each node, it
- * tries to contact the name server and get as many names
- * resolved as it can. It stops after either all collections
- * have host names, or if some collections don't have host names
- * but either everyone doesn't know what they are, or after too
- * many tries, none could be reached.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split off from sup.c
- *
- **********************************************************************
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-extern COLLECTION *firstC; /* collection list pointer */
-
-/*****************************************
- *** G E T H O S T N A M E S ***
- *****************************************/
-
-/*
- * For each collection that doesn't have a host name specified, read
- * the file server list for the name of the host for that collection.
- * It's a fatal error if a collection has no file server.
- */
-
-void
-getnams()
-{
- COLLECTION *c;
- char buf[STRINGLENGTH];
- FILE *f;
- char *p, *q;
-
- for (c = firstC; c && c->Chtree != NULL; c = c->Cnext)
- ;
- if (c == NULL)
- return;
- (void) snprintf(buf, sizeof buf, FILEHOSTS, DEFDIR);
- f = fopen(buf, "r");
- if (f == NULL)
- logquit (1, "Can't open %s", buf);
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, "= \t");
- p = skipover(p, " \t");
- if (*p == '=')
- p++;
- p = skipover(p, " \t");
- if (*p == '\0')
- goaway("error in collection/host file");
- do {
- if (strcmp(c->Cname, q) == 0) {
- do {
- q = nxtarg(&p, ", \t");
- p = skipover(p, " \t");
- if (*p == ',')
- p++;
- p = skipover(p, " \t");
- (void) Tinsert(&c->Chtree, q, FALSE);
- } while (*p != '\0');
- }
- while ((c = c->Cnext) != NULL && c->Chtree != NULL)
- ;
- } while (c != NULL);
- for (c = firstC; c && c->Chtree != NULL; c = c->Cnext)
- ;
- if (c == NULL)
- break;
- }
- (void) fclose(f);
- if (c == NULL)
- return;
- do {
- logerr ("Host for collection %s not found", c->Cname);
- while ((c = c->Cnext) != NULL && c->Chtree != NULL)
- ;
- } while (c);
- logquit(1, "Hosts not found for all collections");
-}
diff --git a/usr.bin/sup/src/supcparse.c b/usr.bin/sup/src/supcparse.c
deleted file mode 100644
index 1820b0ace39..00000000000
--- a/usr.bin/sup/src/supcparse.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/* $OpenBSD: supcparse.c,v 1.9 2003/09/05 03:28:27 tedu Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * sup collection parsing routines
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.6 92/08/11 12:07:38 mrt
- * Added use-rel-suffix option corresponding to -u switch.
- * [92/07/26 mrt]
- *
- * Revision 1.5 92/02/08 18:24:19 mja
- * Added "keep" supfile option, corresponding to -k switch.
- * [92/01/17 vdelvecc]
- *
- * Revision 1.4 91/05/16 14:49:50 ern
- * Change default timeout from none to 3 hours so we don't accumalute
- * processes running sups to dead hosts especially for users.
- * [91/05/16 14:49:21 ern]
- *
- *
- * 10-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added timeout to backoff.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support. Removed obsolete options.
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split off from sup.c
- *
- **********************************************************************
- */
-
-#include "supcdefs.h"
-#include "supextern.h"
-
-
-#ifdef lint
-static char _argbreak;
-#else
-extern char _argbreak; /* break character from nxtarg */
-#endif
-
-typedef enum { /* supfile options */
- OHOST, OBASE, OHOSTBASE, OPREFIX, ORELEASE,
- ONOTIFY, OLOGIN, OPASSWORD, OCRYPT,
- OBACKUP, ODELETE, OEXECUTE, OOLD, OTIMEOUT, OKEEP, OURELSUF,
- OCOMPRESS
-} OPTION;
-
-struct option {
- char *op_name;
- OPTION op_enum;
-} options[] = {
- { "host", OHOST },
- { "base", OBASE },
- { "hostbase", OHOSTBASE },
- { "prefix", OPREFIX },
- { "release", ORELEASE },
- { "notify", ONOTIFY },
- { "login", OLOGIN },
- { "password", OPASSWORD },
- { "crypt", OCRYPT },
- { "backup", OBACKUP },
- { "delete", ODELETE },
- { "execute", OEXECUTE },
- { "old", OOLD },
- { "timeout", OTIMEOUT },
- { "keep", OKEEP },
- { "use-rel-suffix", OURELSUF },
- { "compress", OCOMPRESS }
-};
-
-static void passdelim(char **, int );
-
-static void
-passdelim(ptr, delim) /* skip over delimiter */
- char **ptr, delim;
-{
- *ptr = skipover(*ptr, " \t");
- if (_argbreak != delim && **ptr == delim) {
- (*ptr)++;
- *ptr = skipover(*ptr, " \t");
- }
-}
-
-int
-parsecoll(c, collname, args)
- COLLECTION *c;
- char *collname, *args;
-{
- char *arg, *p;
- OPTION option;
- int opno;
-
- c->Cnext = NULL;
- c->Cname = strdup(collname);
- c->Chost = NULL;
- c->Chtree = NULL;
- c->Cbase = NULL;
- c->Chbase = NULL;
- c->Cprefix = NULL;
- c->Crelease = NULL;
- c->Cnotify = NULL;
- c->Clogin = NULL;
- c->Cpswd = NULL;
- c->Ccrypt = NULL;
- c->Ctimeout = 3*60*60; /* default to 3 hours instead of no timeout */
- c->Cflags = 0;
- c->Cnogood = FALSE;
- c->Clockfd = -1;
- args = skipover(args, " \t");
- while (*(arg = nxtarg(&args, " \t="))) {
- for (opno = 0; opno < sizeofA(options); opno++)
- if (strcmp(arg, options[opno].op_name) == 0)
- break;
- if (opno == sizeofA(options)) {
- logerr("Invalid supfile option %s for collection %s",
- arg, c->Cname);
- return (-1);
- }
- option = options[opno].op_enum;
- switch (option) {
- case OHOST:
- passdelim(&args, '=');
- do {
- arg = nxtarg(&args, ", \t");
- (void) Tinsert(&c->Chtree, arg, FALSE);
- arg = args;
- p = skipover(args, " \t");
- if (*p++ == ',')
- args = p;
- } while (arg != args);
- break;
- case OBASE:
- passdelim (&args, '=');
- arg = nxtarg (&args, " \t");
- c->Cbase = strdup(arg);
- break;
- case OHOSTBASE:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Chbase = strdup(arg);
- break;
- case OPREFIX:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Cprefix = strdup(arg);
- break;
- case ORELEASE:
- passdelim(&args, '=');
- arg = nxtarg (&args, " \t");
- c->Crelease = strdup(arg);
- break;
- case ONOTIFY:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Cnotify = strdup(arg);
- break;
- case OLOGIN:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Clogin = strdup(arg);
- break;
- case OPASSWORD:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Cpswd = strdup(arg);
- break;
- case OCRYPT:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Ccrypt = strdup(arg);
- break;
- case OBACKUP:
- c->Cflags |= CFBACKUP;
- break;
- case ODELETE:
- c->Cflags |= CFDELETE;
- break;
- case OEXECUTE:
- c->Cflags |= CFEXECUTE;
- break;
- case OOLD:
- c->Cflags |= CFOLD;
- break;
- case OKEEP:
- c->Cflags |= CFKEEP;
- break;
- case OURELSUF:
- c->Cflags |= CFURELSUF;
- break;
- case OCOMPRESS:
- c->Cflags |= CFCOMPRESS;
- break;
- case OTIMEOUT:
- passdelim(&args, '=');
- arg = nxtarg(&args, " \t");
- c->Ctimeout = atoi(arg);
- break;
- }
- }
- return (0);
-}
-
-time_t
-getwhen(collection, relsuffix)
- char *collection, *relsuffix;
-{
- char buf[STRINGLENGTH];
- char *ep;
- FILE *fp;
- time_t tstamp;
-
- (void) snprintf(buf, sizeof buf, FILEWHEN, collection, relsuffix);
-
- if ((fp = fopen(buf, "r")) == NULL)
- return 0;
-
- if (fgets(buf, sizeof(buf), fp) == NULL) {
- (void) fclose(fp);
- return 0;
- }
-
- (void) fclose(fp);
-
- if ((tstamp = strtol(buf, &ep, 0)) == -1 || *ep != '\n')
- return (0);
-
- return (tstamp);
-}
-
-int
-putwhen(fname, tstamp)
- char *fname;
- time_t tstamp;
-{
- FILE *fp;
- if ((fp = fopen(fname, "w")) == NULL)
- return (0);
- if (fprintf(fp, "%u\n", tstamp) < 0) {
- (void) fclose(fp);
- return (0);
- }
- if (fclose(fp) != 0)
- return (0);
- return (1);
-}
diff --git a/usr.bin/sup/src/supcvers.c b/usr.bin/sup/src/supcvers.c
deleted file mode 100644
index 9b3e1e0ad32..00000000000
--- a/usr.bin/sup/src/supcvers.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* $OpenBSD: supcvers.c,v 1.4 2001/04/29 21:52:16 millert Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- * Revision 1.8 92/08/11 12:07:51 mrt
- * Added use-rel-suffix option. Picked up STUMP changes.
- * [V7.26]
- *
- * Revision 1.7 92/02/08 18:24:23 mja
- * Support for -k/-K and "keep" option. [V7.25]
- * [92/01/17 vdelvecc]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Removed nameserver support. [V7.24]
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support. [V6.23]
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Changes for Version 6, better supoort to reflect errors to
- * logfile. [V6.22]
- *
- * 25-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Split sup.c into subparts. [V5.21]
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changes to many files to make lint happy. [V5.20]
- *
- * 01-Apr-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changes to sup.c and scmio.c. [V5.19]
- *
- * 19-Sep-86 Mike Accetta (mja) at Carnegie-Mellon University
- * Changes to sup.c. [V5.18]
- *
- * 21-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Minor bug fix to previous edit in sup.c. [V5.17]
- *
- * 07-Jun-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changes to sup.c and sup.h. [V5.16]
- *
- * 30-May-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added changes to sup.c, sup.h, scm.c, scmio.h. [V5.15]
- *
- * 19-Feb-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created. [V5.14]
- *
- **********************************************************************
- */
-
-int PGMVERSION = 26; /* program version of sup */
diff --git a/usr.bin/sup/src/supextern.h b/usr.bin/sup/src/supextern.h
deleted file mode 100644
index bcfac9bafba..00000000000
--- a/usr.bin/sup/src/supextern.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* $OpenBSD: supextern.h,v 1.9 2009/05/09 12:02:17 chl Exp $ */
-
-/* atoo.c */
-unsigned int atoo(char *);
-
-#if 0
-/* ci.c */
-int ci(char *, FILE *, int, CIENTRY *, char *, char *);
-#endif
-
-/* errmsg.c */
-const char *errmsg(int);
-
-/* expand.c */
-int expand(char *, char **, int);
-
-/* ffilecopy.c */
-int ffilecopy(FILE *, FILE *);
-
-/* filecopy.c */
-int filecopy(int, int );
-
-/* log.c */
-void logopen(char *);
-void logquit(int, char *, ...);
-void logerr(char *, ...);
-void loginfo(char *, ...);
-#ifdef LIBWRAP
-void logdeny(char *, ...);
-void logallow(char *, ...);
-#endif
-
-/* netcryptvoid.c */
-int netcrypt(char *);
-int getcryptbuf(int);
-void decode(char *, char *, int);
-void encode(char *, char *, int);
-
-/* nxtarg.c */
-char *nxtarg(char **, char *);
-
-/* path.c */
-void path(char *, char *, int, char *, int);
-
-/* quit.c */
-void quit(int, char *, ...);
-
-/* read_line.c */
-char *read_line(FILE *, size_t *, size_t *, const char[3], int);
-
-/* run.c */
-int run(char *, ...);
-int runv(char *, char **);
-int runp(char *, ...);
-int runvp(char *, char **);
-int runio(char *const[], const char *, const char *, const char *);
-int runiofd(char *const[], const int, const int, const int);
-
-/* scan.c */
-int getrelease(char *);
-void makescanlists(void);
-void getscanlists(void);
-void cdprefix(char *);
-
-/* scm.c */
-int lock_host_file(char *);
-int servicesetup(char *);
-int service(void);
-int serviceprep(void);
-int servicekill(void);
-int serviceend(void);
-int dobackoff(int *, int *);
-int request(char *, char *, int *);
-int requestend(void);
-char *remotehost(void);
-int thishost(char *);
-int samehost(void);
-int matchhost(char *);
-int scmerr(int, char *, ...);
-int byteswap(int);
-
-/* scmio.c */
-int writemsg(int);
-int writemend(void);
-int writeint(int);
-int writestring(char *);
-int writefile(int);
-int writemnull(int);
-int writemint(int, int );
-int writemstr(int, char *);
-int prereadcount(int *);
-int readflush(void);
-int readmsg(int);
-int readmend(void);
-int readskip(void);
-int readint(int *);
-int readstring(char **);
-int readfile(int);
-int readmnull(int);
-int readmint(int, int *);
-int readmstr(int, char **);
-void crosspatch(void);
-
-/* skipto.c */
-char *skipto(char *, char *);
-char *skipover(char *, char *);
-
-/* stree.c */
-void Tfree(TREE **);
-TREE *Tinsert(TREE **, char *, int);
-TREE *Tsearch(TREE *, char *);
-TREE *Tlookup(TREE *, char *);
-int Trprocess(TREE *, int (*)(TREE *, void *), void *);
-int Tprocess(TREE *, int (*)(TREE *, void *), void *);
-#ifdef DEBUG
-void Tprint(TREE *, char *);
-#endif
-
-/* supcmeat.c */
-int getonehost(TREE *, void *);
-TREE *getcollhost(int *, int *, long *, int *);
-void getcoll(void);
-int signon(TREE *, int, int *);
-int setup(TREE *);
-void suplogin(void);
-void listfiles(void);
-void recvfiles(void);
-int prepare(char *, int, int *, struct stat *);
-int recvdir(TREE *, int, struct stat *);
-int recvsym(TREE *, int, struct stat *);
-int recvreg(TREE *, int, struct stat *);
-int copyfile(char *, char *);
-void finishup(int);
-void done(int, char *, ...);
-void goaway(char *, ...);
-
-/* supcmisc.c */
-void prtime(void);
-int establishdir(char *);
-int makedir(char *, int, struct stat *);
-int estabd(char *, char *);
-void ugconvert(char *, char *, uid_t *, gid_t *, int *);
-void notify(char *, ...);
-void lockout(int);
-char *fmttime(time_t);
-
-/* supcname.c */
-void getnams(void);
-
-/* supcparse.c */
-int parsecoll(COLLECTION *, char *, char *);
-time_t getwhen(char *, char *);
-int putwhen(char *, time_t);
-
-/* supmsg.c */
-int msgsignon(void);
-int msgsignonack(void);
-int msgsetup(void);
-int msgsetupack(void);
-int msgcrypt(void);
-int msgcryptok(void);
-int msglogin(void);
-int msglogack(void);
-int msgrefuse(void);
-int msglist(void);
-int msgneed(void);
-int msgdeny(void);
-int msgsend(void);
-int msgrecv(int (*)(TREE *, va_list), ...);
-int msgdone(void);
-int msggoaway(void);
-int msgxpatch(void);
-int msgcompress(void);
-
-/* vprintf.c */
-/* XXX already in system headers included already - but with different
- argument declarations! */
-#if 0
-int vprintf(const char *, va_list);
-int vfprintf(FILE *, const char *, va_list);
-int vsprintf(char *, const char *, va_list);
-int vsnprintf(char *, size_t, const char *, va_list);
-#endif
diff --git a/usr.bin/sup/src/supfilesrv.c b/usr.bin/sup/src/supfilesrv.c
deleted file mode 100644
index 712a20819e8..00000000000
--- a/usr.bin/sup/src/supfilesrv.c
+++ /dev/null
@@ -1,2123 +0,0 @@
-/* $OpenBSD: supfilesrv.c,v 1.38 2007/09/14 14:29:20 chl Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- *
- */
-/*
- * supfilesrv -- SUP File Server
- *
- * Usage: supfilesrv [-d] [-l] [-P] [-N] [-R] [-S]
- * -d "debug" -- don't fork daemon
- * -l "log" -- print successull connects (when compiled with libwrap)
- * -P "debug ports" -- use debugging network ports
- * -N "debug network" -- print debugging messages for network i/o
- * -R "RCS mode" -- if file is an rcs file, use co to get contents
- * -S "Operate silently" -- Only print error messages
- *
- **********************************************************************
- * HISTORY
- * 2-Aug-99 Manuel Bouyer at LIP6
- * Added libwrap support
- *
- * 13-Sep-92 Mary Thompson (mrt) at Carnegie-Mellon University
- * Changed name of sup program in xpatch from /usr/cs/bin/sup to
- * /usr/bin/sup for exported version of sup.
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.20 92/09/09 22:05:00 mrt
- * Added Brad's change to make sendfile take a va_list.
- * Added support in login to accept an non-encrypted login
- * message if no user or password is being sent. This supports
- * a non-crypting version of sup. Also fixed to skip leading
- * white space from crypts in host files.
- * [92/09/01 mrt]
- *
- * Revision 1.19 92/08/11 12:07:59 mrt
- * Made maxchildren a patchable variable, which can be set by the
- * command line switch -C or else defaults to the MAXCHILDREN
- * defined in sup.h. Added most of Brad's STUMP changes.
- * Increased PGMVERSION to 12 to reflect substantial changes.
- * [92/07/28 mrt]
- *
- * Revision 1.18 90/12/25 15:15:39 ern
- * Yet another rewrite of the logging code. Make up the text we will write
- * and then get in, write it and get out.
- * Also set error on write-to-full-disk if the logging is for recording
- * server is busy.
- * [90/12/25 15:15:15 ern]
- *
- * Revision 1.17 90/05/07 09:31:13 dlc
- * Sigh, some more fixes to the new "crypt" file handling code. First,
- * just because the "crypt" file is in a local file system does not mean
- * it can be trusted. We have to check for hard links to root owned
- * files whose contents could be interpretted as a crypt key. For
- * checking this fact, the new routine stat_info_ok() was added. This
- * routine also makes other sanity checks, such as owner only permission,
- * the file is a regular file, etc. Also, even if the uid/gid of th
- * "crypt" file is not going to be used, still use its contents in order
- * to cause fewer surprises to people supping out of a shared file system
- * such as AFS.
- * [90/05/07 dlc]
- *
- * Revision 1.16 90/04/29 04:21:08 dlc
- * Fixed logic bug in docrypt() which would not get the stat information
- * from the crypt file if the crypt key had already been set from a
- * "host" file.
- * [90/04/29 dlc]
- *
- * Revision 1.15 90/04/18 19:51:27 dlc
- * Added the new routines local_file(), link_nofollow() for use in
- * dectecting whether a file is located in a local file system. These
- * routines probably should have been in another module, but only
- * supfilesrv needs to do the check and none of its other modules seemed
- * appropriate. Note, the implementation should be changed once we have
- * direct kernel support, for example the fstatfs(2) system call, for
- * detecting the type of file system a file resides. Also, I changed
- * the routines which read the crosspatch crypt file or collection crypt
- * file to save the uid and gid from the stat information obtained via
- * the local_file() call (when the file is local) at the same time the
- * crypt key is read. This change disallows non-local files for the
- * crypt key to plug a security hole involving the usage of the uid/gid
- * of the crypt file to define who the file server should run as. If
- * the saved uid/gid are both valid, then the server will set its uid/gid
- * to these values.
- * [90/04/18 dlc]
- *
- * Revision 1.14 89/08/23 14:56:15 gm0w
- * Changed msgf routines to msg routines.
- * [89/08/23 gm0w]
- *
- * Revision 1.13 89/08/03 19:57:33 mja
- * Remove setaid() call.
- *
- * Revision 1.12 89/08/03 19:49:24 mja
- * Updated to use v*printf() in place of _doprnt().
- * [89/04/19 mja]
- *
- * 11-Sep-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to record release name in logfile.
- *
- * 18-Mar-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added host=<hostfile> support to releases file. [V7.12]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Created docrypt() routine for crypt
- * test message.
- *
- * 09-Sep-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed common information logging code, the quiet switch, and
- * moved samehost() check to after device/inode check.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support. [V5.11]
- *
- * 26-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Added code to record final status of client in logfile. [V5.10]
- *
- * 22-May-87 Chriss Stephens (chriss) at Carnegie Mellon University
- * Mergered divergent CS and ECE versions. [V5.9a]
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed support for version 3 of SUP protocol. Added changes
- * to make lint happy. Added calls to new logging routines. [V5.9]
- *
- * 31-Mar-87 Dan Nydick (dan) at Carnegie-Mellon University
- * Fixed so no password check is done when crypts are used.
- *
- * 25-Nov-86 Rudy Nedved (ern) at Carnegie-Mellon University
- * Set F_APPEND fcntl in logging to increase the chance
- * that the log entry from this incarnation of the file
- * server will not be lost by another incarnation. [V5.8]
- *
- * 20-Oct-86 Dan Nydick (dan) at Carnegie-Mellon University
- * Changed not to call okmumbles when not compiled with CMUCS.
- *
- * 04-Aug-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to increment scmdebug as more -N flags are
- * added. [V5.7]
- *
- * 25-May-86 Jonathan J. Chew (jjc) at Carnegie-Mellon University
- * Renamed local variable in main program from "sigmask" to
- * "signalmask" to avoid name conflict with 4.3BSD identifier.
- * Conditionally compile in calls to CMU routines, "setaid" and
- * "logaccess". [V5.6]
- *
- * 21-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed supfilesrv to use the crypt file owner and group for
- * access purposes, rather than the directory containing the crypt
- * file. [V5.5]
- *
- * 07-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to keep logfiles in repository collection directory.
- * Added code for locking collections. [V5.4]
- *
- * 05-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to support new FSETUPBUSY return. Now accepts all
- * connections and tells any clients after the 8th that the
- * fileserver is busy. New clients will retry again later. [V5.3]
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Major rewrite for protocol version 4. [V4.2]
- *
- * 12-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Fixed close of crypt file to use file pointer as argument
- * instead of string pointer.
- *
- * 24-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Allow "!hostname" lines and comments in collection "host" file.
- *
- * 13-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Don't use access() on symbolic links since they may not point to
- * an existing file.
- *
- * 22-Oct-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code to restrict file server availability to when it has
- * less than or equal to eight children.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#ifdef AFS
-#include <afs/param.h>
-#undef MAXNAMLEN
-#endif
-#include <sys/param.h>
-#include <c.h>
-#include <signal.h>
-#include <errno.h>
-#include <setjmp.h>
-#include <pwd.h>
-#include <grp.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <sys/mount.h>
-#ifndef HAS_POSIX_DIR
-#include <sys/dir.h>
-#else
-#include <dirent.h>
-#endif
-#if MACH
-#include <sys/ioctl.h>
-#endif
-#if CMUCS
-#include <acc.h>
-#include <sys/ttyloc.h>
-#include <access.h>
-#include <sys/viceioctl.h>
-#else /* CMUCS */
-#define ACCESS_CODE_OK 0
-#define ACCESS_CODE_BADPASSWORD (-2)
-#endif /* CMUCS */
-
-#ifdef __linux__
-# include <sys/vfs.h>
-# include <linux/nfs_fs.h>
-#endif
-
-#ifdef __SVR4
-# include <sys/mkdev.h>
-# include <sys/statvfs.h>
-#endif
-
-#ifdef LIBWRAP
-# include <tcpd.h>
-#endif
-
-#ifdef HAS_LOGIN_CAP
-# include <login_cap.h>
-#endif
-
-#include "supcdefs.h"
-#include "supextern.h"
-#define MSGFILE
-#include "supmsg.h"
-
-#ifndef UID_MAX
-#define UID_MAX ((uid_t)-1)
-#define GID_MAX ((gid_t)-1)
-#else
-#ifndef GID_MAX
-#define GID_MAX UID_MAX
-#endif
-#endif
-
-int maxchildren;
-
-/*
- * These are used to save the stat information from the crosspatch crypt
- * file or collection crypt file at the time it is opened for the crypt
- * key and it is verified to be a local file.
- */
-uid_t runas_uid = UID_MAX;
-gid_t runas_gid = GID_MAX;
-
-#define PGMVERSION 13
-
-/*************************
- *** M A C R O S ***
- *************************/
-
-#define HASHBITS 8
-#define HASHSIZE (1<<HASHBITS)
-#define HASHMASK (HASHSIZE-1)
-#define HASHFUNC(x,y) ((x)&HASHMASK)
-
-/*******************************************
- *** D A T A S T R U C T U R E S ***
- *******************************************/
-
-struct hashstruct { /* hash table for number lists */
- int Hnum1; /* numeric keys */
- int Hnum2;
- char *Hname; /* string value */
- TREE *Htree; /* TREE value */
- struct hashstruct *Hnext;
-};
-typedef struct hashstruct HASH;
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-char program[] = "supfilesrv"; /* program name for SCM messages */
-pid_t progpid = -1; /* and process id */
-
-jmp_buf sjbuf; /* jump location for network errors */
-TREELIST *listTL; /* list of trees to upgrade */
-
-char *oneconnect = NULL; /* -O flag */
-int silent; /* -S flag */
-#ifdef LIBWRAP
-int clog; /* -l flag */
-#endif
-int live; /* -d flag */
-int dbgportsq; /* -P flag */
-extern int scmdebug; /* -N flag */
-extern int netfile;
-#ifdef RCS
-int candorcs; /* -R flag */
-int dorcs = FALSE;
-#endif
-
-char *clienthost; /* host name of client */
-int nchildren; /* number of children that exist */
-char *prefix; /* collection pathname prefix */
-char *release; /* collection release name */
-char *cryptkey; /* encryption key if non-null */
-#ifdef CVS
-char *cvs_root; /* RCS root */
-#endif
-char *rcs_branch; /* RCS branch name */
-int lockfd; /* descriptor of lock file */
-
-/* global variables for scan functions */
-int trace = FALSE; /* directory scan trace */
-int cancompress = FALSE; /* Can we compress files */
-int docompress = FALSE; /* Do we compress files */
-
-HASH *uidH[HASHSIZE]; /* for uid and gid lookup */
-HASH *gidH[HASHSIZE];
-HASH *inodeH[HASHSIZE]; /* for inode lookup for linked file check */
-
-
-/* supfilesrv.c */
-int main(int, char **);
-void chldsig(int);
-void usage(void);
-void init(int, char **);
-void answer(void);
-void srvsignon(void);
-void srvsetup(void);
-void docrypt(void);
-void srvlogin(void);
-void listfiles(void);
-int denyone(TREE *, void *);
-void sendfiles(void);
-int sendone(TREE *, void *);
-int senddir(TREE *, void *);
-int sendfile(TREE *, va_list);
-void srvfinishup(time_t);
-void Hfree(HASH **);
-HASH *Hlookup(HASH **, int, int );
-void Hinsert(HASH **, int, int, char *, TREE *);
-TREE *linkcheck(TREE *, int, int );
-char *uconvert(uid_t);
-char *gconvert(gid_t);
-char *changeuid(char *, char *, uid_t, gid_t);
-void goaway(char *, ...);
-char *fmttime(time_t);
-int local_file(int, struct stat *);
-int stat_info_ok(struct stat *, struct stat *);
-int link_nofollow(int);
-int link_nofollow(int);
-int opentmp(char *, size_t);
-
-/*************************************
- *** M A I N R O U T I N E ***
- *************************************/
-
-int
-main (argc,argv)
-int argc;
-char **argv;
-{
- int x;
- pid_t pid;
- sigset_t nset, oset;
- struct sigaction chld,ign;
- time_t tloc;
-#ifdef LIBWRAP
- struct request_info req;
-#endif
-
- /* initialize global variables */
- pgmversion = PGMVERSION; /* export version number */
- server = TRUE; /* export that we're not a server */
- collname = NULL; /* no current collection yet */
- maxchildren = MAXCHILDREN; /* defined in sup.h */
-
- init (argc,argv); /* process arguments */
-
- if (!live) /* if not debugging, turn into daemon */
-#ifdef HAS_DAEMON
- daemon(0, 0);
-#else
- /* XXX - child should close fd's */
- switch (fork()) {
- case 0:
- setsid(); /* child, start new session */
- break;
- case -1:
- perror("fork:");
- exit(1);
- default:
- exit(0); /* parent just exits */
- }
-#endif
-
- logopen("supfile");
- tloc = time(NULL);
- loginfo("SUP File Server Version %d.%d (%s) starting at %s",
- PROTOVERSION, PGMVERSION, scmversion, fmttime(tloc));
- if (live) {
- x = service ();
-
- if (x != SCMOK)
- logquit(1, "Can't connect to network");
-#ifdef LIBWRAP
- request_init(&req, RQ_DAEMON, "supfilesrv", RQ_FILE, netfile,
- 0);
- fromhost(&req);
- if (hosts_access(&req) == 0) {
- logdeny("refused connection from %.500s",
- eval_client(&req));
- servicekill();
- exit(1);
- }
- if (clog)
- logallow("connection from %.500s", eval_client(&req));
-#endif
- answer();
- (void) serviceend();
- exit(0);
- }
- memset(&ign, 0, sizeof ign);
- ign.sa_handler = SIG_IGN;
- sigemptyset(&ign.sa_mask);
- ign.sa_flags = 0;
- (void) sigaction(SIGHUP,&ign,NULL);
- (void) sigaction(SIGINT,&ign,NULL);
- (void) sigaction(SIGPIPE,&ign,NULL);
- memset(&chld, 0, sizeof chld);
- chld.sa_handler = chldsig;
- sigemptyset(&chld.sa_mask);
- chld.sa_flags = 0;
- (void) sigaction(SIGCHLD,&chld,NULL);
- nchildren = 0;
- for (;;) {
- x = service();
- if (x != SCMOK) {
- logerr("Error in establishing network connection");
- (void) servicekill();
- continue;
- }
- sigemptyset(&nset);
- sigaddset(&nset, SIGCHLD);
- sigprocmask(SIG_BLOCK, &nset, &oset);
- if ((pid = fork()) == 0) { /* server process */
-#ifdef LIBWRAP
- request_init(&req, RQ_DAEMON, "supfilesrv", RQ_FILE,
- netfile, 0);
- fromhost(&req);
- if (hosts_access(&req) == 0) {
- logdeny("refused connection from %.500s",
- eval_client(&req));
- servicekill();
- exit(1);
- }
- if (clog) {
- logallow("connection from %.500s",
- eval_client(&req));
- }
-#endif
- (void) serviceprep();
- answer();
- (void) serviceend();
- exit(0);
- }
- (void) servicekill(); /* parent */
- if (pid > 0)
- nchildren++;
- (void) sigprocmask(SIG_SETMASK, &oset, NULL);
- }
-}
-
-/*
- * Child status signal handler
- */
-void
-chldsig(snum)
- int snum;
-{
- int w;
-
- while (waitpid(-1, &w, WNOHANG) > 0) {
- if (nchildren)
- nchildren--;
- }
-}
-
-/*****************************************
- *** I N I T I A L I Z A T I O N ***
- *****************************************/
-
-void
-usage()
-{
-#ifdef LIBWRAP
- quit(1,"Usage: supfilesrv [ -l | -d | -P | -N | -C <max children> | -H <host> <user> <cryptfile> <supargs> ]\n");
-#else
- quit(1,"Usage: supfilesrv [ -d | -P | -N | -C <max children> | -H <host> <user> <cryptfile> <supargs> ]\n");
-#endif
-}
-
-void
-init(argc, argv)
- int argc;
- char **argv;
-{
- int i;
- int x;
- char *clienthost, *clientuser;
- char *p;
- char buf[STRINGLENGTH];
- int maxsleep;
- FILE *f;
-
-#ifdef RCS
- candorcs = FALSE;
-#endif
- live = FALSE;
-#ifdef LIBWRAP
- clog = FALSE;
-#endif
- dbgportsq = FALSE;
- scmdebug = 0;
- clienthost = NULL;
- clientuser = NULL;
- maxsleep = 5;
- if (--argc < 0)
- usage ();
- argv++;
- while (clienthost == NULL && argc > 0 && argv[0][0] == '-') {
- switch (argv[0][1]) {
- case 'S':
- silent = TRUE;
- break;
-#ifdef LIBWRAP
- case 'l':
- clog = TRUE;
- break;
-#endif
- case 'd':
- live = TRUE;
- break;
- case 'P':
- dbgportsq = TRUE;
- break;
- case 'N':
- scmdebug++;
- break;
- case 'C':
- if (--argc < 1)
- quit (1,"Missing arg to -C\n");
- argv++;
- maxchildren = atoi(argv[0]);
- break;
- case 'O':
- if (--argc < 1)
- quit (1,"Missing arg to -O\n");
- argv++;
- oneconnect = argv[0];
- break;
- case 'H':
- if (--argc < 3)
- quit (1,"Missing args to -H\n");
- argv++;
- clienthost = argv[0];
- clientuser = argv[1];
- cryptkey = argv[2];
- argc -= 2;
- argv += 2;
- break;
-#ifdef RCS
- case 'R':
- candorcs = TRUE;
- break;
-#endif
- default:
- fprintf(stderr, "Unknown flag %s ignored\n", argv[0]);
- break;
- }
- --argc;
- argv++;
- }
- if (clienthost == NULL) {
- if (argc != 0)
- usage ();
- x = servicesetup(dbgportsq ? DEBUGFPORT : FILEPORT);
- if (x != SCMOK)
- quit(1,"Error in network setup");
- for (i = 0; i < HASHSIZE; i++)
- uidH[i] = gidH[i] = inodeH[i] = NULL;
- return;
- }
- server = FALSE;
- if (argc < 1)
- usage();
- f = fopen(cryptkey, "r");
- if (f == NULL)
- quit(1, "Unable to open cryptfile %s\n", cryptkey);
- if ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (*p == '\0')
- quit(1, "No cryptkey found in %s\n", cryptkey);
- cryptkey = strdup(buf);
- if (cryptkey == NULL)
- quit(1, "Unable to allocate memory\n");
-
- }
- (void) fclose(f);
- x = request (dbgportsq ? DEBUGFPORT : FILEPORT, clienthost, &maxsleep);
- if (x != SCMOK)
- quit(1, "Unable to connect to host %s\n", clienthost);
- x = msgsignon ();
- if (x != SCMOK)
- quit(1, "Error sending signon request to fileserver\n");
- x = msgsignonack();
- if (x != SCMOK)
- quit(1, "Error reading signon reply from fileserver\n");
- printf("SUP Fileserver %d.%d (%s) %ld on %s\n", protver, pgmver,
- scmver, (long)fspid, remotehost());
- free(scmver);
- scmver = NULL;
- if (protver < 7)
- quit(1, "Remote fileserver does not implement reverse sup\n");
- xpatch = TRUE;
- xuser = clientuser;
- x = msgsetup();
- if (x != SCMOK)
- quit(1, "Error sending setup request to fileserver\n");
- x = msgsetupack();
- if (x != SCMOK)
- quit(1, "Error reading setup reply from fileserver\n");
- switch(setupack) {
- case FSETUPOK:
- break;
- case FSETUPSAME:
- quit(1, "User %s not found on remote client\n", xuser);
- case FSETUPHOST:
- quit(1, "This host has no permission to reverse sup\n");
- default:
- quit(1, "Unrecognized file server setup status %d\n", setupack);
- }
- if (netcrypt(cryptkey) != SCMOK )
- quit(1, "Running non-crypting fileserver\n");
- crypttest = CRYPTTEST;
- x = msgcrypt();
- if (x != SCMOK)
- quit(1, "Error sending encryption test request\n");
- x = msgcryptok();
- if (x == SCMEOF)
- quit(1, "Data encryption test failed\n");
- if (x != SCMOK)
- quit(1, "Error reading encryption test reply\n");
- logcrypt = CRYPTTEST;
- loguser = NULL;
- logpswd = NULL;
- if (netcrypt(PSWDCRYPT) != SCMOK) /* encrypt password data */
- quit(1, "Running non-crypting fileserver\n");
- x = msglogin();
- (void) netcrypt(NULL); /* turn off encryption */
- if (x != SCMOK)
- quit(1, "Error sending login request to file server\n");
- x = msglogack();
- if (x != SCMOK)
- quit(1, "Error reading login reply from file server\n");
- if (logack == FLOGNG)
- quit(1, "%s\nImproper login to %s account\n", logerror, xuser);
- xargc = argc;
- xargv = argv;
- x = msgxpatch();
- if (x != SCMOK)
- quit(1, "Error sending crosspatch request\n");
- crosspatch();
- exit(0);
-}
-
-/*****************************************
- *** A N S W E R R E Q U E S T ***
- *****************************************/
-
-void
-answer()
-{
- time_t starttime;
- int x;
-
- progpid = fspid = getpid();
- collname = NULL;
- basedir = NULL;
- prefix = NULL;
- release = NULL;
- rcs_branch = NULL;
-#ifdef CVS
- cvs_root = NULL;
-#endif
- goawayreason = NULL;
- donereason = NULL;
- lockfd = -1;
- starttime = time(NULL);
- if (!setjmp(sjbuf)) {
- srvsignon();
- srvsetup();
- docrypt();
- srvlogin();
- if (xpatch) {
- x = msgxpatch();
- if (x != SCMOK)
- exit(0);
- xargv[0] = "sup";
- xargv[1] = "-X";
- xargv[xargc] = NULL;
- (void) dup2(netfile,0);
- (void) dup2(netfile,1);
- (void) dup2(netfile,2);
- closefrom(3);
- execvp(xargv[0], xargv);
- exit(0);
- }
- listfiles();
- sendfiles();
- }
- srvfinishup(starttime);
- if (collname)
- free(collname);
- if (basedir)
- free(basedir);
- if (prefix)
- free(prefix);
- if (release)
- free(release);
- if (rcs_branch)
- free(rcs_branch);
-#ifdef CVS
- if (cvs_root)
- free(cvs_root);
-#endif
- if (goawayreason) {
- if (donereason == goawayreason)
- donereason = NULL;
- free(goawayreason);
- }
- if (donereason)
- free(donereason);
- if (lockfd >= 0)
- (void) close(lockfd);
- endpwent();
- endgrent();
-#if CMUCS
- endacent();
-#endif /* CMUCS */
- Hfree(uidH);
- Hfree(gidH);
- Hfree(inodeH);
-}
-
-/*****************************************
- *** S I G N O N C L I E N T ***
- *****************************************/
-
-void
-srvsignon()
-{
- int x;
-
- xpatch = FALSE;
- x = msgsignon();
- if (x != SCMOK)
- goaway("Error reading signon request from client");
- x = msgsignonack();
- if (x != SCMOK)
- goaway("Error sending signon reply to client");
- free(scmver);
- scmver = NULL;
-}
-
-/*****************************************************************
- *** E X C H A N G E S E T U P I N F O R M A T I O N ***
- *****************************************************************/
-
-void
-srvsetup()
-{
- int x;
- char *p,*q;
- char buf[STRINGLENGTH];
- FILE *f;
- struct stat sbuf;
- TREELIST *tl;
-
- if (protver > 7)
- cancompress = TRUE;
- x = msgsetup();
- if (x != SCMOK)
- goaway("Error reading setup request from client");
- if (protver < 4) {
- setupack = FSETUPOLD;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Sup client using obsolete version of protocol");
- }
- if (xpatch) {
- struct passwd *pw;
-
- if ((pw = getpwnam(xuser)) == NULL) {
- setupack = FSETUPSAME;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf,TRUE);
- goaway("User `%s' not found", xuser);
- }
- (void) free(xuser);
- xuser = strdup(pw->pw_dir);
-
- /* check crosspatch host access file */
- cryptkey = NULL;
- (void) snprintf(buf, sizeof buf, FILEXPATCH, xuser);
-
- /* Turn off link following */
- if (link_nofollow(1) != -1) {
- int hostok = FALSE;
- /* get stat info before open */
- if (stat(buf, &sbuf) == -1)
- (void) memset(&sbuf, 0, sizeof(sbuf));
-
- if ((f = fopen(buf, "r")) != NULL) {
- struct stat fsbuf;
-
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t");
- if (*p == '\0')
- continue;
- if (!matchhost(q))
- continue;
-
- cryptkey = strdup(p);
- hostok = TRUE;
- if (local_file(fileno(f), &fsbuf) > 0
- && stat_info_ok(&sbuf, &fsbuf)) {
- runas_uid = sbuf.st_uid;
- runas_gid = sbuf.st_gid;
- }
- break;
- }
- (void) fclose(f);
- }
-
- /* Restore link following */
- if (link_nofollow(0) == -1)
- goaway ("Restore link following");
-
- if (!hostok) {
- setupack = FSETUPHOST;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Host not on access list");
- }
- }
- setupack = FSETUPOK;
- x = msgsetupack();
- if (x != SCMOK)
- goaway("Error sending setup reply to client");
- return;
- }
-#ifdef RCS
- if (candorcs && release != NULL &&
- (strncmp(release, "RCS.", 4) == 0)) {
- rcs_branch = strdup(&release[4]);
- free(release);
- release = strdup("RCS");
- dorcs = TRUE;
- }
-#endif
- if (release == NULL)
- release = strdup(DEFRELEASE);
- if (basedir == NULL || *basedir == '\0') {
- basedir = NULL;
- (void) snprintf(buf, sizeof buf, FILEDIRS, DEFDIR);
- f = fopen(buf, "r");
- if (f) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t=");
- if (strcmp(q, collname) == 0) {
- basedir = skipover(p, " \t=");
- basedir = strdup(basedir);
- break;
- }
- }
- (void) fclose(f);
- }
- if (basedir == NULL) {
- (void) snprintf(buf, sizeof buf, FILEBASEDEFAULT,
- collname);
- basedir = strdup(buf);
- }
- }
- if (chdir(basedir) < 0)
- goaway("Can't chdir to base directory %s", basedir);
- (void) snprintf(buf, sizeof buf, FILEPREFIX, collname);
- f = fopen(buf, "r");
- if (f) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- prefix = strdup(p);
- if (chdir(prefix) < 0)
- goaway("Can't chdir to %s from base directory %s",
- prefix,basedir);
- break;
- }
- (void) fclose(f);
- }
- x = stat(".", &sbuf);
- if (prefix)
- (void) chdir(basedir);
- if (x < 0)
- goaway("Can't stat base/prefix directory");
- if (nchildren >= maxchildren) {
- setupack = FSETUPBUSY;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Sup client told to try again later");
- }
- if (sbuf.st_dev == basedev && sbuf.st_ino == baseino && samehost()) {
- setupack = FSETUPSAME;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Attempt to upgrade to same directory on same host");
- }
- /* obtain release information */
- if (!getrelease(release)) {
- setupack = FSETUPRELEASE;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Invalid release information");
- }
- /* check host access file */
- cryptkey = NULL;
- for (tl = listTL; tl != NULL; tl = tl->TLnext) {
- char *h;
- if ((h = tl->TLhost) == NULL)
- h = FILEHOSTDEF;
- (void) snprintf(buf, sizeof buf, FILEHOST, collname, h);
- f = fopen(buf, "r");
- if (f) {
- int hostok = FALSE;
-
- while ((p = fgets (buf, sizeof(buf), f)) != NULL) {
- int not;
-
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t");
- if ((not = (*q == '!')) && *++q == '\0')
- q = nxtarg(&p, " \t");
- hostok = (not == (matchhost(q) == 0));
- if (hostok) {
- while ((*p == ' ') || (*p == '\t'))
- p++;
- if (*p)
- cryptkey = strdup(p);
- break;
- }
- }
- (void) fclose(f);
- if (!hostok) {
- setupack = FSETUPHOST;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Host not on access list for %s",
- collname);
- }
- }
- }
- /* try to lock collection */
- (void) snprintf(buf, sizeof buf, FILELOCK, collname);
-#ifdef LOCK_SH
- x = open(buf, O_RDONLY, 0);
- if (x >= 0) {
- if (flock(x, LOCK_SH|LOCK_NB) < 0) {
- (void) close(x);
- if (errno != EWOULDBLOCK)
- goaway("Can't lock collection %s", collname);
- setupack = FSETUPBUSY;
- (void) msgsetupack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Sup client told to wait for lock");
- }
- lockfd = x;
- }
-#endif
- if (oneconnect != NULL && (lock_host_file(oneconnect) < 0))
- goaway("I'm still working on a previous request from your host.");
- setupack = FSETUPOK;
- x = msgsetupack();
- if (x != SCMOK)
- goaway("Error sending setup reply to client");
-}
-
-/** Test data encryption **/
-void
-docrypt()
-{
- int x;
- char *p;
- char buf[STRINGLENGTH];
- FILE *f;
- struct stat sbuf;
-
- if (!xpatch) {
- (void) snprintf(buf, sizeof buf, FILECRYPT, collname);
-
- /* Turn off link following */
- if (link_nofollow(1) != -1) {
- /* get stat info before open */
- if (stat(buf, &sbuf) == -1)
- (void) memset(&sbuf, 0, sizeof(sbuf));
-
- if ((f = fopen(buf, "r")) != NULL) {
- struct stat fsbuf;
-
- if (cryptkey == NULL &&
- (p = fgets(buf, sizeof(buf), f))) {
- p[strcspn(p, "\n")] = '\0';
- if (*p)
- cryptkey = strdup(buf);
- }
- if (local_file(fileno(f), &fsbuf) > 0
- && stat_info_ok(&sbuf, &fsbuf)) {
- runas_uid = sbuf.st_uid;
- runas_gid = sbuf.st_gid;
- }
- (void) fclose(f);
- }
- /* Restore link following */
- if (link_nofollow(0) == -1)
- goaway("Restore link following");
- }
- }
- if (netcrypt (cryptkey) != SCMOK)
- goaway("Runing non-crypting supfilesrv");
- x = msgcrypt();
- if (x != SCMOK)
- goaway("Error reading encryption test request from client");
- (void) netcrypt(NULL);
- if (strcmp(crypttest, CRYPTTEST) != 0)
- goaway("Client not encrypting data properly");
- free(crypttest);
- crypttest = NULL;
- x = msgcryptok();
- if (x != SCMOK)
- goaway("Error sending encryption test reply to client");
-}
-
-/***************************************************************
- *** C O N N E C T T O P R O P E R A C C O U N T ***
- ***************************************************************/
-
-void
-srvlogin()
-{
- int x;
- uid_t fileuid = UID_MAX;
- gid_t filegid = GID_MAX;
-
- (void) netcrypt(PSWDCRYPT); /* encrypt acct name and password */
- x = msglogin();
- (void) netcrypt(NULL); /* turn off encryption */
- if (x != SCMOK)
- goaway("Error reading login request from client");
- if (logcrypt) {
- if (strcmp(logcrypt, CRYPTTEST) != 0) {
- logack = FLOGNG;
- logerror = "Improper login encryption";
- (void) msglogack();
- goaway("Client not encrypting login information properly");
- }
- free(logcrypt);
- logcrypt = NULL;
- }
- if (loguser == NULL) {
- if (cryptkey) {
- if (runas_uid != UID_MAX && runas_gid != GID_MAX) {
- fileuid = runas_uid;
- filegid = runas_gid;
- loguser = NULL;
- } else
- loguser = strdup(DEFUSER);
- } else
- loguser = strdup(DEFUSER);
- }
- if ((logerror = changeuid(loguser, logpswd, fileuid, filegid)) != NULL) {
- logack = FLOGNG;
- (void) msglogack();
- if (protver >= 6)
- longjmp(sjbuf, TRUE);
- goaway("Client denied login access");
- }
- if (loguser)
- free(loguser);
- if (logpswd)
- free(logpswd);
- logack = FLOGOK;
- x = msglogack();
- if (x != SCMOK)
- goaway("Error sending login reply to client");
- if (!xpatch) /* restore desired encryption */
- if (netcrypt(cryptkey) != SCMOK)
- goaway("Running non-crypting supfilesrv");
- free(cryptkey);
- cryptkey = NULL;
-}
-
-/*****************************************
- *** M A K E N A M E L I S T ***
- *****************************************/
-
-void
-listfiles()
-{
- int x;
-
- refuseT = NULL;
- x = msgrefuse();
- if (x != SCMOK)
- goaway("Error reading refuse list from client");
- getscanlists();
- Tfree(&refuseT);
- x = msglist();
- if (x != SCMOK)
- goaway("Error sending file list to client");
- Tfree(&listT);
- listT = NULL;
- needT = NULL;
- x = msgneed();
- if (x != SCMOK)
- goaway("Error reading needed files list from client");
- denyT = NULL;
- (void) Tprocess(needT, denyone, NULL);
- Tfree(&needT);
- x = msgdeny();
- if (x != SCMOK)
- goaway("Error sending denied files list to client");
- Tfree(&denyT);
-}
-
-
-int
-denyone(t, v)
- TREE *t;
- void *v;
-{
- TREELIST *tl;
- char *name = t->Tname;
- int update = (t->Tflags&FUPDATE) != 0;
- struct stat sbuf;
- TREE *tlink;
- char slinkname[STRINGLENGTH];
- int x;
-
- for (tl = listTL; tl != NULL; tl = tl->TLnext)
- if ((t = Tsearch(tl->TLtree, name)) != NULL)
- break;
- if (t == NULL) {
- (void) Tinsert(&denyT, name, FALSE);
- return (SCMOK);
- }
- cdprefix(tl->TLprefix);
- if (S_ISLNK(t->Tmode))
- x = lstat(name, &sbuf);
- else
- x = stat(name, &sbuf);
- if (x < 0 || (sbuf.st_mode&S_IFMT) != (t->Tmode&S_IFMT)) {
- (void) Tinsert(&denyT, name, FALSE);
- return (SCMOK);
- }
- switch (t->Tmode&S_IFMT) {
- case S_IFLNK:
- if ((x = readlink(name, slinkname, sizeof slinkname-1)) <= 0) {
- (void) Tinsert(&denyT, name, FALSE);
- return (SCMOK);
- }
- slinkname[x] = '\0';
- (void) Tinsert(&t->Tlink, slinkname, FALSE);
- break;
- case S_IFREG:
- if (sbuf.st_nlink > 1 &&
- (tlink = linkcheck(t, (int)sbuf.st_dev, (int)sbuf.st_ino)))
- {
- (void) Tinsert(&tlink->Tlink, name, FALSE);
- return (SCMOK);
- }
- if (update)
- t->Tflags |= FUPDATE;
- case S_IFDIR:
- t->Tuid = sbuf.st_uid;
- t->Tgid = sbuf.st_gid;
- break;
- default:
- (void) Tinsert(&denyT, name, FALSE);
- return (SCMOK);
- }
- t->Tflags |= FNEEDED;
- return (SCMOK);
-}
-
-/*********************************
- *** S E N D F I L E S ***
- *********************************/
-
-void
-sendfiles()
-{
- TREELIST *tl;
- int x;
-
- /* Does the protocol support compression */
- if (cancompress) {
- /* Check for compression on sending files */
- x = msgcompress();
- if ( x != SCMOK)
- goaway("Error sending compression check to server");
- }
- /* send all files */
- for (tl = listTL; tl != NULL; tl = tl->TLnext) {
- cdprefix(tl->TLprefix);
-#ifdef CVS
- if (candorcs) {
- cvs_root = getcwd(NULL, MAXPATHLEN);
- if (!cvs_root || access("CVSROOT", F_OK) < 0)
- dorcs = FALSE;
- else {
- loginfo("is a CVSROOT \"%s\"\n", cvs_root);
- dorcs = TRUE;
- }
- }
-#endif
- (void) Tprocess(tl->TLtree, sendone, NULL);
- }
- /* send directories in reverse order */
- for (tl = listTL; tl != NULL; tl = tl->TLnext) {
- cdprefix(tl->TLprefix);
- (void) Trprocess(tl->TLtree, senddir, NULL);
- }
- x = msgsend();
- if (x != SCMOK)
- goaway("Error reading receive file request from client");
- upgradeT = NULL;
- x = msgrecv(sendfile, 0);
- if (x != SCMOK)
- goaway("Error sending file to client");
-}
-
-int
-sendone(t, v)
- TREE *t;
- void *v;
-{
- int x, fd, ifd;
- char temp_file[MAXPATHLEN];
- char *av[50]; /* More than enough */
-
- if ((t->Tflags&FNEEDED) == 0) /* only send needed files */
- return (SCMOK);
- if (S_ISDIR(t->Tmode)) /* send no directories this pass */
- return (SCMOK);
- x = msgsend();
- if (x != SCMOK)
- goaway("Error reading receive file request from client");
- upgradeT = t; /* upgrade file pointer */
- fd = -1; /* no open file */
- if (S_ISREG(t->Tmode)) {
- if (!listonly && (t->Tflags&FUPDATE) == 0) {
-#ifdef RCS
- if (dorcs) {
- char rcs_release[MAXPATHLEN];
-
- fd = opentmp(rcs_file, sizeof(rcs_file));
- if (fd < 0)
- goaway ("We died trying to create temp file");
- close(fd);
- if (strcmp(&t->Tname[strlen(t->Tname)-2], ",v") == 0) {
- t->Tname[strlen(t->Tname)-2] = '\0';
- ac = 0;
-#ifdef CVS
- av[ac++] = "cvs";
- av[ac++] = "-d";
- av[ac++] = cvs_root;
- av[ac++] = "-r";
- av[ac++] = "-l";
- av[ac++] = "-Q";
- av[ac++] = "co";
- av[ac++] = "-p";
- if (rcs_branch != NULL) {
- av[ac++] = "-r";
- av[ac++] = rcs_branch;
- }
-#else
- av[ac++] = "co";
- av[ac++] = "-q";
- av[ac++] = "-p";
- if (rcs_branch != NULL) {
- snprintf(rcs_release,
- sizeof rcs_release,
- "-r%s", rcs_branch);
- av[ac++] = rcs_release;
- }
-#endif
- av[ac++] = t->Tname;
- av[ac++] = NULL;
- status = runio(av, NULL, rcs_file,
- "/dev/null");
- /*loginfo("using rcs mode \n");*/
- if (status < 0 || WEXITSTATUS(status)) {
- /* Just in case */
- unlink(rcs_file);
- if (status < 0) {
- goaway("We died trying to run cvs or rcs on %s", rcs_file);
- t->Tmode = 0;
- } else {
-#if 0
- logerr("rcs command failed = %d\n",
- WEXITSTATUS(status));
-#endif
- t->Tflags |= FUPDATE;
- }
- } else if (docompress) {
- fd = opentmp(temp_file, sizeof(temp_file));
- if (fd < 0)
- goaway ("We died trying to create temp file");
- ifd = open(rcs_file, O_RDONLY, 0);
- if (ifd < 0)
- goaway ("We died trying to open %s", rcs_file);
- av[0] = "gzip";
- av[1] = "-cf";
- av[2] = NULL;
- if (runiofd(av, ifd, fd, 2) != 0) {
- close(fd);
- close(ifd);
- /* Just in case */
- unlink(temp_file);
- unlink(rcs_file);
- goaway("We died trying to gzip %s", rcs_file);
- t->Tmode = 0;
- }
- lseek(fd, (off_t)0, SEEK_SET);
- close(ifd);
- } else
- fd = open (rcs_file,O_RDONLY,0);
- }
- }
-#endif
- if (fd == -1) {
- if (docompress) {
- fd = opentmp(temp_file, sizeof(temp_file));
- if (fd < 0)
- goaway ("We died trying to create temp file");
- ifd = open(t->Tname, O_RDONLY, 0);
- if (ifd < 0)
- goaway ("We died trying to open %s", t->Tname);
- av[0] = "gzip";
- av[1] = "-cf";
- av[2] = NULL;
- if (runiofd(av, ifd, fd, 2) != 0) {
- close(fd);
- close(ifd);
- /* Just in case */
- unlink(temp_file);
- goaway("We died trying to run gzip %s", t->Tname);
- t->Tmode = 0;
- }
- lseek(fd, (off_t)0, SEEK_SET);
- close(ifd);
- } else
- fd = open(t->Tname, O_RDONLY, 0);
- }
- if (fd < 0 && (t->Tflags&FUPDATE) == 0)
- t->Tmode = 0;
- }
- if (t->Tmode) {
- t->Tuser = strdup(uconvert(t->Tuid));
- t->Tgroup = strdup(gconvert(t->Tgid));
- }
- }
- x = msgrecv(sendfile,fd);
- if (docompress)
- unlink(temp_file);
-#ifdef RCS
- if (dorcs)
- unlink(rcs_file);
-#endif
- if (x != SCMOK)
- goaway("Error sending file %s to client", t->Tname);
- return (SCMOK);
-}
-
-int
-senddir(t, v)
- TREE *t;
- void *v;
-{
- int x;
-
- if ((t->Tflags&FNEEDED) == 0) /* only send needed files */
- return (SCMOK);
- if (!S_ISDIR(t->Tmode)) /* send only directories this pass */
- return (SCMOK);
- x = msgsend();
- if (x != SCMOK)
- goaway("Error reading receive file request from client");
- upgradeT = t; /* upgrade file pointer */
- t->Tuser = strdup(uconvert(t->Tuid));
- t->Tgroup = strdup(gconvert(t->Tgid));
- x = msgrecv(sendfile,0);
- if (x != SCMOK)
- goaway("Error sending file %s to client", t->Tname);
- return (SCMOK);
-}
-
-int
-sendfile(t, ap)
- TREE *t;
- va_list ap;
-{
- int x, fd;
-
- fd = va_arg(ap,int);
- if (!S_ISREG(t->Tmode) || listonly || (t->Tflags&FUPDATE))
- return (SCMOK);
- x = writefile(fd);
- if (x != SCMOK)
- goaway("Error sending file %s to client", t->Tname);
- (void) close(fd);
- return (SCMOK);
-}
-
-/*****************************************
- *** E N D C O N N E C T I O N ***
- *****************************************/
-
-void
-srvfinishup(starttime)
- time_t starttime;
-{
- int x = SCMOK;
- char tmpbuf[BUFSIZ], lognam[STRINGLENGTH];
- int logfd;
- time_t finishtime;
- char *releasename;
-
- /*
- * Because we are headed for an exit() we don't bother to
- * free memory allocated by this function.
- */
- (void) netcrypt(NULL);
- if (protver < 6) {
- if (goawayreason != NULL)
- free(goawayreason);
- goawayreason = NULL;
- x = msggoaway();
- doneack = FDONESUCCESS;
- donereason = strdup("Unknown");
- } else if (goawayreason == NULL)
- x = msgdone();
- else {
- doneack = FDONEGOAWAY;
- donereason = goawayreason;
- }
- if (x == SCMEOF || x == SCMERR) {
- doneack = FDONEUSRERROR;
- donereason = strdup("Premature EOF on network");
- } else if (x != SCMOK) {
- doneack = FDONESRVERROR;
- donereason = strdup("Unknown SCM code");
- }
- if (doneack == FDONEDONTLOG)
- return;
- if (donereason == NULL)
- donereason = strdup("No reason");
- if (doneack == FDONESRVERROR || doneack == FDONEUSRERROR)
- logerr("%s", donereason);
- else if (doneack == FDONEGOAWAY)
- logerr("GOAWAY: %s", donereason);
- else if (doneack != FDONESUCCESS)
- logerr("Reason %d: %s", doneack, donereason);
- goawayreason = donereason;
- cdprefix(NULL);
- if (collname == NULL) {
- logerr("NULL collection in svrfinishup");
- return;
- }
- (void) snprintf(lognam, sizeof lognam, FILELOGFILE, collname);
- if ((logfd = open(lognam, O_APPEND|O_WRONLY, 0644)) < 0)
- return; /* can not open file up...error */
- if ((releasename = release) == NULL)
- releasename = "UNKNOWN";
- finishtime = time(NULL);
- (void) snprintf(tmpbuf, sizeof tmpbuf, "%s %s %s %s %s %d %s\n",
- strdup(fmttime(lasttime)), strdup(fmttime(starttime)),
- strdup(fmttime(finishtime)), remotehost(), releasename,
- FDONESUCCESS-doneack, donereason);
-#if MACH
- /* if we are busy dont get stuck updating the disk if full */
- if (setupack == FSETUPBUSY) {
- long l = FIOCNOSPC_ERROR;
- ioctl(logfd, FIOCNOSPC, &l);
- }
-#endif /* MACH */
- (void) write(logfd, tmpbuf, strlen(tmpbuf));
- (void) close(logfd);
-}
-
-/***************************************************
- *** H A S H T A B L E R O U T I N E S ***
- ***************************************************/
-
-void
-Hfree(table)
- HASH **table;
-{
- HASH *h;
- int i;
-
- for (i = 0; i < HASHSIZE; i++)
- while ((h = table[i]) != NULL) {
- table[i] = h->Hnext;
- if (h->Hname)
- free(h->Hname);
- free(h);
- }
-}
-
-HASH *
-Hlookup(table, num1, num2)
- HASH **table;
- int num1, num2;
-{
- HASH *h;
- int hno;
-
- hno = HASHFUNC(num1, num2);
- for (h = table[hno]; h && (h->Hnum1 != num1 || h->Hnum2 != num2);
- h = h->Hnext)
- ;
- return (h);
-}
-
-void
-Hinsert(table, num1, num2, name, tree)
- HASH **table;
- int num1, num2;
- char *name;
- TREE *tree;
-{
- HASH *h;
- int hno;
-
- hno = HASHFUNC(num1, num2);
- h = (HASH *) malloc(sizeof(HASH));
- h->Hnum1 = num1;
- h->Hnum2 = num2;
- h->Hname = name;
- h->Htree = tree;
- h->Hnext = table[hno];
- table[hno] = h;
-}
-
-/*********************************************
- *** U T I L I T Y R O U T I N E S ***
- *********************************************/
-
-TREE *
-linkcheck(t, d, i)
- TREE *t;
- int d, i; /* inode # and device # */
-{
- HASH *h;
-
- h = Hlookup(inodeH,i,d);
- if (h)
- return (h->Htree);
- Hinsert(inodeH, i, d, NULL, t);
- return (NULL);
-}
-
-char *
-uconvert(uid)
- uid_t uid;
-{
- struct passwd *pw;
- char *p;
- HASH *u;
-
- u = Hlookup(uidH, uid, 0);
- if (u)
- return (u->Hname);
- pw = getpwuid (uid);
- if (pw == NULL)
- return ("");
- p = strdup(pw->pw_name);
- Hinsert(uidH, uid, 0, p, NULL);
- return (p);
-}
-
-char *
-gconvert(gid)
- gid_t gid;
-{
- struct group *gr;
- char *p;
- HASH *g;
-
- g = Hlookup(gidH, gid, 0);
- if (g)
- return (g->Hname);
- gr = getgrgid(gid);
- if (gr == NULL)
- return ("");
- p = strdup(gr->gr_name);
- Hinsert(gidH, gid, 0, p, NULL);
- return (p);
-}
-
-char *
-changeuid(namep, passwordp, fileuid, filegid)
- char *namep, *passwordp;
- uid_t fileuid;
- gid_t filegid;
-{
- char *group,*account,*pswdp;
- struct passwd *pwd;
- struct group *grp;
-#if CMUCS
- struct account *acc;
- struct ttyloc tlc;
-#endif /* CMUCS */
- int status = ACCESS_CODE_OK;
- char nbuf[STRINGLENGTH];
- static char errbuf[STRINGLENGTH];
-#if CMUCS
- int *grps;
-#endif /* CMUCS */
- char *p = NULL;
-
- if (namep == NULL) {
- pwd = getpwuid(fileuid);
- if (pwd == NULL) {
- (void) snprintf(errbuf, sizeof errbuf,
- "Reason: Unknown user id %u", fileuid);
- return (errbuf);
- }
- grp = getgrgid(filegid);
- if (grp)
- (void) strlcpy(group=nbuf, grp->gr_name, sizeof nbuf);
- else
- group = NULL;
- account = NULL;
- pswdp = NULL;
- } else {
- (void) strlcpy(nbuf, namep, sizeof nbuf);
- account = group = strchr(nbuf, ',');
- if (group != NULL) {
- *group++ = '\0';
- account = strchr(group, ',');
- if (account != NULL) {
- *account++ = '\0';
- if (*account == '\0')
- account = NULL;
- }
- if (*group == '\0')
- group = NULL;
- }
- pwd = getpwnam(nbuf);
- if (pwd == NULL) {
- (void) snprintf(errbuf, sizeof errbuf,
- "Reason: Unknown user %s", nbuf);
- return (errbuf);
- }
- if (strcmp(nbuf, DEFUSER) == 0)
- pswdp = NULL;
- else
- pswdp = passwordp ? passwordp : "";
-#ifdef AFS
- if (strcmp(nbuf, DEFUSER) != 0) {
- char *reason;
-
- setpag(); /* set a pag */
- if (ka_UserAuthenticate(pwd->pw_name, "", 0,
- pswdp, 1, &reason)) {
- (void) snprintf(errbuf, sizeof errbuf,
- "AFS authentication failed, %s",
- reason);
- logerr ("Attempt by %s; %s", nbuf, errbuf);
- return (errbuf);
- }
- }
-#endif
- }
- if (getuid() != 0) {
- if (getuid() == pwd->pw_uid)
- return (NULL);
- if (strcmp(pwd->pw_name, DEFUSER) == 0)
- return (NULL);
- logerr("Fileserver not superuser");
- return ("Reason: fileserver is not running privileged");
- }
-#if CMUCS
- tlc.tlc_hostid = TLC_UNKHOST;
- tlc.tlc_ttyid = TLC_UNKTTY;
- if (okaccess(pwd->pw_name,ACCESS_TYPE_SU,0,-1,tlc) != 1)
- status = ACCESS_CODE_DENIED;
- else {
- grp = NULL;
- acc = NULL;
- status = oklogin(pwd->pw_name, group, &account, pswdp, &pwd,
- &grp, &acc, &grps);
- if (status == ACCESS_CODE_OK) {
- if ((p = okpassword(pswdp, pwd->pw_name, pwd->pw_gecos)) != NULL)
- status = ACCESS_CODE_INSECUREPWD;
- }
- }
-#else /* CMUCS */
- status = ACCESS_CODE_OK;
- if (namep && strcmp(pwd->pw_name, DEFUSER) != 0)
- if (strcmp(pwd->pw_passwd, crypt(pswdp, pwd->pw_passwd)))
- status = ACCESS_CODE_BADPASSWORD;
-#endif /* CMUCS */
- switch (status) {
- case ACCESS_CODE_OK:
- break;
- case ACCESS_CODE_BADPASSWORD:
- p = "Reason: Invalid password";
- break;
-#if CMUCS
- case ACCESS_CODE_INSECUREPWD:
- (void) snprintf(errbuf, sizeof errbuf, "Reason: %s", p);
- p = errbuf;
- break;
- case ACCESS_CODE_DENIED:
- p = "Reason: Access denied";
- break;
- case ACCESS_CODE_NOUSER:
- p = errbuf;
- break;
- case ACCESS_CODE_ACCEXPIRED:
- p = "Reason: Account expired";
- break;
- case ACCESS_CODE_GRPEXPIRED:
- p = "Reason: Group expired";
- break;
- case ACCESS_CODE_ACCNOTVALID:
- p = "Reason: Invalid account";
- break;
- case ACCESS_CODE_MANYDEFACC:
- p = "Reason: User has more than one default account";
- break;
- case ACCESS_CODE_NOACCFORGRP:
- p = "Reason: No account for group";
- break;
- case ACCESS_CODE_NOGRPFORACC:
- p = "Reason: No group for account";
- break;
- case ACCESS_CODE_NOGRPDEFACC:
- p = "Reason: No group for default account";
- break;
- case ACCESS_CODE_NOTGRPMEMB:
- p = "Reason: Not member of group";
- break;
- case ACCESS_CODE_NOTDEFMEMB:
- p = "Reason: Not member of default group";
- break;
- case ACCESS_CODE_OOPS:
- p = "Reason: Internal error";
- break;
-#endif /* CMUCS */
- default:
- (void) snprintf(errbuf, sizeof errbuf, "Reason: Status %d",
- status);
- p = errbuf;
- break;
- }
- if (pwd == NULL)
- return (p);
- if (status != ACCESS_CODE_OK) {
- logerr("Login failure for %s", pwd->pw_name);
- logerr("%s", p);
-#if CMUCS
- logaccess(pwd->pw_name, ACCESS_TYPE_SUP, status, 0, -1, tlc);
-#endif /* CMUCS */
- return (p);
- }
-#if CMUCS
- if (setgroups(grps[0], &grps[1]) < 0)
- logerr("setgroups: %%m");
- if (setresgid(grp->gr_gid, grp->gr_gid, grp->gr_gid) < 0)
- logerr("setresgid: %%m");
- if (setresuid(pwd->pw_uid, pwd->pw_uid, pwd->pw_uid) < 0)
- logerr("setresuid: %%m");
-#else /* CMUCS */
-#ifdef HAS_LOGIN_CAP
- if (setusercontext(NULL, pwd, pwd->pw_uid, LOGIN_SETALL) < 0)
- return ("Error setting user context");
-#else
- if (initgroups(pwd->pw_name,pwd->pw_gid) < 0)
- return ("Error setting group list");
- if (setresgid(pwd->pw_gid, pwd->pw_gid, pwd->pw_gid) < 0)
- logerr("setresgid: %%m");
-#ifndef NO_SETLOGIN
- if (setlogin(pwd->pw_name) < 0)
- logerr("setlogin: %%m");
-#endif
- if (setresuid(pwd->pw_uid, pwd->pw_uid, pwd->pw_uid) < 0)
- logerr("setresuid: %%m");
-#endif /* HAS_LOGIN_CAP */
-#endif /* CMUCS */
- return (NULL);
-}
-
-void
-goaway(char *fmt,...)
-{
- char buf[STRINGLENGTH];
- va_list ap;
-
- va_start(ap, fmt);
- (void) netcrypt(NULL);
-
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- strlcat(buf, " [", sizeof(buf));
- strlcat(buf, remotehost(), sizeof(buf));
- strlcat(buf, "]", sizeof(buf));
- goawayreason = strdup(buf);
- (void) msggoaway();
- logerr("%s", buf);
- longjmp(sjbuf, TRUE);
-}
-
-char *
-fmttime(time)
- time_t time;
-{
- static char buf[16];
- char *p;
-
- /*
- * Copy ctime to buf, stripping day of week, year, and newline.
- * E.g.: "Thu Nov 24 18:22:48 1986\n" -> "Nov 24 18:22:48"
- */
- p = ctime(&time) + 4;
- (void) strlcpy(buf, p, sizeof(buf));
- return (buf);
-}
-
-/*
- * Determine whether the file referenced by the file descriptor 'handle' can
- * be trusted, namely is it a file resident in the local file system.
- *
- * The main method of operation is to perform operations on the file
- * descriptor so that an attempt to spoof the checks should fail, for
- * example renamimg the file from underneath us and/or changing where the
- * file lives from underneath us.
- *
- * returns: -1 for error, indicating that we can not tell
- * 0 for file is definitely not local, or it is an RFS link
- * 1 for file is local and can be trusted
- *
- * Side effect: copies the stat information into the supplied buffer,
- * regardless of the type of file system the file resides.
- *
- * Currently, the cases that we try to distinguish are RFS, AFS, NFS and
- * UFS, where the latter is considered a trusted file. We assume that the
- * caller has disabled link following and will detect an attempt to access
- * a file through an RFS link, except in the case the last component is
- * an RFS link. With link following disabled, the last component itself is
- * interpreted as a regular file if it is really an RFS link, so we
- * disallow the RFS link identified by group "symlink" and mode "IEXEC by
- * owner only". An AFS file is
- * detected by trying the VIOCIGETCELL ioctl, which is one of the few AFS
- * ioctls which operate on a file descriptor. Note, this AFS ioctl is
- * implemented in the cache manager, so the decision does not involve a
- * query with the AFS file server. An NFS file is detected by looking at
- * the major device number and seeing if it matches the known values for
- * MACH NSF/Sun OS 3.x or Sun OS 4.x.
- *
- * Having the fstatfs() system call would make this routine easier and
- * more reliable.
- *
- * Note, in order to make the checks simpler, the file referenced by the
- * file descriptor can not be a BSD style symlink. Even with symlink
- * following of the last path component disabled, the attempt to open a
- * file which is a symlink will succeed, so we check for the BSD symlink
- * file type here. Also, the link following on/off and RFS file types
- * are only relevant in a MACH environment.
- */
-#ifdef AFS
-#include <sys/viceioctl.h>
-#endif
-
-#define SYMLINK_GRP 64
-
-int local_file(handle, sinfo)
- int handle;
- struct stat *sinfo;
-{
- struct stat sb;
-#ifdef VIOCIGETCELL
- /*
- * dummies for the AFS ioctl
- */
- struct ViceIoctl vdata;
- char cellname[512];
-#endif /* VIOCIGETCELL */
-
- if (fstat(handle, &sb) < 0)
- return(-1);
- if (sinfo != NULL)
- *sinfo = sb;
-
-#if CMUCS
- /*
- * If the following test succeeds, then the file referenced by
- * 'handle' is actually an RFS link, so we will not trust it.
- * See <sys/inode.h>.
- */
- if (sb.st_gid == SYMLINK_GRP
- && (sb.st_mode & (S_IFMT|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)))
- == (S_IFREG|S_IEXEC))
- return(0);
-#endif /* CMUCS */
-
- /*
- * Do not trust BSD style symlinks either.
- */
- if (S_ISLNK(sb.st_mode))
- return(0);
-
-#ifdef VIOCIGETCELL
- /*
- * This is the VIOCIGETCELL ioctl, which takes an fd, not
- * a path name. If it succeeds, then the file is in AFS.
- *
- * On failure, ENOTTY indicates that the file was not in
- * AFS; all other errors are pessimistically assumed to be
- * a temporary AFS error.
- */
- vdata.in_size = 0;
- vdata.out_size = sizeof(cellname);
- vdata.out = cellname;
- if (ioctl(handle, VIOCIGETCELL, (char *)&vdata) != -1)
- return(0);
- if (errno != ENOTTY)
- return(-1);
-#endif /* VIOCIGETCELL */
-
- /*
- * Verify the file is not in NFS.
- */
-#ifdef __SVR4
- {
- struct statvfs sf;
-
- if (fstatvfs(handle, &sf) == -1)
- return(-1);
- return strncmp(sf.f_basetype, "nfs", 3) != 0;
- }
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
- {
- struct statfs sf;
- if (fstatfs(handle, &sf) == -1)
- return(-1);
- return strncmp(sf.f_fstypename, "nfs", 3) != 0;
- }
-#elif defined(__linux__)
- {
- struct statfs sf;
-
- if (fstatfs(handle, &sf) == -1)
- return(-1);
- return sf.f_type != NFS_SUPER_MAGIC;
- }
-#else
- /*
- * Sun OS 3.x use major device 255 for NFS files;
- * Sun OS 4.x seems to use 130 (I have only determined
- * this empirically -- DLC). Without a fstatfs()
- * system call, this will have to do for now.
- */
-
- return !(major(sb.st_dev) == 255 || major(sb.st_dev) == 130);
-
-#endif
-}
-
-/*
- * Companion routine for ensuring that a local file can be trusted. Compare
- * various pieces of the stat information to make sure that the file can be
- * trusted. Returns true for stat information which meets the criteria
- * for being trustworthy. The main paranoia is to prevent a hard link to
- * a root owned file. Since the link could be removed after the file is
- * opened, a simply fstat() can not be relied upon. The two stat buffers
- * for comparison should come from a stat() on the file name and a following
- * fstat() on the open file. Some of the following checks are also an
- * additional level of paranoia. Also, this test will fail (correctly) if
- * either or both of the stat structures have all fields zeroed; typically
- * due to a stat() failure.
- */
-int
-stat_info_ok(sb1, sb2)
- struct stat *sb1, *sb2;
-{
- return (sb1->st_ino == sb2->st_ino && /* Still the same file */
- sb1->st_dev == sb2->st_dev && /* On the same device */
- sb1->st_mode == sb2->st_mode && /* Perms (and type) same */
- S_ISREG(sb1->st_mode) && /* Only allow reg files */
- (sb1->st_mode & 077) == 0 && /* Owner only perms */
- sb1->st_nlink == sb2->st_nlink && /* # hard links same... */
- sb1->st_nlink == 1 && /* and only 1 */
- sb1->st_uid == sb2->st_uid && /* owner and ... */
- sb1->st_gid == sb2->st_gid && /* group unchanged */
- sb1->st_mtime == sb2->st_mtime && /* Unmodified between stats */
- sb1->st_ctime == sb2->st_ctime); /* Inode unchanged. Hopefully
- a catch-all paranoid test */
-}
-
-#if MACH
-/*
- * Twiddle symbolic/RFS link following on/off. This is a no-op in a non
- * CMUCS/MACH environment. Also, the setmodes/getmodes interface is used
- * mainly because it is simpler than using table(2) directly.
- */
-#include <sys/table.h>
-
-int
-link_nofollow(on)
- int on;
-{
- static int modes = -1;
-
- if (modes == -1 && (modes = getmodes()) == -1)
- return(-1);
- if (on)
- return(setmodes(modes | UMODE_NOFOLLOW));
- return(setmodes(modes));
-}
-#else /* MACH */
-/*ARGSUSED*/
-int
-link_nofollow(on)
- int on;
-{
- return(0);
-}
-#endif /* MACH */
-
-int
-opentmp(path, psize)
- char *path;
- size_t psize;
-{
- char *tdir;
-
- if ((tdir = getenv("TMPDIR")) == NULL || *tdir == '\0')
- tdir = "/tmp";
- if (snprintf(path, psize, "%s/supfilesrv.XXXXXXXXXX", tdir) >= psize) {
- errno = ENAMETOOLONG;
- return (-1);
- }
- return (mkstemp(path));
-}
diff --git a/usr.bin/sup/src/supmsg.c b/usr.bin/sup/src/supmsg.c
deleted file mode 100644
index adca8475f90..00000000000
--- a/usr.bin/sup/src/supmsg.c
+++ /dev/null
@@ -1,786 +0,0 @@
-/* $OpenBSD: supmsg.c,v 1.12 2002/08/12 00:42:56 aaron Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 2.4 92/09/09 22:05:17 mrt
- * Moved PFI definition under __STDC__ conditional since it
- * is already defined in libc.h in this case.
- * [92/09/01 mrt]
- *
- * Revision 2.3 92/08/11 12:08:12 mrt
- * Added copyright
- * [92/08/10 mrt]
- * Brad's changes: Delinted, Incorporated updated variable
- * argument list usage from old msgxfer.c
- * [92/07/24 mrt]
- *
- * Revision 2.2 89/08/23 15:02:56 gm0w
- * Created from separate message modules.
- * [89/08/14 gm0w]
- *
- **********************************************************************
- */
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libc.h>
-#include <c.h>
-#include "supcdefs.h"
-#include "supextern.h"
-#define MSGSUBR
-#define MSGFILE
-#include "supmsg.h"
-
-/*
- * signon message
- */
-extern int pgmver; /* program version of partner */
-extern int pgmversion; /* my program version */
-extern char *scmver; /* scm version of partner */
-extern pid_t fspid; /* process id of fileserver */
-
-static int refuseone(TREE *, void *);
-static int listone(TREE *, void *);
-static int needone(TREE *, void *);
-static int denyone(TREE *, void *);
-static int writeone(TREE *, void *);
-
-int
-msgsignon()
-{
- int x;
-
- if (server) {
- x = readmsg(MSGSIGNON);
- if (x == SCMOK)
- x = readint(&protver);
- if (x == SCMOK)
- x = readint(&pgmver);
- if (x == SCMOK)
- x = readstring(&scmver);
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGSIGNON);
- if (x == SCMOK)
- x = writeint(PROTOVERSION);
- if (x == SCMOK)
- x = writeint(pgmversion);
- if (x == SCMOK)
- x = writestring(scmversion);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-int
-msgsignonack()
-{
- int x;
-
- if (server) {
- x = writemsg(MSGSIGNONACK);
- if (x == SCMOK)
- x = writeint(PROTOVERSION);
- if (x == SCMOK)
- x = writeint(pgmversion);
- if (x == SCMOK)
- x = writestring(scmversion);
- if (x == SCMOK)
- x = writeint(fspid);
- if (x == SCMOK)
- x = writemend();
- } else {
- x = readmsg(MSGSIGNONACK);
- if (x == SCMOK)
- x = readint(&protver);
- if (x == SCMOK)
- x = readint(&pgmver);
- if (x == SCMOK)
- x = readstring(&scmver);
- if (x == SCMOK)
- x = readint(&fspid);
- if (x == SCMOK)
- x = readmend();
- }
- return (x);
-}
-
-/*
- * setup message
- */
-extern int xpatch; /* setup crosspatch to a new client */
-extern char *xuser; /* user,group,acct for crosspatch */
-extern char *collname; /* base directory */
-extern char *basedir; /* base directory */
-extern int basedev; /* base directory device */
-extern int baseino; /* base directory inode */
-extern time_t lasttime; /* time of last upgrade */
-extern int listonly; /* only listing files, no data xfer */
-extern int newonly; /* only send new files */
-extern char *release; /* release name */
-extern int setupack; /* ack return value for setup */
-
-int
-msgsetup()
-{
- int x;
-
- if (server) {
- x = readmsg(MSGSETUP);
- if (x != SCMOK)
- return (x);
- if (protver >= 7) {
- x = readint(&xpatch);
- if (x != SCMOK)
- return (x);
- } else
- xpatch = FALSE;
- if (xpatch) {
- x = readstring(&xuser);
- if (x != SCMOK)
- return (x);
- return (readmend());
- }
- x = readstring(&collname);
- if (x == SCMOK)
- x = readint((int *)&lasttime);
- if (x == SCMOK)
- x = readstring(&basedir);
- if (x == SCMOK)
- x = readint(&basedev);
- if (x == SCMOK)
- x = readint(&baseino);
- if (x == SCMOK)
- x = readint(&listonly);
- if (x == SCMOK)
- x = readint(&newonly);
- if (x == SCMOK) {
- if (protver < 6)
- release = NULL;
- else
- x = readstring(&release);
- }
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGSETUP);
- if (x != SCMOK)
- return (x);
- if (protver >= 7) {
- x = writeint(xpatch);
- if (x != SCMOK)
- return (x);
- }
- if (xpatch) {
- x = writestring(xuser);
- if (x != SCMOK)
- return (x);
- return (writemend());
- }
- if (x == SCMOK)
- x = writestring(collname);
- if (x == SCMOK)
- x = writeint((int)lasttime);
- if (x == SCMOK)
- x = writestring(basedir);
- if (x == SCMOK)
- x = writeint(basedev);
- if (x == SCMOK)
- x = writeint(baseino);
- if (x == SCMOK)
- x = writeint(listonly);
- if (x == SCMOK)
- x = writeint(newonly);
- if (x == SCMOK && protver >= 6)
- x = writestring(release);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-int
-msgsetupack()
-{
-
- if (server)
- return (writemint(MSGSETUPACK, setupack));
- return (readmint(MSGSETUPACK, &setupack));
-}
-
-/*
- * crypt test message
- */
-extern char *crypttest; /* encryption test string */
-
-int
-msgcrypt()
-{
-
- if (server)
- return (readmstr(MSGCRYPT, &crypttest));
- return (writemstr(MSGCRYPT, crypttest));
-}
-
-int
-msgcryptok()
-{
-
- if (server)
- return (writemnull(MSGCRYPTOK));
- return (readmnull(MSGCRYPTOK));
-}
-
-/*
- * login message
- */
-extern char *logcrypt; /* login encryption test */
-extern char *loguser; /* login username */
-extern char *logpswd; /* password for login */
-extern int logack; /* login ack status */
-extern char *logerror; /* error from login */
-
-int
-msglogin()
-{
- int x;
-
- if (server) {
- x = readmsg(MSGLOGIN);
- if (x == SCMOK)
- x = readstring(&logcrypt);
- if (x == SCMOK)
- x = readstring(&loguser);
- if (x == SCMOK)
- x = readstring(&logpswd);
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGLOGIN);
- if (x == SCMOK)
- x = writestring(logcrypt);
- if (x == SCMOK)
- x = writestring(loguser);
- if (x == SCMOK)
- x = writestring(logpswd);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-int
-msglogack()
-{
- int x;
-
- if (server) {
- x = writemsg(MSGLOGACK);
- if (x == SCMOK)
- x = writeint(logack);
- if (x == SCMOK)
- x = writestring(logerror);
- if (x == SCMOK)
- x = writemend();
- } else {
- x = readmsg(MSGLOGACK);
- if (x == SCMOK)
- x = readint(&logack);
- if (x == SCMOK)
- x = readstring(&logerror);
- if (x == SCMOK)
- x = readmend();
- }
- return (x);
-}
-
-/*
- * refuse list message
- */
-extern TREE *refuseT; /* tree of files to refuse */
-
-static int
-refuseone(t, v)
- TREE *t;
- void *v;
-{
- return (writestring(t->Tname));
-}
-
-int
-msgrefuse()
-{
- int x;
-
- if (server) {
- char *name;
-
- x = readmsg(MSGREFUSE);
- if (x == SCMOK)
- x = readstring(&name);
- while (x == SCMOK) {
- if (name == NULL)
- break;
- (void) Tinsert(&refuseT, name, FALSE);
- free(name);
- x = readstring(&name);
- }
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGREFUSE);
- if (x == SCMOK)
- x = Tprocess(refuseT, refuseone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-/*
- * list files message
- */
-extern TREE *listT; /* tree of files to list */
-extern time_t scantime; /* time that collection was scanned */
-
-static int
-listone(t, v)
- TREE *t;
- void *v;
-{
- int x;
-
- x = writestring(t->Tname);
- if (x == SCMOK)
- x = writeint((int)t->Tmode);
- if (x == SCMOK)
- x = writeint((int)t->Tflags);
- if (x == SCMOK)
- x = writeint(t->Tmtime);
- return (x);
-}
-
-int
-msglist()
-{
- int x;
-
- if (server) {
- x = writemsg(MSGLIST);
- if (x == SCMOK)
- x = Tprocess(listT, listone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = writeint((int)scantime);
- if (x == SCMOK)
- x = writemend();
- } else {
- char *name;
- int mode, flags, mtime;
- TREE *t;
-
- x = readmsg(MSGLIST);
- if (x == SCMOK)
- x = readstring(&name);
- while (x == SCMOK) {
- if (name == NULL)
- break;
- x = readint(&mode);
- if (x == SCMOK)
- x = readint(&flags);
- if (x == SCMOK)
- x = readint(&mtime);
- if (x != SCMOK)
- break;
- t = Tinsert(&listT, name, TRUE);
- free(name);
- t->Tmode = mode;
- t->Tflags = flags;
- t->Tmtime = mtime;
- x = readstring(&name);
- }
- if (x == SCMOK)
- x = readint((int *)&scantime);
- if (x == SCMOK)
- x = readmend();
- }
- return (x);
-}
-
-/*
- * files needed message
- */
-extern TREE *needT; /* tree of files to need */
-
-static int
-needone(t, v)
- TREE *t;
- void *v;
-{
- int x;
-
- x = writestring(t->Tname);
- if (x == SCMOK)
- x = writeint((t->Tflags&FUPDATE) != 0);
- return (x);
-}
-
-int msgneed()
-{
- int x;
-
- if (server) {
- char *name;
- int update;
- TREE *t;
-
- x = readmsg(MSGNEED);
- if (x == SCMOK)
- x = readstring(&name);
- while (x == SCMOK) {
- if (name == NULL)
- break;
- x = readint(&update);
- if (x != SCMOK)
- break;
- t = Tinsert(&needT, name, TRUE);
- free(name);
- if (update)
- t->Tflags |= FUPDATE;
- x = readstring(&name);
- }
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGNEED);
- if (x == SCMOK)
- x = Tprocess(needT, needone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-/*
- * files denied message
- */
-extern TREE *denyT; /* tree of files to deny */
-
-static int
-denyone(t, v)
- TREE *t;
- void *v;
-{
-
- return (writestring(t->Tname));
-}
-
-int
-msgdeny()
-{
- int x;
-
- if (server) {
- x = writemsg(MSGDENY);
- if (x == SCMOK)
- x = Tprocess(denyT,denyone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = writemend();
- } else {
- char *name;
-
- x = readmsg(MSGDENY);
- if (x == SCMOK)
- x = readstring(&name);
- while (x == SCMOK) {
- if (name == NULL)
- break;
- (void) Tinsert(&denyT, name, FALSE);
- free(name);
- x = readstring(&name);
- }
- if (x == SCMOK)
- x = readmend();
- }
- return (x);
-}
-
-/*
- * send file message
- */
-int
-msgsend()
-{
-
- if (server)
- return (readmnull(MSGSEND));
- return (writemnull(MSGSEND));
-}
-
-/*
- * receive file message
- */
-extern TREE *upgradeT; /* pointer to file being upgraded */
-
-static int
-writeone(t, v)
- TREE *t;
- void *v;
-{
-
- return (writestring(t->Tname));
-}
-
-
-int
-msgrecv(int (*xferfile)(TREE *, va_list),...)
-{
- va_list args;
- int x;
- TREE *t = upgradeT;
- va_start(args,xferfile);
- if (server) {
- x = writemsg (MSGRECV);
- if (t == NULL) {
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = writemend();
- goto done;
- }
- if (x == SCMOK)
- x = writestring(t->Tname);
- if (x == SCMOK)
- x = writeint(t->Tmode);
- if (t->Tmode == 0) {
- if (x == SCMOK)
- x = writemend();
- goto done;
- }
- if (x == SCMOK)
- x = writeint(t->Tflags);
- if (x == SCMOK)
- x = writestring(t->Tuser);
- if (x == SCMOK)
- x = writestring(t->Tgroup);
- if (x == SCMOK)
- x = writeint(t->Tmtime);
- if (x == SCMOK)
- x = Tprocess(t->Tlink, writeone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = Tprocess(t->Texec,writeone, NULL);
- if (x == SCMOK)
- x = writestring(NULL);
- if (x == SCMOK)
- x = (*xferfile)(t, args);
- if (x == SCMOK)
- x = writemend();
- } else {
- char *linkname, *execcmd;
-
- if (t == NULL) {
- x = SCMERR;
- goto done;
- }
- x = readmsg (MSGRECV);
- if (x == SCMOK)
- x = readstring(&t->Tname);
- if (x == SCMOK && t->Tname == NULL) {
- x = readmend();
- if (x == SCMOK)
- x = (*xferfile)(NULL, args);
- goto done;
- }
- if (x == SCMOK)
- x = readint(&t->Tmode);
- if (t->Tmode == 0) {
- x = readmend();
- if (x == SCMOK)
- x = (*xferfile)(t, args);
- goto done;
- }
- if (x == SCMOK)
- x = readint(&t->Tflags);
- if (x == SCMOK)
- x = readstring(&t->Tuser);
- if (x == SCMOK)
- x = readstring(&t->Tgroup);
- if (x == SCMOK)
- x = readint(&t->Tmtime);
- t->Tlink = NULL;
- if (x == SCMOK)
- x = readstring(&linkname);
- while (x == SCMOK) {
- if (linkname == NULL)
- break;
- (void) Tinsert(&t->Tlink, linkname, FALSE);
- free(linkname);
- x = readstring(&linkname);
- }
- t->Texec = NULL;
- if (x == SCMOK)
- x = readstring(&execcmd);
- while (x == SCMOK) {
- if (execcmd == NULL)
- break;
- (void) Tinsert(&t->Texec, execcmd, FALSE);
- free(execcmd);
- x = readstring(&execcmd);
- }
- if (x == SCMOK)
- x = (*xferfile)(t, args);
- if (x == SCMOK)
- x = readmend();
- }
-
-done:
- va_end(args);
- return (x);
-}
-
-/*
- * protocol done message
- */
-extern int doneack;
-extern char *donereason;
-
-int
-msgdone()
-{
- int x;
-
- if (protver < 6) {
- printf("Error, msgdone should not have been called.");
- return (SCMERR);
- }
- if (server) {
- x = readmsg(MSGDONE);
- if (x == SCMOK)
- x = readint(&doneack);
- if (x == SCMOK)
- x = readstring(&donereason);
- if (x == SCMOK)
- x = readmend();
- } else {
- x = writemsg(MSGDONE);
- if (x == SCMOK)
- x = writeint(doneack);
- if (x == SCMOK)
- x = writestring(donereason);
- if (x == SCMOK)
- x = writemend();
- }
- return (x);
-}
-
-/*
- * go away message
- */
-extern char *goawayreason; /* reason for goaway */
-
-int
-msggoaway()
-{
-
- return (writemstr(MSGGOAWAY, goawayreason));
-}
-
-/*
- * cross-patch protocol message
- */
-extern int xargc; /* arg count for crosspatch */
-extern char **xargv; /* arg array for crosspatch */
-
-int
-msgxpatch()
-{
- int x, i;
-
- if (server) {
- x = readmsg(MSGXPATCH);
- if (x != SCMOK)
- return (x);
- x = readint(&xargc);
- if (x != SCMOK)
- return (x);
- xargc += 2;
- xargv = (char **)calloc(xargc+1, sizeof (char *));
- if (xargv == NULL)
- return (SCMERR);
- for (i = 2; i < xargc; i++) {
- x = readstring(&xargv[i]);
- if (x != SCMOK)
- return (x);
- }
- x = readmend();
- } else {
- x = writemsg(MSGXPATCH);
- if (x != SCMOK)
- return (x);
- x = writeint(xargc);
- if (x != SCMOK)
- return (x);
- for (i = 0; i < xargc; i++) {
- x = writestring(xargv[i]);
- if (x != SCMOK)
- return (x);
- }
- x = writemend();
- }
- return (x);
-}
-
-/*
- * Compression check protocol message
- */
-extern int docompress; /* Compress file before sending? */
-
-int
-msgcompress()
-{
-
- if (server)
- return (readmint(MSGCOMPRESS, &docompress));
- return (writemint(MSGCOMPRESS, docompress));
-}
diff --git a/usr.bin/sup/src/supmsg.h b/usr.bin/sup/src/supmsg.h
deleted file mode 100644
index 798b42bee50..00000000000
--- a/usr.bin/sup/src/supmsg.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* $OpenBSD: supmsg.h,v 1.7 2002/06/12 06:07:16 mpech Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * supmsg.h - global definitions/variables used in msg routines.
- *
- **********************************************************************
- * HISTORY
- *
- * 7-July-93 Nate Williams at Montana State University
- * Modified SUP to use gzip based compression when sending files
- * across the network to save BandWidth
- *
- * Revision 1.7 92/08/11 12:08:20 mrt
- * Added copyright.
- * [92/08/10 mrt]
- *
- * Revision 1.6 89/08/23 14:56:42 gm0w
- * Changed MSGF to MSG constants.
- * [89/08/23 gm0w]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added crosspatch support. Removed nameserver support.
- *
- * 29-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added "release" support.
- *
- * 27-May-87 Doug Philips (dwp) at Carnegie-Mellon University
- * Added MSGFDONE and subvalues, added doneack and donereason.
- *
- * 20-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added changes to make lint happy.
- *
- * 04-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed hostname to hostT to support multiple repositories per
- * collection. Added FSETUPBUSY to tell clients that server is
- * currently busy.
- *
- * 19-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Created.
- *
- **********************************************************************
- */
-
-/* Special messages reserved for SCM */
-#define MSGGOAWAY (-1) /* see scm.c */
-
-/* Message types -- see supmsg.c */
-#define MSGSIGNON (101)
-#define MSGSIGNONACK (102)
-#define MSGSETUP (103)
-#define MSGSETUPACK (104)
-#define MSGLOGIN (105)
-#define MSGLOGACK (106)
-#define MSGCRYPT (107)
-#define MSGCRYPTOK (108)
-#define MSGREFUSE (109)
-#define MSGLIST (110)
-#define MSGNEED (111)
-#define MSGDENY (112)
-#define MSGSEND (113)
-#define MSGRECV (114)
-#define MSGDONE (115)
-#define MSGXPATCH (117)
-#define MSGCOMPRESS (118)
-
-/* MSGSETUPACK data codes - setupack */
-#define FSETUPOK (999)
-#define FSETUPHOST (998)
-#define FSETUPSAME (997)
-#define FSETUPOLD (996)
-#define FSETUPBUSY (995)
-#define FSETUPRELEASE (994)
-
-/* MSGLOGACK data codes - loginack */
-#define FLOGOK (989)
-#define FLOGNG (988)
-
-/* MSGDONE data codes - doneack */
-#define FDONESUCCESS (979)
-#define FDONEDONTLOG (978)
-#define FDONESRVERROR (977)
-#define FDONEUSRERROR (976)
-#define FDONEGOAWAY (975)
-
-#ifdef MSGSUBR
-
-/* used in all msg routines */
-extern int server; /* true if we are the server */
-extern int protver; /* protocol version of partner */
-
-#else /* MSGSUBR */
-
-#ifdef MSGFILE
-#define EXTERN
-#else /* MSGFILE */
-#define EXTERN extern
-#endif /* MSGFILE */
-
-/* used in all msg routines */
-EXTERN int server; /* true if we are the server */
-
-/* msggoaway */
-EXTERN char *goawayreason; /* reason for goaway */
-
-/* msgsignon */
-EXTERN int pgmversion; /* version of this program */
-EXTERN int protver; /* protocol version of partner */
-EXTERN int pgmver; /* program version of partner */
-EXTERN char *scmver; /* scm version of partner */
-EXTERN pid_t fspid; /* process id of fileserver */
-
-/* msgsetup */
-EXTERN int xpatch; /* setup crosspatch to a new client */
-EXTERN char *xuser; /* user for crosspatch */
-EXTERN char *collname; /* collection name */
-EXTERN char *basedir; /* base directory */
-EXTERN int basedev; /* base directory device */
-EXTERN int baseino; /* base directory inode */
-EXTERN time_t lasttime; /* time of last upgrade */
-EXTERN int listonly; /* only listing files, no data xfer */
-EXTERN int newonly; /* only send new files */
-EXTERN char *release; /* release name */
-EXTERN int setupack; /* ack return value for setup */
-
-/* msgcrypt */
-EXTERN char *crypttest; /* encryption test string */
-
-/* msglogin */
-EXTERN char *logcrypt; /* login encryption test */
-EXTERN char *loguser; /* login username */
-EXTERN char *logpswd; /* password for login */
-EXTERN int logack; /* login ack status */
-EXTERN char *logerror; /* error string from oklogin */
-
-/* msgxpatch */
-EXTERN int xargc; /* arg count for crosspatch */
-EXTERN char **xargv; /* arg array for crosspatch */
-
-/* msgrefuse */
-EXTERN TREE *refuseT; /* tree of files to refuse */
-
-/* msglist */
-EXTERN TREE *listT; /* tree of files to list */
-EXTERN time_t scantime; /* time that collection was scanned */
-
-/* msgneed */
-EXTERN TREE *needT; /* tree of files to need */
-
-/* msgdeny */
-EXTERN TREE *denyT; /* tree of files to deny */
-
-/* msgrecv */
-/* msgsend */
-EXTERN TREE *upgradeT; /* pointer to file being upgraded */
-
-/* msgdone */
-EXTERN int doneack; /* done ack status */
-EXTERN char *donereason; /* set if indicated by doneack */
-
-#undef EXTERN
-
-#endif /* MSGSUBR */
diff --git a/usr.bin/sup/src/supscan.c b/usr.bin/sup/src/supscan.c
deleted file mode 100644
index 3ab619fa60a..00000000000
--- a/usr.bin/sup/src/supscan.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/* $OpenBSD: supscan.c,v 1.15 2007/09/11 15:47:17 gilles Exp $ */
-
-/*
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-/*
- * supscan -- SUP Scan File Builder
- *
- * Usage: supscan [ -v ] collection [ basedir ]
- * supscan [ -v ] -f dirfile
- * supscan [ -v ] -s
- * -f "file" -- use dirfile instead of system coll.dir
- * -s "system" -- perform scan for system supfile
- * -v "verbose" -- print messages as you go
- * collection -- name of the desired collection if not -s
- * basedir -- name of the base directory, if not
- * the default or recorded in coll.dir
- * dirfile -- name of replacement for system coll.dir.
- *
- **********************************************************************
- * HISTORY
- * Revision 1.14 92/08/11 12:08:30 mrt
- * Picked up Brad's deliniting and variable argument changes
- * [92/08/10 mrt]
- *
- * Revision 1.13 92/02/08 18:04:44 dlc
- * Once again revised localhost(). Do not use gethostbyname() at
- * all, but assume that the host names in the coll.host file are at
- * least a prefix of the fully qualified name. Modcoll (and related
- * scripts) will maintain this fact.
- * [92/02/08 dlc]
- *
- * Revision 1.12 91/08/17 23:35:31 dlc
- * Changes to localhost() function:
- * - Use host name in kernel for local host name; assume it is
- * fully qualified.
- * - If gethostbyname() of host to see if we are the repository
- * fails, with TRY_AGAIN or NO_RECOVERY, then use the "host"
- * parameter. Print a diagnostic in this case.
- * [91/08/17 dlc]
- *
- * Revision 1.11 90/04/04 10:53:01 dlc
- * Changed localhost to retry getting the local host name 4 times with
- * 30 second sleep intervals before aborting; after 4 tries, things are
- * probably too messed up for the supscan to do anything useful
- * [90/04/04 dlc]
- *
- * Revision 1.10 89/08/03 19:49:33 mja
- * Updated to use v*printf() in place of _doprnt().
- * [89/04/19 mja]
- *
- * Revision 1.9 89/06/18 14:41:37 gm0w
- * Fixed up some notify messages of errors to use "SUP:" prefix.
- * [89/06/18 gm0w]
- *
- * 13-May-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed goaway to longjmp back to top-level to scan next
- * collection. [V7.6]
- *
- * 19-Feb-88 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added -f <filename> switch to scan all (or part) of the
- * collections in a file of collection/base-directory pairs.
- * [V7.5]
- *
- * 27-Dec-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Removed nameserver support (which means to use a new
- * datafile).
- *
- * 09-Sep-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Use case-insensitive hostname comparison.
- *
- * 28-Jun-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added code for "release" support. [V6.4]
- *
- * 05-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Changed collection setup errors to be non-fatal. [V5.3]
- *
- * 29-Dec-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Moved most of the scanning code to scan.c. [V4.2]
- *
- * 02-Nov-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Added "-s" option.
- *
- * 22-Sep-85 Glenn Marcy (gm0w) at Carnegie-Mellon University
- * Merged 4.1 and 4.2 versions together.
- *
- * 04-Jun-85 Steven Shafer (sas) at Carnegie-Mellon University
- * Created for 4.2 BSD.
- *
- **********************************************************************
- */
-
-#include <libc.h>
-#include <c.h>
-#include <netdb.h>
-#include <setjmp.h>
-#include <stdarg.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include "supcdefs.h"
-#include "supextern.h"
-
-#define PGMVERSION 6
-
-/*******************************************
- *** D A T A S T R U C T U R E S ***
- *******************************************/
-
-struct scan_collstruct { /* one per collection to be upgraded */
- char *Cname; /* collection name */
- char *Cbase; /* local base directory */
- char *Cprefix; /* local collection pathname prefix */
- struct scan_collstruct *Cnext; /* next collection */
-};
-typedef struct scan_collstruct SCAN_COLLECTION;
-
-/*********************************************
- *** G L O B A L V A R I A B L E S ***
- *********************************************/
-
-int trace; /* -v flag */
-int quiet; /* -q flag */
-
-SCAN_COLLECTION *firstC; /* collection list pointer */
-char *collname; /* collection name */
-char *basedir; /* base directory name */
-char *prefix; /* collection pathname prefix */
-time_t lasttime = 0; /* time of last upgrade */
-time_t scantime; /* time of this scan */
-int newonly = FALSE; /* new files only */
-jmp_buf sjbuf; /* jump location for errors */
-
-TREELIST *listTL; /* list of all files specified by <coll>.list */
-TREE *listT; /* final list of files in collection */
-TREE *refuseT = NULL; /* list of all files specified by <coll>.list */
-
-
-void usage(void);
-void init(int, char **);
-static SCAN_COLLECTION *getscancoll(char *, char *, char *);
-int localhost(char *);
-int main(int, char **);
-
-/*************************************
- *** M A I N R O U T I N E ***
- *************************************/
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- SCAN_COLLECTION * volatile c;
-
- init(argc, argv); /* process arguments */
- for (c = firstC; c; c = c->Cnext) {
- collname = c->Cname;
- basedir = c->Cbase;
- prefix = c->Cprefix;
- (void) chdir(basedir);
- scantime = time(NULL);
- if (!quiet)
- printf("SUP Scan for %s starting at %s", collname,
- ctime(&scantime));
- (void) fflush(stdout);
- if (!setjmp(sjbuf)) {
- makescanlists(); /* record names in scan files */
- scantime = time(NULL);
- if (!quiet)
- printf("SUP Scan for %s completed at %s",
- collname, ctime(&scantime));
- } else
- fprintf(stderr, "SUP: Scan for %s aborted at %s",
- collname, ctime(&scantime));
- if (!quiet)
- (void) fflush(stdout);
- }
- while ((c = firstC) != NULL) {
- firstC = firstC->Cnext;
- free(c->Cname);
- free(c->Cbase);
- if (c->Cprefix)
- free(c->Cprefix);
- free(c);
- }
- exit (0);
-}
-
-/*****************************************
- *** I N I T I A L I Z A T I O N ***
- *****************************************/
-
-void
-usage()
-{
-
- fprintf(stderr, "Usage: supscan [ -vq ] collection [ basedir ]\n");
- fprintf(stderr, " supscan [ -vq ] -f dirfile\n");
- fprintf(stderr, " supscan [ -vq ] -s\n");
- exit (1);
-}
-
-void
-init(argc, argv)
- int argc;
- char **argv;
-{
- char buf[STRINGLENGTH], fbuf[STRINGLENGTH], *p, *q;
- FILE *f;
- SCAN_COLLECTION **c;
- int fflag, sflag;
- char *filename = NULL;
-
- quiet = FALSE;
- trace = FALSE;
- fflag = FALSE;
- sflag = FALSE;
- while (argc > 1 && argv[1][0] == '-') {
- switch (argv[1][1]) {
- case 'f':
- fflag = TRUE;
- if (argc == 2)
- usage();
- --argc;
- argv++;
- filename = argv[1];
- break;
- case 'q':
- quiet = TRUE;
- break;
- case 'v':
- trace = TRUE;
- break;
- case 's':
- sflag = TRUE;
- break;
- default:
- fprintf(stderr, "supscan: Invalid flag %s ignored\n",
- argv[1]);
- (void) fflush(stderr);
- }
- --argc;
- argv++;
- }
- if (!fflag) {
- (void) snprintf(fbuf, sizeof fbuf, FILEDIRS, DEFDIR);
- filename = fbuf;
- }
- if (sflag) {
- if (argc != 1)
- usage();
- firstC = NULL;
- c = &firstC;
- (void) snprintf(buf, sizeof buf, FILEHOSTS, DEFDIR);
- if ((f = fopen(buf, "r")) == NULL)
- quit(1, "supscan: Unable to open %s\n", buf);
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- collname = nxtarg(&p, " \t=");
- p = skipover(p, " \t=");
- if (!localhost(p))
- continue;
- *c = getscancoll(filename, strdup(collname), NULL);
- if (*c)
- c = &((*c)->Cnext);
- }
- (void) fclose(f);
- return;
- }
- if (argc < 2 && fflag) {
- firstC = NULL;
- c = &firstC;
- if ((f = fopen(filename, "r")) == NULL)
- quit(1, "supscan: Unable to open %s\n", filename);
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:",*p))
- continue;
- q = nxtarg(&p, " \t=");
- p = skipover(p, " \t=");
- *c = getscancoll(filename, strdup(q), strdup(p));
- if (*c)
- c = &((*c)->Cnext);
- }
- (void) fclose(f);
- return;
- }
- if (argc < 2 || argc > 3)
- usage();
- firstC = getscancoll(filename, strdup(argv[1]),
- argc > 2 ? strdup(argv[2]) : NULL);
-}
-
-static SCAN_COLLECTION *
-getscancoll(filename, collname, basedir)
- char *filename, *collname, *basedir;
-{
- char buf[STRINGLENGTH], *p, *q;
- FILE *f;
- SCAN_COLLECTION *c;
-
- if (basedir == NULL) {
- if ((f = fopen(filename, "r")) != NULL) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- q = nxtarg(&p, " \t=");
- if (strcmp(q, collname) == 0) {
- p = skipover(p, " \t=");
- basedir = strdup(p);
- break;
- }
- }
- (void) fclose(f);
- }
- if (basedir == NULL) {
- (void) snprintf(buf, sizeof buf, FILEBASEDEFAULT,
- collname);
- basedir = strdup(buf);
- }
- }
- if (chdir(basedir) < 0) {
- fprintf (stderr,
- "supscan: Can't chdir to base directory %s for %s\n",
- basedir, collname);
- return (NULL);
- }
- prefix = NULL;
- (void) snprintf(buf, sizeof buf, FILEPREFIX, collname);
- if ((f = fopen(buf, "r")) != NULL) {
- while ((p = fgets(buf, sizeof(buf), f)) != NULL) {
- p[strcspn(p, "\n")] = '\0';
- if (strchr("#;:", *p))
- continue;
- prefix = strdup(p);
- if (chdir(prefix) < 0) {
- fprintf(stderr, "supscan: can't chdir to %s from base directory %s for %s\n",
- prefix, basedir, collname);
- return (NULL);
- }
- break;
- }
- (void) fclose(f);
- }
- if ((c = (SCAN_COLLECTION *) malloc(sizeof(SCAN_COLLECTION))) == NULL)
- quit(1, "supscan: can't malloc collection structure\n");
- c->Cname = collname;
- c->Cbase = basedir;
- c->Cprefix = prefix;
- c->Cnext = NULL;
- return (c);
-}
-
-void
-goaway(char *fmt,...)
-{
- va_list ap;
-
- va_start(ap,fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- (void) putc ('\n', stderr);
- (void) fflush(stderr);
- longjmp(sjbuf,TRUE);
-}
-
-int
-localhost (host)
- char *host;
-{
- static char myhost[MAXHOSTNAMELEN];
- static int myhostlen;
- int hostlen;
-
- if (*myhost == '\0') {
- /*
- * We assume that the host name in the kernel is the
- * fully qualified form.
- */
- if (gethostname(myhost, sizeof (myhost)) < 0)
- quit (1, "supscan: can't get kernel host name\n");
- myhostlen = strlen(myhost);
- }
-
- /*
- * Here, we assume that the 'host' parameter from the
- * coll.host file is at least a prefix of the fully qualified
- * host name of some machine. This will be true when modcoll(8)
- * (and related scripts) maintain the relevant files, but if
- * a person makes a manual change, problems could result. In
- * particular, if a nicname, such as "Y" for "GANDALF.CS.CMU.EDU"
- * is present in the coll.host file, things will not work as
- * expected.
- */
-
- hostlen = strlen(host);
-
- return(strncasecmp(myhost, host,
- hostlen < myhostlen ? hostlen : myhostlen) == 0);
-}
diff --git a/usr.bin/sup/src/supservers.8 b/usr.bin/sup/src/supservers.8
deleted file mode 100644
index cfe81f21a03..00000000000
--- a/usr.bin/sup/src/supservers.8
+++ /dev/null
@@ -1,261 +0,0 @@
-.\" $OpenBSD: supservers.8,v 1.8 2003/03/18 08:44:09 jmc Exp $
-.\"
-.\" Copyright (c) 1992 Carnegie Mellon University
-.\" All Rights Reserved.
-.\"
-.\" Permission to use, copy, modify and distribute this software and its
-.\" documentation is hereby granted, provided that both the copyright
-.\" notice and this permission notice appear in all copies of the
-.\" software, derivative works or modified versions, and any portions
-.\" thereof, and that both notices appear in supporting documentation.
-.\"
-.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
-.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
-.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
-.\"
-.\" Carnegie Mellon requests users of this software to return to
-.\"
-.\" Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU
-.\" School of Computer Science
-.\" Carnegie Mellon University
-.\" Pittsburgh PA 15213-3890
-.\"
-.\" any improvements or extensions that they make and grant Carnegie Mellon
-.\" the rights to redistribute these changes.
-.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" HISTORY
-.\"
-.\" Revision 1.3 92/08/11 12:08:50 mrt
-.\" Documented -C switch
-.\" [92/08/11 mrt]
-.\"
-.TH SUPSERVERS 8 1/16/86
-.CM 1
-.SH "NAME"
-supfilesrv, supscan \- sup server processes
-.SH "SYNOPSIS"
-supfilesrv
-[
-.I
--d
-] [
-.I
--l
-] [
-.I
--q
-] [
-.I
--N
-] [
-.I
--P
-] [
-.I -C MaxChildren
-] [
-.I -O lockdir
-]
-.br
-supscan [
-.I
--v
-] [
-.I
--s
-] [
-.I
-collection
-] [
-.I
-basedir
-]
-.SH "DESCRIPTION"
-.I
-Supfilesrv
-is the server processes used to interact with
-.I
-sup
-client processes via the IP/TCP network protocol.
-This server
-normally is expected to be running on server machines at all times.
-Each machine with files of interest to users on other machines is
-expected to be a file server and should run
-.I
-supfilesrv.
-
-A file server machine will service requests for both "private" and
-"system" file collections.
-No special action is necessary to support
-private collections, as the client user is expected to supply all
-necessary information.
-For system collections, if the base directory
-is not the default (see FILES below), an entry must be put into
-the directory list file; this entry is a single text line containing
-the name of the collection, one or more spaces, and the name of the
-base directory for that collection.
-
-Each collection should have
-an entry in the host list file; this entry is a single text line
-containing the name of the collection, one or more spaces, and
-the name of the host machine acting as file server for that collection.
-
-Details of setting up a file collection for the file server are
-described in the manual entry for
-.I
-sup(1).
-
-.I
-Supfilesrv
-generally runs as a network server process that listens for connections,
-and for each connection (double-)forks a process to handle the interaction
-with the client.
-However, with the -d flag, no forking will take place:
-the server will listen for a network connection, handle it, and exit.
-This is useful for debugging the servers in "live" mode rather than as
-daemons.
-
-For debugging purposes, the -P "debugging ports" flag can be used.
-It will cause the selection of an alternate, non-privileged set of
-TCP ports instead of the usual ports, which are reserved for the
-active server processes. The -N "network debugging" flag can be used
-to produce voluminous messages describing the network communication
-progress and status. The more -N switches that you use the more output
-you get. Use 3 (separated by spaces: -N -N -N) to get a complete record
-of all network messages. Log messages are printed by
-.I syslog
-on
-.I daemon.log .
-To suppress
-log messages, the -q "quiet" flag can be used.
-
-.I supfilesrv
-uses libwrap style access control (the /etc/hosts.allow and /etc/hosts.deny
-files) with service name "supfilesrv". The -l "log" flag turn on loggin of
-accepted connections (denied connections are always logged).
-
-Normally the
-.I supfilesrv
-will only respond to 3 requests simultaneously, forking a child
-process for each client. If it gets additional requests it will respond
-with the error FSSETUPBUSY. The -C MaxChildren switch can be used
-to increase (or decrease) this number.
-
-
-The -O lockdir switch is used to make
-.I supfilesrv
-allow only one active connection at a time from any client IP address.
-This is accomplished by each serving process obtaining exclusive lock,
-and writing its process ID into a file in "lockdir" where the filename
-is the dotted decimal IP address of the connecting host. Any
-connections from a client where a lock can not be obtained on such a file
-will be rejected, limiting any client host to one connection at a time
-to this sup server. This is useful for preventing problems where
-clients running
-.I sup
-on a regular basis manage to time requests so that a second request
-comes in before the first one completes.
-
-.SH "SUPSCAN"
-It is possible to pre-compile a list of the files in a collection
-to make
-.I
-supfilesrv
-service that collection much faster. This can be done by running
-.I
-supscan
-on the desired collection on the repository machine. This produces a
-list of all the files in the collection at the time of the
-.I
-supscan;
-subsequent upgrades will be based on this list of files rather than
-actually scanning the disk at the time of the upgrade. Of course,
-the upgrade will consequently bring the client machine up to the status
-of the repository machine as of the time of the
-.I
-supscan
-rather than as of the time of the upgrade; hence, if
-.I
-supscan
-is used, it should be run periodically on the
-collection.
-This facility is useful for extremely large file collections
-that are upgraded many times per day, such as the CMU UNIX system
-software. The "verbose" flag
-.I
--v
-will cause
-.I
-supscan
-to produce output messages as it scans the files in the collection.
-The "system" flag
-.I
--s
-will cause
-.I
-supscan
-to scan all system collections residing on the current host.
-The
-.I
-basedir
-parameter must be specified if the collection is a private
-collection whose base directory is not the default.
-.SH "FILES"
-.TP
-/usr
-default base directory for a collection
-.TP
-/usr/lib/supfiles/coll.dir
-directory list file for file server
-.TP
-/usr/lib/supfiles/coll.host
-host list file for system sups.
-.TP
-<base-directory>/sup/<collection>/*
-files used by file server (see
-.I
-sup(1))
-.TP
-<base-directory>/sup/<collection>/list
-list file used by
-.I
-supscan
-to create file list
-.TP
-<base-directory>/sup/<collection>/scan
-file list created by
-.I
-supscan
-from list file
-.i0
-.DT
-.PP
-.SH "SEE ALSO"
-sup(1)
-.br
-.I
-The SUP Software Upgrade Protocol,
-S.
-A.
-Shafer, CMU Computer Science Dept., 1985.
-.SH "DIAGNOSTICS"
-The file server places log messages on the
-standard and diagnostic output files.
-The process name and process
-id number generally accompany each message for diagnostic purposes.
-.SH "HISTORY"
-.TP
-31-July-92 Mary Thompson (mrt) at Carnegie Mellon University
-Removed references to supnameserver which has not existed for
-a long time. Update a few file names. Added -C switch.
-.TP
-21-May-87 Glenn Marcy (gm0w) at Carnegie-Mellon University
-Updated documentation for 4.3; changed /usr/cmu to /usr/cs.
-.TP
-15-Jan-86 Glenn Marcy (gm0w) at Carnegie-Mellon University
-Updated documentation; -s switch to supscan.
-.TP
-23-May-85 Steven Shafer (sas) at Carnegie-Mellon University
-Supscan created and documented; also -N flag.
-.TP
-04-Apr-85 Steven Shafer (sas) at Carnegie-Mellon University
-Created.
diff --git a/usr.bin/sup/src/sysent.h b/usr.bin/sup/src/sysent.h
deleted file mode 100644
index 7d639fdf365..00000000000
--- a/usr.bin/sup/src/sysent.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* $OpenBSD: sysent.h,v 1.8 2003/05/10 17:52:17 miod Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- **********************************************************************
- * HISTORY
- * Revision 2.4 89/12/05 16:02:00 mrt
- * Removed include of sys/features.h as it is no longer
- * exported or needed.
- * [89/12/05 mrt]
- *
- * Revision 2.3 89/01/20 15:44:24 gm0w
- * Added externs to the non-STDC case for functions that do not
- * have int return values.
- * [88/12/17 gm0w]
- *
- * Revision 2.2 88/12/14 23:35:52 mja
- * Created.
- * [88/01/06 jjk]
- *
- **********************************************************************
- */
-
-#ifndef _SYSENT_H_
-#define _SYSENT_H_ 1
-
-#if 0
-#include <sys/types.h>
-#include <sys/time.h>
-extern int access(const char *, int);
-extern int acct(const char *);
-extern int brk(void *);
-extern int sbrk(int);
-extern int chdir(const char *);
-extern int chmod(const char *, int);
-extern int fchmod(int, int);
-extern int chown(const char *, int, int);
-extern int fchown(int, int, int);
-extern int chroot(const char *);
-extern int close(int);
-extern int creat(const char *, int);
-extern int dup(int);
-extern int dup2(int, int);
-extern int execve(const char *, const char **, const char **);
-extern void _exit(int);
-extern int fcntl(int, int, int);
-extern int flock(int, int);
-extern int fork(void);
-extern int fsync(int);
-extern int getdtablesize(void);
-extern gid_t getgid(void);
-extern gid_t getegid(void);
-extern int getgroups(int, int *);
-extern long gethostid(void);
-extern int sethostid(long);
-extern int gethostname(char *, size_t);
-extern int sethostname(const char *, int);
-extern int getpagesize(void);
-extern int getpgrp(int);
-extern int getpid(void);
-extern int getppid(void);
-extern uid_t getuid(void);
-extern uid_t geteuid(void);
-extern int ioctl(int, unsigned long, void *);
-extern int kill(int, int);
-extern int killpg(int, int);
-extern int link(const char *, const char *);
-extern off_t lseek(int, off_t, int);
-extern int mkdir(const char *, int);
-extern int mknod(const char *, int, int);
-extern int mount(const char *, const char *, int);
-extern int umount(const char *);
-extern int open(const char *, int, int);
-extern int pipe(int *);
-extern int profil(void *, int, int, int);
-extern int ptrace(int, int, int *, int);
-extern int quota(int, int, int, void *);
-extern int read(int, void *, int);
-extern int readlink(const char *, void *, int);
-extern int reboot(int);
-extern int rename(const char *, const char *);
-extern int rmdir(const char *);
-extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-extern int setgroups(int, int *);
-extern int setpgrp(int, int);
-extern int setquota(const char *, const char *);
-extern int setregid(gid_t, gid_t);
-extern int setreuid(uid_t, uid_t);
-extern int symlink(const char *, const char *);
-extern void sync(void);
-extern int syscall(int, ...);
-extern int truncate(const char *, off_t);
-extern int ftruncate(int, off_t);
-extern int umask(int);
-extern int unlink(const char *);
-extern void vhangup(void);
-extern int write(int, void *, int);
-
-#ifndef _VICEIOCTL
-#include <sys/viceioctl.h>
-#endif /* not _VICEIOCTL */
-extern int icreate(int, int, int, int, int, int);
-extern int iinc(int, int, long);
-extern int idec(int, int, long);
-extern int iopen(int, int, int);
-extern int iread(int, int, int, int, void *, int);
-extern int iwrite(int, int, int, int, void *, int);
-extern int pioctl(const char *, unsigned long, struct ViceIoctl *, int);
-extern int setpag(void);
-#endif
-#endif /* not _SYSENT_H_ */
diff --git a/usr.bin/sup/src/time.h b/usr.bin/sup/src/time.h
deleted file mode 100644
index b1c1b878f07..00000000000
--- a/usr.bin/sup/src/time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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.
- *
- * @(#)time.h 5.12 (Berkeley) 3/9/91
- */
-
-#ifndef _TIME_H_
-#define _TIME_H_
-
-struct tm {
- int tm_sec; /* seconds after the minute [0-60] */
- int tm_min; /* minutes after the hour [0-59] */
- int tm_hour; /* hours since midnight [0-23] */
- int tm_mday; /* day of the month [1-31] */
- int tm_mon; /* months since January [0-11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday [0-6] */
- int tm_yday; /* days since January 1 [0-365] */
- int tm_isdst; /* Daylight Saving Time flag */
- long tm_gmtoff; /* offset from UTC in seconds */
- char *tm_zone; /* timezone abbreviation */
-};
-
-char *asctime(const struct tm *);
-char *ctime(const time_t *);
-double difftime(time_t, time_t);
-struct tm *gmtime(const time_t *);
-struct tm *localtime(const time_t *);
-time_t mktime(struct tm *);
-time_t time(time_t *);
-void tzset(void);
-char *timezone(int, int);
-void tzsetwall(void);
-
-#endif /* !_TIME_H_ */
diff --git a/usr.bin/sup/src/unvis.c b/usr.bin/sup/src/unvis.c
deleted file mode 100644
index 5431a1f6ba1..00000000000
--- a/usr.bin/sup/src/unvis.c
+++ /dev/null
@@ -1,244 +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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: unvis.c,v 1.6 2003/08/01 19:11:46 avsm Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <ctype.h>
-#include <vis.h>
-
-#ifdef NEED_VIS
-/*
- * decode driven by state machine
- */
-#define S_GROUND 0 /* haven't seen escape char */
-#define S_START 1 /* start decoding special sequence */
-#define S_META 2 /* metachar started (M) */
-#define S_META1 3 /* metachar more, regular char (-) */
-#define S_CTRL 4 /* control char started (^) */
-#define S_OCTAL2 5 /* octal digit 2 */
-#define S_OCTAL3 6 /* octal digit 3 */
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-
-/*
- * unvis - decode characters previously encoded by vis
- */
-int
-unvis(char *cp, char c, int *astate, int flag)
-{
-
- if (flag & UNVIS_END) {
- if (*astate == S_OCTAL2 || *astate == S_OCTAL3) {
- *astate = S_GROUND;
- return (UNVIS_VALID);
- }
- return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
- }
-
- switch (*astate) {
-
- case S_GROUND:
- *cp = 0;
- if (c == '\\') {
- *astate = S_START;
- return (0);
- }
- *cp = c;
- return (UNVIS_VALID);
-
- case S_START:
- switch(c) {
- case '\\':
- *cp = c;
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '0': case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- *cp = (c - '0');
- *astate = S_OCTAL2;
- return (0);
- case 'M':
- *cp = (char) 0200;
- *astate = S_META;
- return (0);
- case '^':
- *astate = S_CTRL;
- return (0);
- case 'n':
- *cp = '\n';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'r':
- *cp = '\r';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'b':
- *cp = '\b';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'a':
- *cp = '\007';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'v':
- *cp = '\v';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 't':
- *cp = '\t';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'f':
- *cp = '\f';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 's':
- *cp = ' ';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case 'E':
- *cp = '\033';
- *astate = S_GROUND;
- return (UNVIS_VALID);
- case '\n':
- /*
- * hidden newline
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- case '$':
- /*
- * hidden marker
- */
- *astate = S_GROUND;
- return (UNVIS_NOCHAR);
- }
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
-
- case S_META:
- if (c == '-')
- *astate = S_META1;
- else if (c == '^')
- *astate = S_CTRL;
- else {
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
- return (0);
-
- case S_META1:
- *astate = S_GROUND;
- *cp |= c;
- return (UNVIS_VALID);
-
- case S_CTRL:
- if (c == '?')
- *cp |= 0177;
- else
- *cp |= c & 037;
- *astate = S_GROUND;
- return (UNVIS_VALID);
-
- case S_OCTAL2: /* second possible octal digit */
- if (isoctal(c)) {
- /*
- * yes - and maybe a third
- */
- *cp = (*cp << 3) + (c - '0');
- *astate = S_OCTAL3;
- return (0);
- }
- /*
- * no - done with current sequence, push back passed char
- */
- *astate = S_GROUND;
- return (UNVIS_VALIDPUSH);
-
- case S_OCTAL3: /* third possible octal digit */
- *astate = S_GROUND;
- if (isoctal(c)) {
- *cp = (*cp << 3) + (c - '0');
- return (UNVIS_VALID);
- }
- /*
- * we were done, push back passed char
- */
- return (UNVIS_VALIDPUSH);
-
- default:
- /*
- * decoder in unknown state - (probably uninitialized)
- */
- *astate = S_GROUND;
- return (UNVIS_SYNBAD);
- }
-}
-
-/*
- * strunvis - decode src into dst
- *
- * Number of chars decoded into dst is returned, -1 on error.
- * Dst is null terminated.
- */
-
-int
-strunvis(dst, src)
- char *dst;
- const char *src;
-{
- char c;
- char *start = dst;
- int state = 0;
-
- while ((c = *src++)) {
- again:
- switch (unvis(dst, c, &state, 0)) {
- case UNVIS_VALID:
- dst++;
- break;
- case UNVIS_VALIDPUSH:
- dst++;
- goto again;
- case 0:
- case UNVIS_NOCHAR:
- break;
- default:
- return (-1);
- }
- }
- if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
- dst++;
- *dst = '\0';
- return (dst - start);
-}
-#endif /* NEED_VIS */
diff --git a/usr.bin/sup/src/vis.c b/usr.bin/sup/src/vis.c
deleted file mode 100644
index d861b71f959..00000000000
--- a/usr.bin/sup/src/vis.c
+++ /dev/null
@@ -1,179 +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. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: vis.c,v 1.6 2003/08/01 19:11:46 avsm Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <limits.h>
-#include <ctype.h>
-#include <vis.h>
-
-#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#ifdef NEED_VIS
-/*
- * vis - visually encode characters
- */
-char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, nextc;
- int flag;
-{
- if (((u_int)c <= UCHAR_MAX && isascii(c) && isgraph(c)) ||
- ((flag & VIS_SP) == 0 && c == ' ') ||
- ((flag & VIS_TAB) == 0 && c == '\t') ||
- ((flag & VIS_NL) == 0 && c == '\n') ||
- ((flag & VIS_SAFE) && (c == '\b' || c == '\007' || c == '\r'))) {
- *dst++ = c;
- if (c == '\\' && (flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- *dst = '\0';
- return (dst);
- }
-
- if (flag & VIS_CSTYLE) {
- switch(c) {
- case '\n':
- *dst++ = '\\';
- *dst++ = 'n';
- goto done;
- case '\r':
- *dst++ = '\\';
- *dst++ = 'r';
- goto done;
- case '\b':
- *dst++ = '\\';
- *dst++ = 'b';
- goto done;
- case '\a':
- *dst++ = '\\';
- *dst++ = 'a';
- goto done;
- case '\v':
- *dst++ = '\\';
- *dst++ = 'v';
- goto done;
- case '\t':
- *dst++ = '\\';
- *dst++ = 't';
- goto done;
- case '\f':
- *dst++ = '\\';
- *dst++ = 'f';
- goto done;
- case ' ':
- *dst++ = '\\';
- *dst++ = 's';
- goto done;
- case '\0':
- *dst++ = '\\';
- *dst++ = '0';
- if (isoctal(nextc)) {
- *dst++ = '0';
- *dst++ = '0';
- }
- goto done;
- }
- }
- if (((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
- *dst++ = '\\';
- *dst++ = ((u_char)c >> 6 & 07) + '0';
- *dst++ = ((u_char)c >> 3 & 07) + '0';
- *dst++ = ((u_char)c & 07) + '0';
- goto done;
- }
- if ((flag & VIS_NOSLASH) == 0)
- *dst++ = '\\';
- if (c & 0200) {
- c &= 0177;
- *dst++ = 'M';
- }
- if (iscntrl(c)) {
- *dst++ = '^';
- if (c == 0177)
- *dst++ = '?';
- else
- *dst++ = c + '@';
- } else {
- *dst++ = '-';
- *dst++ = c;
- }
-done:
- *dst = '\0';
- return (dst);
-}
-
-/*
- * strvis, strvisx - visually encode characters from src into dst
- *
- * Dst must be 4 times the size of src to account for possible
- * expansion. The length of dst, not including the trailing NULL,
- * is returned.
- *
- * Strvisx encodes exactly len bytes from src into dst.
- * This is useful for encoding a block of data.
- */
-int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
-{
- char c;
- char *start;
-
- for (start = dst; (c = *src);)
- dst = vis(dst, c, flag, *++src);
- *dst = '\0';
- return (dst - start);
-}
-
-int
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
-{
- char c;
- char *start;
-
- for (start = dst; len > 1; len--) {
- c = *src;
- dst = vis(dst, c, flag, *++src);
- }
- if (len)
- dst = vis(dst, *src, flag, '\0');
- *dst = '\0';
-
- return (dst - start);
-}
-#endif /* NEED_VIS */
diff --git a/usr.bin/sup/src/vis/vis.h b/usr.bin/sup/src/vis/vis.h
deleted file mode 100644
index ff21c858144..00000000000
--- a/usr.bin/sup/src/vis/vis.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* $OpenBSD: vis.h,v 1.1 2003/08/01 19:10:20 avsm Exp $ */
-/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */
-
-/*-
- * Copyright (c) 1990 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.
- *
- * @(#)vis.h 5.9 (Berkeley) 4/3/91
- */
-
-#ifndef _VIS_H_
-#define _VIS_H_
-
-/*
- * to select alternate encoding format
- */
-#define VIS_OCTAL 0x01 /* use octal \ddd format */
-#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */
-
-/*
- * to alter set of characters encoded (default is to encode all
- * non-graphic except space, tab, and newline).
- */
-#define VIS_SP 0x04 /* also encode space */
-#define VIS_TAB 0x08 /* also encode tab */
-#define VIS_NL 0x10 /* also encode newline */
-#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
-#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
-
-/*
- * other
- */
-#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
-
-/*
- * unvis return codes
- */
-#define UNVIS_VALID 1 /* character valid */
-#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
-#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
-#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
-#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
-
-/*
- * unvis flags
- */
-#define UNVIS_END 1 /* no more characters */
-
-char *vis(char *, int, int, int);
-int strvis(char *, const char *, int);
-int strvisx(char *, const char *, size_t, int);
-int strunvis(char *, const char *);
-int unvis(char *, char, int *, int);
-
-#endif /* !_VIS_H_ */
diff --git a/usr.bin/sup/src/vprintf.c b/usr.bin/sup/src/vprintf.c
deleted file mode 100644
index 8f97a6d9493..00000000000
--- a/usr.bin/sup/src/vprintf.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* $OpenBSD: vprintf.c,v 1.8 2001/05/04 22:16:17 millert Exp $ */
-
-/*
- * Copyright (c) 1991 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the rights
- * to redistribute these changes.
- */
-/*
- * varargs versions of printf routines
- *
- **********************************************************************
- * HISTORY
- * Revision 2.5 89/09/08 18:15:55 mbj
- * Use _doprnt() for the Multimax (an "old" architecture).
- * [89/09/08 mbj]
- *
- * Revision 2.4 89/08/03 14:40:10 mja
- * Add vsnprintf() routine.
- * [89/07/12 mja]
- *
- * Terminate vsprintf() string with null byte.
- * [89/04/21 mja]
- *
- * Change to use new hidden name for _doprnt on MIPS.
- * [89/04/18 mja]
- *
- * Revision 2.3 89/06/10 14:13:43 gm0w
- * Added putc of NULL byte to vsprintf.
- * [89/06/10 gm0w]
- *
- * Revision 2.2 88/12/13 13:53:17 gm0w
- * From Brad White.
- * [88/12/13 gm0w]
- ************************************************************
- */
-
-#include <stdio.h>
-#include <varargs.h>
-
-#ifdef _IOSTRG
-#define STRFLAG (_IOSTRG|_IOWRT) /* no _IOWRT: avoid stdio bug */
-#else
-#define STRFLAG (_IOREAD) /* XXX: Assume svr4 stdio */
-#endif
-
-#ifdef DOPRINT_VA
-/*
- * system provides _doprnt_va routine
- */
-#define _doprnt _doprnt_va
-#else
-/*
- * system provides _doprnt routine
- */
-#define _doprnt_va _doprnt
-#endif
-
-
-#ifdef NEED_VPRINTF
-int
-vprintf(fmt, args)
- char *fmt;
- va_list args;
-{
- _doprnt(fmt, args, stdout);
- return (ferror(stdout) ? EOF : 0);
-}
-
-int
-vfprintf(f, fmt, args)
- FILE *f;
- char *fmt;
- va_list args;
-{
-
- _doprnt(fmt, args, f);
- return (ferror(f) ? EOF : 0);
-}
-
-int
-vsprintf(s, fmt, args)
- char *s, *fmt;
- va_list args;
-{
- FILE fakebuf;
-
- fakebuf._flag = STRFLAG;
- fakebuf._base = (void *) s;
- fakebuf._ptr = (void *) s;
- fakebuf._cnt = 32767;
- _doprnt(fmt, args, &fakebuf);
- putc('\0', &fakebuf);
- return (strlen(s));
-}
-#endif /* NEED_VPRINTF */
-
-#if defined(NEED_VSNPRINTF) || defined(NEED_VPRINTF)
-int
-vsnprintf(s, n, fmt, args)
- char *s, *fmt;
- va_list args;
-{
- FILE fakebuf;
-
- fakebuf._flag = STRFLAG;
- fakebuf._base = (void *) s;
- fakebuf._ptr = (void *) s;
- fakebuf._cnt = n-1;
- fakebuf._file = -1;
- _doprnt(fmt, args, &fakebuf);
- fakebuf._cnt++;
- putc('\0', &fakebuf);
- if (fakebuf._cnt<0)
- fakebuf._cnt = 0;
- return (n-fakebuf._cnt-1);
-}
-#endif /* NEED_VPRINTF || NEED_VSNPRINTF */
diff --git a/usr.bin/sup/sup/Makefile b/usr.bin/sup/sup/Makefile
deleted file mode 100644
index e99be9ae644..00000000000
--- a/usr.bin/sup/sup/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $OpenBSD: Makefile,v 1.7 2003/12/02 01:41:02 millert Exp $
-
-PROG= sup
-MAN= sup.1
-SRCS= supcmain.c supcvers.c supcparse.c supcname.c supcmisc.c supcmeat.c \
- scm.c scmio.c stree.c log.c supmsg.c \
- atoo.c errmsg.c expand.c ffilecopy.c filecopy.c nxtarg.c \
- path.c quit.c run.c skipto.c netcryptvoid.c
-BINOWN= root
-BINGRP= daemon
-BINMODE=555
-BINDIR= /usr/bin
-CFLAGS+=-I${.CURDIR}/../src
-.PATH: ${.CURDIR}/../src
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/sup/supfilesrv/Makefile b/usr.bin/sup/supfilesrv/Makefile
deleted file mode 100644
index 5f4030308c4..00000000000
--- a/usr.bin/sup/supfilesrv/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# $OpenBSD: Makefile,v 1.11 2003/12/02 01:41:02 millert Exp $
-
-PROG= supfilesrv
-MAN= supservers.8
-MLINKS= supservers.8 supfilesrv.8
-MLINKS+=supservers.8 supscan.8
-SRCS= supfilesrv.c scan.c scm.c scmio.c stree.c log.c supmsg.c \
- atoo.c errmsg.c expand.c ffilecopy.c filecopy.c nxtarg.c \
- path.c quit.c run.c skipto.c netcryptvoid.c
-LDADD+= -lwrap
-DPADD+= ${LIBWRAP}
-BINOWN= root
-BINGRP= daemon
-BINMODE=555
-BINDIR= /usr/sbin
-CFLAGS+=-I${.CURDIR}/../src
-.PATH: ${.CURDIR}/../src
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/sup/supscan/Makefile b/usr.bin/sup/supscan/Makefile
deleted file mode 100644
index 546cdc82839..00000000000
--- a/usr.bin/sup/supscan/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $OpenBSD: Makefile,v 1.7 2003/12/02 01:41:02 millert Exp $
-
-PROG= supscan
-NOMAN=
-SRCS= supscan.c stree.c scan.c \
- atoo.c errmsg.c expand.c ffilecopy.c filecopy.c nxtarg.c \
- path.c quit.c run.c skipto.c netcryptvoid.c
-BINOWN= root
-BINGRP= daemon
-BINMODE=555
-BINDIR= /usr/sbin
-CFLAGS+=-I${.CURDIR}/../src
-.PATH: ${.CURDIR}/../src
-
-.include <bsd.prog.mk>