home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / tripwire / part05 < prev    next >
Encoding:
Text File  |  1993-04-19  |  67.3 KB  |  2,312 lines

  1. Newsgroups: comp.sources.unix
  2. From: spaf@cs.purdue.edu (Gene Spafford)
  3. Subject: v26i177: tripwire - security integrity monitor, Part05/08
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: spaf@cs.purdue.edu (Gene Spafford)
  8. Posting-Number: Volume 26, Issue 177
  9. Archive-Name: tripwire/part05
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 5 (of 8)."
  18. # Contents:  tripwire-1.0 tripwire-1.0/sigs tripwire-1.0/sigs/crc32
  19. #   tripwire-1.0/sigs/md4 tripwire-1.0/sigs/md5
  20. #   tripwire-1.0/sigs/snefru tripwire-1.0/src tripwire-1.0/src/main.c
  21. #   tripwire-1.0/src/dbase.build.c tripwire-1.0/src/config.pre.y
  22. #   tripwire-1.0/sigs/md4/md4.c tripwire-1.0/sigs/snefru/README.snefru
  23. #   tripwire-1.0/sigs/crc32/crc32.c tripwire-1.0/src/ignorevec.c
  24. #   tripwire-1.0/sigs/md5/Makefile
  25. # Wrapped by spaf@uther.cs.purdue.edu on Tue Nov  3 16:31:56 1992
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test ! -d 'tripwire-1.0' ; then
  28.     echo shar: Creating directory \"'tripwire-1.0'\"
  29.     mkdir 'tripwire-1.0'
  30. fi
  31. if test ! -d 'tripwire-1.0/sigs' ; then
  32.     echo shar: Creating directory \"'tripwire-1.0/sigs'\"
  33.     mkdir 'tripwire-1.0/sigs'
  34. fi
  35. if test ! -d 'tripwire-1.0/sigs/crc32' ; then
  36.     echo shar: Creating directory \"'tripwire-1.0/sigs/crc32'\"
  37.     mkdir 'tripwire-1.0/sigs/crc32'
  38. fi
  39. if test ! -d 'tripwire-1.0/sigs/md4' ; then
  40.     echo shar: Creating directory \"'tripwire-1.0/sigs/md4'\"
  41.     mkdir 'tripwire-1.0/sigs/md4'
  42. fi
  43. if test ! -d 'tripwire-1.0/sigs/md5' ; then
  44.     echo shar: Creating directory \"'tripwire-1.0/sigs/md5'\"
  45.     mkdir 'tripwire-1.0/sigs/md5'
  46. fi
  47. if test ! -d 'tripwire-1.0/sigs/snefru' ; then
  48.     echo shar: Creating directory \"'tripwire-1.0/sigs/snefru'\"
  49.     mkdir 'tripwire-1.0/sigs/snefru'
  50. fi
  51. if test ! -d 'tripwire-1.0/src' ; then
  52.     echo shar: Creating directory \"'tripwire-1.0/src'\"
  53.     mkdir 'tripwire-1.0/src'
  54. fi
  55. if test -f 'tripwire-1.0/src/main.c' -a "${1}" != "-c" ; then 
  56.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/main.c'\"
  57. else
  58. echo shar: Extracting \"'tripwire-1.0/src/main.c'\" \(10112 characters\)
  59. sed "s/^X//" >'tripwire-1.0/src/main.c' <<'END_OF_FILE'
  60. X#ifndef lint
  61. Xstatic char rcsid[] = "$Id: main.c,v 1.3 92/11/03 02:43:52 genek Exp $";
  62. X#endif
  63. X
  64. X/************************************************************************
  65. X *
  66. X *   All files in the distribution of Tripwire are Copyright 1992 by the
  67. X *   Purdue Research Foundation of Purdue University.  All rights
  68. X *   reserved.  Some individual files in this distribution may be covered
  69. X *   by other copyrights, as noted in their embedded comments.
  70. X *
  71. X *   Redistribution and use in source and binary forms are permitted
  72. X *   provided that this entire copyright notice is duplicated in all such
  73. X *   copies, and that any documentation, announcements, and other
  74. X *   materials related to such distribution and use acknowledge that the
  75. X *   software was developed at Purdue University, W. Lafayette, IN by
  76. X *   Gene Kim and Eugene Spafford.  No charge, other than an "at-cost"
  77. X *   distribution fee, may be charged for copies, derivations, or
  78. X *   distributions of this material without the express written consent
  79. X *   of the copyright holder.  Neither the name of the University nor the
  80. X *   names of the authors may be used to endorse or promote products
  81. X *   derived from this material without specific prior written
  82. X *   permission.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
  83. X *   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
  84. X *   IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR ANY PARTICULAR
  85. X *   PURPOSE.
  86. X *
  87. X ************************************************************************/
  88. X
  89. X/*
  90. X * main.c
  91. X *
  92. X *    main routines and global variables
  93. X *
  94. X * Gene Kim
  95. X * Purdue University
  96. X */
  97. X
  98. X#include "../include/config.h"
  99. X#include <stdio.h>
  100. X#ifdef STDLIBH
  101. X#include <stdlib.h>
  102. X#include <unistd.h>
  103. X#endif
  104. X#include <sys/types.h>
  105. X#include <sys/stat.h>
  106. X#include <fcntl.h>
  107. X#include <sys/param.h>
  108. X#ifdef STRINGH
  109. X#include <string.h>
  110. X#else
  111. X#include <strings.h>
  112. X#endif
  113. X#ifdef MALLOCH
  114. X# include <malloc.h>
  115. X#endif
  116. X#if (defined(SYSV) && (SYSV < 3))
  117. X# include <limits.h>
  118. X#endif    /* SVR2 */
  119. X#include "../include/list.h"
  120. X#include "../include/tripwire.h"
  121. X#include "../include/patchlevel.h"
  122. X
  123. X
  124. X/* version information */
  125. X
  126. Xchar *version_num = VERSION_NUM;
  127. Xint db_version_num = DB_VERSION_NUM;
  128. X
  129. X/******* signature functions *****************************************
  130. X *    sig_md5_get        : MD5 by RSA
  131. X *    sig_snefru_get        : Snefru by Xerox
  132. X *    sig_null_get        : null
  133. X *********************************************************************/
  134. X
  135. Xint (*pf_signatures [NUM_SIGS]) () = {
  136. X                    SIG0FUNC,
  137. X                    SIG1FUNC,
  138. X                    SIG2FUNC,
  139. X                    SIG3FUNC,
  140. X                    SIG4FUNC,
  141. X                    SIG5FUNC,
  142. X                    SIG6FUNC,
  143. X                    SIG7FUNC,
  144. X                    SIG8FUNC,
  145. X                    SIG9FUNC
  146. X                      };
  147. Xchar *signames[NUM_SIGS] = {
  148. X                    SIG0NAME,
  149. X                    SIG1NAME,
  150. X                    SIG2NAME,
  151. X                    SIG3NAME,
  152. X                    SIG4NAME,
  153. X                    SIG5NAME,
  154. X                    SIG6NAME,
  155. X                    SIG7NAME,
  156. X                    SIG8NAME,
  157. X                    SIG9NAME
  158. X                      };
  159. X
  160. Xchar *config_file = CONFIG_FILE;
  161. Xchar *database_file = DATABASE_FILE;
  162. X
  163. Xchar *database_path = DATABASE_PATH;
  164. Xchar *config_path = CONFIG_PATH;
  165. X
  166. Xchar tempdatabase_file[MAXPATHLEN];
  167. X
  168. Xchar *defaultignore = DEFAULTIGNORE;
  169. Xstatic char *defaultignore_parsed;
  170. X
  171. Xchar *db_record_format = DB_RECORD_FORMAT;
  172. X
  173. Xstruct list *filelist = (struct list *) NULL;
  174. X
  175. Xint debuglevel = 1;
  176. Xint verbosity = 0;
  177. Xstatic int dbaseinit = 0;
  178. Xint printhex = 0;
  179. Xstatic char *updateentry = NULL;
  180. Xint quiet = 0;
  181. Xint printpreprocess = 0;
  182. Xchar *specified_dbasefile = NULL;
  183. Xchar *specified_configfile = NULL;
  184. Xint runtimeignore = 0;
  185. X
  186. Xchar *progname;
  187. X
  188. Xstatic void
  189. Xusage()
  190. X{
  191. X    fputs("usage: tripwire [ options ... ]\n", stderr);
  192. X    fputs("\tWhere `options' are:\n", stderr);
  193. X    fputs("\t\t-initialize    Database Generation mode\n", stderr);
  194. X    fputs("\t\t-init        \n", stderr);
  195. X    fputs("\t\t-update entry    update entry (a file, directory, or \n", stderr);
  196. X    fputs("\t\t            tw.config entry) in the database\n", stderr);
  197. X    fputs("\t\t-d dbasefile    read in database from dbasefile\n", stderr);
  198. X    fputs("\t\t            (use `-d -' to read from stdin)\n", stderr);
  199. X    fputs("\t\t-c configfile    read in config file from configfile\n", stderr);
  200. X    fputs("\t\t            (use `-c -' to read from stdin)\n", stderr);
  201. X    fputs("\t\t-Dvar=value    define a tw.config variable (ala @@define)\n",
  202. X    stderr);
  203. X    fputs("\t\t-Uvar        undefine a tw.config variable (ala @@undef)\n",
  204. X    stderr);
  205. X    fputs("\t\t-i #|all     ignore the specified signature (to reduce\n", stderr);
  206. X    fputs("\t\t            execution time)\n", stderr);
  207. X    fputs("\t\t-q        quiet mode\n", stderr);
  208. X    fputs("\t\t-v        verbose mode\n", stderr);
  209. X    fputs("\t\t-preprocess    print out preprocessed configuration file\n",
  210. X    stderr);
  211. X    fputs("\t\t-E        \n", stderr);
  212. X    fputs("\t\t-version    print version and patch information\n", stderr);
  213. X    exit(1);
  214. X}
  215. X
  216. X/*
  217. X * void
  218. X * version()
  219. X *
  220. X *    print out version information, with patchlevel information.
  221. X *    currently, there is no real correlation between the two.
  222. X */
  223. X
  224. Xstatic void
  225. Xversion()
  226. X{
  227. X    fprintf(stderr, "\nTripwire version %s (patchlevel %d)\n\n", version_num,
  228. X                PATCHLEVEL);
  229. X    fprintf(stderr, "Copyright (c) 1992, Purdue Research Foundation\n");
  230. X    fprintf(stderr, "\tBy Gene Kim, Eugene Spafford\n\n");
  231. X    exit(0);
  232. X}
  233. X
  234. Xint
  235. Xmain(argc, argv)
  236. X    int argc;
  237. X    char *argv[];
  238. X{
  239. X    int i;
  240. X    char *pc;
  241. X    char database[MAXPATHLEN];
  242. X    char mask[64];
  243. X    int fd;
  244. X
  245. X    progname = argv[0];
  246. X
  247. X    /* iterate through arguments */
  248. X    for (i = 1; i < argc; i++) {
  249. X    pc = argv[i];
  250. X    /* verbose mode */
  251. X    if (strcmp(pc, "-v") == 0) {
  252. X        verbosity++;
  253. X        continue;
  254. X    }
  255. X    /* quiet mode */
  256. X    if (strcmp(pc, "-q") == 0) {
  257. X        quiet++;
  258. X        continue;
  259. X    }
  260. X    /* hex mode */
  261. X    if (strcmp(pc, "-x") == 0) {
  262. X        printhex++;
  263. X        continue;
  264. X    }
  265. X    /* database generation mode */
  266. X    if (strcmp(pc, "-initialize") == 0 || strcmp(pc, "-init") == 0 ||
  267. X                          strcmp(pc, "-initialise") == 0) {
  268. X        dbaseinit++;
  269. X        continue;
  270. X    }
  271. X    /* print preprocessed configuration file */
  272. X    if ((strcmp(pc, "-preprocess") == 0) || (strcmp(pc, "-E") == 0)) {
  273. X        printpreprocess++;
  274. X        continue;
  275. X    }
  276. X    /* update specific database entry */
  277. X    if (strcmp(pc, "-update") == 0) {
  278. X        /* check to see that there is an argument */
  279. X        if ((pc = argv[++i]) == NULL) {
  280. X        usage();
  281. X        }
  282. X        updateentry = pc;
  283. X        continue;
  284. X    }
  285. X    /* specify database file */
  286. X    if (strcmp(pc, "-d") == 0) {
  287. X        /* check to see that there is an argument */
  288. X        if ((pc = argv[++i]) == NULL) {
  289. X        usage();
  290. X        }
  291. X        specified_dbasefile = pc;
  292. X        continue;
  293. X    }
  294. X    /* specify configuration file */
  295. X    if (strcmp(pc, "-c") == 0) {
  296. X        /* check to see that there is an argument */
  297. X        if ((pc = argv[++i]) == NULL) {
  298. X        usage();
  299. X        }
  300. X        specified_configfile = pc;
  301. X        continue;
  302. X    }
  303. X    /* ignore specified signatures */
  304. X    if (strcmp(pc, "-i") == 0) {
  305. X        int tmpflag;
  306. X
  307. X        /* check to see if there is an argument */
  308. X        if ((pc = argv[++i]) == NULL) {
  309. X        usage();
  310. X        }
  311. X        if (strcmp(pc, "all") == 0) {
  312. X        runtimeignore = IGNORE_0_9;
  313. X        continue;
  314. X        }
  315. X        if ((sscanf(pc, "%d", &tmpflag)) != 1)
  316. X        usage();
  317. X        runtimeignore |= (IGNORE_0 << tmpflag);
  318. X        continue;
  319. X    }
  320. X    /* print out version information */
  321. X    if (strcmp(pc, "-version") == 0) {
  322. X        version();
  323. X    }
  324. X    /* define (-Dfoo=bar) */
  325. X    if (strncmp(pc, "-D", 2) == 0) {
  326. X        char key[512], value[512];
  327. X
  328. X        if (!pc[2]) {
  329. X        fputs("tripwire: -D requires an argument!\n", stderr);
  330. X        exit(1);
  331. X        }
  332. X        (void) string_split_ch(pc+2, key, value, '=');
  333. X        tw_mac_define(key, value);
  334. X        continue;
  335. X    }
  336. X    /* undef (-Ufoo) */
  337. X    if (strncmp(pc, "-U", 2) == 0) {
  338. X        if (!pc[2]) {
  339. X        fputs("tripwire: -U requires an argument!\n", stderr);
  340. X        exit(1);
  341. X        }
  342. X        tw_mac_undef(pc+2);
  343. X        continue;
  344. X    }
  345. X    usage();
  346. X    }
  347. X
  348. X    /* argument sanity checking */
  349. X    /*        are two files set to read from stdin? */
  350. X    if (specified_configfile != NULL && specified_dbasefile) {
  351. X    if (strcmp(specified_configfile, "-") == 0 &&
  352. X        strcmp(specified_dbasefile, "-") == 0) {
  353. X        fprintf(stderr, "%s: specified database and configuration file can't be both be stdin!\n", progname);
  354. X        exit(1);
  355. X    }
  356. X    }
  357. X
  358. X    /* initialize lists */
  359. X    list_init();
  360. X
  361. X    /* build hostname specific names */
  362. X    filename_hostname_expand(&config_path);
  363. X    filename_hostname_expand(&config_file);
  364. X    filename_hostname_expand(&database_path);
  365. X    filename_hostname_expand(&database_file);
  366. X
  367. X    /* recompute the default ignore string (old -> new format) */
  368. X    (void) strcpy(mask, defaultignore);
  369. X    ignore_configvec_to_dvec(mask);
  370. X    defaultignore_parsed = mask;
  371. X
  372. X    /* are we in database generation mode? */
  373. X    if (dbaseinit) {
  374. X    char *oldpath = database_path;
  375. X    char *newpath = database_path = "./databases";
  376. X    struct list *dbase_entry_list = (struct list *) NULL;
  377. X
  378. X    /* place database in ./databases */
  379. X    database_path = newpath;
  380. X
  381. X    if (mkdir(newpath, 0777) >= 0) {
  382. X        fprintf(stderr, "### Warning:\tcreating %s directory!\n",
  383. X                newpath);
  384. X        fprintf(stderr, "###\n");
  385. X    }
  386. X
  387. X    /* generate the database */
  388. X    configfile_read(&filelist, &dbase_entry_list);
  389. X    database_build(&filelist, DBASE_PERMANENT, &dbase_entry_list);
  390. X    fprintf(stderr, "###\n");
  391. X    fprintf(stderr,
  392. X"### Warning:   Database file placed in %s/%s.\n", database_path,
  393. X                            database_file);
  394. X    fprintf(stderr, "###\n");
  395. X    fprintf(stderr,
  396. X"###            Make sure to move this file file and the configuration\n");
  397. X    fprintf(stderr,
  398. X"###            to secure media!\n");
  399. X    fprintf(stderr, "###\n");
  400. X    fprintf(stderr,
  401. X"###            (Tripwire expects to find it in '%s'.)\n", oldpath);
  402. X    exit(0);
  403. X    }
  404. X
  405. X    /*
  406. X     *     make sure that database file is there!
  407. X     *         (this is meaningless if we specified stdin "-")
  408. X     */
  409. X
  410. X    if (specified_dbasefile == NULL)
  411. X    sprintf(database, "%s/%s", database_path, database_file);
  412. X    else
  413. X    (void) strcpy(database, specified_dbasefile);
  414. X
  415. X    if (strcmp(database, "-") != 0) {
  416. X    if ((fd = open(database, O_RDONLY)) < 0) {
  417. X        fprintf(stderr,
  418. X            "%s: database file '%s/%s' does not exist!  Aborting...\n",
  419. X            progname, database_path, database_file);
  420. X        exit(1);
  421. X    }
  422. X    (void) close(fd);
  423. X    }
  424. X
  425. X    /* are we in database update mode? */
  426. X    if (updateentry) {
  427. X    preen_update(updateentry);
  428. X    exit(0);
  429. X    }
  430. X
  431. X    /* we're in integrity checking mode */
  432. X    preen_gather();
  433. X    exit(0);
  434. X    /*NOTREACHED*/
  435. X}
  436. END_OF_FILE
  437. if test 10112 -ne `wc -c <'tripwire-1.0/src/main.c'`; then
  438.     echo shar: \"'tripwire-1.0/src/main.c'\" unpacked with wrong size!
  439. fi
  440. # end of 'tripwire-1.0/src/main.c'
  441. fi
  442. if test -f 'tripwire-1.0/src/dbase.build.c' -a "${1}" != "-c" ; then 
  443.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/dbase.build.c'\"
  444. else
  445. echo shar: Extracting \"'tripwire-1.0/src/dbase.build.c'\" \(10027 characters\)
  446. sed "s/^X//" >'tripwire-1.0/src/dbase.build.c' <<'END_OF_FILE'
  447. X#ifndef lint
  448. Xstatic char rcsid[] = "$Id: dbase.build.c,v 1.3 92/11/03 02:43:40 genek Exp $";
  449. X#endif
  450. X
  451. X/*
  452. X * dbase.build.c
  453. X *
  454. X *    build the preen.database file with the list of files that
  455. X *    was generated by config.parse.c
  456. X *
  457. X * Gene Kim
  458. X * Purdue University
  459. X * September 27, 1992
  460. X */
  461. X
  462. X#include "../include/config.h"
  463. X#include <stdio.h>
  464. X#ifdef STDLIBH
  465. X#include <stdlib.h>
  466. X#include <unistd.h>
  467. X#endif
  468. X#include <fcntl.h>
  469. X#include <sys/param.h>
  470. X#include <sys/types.h>
  471. X#include <sys/stat.h>
  472. X#ifndef XENIX
  473. X# include <sys/time.h>
  474. X#else
  475. X# include <time.h>
  476. X#endif     /* XENIX */
  477. X#ifdef DIRENT
  478. X# include <dirent.h>
  479. X#else
  480. X# ifndef XENIX
  481. X#  include <sys/dir.h>
  482. X# else        /* XENIX */
  483. X#  include <sys/ndir.h>
  484. X# endif        /* XENIX */
  485. X#endif    /* DIRENT */
  486. X#if (defined(SYSV) && (SYSV < 3))
  487. X# include <limits.h>
  488. X#endif    /* SVR2 */
  489. X#ifdef STRINGH
  490. X#include <string.h>
  491. X#else
  492. X#include <strings.h>
  493. X#endif
  494. X#include "../include/list.h"
  495. X#include "../include/tripwire.h"
  496. X
  497. X#if defined(SYSV) && (SYSV < 4)
  498. X#ifndef HAVE_LSTAT
  499. X#  define lstat(x,y) stat(x,y)
  500. X#endif
  501. X#endif        /* SYSV */
  502. X
  503. Xint files_scanned_num = 0;
  504. X
  505. X/* prototypes */
  506. Xchar *mktemp();
  507. Xstatic void database_record_write();
  508. X
  509. X#ifndef L_tmpnam
  510. X# define L_tmpnam (unsigned int) MAXPATHLEN
  511. X#endif
  512. X
  513. Xchar backupfile[MAXPATHLEN];
  514. X
  515. X/*
  516. X * database_build(struct list **pp_list, int tempdatabaseflag)
  517. X *
  518. X *    take the list of file elements from the list and store all of
  519. X *    the pertinent inode and signature information in the database
  520. X *    file.
  521. X *
  522. X *    if (tempdatabaseflag) is set, then we write to a private file
  523. X *    in the /tmp directory.
  524. X */
  525. X
  526. Xvoid
  527. Xdatabase_build (pp_list, mode, pp_entry_list)
  528. X    struct list **pp_list;
  529. X    int mode;
  530. X    struct list **pp_entry_list;
  531. X{
  532. X    struct list_elem *p_fileentry;
  533. X    struct list_elem *p_configentry;
  534. X    FILE *fpw;
  535. X    char database[MAXPATHLEN];
  536. X    int entrynum,
  537. X        oldumask;
  538. X    extern int  errno;
  539. X
  540. X
  541. X#ifndef XENIX
  542. X    struct timezone tzone;
  543. X    struct timeval tval;
  544. X#else
  545. X    long tval;
  546. X#endif    /* XENIX */
  547. X
  548. X    fprintf(stderr, "### Phase 3:   %s file information database\n",
  549. X        mode == DBASE_UPDATE ? "Updating" : "Creating");
  550. X
  551. X
  552. X    /* create the database file
  553. X     *         if we are making the permanent database, then we write
  554. X     *        to the specified file.
  555. X     *
  556. X     *        else, we create a temporary file, and save the name of it.
  557. X     */
  558. X
  559. X    /* XXX - we should use open() so we can set the modes */
  560. X
  561. X    oldumask = umask(077);
  562. X
  563. X    if (mode == DBASE_TEMPORARY) {
  564. X    char *tmpfilename = (char *) malloc(L_tmpnam);
  565. X    (void) strcpy(tmpfilename, TEMPFILE_TEMPLATE);
  566. X
  567. X    if ((char *) mktemp(tmpfilename) == NULL)
  568. X        die_with_err("database_build: mktemp()", (char *) NULL);
  569. X
  570. X    (void) strcpy(tempdatabase_file, tmpfilename);
  571. X    (void) strcpy(database, tempdatabase_file);
  572. X    }                    /* end if temporary database */
  573. X    else {            
  574. X    sprintf(database, "%s/%s", database_path, database_file);
  575. X    }                    /* end if non-temporary database */
  576. X
  577. X    /* back up any existing database */
  578. X    if (mode == DBASE_UPDATE) {
  579. X    FILE *fpin, *fpout;
  580. X    char backup[MAXPATHLEN];
  581. X        register int ctemp;
  582. X
  583. X    sprintf(backup, "%s.old", database_file);
  584. X
  585. X    /* make sure we stay underneath maximum file length */
  586. X
  587. X    if ((int)(strlen(database_file) + 4) > MAXNAMLEN) {
  588. X
  589. X        /* tack on .old as well as it fits */
  590. X        (void) strcpy(backup + (MAXNAMLEN - 4), ".old");
  591. X    }
  592. X    /* so we can reference it later */
  593. X    (void) strcpy(backupfile, backup);  /* strlen(./Databases/) == 12 */
  594. X
  595. X    if ((fpin = fopen(database, "r")) == NULL)
  596. X        die_with_err("database_build: Couldn't open database `%s'!\n", database);
  597. X
  598. X    else if ((fpout = fopen(backup, "w")) == NULL)
  599. X        die_with_err("Couldn't open '%s'!\n", backup);
  600. X
  601. X    /* make the backup file */
  602. X    while ((ctemp = getc(fpin)) != EOF)
  603. X        putc((char) ctemp, fpout);
  604. X
  605. X    (void) fclose(fpin);
  606. X    (void) fclose(fpout);
  607. X    }
  608. X
  609. X    /* rebuild the database */
  610. X    if ((fpw = fopen(database, "w")) == NULL)
  611. X    die_with_err("Hint: Maybe the database directory '%s' doesn't exist?\n",
  612. X                    database);
  613. X
  614. X    (void) umask(oldumask);
  615. X
  616. X
  617. X    /* get time information for banner */
  618. X
  619. X#ifndef XENIX
  620. X    if (gettimeofday(&tval, &tzone) < 0)
  621. X        die_with_err("gettimeofday()", (char *) NULL);
  622. X#else
  623. X    tval = time((long *) 0);
  624. X#endif    /* XENIX */
  625. X
  626. X
  627. X    /* add a banner to the top of the database file */
  628. X    /*        note that the newline comes from date  */
  629. X    fprintf(fpw, "# Generated by Tripwire, version %s on %s",
  630. X                version_num, ctime((time_t *)&tval));
  631. X    fprintf(fpw, "@@dbaseversion %d\n", db_version_num);
  632. X
  633. X    /* we use &filelist as the key */
  634. X    if (list_open(pp_list) < 0)
  635. X    die_with_err("database_build: list_open() failed!\n", (char *) NULL);
  636. X
  637. X    while ((p_fileentry = list_get(pp_list)) != NULL) {
  638. X
  639. X    struct stat statbuf;
  640. X    char *filename, ignorevec[512];
  641. X
  642. X    /* if we're in a debugging mood, print out the entries */
  643. X
  644. XSPDEBUG(10)
  645. Xprintf("--(%3d)--> %s\n", files_scanned_num, p_fileentry->varname);
  646. X
  647. X    /*
  648. X     * if we're in UPDATE mode, we simply copy entries unless
  649. X     * FLAG_UPDATE is set.
  650. X     */
  651. X
  652. X    if (mode == DBASE_UPDATE) {
  653. X        char s[MAXPATHLEN*2];
  654. X
  655. X        if (! (list_getflag(p_fileentry->varname, pp_list) & FLAG_UPDATE)) {
  656. X        sprintf(s, "%s %s", p_fileentry->varname,
  657. X                        p_fileentry->varvalue);
  658. X        fputs(s, fpw);
  659. X        continue;
  660. X        }
  661. X    }
  662. X
  663. X    /* get the stat information on it */
  664. X    filename = p_fileentry->varname;
  665. X    if (sscanf(p_fileentry->varvalue, "%d %s", &entrynum, ignorevec) != 2)
  666. X           die_with_err("database_build: sscanf() parsing error!\n",
  667. X                        (char *) NULL);
  668. X
  669. X    if (lstat(filename, &statbuf) < 0) {
  670. X        if (errno == ENOENT) {
  671. X        fprintf(stderr,
  672. X            "%s: %s: disappeared.  Skipping...\n", progname, filename);
  673. X        continue;
  674. X        }
  675. X        else
  676. X          die_with_err("database_build: lstat()", filename);
  677. X    }
  678. X
  679. X    /* pick up NO_OPEN flag if we're in UPDATE mode
  680. X     *
  681. X     * if it is a special file or device, add it to the list, but
  682. X     * make sure we don't open it and read from it!
  683. X     */
  684. X    if (mode == DBASE_UPDATE)
  685. X        switch (statbuf.st_mode & S_IFMT) {
  686. X          case S_IFIFO:
  687. X          case S_IFCHR:
  688. X          case S_IFDIR:
  689. X          case S_IFBLK:
  690. X#if !defined(SYSV) || (SYSV > 3)
  691. X          case S_IFSOCK:
  692. X#endif
  693. X        (void) list_setflag(filename, FLAG_NOOPEN, pp_list);
  694. X        }
  695. X
  696. X    database_record_write(fpw, filename, p_fileentry->flag, ignorevec,
  697. X                    &statbuf, entrynum);
  698. X
  699. X    files_scanned_num++;
  700. X    }                    /* end while list_read() */
  701. X
  702. X    /* cleanup */
  703. X    if (list_close(pp_list) < 0)
  704. X      die_with_err("database_build: list_close() failed!\n", (char *) NULL);
  705. X
  706. X    /* print out table of contents in permanent database */
  707. X    if (mode != DBASE_TEMPORARY) {
  708. X    /* we use &pp_entry_list as the key */
  709. X    if (list_open(pp_entry_list) < 0)
  710. X      die_with_err("database_build: list_open() failed!\n", (char *) NULL);
  711. X
  712. X    /* print out the contents */
  713. X    while ((p_configentry = list_get(pp_entry_list)) != NULL)
  714. X        fprintf(fpw, "@@contents %s %s\n", p_configentry->varname,
  715. X                p_configentry->varvalue);
  716. X
  717. X    /* close the list */
  718. X    if (list_close(pp_entry_list) < 0)
  719. X      die_with_err("database_build: list_close() failed!\n", (char *) NULL);
  720. X    }
  721. X
  722. X    (void) fclose(fpw);
  723. X
  724. X    return;
  725. X}
  726. X
  727. X/*
  728. X * database_record_write(FILE *fpw, char *filename, int flags,
  729. X *                              char *ignorevec, struct stat *statbuf,
  730. X *                int entrynum)
  731. X *
  732. X *     write out the pertinent information of the specifed file to the
  733. X *    database.
  734. X *
  735. X *     gather the signatures, and include that in the info going to
  736. X *        to the database.
  737. X *
  738. X *    (entrynum) is the unique entry number tag from tw.config.
  739. X */
  740. X
  741. Xstatic void
  742. Xdatabase_record_write (fpw, filename, flags, ignorevec, statbuf, entrynum)
  743. X    FILE *fpw;
  744. X    char *filename;
  745. X    int flags;
  746. X    char *ignorevec;
  747. X    struct stat *statbuf;
  748. X    int entrynum;
  749. X{
  750. X    char     sigs[NUM_SIGS][SIG_MAX_LEN];
  751. X    int        fd, i;
  752. X    int        ignoremask;
  753. X    char    vec64_a[50];
  754. X    char    vec64_c[50];
  755. X    char    vec64_m[50];
  756. X    char    sigs_concat[1024];
  757. X    /* filename, entrynum, ignore, mode, inode, nlinks, uid, gid, size,
  758. X     *        access, modify, ctime, {sig0, sig1, ..., sig9}
  759. X     */
  760. X    static char *format = "%s %ld %s %lo %ld %ld %ld %ld %ld %s %s %s %s\n";
  761. X
  762. X    if (verbosity) {
  763. X    fprintf(stderr, "scanning: %s\n", filename);
  764. X    }
  765. X
  766. X    /*
  767. X     * check for NOOPEN flag (for special files that shouldn't be
  768. X     *         read from, like devices)
  769. X     *
  770. X     * if it's a symlink, then we collect the stat info on the link
  771. X     *         itself.  remember, we never traverse symlinks!
  772. X     *
  773. X     * so, we make up null signatures.
  774. X     */
  775. X    if ((flags & FLAG_NOOPEN) || (flags & FLAG_SYMLINK)) {
  776. X    for (i = 0; i < NUM_SIGS; i++) {
  777. X        register char *pc = sigs[i];
  778. X        *pc++ = '0';
  779. X        *pc++ = ' ';
  780. X        *pc++ = '\0';
  781. X    }
  782. X
  783. X    goto SKIPPED_SIGS;
  784. X    }
  785. X
  786. X    /* descriptor for signature functions */
  787. X    if ((fd = open(filename, O_RDONLY)) < 0) {
  788. X    /* skip it if we had an error */
  789. X    warn_with_err("Trying to open %s for signature\n", filename);
  790. X    return;
  791. X    }
  792. X
  793. X    /* first find out which signatures we don't need to collect */
  794. X    ignoremask = ignore_vec_to_scalar(ignorevec);
  795. X
  796. X    /* collect signatures */
  797. X    for (i = 0; i < NUM_SIGS; i++) {
  798. X    char *pc = sigs[i];
  799. X
  800. X    /* do we skip this signature? */
  801. X    if ((ignoremask & (IGNORE_0 << i)) || (runtimeignore & (IGNORE_0 << i)))
  802. X        (void) strcpy(pc, "0 ");
  803. X    else {
  804. X        (*pf_signatures[i])(fd, pc, SIG_MAX_LEN);
  805. X        (void) strcat(pc, " ");
  806. X    }
  807. X    }
  808. X
  809. X    /* close up the descriptor, since we're done */
  810. X    (void) close(fd);
  811. X
  812. XSKIPPED_SIGS:
  813. X
  814. X    /* concatenate all the signature */
  815. X    sigs_concat[0] = '\0';
  816. X    for (i = 0; i < NUM_SIGS; i++)
  817. X    strcat(sigs_concat, sigs[i]);
  818. X
  819. X    /* escape any special characters in the filename */
  820. X    filename_escape(filename);
  821. X
  822. X    /* filename, ignore, mode, inode, nlinks, uid, gid, size, access, modify,
  823. X     *         ctime, sig0, sig1, ..., sig9
  824. X     */
  825. X
  826. X
  827. X    fprintf(fpw, format, filename, (long)entrynum, ignorevec,
  828. X    (long)statbuf->st_mode, (long)statbuf->st_ino,
  829. X    (long)statbuf->st_nlink, (long)statbuf->st_uid,
  830. X    (long)statbuf->st_gid, (long)statbuf->st_size,
  831. X    ltob64((unsigned long) statbuf->st_atime, vec64_a),
  832. X    ltob64((unsigned long) statbuf->st_mtime, vec64_m),
  833. X    ltob64((unsigned long) statbuf->st_ctime, vec64_c),
  834. X    sigs_concat);
  835. X
  836. X    return;
  837. X
  838. X}
  839. END_OF_FILE
  840. if test 10027 -ne `wc -c <'tripwire-1.0/src/dbase.build.c'`; then
  841.     echo shar: \"'tripwire-1.0/src/dbase.build.c'\" unpacked with wrong size!
  842. fi
  843. # end of 'tripwire-1.0/src/dbase.build.c'
  844. fi
  845. if test -f 'tripwire-1.0/src/config.pre.y' -a "${1}" != "-c" ; then 
  846.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/config.pre.y'\"
  847. else
  848. echo shar: Extracting \"'tripwire-1.0/src/config.pre.y'\" \(9777 characters\)
  849. sed "s/^X//" >'tripwire-1.0/src/config.pre.y' <<'END_OF_FILE'
  850. X%token DIRECTIVE
  851. X%token COMMENT    
  852. X%token EOL
  853. X%token STRING
  854. X%token INCLUDE
  855. X%token DEFINE
  856. X%token UNDEF
  857. X%token IFDEF
  858. X%token IFNDEF
  859. X%token IFHOST
  860. X%token IFNHOST
  861. X%token ELSE
  862. X%token ENDIF
  863. X%token CONTENTS
  864. X%token DBASEVERSION
  865. X%token LPAREN
  866. X%token RPAREN
  867. X%token ANDAND
  868. X%token OROR
  869. X%token ECHOTHIS
  870. X%token BSLASH
  871. X%token ESCCHAR
  872. X
  873. X%{
  874. X/* $Id: config.pre.y,v 1.2 92/11/03 04:49:41 genek Exp $ */
  875. X
  876. X/*
  877. X * config.y
  878. X *
  879. X *    tw.config preprocessor parser for yacc.
  880. X *
  881. X *    This implementation does an unfortunately large number of 
  882. X *    malloc()'s and free()'s to store the lexeme values.  Although
  883. X *    memory leaks are few, too much time is spent doing memory
  884. X *    allocation.
  885. X *
  886. X *    At this point, I would argue that this is not too significant,
  887. X *    since we only run this routine once.
  888. X *
  889. X * Gene Kim
  890. X * Purdue University
  891. X * October 5, 1992
  892. X */
  893. X
  894. X#include "../include/config.h"
  895. X#include <stdio.h>
  896. X#ifdef STRINGH
  897. X#include <string.h>
  898. X#else
  899. X#include <strings.h>
  900. X#endif
  901. X#include <assert.h>
  902. X#include <sys/types.h>
  903. X#include <sys/stat.h>
  904. X#include "../include/list.h"
  905. X#include "../include/tripwire.h"
  906. X
  907. X#define INCLUDE_STACK_SZ     16    /* max num of nested includes */
  908. X
  909. Xint yaccdebuglevel = 0;
  910. X
  911. Xstatic int linenumber = 0;
  912. X
  913. Xstatic FILE *fp_stack[INCLUDE_STACK_SZ];
  914. Xstatic int linenumber_stack[INCLUDE_STACK_SZ];
  915. Xstatic char *filename_stack[INCLUDE_STACK_SZ];
  916. Xstatic int stackpointer = 0;
  917. Xstatic int found_db_version = 0;
  918. Xstatic struct list **pp_entry_list_global = NULL;
  919. X
  920. Xstatic char *currparsefile = NULL;
  921. X
  922. X/* prototypes */
  923. Xstatic char *string_dequote();
  924. Xstatic void include_push();
  925. Xstatic FILE *include_pop();
  926. X
  927. X%}
  928. X
  929. X%union {
  930. X    char     *string;
  931. X    int     val;
  932. X}
  933. X
  934. X%left <string> COMMENT STRING ESCCHAR 
  935. X%token <val> IFDEF IFNDEF IFHOST IFNHOST
  936. X%type <string> word words directive colines coline else 
  937. X%type <val> if_expr host_expr
  938. X%left <val> ANDAND OROR
  939. X
  940. X%start lines
  941. X%%
  942. X
  943. Xlines    : lines line 
  944. X    | 
  945. X    ;
  946. X
  947. X/* we do all of the line-emitting in this production (line) */
  948. X
  949. Xline    : directive EOL
  950. X        {
  951. X        /*
  952. X        linenumber++;
  953. X        */
  954. X
  955. X        if ($1)    { 
  956. X            fprintf(yyout, "%s\n", $1); 
  957. X            free($1);
  958. X        }
  959. X        }
  960. X    | words EOL
  961. X        {
  962. X        /*
  963. X        linenumber++; 
  964. X        */
  965. X
  966. X        if ($1)    { 
  967. X            fprintf(yyout, "%s\n", $1); 
  968. X            free($1);
  969. X        }
  970. X        }
  971. X    ;
  972. X
  973. X
  974. Xcolines    : colines coline 
  975. X        {
  976. X        /* concatenate the two terminals together */
  977. X        if ($1 == NULL) {
  978. X            $$ = (char *) malloc((unsigned) strlen($2) + 1);
  979. X            $$[0] = '\0';
  980. X        }
  981. X        else {
  982. X            $$ = (char *) malloc((unsigned) 
  983. X                    (strlen($1) + strlen($2)) + 2);
  984. X            (void) strcpy($$, $1);
  985. X            (void) strcat($$, "\n");
  986. X
  987. X            /* free up the left component */
  988. X            free($1);
  989. X        }
  990. X        (void) strcat($$, $2);
  991. X
  992. X        /* free up the right component */
  993. X        if ($2)
  994. X            free($2);
  995. X        }
  996. X    | 
  997. X        {
  998. X        $$ = NULL;
  999. X        }
  1000. X    ;
  1001. X
  1002. Xcoline    : directive EOL         { $$ = $1; /* linenumber++; */}
  1003. X    | words EOL             { $$ = $1; /* linenumber++; */}
  1004. X    ;
  1005. X
  1006. Xelse    : ELSE colines 
  1007. X        {
  1008. X        $$ = $2;
  1009. X        }
  1010. X    | 
  1011. X        {
  1012. X        $$ = NULL;
  1013. X        }
  1014. X    ;
  1015. X
  1016. Xif_expr    : LPAREN if_expr RPAREN
  1017. X        { 
  1018. X        $$ = $2;
  1019. X        }
  1020. X    | if_expr ANDAND if_expr
  1021. X        {
  1022. X        $$ = $1 && $3;
  1023. X        }
  1024. X    | if_expr OROR if_expr
  1025. X        {
  1026. X        $$ = $1 || $3;
  1027. X        }
  1028. X    | word
  1029. X        {
  1030. X        $$ = tw_mac_ifdef($1);
  1031. X        }
  1032. X
  1033. Xhost_expr: LPAREN host_expr RPAREN
  1034. X        { 
  1035. X        $$ = $2;
  1036. X        }
  1037. X    | host_expr ANDAND host_expr
  1038. X        {
  1039. X        $$ = $1 && $3;
  1040. X        }
  1041. X    | host_expr OROR host_expr
  1042. X        {
  1043. X        $$ = $1 || $3;
  1044. X        }
  1045. X    | word
  1046. X        {
  1047. X        $$ = tw_mac_ifhost($1);
  1048. X        }
  1049. X
  1050. Xdirective:    
  1051. X      DEFINE word             { tw_mac_define($2, ""); $$ = NULL; }
  1052. X    | DEFINE word word         { tw_mac_define($2, $3); $$ = NULL; }
  1053. X    | UNDEF word             { tw_mac_undef($2); $$ = NULL; }
  1054. X    | IFDEF if_expr
  1055. X        {
  1056. X        $1 = $2;
  1057. X        }
  1058. X          EOL colines else ENDIF
  1059. X        {
  1060. X        if ($1) { $$ = $5; }
  1061. X        else     { $$ = $6; }
  1062. X
  1063. X        /*
  1064. X        linenumber++;
  1065. X        */
  1066. X        }
  1067. X    | IFNDEF if_expr
  1068. X        {
  1069. X        $1 = !$2;
  1070. X        }
  1071. X          EOL colines else ENDIF
  1072. X        {
  1073. X        if ($1) { $$ = $5; }
  1074. X        else     { $$ = $6; }
  1075. X
  1076. X        /*
  1077. X        linenumber++;
  1078. X        */
  1079. X        }
  1080. X    | IFHOST host_expr
  1081. X        {
  1082. X        $1 = $2;
  1083. X        }
  1084. X          EOL colines else ENDIF
  1085. X        {
  1086. X        if ($1) { $$ = $5; }
  1087. X        else     { $$ = $6; }
  1088. X
  1089. X        /*
  1090. X        linenumber++;
  1091. X        */
  1092. X        }
  1093. X    | IFNHOST host_expr
  1094. X        {
  1095. X        $1 = !$2;
  1096. X        }
  1097. X          EOL colines else ENDIF
  1098. X        {
  1099. X        if ($1) { $$ = $5; }
  1100. X        else     { $$ = $6; }
  1101. X
  1102. X        /*
  1103. X        linenumber++;
  1104. X        */
  1105. X        }
  1106. X    | INCLUDE word
  1107. X        {
  1108. X        /* push a new @@include file onto the include stack */
  1109. X        include_push($2, &yyin);
  1110. X        $$ = NULL;
  1111. X
  1112. X        }
  1113. X    | CONTENTS word
  1114. X        {
  1115. X        char *pc = "@@contents ";
  1116. X
  1117. X        /* record contents in list */
  1118. X        list_set($2, "", 0, pp_entry_list_global);
  1119. X
  1120. X        /* reconstruct and emit the entire string */
  1121. X        $$ = (char *) malloc((unsigned) (strlen($2) + strlen(pc)) + 1);
  1122. X        (void) strcpy($$, pc);
  1123. X        (void) strcat($$, $2);
  1124. X
  1125. X        /* free up the right side */
  1126. X        free($2);
  1127. X        }
  1128. X    | ECHOTHIS words
  1129. X        {
  1130. X        printf("tw.config: echo: %s\n", $2);
  1131. X        }
  1132. X    | DBASEVERSION word
  1133. X        {
  1134. X        int version;
  1135. X
  1136. X        if (sscanf($2, "%d", &version) != 1) {
  1137. X            yyerror("");
  1138. X        }
  1139. X
  1140. X        /* check if the database format is too old */
  1141. X        if (version != db_version_num) {
  1142. X            fprintf(stderr, 
  1143. X            "tripwire: configuration file '%s' format is too old!\n",
  1144. X            version);
  1145. X            exit(1);
  1146. X        }
  1147. X
  1148. X        /* free up the right side */
  1149. X        free($2);
  1150. X
  1151. X        /* we must see one of these productions in the file */
  1152. X        found_db_version = 1;
  1153. X
  1154. X        $$ = NULL;
  1155. X        }
  1156. X    ;
  1157. X
  1158. Xwords    : words word
  1159. X        {
  1160. X        /* concatenate the two terminals together */
  1161. X        if ($1 == NULL) {
  1162. X            $$ = (char *) malloc((unsigned) strlen($2) + 1);
  1163. X            $$[0] = '\0';
  1164. X        }
  1165. X        else {
  1166. X            $$ = (char *) malloc((unsigned) 
  1167. X                    (strlen($1) + strlen($2)) + 2);
  1168. X            (void) strcpy($$, $1);
  1169. X            (void) strcat($$, " ");
  1170. X
  1171. X            /* free up the left component */
  1172. X            free($1);
  1173. X        }
  1174. X        (void) strcat($$, $2);
  1175. X
  1176. X        /* free up the right component */
  1177. X        if ($2) 
  1178. X            free($2);
  1179. X        }
  1180. X    |
  1181. X        {
  1182. X        $$ = NULL;
  1183. X        }
  1184. X    ;
  1185. X
  1186. Xword    : STRING
  1187. X        {
  1188. X        $$ = strcpy((char *) malloc((unsigned) strlen($1) + 1), $1);
  1189. X        }
  1190. X    | DIRECTIVE STRING
  1191. X        {
  1192. X        char *pc;
  1193. X
  1194. X        /* if not defined */
  1195. X        if (tw_mac_ifdef($2) == 0) {
  1196. X            fprintf(stderr, "warning: uninitialized definition at line %d in '%s'!\n(Hint: maybe a misspelled directive?)\n", linenumber,
  1197. X                        currparsefile);
  1198. X            $$ = NULL;
  1199. X        }
  1200. X        else {
  1201. X            /* else substitute in the input stream */
  1202. X            pc = tw_mac_dereference($2);
  1203. X            assert(pc != NULL);
  1204. X
  1205. X            $$ = (char *) malloc((unsigned) strlen(pc) + 1);
  1206. X            (void) strcpy($$, pc);
  1207. X        }
  1208. X        }
  1209. X    ;
  1210. X
  1211. X    
  1212. X%%
  1213. X
  1214. X#include "lex.yy.c"
  1215. X
  1216. X/*ARGSUSED*/
  1217. Xyyerror(s)
  1218. X    char *s;
  1219. X{
  1220. X     fprintf(stderr, 
  1221. X    "syntax error at line %d in configuration file '%s'!  Aborting...\n", 
  1222. X        ++linenumber, currparsefile);
  1223. X}
  1224. X
  1225. X/*
  1226. X * void
  1227. X * tw_macro_parse(char *filename, FILE *fpin, FILE *fpout, 
  1228. X *                        struct list **pp_entry_list)
  1229. X *
  1230. X *    wrapper around yyparse(), initiailzing input and output data.
  1231. X */
  1232. X
  1233. Xvoid
  1234. Xtw_macro_parse(filename, fpin, fpout, pp_entry_list)
  1235. X    char *filename;
  1236. X    FILE *fpin, *fpout;
  1237. X    struct list **pp_entry_list;
  1238. X{
  1239. X    /* set up input and output pointers */
  1240. X    yyin = fpin;
  1241. X    yyout = fpout;
  1242. X
  1243. X    /* set up initial filename */
  1244. X    currparsefile = filename;
  1245. X
  1246. X    pp_entry_list_global = pp_entry_list;
  1247. X
  1248. X    (void) yyparse();
  1249. X}
  1250. X
  1251. X/* counters odd behaviour of flex -- Simon Leinen */
  1252. X#ifdef yywrap
  1253. X# undef yyrap
  1254. X#endif
  1255. X
  1256. Xyywrap()
  1257. X{
  1258. X    /* check to see if we've reached the bottom of the @@include stack */
  1259. X    if (include_pop()) {
  1260. X    linenumber++;
  1261. X    return 0;
  1262. X    }
  1263. X
  1264. X    /* check to see if we've seen a @@dbversion line */
  1265. X#ifdef FOO
  1266. X    if (!found_db_version) {
  1267. X    fprintf(stderr, "tripwire: database file doesn't contain version number!  (old database?)\n");
  1268. X    exit(1);
  1269. X    }
  1270. X#endif
  1271. X
  1272. X    /* close up parser */
  1273. X    return 1;
  1274. X}
  1275. X
  1276. X/*
  1277. X * static char *
  1278. X * string_dequote(char *s)
  1279. X *
  1280. X *    remove pairs of quoted strings.
  1281. X */
  1282. X
  1283. Xstatic char *
  1284. Xstring_dequote(s)
  1285. X    char *s;
  1286. X{
  1287. X    char temp[1024];
  1288. X
  1289. X    /* do we need to do anything? */
  1290. X    if (s[0] != '"')         { return s; }
  1291. X
  1292. X    (void) strncpy(temp, s+1, strlen(s) - 2);
  1293. X    (void) strcpy(s, temp);
  1294. X
  1295. X    return s;
  1296. X
  1297. X}
  1298. X
  1299. X/* 
  1300. X * void
  1301. X * include_push(char *filename, FILE **p_fp_old)
  1302. X *
  1303. X *    return a stdio (FILE *) pointer to the opened (filename), saving 
  1304. X *    the old (FILE *) pointer and line number on the stack.
  1305. X *
  1306. X *    returns (NULL) when we pop back to the original file.
  1307. X */
  1308. X
  1309. Xstatic void
  1310. Xinclude_push(filename, p_fp_old)
  1311. X    char *filename;
  1312. X    FILE **p_fp_old;
  1313. X{
  1314. X    static FILE *fp;
  1315. X    char *pc;
  1316. X    extern int  errno;
  1317. X
  1318. X    /* check for stack overflow */
  1319. X    if (stackpointer == INCLUDE_STACK_SZ) {
  1320. X    fprintf(stderr, "Too many nested includes at line %d in file '%s'!\n", 
  1321. X                linenumber, currparsefile);
  1322. X    exit(1);
  1323. X    }
  1324. X
  1325. X    /* dequote the include filename */
  1326. X    string_dequote(filename);
  1327. X
  1328. X    /* save the old file pointer, filename, and linenumber on the stack */
  1329. X    fp_stack[stackpointer] = *p_fp_old;
  1330. X
  1331. X    (void) strcpy((pc = (char *) malloc((unsigned) strlen(currparsefile) + 1)), 
  1332. X                    currparsefile);
  1333. X    filename_stack[stackpointer] = pc;
  1334. X
  1335. X    linenumber_stack[stackpointer++] = linenumber;
  1336. X
  1337. X    /* try opening the file */
  1338. X    if ((fp = fopen(filename, "r")) == NULL) {
  1339. X    if (errno == ENOENT) {
  1340. X        fprintf(stderr, "tw.config: @@include '%s' file not found in '%s'!\n",
  1341. X                filename, currparsefile);
  1342. X        exit(1);
  1343. X    }
  1344. X    else {
  1345. X        char msg[100];
  1346. X        sprintf(msg, "%s: fopen()", filename);
  1347. X        perror(msg);
  1348. X        exit(1);
  1349. X    }
  1350. X    }
  1351. X
  1352. X    /* replace old pointer with new */
  1353. X    *p_fp_old = fp;
  1354. X
  1355. X    /* reset line number and filename */
  1356. X    linenumber = 0;
  1357. X    currparsefile = pc;
  1358. X}
  1359. X
  1360. X/*
  1361. X * FILE *
  1362. X * include_pop()
  1363. X *
  1364. X *    pop the last file structure off the @@include stack.
  1365. X *
  1366. X *    returns NULL when we've exhausted the stack.
  1367. X */
  1368. X
  1369. Xstatic FILE *
  1370. Xinclude_pop()
  1371. X{
  1372. X    /* check for stack underflow */
  1373. X    if (stackpointer-- == 0)
  1374. X    return NULL;
  1375. X
  1376. X    /* pop off the line numbers and the stdio file pointer */
  1377. X    yyin = fp_stack[stackpointer];
  1378. X    linenumber = linenumber_stack[stackpointer];
  1379. X    currparsefile = filename_stack[stackpointer];
  1380. X    free(filename_stack[stackpointer]);
  1381. X
  1382. X    return yyin;
  1383. X}
  1384. X
  1385. END_OF_FILE
  1386. if test 9777 -ne `wc -c <'tripwire-1.0/src/config.pre.y'`; then
  1387.     echo shar: \"'tripwire-1.0/src/config.pre.y'\" unpacked with wrong size!
  1388. fi
  1389. # end of 'tripwire-1.0/src/config.pre.y'
  1390. fi
  1391. if test -f 'tripwire-1.0/sigs/md4/md4.c' -a "${1}" != "-c" ; then 
  1392.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/md4/md4.c'\"
  1393. else
  1394. echo shar: Extracting \"'tripwire-1.0/sigs/md4/md4.c'\" \(9435 characters\)
  1395. sed "s/^X//" >'tripwire-1.0/sigs/md4/md4.c' <<'END_OF_FILE'
  1396. X#ifndef lint
  1397. Xstatic char rcsid[] = "$Id: md4.c,v 1.1.1.2 92/11/02 18:21:41 genek Exp $";
  1398. X#endif
  1399. X
  1400. X/* 
  1401. X** **************************************************************************
  1402. X** md4.c -- Implementation of MD4 Message Digest Algorithm                 **
  1403. X** Updated: 2/16/90 by Ronald L. Rivest                                    **
  1404. X** (C) 1990 RSA Data Security, Inc.                                        **
  1405. X** **************************************************************************
  1406. X*/
  1407. X
  1408. X/* 
  1409. X** To use MD4:
  1410. X**   -- Include md4.h in your program
  1411. X**   -- Declare an MDstruct MD to hold the state of the digest computation.
  1412. X**   -- Initialize MD using MDbegin(&MD)
  1413. X**   -- For each full block (64 bytes) X you wish to process, call
  1414. X**          MDupdate(&MD,X,512)
  1415. X**      (512 is the number of bits in a full block.)
  1416. X**   -- For the last block (less than 64 bytes) you wish to process,
  1417. X**          MDupdate(&MD,X,n)
  1418. X**      where n is the number of bits in the partial block. A partial
  1419. X**      block terminates the computation, so every MD computation should
  1420. X**      terminate by processing a partial block, even if it has n = 0.
  1421. X**   -- The message digest is available in MD.buffer[0] ... MD.buffer[3].
  1422. X**      (Least-significant byte of each word should be output first.)
  1423. X**   -- You can print out the digest using MDprint(&MD)
  1424. X*/
  1425. X
  1426. X/* Implementation notes:
  1427. X** This implementation assumes that ints are 32-bit quantities.
  1428. X** If the machine stores the least-significant byte of an int in the
  1429. X** least-addressed byte (eg., VAX and 8086), then LOWBYTEFIRST should be
  1430. X** set to TRUE.  Otherwise (eg., SUNS), LOWBYTEFIRST should be set to
  1431. X** FALSE.  Note that on machines with LOWBYTEFIRST FALSE the routine
  1432. X** MDupdate modifies has a side-effect on its input array (the order of bytes
  1433. X** in each word are reversed).  If this is undesired a call to MDreverse(X) can
  1434. X** reverse the bytes of X back into order after each call to MDupdate.
  1435. X*/
  1436. X#define TRUE  1
  1437. X#define FALSE 0
  1438. X
  1439. X
  1440. X/* Compile-time includes 
  1441. X*/
  1442. X#include "../../include/config.h"
  1443. X#include <stdio.h>
  1444. X#ifdef STDLIBH
  1445. X#include <stdlib.h>
  1446. X#endif
  1447. X#include "../../include/byteorder.h"
  1448. X#include "md4.h"
  1449. X
  1450. X/* Compile-time declarations of MD4 ``magic constants''.
  1451. X*/
  1452. X#define I0  0x67452301       /* Initial values for MD buffer */
  1453. X#define I1  0xefcdab89
  1454. X#define I2  0x98badcfe
  1455. X#define I3  0x10325476
  1456. X#define C2  013240474631     /* round 2 constant = sqrt(2) in octal */
  1457. X#define C3  015666365641     /* round 3 constant = sqrt(3) in octal */
  1458. X/* C2 and C3 are from Knuth, The Art of Programming, Volume 2
  1459. X** (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
  1460. X** Table 2, page 660.
  1461. X*/
  1462. X#define fs1  3               /* round 1 shift amounts */
  1463. X#define fs2  7   
  1464. X#define fs3 11  
  1465. X#define fs4 19  
  1466. X#define gs1  3               /* round 2 shift amounts */
  1467. X#define gs2  5   
  1468. X#define gs3  9   
  1469. X#define gs4 13  
  1470. X#define hs1  3               /* round 3 shift amounts */
  1471. X#define hs2  9 
  1472. X#define hs3 11 
  1473. X#define hs4 15
  1474. X
  1475. X
  1476. X/* Compile-time macro declarations for MD4.
  1477. X** Note: The ``rot'' operator uses the variable ``tmp''.
  1478. X** It assumes tmp is declared as unsigned int, so that the >>
  1479. X** operator will shift in zeros rather than extending the sign bit.
  1480. X*/
  1481. X#define    f(X,Y,Z)             ((X&Y) | ((~X)&Z))
  1482. X#define    g(X,Y,Z)             ((X&Y) | (X&Z) | (Y&Z))
  1483. X#define h(X,Y,Z)             (X^Y^Z)
  1484. X#define rot(X,S)             (tmp=X,(tmp<<S) | (tmp>>(32-S)))
  1485. X#define ff(A,B,C,D,i,s)      A = rot((A + f(B,C,D) + X[i]),s)
  1486. X#define gg(A,B,C,D,i,s)      A = rot((A + g(B,C,D) + X[i] + C2),s)
  1487. X#define hh(A,B,C,D,i,s)      A = rot((A + h(B,C,D) + X[i] + C3),s)
  1488. X
  1489. X/* MDprint(MDp)
  1490. X** Print message digest buffer MDp as 32 hexadecimal digits.
  1491. X** Order is from low-order byte of buffer[0] to high-order byte of buffer[3].
  1492. X** Each byte is printed with high-order hexadecimal digit first.
  1493. X** This is a user-callable routine.
  1494. X*/
  1495. Xvoid 
  1496. XMDprint(MDp)
  1497. XMDptr MDp;
  1498. X{ int i,j;
  1499. X  for (i=0;i<4;i++)
  1500. X    for (j=0;j<32;j=j+8)
  1501. X      printf("%02x",(MDp->buffer[i]>>j) & 0xFF);
  1502. X}
  1503. X
  1504. X/* MDbegin(MDp)
  1505. X** Initialize message digest buffer MDp. 
  1506. X** This is a user-callable routine.
  1507. X*/
  1508. Xvoid 
  1509. XMDbegin(MDp)
  1510. XMDptr MDp;
  1511. X{ int i;
  1512. X  MDp->buffer[0] = I0;  
  1513. X  MDp->buffer[1] = I1;  
  1514. X  MDp->buffer[2] = I2;  
  1515. X  MDp->buffer[3] = I3; 
  1516. X  for (i=0;i<8;i++) MDp->count[i] = 0;
  1517. X  MDp->done = 0;
  1518. X}
  1519. X
  1520. X/* MDreverse(X)
  1521. X** Reverse the byte-ordering of every int in X.
  1522. X** Assumes X is an array of 16 ints.
  1523. X** The macro revx reverses the byte-ordering of the next word of X.
  1524. X*/
  1525. X#define revx { t = (*X << 16) | (*X >> 16); \
  1526. X           *X++ = ((t & 0xFF00FF00) >> 8) | ((t & 0x00FF00FF) << 8); }
  1527. Xvoid
  1528. XMDreverse(X)
  1529. Xunsigned int *X;
  1530. X{ register unsigned int t;
  1531. X  revx; revx; revx; revx; revx; revx; revx; revx;
  1532. X  revx; revx; revx; revx; revx; revx; revx; revx;
  1533. X}
  1534. X
  1535. X/* MDblock(MDp,X)
  1536. X** Update message digest buffer MDp->buffer using 16-word data block X.
  1537. X** Assumes all 16 words of X are full of data.
  1538. X** Does not update MDp->count.
  1539. X** This routine is not user-callable. 
  1540. X*/
  1541. Xstatic void
  1542. XMDblock(MDp,X)
  1543. XMDptr MDp;
  1544. Xunsigned int *X;
  1545. X{ 
  1546. X  register unsigned int tmp, A, B, C, D;
  1547. X#if BYTEORDER != 0x4321
  1548. X  MDreverse(X);
  1549. X#endif
  1550. X  A = MDp->buffer[0];
  1551. X  B = MDp->buffer[1];
  1552. X  C = MDp->buffer[2];
  1553. X  D = MDp->buffer[3];
  1554. X  /* Update the message digest buffer */
  1555. X  ff(A , B , C , D ,  0 , fs1); /* Round 1 */
  1556. X  ff(D , A , B , C ,  1 , fs2); 
  1557. X  ff(C , D , A , B ,  2 , fs3); 
  1558. X  ff(B , C , D , A ,  3 , fs4); 
  1559. X  ff(A , B , C , D ,  4 , fs1); 
  1560. X  ff(D , A , B , C ,  5 , fs2); 
  1561. X  ff(C , D , A , B ,  6 , fs3); 
  1562. X  ff(B , C , D , A ,  7 , fs4); 
  1563. X  ff(A , B , C , D ,  8 , fs1); 
  1564. X  ff(D , A , B , C ,  9 , fs2); 
  1565. X  ff(C , D , A , B , 10 , fs3); 
  1566. X  ff(B , C , D , A , 11 , fs4); 
  1567. X  ff(A , B , C , D , 12 , fs1); 
  1568. X  ff(D , A , B , C , 13 , fs2); 
  1569. X  ff(C , D , A , B , 14 , fs3); 
  1570. X  ff(B , C , D , A , 15 , fs4); 
  1571. X  gg(A , B , C , D ,  0 , gs1); /* Round 2 */
  1572. X  gg(D , A , B , C ,  4 , gs2); 
  1573. X  gg(C , D , A , B ,  8 , gs3); 
  1574. X  gg(B , C , D , A , 12 , gs4); 
  1575. X  gg(A , B , C , D ,  1 , gs1); 
  1576. X  gg(D , A , B , C ,  5 , gs2); 
  1577. X  gg(C , D , A , B ,  9 , gs3); 
  1578. X  gg(B , C , D , A , 13 , gs4); 
  1579. X  gg(A , B , C , D ,  2 , gs1); 
  1580. X  gg(D , A , B , C ,  6 , gs2); 
  1581. X  gg(C , D , A , B , 10 , gs3); 
  1582. X  gg(B , C , D , A , 14 , gs4); 
  1583. X  gg(A , B , C , D ,  3 , gs1); 
  1584. X  gg(D , A , B , C ,  7 , gs2); 
  1585. X  gg(C , D , A , B , 11 , gs3); 
  1586. X  gg(B , C , D , A , 15 , gs4);  
  1587. X  hh(A , B , C , D ,  0 , hs1); /* Round 3 */
  1588. X  hh(D , A , B , C ,  8 , hs2); 
  1589. X  hh(C , D , A , B ,  4 , hs3); 
  1590. X  hh(B , C , D , A , 12 , hs4); 
  1591. X  hh(A , B , C , D ,  2 , hs1); 
  1592. X  hh(D , A , B , C , 10 , hs2); 
  1593. X  hh(C , D , A , B ,  6 , hs3); 
  1594. X  hh(B , C , D , A , 14 , hs4); 
  1595. X  hh(A , B , C , D ,  1 , hs1); 
  1596. X  hh(D , A , B , C ,  9 , hs2); 
  1597. X  hh(C , D , A , B ,  5 , hs3); 
  1598. X  hh(B , C , D , A , 13 , hs4); 
  1599. X  hh(A , B , C , D ,  3 , hs1); 
  1600. X  hh(D , A , B , C , 11 , hs2); 
  1601. X  hh(C , D , A , B ,  7 , hs3); 
  1602. X  hh(B , C , D , A , 15 , hs4);
  1603. X  MDp->buffer[0] += A; 
  1604. X  MDp->buffer[1] += B;
  1605. X  MDp->buffer[2] += C;
  1606. X  MDp->buffer[3] += D; 
  1607. X}
  1608. X
  1609. X/* MDupdate(MDp,X,count)
  1610. X** Input: MDp -- an MDptr
  1611. X**        X -- a pointer to an array of unsigned characters.
  1612. X**        count -- the number of bits of X to use.
  1613. X**                 (if not a multiple of 8, uses high bits of last byte.)
  1614. X** Update MDp using the number of bits of X given by count.
  1615. X** This is the basic input routine for an MD4 user.
  1616. X** The routine completes the MD computation when count < 512, so
  1617. X** every MD computation should end with one call to MDupdate with a
  1618. X** count less than 512.  A call with count 0 will be ignored if the
  1619. X** MD has already been terminated (done != 0), so an extra call with count
  1620. X** 0 can be given as a ``courtesy close'' to force termination if desired.
  1621. X*/
  1622. Xvoid 
  1623. XMDupdate(MDp,X,count)
  1624. XMDptr MDp;
  1625. Xunsigned char *X;
  1626. Xunsigned int count;
  1627. X{ unsigned int i, tmp, bit, byte, mask;
  1628. X  unsigned char XX[64];
  1629. X  unsigned char *p;
  1630. X  /* return with no error if this is a courtesy close with count
  1631. X  ** zero and MDp->done is true.
  1632. X  */
  1633. X  if (count == 0 && MDp->done) return;
  1634. X  /* check to see if MD is already done and report error */
  1635. X  if (MDp->done) { printf("\nError: MDupdate MD already done."); return; }
  1636. X  /* Add count to MDp->count */
  1637. X  tmp = count;
  1638. X  p = MDp->count;
  1639. X  while (tmp)
  1640. X    { tmp += *p;
  1641. X      *p++ = tmp;
  1642. X      tmp = tmp >> 8;
  1643. X    }
  1644. X  /* Process data */
  1645. X  if (count == 512) 
  1646. X    { /* Full block of data to handle */
  1647. X      MDblock(MDp,(unsigned int *)X);
  1648. X    }
  1649. X  else if (count > 512) /* Check for count too large */
  1650. X    { printf("\nError: MDupdate called with illegal count value %d.",count);
  1651. X      return;
  1652. X    }
  1653. X  else /* partial block -- must be last block so finish up */
  1654. X    { /* Find out how many bytes and residual bits there are */
  1655. X      byte = count >> 3;
  1656. X      bit =  count & 7;
  1657. X      /* Copy X into XX since we need to modify it */
  1658. X      for (i=0;i<=byte;i++)   XX[i] = X[i];
  1659. X      for (i=byte+1;i<64;i++) XX[i] = 0;
  1660. X      /* Add padding '1' bit and low-order zeros in last byte */
  1661. X      mask = 1 << (7 - bit);
  1662. X      XX[byte] = (XX[byte] | mask) & ~( mask - 1);
  1663. X      /* If room for bit count, finish up with this block */
  1664. X      if (byte <= 55)
  1665. X    { for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
  1666. X      MDblock(MDp,(unsigned int *)XX);
  1667. X    }
  1668. X      else /* need to do two blocks to finish up */
  1669. X    { MDblock(MDp,(unsigned int *)XX);
  1670. X      for (i=0;i<56;i++) XX[i] = 0;
  1671. X      for (i=0;i<8;i++)  XX[56+i] = MDp->count[i];
  1672. X      MDblock(MDp,(unsigned int *)XX);
  1673. X    }
  1674. X      /* Set flag saying we're done with MD computation */
  1675. X      MDp->done = 1;
  1676. X    }
  1677. X}
  1678. END_OF_FILE
  1679. if test 9435 -ne `wc -c <'tripwire-1.0/sigs/md4/md4.c'`; then
  1680.     echo shar: \"'tripwire-1.0/sigs/md4/md4.c'\" unpacked with wrong size!
  1681. fi
  1682. # end of 'tripwire-1.0/sigs/md4/md4.c'
  1683. fi
  1684. if test -f 'tripwire-1.0/sigs/snefru/README.snefru' -a "${1}" != "-c" ; then 
  1685.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/snefru/README.snefru'\"
  1686. else
  1687. echo shar: Extracting \"'tripwire-1.0/sigs/snefru/README.snefru'\" \(8502 characters\)
  1688. sed "s/^X//" >'tripwire-1.0/sigs/snefru/README.snefru' <<'END_OF_FILE'
  1689. X# $Id: README.snefru,v 1.1.1.2 92/11/02 18:22:42 genek Exp $ 
  1690. X
  1691. X    The Snefru one-way hash function package is copyrighted by
  1692. XXerox Corporation.  The following disclaimer can be found in the
  1693. XSnefru C code:  (Comments on changes made to accomodate its use
  1694. Xwithin Tripwire follow the disclaimer.)
  1695. X
  1696. X==================
  1697. X
  1698. X/*
  1699. X  This is an implementation of Snefru. Snefru is a one-way hash
  1700. X  function that provides authentication. It does not provide secrecy.
  1701. X  
  1702. X  Snefru is named after a Pharaoh of ancient Egypt.
  1703. X  
  1704. X  Copyright (c) Xerox Corporation 1989. All rights reserved.
  1705. X  
  1706. X  License to copy and use this software is granted provided that it is
  1707. X  identified as the "Xerox Secure Hash Function" in all material mentioning
  1708. X  or referencing this software or this hash function.
  1709. X  
  1710. X  License is also granted to make and use derivative works provided that such
  1711. X  works are identified as "derived from the Xerox Secure Hash Function" in
  1712. X  all material mentioning or referencing the derived work.
  1713. X  
  1714. X  Xerox Corporation makes no representations concerning either the
  1715. X  merchantability of this software or the suitability of this software for
  1716. X  any particular purpose.  It is provided "as is" without express or implied
  1717. X  warranty of any kind.
  1718. X  
  1719. X  These notices must be retained in any copies of any part of this software.
  1720. X  
  1721. X  Updated information about Snefru is available from arisia.xerox.com in
  1722. X  directory /pub/hash by anonymous FTP.  The README file provides a quick
  1723. X  introduction.
  1724. X
  1725. X  This is version 2.5a, November 29, 1990.
  1726. X  Version 2.5a provides a reasonably understandable and efficient
  1727. X    implementation of Snefru.  Further, this version provides
  1728. X    8 passes.  While 4 pass Snefru has not been broken, the use
  1729. X    of 4 pass Snefru for production use is not recommended at
  1730. X    this time.  Further study of the security of Snefru is
  1731. X    required before production use is advisable.
  1732. X  
  1733. X  This program reads from the standard input until EOF is reached (the first
  1734. X  "read" that returns 0 bytes).  The data on the standard input is "hashed"
  1735. X  with a cryptographically secure one-way hash function (also known as a
  1736. X  "message digest", "fingerprint", "Manipulation Detection Code" or "MDC").
  1737. X  The hash is then printed on the standard output.
  1738. X  
  1739. X  The input can be of any size.  The output is 128 bits printed as 32
  1740. X  characters in hex.  The output size can be changed to 256 bits be setting
  1741. X  the parameter OUTPUT_BLOCK_SIZE to 8.  (The 8 indicates the number of
  1742. X  32-bit words in the output).
  1743. X  
  1744. X  The primary use of one-way hash functions is to determine if there have been
  1745. X  any unauthorized, malicious, or accidental changes made to a file.  For
  1746. X  example, if an executable program file produces the hash "209884c4
  1747. X  2e89d967 5456ac0e 61269550", then any change to that program file will
  1748. X  cause the hash to be changed.  Thus, the tampering can be detected by
  1749. X  comparing the current output value with the previously computed (and
  1750. X  presumably correct) output value.
  1751. X  
  1752. X  Hash512 is the centrol routine in this program.  It is used in this program in
  1753. X  a linear fashion -- i.e., a sequential file is hashed down by repeated
  1754. X  applications of Hash512.  Changing a single bit in the file would then
  1755. X  require completely re-computing the hash from the point of change onward.
  1756. X  
  1757. X  Hash512 can be used in a tree-structured fashion to authenticate a large table
  1758. X  of data. This would imply that changing a single bit would not force a
  1759. X  complete re-computation of the hash value, but would instead require only
  1760. X  log n re-computations of Hash512 to "patch up" the changes along the path
  1761. X  from the root to the changed leaf entry. A tree-structured application
  1762. X  also has the advantage that any single entry in the table can subsequently
  1763. X  be authenticated by someone who knows only the "authentication path" from
  1764. X  the root of the tree to the leaf entry.  These concepts are discussed more
  1765. X  thoroughly in "Secrecy, Authentication, and Public Key Systems" by Ralph
  1766. X  C. Merkle, UMI Research Press, 1982 (see particularly Chapter 2, "One Way
  1767. X  Hash Functions").  The use of a tree-structured pattern of applications of
  1768. X  a one-way hash function is covered by U.S. Patent #4,309,569, "Method of
  1769. X  Providing Digital Signatures" (contact Stanford University, Office of
  1770. X  Technology Licensing).
  1771. X  
  1772. X  
  1773. X  At the present time (November 29, 1990) the author knows of no method for
  1774. X  "breaking" this one-way function, (i.e., finding two input files that
  1775. X  produce the same output value).
  1776. X  
  1777. X  We recommend against the use of output sizes smaller than 128 bits, and
  1778. X  against the use of an input that is less than 2 (two) words larger than
  1779. X  the size of the output.  When the input size equals the output size,
  1780. X  Snefru suffers a serious degradation in security (an observation due to
  1781. X  Coppersmith).
  1782. X
  1783. X  Further study and validation of the security of Snefru is required prior
  1784. X  to production use.
  1785. X  
  1786. X  If anyone using this program finds two different inputs that produce the same
  1787. X  output, please contact Ralph C. Merkle via E-mail (merkle@xerox.com) or
  1788. X  via normal mail at: Xerox PARC 3333 Coyote Hill Road Palo Alto, CA 94304
  1789. X  (415) 494-4000
  1790. X  
  1791. X  
  1792. X  See the paper "A Fast Software One Way Hash Function" by Ralph C. Merkle,
  1793. X  to appear in The Journal of Cryptology, for a more detailed explanation.
  1794. X  
  1795. X  The following test cases were taken directly from a terminal, and can be used
  1796. X  to verify the correct functioning of an implementation of Snefru.  The
  1797. X  first input is simply a carriage return followed by control-d.  The second
  1798. X  input is "1" followed by carriage return followed by control-d, the third
  1799. X  input is "12" followed by carriage return followed by control-d, etc.
  1800. X  (In some cases, two control-d's will be required).
  1801. X
  1802. XNote that the test cases given are from 8-pass Snefru (e.g., SECURITY_LEVEL=8)
  1803. X
  1804. X% ./snefru
  1805. X
  1806. X d9fcb317 1c097fbb a8c8f12a a0906bad
  1807. X% ./snefru
  1808. X1
  1809. X 44ec420c e99c1f62 feb66c53 c24ae453
  1810. X% ./snefru
  1811. X12
  1812. X 7182051a a852ef6f ba4b6c9c 9b79b317
  1813. X% ./snefru
  1814. X123
  1815. X bc3a50af 82bf56d6 a64732bc 7b050a93
  1816. X% ./snefru
  1817. X1234
  1818. X c5b8a049 85a8eadf b4331a89 88752b77
  1819. X% ./snefru
  1820. X12345
  1821. X d559a2b6 2f6f4411 1324f852 08723707
  1822. X% ./snefru
  1823. X123456
  1824. X 6cfb5e8f 1da02bd1 67b01e48 16686c30
  1825. X% ./snefru
  1826. X1234567
  1827. X 29aa4832 5f275a8a 7a01ba15 43c54ba5
  1828. X% ./snefru
  1829. X12345678
  1830. X be862a6b 68b7df88 7ebe0031 9cbc4a47
  1831. X% ./snefru
  1832. X123456789
  1833. X 6103721c cd8ad565 d68e90b0 f8906163
  1834. X% 
  1835. X
  1836. X
  1837. XThe following outputs were obtained after the program was
  1838. Xcompiled with OUTPUT_BLOCK_SIZE set to 8.  This can be done
  1839. Xby using the -D option on cc, as:
  1840. Xcc -o snefru256 -DOUTPUT_BLOCK_SIZE=8 snefru.c
  1841. X
  1842. XNote that the test cases given are from 8-pass Snefru (e.g., SECURITY_LEVEL=8)
  1843. X
  1844. X% ./snefru256
  1845. X
  1846. X 2e02687f 0d45d5b9 b50cb68c 3f33e684 3d618a1a ca2d0689 3d3eb4e3 026b5732
  1847. X% ./snefru256
  1848. X1
  1849. X bfea4a05 a2a2ef15 c736d114 598a20b9 d9bd4d66 b661e6b0 5ecf6a77 37bdc58c
  1850. X% ./snefru256
  1851. X12
  1852. X ac677d69 761ade3f 189c7aef 106d5fe7 392d324e 19cc76d5 db4a2c05 f2cc2cc5
  1853. X% ./snefru256
  1854. X123
  1855. X 061c76aa 1db4a22c 0e42945e 26c48499 b5400162 e08c640b e05d3c00 7c44793d
  1856. X% ./snefru256
  1857. X1234
  1858. X 1e87fe1d 9c927e9e 24be85e3 cc733598 73541640 a6261793 ce5a9749 53113f5e
  1859. X% ./snefru256
  1860. X12345
  1861. X 1b59927d 85a9349a 87796620 fe2ff401 a06a7ba4 8794498e bab978ef c3a68912
  1862. X% ./snefru256
  1863. X123456
  1864. X 28e9d9bc 35032b68 faeda881 01ecb252 4317e9da 111b0e3e 70941072 12d9cf72
  1865. X% ./snefru256
  1866. X1234567
  1867. X f7fff4ee 74fd1b8d 6b3267f8 4e47e007 f029d13b 8af7e37e 34d13b46 9b8f248f
  1868. X% ./snefru256
  1869. X12345678
  1870. X ee7d64b0 102b2205 e9892661 3b200185 559d08be 6ad787da 717c9687 44e11af3
  1871. X% ./snefru256
  1872. X123456789
  1873. X 4ca72639 e40e9ab9 c0c3f523 c4449b39 11632d37 4c124d77 02192ec2 e4e0b7a3
  1874. X% 
  1875. X
  1876. X  Note that "word32" MUST be 32 bits
  1877. X  
  1878. X  Implementor:  Ralph C. Merkle
  1879. X  
  1880. X */
  1881. X
  1882. X==================
  1883. X
  1884. X    The Snefru one-way hash function package is copyrighted by
  1885. XXerox Corporation.  The disclaimer from the C code has been
  1886. Xretained, and is shown above.
  1887. X
  1888. X    All big-endian/little-endian specific code in snefru.c has
  1889. Xbeen replaced by code that can resolve this automatically at
  1890. Xcompile-time.  Tripwire specific code is also in snefru.c to
  1891. Xto minimize the amount of overhead in collecting signatures from
  1892. Xwithin Tripwire.  (We certainly don't want to fork() for every
  1893. Xfile we need to scan!)
  1894. X
  1895. X    Because of this, snefru.c is no longer identical to the
  1896. Xvirgin Snefru distribution.  I have sent my changes to the
  1897. Xauthor, but I am not aware of any buybacks at this time.
  1898. X
  1899. X    The original Snefru code can be obtained via anonymous FTP
  1900. Xfrom arisia.xerox.com.  The original README file has been
  1901. Xretained in the Tripwire distribution.
  1902. X
  1903. X
  1904. X
  1905. XGene Kim
  1906. XSeptember 7, 1992
  1907. END_OF_FILE
  1908. if test 8502 -ne `wc -c <'tripwire-1.0/sigs/snefru/README.snefru'`; then
  1909.     echo shar: \"'tripwire-1.0/sigs/snefru/README.snefru'\" unpacked with wrong size!
  1910. fi
  1911. # end of 'tripwire-1.0/sigs/snefru/README.snefru'
  1912. fi
  1913. if test -f 'tripwire-1.0/sigs/crc32/crc32.c' -a "${1}" != "-c" ; then 
  1914.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/crc32/crc32.c'\"
  1915. else
  1916. echo shar: Extracting \"'tripwire-1.0/sigs/crc32/crc32.c'\" \(8219 characters\)
  1917. sed "s/^X//" >'tripwire-1.0/sigs/crc32/crc32.c' <<'END_OF_FILE'
  1918. X#ifndef lint
  1919. Xstatic char rcsid[] = "$Id: crc32.c,v 1.1.1.2 92/11/02 18:20:58 genek Exp $";
  1920. X#endif
  1921. X
  1922. X/*
  1923. X * crc32.c
  1924. X *
  1925. X *    signature function hook for CRC32.
  1926. X *
  1927. X * Gene Kim
  1928. X * Purdue University
  1929. X * October 14, 1992
  1930. X */
  1931. X
  1932. X  /* ============================================================= */
  1933. X  /*  COPYRIGHT (C) 1986 Gary S. Brown.  You may use this program, or       */
  1934. X  /*  code or tables extracted from it, as desired without restriction.     */
  1935. X  /*                                                                        */
  1936. X  /*  First, the polynomial itself and its table of feedback terms.  The    */
  1937. X  /*  polynomial is                                                         */
  1938. X  /*  X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0   */
  1939. X  /*                                                                        */
  1940. X  /*  Note that we take it "backwards" and put the highest-order term in    */
  1941. X  /*  the lowest-order bit.  The X^32 term is "implied"; the LSB is the     */
  1942. X  /*  X^31 term, etc.  The X^0 term (usually shown as "+1") results in      */
  1943. X  /*  the MSB being 1.                                                      */
  1944. X  /*                                                                        */
  1945. X  /*  Note that the usual hardware shift register implementation, which     */
  1946. X  /*  is what we're using (we're merely optimizing it by doing eight-bit    */
  1947. X  /*  chunks at a time) shifts bits into the lowest-order term.  In our     */
  1948. X  /*  implementation, that means shifting towards the right.  Why do we     */
  1949. X  /*  do it this way?  Because the calculated CRC must be transmitted in    */
  1950. X  /*  order from highest-order term to lowest-order term.  UARTs transmit   */
  1951. X  /*  characters in order from LSB to MSB.  By storing the CRC this way,    */
  1952. X  /*  we hand it to the UART in the order low-byte to high-byte; the UART   */
  1953. X  /*  sends each low-bit to hight-bit; and the result is transmission bit   */
  1954. X  /*  by bit from highest- to lowest-order term without requiring any bit   */
  1955. X  /*  shuffling on our part.  Reception works similarly.                    */
  1956. X  /*                                                                        */
  1957. X  /*  The feedback terms table consists of 256, 32-bit entries.  Notes:     */
  1958. X  /*                                                                        */
  1959. X  /*      The table can be generated at runtime if desired; code to do so   */
  1960. X  /*      is shown later.  It might not be obvious, but the feedback        */
  1961. X  /*      terms simply represent the results of eight shift/xor opera-      */
  1962. X  /*      tions for all combinations of data and CRC register values.       */
  1963. X  /*                                                                        */
  1964. X  /*      The values must be right-shifted by eight bits by the "updcrc"    */
  1965. X  /*      logic; the shift must be unsigned (bring in zeroes).  On some     */
  1966. X  /*      hardware you could probably optimize the shift in assembler by    */
  1967. X  /*      using byte-swap instructions.                                     */
  1968. X  /*      polynomial $edb88320                                              */
  1969. X  /*                                                                        */
  1970. X  /*  --------------------------------------------------------------------  */
  1971. X
  1972. X#include "../../include/config.h"
  1973. X#include <stdio.h>
  1974. X#include <sys/types.h>
  1975. X#ifdef STDLIBH
  1976. X#include <stdlib.h>
  1977. X#include <unistd.h>
  1978. X#endif
  1979. X#include "../../include/sigs.h"
  1980. X#include "crc32.h"
  1981. X#define BUFSIZE 4096
  1982. X
  1983. Xstatic long crc_32_tab[] = {
  1984. X      0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
  1985. X      0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
  1986. X      0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
  1987. X      0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
  1988. X      0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
  1989. X      0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
  1990. X      0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
  1991. X      0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
  1992. X      0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
  1993. X      0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
  1994. X      0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
  1995. X      0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
  1996. X      0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
  1997. X      0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
  1998. X      0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
  1999. X      0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
  2000. X      0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
  2001. X      0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
  2002. X      0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
  2003. X      0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
  2004. X      0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
  2005. X      0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
  2006. X      0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
  2007. X      0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
  2008. X      0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
  2009. X      0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
  2010. X      0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
  2011. X      0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
  2012. X      0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
  2013. X      0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
  2014. X      0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
  2015. X      0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
  2016. X      0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
  2017. X      0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
  2018. X      0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
  2019. X      0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
  2020. X      0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
  2021. X      0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
  2022. X      0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
  2023. X      0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
  2024. X      0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
  2025. X      0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
  2026. X      0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
  2027. X      0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
  2028. X      0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
  2029. X      0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
  2030. X      0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
  2031. X      0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
  2032. X      0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
  2033. X      0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
  2034. X      0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
  2035. X      0x2d02ef8dL
  2036. X   };
  2037. X
  2038. X/* ------------------------------------------------------------- */
  2039. X
  2040. Xstatic long crc32val;
  2041. X
  2042. Xstatic void
  2043. XUpdateCRC(s, len)
  2044. Xregister unsigned char *s;
  2045. Xregister int len;
  2046. X /* update running CRC calculation with contents of a buffer */
  2047. X{
  2048. X   int i;
  2049. X   for (i = 0;  i < len;  i ++) {
  2050. X      crc32val = crc_32_tab[(int) ((crc32val) ^ (s[i])) & 0xff] ^
  2051. X         (((crc32val) >> 8) & 0x00FFFFFFL);
  2052. X   }
  2053. X}
  2054. X
  2055. X#define MAXCRC 0xFFFFFFFFL            /* 32-bit CRC */
  2056. X
  2057. Xint 
  2058. Xsig_crc32_get (fd_in, ps_signature, siglen)
  2059. X    int fd_in;
  2060. X    char *ps_signature;
  2061. X    int siglen;
  2062. X{
  2063. X    unsigned char buffer[BUFSIZE];
  2064. X    int        readin = -1;
  2065. X    char scratch[100];
  2066. X
  2067. X    if (lseek(fd_in, 0, SEEK_SET) < 0) {
  2068. X    perror("sig_md5_get: lseek()");
  2069. X    exit(1);
  2070. X    }
  2071. X
  2072. X    crc32val = 0xFFFFFFFFL;
  2073. X    while ((readin = read(fd_in, (char *)buffer, (off_t) BUFSIZE)) == BUFSIZE) {
  2074. X    UpdateCRC(buffer, BUFSIZE);
  2075. X    }
  2076. X    if (readin != 0) {
  2077. X    UpdateCRC(buffer, readin);
  2078. X    }
  2079. X    crc32val = -1 - crc32val;
  2080. X    sprintf(ps_signature, "%6s", ltob64((unsigned long)crc32val, scratch));
  2081. X
  2082. X    return 0;
  2083. X}
  2084. X
  2085. END_OF_FILE
  2086. if test 8219 -ne `wc -c <'tripwire-1.0/sigs/crc32/crc32.c'`; then
  2087.     echo shar: \"'tripwire-1.0/sigs/crc32/crc32.c'\" unpacked with wrong size!
  2088. fi
  2089. # end of 'tripwire-1.0/sigs/crc32/crc32.c'
  2090. fi
  2091. if test -f 'tripwire-1.0/src/ignorevec.c' -a "${1}" != "-c" ; then 
  2092.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/ignorevec.c'\"
  2093. else
  2094. echo shar: Extracting \"'tripwire-1.0/src/ignorevec.c'\" \(3545 characters\)
  2095. sed "s/^X//" >'tripwire-1.0/src/ignorevec.c' <<'END_OF_FILE'
  2096. X#ifndef lint
  2097. Xstatic char     rcsid[] = "$Id: ignorevec.c,v 1.2 92/11/03 02:43:45 genek Exp $";
  2098. X
  2099. X#endif
  2100. X
  2101. X/*
  2102. X * ignorevec.c
  2103. X *
  2104. X *    ignore-flag vector handling routines
  2105. X *
  2106. X * Gene Kim
  2107. X * Purdue University
  2108. X */
  2109. X
  2110. X#include "../include/config.h"
  2111. X#include <stdio.h>
  2112. X#ifdef STDLIBH
  2113. X#include <stdlib.h>
  2114. X#endif
  2115. X#ifdef STRINGH
  2116. X#include <string.h>
  2117. X#else
  2118. X#include <strings.h>
  2119. X#endif
  2120. X#include <ctype.h>
  2121. X
  2122. X#ifdef __STDC__            /* pick up all the structure prototypes */
  2123. X#include <sys/types.h>
  2124. X#include <sys/stat.h>
  2125. X#endif
  2126. X
  2127. X#include "../include/list.h"
  2128. X#include "../include/tripwire.h"
  2129. X
  2130. X/*
  2131. X * ignore_vec_to_scalar(char *s)
  2132. X *
  2133. X *    take an ignore vector, and return an integer composed of OR'ed
  2134. X *    ignore flags.
  2135. X */
  2136. X
  2137. Xint
  2138. Xignore_vec_to_scalar (s)
  2139. X    char *s;
  2140. X{
  2141. X    register int  retval = 0;
  2142. X
  2143. X    retval = (int) b64tol (s);
  2144. X
  2145. XSPDEBUG (10)
  2146. Xprintf ("ignore_vec_to_scalar (%s) --> %d\n", s, retval);
  2147. X
  2148. X    return retval;
  2149. X}
  2150. X
  2151. X/*
  2152. X * ignore_configvec_to_dvec(char *s)
  2153. X *
  2154. X *    convert a configuration-style ignore vector to the format we use in
  2155. X *    database files.
  2156. X */
  2157. X
  2158. X#define MASKIT(mask) if (ignorethis) {ignoremask |= (mask);} \
  2159. X             else {ignoremask = ignoremask & (~mask);}
  2160. X
  2161. Xvoid
  2162. Xignore_configvec_to_dvec (s)
  2163. X    char           *s;
  2164. X{
  2165. X    char dvec[128];
  2166. X    int  ignoremask = 0, ignorethis = 0;
  2167. X    char *pc;
  2168. X    unsigned long l;
  2169. X
  2170. X    /*
  2171. X     * where ignore-flags are in the format:
  2172. X     *
  2173. X     *     [ [N|R|L]    [ [-|+][p|i|n|u|g|s|a|m|c|0|1|2|3|4|5|6|7|8|9] ] ]
  2174. X     *    (template)     (modifier)
  2175. X     *
  2176. X     * Templates:     (default)    N :  Nothing (+pinusgsamc0123456789)
  2177. X     *                        R :  Read-only (N-a)
  2178. X     *                        L :  Log (N-sam0123456789)
  2179. X     *                                  E :  Everything (-pnugsamci0123456789)
  2180. X     */
  2181. X
  2182. X
  2183. X /* walk through the ignore vector */
  2184. X    for (pc = s; *pc; pc++) {
  2185. X
  2186. X    /* look for template */
  2187. X    switch (*pc) {
  2188. X    case 'E':
  2189. X        ignoremask = IGNORE_P | IGNORE_N | IGNORE_U | IGNORE_G |
  2190. X             IGNORE_S | IGNORE_A | IGNORE_M | IGNORE_C |
  2191. X             IGNORE_I | IGNORE_0_9;
  2192. X        break;
  2193. X      case 'L':
  2194. X        ignoremask = IGNORE_S | IGNORE_A | IGNORE_M | IGNORE_0_9;
  2195. X        break;
  2196. X      case 'N':
  2197. X        ignoremask = 0;
  2198. X        break;
  2199. X      case 'R':
  2200. X        ignoremask = IGNORE_A |
  2201. X             IGNORE_3 | IGNORE_4 | IGNORE_5 | IGNORE_6 |
  2202. X             IGNORE_7 | IGNORE_8 | IGNORE_9;
  2203. X        break;
  2204. X      default:
  2205. X        goto NEXTPLACE;
  2206. X    }
  2207. X    }
  2208. XNEXTPLACE:
  2209. X    for (; *pc; pc++) {
  2210. X    switch (*pc) {
  2211. X      case '+': ignorethis = 0; break;
  2212. X      case '-': ignorethis = 1; break;
  2213. X      case 'p': MASKIT (IGNORE_P); break;
  2214. X      case 'i': MASKIT (IGNORE_I); break;
  2215. X      case 'n': MASKIT (IGNORE_N); break;
  2216. X      case 'u': MASKIT (IGNORE_U); break;
  2217. X      case 'g': MASKIT (IGNORE_G); break;
  2218. X      case 's': MASKIT (IGNORE_S); break;
  2219. X      case 'a': MASKIT (IGNORE_A); break;
  2220. X      case 'm': MASKIT (IGNORE_M); break;
  2221. X      case 'c': MASKIT (IGNORE_C); break;
  2222. X      case '0': MASKIT (IGNORE_0); break;
  2223. X      case '1': MASKIT (IGNORE_1); break;
  2224. X      case '2': MASKIT (IGNORE_2); break;
  2225. X      case '3': MASKIT (IGNORE_3); break;
  2226. X      case '4': MASKIT (IGNORE_4); break;
  2227. X      case '5': MASKIT (IGNORE_5); break;
  2228. X      case '6': MASKIT (IGNORE_6); break;
  2229. X      case '7': MASKIT (IGNORE_7); break;
  2230. X      case '8': MASKIT (IGNORE_8); break;
  2231. X      case '9': MASKIT (IGNORE_9); break;
  2232. X      default:
  2233. X        fprintf (stderr,
  2234. X         "%s: configuration parse error: illegal flag ('%c' in '%s')\n",
  2235. X             progname, *pc, s);
  2236. X        exit (1);
  2237. X    }
  2238. X
  2239. X    }
  2240. X
  2241. X /* now turn it into a string that we can interpolate */
  2242. X
  2243. X    l = ignoremask;
  2244. X    (void) ltob64 (l, dvec);
  2245. X
  2246. XSPDEBUG (10)
  2247. Xprintf ("ignore_configvec_to_dvec: (%s) --> (%s)\n", s, dvec);
  2248. X
  2249. X    (void) strcpy (s, dvec);
  2250. X
  2251. X    return;
  2252. X}
  2253. END_OF_FILE
  2254. if test 3545 -ne `wc -c <'tripwire-1.0/src/ignorevec.c'`; then
  2255.     echo shar: \"'tripwire-1.0/src/ignorevec.c'\" unpacked with wrong size!
  2256. fi
  2257. # end of 'tripwire-1.0/src/ignorevec.c'
  2258. fi
  2259. if test -f 'tripwire-1.0/sigs/md5/Makefile' -a "${1}" != "-c" ; then 
  2260.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/md5/Makefile'\"
  2261. else
  2262. echo shar: Extracting \"'tripwire-1.0/sigs/md5/Makefile'\" \(305 characters\)
  2263. sed "s/^X//" >'tripwire-1.0/sigs/md5/Makefile' <<'END_OF_FILE'
  2264. X# $Id: Makefile,v 1.1.1.2 92/11/02 18:21:58 genek Exp $
  2265. X#
  2266. X# Makefile for md5 wrapper
  2267. X#
  2268. X# Gene Kim
  2269. X# Purdue University
  2270. X# October 18, 1992
  2271. X#
  2272. X
  2273. Xall:    md5.o md5wrapper.o
  2274. X
  2275. X.c.o:
  2276. X    $(CC) $(CFLAGS) -c $<
  2277. X    
  2278. Xclean:
  2279. X    -rm -rf md5.o md5wrapper.o
  2280. X
  2281. Xmd5.o: ../../include/byteorder.h
  2282. Xmd5wrapper.o: ../../include/byteorder.h
  2283. END_OF_FILE
  2284. if test 305 -ne `wc -c <'tripwire-1.0/sigs/md5/Makefile'`; then
  2285.     echo shar: \"'tripwire-1.0/sigs/md5/Makefile'\" unpacked with wrong size!
  2286. fi
  2287. # end of 'tripwire-1.0/sigs/md5/Makefile'
  2288. fi
  2289. echo shar: End of archive 5 \(of 8\).
  2290. cp /dev/null ark5isdone
  2291. MISSING=""
  2292. for I in 1 2 3 4 5 6 7 8 ; do
  2293.     if test ! -f ark${I}isdone ; then
  2294.     MISSING="${MISSING} ${I}"
  2295.     fi
  2296. done
  2297. if test "${MISSING}" = "" ; then
  2298.     echo You have unpacked all 8 archives.
  2299.     echo "Now read the README file"
  2300.     rm -f ark[1-9]isdone
  2301. else
  2302.     echo You still need to unpack the following archives:
  2303.     echo "        " ${MISSING}
  2304. fi
  2305. ##  End of shell archive.
  2306. exit 0
  2307. -- 
  2308. Gene Spafford
  2309. Software Engineering Research Center & Dept. of Computer Sciences
  2310. Purdue University, W. Lafayette IN 47907-1398
  2311. Internet:  spaf@cs.purdue.edu    phone:  (317) 494-7825
  2312.