Main Page | Class List | Directories | File List | Class Members | File Members

cf.defs.h

Go to the documentation of this file.
00001 /* cfengine for GNU
00002  
00003         Copyright (C) 1995
00004         Free Software Foundation, Inc.
00005  
00006    This file is part of GNU cfengine - written and maintained 
00007    by Mark Burgess, Dept of Computing and Engineering, Oslo College,
00008    Dept. of Theoretical physics, University of Oslo
00009  
00010    This program is free software; you can redistribute it and/or modify it
00011    under the terms of the GNU General Public License as published by the
00012    Free Software Foundation; either version 2, or (at your option) any
00013    later version.
00014  
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019  
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
00023  
00024 
00025 /*******************************************************************/
00026 /*                                                                 */
00027 /*  HEADER for cfengine                                            */
00028 /*                                                                 */
00029 /*******************************************************************/
00030 
00031 #include "conf.h"
00032 #include <stdio.h>
00033 
00034 /*#if defined(STDC_HEADERS) || defined(SUN4)*/
00035 #ifdef HAVE_STDLIB_H
00036 #include <stdlib.h>
00037 #endif
00038 #include <strings.h>
00039 #include <string.h>
00040 #include <ctype.h>
00041 #include <limits.h>
00042 
00043 #ifdef HAVE_UNAME
00044 #include <sys/utsname.h>
00045 #else
00046 #define _SYS_NMLN       257
00047 
00048 struct utsname
00049   {
00050    char    sysname[_SYS_NMLN];
00051    char    nodename[_SYS_NMLN];
00052    char    release[_SYS_NMLN];
00053    char    version[_SYS_NMLN];
00054    char    machine[_SYS_NMLN];
00055    };
00056 
00057 #endif
00058 
00059 #include <sys/types.h>
00060 #include <sys/stat.h>
00061 
00062 #ifdef HAVE_SYS_SYSTEMINFO_H
00063 # include <sys/systeminfo.h>
00064 #endif
00065 
00066 #ifdef HAVE_SYS_PARAM_H
00067 # include <sys/param.h>
00068 #endif
00069 
00070 #ifdef HAVE_SYS_MOUNT_H
00071 #include <sys/mount.h>
00072 #endif
00073 
00074 #ifdef HAVE_SYS_WAIT_H
00075 # include <sys/wait.h>
00076 #endif
00077 #ifndef WEXITSTATUS
00078 # define WEXITSTATUS(s) ((unsigned)(s) >> 8)
00079 #endif
00080 #ifndef WIFEXITED
00081 # define WIFEXITED(s) (((s) & 255) == 0)
00082 #endif
00083 #ifndef WIFSIGNALED
00084 # define WIFSIGNALED(s) ((s) & 0)  /* Can't use for BSD */
00085 #endif
00086 #ifndef WTERMSIG
00087 #define WTERMSIG(s) ((s) & 0)
00088 #endif
00089 
00090 #include <openssl/err.h>
00091 #include <openssl/pem.h>
00092 #include <openssl/evp.h>
00093 #include <openssl/rsa.h>
00094 #include <openssl/rand.h>
00095 #include <openssl/bn.h>
00096 #include <errno.h>
00097 
00098 #ifdef HAVE_DIRENT_H
00099 # include <dirent.h>
00100 #else
00101 # define dirent direct
00102 # if HAVE_SYS_NDIR_H
00103 #  include <sys/ndir.h>
00104 # endif
00105 # if HAVE_SYS_DIR_H
00106 #   include <sys/dir.h>
00107 # endif
00108 # if HAVE_NDIR_H
00109 #  include <ndir.h>
00110 # endif
00111 #endif
00112 
00113 #include <signal.h>
00114 
00115 #include <syslog.h>
00116 extern int errno;
00117 
00118 /* Do this for ease of configuration from the Makefile */
00119 
00120 #ifdef HPuUX
00121 #define HPUX
00122 #endif
00123 
00124 #ifdef SunOS
00125 #define SUN4
00126 #endif
00127 
00128 /* end of patch */
00129 
00130 #ifdef AIX
00131 #ifndef ps2
00132 #include <sys/statfs.h>
00133 #endif
00134 #endif
00135 
00136 #ifdef SOLARIS
00137 #include <sys/statvfs.h>
00138 #undef nfstype
00139 #endif
00140 
00141 #ifndef HAVE_BCOPY
00142 #define bcopy(fr,to,n)  memcpy(to,fr,n)  /* Eliminate ucblib */
00143 #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
00144 #define bzero(s, n)     memset ((s), 0, (n))
00145 #endif
00146 
00147 #ifdef HAVE_UNISTD_H
00148 #include <unistd.h>
00149 #endif
00150 
00151 #ifdef HAVE_MALLOC_H
00152 #ifndef OPENBSD
00153 #ifdef __FreeBSD__
00154 #include <stdlib.h>
00155 #else
00156 #include <malloc.h>
00157 #endif
00158 #endif
00159 #endif
00160 
00161 #include <fcntl.h>
00162 
00163 #ifdef HAVE_VFS_H
00164 # include <sys/vfs.h>
00165 #endif
00166 
00167 #ifdef HPUX
00168 # include <sys/dirent.h>
00169 #endif
00170 
00171 #ifdef HAVE_UTIME_H
00172 # include <utime.h>      /* use utime not utimes for portability */
00173 #elif TIME_WITH_SYS_TIME
00174 #  include <sys/time.h>
00175 #  include <time.h>
00176 #elif HAVE_SYS_TIME_H
00177 #  include <sys/time.h>
00178 #elif ! defined(AOS)
00179 #  include <time.h>
00180 #endif
00181 
00182 #ifdef HAVE_TIME_H
00183 # include <time.h>
00184 #endif
00185 
00186 #ifdef HAVE_SYS_TIME_H
00187 # include <sys/time.h>
00188 #endif
00189 
00190 #include <pwd.h>
00191 #include <grp.h>
00192 
00193 #ifdef HAVE_SYS_SOCKIO_H
00194 # include <sys/sockio.h>
00195 #endif
00196 
00197 #include <sys/socket.h>
00198 #include <sys/ioctl.h>
00199 #include <net/if.h>
00200 #include <netinet/in.h>
00201 #ifndef AOS
00202 # include <arpa/inet.h>
00203 #endif
00204 #include <netdb.h>
00205 #if !defined LINUX && !defined NT
00206 #include <sys/protosw.h>
00207 #undef sgi
00208 #include <net/route.h>
00209 #endif
00210 
00211 #ifdef LINUX
00212 #ifdef __GLIBC__
00213 # include <net/route.h>
00214 # include <netinet/in.h>
00215 #else
00216 # include <linux/route.h>
00217 # include <linux/in.h>
00218 #endif
00219 #endif
00220 
00221 #ifdef HAVE_RXPOSIX_H
00222 # include <rxposix.h>
00223 #elif  HAVE_REGEX_H
00224 # include <regex.h>
00225 #else
00226 # include "../pub/gnuregex.h"
00227 #endif
00228 
00229 #ifndef HAVE_SNPRINTF
00230 #include "../pub/snprintf.h"
00231 #endif
00232 
00233 
00234 /*******************************************************************/
00235 /* Various defines                                                 */
00236 /*******************************************************************/
00237 
00238 #define true  1
00239 #define false 0
00240 #define bufsize 4096
00241 #define buffer_margin 32
00242 #define maxvarsize 1024
00243 #define maxlinksize 256
00244 #define maxlinklevel 4
00245 #define maxargs 31
00246 #define cfmaxiplen 64       /* numerical ip length */
00247 #define noproccols 16
00248 #define hashtablesize 1021  /* prime number */
00249 #define macroalphabet 61    /* a-z, A-Z plus a bit */
00250 #define maxshellargs 30
00251 #define samemode 0
00252 #define sameowner (uid_t)-1
00253 #define unknown_owner (uid_t)-2
00254 #define samegroup (gid_t)-1
00255 #define unknown_group (gid_t)-2
00256 #define cfnosize    -1
00257 #define extra_space 8      /* pads items during AppendItem for eol handling in editfiles */
00258 #define cfinfinity (int)999999999
00259 #define ticksperday 86400 /* 60 * 60 *24 */
00260 #define cf_not_connected -1
00261 #define recursion_limit 100
00262 #define cf_monday_morning 342000
00263 
00264 #define exec_ifelapsed 5
00265 #define exec_expireafter 10
00266 
00267 
00268 /* Need this to to avoid conflict with solaris 2.6 and db.h */
00269 
00270 #ifdef SOLARIS
00271 # define u_int32_t uint32_t
00272 # define u_int16_t uint16_t
00273 # define u_int8_t uint8_t
00274 #endif
00275 
00276 
00277 /*******************************************************************/
00278 /* Class array limits                                              */
00279 /* This is the only place you ever need to edit anything           */
00280 /*******************************************************************/
00281 
00282 #define CLSSATTR 35         /* increase this for each new class added */
00283                             /* It defines the array size for class data */
00284 #define ATTRDIM 3           /* Only used in CLASSATTRUBUTES[][] defn */
00285 
00286    /* end class array limits */
00287 
00288 /*******************************************************************/
00289 
00290 #define AVDB_FILE     "cf_averages.db"
00291 #define STATELOG_FILE "state_log"
00292 #define ENV_NEW_FILE  "env_data.new"
00293 #define ENV_FILE      "env_data"
00294 
00295 #define CFINPUTSVAR "CFINPUTS"          /* default name for file path var */
00296 #define CFALLCLASSESVAR "CFALLCLASSES"  /* default name for CFALLCLASSES env */
00297 #define INFINITERECURSE -99             /* code used to signify inf in recursion */
00298 #define CF_TRUNCATE -1
00299 #define CF_EMPTYFILE -2
00300 #define CF_USELOGFILE true              /* synonyms for tidy.c */
00301 #define CF_NOLOGFILE  false
00302 #define CF_SAVED ".cfsaved"
00303 #define CF_EDITED ".cfedited"
00304 #define CF_NEW ".cfnew"
00305 #define CFD_TERMINATOR "---cfXen/gine/cfXen/gine---"
00306 #define CFD_TRUE "CFD_TRUE"
00307 #define CFD_FALSE "CFD_FALSE"
00308 #define CF_ANYCLASS "any"
00309 #define CF_NOCLASS "XX_CF_opposite_any_XX"
00310 #define CF_NOUSER -99
00311 #define CF_RSA_PROTO_OFFSET 24
00312 #define CF_PROTO_OFFSET 16
00313 #define CF_SMALL_OFFSET 2
00314 #define CF_MD5_LEN 16
00315 #define CF_SHA_LEN 20
00316 
00317 #define CF_DONE 't'
00318 #define CF_MORE 'm'
00319 
00320 #define CFFAILEDSTR "BAD: Host authentication failed. Did you forget the domain name?"
00321 #define CFCHANGEDSTR1 "BAD: File changed "   /* Split this so it cannot be recognized */
00322 #define CFCHANGEDSTR2 "while copying"
00323 
00324 #define CF_START_DOMAIN "undefined.domain"
00325 
00326 #define CFLOGSIZE 1048576                  /* Size of lock-log before rotation */
00327 
00328 /* Output control defines */
00329 
00330 #define Verbose if (VERBOSE || DEBUG || D2) printf
00331 #define EditVerbose  if (EDITVERBOSE || DEBUG || D2) printf
00332 #define Debug3  if (D3 || DEBUG || D2) printf
00333 #define Debug2  if (DEBUG || D2) printf
00334 #define Debug1  if (DEBUG || D1) printf
00335 #define Debug   if (DEBUG || D1 || D2) printf
00336 #define DebugVoid if (false) printf
00337 #define Silent if (! SILENT || VERBOSE || DEBUG || D2) printf
00338 #define DaemonOnly if (ISCFENGINE) yyerror("This belongs in cfservd.conf")
00339 #define CfengineOnly if (! ISCFENGINE) yyerror("This belongs in cfagent.conf")
00340 
00341 /* GNU REGEX */
00342 
00343 #define BYTEWIDTH 8
00344 
00345 /*****************************************************************************/
00346 
00347 #define GRAINS   64
00348 #define ATTR     11
00349 #define PH_LIMIT 10
00350 #define CFWEEK   (7.0*24.0*3600.0)
00351 #define MEASURE_INTERVAL (5.0*60.0)
00352 
00353 
00354 struct Averages
00355    {
00356    double expect_number_of_users;
00357    double expect_rootprocs;
00358    double expect_otherprocs;
00359    double expect_diskfree;
00360    double expect_loadavg;
00361    double expect_incoming[ATTR];
00362    double expect_outgoing[ATTR];
00363    double expect_pH[PH_LIMIT];
00364       
00365    double var_number_of_users;
00366    double var_rootprocs;
00367    double var_otherprocs;
00368    double var_diskfree;
00369    double var_loadavg;
00370    double var_incoming[ATTR];
00371    double var_outgoing[ATTR];
00372    double var_pH[PH_LIMIT];      
00373    };
00374 
00375 /*******************************************************************/
00376 /* Copy file defines                                               */
00377 /*******************************************************************/
00378 
00379             /* Based heavily on cp.c in GNU-fileutils */
00380 
00381 #ifndef DEV_BSIZE
00382 #ifdef BSIZE
00383 #define DEV_BSIZE BSIZE
00384 #else /* !BSIZE */
00385 #define DEV_BSIZE 4096
00386 #endif /* !BSIZE */
00387 #endif /* !DEV_BSIZE */
00388  
00389 /* Extract or fake data from a `struct stat'.
00390    ST_BLKSIZE: Optimal I/O blocksize for the file, in bytes.
00391    ST_NBLOCKS: Number of 512-byte blocks in the file
00392    (including indirect blocks). */
00393 
00394 #ifndef HAVE_ST_BLOCKS
00395 # define ST_BLKSIZE(statbuf) DEV_BSIZE
00396 # if defined(_POSIX_SOURCE) || !defined(BSIZE) /* fileblocks.c uses BSIZE.  */
00397 #  define ST_NBLOCKS(statbuf) (((statbuf).st_size + 512 - 1) / 512)
00398 # else /* !_POSIX_SOURCE && BSIZE */
00399 #  define ST_NBLOCKS(statbuf) (st_blocks ((statbuf).st_size))
00400 # endif /* !_POSIX_SOURCE && BSIZE */
00401 #else /* HAVE_ST_BLOCKS */
00402 /* Some systems, like Sequents, return st_blksize of 0 on pipes. */
00403 # define ST_BLKSIZE(statbuf) ((statbuf).st_blksize > 0 \
00404                                ? (statbuf).st_blksize : DEV_BSIZE)
00405 # if defined(hpux) || defined(__hpux__) || defined(__hpux)
00406 /* HP-UX counts st_blocks in 1024-byte units.
00407    This loses when mixing HP-UX and BSD filesystems with NFS.  */
00408 #  define ST_NBLOCKS(statbuf) ((statbuf).st_blocks * 2)
00409 # else /* !hpux */
00410 #  if defined(_AIX) && defined(_I386)
00411 /* AIX PS/2 counts st_blocks in 4K units.  */
00412 #    define ST_NBLOCKS(statbuf) ((statbuf).st_blocks * 8)
00413 #  else /* not AIX PS/2 */
00414 #    define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
00415 #  endif /* not AIX PS/2 */
00416 # endif /* !hpux */
00417 #endif /* HAVE_ST_BLOCKS */
00418 
00419 #ifndef SEEK_CUR
00420 #define SEEK_CUR 1
00421 #endif
00422 
00423 /*******************************************************************/
00424 /* Client server defines                                           */
00425 /*******************************************************************/
00426 
00427 #define CFENGINE_SERVICE "cfengine"
00428 
00429 enum PROTOS
00430    {
00431    cfd_exec,
00432    cfd_auth,
00433    cfd_get,
00434    cfd_opendir,
00435    cfd_synch,
00436    cfd_classes,
00437    cfd_md5,
00438    cfd_smd5,
00439    cfd_cauth,
00440    cfd_sauth,
00441    cfd_ssynch,
00442    cfd_sget,
00443    cfd_bad
00444    };
00445 
00446 #define CF_WORDSIZE 8 /* Number of bytes in a word */
00447 
00448 /*******************************************************************/
00449 
00450 enum cf_filetype
00451    {
00452    cf_reg,
00453    cf_link,
00454    cf_dir,
00455    cf_fifo,
00456    cf_block,
00457    cf_char,
00458    cf_sock
00459    };
00460 
00461 /*******************************************************************/
00462 
00463 struct cfstat
00464    {
00465    char             *cf_filename;   /* What file are we statting? */
00466    char             *cf_server;     /* Which server did this come from? */
00467    enum cf_filetype  cf_type;       /* enum filetype */
00468    mode_t            cf_lmode;      /* Mode of link, if link */
00469    mode_t            cf_mode;       /* Mode of remote file, not link */
00470    uid_t             cf_uid;        /* User ID of the file's owner */
00471    gid_t             cf_gid;        /* Group ID of the file's group */
00472    off_t             cf_size;       /* File size in bytes */
00473    time_t            cf_atime;      /* Time of last access */
00474    time_t            cf_mtime;      /* Time of last data modification */
00475    time_t            cf_ctime;      /* Time of last file status change */
00476    char              cf_makeholes;  /* what we need to know from blksize and blks */
00477    char             *cf_readlink;   /* link value or NULL */
00478    int               cf_failed;     /* stat returned -1 */
00479    int               cf_nlink;      /* Number of hard links */
00480    int               cf_ino;        /* inode number on server */
00481    struct cfstat    *next;
00482    };
00483 
00484 /*******************************************************************/
00485 
00486 struct cfdir
00487    {
00488    DIR         *cf_dirh;
00489    struct Item *cf_list;
00490    struct Item *cf_listpos;  /* current pos */
00491    };
00492 
00493 typedef struct cfdir CFDIR;
00494 
00495 /*******************************************************************/
00496 
00497 struct cfdirent
00498    {
00499    struct dirent *cf_dirp;
00500    char   d_name[bufsize];   /* This is bigger than POSIX */
00501    };
00502 
00503 
00504 /*******************************************************************/
00505 
00506 enum cfsizes
00507    {
00508    cfabs,
00509    cfpercent
00510    };
00511 
00512 
00513 /*******************************************************************/
00514 
00515 enum builtin
00516    {
00517    nofn,
00518    fn_randomint,
00519    fn_newerthan,
00520    fn_accessedbefore,
00521    fn_changedbefore,
00522    fn_fileexists,
00523    fn_isdir,
00524    fn_islink,
00525    fn_isplain,
00526    fn_execresult,
00527    fn_returnszero,
00528    fn_iprange,
00529    fn_isdefined,
00530    fn_strcmp,
00531    fn_showstate
00532    };
00533 
00534 /*******************************************************************/
00535 
00536 enum actions
00537    {
00538    none,
00539    control,
00540    alerts,
00541    groups,
00542    image,
00543    resolve,
00544    processes,
00545    files,
00546    tidy,
00547    homeservers,
00548    binservers,
00549    mailserver,
00550    required,
00551    disks,
00552    mountables,
00553    links,
00554    import,
00555    shellcommands,
00556    disable,
00557    makepath,
00558    ignore,
00559    broadcast,
00560    defaultroute,
00561    misc_mounts,
00562    editfiles,
00563    unmounta,
00564    admit,
00565    deny,
00566    acls,
00567    interfaces,
00568    filters,
00569    strategies
00570    };
00571 
00572 /*******************************************************************/
00573 
00574 enum classes
00575    {
00576    empty,
00577    soft,
00578    sun4,
00579    ultrx,
00580    hp,
00581    aix,
00582    linuxx,
00583    solaris,
00584    osf,
00585    digital,
00586    sun3,
00587    irix4,
00588    irix,
00589    irix64,
00590    freebsd,
00591    solarisx86,
00592    bsd4_3,
00593    newsos,
00594    netbsd,
00595    aos,
00596    bsd_i,
00597    nextstep,
00598    crayos,
00599    GnU,
00600    cfnt,
00601    unix_sv,
00602    openbsd,
00603    cfsco,
00604    darwin,
00605    ux4800,
00606    unused1,
00607    unused2,
00608    unused3
00609    };
00610 
00611 
00612 /*******************************************************************/
00613 
00614 enum fileactions
00615    {
00616    warnall,
00617    warnplain,
00618    warndirs,
00619    fixall,
00620    fixplain,
00621    fixdirs,
00622    touch,
00623    linkchildren,
00624    create,
00625    compress,
00626    alert
00627    };
00628 
00629 /*******************************************************************/
00630 
00631 enum fileattr  /* See COMMATTRIBUTES[] in globals.c  for matching entry */
00632    {
00633    cfrecurse,
00634    cfmode,
00635    cfowner,
00636    cfgroup,
00637    cfage,
00638    cfaction,
00639    cfpattern,
00640    cflinks,
00641    cftype,
00642    cfdest,
00643    cfforce,
00644    cfforcedirs,
00645    cfforceipv4,
00646    cfbackup,
00647    cfrotate,
00648    cfsize,
00649    cfmatches,
00650    cfsignal,
00651    cfexclude,
00652    cfcopy,
00653    cfsymlink,
00654    cfcptype,
00655    cflntype,
00656    cfinclude,
00657    cfdirlinks,
00658    cfrmdirs,
00659    cfserver,
00660    cfdefine,
00661    cfelsedef,
00662    cffailover,
00663    cftimeout,
00664    cffree,
00665    cfnofile,
00666    cfacl,
00667    cfpurge,
00668    cfuseshell,
00669    cfsetlog,
00670    cfsetinform,
00671    cfsetnetmask,
00672    cfsetbroadcast,
00673    cfignore,
00674    cfdeldir,
00675    cfdelfstab,
00676    cfstealth,
00677    cfchksum,
00678    cfflags,
00679    cfencryp,
00680    cfverify,
00681    cfroot,
00682    cftypecheck,
00683    cfumask,
00684    cfcompress,
00685    cffilter,
00686    cffork,
00687    cfchdir,
00688    cfchroot,
00689    cfpreview,
00690    cfrepository,
00691    cftimestamps,
00692    cftrustkey,
00693    cfcompat,
00694    cfmountoptions,
00695    cfreadonly,
00696    cfbad                        /* HvB must be as last */               
00697    };
00698 
00699 
00700 /*******************************************************************/
00701 
00702 enum itemtypes
00703    {
00704    simple,
00705    netgroup,
00706    classscript,
00707    deletion,
00708    groupdeletion
00709    };
00710 
00711 /*********************************************************************/
00712 
00713 enum vnames 
00714    {
00715    cffaculty,
00716    cfsite,
00717    cfhost,
00718    cffqhost,
00719    cfipaddr,
00720    cfbinserver,
00721    cfsysadm,
00722    cfdomain,
00723    cftimezone,
00724    cfnetmask,
00725    cfnfstype,
00726    cfssize,
00727    cfscount,
00728    cfeditsize,
00729    cfbineditsize,
00730    cfactseq,
00731    cfmountpat,
00732    cfhomepat,
00733    cfaddclass,
00734    cfinstallclass,
00735    cfschedule,
00736    cfaccess,
00737    cfclass,
00738    cfarch,
00739    cfarch2,
00740    cfdate,
00741    cfyear,
00742    cfmonth,
00743    cfday,
00744    cfhr,
00745    cfmin,
00746    cfallclass,
00747    cfexcludecp,
00748    cfsinglecp,
00749    cfautodef,
00750    cfexcludeln,
00751    cfcplinks,
00752    cflncopies,
00753    cfrepos,
00754    cfspc,
00755    cftab,
00756    cflf,
00757    cfcr,
00758    cfn,
00759    cfdblquote,
00760    cfquote,
00761    cfdollar,
00762    cfrepchar,
00763    cflistsep,
00764    cfunderscore,
00765    cfifname,
00766    cfexpireafter,
00767    cfifelapsed,
00768    cfextension,
00769    cfsuspicious,
00770    cfspooldirs,
00771    cfnonattackers,
00772    cfattackers,
00773    cfmulticonn,
00774    cftrustkeys,
00775    cfdynamic,
00776    cfallowusers,
00777    cfskipverify,
00778    cfdefcopy,
00779    cfredef,
00780    nonexistentvar
00781    };
00782 
00783 /*******************************************************************/
00784 
00785 enum resc
00786    {
00787    rmountcom,
00788    runmountcom,
00789    rethernet,
00790    rmountopts,
00791    runused,
00792    rfstab,
00793    rmaildir,
00794    rnetstat,
00795    rpscomm,
00796    rpsopts
00797    };
00798 
00799 /*******************************************************************/
00800 
00801 enum aseq
00802    {
00803    mkpaths,
00804    lnks,
00805    chkmail,
00806    requir,
00807    diskreq,
00808    tidyf,
00809    shellcom,
00810    chkfiles,
00811    disabl,
00812    mountresc,
00813    edfil,
00814    mountall,
00815    umnt,
00816    resolv,
00817    imag,
00818    netconfig,
00819    tzone,
00820    mountinfo,
00821    procs,
00822    non,
00823    plugin
00824    };
00825 
00826 /*******************************************************************/
00827 
00828 enum editnames
00829    {
00830    NoEdit,
00831    DeleteLinesStarting,
00832    DeleteLinesContaining,
00833    DeleteLinesMatching,
00834    AppendIfNoSuchLine,
00835    PrependIfNoSuchLine,
00836    WarnIfNoSuchLine,
00837    WarnIfLineMatching,
00838    WarnIfNoLineMatching,
00839    WarnIfLineStarting,
00840    WarnIfLineContaining,
00841    WarnIfNoLineStarting,
00842    WarnIfNoLineContaining,
00843    HashCommentLinesContaining,
00844    HashCommentLinesStarting,
00845    HashCommentLinesMatching,
00846    SlashCommentLinesContaining,
00847    SlashCommentLinesStarting,
00848    SlashCommentLinesMatching,
00849    PercentCommentLinesContaining,
00850    PercentCommentLinesStarting,
00851    PercentCommentLinesMatching,
00852    ResetSearch,
00853    SetSearchRegExp,
00854    LocateLineMatching,
00855    InsertLine,
00856    IncrementPointer,
00857    ReplaceLineWith,
00858    DeleteToLineMatching,
00859    HashCommentToLineMatching,
00860    PercentCommentToLineMatching,
00861    SetScript,
00862    RunScript,
00863    RunScriptIfNoLineMatching,
00864    RunScriptIfLineMatching,
00865    AppendIfNoLineMatching,
00866    PrependIfNoLineMatching,
00867    DeleteNLines,
00868    EmptyEntireFilePlease,
00869    GotoLastLine,
00870    BreakIfLineMatches,
00871    BeginGroupIfNoMatch,
00872    BeginGroupIfNoLineMatching,
00873    BeginGroupIfNoSuchLine,
00874    EndGroup,
00875    Append,
00876    Prepend,
00877    SetCommentStart,
00878    SetCommentEnd,
00879    CommentLinesMatching,
00880    CommentLinesStarting,
00881    CommentToLineMatching,
00882    CommentNLines,
00883    UnCommentNLines,
00884    ReplaceAll,
00885    With,
00886    SetLine,
00887    FixEndOfLine,
00888    AbortAtLineMatching,
00889    UnsetAbort,
00890    AutoMountDirectResources,
00891    UnCommentLinesContaining,
00892    UnCommentLinesMatching,
00893    InsertFile,
00894    CommentLinesContaining,
00895    BeginGroupIfFileIsNewer,
00896    BeginGroupIfFileExists,
00897    BeginGroupIfNoLineContaining,
00898    BeginGroupIfDefined,
00899    BeginGroupIfNotDefined,
00900    AutoCreate,
00901    ForEachLineIn,
00902    EndLoop,
00903    ReplaceLinesMatchingField,
00904    SplitOn,
00905    AppendToLineIfNotContains,
00906    DeleteLinesAfterThisMatching,
00907    DefineClasses,
00908    ElseDefineClasses,
00909    CatchAbort,
00910    EditBackup,
00911    EditLog,
00912    EditInform,
00913    EditRecurse,
00914    EditMode,
00915    WarnIfContainsString,
00916    WarnIfContainsFile,
00917    EditIgnore,
00918    EditExclude,
00919    EditInclude,
00920    EditRepos,
00921    EditUmask,
00922    EditUseShell,
00923    EditFilter,
00924    DefineInGroup
00925    };
00926 
00927 enum RegExpTypes
00928    {
00929    posix,
00930    gnu,
00931    bsd
00932    };
00933 
00934 
00935 /*******************************************************************/
00936 
00937 enum SignalNames
00938    {
00939    cfnosignal,
00940    cfhup,
00941    cfint,
00942    cfquit,
00943    cfill,
00944    cftrap,
00945    cfiot,
00946    cfemt,
00947    cffpr,
00948    cfkill,
00949    cfbus,
00950    cfsegv,
00951    cfsys,
00952    cfpipe,
00953    cfalrm,
00954    cfterm,
00955    };
00956 
00957 #define highest_signal 64
00958 
00959 /*******************************************************************/
00960 
00961 enum cfoutputlevel
00962    {
00963    cfsilent,
00964    cfinform,
00965    cfverbose,
00966    cfeditverbose,
00967    cferror,
00968    cflogonly
00969    };
00970 
00971 /*******************************************************************/
00972 
00973 enum modestate
00974    {
00975    wild,
00976    who,
00977    which
00978    };
00979 
00980 enum modesort
00981    {
00982    unknown,
00983    numeric,
00984    symbolic
00985    };
00986 
00987 /*******************************************************************/
00988 
00989 typedef char flag;
00990 
00991 /*******************************************************************/
00992 
00993 struct cfagent_connection
00994    {
00995    int sd;
00996    int trust;
00997    int family;     /* AF_INET or AF_INET6 */
00998    char localip[cfmaxiplen];
00999    char remoteip[cfmaxiplen];
01000    unsigned char *session_key;
01001    short error;
01002    };
01003 
01004 /*******************************************************************/
01005 
01006 struct cfObject
01007    {
01008    char *scope;                       /* Name of object (scope) */
01009    char *hashtable[hashtablesize];    /* Variable heap  */
01010    char *classlist;                   /* Private classes -- ? */
01011    struct Item *actionsequence;
01012    struct cfObject *next;
01013    };
01014 
01015 
01016 /*
01017 
01018  $(globalvar)
01019 
01020  $(obj.name)
01021 
01022 */
01023 
01024 /*******************************************************************/
01025 
01026 struct CompressedArray
01027    {
01028    int key;
01029    char *value;
01030    struct CompressedArray *next;
01031    };
01032 
01033 /*******************************************************************/
01034 
01035 struct Interface
01036    {
01037    char done;
01038    char *scope;
01039    char *ifdev;
01040    char *netmask;
01041    char *broadcast;
01042    char *classes;
01043    struct Interface *next;
01044    };
01045 
01046 /*******************************************************************/
01047 
01048 struct Item
01049    {
01050    char done;
01051    char *name;
01052    char *classes;
01053    struct Item *next;
01054    char *scope;
01055    };
01056 
01057 /*******************************************************************/
01058 
01059 struct TwoDimList
01060    {
01061    short is2d;                  /* true if list > 1 */
01062    short rounds;
01063    char  sep;                   /* char used to divide into strings with 1 variable */
01064    struct Item *ilist;          /* Each node contains a list */
01065    struct Item *current;        /* A static working pointer */
01066    struct TwoDimList *next;
01067    };
01068 
01069 /*******************************************************************/
01070 
01071 struct Process
01072    {
01073    char done;
01074    char *scope;
01075    char           *expr;          /* search regex */
01076    char           *restart;       /* shell comm to be done after */
01077    char           *chdir;
01078    char           *chroot;
01079    uid_t          uid;
01080    gid_t          gid;
01081    mode_t         umask;
01082    short          matches;
01083    char           comp;
01084    char           *defines;
01085    char           *elsedef;
01086    short          signal;
01087    char           action;
01088    char           *classes;
01089    char           useshell;
01090    char           log;
01091    char           inform;
01092    struct Item    *exclusions;
01093    struct Item    *inclusions;
01094    struct Item    *filters;
01095    struct Process *next;
01096    };
01097 
01098 /*******************************************************************/
01099 
01100 /*
01101  * HvB : Bas van der Vlies
01102 */
01103 struct Mountables
01104    {
01105    char                 done;
01106    char                 *scope;
01107    char                 readonly;       /* y/n - true false */
01108    char                 *filesystem;
01109    char                 *mountopts;
01110    struct Mountables    *next;
01111    };
01112 
01113 /*******************************************************************/
01114 
01115 struct Tidy
01116    {
01117    int          maxrecurse;              /* sets maxval */
01118    char         done;       /* Too intensive in Tidy Pattern */
01119    char         *scope;
01120    char        *path;
01121    struct Item *exclusions;
01122    struct Item *ignores;      
01123    struct TidyPattern *tidylist;
01124    struct Tidy        *next;   
01125    };
01126 
01127    /**** SUB CLASS *********************************************/
01128 
01129       struct TidyPattern
01130          {
01131          int                recurse;
01132          short              age;
01133          int                size;              /* in bytes */
01134          char               *pattern;        /* synonym for pattern */
01135          struct Item        *filters;
01136          char               *classes;
01137          char               *defines;
01138          char               *elsedef;
01139          char               compress;
01140          char               travlinks;
01141          char               dirlinks;          /* k=keep, t=tidy */
01142          char               rmdirs;            /* t=true, f=false */
01143          char               searchtype;        /* a, m, c time */
01144          char               log;
01145          char               inform;
01146          struct TidyPattern *next;
01147          };
01148 
01149 
01150 /*******************************************************************/
01151 
01152 struct Mounted
01153    {
01154    char *scope;
01155    char *name;
01156    char *on;
01157    char *options;
01158    char *type;
01159    };
01160 
01161 /*******************************************************************/
01162 
01163 struct MiscMount
01164    {
01165    char done;
01166    char *scope;
01167    char *from;
01168    char *onto;
01169    char *options;
01170    char *classes;
01171    struct MiscMount *