[BACK]Return to defs.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / rdist

Annotation of src/usr.bin/rdist/defs.h, Revision 1.7

1.7     ! millert     1: /*     $OpenBSD: defs.h,v 1.6 1997/04/27 13:01:28 downsj Exp $ */
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.7     ! millert    38:  * $Id: defs.h,v 1.6 1997/04/27 13:01:28 downsj 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 */
1.6       downsj     98: #if    defined(NEED_STDLIB_H)
                     99: #include <stdlib.h>
                    100: #endif /* NEED_STDLIB_H */
1.2       dm        101: #if    defined(NEED_STRING_H)
                    102: #include <string.h>
                    103: #endif /* NEED_STRING_H */
1.1       deraadt   104:
1.2       dm        105: #if defined(ARG_TYPE)
                    106: #if    ARG_TYPE == ARG_STDARG
                    107: #include <stdarg.h>
                    108: #endif
                    109: #if    ARG_TYPE == ARG_VARARGS
                    110: #include <varargs.h>
                    111: #endif
                    112: #endif /* ARG_TYPE */
                    113:
                    114:        /* boolean truth */
                    115: #ifndef TRUE
                    116: #define TRUE           1
                    117: #endif
                    118: #ifndef FALSE
                    119: #define FALSE          0
                    120: #endif
                    121:
                    122:        /* file modes */
                    123: #ifndef S_IXUSR
                    124: #define S_IXUSR                0000100
                    125: #endif
                    126: #ifndef S_IXGRP
                    127: #define S_IXGRP                0000010
                    128: #endif
                    129: #ifndef S_IXOTH
                    130: #define S_IXOTH                0000001
                    131: #endif
1.1       deraadt   132:
                    133:        /* lexical definitions */
1.2       dm        134: #define        QUOTECHAR       160     /* quote next character */
1.1       deraadt   135:
                    136:        /* table sizes */
                    137: #define HASHSIZE       1021
1.2       dm        138: #define INMAX          3500
1.1       deraadt   139:
                    140:        /* expand type definitions */
1.2       dm        141: #define E_VARS         0x1
                    142: #define E_SHELL                0x2
                    143: #define E_TILDE                0x4
                    144: #define E_ALL          0x7
1.1       deraadt   145:
                    146:        /* actions for lookup() */
1.2       dm        147: #define LOOKUP         0
                    148: #define INSERT         1
                    149: #define REPLACE                2
                    150:
                    151:        /* Bit flag test macros */
                    152: #define IS_ON(b,f)     (b > 0 && (b & f))
                    153: #define IS_OFF(b,f)    !(IS_ON(b,f))
                    154: #define FLAG_ON(b,f)   b |= f
                    155: #define FLAG_OFF(b,f)  b &= ~(f)
                    156:
                    157: /*
                    158:  * POSIX systems should already have S_* defined.
                    159:  */
                    160: #ifndef S_ISDIR
                    161: #define S_ISDIR(m)     (((m) & S_IFMT) == S_IFDIR)
                    162: #endif
                    163: #ifndef S_ISREG
                    164: #define S_ISREG(m)     (((m) & S_IFMT) == S_IFREG)
                    165: #endif
                    166: #ifndef S_ISLNK
                    167: #define S_ISLNK(m)     (((m) & S_IFMT) == S_IFLNK)
                    168: #endif
                    169:
                    170: #define ALLOC(x)       (struct x *) xmalloc(sizeof(struct x))
                    171: #define A(s)           ((s) ? s : "<null>")
                    172:
                    173: /*
                    174:  * Environment variable names
                    175:  */
                    176: #define E_FILES                "FILES"                 /* List of files */
                    177: #define E_LOCFILE      "FILE"                  /* Local Filename  */
                    178: #define E_REMFILE      "REMFILE"               /* Remote Filename */
                    179: #define E_BASEFILE     "BASEFILE"              /* basename of Remote File */
                    180:
                    181: /*
                    182:  * Suffix to use when saving files
                    183:  */
                    184: #ifndef SAVE_SUFFIX
                    185: #define SAVE_SUFFIX    ".OLD"
                    186: #endif
