[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.11

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