Annotation of src/usr.bin/rdist/defs.h, Revision 1.5
1.5 ! etheisen 1: /* $OpenBSD$ */
1.2 dm 2: #ifndef __DEFS_H__
3: #define __DEFS_H__
1.1 deraadt 4: /*
1.2 dm 5: * Copyright (c) 1983 Regents of the University of California.
6: * All rights reserved.
1.1 deraadt 7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: */
36:
1.2 dm 37: /*
1.5 ! etheisen 38: * $Id: defs.h,v 1.4 1996/04/28 22:10:12 etheisen Exp $
1.2 dm 39: * @(#)defs.h 5.2 (Berkeley) 3/20/86
40: */
1.1 deraadt 41:
1.2 dm 42: /*
43: * POSIX settings
44: */
45: #if defined(_POSIX_SOURCE)
46: #include <unistd.h>
47: #include <stdlib.h>
48: #endif /* _POSIX_SOURCE */
49: #include <stdio.h>
50: #include <ctype.h>
1.1 deraadt 51: #include <errno.h>
52: #include <pwd.h>
53: #include <grp.h>
1.2 dm 54: #include <syslog.h>
55: #include <setjmp.h>
56: #include <sys/types.h>
57: #include <sys/param.h>
58: #include <sys/file.h>
59: #include <sys/time.h>
60: #include <sys/stat.h>
61:
62: #include "version.h"
63: #include "config-def.h"
64: #include "config.h"
65: #include "config-data.h"
1.1 deraadt 66: #include "pathnames.h"
1.2 dm 67: #include "types.h"
68:
69: #if !defined(yacc)
70: /* #include "y.tab.h" */
71: #endif /* yacc */
72:
73: #include <signal.h>
1.1 deraadt 74:
75: /*
1.2 dm 76: * This belongs in os-svr4.h but many SVR4 OS's
77: * define SVR4 externel to Rdist so we put this
78: * check here.
1.1 deraadt 79: */
1.2 dm 80: #if defined(SVR4)
81: #define NEED_FCNTL_H
82: #define NEED_UNISTD_H
83: #define NEED_NETDB_H
84: #endif /* defined(SVR4) */
85:
86: #if defined(NEED_NETDB_H)
87: #include <netdb.h>
88: #endif /* NEED_NETDB_H */
89: #if defined(NEED_FCNTL_H)
90: #include <fcntl.h>
91: #endif /* NEED_FCNTL_H */
92: #if defined(NEED_LIMITS_H)
93: #include <limits.h>
94: #endif /* NEED_LIMITS_H */
95: #if defined(NEED_UNISTD_H)
96: #include <unistd.h>
97: #endif /* NEED_UNISTD_H */
98: #if defined(NEED_STRING_H)
99: #include <string.h>
100: #endif /* NEED_STRING_H */
1.1 deraadt 101:
1.2 dm 102: #if defined(ARG_TYPE)
103: #if ARG_TYPE == ARG_STDARG
104: #include <stdarg.h>
105: #endif
106: #if ARG_TYPE == ARG_VARARGS
107: #include <varargs.h>
108: #endif
109: #endif /* ARG_TYPE */
110:
111: /* boolean truth */
112: #ifndef TRUE
113: #define TRUE 1
114: #endif
115: #ifndef FALSE
116: #define FALSE 0
117: #endif
118:
119: /* file modes */
120: #ifndef S_IXUSR
121: #define S_IXUSR 0000100
122: #endif
123: #ifndef S_IXGRP
124: #define S_IXGRP 0000010
125: #endif
126: #ifndef S_IXOTH
127: #define S_IXOTH 0000001
128: #endif
1.1 deraadt 129:
130: /* lexical definitions */
1.2 dm 131: #define QUOTECHAR 160 /* quote next character */
1.1 deraadt 132:
133: /* table sizes */
134: #define HASHSIZE 1021
1.2 dm 135: #define INMAX 3500
1.1 deraadt 136:
137: /* expand type definitions */
1.2 dm 138: #define E_VARS 0x1
139: #define E_SHELL 0x2
140: #define E_TILDE 0x4
141: #define E_ALL 0x7
1.1 deraadt 142:
143: /* actions for lookup() */
1.2 dm 144: #define LOOKUP 0
145: #define INSERT 1
146: #define REPLACE 2
147:
148: /* Bit flag test macros */
149: #define IS_ON(b,f) (b > 0 && (b & f))
150: #define IS_OFF(b,f) !(IS_ON(b,f))
151: #define FLAG_ON(b,f) b |= f
152: #define FLAG_OFF(b,f) b &= ~(f)
153:
154: /*
155: * POSIX systems should already have S_* defined.
156: */
157: #ifndef S_ISDIR
158: #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
159: #endif
160: #ifndef S_ISREG
161: #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
162: #endif
163: #ifndef S_ISLNK
164: #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
165: #endif
166:
167: #define ALLOC(x) (struct x *) xmalloc(sizeof(struct x))
168: #define A(s) ((s) ? s : "<null>")
169:
170: /*
171: * Environment variable names
172: */
173: #define E_FILES "FILES" /* List of files */
174: #define E_LOCFILE "FILE" /* Local Filename */
175: #define E_REMFILE "REMFILE" /* Remote Filename */
176: #define E_BASEFILE "BASEFILE" /* basename of Remote File */
177:
178: /*
179: * Suffix to use when saving files
180: */
181: #ifndef SAVE_SUFFIX
182: #define SAVE_SUFFIX ".OLD"
183: #endif
1.1 deraadt 184:
1.2 dm 185: /*
186: * Get system error string
187: */
188: #define SYSERR strerror(errno)
189:
190: #define COMMENT_CHAR '#' /* Config file comment char */
191: #define CNULL '\0' /* NULL character */
192:
193: /*
194: * These are the top level protocol commands.
195: */
196: #define C_NONE '=' /* No command - pass cleanly */
197: #define C_ERRMSG '\1' /* Log an error message */
198: #define C_FERRMSG '\2' /* Log a fatal error message */
199: #define C_NOTEMSG '\3' /* Log a note message */
200: #define C_LOGMSG '\4' /* Log a message */
201: #define C_ACK '\5' /* Acknowledge */
202: #define C_SETCONFIG 'c' /* Set configuration parameters */
203: #define C_DIRTARGET 'T' /* Set target directory name */
204: #define C_TARGET 't' /* Set target file name */
205: #define C_RECVREG 'R' /* Receive a regular file */
206: #define C_RECVDIR 'D' /* Receive a directory */
207: #define C_RECVSYMLINK 'K' /* Receive a symbolic link */
208: #define C_RECVHARDLINK 'k' /* Receive a hard link */
209: #define C_END 'E' /* Indicate end of recieve/send */
210: #define C_CLEAN 'C' /* Clean up */
211: #define C_QUERY 'Q' /* Query without checking */
212: #define C_SPECIAL 'S' /* Execute special command */
213: #define C_CMDSPECIAL 's' /* Execute cmd special command */
214: #define C_CHMOD 'M' /* Chmod a file */
215:
216: #define ack() (void) sendcmd(C_ACK, (char *)NULL)
217: #define err() (void) sendcmd(C_ERRMSG, (char *)NULL)
218:
219: /*
220: * Session startup commands.
221: */
222: #define S_VERSION 'V' /* Version number */
223: #define S_REMOTEUSER 'R' /* Remote user name */
224: #define S_LOCALUSER 'L' /* Local user name */
225: #define S_END 'E' /* End of session startup commands */
1.1 deraadt 226:
1.2 dm 227: /*
228: * These are the commands for "set config".
229: */
230: #define SC_FREESPACE 's' /* Set min free space */
231: #define SC_FREEFILES 'f' /* Set min free files */
232: #define SC_HOSTNAME 'H' /* Set client hostname */
233: #define SC_LOGGING 'L' /* Set logging options */
234:
235: /*
236: * Query commands
237: */
238: #define QC_ONNFS 'F' /* File exists & is on a NFS */
239: #define QC_ONRO 'O' /* File exists & is on a readonly fs */
240: #define QC_NO 'N' /* File does not exist */
241: #define QC_SYM 'l' /* File exists & is a symlink */
242: #define QC_YES 'Y' /* File does exist */
1.1 deraadt 243:
1.2 dm 244: /*
245: * Clean commands
246: */
247: #define CC_QUERY 'Q' /* Query if file should be rm'ed */
248: #define CC_END 'E' /* End of cleaning */
249: #define CC_YES 'Y' /* File doesn't exist - remove */
250: #define CC_NO 'N' /* File does exist - don't remove */
251:
252: /*
253: * Run Command commands
254: */
255: #define RC_FILE 'F' /* Name of a target file */
256: #define RC_COMMAND 'C' /* Command to run */
257:
258: /*
259: * Name list
260: */
261: struct namelist { /* for making lists of strings */
1.1 deraadt 262: char *n_name;
263: struct namelist *n_next;
264: };
265:
1.2 dm 266: /*
267: * Sub command structure
268: */
1.1 deraadt 269: struct subcmd {
270: short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
1.2 dm 271: opt_t sc_options;
1.1 deraadt 272: char *sc_name;
273: struct namelist *sc_args;
274: struct subcmd *sc_next;
275: };
276:
1.2 dm 277: /*
278: * Cmd flags
279: */
280: #define CMD_ASSIGNED 0x01 /* This entry has been assigned */
281: #define CMD_CONNFAILED 0x02 /* Connection failed */
282: #define CMD_NOCHKNFS 0x04 /* Disable NFS checks */
283:
284: /*
285: * General command structure
286: */
1.1 deraadt 287: struct cmd {
288: int c_type; /* type - ARROW,DCOLON */
1.2 dm 289: int c_flags; /* flags - CMD_USED,CMD_FAILED */
1.1 deraadt 290: char *c_name; /* hostname or time stamp file name */
291: char *c_label; /* label for partial update */
292: struct namelist *c_files;
293: struct subcmd *c_cmds;
294: struct cmd *c_next;
295: };
296:
1.2 dm 297: /*
298: * Hard link buffer information
299: */
1.1 deraadt 300: struct linkbuf {
301: ino_t inum;
302: dev_t devnum;
303: int count;
304: char pathname[BUFSIZ];
1.2 dm 305: char src[BUFSIZ];
1.1 deraadt 306: char target[BUFSIZ];
307: struct linkbuf *nextp;
308: };
309:
1.2 dm 310: extern char *optarg; /* Option argument */
311: extern char *path_remsh; /* Remote shell command */
312: extern char buf[]; /* General purpose buffer */
313: extern char host[]; /* Host name of master copy */
314: extern char *currenthost; /* Name of current host */
315: extern char *progname; /* Name of this program */
316: extern char **realargv; /* Real argv */
317: extern int optind; /* Option index into argv */
318: extern int contimedout; /* Connection timed out */
319: extern int debug; /* Debugging flag */
320: extern opt_t defoptions; /* Default install options */
321: extern int do_fork; /* Should we do fork()'ing */
322: extern int errno; /* System error number */
323: extern int isserver; /* Acting as remote server */
324: extern int nerrs; /* Number of errors seen */
325: extern int nflag; /* NOP flag, don't execute commands */
326: extern opt_t options; /* Global options */
327: extern int proto_version; /* Protocol version number */
328: extern int realargc; /* Real argc */
329: extern int rem_r; /* Remote file descriptor, reading */
330: extern int rem_w; /* Remote file descriptor, writing */
331: extern int rtimeout; /* Response time out in seconds */
1.3 dm 332: extern int setjmp_ok; /* setjmp/longjmp flag */
1.2 dm 333: extern UID_T userid; /* User ID of rdist user */
334: extern jmp_buf finish_jmpbuf; /* Setjmp buffer for finish() */
335: extern struct group *gr; /* pointer to static area used by getgrent */
336: extern struct linkbuf *ihead; /* list of files with more than one link */
337: extern struct passwd *pw; /* pointer to static area used by getpwent */
338: #ifdef USE_STATDB
339: extern int dostatdb;
340: extern int juststatdb;
341: #endif /* USE_STATDB */
342:
343: /*
344: * System function declarations
345: */
346: char *hasmntopt();
347: char *strchr();
348: char *strdup();
349: char *strrchr();
350: char *strtok();
351:
352: /*
353: * Our own declarations.
354: */
355: char *exptilde();
356: char *makestr();
357: char *xcalloc();
358: char *xmalloc();
359: char *xrealloc();
360: extern char *xbasename();
361: extern char *getdistoptlist();
362: extern char *getgroupname();
363: extern char *getnlstr();
364: extern char *getnotifyfile();
365: extern char *getondistoptlist();
366: extern char *getusername();
367: extern char *getversion();
368: extern char *msgparseopts();
369: extern char *searchpath();
370: extern int any();
371: extern int init();
372: extern int install();
373: extern int isexec();
374: extern int parsedistopts();
375: extern int remline();
376: extern int setfiletime();
377: extern int spawn();
378: extern struct subcmd *makesubcmd();
379: extern void checkhostname();
380: extern void cleanup();
381: extern void complain();
382: extern void docmds();
383: extern void finish();
384: extern void log();
385: extern void logmsg();
386: extern void lostconn();
387: extern void markassigned();
388: extern void msgprusage();
389: extern void note();
390: extern void runcmdspecial();
391: extern void runcommand();
392: extern void server();
393: extern void setprogname();
394: extern void sighandler();
395: extern void waitup();
396: struct namelist *expand();
397: struct namelist *lookup();
398: struct namelist *makenl();
399: extern WRITE_RETURN_T xwrite();
400:
401: #if defined(ARG_TYPE) && ARG_TYPE == ARG_STDARG
402: extern void debugmsg(int, char *, ...);
403: extern void error(char *, ...);
404: extern void fatalerr(char *, ...);
405: extern void message(int, char *, ...);
1.4 etheisen 406: /*extern void setproctitle(char *fmt, ...); /* Not for OpenBSD*/
1.2 dm 407: #else
408: extern void debugmsg();
409: extern void error();
410: extern void fatalerr();
411: extern void message();
412: extern void setproctitle();
413: #endif
414:
415: #endif /* __DEFS_H__ */