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