1/*	$NetBSD: sup.h,v 1.10 2002/07/10 18:53:59 wiz Exp $	*/
2
3/*
4 * Copyright (c) 1992 Carnegie Mellon University
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
12 *
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 *
17 * Carnegie Mellon requests users of this software to return to
18 *
19 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20 *  School of Computer Science
21 *  Carnegie Mellon University
22 *  Pittsburgh PA 15213-3890
23 *
24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes.
26 */
27/* sup.h -- declarations for sup, supnamesrv, supfilesrv
28 *
29 * VERSION NUMBER for any program is given by:  a.b (c)
30 * where	a = PROTOVERSION	is the protocol version #
31 *		b = PGMVERSION		is program # within protocol
32 *		c = scmversion		is communication module version
33 *			(i.e. operating system for which scm is configured)
34 **********************************************************************
35 * HISTORY
36 * 13-Sep-92  Mary Thompson (mrt) at Carnegie-Mellon University
37 *	Changed name of DEFDIR from /usr/cs to /usr.
38 *
39 * 7-July-93  Nate Williams at Montana State University
40 *	Modified SUP to use gzip based compression when sending files
41 *	across the network to save BandWidth
42 *
43 * Revision 1.10  92/08/11  12:06:42  mrt
44 * 	Added definition for DEBUGFPORTNUM, the debugging port number.
45 * 	Changed so that last and when file names could include
46 * 	the relase name if any.
47 * 	[92/07/23            mrt]
48 *
49 * Revision 1.9  91/04/29  14:39:03  mja
50 * 	Reduce MAXCHILDREN from 8 to 3.
51 *
52 * Revision 1.8  89/08/23  14:55:30  gm0w
53 * 	Moved coll.dir from supservers to supfiles.
54 * 	[89/08/23            gm0w]
55 *
56 * 18-Mar-88  Glenn Marcy (gm0w) at Carnegie-Mellon University
57 *	Added host=<hostfile> support to releases file.
58 *
59 * 27-Dec-87  Glenn Marcy (gm0w) at Carnegie-Mellon University
60 *	Added crosspatch support.  Removed nameserver support.
61 *
62 * 27-Jun-87  Glenn Marcy (gm0w) at Carnegie-Mellon University
63 *	Added TREELIST and other changes for "release" support.
64 *
65 * 25-May-87  Doug Philips (dwp) at Carnegie-Mellon University
66 *	Version 6 of the network protocol, better support to reflect errors
67 *	back to server logfile.
68 *
69 * 21-May-87  Chriss Stephens (chriss) at Carnegie Mellon University
70 *	Merged divergent CS and EE versions.
71 *
72 * 19-Sep-86  Mike Accetta (mja) at Carnegie-Mellon University
73 *	Added FILESUPTDEFAULT definition.
74 *
75 * 07-Jun-86  Glenn Marcy (gm0w) at Carnegie-Mellon University
76 *	Removed FILESRVBUSYWAIT.  Now uses exponential backoff.
77 *
78 * 30-May-86  Glenn Marcy (gm0w) at Carnegie-Mellon University
79 *	Added numeric port numbers to use when port names are not in the
80 *	host table.
81 *
82 * 04-Jan-86  Glenn Marcy (gm0w) at Carnegie-Mellon University
83 *	Update protocol version to 5 for name server protocol change to
84 *	allow multiple repositories per collection.  Added FILESRVBUSYWAIT
85 *	of 5 minutes.  Added FILELOCK file to indicate collections that
86 *	should be exclusively locked when upgraded.
87 *
88 * 22-Sep-85  Glenn Marcy (gm0w) at Carnegie-Mellon University
89 *	Merged 4.1 and 4.2 versions together.
90 *
91 * 04-Jun-85  Steven Shafer (sas) at Carnegie-Mellon University
92 *	Created for 4.2 BSD.
93 *
94 **********************************************************************
95 */
96
97/* PGMVERSION is defined separately in each program */
98extern char scmversion[];		/* string version of scm */
99#define PROTOVERSION 8			/* version of network protocol */
100#define SCANVERSION  2			/* version of scan file format */
101
102/* TCP servers for name server and file server */
103#define FILEPORT	"supfilesrv"
104#define FILEPORTNUM	871
105#define DEBUGFPORT	"supfiledbg"
106#define DEBUGFPORTNUM	1127
107
108/* Default directory for system sup information */
109#ifndef	DEFDIR
110#ifdef EE_XXX
111#define DEFDIR		"/etc"
112#else  /* EE_XXX */
113#define DEFDIR		"/usr"
114#endif /* EE_XXX */
115#endif	/* DEFDIR */
116#ifndef DEFSCAN
117#define DEFSCAN	""
118#endif
119
120/* Data files used in scan.c */
121#ifdef EE_XXX
122#define FILELIST	DEFSCAN "supscan/%s/%s"
123#define FILESCAN	DEFSCAN "supscan/%s/%s"
124#define FILEHOST	DEFSCAN "supscan/%s/%s"
125#else
126#define FILELIST	DEFSCAN "sup/%s/%s"
127#define FILESCAN	DEFSCAN "sup/%s/%s"
128#define FILEHOST	DEFSCAN "sup/%s/%s"
129#endif
130#define FILELISTDEF	"list"
131#define FILESCANDEF	"scan"
132#define FILEHOSTDEF	"host"
133#define DEFRELEASE	"default"
134
135/* Data files used in sup.c */
136#define FILEBASEDEFAULT	DEFDIR "/%s" /* also supfilesrv and supscan */
137#ifdef EE_XXX
138#define FILESUPDEFAULT	"%s/supfiles/coll.list"
139#define FILESUPTDEFAULT	"%s/supfiles/coll.what"
140#define FILEHOSTS	"%s/supfiles/coll.host"
141#else  /* EE_XXX */
142#define FILESUPDEFAULT	"%s/lib/supfiles/coll.list"
143#define FILESUPTDEFAULT	"%s/lib/supfiles/coll.what"
144#define FILEHOSTS	"%s/lib/supfiles/coll.host"
145#endif /* EE_XXX */
146#define FILEBKDIR	"%s/BACKUP"
147#define FILEBACKUP	"%s/BACKUP/%s"
148#define FILELAST	DEFSCAN "sup/%s/last%s"
149#define FILELASTTEMP	DEFSCAN "sup/%s/last%s.temp"
150#define FILELOCK	DEFSCAN "sup/%s/lock"	/* also supfilesrv */
151#define FILEREFUSE	DEFSCAN "sup/%s/refuse"
152#define FILEWHEN	DEFSCAN "sup/%s/when%s"
153
154/* Data files used in supfilesrv.c */
155#define FILEXPATCH	"%s/sup/xpatch.host"
156#ifdef EE_XXX
157#define FILEDIRS	"%s/supfiles/coll.dir" /* also supscan */
158#else  /* EE_XXX */
159#define FILEDIRS	"%s/lib/supfiles/coll.dir" /* also supscan */
160#endif /* EE_XXX */
161#define FILECRYPT	DEFSCAN "sup/%s/crypt"
162#define FILELOGFILE	DEFSCAN "sup/%s/logfile"
163#ifdef EE_XXX
164#define FILEPREFIX	DEFSCAN "supscan/%s/prefix"	/* also supscan */
165#define FILERELEASES	DEFSCAN "supscan/%s/releases" /* also supscan */
166#else
167#define FILEPREFIX	DEFSCAN "sup/%s/prefix"	/* also supscan */
168#define FILERELEASES	DEFSCAN "sup/%s/releases" /* also supscan */
169#endif
170
171/* String length */
172#define STRINGLENGTH	2000
173
174/* Password transmission encryption key */
175#define PSWDCRYPT	"SuperMan"
176/* Test string for encryption */
177#define CRYPTTEST	"Hello there, Sailor Boy!"
178
179/* Default login account for file server */
180#ifndef	DEFUSER
181#define DEFUSER		"anon"
182#endif	/* DEFUSER */
183
184/* subroutine return codes */
185#define SCMOK		(1)		/* routine performed correctly */
186#define SCMEOF		(0)		/* read EOF on network connection */
187#define SCMERR		(-1)		/* error occurred during routine */
188
189/* data structure for describing a file being upgraded */
190
191struct treestruct {
192/* fields for file information */
193	char *Tname;			/* path component name */
194	int Tflags;			/* flags of file */
195	int Tmode;			/* st_mode of file */
196	char *Tuser;			/* owner of file */
197	int Tuid;			/* owner id of file */
198	char *Tgroup;			/* group of file */
199	int Tgid;			/* group id of file */
200	int Tctime;			/* inode modification time */
201	int Tmtime;			/* data modification time */
202	struct treestruct *Tlink;	/* tree of link names */
203	struct treestruct *Texec;	/* tree of execute commands */
204/* fields for sibling AVL tree */
205	int Tbf;			/* balance factor */
206	struct treestruct *Tlo,*Thi;	/* ordered sibling tree */
207};
208typedef struct treestruct TREE;
209
210/* data structure to represent a list of trees to upgrade */
211
212struct tliststruct {
213	struct tliststruct *TLnext;	/* next entry in tree list */
214/* fields for tree information */
215	char *TLname;			/* release name for tree */
216	char *TLprefix;			/* prefix of tree */
217	char *TLlist;			/* name of list file */
218	char *TLscan;			/* name of scan file */
219	char *TLhost;			/* name of host file */
220	TREE *TLtree;			/* tree of files to upgrade */
221};
222typedef struct tliststruct TREELIST;
223
224/* bitfield not defined in stat.h */
225#define S_IMODE		  07777		/* part of st_mode that chmod sets */
226
227/* flag bits for files */
228#define FNEW		     01		/* ctime of file has changed */
229#define FBACKUP		     02		/* backup of file is allowed */
230#define FNOACCT		     04		/* don't set file information */
231#define FUPDATE		    010		/* only set file information */
232#define FNEEDED		0100000		/* file needed for upgrade */
233
234/* version 3 compatibility */
235#define	FCOMPAT		0010000		/* Added to detect execute commands to send */
236
237/* message types now obsolete */
238#define MSGFEXECQ	(115)
239#define MSGFEXECNAMES	(116)
240
241/* flag bits for files in list of all files */
242#define ALLNEW		      01
243#define ALLBACKUP	      02
244#define ALLEND		      04
245#define ALLDIR		     010
246#define ALLNOACCT	     020
247#define ALLSLINK	    0100
248
249/* flag bits for file mode word */
250#define MODELINK	  010000
251#define MODEDIR		  040000
252#define MODESYM		 0100000
253#define MODENOACCT	 0200000
254#define MODEUPDATE	01000000
255
256/* blocking factor for filenames in list of all file names */
257#define BLOCKALL	32
258
259/* end version 3 compatibility */
260
261#define MAXCHILDREN 3			/* maximum number of children allowed
262					   to sup at the same time */
263
264#include <stdarg.h>
265