1.1       deraadt   187:
1.2       dm        188: /*
                    189:  * Get system error string
                    190:  */
                    191: #define SYSERR                 strerror(errno)
                    192:
                    193: #define COMMENT_CHAR   '#'             /* Config file comment char */
                    194: #define CNULL          '\0'            /* NULL character */
                    195:
                    196: /*
                    197:  * These are the top level protocol commands.
                    198:  */
                    199: #define C_NONE         '='             /* No command - pass cleanly */
                    200: #define C_ERRMSG       '\1'            /* Log an error message */
                    201: #define C_FERRMSG      '\2'            /* Log a fatal error message */
                    202: #define C_NOTEMSG      '\3'            /* Log a note message */
                    203: #define C_LOGMSG       '\4'            /* Log a message */
                    204: #define C_ACK          '\5'            /* Acknowledge */
                    205: #define C_SETCONFIG    'c'             /* Set configuration parameters */
                    206: #define C_DIRTARGET    'T'             /* Set target directory name */
                    207: #define C_TARGET       't'             /* Set target file name */
                    208: #define C_RECVREG      'R'             /* Receive a regular file */
                    209: #define C_RECVDIR      'D'             /* Receive a directory */
                    210: #define C_RECVSYMLINK  'K'             /* Receive a symbolic link */
                    211: #define C_RECVHARDLINK 'k'             /* Receive a hard link */
                    212: #define C_END          'E'             /* Indicate end of recieve/send */
                    213: #define C_CLEAN                'C'             /* Clean up */
                    214: #define C_QUERY                'Q'             /* Query without checking */
                    215: #define C_SPECIAL      'S'             /* Execute special command */
                    216: #define C_CMDSPECIAL   's'             /* Execute cmd special command */
                    217: #define C_CHMOD                'M'             /* Chmod a file */
                    218:
                    219: #define        ack()           (void) sendcmd(C_ACK, (char *)NULL)
                    220: #define        err()           (void) sendcmd(C_ERRMSG, (char *)NULL)
                    221:
                    222: /*
                    223:  * Session startup commands.
                    224:  */
                    225: #define S_VERSION      'V'             /* Version number */
                    226: #define S_REMOTEUSER   'R'             /* Remote user name */
                    227: #define S_LOCALUSER    'L'             /* Local user name */
                    228: #define S_END          'E'             /* End of session startup commands */
1.1       deraadt   229:
1.2       dm        230: /*
                    231:  * These are the commands for "set config".
                    232:  */
                    233: #define SC_FREESPACE   's'             /* Set min free space */
                    234: #define SC_FREEFILES   'f'             /* Set min free files */
                    235: #define SC_HOSTNAME    'H'             /* Set client hostname */
                    236: #define SC_LOGGING     'L'             /* Set logging options */
                    237:
                    238: /*
                    239:  * Query commands
                    240:  */
                    241: #define QC_ONNFS       'F'             /* File exists & is on a NFS */
                    242: #define QC_ONRO                'O'             /* File exists & is on a readonly fs */
                    243: #define QC_NO          'N'             /* File does not exist */
                    244: #define QC_SYM         'l'             /* File exists & is a symlink */
                    245: #define QC_YES         'Y'             /* File does exist */
1.1       deraadt   246:
1.2       dm        247: /*
                    248:  * Clean commands
                    249:  */
                    250: #define CC_QUERY       'Q'             /* Query if file should be rm'ed */
                    251: #define CC_END         'E'             /* End of cleaning */
                    252: #define CC_YES         'Y'             /* File doesn't exist - remove */
                    253: #define CC_NO          'N'             /* File does exist - don't remove */
                    254:
                    255: /*
                    256:  * Run Command commands
                    257:  */
                    258: #define RC_FILE                'F'             /* Name of a target file */
                    259: #define RC_COMMAND     'C'             /* Command to run */
                    260:
                    261: /*
                    262:  * Name list
                    263:  */
                    264: struct namelist {              /* for making lists of strings */
1.1       deraadt   265:        char    *n_name;
                    266:        struct  namelist *n_next;
                    267: };
                    268:
1.2       dm        269: /*
                    270:  * Sub command structure
                    271:  */
1.1       deraadt   272: struct subcmd {
                    273:        short   sc_type;        /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
1.2       dm        274:        opt_t   sc_options;
1.1       deraadt   275:        char    *sc_name;
                    276:        struct  namelist *sc_args;
                    277:        struct  subcmd *sc_next;
                    278: };
                    279:
1.2       dm        280: /*
                    281:  * Cmd flags
                    282:  */
                    283: #define CMD_ASSIGNED   0x01    /* This entry has been assigned */
                    284: #define CMD_CONNFAILED 0x02    /* Connection failed */
                    285: #define CMD_NOCHKNFS   0x04    /* Disable NFS checks */
                    286:
                    287: /*
                    288:  * General command structure
                    289:  */
1.1       deraadt   290: struct cmd {
                    291:        int     c_type;         /* type - ARROW,DCOLON */
1.2       dm        292:        int     c_flags;        /* flags - CMD_USED,CMD_FAILED */
1.1       deraadt   293:        char    *c_name;        /* hostname or time stamp file name */
                    294:        char    *c_label;       /* label for partial update */
                    295:        struct  namelist *c_files;
                    296:        struct  subcmd *c_cmds;
                    297:        struct  cmd *c_next;
                    298: };
                    299:
1.2       dm        300: /*
                    301:  * Hard link buffer information
                    302:  */
1.1       deraadt   303: struct linkbuf {
                    304:        ino_t   inum;
                    305:        dev_t   devnum;
                    306:        int     count;
                    307:        char    pathname[BUFSIZ];
1.2       dm        308:        char    src[BUFSIZ];
1.1       deraadt   309:        char    target[BUFSIZ];
                    310:        struct  linkbuf *nextp;
                    311: };
                    312:
1.2       dm        313: extern char           *optarg;         /* Option argument */
                    314: extern char           *path_remsh;     /* Remote shell command */
                    315: extern char            host[];         /* Host name of master copy */
                    316: extern char           *currenthost;    /* Name of current host */
                    317: extern char           *progname;       /* Name of this program */
                    318: extern char          **realargv;       /* Real argv */
                    319: extern int             optind;         /* Option index into argv */
                    320: extern int             contimedout;    /* Connection timed out */
                    321: extern int             debug;          /* Debugging flag */
                    322: extern opt_t           defoptions;     /* Default install options */
                    323: extern int             do_fork;        /* Should we do fork()'ing */
                    324: extern int             errno;          /* System error number */
                    325: extern int             isserver;       /* Acting as remote server */
                    326: extern int             nerrs;          /* Number of errors seen */
                    327: extern int             nflag;          /* NOP flag, don't execute commands */
                    328: extern opt_t           options;        /* Global options */
                    329: extern int             proto_version;  /* Protocol version number */
                    330: extern int             realargc;       /* Real argc */
                    331: extern int             rem_r;          /* Remote file descriptor, reading */
                    332: extern int             rem_w;          /* Remote file descriptor, writing */
                    333: extern int             rtimeout;       /* Response time out in seconds */
1.3       dm        334: extern int             setjmp_ok;      /* setjmp/longjmp flag */
1.2       dm        335: extern UID_T           userid;         /* User ID of rdist user */
                    336: extern jmp_buf                 finish_jmpbuf;  /* Setjmp buffer for finish() */
                    337: extern struct group    *gr;    /* pointer to static area used by getgrent */
                    338: extern struct linkbuf  *ihead; /* list of files with more than one link */
                    339: extern struct passwd   *pw;    /* pointer to static area used by getpwent */
                    340: #ifdef USE_STATDB
                    341: extern int             dostatdb;
                    342: extern int             juststatdb;
                    343: #endif /* USE_STATDB */
                    344:
1.6       downsj    345: #if 0
1.2       dm        346: /*
                    347:  * System function declarations
                    348:  */
                    349: char                          *hasmntopt();
                    350: char                          *strchr();
                    351: char                          *strdup();
                    352: char                          *strrchr();
                    353: char                          *strtok();
1.6       downsj    354: #endif
1.2       dm        355:
                    356: /*
                    357:  * Our own declarations.
                    358:  */
                    359: char                          *exptilde();
                    360: char                          *makestr();
                    361: char                          *xcalloc();
                    362: char                          *xmalloc();
                    363: char                          *xrealloc();
                    364: extern char                   *xbasename();
                    365: extern char                   *getdistoptlist();
                    366: extern char                   *getgroupname();
                    367: extern char                   *getnlstr();
                    368: extern char                   *getnotifyfile();
                    369: extern char                   *getondistoptlist();
                    370: extern char                   *getusername();
                    371: extern char                   *getversion();
                    372: extern char                   *msgparseopts();
                    373: extern char                   *searchpath();
                    374: extern int                     any();
                    375: extern int                     init();
                    376: extern int                     install();
                    377: extern int                     isexec();
                    378: extern int                     parsedistopts();
                    379: extern int                     remline();
                    380: extern int                     setfiletime();
                    381: extern int                     spawn();
                    382: extern struct subcmd          *makesubcmd();
                    383: extern void                    checkhostname();
                    384: extern void                    cleanup();
                    385: extern void                    complain();
                    386: extern void                    docmds();
                    387: extern void                    finish();
                    388: extern void                    log();
                    389: extern void                    logmsg();
                    390: extern void                    lostconn();
                    391: extern void                    markassigned();
                    392: extern void                    msgprusage();
                    393: extern void                    note();
                    394: extern void                    runcmdspecial();
                    395: extern void                    runcommand();
                    396: extern void                    server();
                    397: extern void                    setprogname();
                    398: extern void                    sighandler();
                    399: extern void                    waitup();
                    400: struct namelist                       *expand();
                    401: struct namelist                       *lookup();
                    402: struct namelist                       *makenl();
                    403: extern WRITE_RETURN_T          xwrite();
                    404:
                    405: #if    defined(ARG_TYPE) && ARG_TYPE == ARG_STDARG
                    406: extern void                    debugmsg(int, char *, ...);
                    407: extern void                    error(char *, ...);
                    408: extern void                    fatalerr(char *, ...);
                    409: extern void                    message(int, char *, ...);
1.6       downsj    410: #if 0
                    411: extern void                    setproctitle(char *fmt, ...);
                    412: #endif
1.2       dm        413: #else
                    414: extern void                    debugmsg();
                    415: extern void                    error();
                    416: extern void                    fatalerr();
                    417: extern void                    message();
                    418: extern void                    setproctitle();
                    419: #endif
                    420:
                    421: #endif /* __DEFS_H__ */