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

  1. Newsgroups: comp.sources.unix
  2. From: spaf@cs.purdue.edu (Gene Spafford)
  3. Subject: v26i176: tripwire - security integrity monitor, Part04/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 176
  9. Archive-Name: tripwire/part04
  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 4 (of 8)."
  18. # Contents:  tripwire-1.0 tripwire-1.0/include tripwire-1.0/sigs
  19. #   tripwire-1.0/sigs/crc tripwire-1.0/sigs/md5 tripwire-1.0/src
  20. #   tripwire-1.0/src/preen.report.c tripwire-1.0/src/utils.c
  21. #   tripwire-1.0/src/config.parse.c tripwire-1.0/sigs/md5/md5.c
  22. #   tripwire-1.0/include/tripwire.h tripwire-1.0/sigs/crc/crc.h
  23. # Wrapped by spaf@uther.cs.purdue.edu on Tue Nov  3 16:31:56 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test ! -d 'tripwire-1.0' ; then
  26.     echo shar: Creating directory \"'tripwire-1.0'\"
  27.     mkdir 'tripwire-1.0'
  28. fi
  29. if test ! -d 'tripwire-1.0/include' ; then
  30.     echo shar: Creating directory \"'tripwire-1.0/include'\"
  31.     mkdir 'tripwire-1.0/include'
  32. fi
  33. if test ! -d 'tripwire-1.0/sigs' ; then
  34.     echo shar: Creating directory \"'tripwire-1.0/sigs'\"
  35.     mkdir 'tripwire-1.0/sigs'
  36. fi
  37. if test ! -d 'tripwire-1.0/sigs/crc' ; then
  38.     echo shar: Creating directory \"'tripwire-1.0/sigs/crc'\"
  39.     mkdir 'tripwire-1.0/sigs/crc'
  40. fi
  41. if test ! -d 'tripwire-1.0/sigs/md5' ; then
  42.     echo shar: Creating directory \"'tripwire-1.0/sigs/md5'\"
  43.     mkdir 'tripwire-1.0/sigs/md5'
  44. fi
  45. if test ! -d 'tripwire-1.0/src' ; then
  46.     echo shar: Creating directory \"'tripwire-1.0/src'\"
  47.     mkdir 'tripwire-1.0/src'
  48. fi
  49. if test -f 'tripwire-1.0/src/preen.report.c' -a "${1}" != "-c" ; then 
  50.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/preen.report.c'\"
  51. else
  52. echo shar: Extracting \"'tripwire-1.0/src/preen.report.c'\" \(15903 characters\)
  53. sed "s/^X//" >'tripwire-1.0/src/preen.report.c' <<'END_OF_FILE'
  54. X#ifndef lint
  55. Xstatic char rcsid[] = "$Id: preen.report.c,v 1.3 92/11/03 02:44:02 genek Exp $";
  56. X#endif
  57. X
  58. X/*
  59. X * preen.report.c
  60. X *
  61. X *    report generation given the data from preening
  62. X *
  63. X * Gene Kim
  64. X * Purdue University
  65. X */
  66. X
  67. X#include "../include/config.h"
  68. X#include <stdio.h>
  69. X#ifdef STDLIBH
  70. X#include <stdlib.h>
  71. X#endif
  72. X#include <sys/types.h>
  73. X#include <sys/stat.h>
  74. X#ifdef STRINGH
  75. X#include <string.h>
  76. X#else
  77. X#include <strings.h>
  78. X#endif
  79. X#include <time.h>
  80. X#ifdef MALLOCH
  81. X# include <malloc.h>
  82. X#endif
  83. X#include "../include/list.h"
  84. X#include "../include/tripwire.h"
  85. X
  86. Xstatic void preen_report_changed_enum();
  87. Xstatic int preen_change_count();
  88. Xstatic char *structstat_fill();
  89. Xstatic void pair_print_ss();
  90. Xstatic void pair_print_ll();
  91. Xstatic void pair_print_llo();
  92. X
  93. X/*
  94. X * preen_report()
  95. X *
  96. X *    report on:
  97. X *        which files have been ADDED
  98. X *        which files have been DELETED
  99. X *        which files have been CHANGED
  100. X *            what attribute changed?
  101. X */
  102. X
  103. Xvoid
  104. Xpreen_report()
  105. X{
  106. X    struct list_elem *p;
  107. X    struct stat statnew, statold;
  108. X    char sigsnew[NUM_SIGS][SIG_MAX_LEN], sigsold[NUM_SIGS][SIG_MAX_LEN];
  109. X    char *s;
  110. X    int unignored;
  111. X
  112. X    fprintf(stderr, "###\n");
  113. X    fprintf(stderr, "###\t\t\tTotal files scanned:\t\t%d\n", files_scanned_num);
  114. X    fprintf(stderr, "###\t\t\t      Files added:\t\t%d\n", diff_added_num);
  115. X    fprintf(stderr, "###\t\t\t      Files deleted:\t\t%d\n", diff_deleted_num);
  116. X    fprintf(stderr, "###\t\t\t      Files changed:\t\t%d\n", diff_changed_num);
  117. X    fprintf(stderr, "###\n");
  118. X    fprintf(stderr, "###\t\t\tAfter applying rules:\n");
  119. X    fprintf(stderr, "###\t\t\t      Changes discarded:\t%d\n",
  120. X            diff_added_num + diff_deleted_num + diff_changed_num -
  121. X                  (unignored = preen_change_count()) );
  122. X    fprintf(stderr, "###\t\t\t      Changes remaining:\t%d\n",
  123. X                unignored + diff_added_num + diff_deleted_num);
  124. X    fprintf(stderr, "###\n");
  125. X
  126. X    /****** added ******/
  127. X
  128. X    /* open each of the three lists, using &diff_xxxx_list as keys */
  129. X    if (list_open(&diff_added_list) < 0) {
  130. X    fprintf(stderr, "preen_report: list_open() failed!\n");
  131. X    exit(1);
  132. X    }
  133. X
  134. X    /* print out each added file in sequence */
  135. X    while ((p = list_get(&diff_added_list)) != NULL) {
  136. X    (void) structstat_fill(p->varvalue, &statnew, sigsnew);
  137. X    direntry_print(p->varname, statnew, DIFF_ADDED);
  138. X    }
  139. X
  140. X    if (list_close(&diff_added_list) < 0) {
  141. X    fprintf(stderr, "preen_report: list_close() failed!\n");
  142. X    exit(1);
  143. X    }
  144. X
  145. X    /****** deleted ******/
  146. X
  147. X    /* now print out the files that were deleted */
  148. X    if (list_open(&diff_deleted_list) < 0) {
  149. X    fprintf(stderr, "preen_report: list_open() failed!\n");
  150. X    exit(1);
  151. X    }
  152. X
  153. X    /* print out each added file in sequence */
  154. X    while ((p = list_get(&diff_deleted_list)) != NULL) {
  155. X    (void) structstat_fill(p->varvalue, &statnew, sigsnew);
  156. X    direntry_print(p->varname, statnew, DIFF_DELETED);
  157. X    }
  158. X
  159. X    if (list_close(&diff_deleted_list) < 0) {
  160. X    fprintf(stderr, "preen_report: list_close() failed!\n");
  161. X    exit(1);
  162. X    }
  163. X
  164. X    /***** changed ******/
  165. X
  166. X    /*
  167. X     * interate through the list
  168. X     *        get the ignore vector
  169. X     *        foreach each (attribute) {
  170. X     *            if (attribute != attribute')
  171. X     *                if (!ignored) { flag it; }
  172. X     *        }
  173. X     */
  174. X    /*
  175. X    list_print(&diff_changed_list);
  176. X    */
  177. X    if (list_open(&diff_changed_list) < 0) {
  178. X    fprintf(stderr, "preen_report: list_open() failed!\n");
  179. X    exit(1);
  180. X    }
  181. X
  182. X    /* print out each added file in sequence */
  183. X    while ((p = list_get(&diff_changed_list)) != NULL) {
  184. X
  185. X    /* copy the filename and expand any escaped characters */
  186. X
  187. X    /* filename, ignore, mode, inode, nlinks, uid, gid, size, access,
  188. X     * modify, ctime, sig1, sig2
  189. X     */
  190. X
  191. X    /* read in the new value from the changed_list
  192. X     *        throw away the new ignorevector -- we use the old one!
  193. X     */
  194. X    (void) structstat_fill(p->varvalue, &statnew, sigsnew);
  195. X
  196. X    /* read in the list1 value form the hash table */
  197. X    if ((s = list_lookup(p->varname, &filelist)) == NULL) {
  198. X        fprintf(stderr, "preen_report: list_lookup() failed!\n");
  199. X        exit(1);
  200. X    }
  201. X
  202. X    (void) structstat_fill(s, &statold, sigsold);
  203. X
  204. X    /* is this file to be ignored? */
  205. X    if (!(list_getflag(p->varname, &diff_changed_list) & FLAG_CHANGED))
  206. X        continue;
  207. X
  208. X    /* print out the report for this file */
  209. X    direntry_print(p->varname, statnew, DIFF_CHANGED);
  210. X
  211. X    }
  212. X
  213. X    if (list_close(&diff_changed_list) < 0) {
  214. X    fprintf(stderr, "preen_report: list_close() failed!\n");
  215. X    exit(1);
  216. X    }
  217. X
  218. X    /* enumerate specifics of changed files, if long output specified */
  219. X    if (!quiet && unignored != 0) {
  220. X    preen_report_changed_enum();
  221. X    }
  222. X
  223. X    return;
  224. X}
  225. X
  226. X/*
  227. X * preen_report_changed_enum()
  228. X *
  229. X *    enumerate each changed attributed for each of the changed files.
  230. X *    this is treated as yet another pass in the checking process.
  231. X */
  232. X
  233. Xstatic void
  234. Xpreen_report_changed_enum()
  235. X{
  236. X    struct list_elem *p;
  237. X    char *ignorevec;
  238. X    char sigsold[NUM_SIGS][SIG_MAX_LEN], sigsnew[NUM_SIGS][SIG_MAX_LEN];
  239. X    struct stat statnew, statold;
  240. X    char *s;
  241. X    char stime1[64], stime2[64];
  242. X    int ignoremask;
  243. X    int i;
  244. X    char label[50];
  245. X
  246. X    (void) fflush(stdout);
  247. X    fprintf(stderr, "### Phase 5:   Generating observed/expected pairs for changed files\n");
  248. X    fprintf(stderr, "###\n");
  249. X    (void) fflush(stderr);
  250. X
  251. Xprintf("### Attr        Observed (what it is)          Expected (what it should be)\n");
  252. Xprintf("### =========== ============================= =============================\n");
  253. X    /****
  254. X    st_atime: Mon Aug 31 16:48:57 1992         Mon Aug 31 14:05:49 1992
  255. X    ****/
  256. X
  257. X    /* open the list of changed files */
  258. X    if (list_open(&diff_changed_list) < 0) {
  259. X    fprintf(stderr, "preen_report: list_open() failed!\n");
  260. X    exit(1);
  261. X    }
  262. X
  263. X    /* print out each added file in sequence */
  264. X    while ((p = list_get(&diff_changed_list)) != NULL) {
  265. X
  266. X    /* filename, ignore, mode, inode, nlinks, uid, gid, size, access,
  267. X     * modify, ctime, sig1, sig2 .. sign
  268. X     */
  269. X
  270. X    /* read in the list2 value from the changed_list
  271. X     *        throw away the new ignorevector -- we use the old one!
  272. X     */
  273. X    (void) structstat_fill(p->varvalue, &statnew, sigsnew);
  274. X
  275. X    /* read in the list1 value form the hash table */
  276. X    if ((s = list_lookup(p->varname, &filelist)) == NULL) {
  277. X        fprintf(stderr, "preen_report_changed_enum: list_lookup() failed!\n");
  278. X        exit(1);
  279. X    }
  280. X
  281. X    ignorevec = structstat_fill(s, &statold, sigsold);
  282. X
  283. X    /* get the ignoremask */
  284. X    ignoremask = ignore_vec_to_scalar(ignorevec);
  285. X
  286. X    /* is this file to be ignored? */
  287. X    if (!(list_getflag(p->varname, &diff_changed_list) & FLAG_CHANGED))
  288. X        continue;
  289. X
  290. X    printf("%s\n", p->varname);
  291. X    /* and then the {expected, received} pairs */
  292. X
  293. X#define STATEQ(x) (statnew.x != statold.x)
  294. X
  295. X    if (!(ignoremask & IGNORE_P))
  296. X        if (STATEQ(st_mode)) {
  297. X        pair_print_llo("st_mode:", (long) statnew.st_mode,
  298. X            (long) statold.st_mode);
  299. X        }
  300. X    
  301. X    if (!(ignoremask & IGNORE_I))
  302. X        if (STATEQ(st_ino)) {
  303. X        pair_print_ll("st_ino:", (long) statnew.st_ino,
  304. X            (long) statold.st_ino);
  305. X        }
  306. X    
  307. X    if (!(ignoremask & IGNORE_N))
  308. X        if (STATEQ(st_nlink)) {
  309. X        pair_print_ll("st_nlink:", (long) statnew.st_nlink,
  310. X            (long) statold.st_nlink);
  311. X        }
  312. X
  313. X    if (!(ignoremask & IGNORE_U))
  314. X        if (STATEQ(st_uid)) {
  315. X        pair_print_ll("st_uid:", (long) statnew.st_uid,
  316. X            (long) statold.st_uid);
  317. X        }
  318. X
  319. X    if (!(ignoremask & IGNORE_G))
  320. X        if (STATEQ(st_gid)) {
  321. X        pair_print_ll("st_gid:", (long) statnew.st_gid,
  322. X            (long) statold.st_gid);
  323. X        }
  324. X
  325. X    if (!(ignoremask & IGNORE_S))
  326. X        if (STATEQ(st_size)) {
  327. X        pair_print_ll("st_size:", (long) statnew.st_size,
  328. X            (long) statold.st_size);
  329. X        }
  330. X
  331. X    if (!(ignoremask & IGNORE_A))
  332. X        if (STATEQ(st_atime)) {
  333. X        (void) strcpy(stime1, ctime(&statnew.st_atime));
  334. X        (void) strcpy(stime2, ctime(&statold.st_atime));
  335. X        chop(stime1);
  336. X        chop(stime2);
  337. X        pair_print_ss("st_atime:", stime1, stime2);
  338. X        }
  339. X
  340. X    if (!(ignoremask & IGNORE_M))
  341. X        if (STATEQ(st_mtime)) {
  342. X        (void) strcpy(stime1, ctime(&statnew.st_mtime));
  343. X        (void) strcpy(stime2, ctime(&statold.st_mtime));
  344. X        chop(stime1);
  345. X        chop(stime2);
  346. X        pair_print_ss("st_mtime:", stime1, stime2);
  347. X        }
  348. X
  349. X    if (!(ignoremask & IGNORE_C))
  350. X        if (STATEQ(st_ctime)) {
  351. X        (void) strcpy(stime1, ctime(&statnew.st_ctime));
  352. X        (void) strcpy(stime2, ctime(&statold.st_ctime));
  353. X        chop(stime1);
  354. X        chop(stime2);
  355. X        pair_print_ss("st_ctime:", stime1, stime2);
  356. X        }
  357. X
  358. X    for (i = 0; i < NUM_SIGS; i++) {
  359. X        if (!(runtimeignore & (IGNORE_0 << i)) &&
  360. X                    !(ignoremask & (IGNORE_0 << i)))
  361. X        if (strcmp(sigsnew[i], sigsold[i]) != 0) {
  362. X            (void) sprintf(label, "%s (sig%d):", signames[i], i);
  363. X            pair_print_ss(label, sigsnew[i], sigsold[i]);
  364. X        }
  365. X
  366. X    }
  367. X
  368. X    /* separate entries by a space */
  369. X    printf("\n");
  370. X    }
  371. X
  372. X    if (list_close(&diff_changed_list) < 0) {
  373. X    fprintf(stderr, "preen_report_changed_enum: list_close() failed!\n");
  374. X    exit(1);
  375. X    }
  376. X}
  377. X
  378. X/*
  379. X * preen_change_count()
  380. X *
  381. X *    return the number of files that are changed, according to their
  382. X *    ignore vectors.
  383. X */
  384. X
  385. Xstatic int
  386. Xpreen_change_count()
  387. X{
  388. X    int changed = 0;
  389. X    struct list_elem *p;
  390. X    char sigsold[NUM_SIGS][SIG_MAX_LEN], sigsnew[NUM_SIGS][SIG_MAX_LEN];
  391. X    char vec64_a[50], vec64_m[50], vec64_c[50];
  392. X    char trash[512];
  393. X    struct stat statnew, statold;
  394. X    char *s;
  395. X    int ignoremask;
  396. X    char ignorevec[512];
  397. X    unsigned long mode, ino, nlink, uid, gid, size;
  398. X    int entrynum;
  399. X    int nfields;
  400. X
  401. X    /***** changed ******/
  402. X
  403. X    /*
  404. X     * interate through the list
  405. X     *        get the ignore vector
  406. X     *        foreach each (attribute) {
  407. X     *            if (attribute != attribute')
  408. X     *                if (!ignored) { flag it; }
  409. X     *        }
  410. X     */
  411. X    if (list_open(&diff_changed_list) < 0) {
  412. X    fprintf(stderr, "preen_report: list_open() failed!\n");
  413. X    exit(1);
  414. X    }
  415. X
  416. X    /* print out each added file in sequence */
  417. X    while ((p = list_get(&diff_changed_list)) != NULL) {
  418. X
  419. X    /* filename, ignore, mode, inode, nlinks, uid, gid, size, access,
  420. X     * modify, ctime, sig1, sig2
  421. X     */
  422. X
  423. X    /* read in the list2 value from the changed_list
  424. X     *        throw away the new ignorevector -- we use the old one!
  425. X     */
  426. X
  427. X    if ((nfields = sscanf(p->varvalue, db_record_format,
  428. X        &entrynum, trash,
  429. X        &mode, &ino, &nlink, &uid, &gid, &size,
  430. X        vec64_a, vec64_m, vec64_c,
  431. X        sigsnew[0], sigsnew[1], sigsnew[2], sigsnew[3], sigsnew[4],
  432. X        sigsnew[5], sigsnew[6], sigsnew[7], sigsnew[8], sigsnew[9]))
  433. X                != DB_RECORD_FIELDS) {
  434. X        fprintf(stderr, "preen_change_count: illegal database record (nfields == %d).   Aborting...\n", nfields);
  435. X        fprintf(stderr, "    '%s'\n", p->varvalue);
  436. X        exit(1);
  437. X    }
  438. X        statnew.st_mode = (mode_t)mode;
  439. X        statnew.st_ino = (ino_t)ino;
  440. X        statnew.st_nlink = (nlink_t)nlink;
  441. X        statnew.st_uid = (uid_t)uid;
  442. X        statnew.st_gid = (gid_t)gid;
  443. X        statnew.st_size = (off_t)size;
  444. X
  445. X    /* convert from base64 to int */
  446. X    statnew.st_atime = b64tol(vec64_a);
  447. X    statnew.st_mtime = b64tol(vec64_m);
  448. X    statnew.st_ctime = b64tol(vec64_c);
  449. X
  450. X    /* read in the list1 value form the hash table */
  451. X    if ((s = list_lookup(p->varname, &filelist)) == NULL) {
  452. X        fprintf(stderr, "preen_report: list_lookup() failed!\n");
  453. X        exit(1);
  454. X    }
  455. X
  456. X    if (sscanf(s, db_record_format,
  457. X        &entrynum, ignorevec,
  458. X        &mode, &ino, &nlink, &uid, &gid, &size,
  459. X        vec64_a, vec64_m, vec64_c,
  460. X        sigsold[0], sigsold[1], sigsold[2], sigsold[3], sigsold[4],
  461. X        sigsold[5], sigsold[6], sigsold[7], sigsold[8], sigsold[9])
  462. X                != DB_RECORD_FIELDS) {
  463. X        fprintf(stderr, "preen_change_count: illegal database record! Aborting...\n");
  464. X        fprintf(stderr, "    '%s'\n", s);
  465. X        exit(1);
  466. X    }
  467. X        statold.st_mode = (mode_t)mode;
  468. X        statold.st_ino = (ino_t)ino;
  469. X        statold.st_nlink = (nlink_t)nlink;
  470. X        statold.st_uid = (uid_t)uid;
  471. X        statold.st_gid = (gid_t)gid;
  472. X        statold.st_size = (off_t)size;
  473. X
  474. X    /* convert from base64 to int */
  475. X    statold.st_atime = b64tol(vec64_a);
  476. X    statold.st_mtime = b64tol(vec64_m);
  477. X    statold.st_ctime = b64tol(vec64_c);
  478. X
  479. X    /* get the ignoremask */
  480. X    ignoremask = ignore_vec_to_scalar(ignorevec);
  481. X
  482. X    /* and then the {expected, received} pairs */
  483. X
  484. X#define FLAGIT() changed++; list_setflag(p->varname, FLAG_CHANGED, &diff_changed_list); continue
  485. X#define SIGEQ(x) if (strcmp(sigsnew[(x)], sigsold[(x)]) != 0)
  486. X
  487. X    /* note the pain we go through to avoid dangling else's */
  488. X    if (!(ignoremask & IGNORE_P)) { if (STATEQ(st_mode)) {FLAGIT();}}
  489. X    if (!(ignoremask & IGNORE_I)) { if (STATEQ(st_ino)) {FLAGIT();}}
  490. X    if (!(ignoremask & IGNORE_N)) { if (STATEQ(st_nlink)) {FLAGIT();}}
  491. X    if (!(ignoremask & IGNORE_U)) { if (STATEQ(st_uid)) {FLAGIT();}}
  492. X    if (!(ignoremask & IGNORE_G)) { if (STATEQ(st_gid)) {FLAGIT();}}
  493. X    if (!(ignoremask & IGNORE_S)) { if (STATEQ(st_size)) {FLAGIT();}}
  494. X    if (!(ignoremask & IGNORE_A)) { if (STATEQ(st_atime)) {FLAGIT();}}
  495. X    if (!(ignoremask & IGNORE_M)) { if (STATEQ(st_mtime)) {FLAGIT();}}
  496. X    if (!(ignoremask & IGNORE_C)) { if (STATEQ(st_ctime)) {FLAGIT();}}
  497. X    if (!(runtimeignore & IGNORE_0) && !(ignoremask & IGNORE_0))
  498. X                    { SIGEQ(0) {FLAGIT();}}
  499. X    if (!(runtimeignore & IGNORE_1) && !(ignoremask & IGNORE_1))
  500. X                    { SIGEQ(1) {FLAGIT();}}
  501. X    if (!(runtimeignore & IGNORE_2) && !(ignoremask & IGNORE_2))
  502. X                    { SIGEQ(2) {FLAGIT();}}
  503. X    if (!(runtimeignore & IGNORE_3) && !(ignoremask & IGNORE_3))
  504. X                    { SIGEQ(3) {FLAGIT();}}
  505. X    if (!(runtimeignore & IGNORE_4) && !(ignoremask & IGNORE_4))
  506. X                    { SIGEQ(4) {FLAGIT();}}
  507. X    if (!(runtimeignore & IGNORE_5) && !(ignoremask & IGNORE_5))
  508. X                    { SIGEQ(5) {FLAGIT();}}
  509. X    if (!(runtimeignore & IGNORE_6) && !(ignoremask & IGNORE_6))
  510. X                    { SIGEQ(6) {FLAGIT();}}
  511. X    if (!(runtimeignore & IGNORE_7) && !(ignoremask & IGNORE_7))
  512. X                    { SIGEQ(7) {FLAGIT();}}
  513. X    if (!(runtimeignore & IGNORE_8) && !(ignoremask & IGNORE_8))
  514. X                    { SIGEQ(8) {FLAGIT();}}
  515. X    if (!(runtimeignore & IGNORE_9) && !(ignoremask & IGNORE_9))
  516. X                    { SIGEQ(9) {FLAGIT();}}
  517. X
  518. X    }
  519. X
  520. X    /* clean up */
  521. X    if (list_close(&diff_changed_list) < 0) {
  522. X    fprintf(stderr, "preen_report: list_close() failed!\n");
  523. X    exit(1);
  524. X    }
  525. X
  526. X    return changed;
  527. X}
  528. X
  529. X/*
  530. X * structstat_fill(char *string, struct stat *statbuf)
  531. X *
  532. X *    given a string from the database, fill in the statbuf structure.
  533. X *    
  534. X *    return the ignore vector (a static system structure)
  535. X */
  536. X
  537. Xstatic char *
  538. Xstructstat_fill (string, statbuf, sigs)
  539. X    char *string;
  540. X    struct stat *statbuf;
  541. X    char sigs[NUM_SIGS][SIG_MAX_LEN];
  542. X{
  543. X    char *ignorevec;
  544. X    static char structstat_fill_string[512];
  545. X    unsigned long        mode, ino, nlink, uid, gid, size;
  546. X    int entrynum;
  547. X    char vec64_a[50], vec64_m[50], vec64_c[50];
  548. X
  549. X    (void) strcpy(structstat_fill_string, string);
  550. X    ignorevec = structstat_fill_string;
  551. X
  552. X    if (sscanf(string, db_record_format,
  553. X        &entrynum, ignorevec,
  554. X        &mode, &ino, &nlink, &uid, &gid, &size,
  555. X        vec64_a, vec64_m, vec64_c,
  556. X        sigs[0], sigs[1], sigs[2], sigs[3], sigs[4],
  557. X        sigs[5], sigs[6], sigs[7], sigs[8], sigs[9])
  558. X                != DB_RECORD_FIELDS) {
  559. X    fprintf(stderr, "structstat_fill: illegal database record! Aborting...\n");
  560. X    fprintf(stderr, "    '%s'\n", string);
  561. X    exit(1);
  562. X    }
  563. X    statbuf->st_mode = (mode_t)mode;
  564. X    statbuf->st_ino = (ino_t)ino;
  565. X    statbuf->st_nlink = (nlink_t)nlink;
  566. X    statbuf->st_uid = (uid_t)uid;
  567. X    statbuf->st_gid = (gid_t)gid;
  568. X    statbuf->st_size = (off_t)size;
  569. X
  570. X    /* convert from base64 to int */
  571. X    statbuf->st_atime = b64tol(vec64_a);
  572. X    statbuf->st_mtime = b64tol(vec64_m);
  573. X    statbuf->st_ctime = b64tol(vec64_c);
  574. X
  575. X    return ignorevec;
  576. X}
  577. X
  578. X/*
  579. X * pair_print_ss(char *label, char *s1, char *s2)
  580. X *
  581. X *    print {expected,received} table with strings
  582. X */
  583. X
  584. Xstatic void
  585. Xpair_print_ss (label, s1, s2)
  586. X    char *label;
  587. X    char *s1;
  588. X    char *s2;
  589. X{
  590. X    printf("%15s %-30s%-30s\n", label, s1, s2);
  591. X    return;
  592. X}
  593. X
  594. X/*
  595. X * pair_print_ll(char *label, long l1, long l2)
  596. X *
  597. X *    print {expected,received} table with longs
  598. X */
  599. X
  600. Xstatic void
  601. Xpair_print_ll (label, l1, l2)
  602. X    char *label;
  603. X    long l1;
  604. X    long l2;
  605. X{
  606. X    printf("%15s %-30ld%-30ld\n", label, l1, l2);
  607. X    return;
  608. X}
  609. X
  610. X/*
  611. X * pair_print_llo(char *label, long l1, long l2)
  612. X *
  613. X *    print {expected,received} table with longs in octal
  614. X */
  615. X
  616. Xstatic void
  617. Xpair_print_llo (label, l1, l2)
  618. X    char *label;
  619. X    long l1;
  620. X    long l2;
  621. X{
  622. X    printf("%15s %-30lo%-30lo\n", label, l1, l2);
  623. X    return;
  624. X}
  625. X
  626. END_OF_FILE
  627. if test 15903 -ne `wc -c <'tripwire-1.0/src/preen.report.c'`; then
  628.     echo shar: \"'tripwire-1.0/src/preen.report.c'\" unpacked with wrong size!
  629. fi
  630. # end of 'tripwire-1.0/src/preen.report.c'
  631. fi
  632. if test -f 'tripwire-1.0/src/utils.c' -a "${1}" != "-c" ; then 
  633.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/utils.c'\"
  634. else
  635. echo shar: Extracting \"'tripwire-1.0/src/utils.c'\" \(13384 characters\)
  636. sed "s/^X//" >'tripwire-1.0/src/utils.c' <<'END_OF_FILE'
  637. X#ifndef lint
  638. Xstatic char rcsid[] = "$Id: utils.c,v 1.27 92/10/20 14:59:01 genek Exp $";
  639. X#endif
  640. X
  641. X/*
  642. X * utils.c
  643. X *
  644. X *    miscellaneous utilities for Tripwire
  645. X *
  646. X * Gene Kim
  647. X * Purdue University
  648. X */
  649. X
  650. X#include "../include/config.h"
  651. X#include <stdio.h>
  652. X#ifdef STDLIBH
  653. X#include <stdlib.h>
  654. X#endif
  655. X#include <ctype.h>
  656. X#ifdef STRINGH
  657. X#include <string.h>
  658. X#else
  659. X#include <strings.h>
  660. X# if (!defined(strchr) && !defined(index))
  661. X#  define strchr(s, c) index(s, c)
  662. X# endif
  663. X# if (!defined(memcpy) && !defined(bcopy))
  664. X#  define memcpy(to, from, n) bcopy(from, to, n)
  665. X# endif
  666. X#endif
  667. X#include <sys/types.h>
  668. X#include <sys/stat.h>
  669. X#include <pwd.h>
  670. X#include <grp.h>
  671. X#include <sys/param.h>
  672. X#include <ctype.h>
  673. X#include <sys/param.h>
  674. X#ifndef MAXHOSTNAMELEN
  675. X#define MAXHOSTNAMELEN 64
  676. X#endif
  677. X#ifndef XENIX
  678. X# include <sys/time.h>
  679. X#else
  680. X# include <time.h>
  681. X#endif     /* XENIX */
  682. X#ifndef GETHOSTNAME
  683. X# include <sys/utsname.h>
  684. X#endif
  685. X#if (defined(SYSV) && (SYSV < 3))
  686. X# include <limits.h>
  687. X#endif    /* SVR2 */
  688. X#include "../include/list.h"
  689. X#include "../include/tripwire.h"
  690. X
  691. Xstatic void print_perm();
  692. X
  693. X#ifndef S_IRGRP
  694. X#define S_IRGRP    (S_IREAD >> 3)
  695. X#define S_IWGRP (S_IWRITE >> 3)
  696. X#define S_IXGRP (S_IEXEC >> 3)
  697. X#define S_IROTH (S_IREAD >> 6)
  698. X#define S_IWOTH (S_IWRITE >> 6)
  699. X#define S_IXOTH (S_IEXEC >> 6)
  700. X#endif
  701. X
  702. Xvoid warn_with_err(format, name)
  703. X   char *format, *name;
  704. X{
  705. X    extern int  errno;
  706. X    int real_errno = errno;
  707. X    char *string;
  708. X
  709. X    if (!name)
  710. X      string = format;
  711. X    else {
  712. X    string = (char *) malloc((unsigned) (strlen(format)+strlen(name)+1));
  713. X    if (!string) {
  714. X        fputs("Unexpected malloc() failure in 'warn_with_err'!\n", stderr);
  715. X        exit(-1);
  716. X    }
  717. X    sprintf(string, format, name);
  718. X    errno = real_errno;
  719. X    }
  720. X
  721. X    perror(string);
  722. X}
  723. X
  724. Xvoid
  725. Xdie_with_err(format, name)
  726. X    char *format, *name;
  727. X{
  728. X    warn_with_err(format, name);
  729. X    exit(1);
  730. X}
  731. X
  732. X/*
  733. X * filename_hostname_expand(char **ps)
  734. X *
  735. X *    expand any '@'s in the specified string to the hostname.
  736. X *
  737. X *    Ex:   "xxx_@_xxx"  ---> "xxx_mentor.cc.purdue.edu_xxx"
  738. X */
  739. X
  740. Xstatic char hostname[MAXHOSTNAMELEN];
  741. X
  742. Xvoid
  743. Xfilename_hostname_expand(ps)
  744. X    char **ps;
  745. X{
  746. X    char *s = *ps;
  747. X    char outpath[MAXPATHLEN];
  748. X    char *pc;
  749. X
  750. X    if (! *hostname) {   /* we only need to do this once */
  751. X#ifndef GETHOSTNAME
  752. X    struct utsname sysinfo;
  753. X
  754. X    if (uname(&sysinfo) < 0)
  755. X    die_with_err("filename_hostname_expand: uname()", (char *) NULL);
  756. X
  757. X    (void) strcpy(hostname, sysinfo.nodename);
  758. X
  759. X#else     /* GETHOSTNAME */
  760. X
  761. X    /* get the hostname */
  762. X    if (gethostname(hostname, sizeof(hostname)) < 0)
  763. X    die_with_err("filename_hostname_expand: gethostname()", (char *) NULL);
  764. X
  765. X#endif     /* GETHOSTNAME */
  766. X    }
  767. X
  768. X    /* is there a '@' in the filename? */
  769. X    if ((pc = strchr(s, '@')) == NULL) {
  770. X    return;
  771. X    }
  772. X
  773. X    /* copy the first part of the string */
  774. X    (void) strncpy(outpath, s, pc-s);
  775. X
  776. X    /* strncpy() doesn't guarantee null-terminated strings! */
  777. X    outpath[pc-s] = '\0';
  778. X
  779. X    /* expand the '@' and copy the rest of the string */
  780. X    (void) strcat(outpath, hostname);
  781. X    (void) strcat(outpath, pc+1);
  782. X
  783. X    /* make our pointer point to the expanded string */
  784. X    if ((pc = (char *) malloc((unsigned int) (strlen(outpath) + 1))) == NULL)
  785. X    die_with_err("filename_hostname_expand: malloc()", (char *) NULL);
  786. X
  787. X    (void) strcpy(pc, outpath);
  788. X
  789. X    *ps = pc;
  790. X
  791. X    return;
  792. X}
  793. X
  794. X/*
  795. X * slash_count(char *pathname)
  796. X *
  797. X *    count the number of slashes in a given pathname.  This is used
  798. X *     to determine the priority of a given file entry when generating
  799. X *     the list of files.
  800. X */
  801. X
  802. Xint
  803. Xslash_count (pathname)
  804. X    char *pathname;
  805. X{
  806. X    register int count = 0;
  807. X    register char *pc;
  808. X
  809. X    for (pc = pathname; *pc; pc++ )
  810. X        if (*pc == '/')
  811. X            count++;
  812. X    return count;
  813. X}
  814. X
  815. X/*
  816. X * string_split_space(char *string, char *s, char *t)
  817. X *
  818. X *     given (string), place the first word into (s), and the rest of
  819. X *    into (t).
  820. X */
  821. X
  822. Xvoid
  823. Xstring_split_space (string, s, t)
  824. X    char *string;
  825. X    char *s;
  826. X    char *t;
  827. X{
  828. X    char *sp;
  829. X
  830. X    /*
  831. X     * (char *sp) = the first space.      s = {string[0..(sp-s-1)]}
  832. X     *                          t = {sp[1..end]}
  833. X     */
  834. X
  835. X    if ((sp = strchr(string, ' ')) == NULL) {
  836. X    fprintf(stderr, "string_split_space: string doesn't contain space!\n");
  837. X    exit(1);
  838. X    /* XXX - yikes!  this shouldn't be fatal!!!  */
  839. X    }
  840. X
  841. X    /* don't forget to null-terminate the string w/strncpy() */
  842. X    (void) strncpy(s, string, sp-string);
  843. X    s[sp-string] = '\0';
  844. X
  845. X    (void) strcpy(t, sp+1);
  846. X    return;
  847. X}
  848. X
  849. X/*
  850. X * int
  851. X * string_split_ch(char *string, char *s, char *t, char ch)
  852. X *
  853. X *     given (string), place the first word into (s), and the rest of
  854. X *    into (t), using (ch) as the field separator.  (ala perl).
  855. X */
  856. X
  857. Xint
  858. Xstring_split_ch (string, s, t, ch)
  859. X    char *string;
  860. X    char *s;
  861. X    char *t;
  862. X    char ch;
  863. X{
  864. X    char *sp;
  865. X
  866. X    /*
  867. X     * (char *sp) = the first space.      s = {string[0..(sp-s-1)]}
  868. X     *                          t = {sp[1..end]}
  869. X     */
  870. X
  871. X    if ((sp = strchr(string, ch)) == NULL) {
  872. X    (void) strcpy(s, string);
  873. X    t[0] = '\0';
  874. X    return -1;
  875. X    }
  876. X
  877. X    /* don't forget to null-terminate the string w/strncpy() */
  878. X    (void) strncpy(s, string, sp-string);
  879. X    s[sp-string] = '\0';
  880. X
  881. X    (void) strcpy(t, sp+1);
  882. X    return 0;
  883. X}
  884. X
  885. X/*
  886. X * chop (char *s)
  887. X *
  888. X *    chop off the last character in a string, ala Perl.
  889. X */
  890. X
  891. Xvoid
  892. Xchop (s)
  893. X    char *s;
  894. X{
  895. X    int slen;
  896. X
  897. X    slen = strlen(s);
  898. X    s[slen-1] = '\0';
  899. X    return;
  900. X}
  901. X
  902. X/*
  903. X * filename_escape_expand(char *filename)
  904. X *
  905. X *    expand \xxx octal characters, metachacters, and known
  906. X *    C escape sequences.
  907. X */
  908. X
  909. Xvoid
  910. Xfilename_escape_expand (filename)
  911. X    char *filename;
  912. X{
  913. X    int i = 0;
  914. X    char filetmp[MAXPATHLEN];
  915. X    int octal;
  916. X    register char *pcin = filename, *pcout = filetmp;
  917. X
  918. X    /*
  919. X     * case I:    it's not escaped
  920. X     * case II:     it's a three digit octal number
  921. X     * case III:    it's a standard C escape sequence
  922. X     *                (\n, \r, \', \", \t, \b, \f)
  923. X     *            (from Johnson, Stephen C.,
  924. X     *                "Yacc: Yet Another Compiler-Compiler")
  925. X     * case IV:    it's one of our metacharacters {@#!|&()= }
  926. X     */
  927. X
  928. X    while (*pcin) {
  929. X
  930. X    /* case I: it's not an escape */
  931. X    if (*pcin != '\\')
  932. X        *pcout++ = *pcin++;
  933. X
  934. X    /* case II: it's a three digit octal number */
  935. X    else if (isdigit(*++pcin)) {
  936. X        /* read in the three characters */
  937. X        for (octal = i = 0; i < 3 ; i++, pcin++) {
  938. X        octal *= 8;
  939. X        
  940. X        if (*pcin > '7' || *pcin < '0') {
  941. X            fprintf(stderr,
  942. X                "filename_escape_expand: bogus octal character (%c) in file `%s'!\n",
  943. X                *pcin, filename);
  944. X            exit(1);
  945. X        }
  946. X        else
  947. X          octal += *pcin-'0';
  948. X        }
  949. X
  950. X        /* warn of filenames with null's in them */
  951. X        if (octal == 0) {
  952. X        fprintf(stderr, "tripwire: warning: null character in file `%s'!\n",  filename);
  953. X        exit(1);
  954. X        }
  955. X
  956. X        *pcout++ = octal & 0xff;
  957. X    }
  958. X
  959. X    /* case III: it's a standard C escape sequence */
  960. X    /* case IV: it's one of our escape characters */
  961. X    else
  962. X        switch(*pcin) {
  963. X        case 'n':        { *pcout++ = '\n'; break; }
  964. X        case 'r':        { *pcout++ = '\r'; break; }
  965. X        case 't':        { *pcout++ = '\t'; break; }
  966. X        case 'b':        { *pcout++ = '\b'; break; }
  967. X        case 'f':        { *pcout++ = '\f'; break; }
  968. X        case '\'':        
  969. X        case '"':        
  970. X        case '@':
  971. X        case '!':
  972. X        case '#':
  973. X        case '=':
  974. X        case ' ':
  975. X        case ')':
  976. X        case '(':
  977. X        case '&':
  978. X        case '|':
  979. X        case '\\':
  980. X          /* same as our default case... it's the character itself */
  981. X        default:         { *pcout++ = *pcin++; break; }
  982. X      }
  983. X    }
  984. X
  985. X
  986. X    /* null terminate the string */
  987. X    *pcout++ = '\0';
  988. X
  989. X    (void) memcpy(filename, filetmp, pcout - filetmp);
  990. X    return;
  991. X}
  992. X
  993. X/*
  994. X * filename_escape(char *filename)
  995. X *
  996. X *    find any characters that must be escaped in the file name.
  997. X */
  998. X
  999. Xvoid
  1000. Xfilename_escape (filename)
  1001. X    char *filename;
  1002. X{
  1003. X    char filetmp[MAXPATHLEN];
  1004. X    register char *pcin = filename, *pcout = filetmp;
  1005. X    static char *octal_array[] = {
  1006. X    "000", "001", "002", "003", "004", "005", "006", "007",
  1007. X    "010", "011", "012", "013", "014", "015", "016", "017",
  1008. X    "020", "021", "022", "023", "024", "025", "026", "027",
  1009. X    "030", "031", "032", "033", "034", "035", "036", "037",
  1010. X    "040", "041", "042", "043", "044", "045", "046", "047",
  1011. X    "050", "051", "052", "053", "054", "055", "056", "057",
  1012. X    "060", "061", "062", "063", "064", "065", "066", "067",
  1013. X    "070", "071", "072", "073", "074", "075", "076", "077",
  1014. X    "100", "101", "102", "103", "104", "105", "106", "107",
  1015. X    "110", "111", "112", "113", "114", "115", "116", "117",
  1016. X    "120", "121", "122", "123", "124", "125", "126", "127",
  1017. X    "130", "131", "132", "133", "134", "135", "136", "137",
  1018. X    "140", "141", "142", "143", "144", "145", "146", "147",
  1019. X    "150", "151", "152", "153", "154", "155", "156", "157",
  1020. X    "160", "161", "162", "163", "164", "165", "166", "167",
  1021. X    "170", "171", "172", "173", "174", "175", "176", "177",
  1022. X    };
  1023. X    register char *pccopy;
  1024. X
  1025. X    /* these only matter if they are the first character */
  1026. X    if (*pcin == '!' || *pcin == '=' || *pcin == '#')    
  1027. X    { *pcout++ = '\\'; *pcout++ = *pcin++; }
  1028. X
  1029. X    /* these must be replace everywhere in the filename */
  1030. X    while (*pcin) {
  1031. X    if (isalnum(*pcin))
  1032. X        *pcout++ = *pcin;
  1033. X    else
  1034. X        switch(*pcin) {
  1035. X          case '\\':
  1036. X          case '\n':
  1037. X          case '\r':
  1038. X          case '\t':
  1039. X          case '\b':
  1040. X          case '\f':
  1041. X          case '\'':
  1042. X          case '\"':
  1043. X          case '@':
  1044. X          case ' ':
  1045. X          case '(':
  1046. X          case ')':
  1047. X          case '&':
  1048. X          case '|':
  1049. X          case '#':
  1050. X        *pcout++ = '\\';
  1051. X        *pcout++ = *(pccopy = octal_array[*pcin]);
  1052. X        *pcout++ = *++pccopy;
  1053. X        *pcout++ = *++pccopy;
  1054. X        break;
  1055. X        default:
  1056. X        *pcout++ = *pcin;
  1057. X        break;
  1058. X        }
  1059. X    pcin++;
  1060. X    }
  1061. X
  1062. X    /* null terminate the string */
  1063. X    *pcout++ = '\0';
  1064. X
  1065. X    (void) memcpy(filename, filetmp, pcout - filetmp);
  1066. X}
  1067. X
  1068. X/*
  1069. X * lto64(long num, char *vec64)
  1070. X *
  1071. X *    convert a long integer to a base-64 string.
  1072. X *
  1073. X *    we return the pointer to the string containing the base-64 number.
  1074. X *    the string will always be padded so it is 6 bytes.
  1075. X *
  1076. X *    REMEMBER: this is also used in the signature routines
  1077. X */
  1078. X
  1079. Xstatic char base64vec[] =
  1080. X  "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  1081. X
  1082. Xchar *
  1083. Xltob64(num, vec64)
  1084. X    register unsigned long num;
  1085. X    char *vec64;
  1086. X{
  1087. X    register char *p1 = vec64;
  1088. X    register int i;
  1089. X
  1090. X
  1091. X    /* build lsb -> msb */
  1092. X    for (i = 5; i >= 0; i--) {
  1093. X        p1[i] = base64vec[num & 0x3f];
  1094. X    num >>= 6;
  1095. X    }
  1096. X
  1097. X    vec64[6] = 0;
  1098. X
  1099. X    return vec64;
  1100. X}
  1101. X
  1102. X/*
  1103. X * long
  1104. X * b64toi(char *vec)
  1105. X *
  1106. X *    given a base-64 string, convert to a long.
  1107. X */
  1108. X
  1109. Xlong
  1110. Xb64tol(vec)
  1111. X    char *vec;
  1112. X{
  1113. X    register char *pc;
  1114. X    register long num = 0L;
  1115. X
  1116. X/*  The following takes advantage of the fact that
  1117. X *  the ASCII collating sequence has  . / 0 1 2 3...9
  1118. X *  all in sequence.  Your milage may vary on other systems.
  1119. X *
  1120. X *  The string is interpreted as base 64 even if it isn't :-)
  1121. X */
  1122. X
  1123. X    for (pc = vec; *pc; pc++) {
  1124. X    num <<= 6;
  1125. X    num += *pc;
  1126. X    
  1127. X    if (*pc <= '9')     
  1128. X      num -= '.';
  1129. X    else if (*pc <= 'Z')
  1130. X      num -= '5';  /* '5' == 'A' - 12 */
  1131. X    else
  1132. X      num -= ';';  /* ';' == 'a' - 38 */
  1133. X    }
  1134. X
  1135. X    return num;
  1136. X}
  1137. X
  1138. X/*
  1139. X * direntry_print(char *name, struct stat stabuf))
  1140. X *
  1141. X *    print out a pretty directory entry for the specified file
  1142. X *
  1143. X *    this routine was taken from crc_check.c, written by Jon Zeeff
  1144. X *    (zeeff@b-tech.ann-arbor.mi.us)
  1145. X *
  1146. X *    hacked for use in Tripwire by Gene Kim (genek@mentor.cc.purdue.edu).
  1147. X */
  1148. X
  1149. Xvoid
  1150. Xdirentry_print (name, statbuf, mode)
  1151. X    char *name;
  1152. X    struct stat statbuf;
  1153. X    int mode;
  1154. X{
  1155. X    struct passwd *entry;
  1156. X    static char owner[20];
  1157. X    char    a_time[50];
  1158. X
  1159. X    static int prev_uid = -9999;
  1160. X
  1161. X    switch(mode) {
  1162. X    case DIFF_ADDED:
  1163. X        printf("added:   "); break;
  1164. X    case DIFF_CHANGED:
  1165. X        printf("changed: "); break;
  1166. X    case DIFF_DELETED:
  1167. X        printf("deleted: "); break;
  1168. X    }
  1169. X
  1170. X    if (statbuf.st_uid != prev_uid) {
  1171. X        entry = (struct passwd *)getpwuid((int) statbuf.st_uid);
  1172. X        if (entry)
  1173. X            (void) strcpy(owner, entry->pw_name);
  1174. X        else
  1175. X            (void) sprintf(owner, "%d", statbuf.st_uid);
  1176. X        prev_uid = statbuf.st_uid;
  1177. X    }
  1178. X    /*
  1179. X    if (statbuf.st_gid != prev_gid) {
  1180. X        group_entry = getgrgid((int) statbuf.st_gid);
  1181. X        if (group_entry)
  1182. X            (void) strcpy(group, group_entry->gr_name);
  1183. X        else
  1184. X            (void) sprintf(group, "%d", statbuf.st_gid);
  1185. X        prev_gid = statbuf.st_gid;
  1186. X    }
  1187. X    */
  1188. X
  1189. X    (void) strcpy(a_time, ctime(&statbuf.st_mtime));
  1190. X    a_time[24] = '\0';
  1191. X
  1192. X    print_perm((unsigned long)statbuf.st_mode);
  1193. X
  1194. X    (void) printf(" %-9.9s %7d %s", owner, statbuf.st_size,
  1195. X                        a_time + 4);
  1196. X    printf(" %s\n", name);
  1197. X
  1198. X}
  1199. X
  1200. X/*    
  1201. X *    This routine was taken from crc_check.c, written by Jon Zeeff
  1202. X *    (zeeff@b-tech.ann-arbor.mi.us)
  1203. X *
  1204. X *    hacked for use in Tripwire by Gene Kim (genek@mentor.cc.purdue.edu).
  1205. X */
  1206. X
  1207. Xstatic void
  1208. Xprint_perm(perm)
  1209. X    unsigned long perm;
  1210. X{
  1211. X
  1212. X    char    string[20];
  1213. X
  1214. X    (void) strcpy(string, "----------");
  1215. X
  1216. X    switch (perm & S_IFMT) {
  1217. X
  1218. X    case S_IFDIR:
  1219. X        string[0] = 'd';
  1220. X        break;
  1221. X
  1222. X    case S_IFBLK:
  1223. X        string[0] = 'b';
  1224. X        break;
  1225. X
  1226. X    case S_IFCHR:
  1227. X        string[0] = 'c';
  1228. X        break;
  1229. X
  1230. X    case S_IFIFO:
  1231. X        string[0] = 'p';
  1232. X        break;
  1233. X    }
  1234. X    if (perm & S_IREAD)
  1235. X        string[1] = 'r';
  1236. X    if (perm & S_IWRITE)
  1237. X        string[2] = 'w';
  1238. X    if (perm & S_ISUID && perm & S_IEXEC)
  1239. X        string[3] = 's';
  1240. X    else if (perm & S_IEXEC)
  1241. X        string[3] = 'x';
  1242. X    else if (perm & S_ISUID)
  1243. X        string[3] = 'S';
  1244. X
  1245. X    if (perm & S_IRGRP)
  1246. X        string[4] = 'r';
  1247. X    if (perm & S_IWGRP)
  1248. X        string[5] = 'w';
  1249. X    if (perm & S_ISUID && perm & S_IXGRP)
  1250. X        string[6] = 's';
  1251. X    else if (perm & S_IXGRP)
  1252. X        string[6] = 'x';
  1253. X    else if (perm & S_ISUID)
  1254. X        string[6] = 'l';
  1255. X
  1256. X    if (perm & S_IROTH)
  1257. X        string[7] = 'r';
  1258. X    if (perm & S_IWOTH)
  1259. X        string[8] = 'w';
  1260. X    if (perm & S_ISVTX && perm & S_IXOTH)
  1261. X        string[9] = 't';
  1262. X    else if (perm & S_IXOTH)
  1263. X        string[9] = 'x';
  1264. X    else if (perm & S_ISVTX)
  1265. X        string[9] = 'T';
  1266. X
  1267. X    (void) printf("%s", string);
  1268. X}
  1269. END_OF_FILE
  1270. if test 13384 -ne `wc -c <'tripwire-1.0/src/utils.c'`; then
  1271.     echo shar: \"'tripwire-1.0/src/utils.c'\" unpacked with wrong size!
  1272. fi
  1273. # end of 'tripwire-1.0/src/utils.c'
  1274. fi
  1275. if test -f 'tripwire-1.0/src/config.parse.c' -a "${1}" != "-c" ; then 
  1276.   echo shar: Will not clobber existing file \"'tripwire-1.0/src/config.parse.c'\"
  1277. else
  1278. echo shar: Extracting \"'tripwire-1.0/src/config.parse.c'\" \(13058 characters\)
  1279. sed "s/^X//" >'tripwire-1.0/src/config.parse.c' <<'END_OF_FILE'
  1280. X#ifndef lint
  1281. Xstatic char rcsid[] = "$Id: config.parse.c,v 1.2 92/11/03 02:43:33 genek Exp $";
  1282. X#endif
  1283. X
  1284. X/*
  1285. X * config.parse.c
  1286. X *
  1287. X *    read in the preen.config file
  1288. X *
  1289. X * Gene Kim
  1290. X * Purdue University
  1291. X */
  1292. X
  1293. X#include "../include/config.h"
  1294. X#include <stdio.h>
  1295. X#ifdef STDLIBH
  1296. X#include <stdlib.h>
  1297. X#include <unistd.h>
  1298. X#endif
  1299. X#include <sys/param.h>
  1300. X#include <sys/types.h>
  1301. X#include <sys/stat.h>
  1302. X#ifdef DIRENT
  1303. X# include <dirent.h>
  1304. X#else
  1305. X# ifndef XENIX
  1306. X#  include <sys/dir.h>
  1307. X# else        /* XENIX */
  1308. X#  include <sys/ndir.h>
  1309. X# endif        /* XENIX */
  1310. X#endif    /* DIRENT */
  1311. X#if (defined(SYSV) && (SYSV < 3))
  1312. X# include <limits.h>
  1313. X#endif    /* SVR2 */
  1314. X#include <ctype.h>
  1315. X#ifdef STRINGH
  1316. X#include <string.h>
  1317. X#else
  1318. X#include <strings.h>
  1319. X#endif
  1320. X#include "../include/list.h"
  1321. X#include "../include/tripwire.h"
  1322. X
  1323. X#if defined(SYSV) && (SYSV < 4)
  1324. X#ifndef HAVE_LSTAT
  1325. X#  define lstat(x,y) stat(x,y)
  1326. X#endif
  1327. X#endif        /* SYSV */
  1328. X
  1329. X#if !defined(major)
  1330. X#define major(x)        (((unsigned)(x)>>16)&0xffff)
  1331. X#endif
  1332. X#if !defined(minor)
  1333. X#define minor(x)        ((x)&0xffff)
  1334. X#endif
  1335. X
  1336. X/* prototypes */
  1337. Xchar *mktemp();
  1338. Xstatic void configfile_descend();
  1339. X
  1340. X#ifndef L_tmpnam
  1341. X# define L_tmpnam (unsigned int) MAXPATHLEN
  1342. X#endif
  1343. X
  1344. X/* global */
  1345. X/*        we keep track of all the entry headers */
  1346. Xstatic struct list *prune_list = (struct list *) NULL;
  1347. X
  1348. X/*
  1349. X * configfile_read(struct list **pp_list, struct list **pp_entry_list)
  1350. X *
  1351. X *    open the configuration file, and pulls out the {file/dir,ignore-flag}
  1352. X *    pairs.
  1353. X *
  1354. X *    (**pp_list) is pointer the head of the file list, where all the
  1355. X *    files are added to.
  1356. X */
  1357. X
  1358. Xvoid
  1359. Xconfigfile_read(pp_list, pp_entry_list)
  1360. X    struct list **pp_list;
  1361. X    struct list **pp_entry_list;
  1362. X{
  1363. X    FILE     *fpin, *fpout;
  1364. X    char    filename[MAXPATHLEN];
  1365. X    char    ignorestring[1024];
  1366. X    char    s[MAXPATHLEN+1024];
  1367. X    char    configfile[MAXPATHLEN];
  1368. X    char    *tmpfilename;
  1369. X    char    number[20];
  1370. X    int        entrynum = 0;
  1371. X    int        err;
  1372. X
  1373. X    /* don't print banner if we're in print-preprocessor mode */
  1374. X    if (!printpreprocess)
  1375. X    fputs("### Phase 1:   Reading configuration file\n", stderr);
  1376. X
  1377. X    /* generate temporary file name */
  1378. X    if ((tmpfilename = (char *) malloc(L_tmpnam)) == NULL) {
  1379. X    perror("configfile_read: malloc()");
  1380. X    exit(1);
  1381. X    };
  1382. X    (void) strcpy(tmpfilename, TEMPFILE_TEMPLATE);
  1383. X
  1384. X    if ((char *) mktemp(tmpfilename) == NULL) {
  1385. X    perror("database_build: mktemp()");
  1386. X    exit(1);
  1387. X    }
  1388. X
  1389. X    /* generate configuration file name */
  1390. X    if (specified_configfile == NULL)
  1391. X    sprintf(configfile, "%s/%s", config_path, config_file);
  1392. X    else
  1393. X    (void) strcpy(configfile, specified_configfile);
  1394. X
  1395. X    /* open the files */
  1396. X    /*        check to see if input is just stdin */
  1397. X    if (*configfile == '-' && !configfile[1]) {  /* configfile == "-" */
  1398. X    fpin = stdin;
  1399. X    }
  1400. X    else if ((fpin = fopen(configfile, "r")) == NULL) {
  1401. X    perror("configfile_read: fopen()");
  1402. X    exit(1);
  1403. X    }
  1404. X
  1405. X    err = umask(077);  /* to protect the tempfile */
  1406. X
  1407. X    if ((fpout = fopen(tmpfilename, "w+")) == NULL) {
  1408. X    perror("configfile_read: fopen()");
  1409. X    exit(1);
  1410. X    }
  1411. X    (void) umask(err);  /* return it to its former state */
  1412. X
  1413. X    /* The following unlink accomplishes two things:
  1414. X     *  1) if the program terminates, we won't leave a temp
  1415. X     *     file sitting around with potentially sensitive names
  1416. X     *     in it.
  1417. X     *  2) the file is "hidden" while we run
  1418. X     */
  1419. X    if (unlink(tmpfilename) < 0) {
  1420. X          perror("configfile_read: unlink()");
  1421. X    exit(1);
  1422. X    }
  1423. X
  1424. X
  1425. X    /*
  1426. X     * pass 0: preprocess file
  1427. X     *        call the yacc hook, located in y.tab.c
  1428. X     */
  1429. X
  1430. X    tw_macro_parse(configfile, fpin, fpout, (struct list **) pp_entry_list);
  1431. X
  1432. X    if (fpin != stdin)
  1433. X    (void) fclose(fpin);
  1434. X    if (fflush(fpout) == EOF) {
  1435. X        fputs("configfile_read: unknown error on fflush(fpout)\n", stderr);
  1436. X    exit(1);
  1437. X    }
  1438. X    else
  1439. X        rewind(fpout);
  1440. X
  1441. X    fpin = fpout;
  1442. X
  1443. X    /* do we just print out the file, and then exit? */
  1444. X    if (printpreprocess) {
  1445. X    int t;
  1446. X
  1447. X    while ((t = getc(fpin)) != EOF)
  1448. X      putc((char) t, stdout);
  1449. X    exit(0);    
  1450. X    }
  1451. X
  1452. X    /* pass 1: get all of the prune entries '!' */
  1453. X    while (fgets(s, sizeof(s), fpin) != NULL) {
  1454. X
  1455. X    int prune_mode;
  1456. X
  1457. X    /* read in database entry */
  1458. X    if ((err = sscanf(s, "%s %s", filename, ignorestring)) == 1) {
  1459. X        (void) strcpy(ignorestring, defaultignore);
  1460. X    }
  1461. X    else if (err != 2) {
  1462. X        fprintf(stderr, "'%s'\n", s);
  1463. X        fputs("configfile_read: parse error\n", stderr);
  1464. X
  1465. X        exit(1);
  1466. X    }
  1467. X
  1468. X    /* check for removeflag (preceding "!" or "=") */
  1469. X    switch (*filename) {
  1470. X          case '!':
  1471. X        prune_mode = PRUNE_ALL;
  1472. X        (void) strcpy(filename, filename+1);    /* adjust name */
  1473. X          break;
  1474. X        case '=':
  1475. X        prune_mode = PRUNE_ONE;
  1476. X        (void) strcpy(filename, filename+1);    /* adjust name */
  1477. X        break;
  1478. X        default:
  1479. X      continue; /* nothing */
  1480. X    }
  1481. X
  1482. X
  1483. X    /* check for fully qualified pathname
  1484. X     */
  1485. X    if (*filename != '/') {
  1486. X        fprintf(stderr,
  1487. X        "config: %s is not fully qualified!  Skipping...\n" ,
  1488. X            filename);
  1489. X        /* XXX -- error handling needed here */
  1490. X        continue;
  1491. X    }
  1492. X
  1493. X    /* expand any escaped octal characters in name */
  1494. X    filename_escape_expand(filename);
  1495. X
  1496. X    /* add to local prune list */
  1497. X    list_set(filename, "", 0, &prune_list);
  1498. X
  1499. X    /* set appropriate prune flag */
  1500. X    list_setflag(filename, prune_mode, &prune_list);
  1501. X    }
  1502. X
  1503. X    /* rewind the file for pass 2 */
  1504. X    rewind(fpin);
  1505. X
  1506. X    /* pass 2: build file lists */
  1507. X
  1508. X    /* it's time for another banner */
  1509. X    if (!printpreprocess)
  1510. X    fputs("### Phase 2:   Generating file list\n", stderr);
  1511. X
  1512. X    while (fgets(s, sizeof(s), fpin) != NULL) {
  1513. X    int    howdeep;
  1514. X    int    prunedir = 0;
  1515. X
  1516. X    /*
  1517. X     * get {filename,ignore} pair:
  1518. X     *     if only argument, then apply default ignore-flags
  1519. X     *
  1520. X     *    note that {ignore} used in the tripwire.config file is
  1521. X     *        different than the one stored in the database file!
  1522. X     *
  1523. X     *    humans use the [N|R|L]+/-[pinugsmc3] format.  in the database,
  1524. X     *        we use the old style where any capitalized letter
  1525. X     *        means it's to be ignored.
  1526. X     */
  1527. X
  1528. X    /* make sure to remember that the ignorestring could be a comment! */
  1529. X    if ( ((err = sscanf(s, "%s %s", filename, ignorestring)) == 1) ||
  1530. X            (ignorestring[0] == '#')) {
  1531. X        (void) strcpy(ignorestring, defaultignore);
  1532. X    }
  1533. X    else if (err != 2) {
  1534. X        fprintf(stderr, "'%s'\nconfigfile_read: parse error\n", s);
  1535. X
  1536. X        exit(1);
  1537. X    }
  1538. X
  1539. X    /* skip all prune entries (we've already taken care of it) */
  1540. X    if (*filename == '!')
  1541. X        continue;
  1542. X
  1543. X    /* check for leading '=', prune after one recursion */
  1544. X    else if (*filename == '=') {
  1545. X        (void) strcpy(filename, filename+1);
  1546. X        prunedir++;
  1547. X    }
  1548. X
  1549. X    /* check for fully qualified pathname
  1550. X     */
  1551. X    if (*filename != '/') {
  1552. X        fprintf(stderr,
  1553. X        "config: %s is not fully qualified!  Skipping...\n" ,
  1554. X            filename);
  1555. X        /* XXX -- error handling needed here */
  1556. X        continue;
  1557. X    }
  1558. X
  1559. X    /* expand any escaped octal characters in name */
  1560. X    filename_escape_expand(filename);
  1561. X
  1562. X    /* pass down the priority -- based on how fully-qualified the
  1563. X     *     entry was.
  1564. X     */
  1565. X    howdeep = slash_count(filename);
  1566. X
  1567. X    /*
  1568. X     * convert configuration-file style ignore-string to our database
  1569. X     * representation.
  1570. X     */
  1571. X    ignore_configvec_to_dvec(ignorestring);
  1572. X
  1573. X    /*
  1574. X     * add the entry to list of entry headers (used for incremental
  1575. X     * database updates.
  1576. X     */
  1577. X    
  1578. X    sprintf(number, "%d", entrynum);
  1579. X    list_set(filename, number, 0, pp_entry_list);
  1580. X
  1581. X    configfile_descend(filename, ignorestring, howdeep, prunedir,
  1582. X                    pp_list, entrynum++);
  1583. X    }                        /* end reading file */
  1584. X
  1585. X    /* print out the list, if we're in a debuggin mode */
  1586. X    if (debuglevel > 10)
  1587. X    list_print(pp_list);
  1588. X
  1589. X    /* clean up */
  1590. X    (void) fclose(fpin);
  1591. X
  1592. X    return;
  1593. X}
  1594. X
  1595. X/*
  1596. X * configfile_descend(char *filename, char *ignorestring, int howdeep,
  1597. X *                int prunedir, struct list **pp_list,
  1598. X *                int entrynum)
  1599. X *
  1600. X *    recurses down the specified filename.  when it finally hits a real
  1601. X *    file, it is added to the list of files.
  1602. X *    
  1603. X *    if (prunedir) is set, then we quit after one recursion.
  1604. X *
  1605. X *    this routine also resolves any multiple instances of a file by
  1606. X *    using (howdeep) as a precendence level.
  1607. X *
  1608. X *    (entrynum) is the unique entry number tag from tw.config.
  1609. X */
  1610. X
  1611. Xstatic void
  1612. Xconfigfile_descend (filename, ignorestring, howdeep,
  1613. X                prunedir, pp_list, entrynum)
  1614. X    char *filename;
  1615. X    char *ignorestring;
  1616. X    int howdeep;
  1617. X    int prunedir;
  1618. X    struct list **pp_list;
  1619. X    int entrynum;
  1620. X{
  1621. X    struct stat statbuf;
  1622. X    static int    countrecurse = 0;    /* count how many levels deep we are */
  1623. X    static int    majordev, minordev;
  1624. X    char t[512];
  1625. X    extern int  errno;
  1626. X
  1627. X    countrecurse++;
  1628. X
  1629. XSPDEBUG(10)
  1630. Xprintf("---> %d: %s\n", countrecurse, filename);
  1631. X
  1632. X    /* check to see if it's on the prune list */
  1633. X    if (list_lookup(filename, &prune_list) != NULL) {
  1634. X
  1635. X    int flag;
  1636. X
  1637. X    /* return only if it was a '!' directive */
  1638. X    if ((flag = list_getflag(filename, &prune_list)) == PRUNE_ALL) {
  1639. X        countrecurse--;
  1640. X        return;
  1641. X    }
  1642. X    else if (flag == PRUNE_ONE)
  1643. X        prunedir = 1;
  1644. X    }
  1645. X
  1646. X    /* get the stat structure of the (real) file */
  1647. X    if (lstat(filename, &statbuf) < 0) {
  1648. X    char err[MAXPATHLEN+64];
  1649. X        int real_err = errno;  /* in case sprintf clobbers the value */
  1650. X        
  1651. X    if (debuglevel > 10) {
  1652. X        sprintf(err, "configfile_descend: lstat(%s)", filename);
  1653. X    } else {
  1654. X        sprintf(err, "%s: %s", progname, filename);
  1655. X    }
  1656. X    errno = real_err;
  1657. X    perror(err);
  1658. X
  1659. X    /* so we just skip it */
  1660. X    countrecurse--;
  1661. X    return;
  1662. X    }
  1663. X
  1664. X    /*
  1665. X     * record our {major,minor} device pair if this is our first time
  1666. X     * recursing.  then we check if it changes.  if it does, we've crossed
  1667. X     * a filesystem, and we prune our tree.
  1668. X     */
  1669. X    if (countrecurse == 1) {
  1670. X
  1671. XSPDEBUG(4)
  1672. Xprintf("configfile_descend: r=%d: %s\n", countrecurse, filename);
  1673. X
  1674. X    majordev = major(statbuf.st_dev);
  1675. X    minordev = minor(statbuf.st_dev);
  1676. X    } else {
  1677. X    if (major(statbuf.st_dev) != majordev ||
  1678. X                    minor(statbuf.st_dev) != minordev) {
  1679. X
  1680. XSPDEBUG(4)
  1681. Xprintf("configfile_descend: pruning '%s' n(%d,%d) != o(%d, %d)\n", filename,
  1682. X            major(statbuf.st_dev), minor(statbuf.st_dev),
  1683. X            majordev, minordev);
  1684. X
  1685. X        countrecurse--;
  1686. X        return;
  1687. X        /* prune */
  1688. X    }
  1689. X    }
  1690. X
  1691. X    /*
  1692. X     * if it is a directory file, then we read in the directory entries
  1693. X     * and then recurse into the directory.
  1694. X     *
  1695. X     * remember, check to see if it's a symbolic link.  we never traverse
  1696. X     * them.
  1697. X     */
  1698. X    if (((statbuf.st_mode & S_IFMT) == S_IFDIR)
  1699. X
  1700. X#if !defined(SYSV) || (SYSV > 3)
  1701. X    && !((statbuf.st_mode & S_IFMT) == S_IFLNK))
  1702. X#else
  1703. X    )
  1704. X#endif
  1705. X    {
  1706. X    DIR *p_dir;
  1707. X
  1708. X#ifdef DIRENT
  1709. X    struct dirent *pd;
  1710. X#else
  1711. X    struct direct *pd;
  1712. X#endif
  1713. X
  1714. X    char recursefile[MAXPATHLEN];
  1715. X
  1716. X    /* handle prunedir flag */
  1717. X
  1718. X    /*
  1719. X     * concatenate entry number to the ignore-string
  1720. X     */
  1721. X
  1722. X    sprintf(t, "%d %s", entrynum, ignorestring);
  1723. X
  1724. X    /*
  1725. X     * just nix it from the list?
  1726. X     */
  1727. X
  1728. X    list_set(filename, t, howdeep, pp_list);
  1729. X    (void) list_setflag(filename, FLAG_NOOPEN, pp_list);
  1730. X
  1731. X    /* if it's a symbolic link, make sure we flag it as such! */
  1732. X
  1733. X#if !defined(SYSV) || (SYSV > 3)
  1734. X    if ((statbuf.st_mode & S_IFMT) == S_IFLNK) {
  1735. X        (void) list_setflag(filename, FLAG_SYMLINK, pp_list);
  1736. X    }
  1737. X#endif
  1738. X
  1739. X    if (prunedir) {
  1740. X        countrecurse--;
  1741. X        return;
  1742. X    }
  1743. X
  1744. XSPDEBUG(4)
  1745. Xfprintf(stderr, "configfile_descend: %s: it's a directory!\n", filename);
  1746. X
  1747. X    if ((p_dir = opendir(filename)) == NULL) {
  1748. X        if (debuglevel > 10) {
  1749. X        perror("configfile_descend: opendir()");
  1750. X        } else {
  1751. X        char err[MAXPATHLEN+64];
  1752. X        int real_errno = errno;
  1753. X        
  1754. X        sprintf(err, "%s: %s", progname, filename);
  1755. X        errno = real_errno;
  1756. X        perror(err);
  1757. X        }
  1758. X        countrecurse--;
  1759. X        return;
  1760. X    }
  1761. X
  1762. X
  1763. X/* broken xenix compiler returns "illegal continue" ?!? */
  1764. X#ifdef XENIX
  1765. X#define XCONTINUE goto XENIX_CONT
  1766. X#else
  1767. X#define XCONTINUE continue
  1768. X#endif
  1769. X
  1770. X    for (pd = readdir(p_dir); pd != NULL; pd = readdir(p_dir)) {
  1771. X        /* we could use strcmp in the following, but this is much faster */
  1772. X        if (pd->d_name[0] == '.') {
  1773. X          if (pd->d_name[1] == 0)    /* must be . */
  1774. X        XCONTINUE;
  1775. X          else if (pd->d_name[1] == '.') {
  1776. X        if (pd->d_name[2] == 0)  /* must be .. */
  1777. X          XCONTINUE;
  1778. X          }
  1779. X        }
  1780. X    
  1781. XSPDEBUG(4)
  1782. Xprintf("--> descend: %s\n", pd->d_name);
  1783. X
  1784. X        /* build pathname of file */
  1785. X        sprintf(recursefile, "%s/%s", filename, pd->d_name);
  1786. X
  1787. X        /* recurse.  it'll pop right back if it is just a file */
  1788. X        configfile_descend(recursefile, ignorestring, howdeep, 0,
  1789. X                    pp_list, entrynum);
  1790. X
  1791. XXENIX_CONT: ;
  1792. X    
  1793. X    }                     /* end foreach file */
  1794. X
  1795. X    /* cleanup */
  1796. X    closedir(p_dir);
  1797. X    }                        /* end if dir */
  1798. X    else {
  1799. X
  1800. X    /*
  1801. X     * concatenate entry number to the ignore-string
  1802. X     */
  1803. X
  1804. X    sprintf(t, "%d %s", entrynum, ignorestring);
  1805. X
  1806. X    /* add to list */
  1807. X    list_set(filename, t, howdeep, pp_list);
  1808. X
  1809. X    /*
  1810. X     * if it is a special file or device, add it to the list, but
  1811. X     * make sure we don't open it and read from it!
  1812. X     */
  1813. X    switch (statbuf.st_mode & S_IFMT) {
  1814. X      case S_IFIFO:
  1815. X      case S_IFCHR:
  1816. X      case S_IFBLK:
  1817. X#if !defined(SYSV) || (SYSV > 3)
  1818. X      case S_IFSOCK:
  1819. X#endif
  1820. X        (void) list_setflag(filename, FLAG_NOOPEN, pp_list);
  1821. X        break;
  1822. X#if !defined(SYSV) || (SYSV > 3)
  1823. X      case S_IFLNK:    /* if it's a symbolic link, make sure we flag it as such! */
  1824. X        (void) list_setflag(filename, FLAG_SYMLINK, pp_list);
  1825. X#endif
  1826. X        break;
  1827. X      default:
  1828. X        break;   /* do nothing for regular files */
  1829. X    }
  1830. X    }                        /* end else dir */
  1831. X
  1832. X    countrecurse--;
  1833. X    return;
  1834. X}
  1835. X
  1836. END_OF_FILE
  1837. if test 13058 -ne `wc -c <'tripwire-1.0/src/config.parse.c'`; then
  1838.     echo shar: \"'tripwire-1.0/src/config.parse.c'\" unpacked with wrong size!
  1839. fi
  1840. # end of 'tripwire-1.0/src/config.parse.c'
  1841. fi
  1842. if test -f 'tripwire-1.0/sigs/md5/md5.c' -a "${1}" != "-c" ; then 
  1843.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/md5/md5.c'\"
  1844. else
  1845. echo shar: Extracting \"'tripwire-1.0/sigs/md5/md5.c'\" \(10291 characters\)
  1846. sed "s/^X//" >'tripwire-1.0/sigs/md5/md5.c' <<'END_OF_FILE'
  1847. X/* $Id: md5.c,v 1.1.1.2 92/11/02 18:22:08 genek Exp $ */
  1848. X
  1849. X/***********************************************************************
  1850. X ** md5.c -- the source code for MD5 routines                         **
  1851. X ** RSA Data Security, Inc. MD5 Message-Digest Algorithm              **
  1852. X ** Created: 2/17/90 RLR                                              **
  1853. X ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version                   **
  1854. X ** Revised (for MD5): RLR 4/27/91                                    **
  1855. X ***********************************************************************
  1856. X ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.  **
  1857. X ** License to copy and use this software is granted provided that    **
  1858. X ** it is identified as the "RSA Data Security, Inc. MD5 Message-     **
  1859. X ** Digest Algorithm" in all material mentioning or referencing this  **
  1860. X ** software or this function.                                        **
  1861. X ** License is also granted to make and use derivative works          **
  1862. X ** provided that such works are identified as "derived from the RSA  **
  1863. X ** Data Security, Inc. MD5 Message-Digest Algorithm" in all          **
  1864. X ** material mentioning or referencing the derived work.              **
  1865. X ** RSA Data Security, Inc. makes no representations concerning       **
  1866. X ** either the merchantability of this software or the suitability    **
  1867. X ** of this software for any particular purpose.  It is provided "as  **
  1868. X ** is" without express or implied warranty of any kind.              **
  1869. X ** These notices must be retained in any copies of any part of this  **
  1870. X ** documentation and/or software.                                    **
  1871. X **********************************************************************/
  1872. X
  1873. X#include "md5.h"
  1874. X
  1875. X/* forward declaration */
  1876. Xstatic void Transform ();
  1877. X
  1878. Xstatic unsigned char PADDING[64] = {
  1879. X  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1880. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1881. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1882. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1883. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1884. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1885. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1886. X  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  1887. X};
  1888. X
  1889. X/* F, G, H and I are basic MD5 functions */
  1890. X#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
  1891. X#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
  1892. X#define H(x, y, z) ((x) ^ (y) ^ (z))
  1893. X#define I(x, y, z) ((y) ^ ((x) | (~z)))
  1894. X
  1895. X/* ROTATE_LEFT rotates x left n bits */
  1896. X#ifdef UNICOS
  1897. X# define ROTATE_LEFT(x,n) (((x) << (n)) | (((x) & 0xffffffff) >> (32-(n))))
  1898. X#else
  1899. X# define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
  1900. X#endif 
  1901. X
  1902. X/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
  1903. X/* Rotation is separate from addition to prevent recomputation */
  1904. X#define FF(a, b, c, d, x, s, ac) \
  1905. X  {(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
  1906. X   (a) = ROTATE_LEFT ((a), (s)); \
  1907. X   (a) += (b); \
  1908. X  }
  1909. X#define GG(a, b, c, d, x, s, ac) \
  1910. X  {(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
  1911. X   (a) = ROTATE_LEFT ((a), (s)); \
  1912. X   (a) += (b); \
  1913. X  }
  1914. X#define HH(a, b, c, d, x, s, ac) \
  1915. X  {(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
  1916. X   (a) = ROTATE_LEFT ((a), (s)); \
  1917. X   (a) += (b); \
  1918. X  }
  1919. X#define II(a, b, c, d, x, s, ac) \
  1920. X  {(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
  1921. X   (a) = ROTATE_LEFT ((a), (s)); \
  1922. X   (a) += (b); \
  1923. X  }
  1924. X
  1925. X/* The routine MD5Init initializes the message-digest context
  1926. X   mdContext. All fields are set to zero.  */
  1927. Xvoid MD5Init (mdContext)
  1928. XMD5_CTX *mdContext;
  1929. X{
  1930. X  mdContext->i[0] = mdContext->i[1] = (UINT4)0;
  1931. X
  1932. X  /* Load magic initialization constants.
  1933. X   */
  1934. X  mdContext->buf[0] = (UINT4)0x67452301;
  1935. X  mdContext->buf[1] = (UINT4)0xefcdab89;
  1936. X  mdContext->buf[2] = (UINT4)0x98badcfe;
  1937. X  mdContext->buf[3] = (UINT4)0x10325476;
  1938. X}
  1939. X
  1940. X/* The routine MD5Update updates the message-digest context to
  1941. X   account for the presence of each of the characters inBuf[0..inLen-1]
  1942. X   in the message whose digest is being computed.  */
  1943. Xvoid MD5Update (mdContext, inBuf, inLen)
  1944. XMD5_CTX *mdContext;
  1945. Xunsigned char *inBuf;
  1946. Xunsigned int inLen;
  1947. X{
  1948. X  UINT4 in[16];
  1949. X  int mdi;
  1950. X  unsigned int i, ii;
  1951. X
  1952. X  /* compute number of bytes mod 64 */
  1953. X  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
  1954. X
  1955. X  /* update number of bits */
  1956. X#ifndef UNICOS
  1957. X  if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
  1958. X#else
  1959. X  if (((mdContext->i[0]+((UINT4)inLen << 3)) & 0xffffffff) < mdContext->i[0])
  1960. X#endif
  1961. X
  1962. X    mdContext->i[1]++;
  1963. X
  1964. X  mdContext->i[0] += ((UINT4)inLen << 3);
  1965. X  mdContext->i[1] += ((UINT4)inLen >> 29);
  1966. X
  1967. X  while (inLen--) {
  1968. X    /* add new character to buffer, increment mdi */
  1969. X    mdContext->in[mdi++] = *inBuf++;
  1970. X
  1971. X    /* transform if necessary */
  1972. X    if (mdi == 0x40) {
  1973. X      for (i = 0, ii = 0; i < 16; i++, ii += 4)
  1974. X        in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
  1975. X                (((UINT4)mdContext->in[ii+2]) << 16) |
  1976. X                (((UINT4)mdContext->in[ii+1]) << 8) |
  1977. X                ((UINT4)mdContext->in[ii]);
  1978. X      Transform (mdContext->buf, in);
  1979. X      mdi = 0;
  1980. X    }
  1981. X  }
  1982. X}
  1983. X
  1984. X/* The routine MD5Final terminates the message-digest computation and
  1985. X   ends with the desired message digest in mdContext->digest[0...15].  */
  1986. Xvoid MD5Final (mdContext)
  1987. XMD5_CTX *mdContext;
  1988. X{
  1989. X  UINT4 in[16];
  1990. X  int mdi;
  1991. X  unsigned int i, ii;
  1992. X  unsigned int padLen;
  1993. X
  1994. X  /* save number of bits */
  1995. X  in[14] = mdContext->i[0];
  1996. X  in[15] = mdContext->i[1];
  1997. X
  1998. X  /* compute number of bytes mod 64 */
  1999. X  mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
  2000. X
  2001. X  /* pad out to 56 mod 64 */
  2002. X  padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
  2003. X  MD5Update (mdContext, PADDING, padLen);
  2004. X
  2005. X  /* append length in bits and transform */
  2006. X  for (i = 0, ii = 0; i < 14; i++, ii += 4)
  2007. X    in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
  2008. X            (((UINT4)mdContext->in[ii+2]) << 16) |
  2009. X            (((UINT4)mdContext->in[ii+1]) << 8) |
  2010. X            ((UINT4)mdContext->in[ii]);
  2011. X  Transform (mdContext->buf, in);
  2012. X
  2013. X  /* store buffer in digest */
  2014. X  for (i = 0, ii = 0; i < 4; i++, ii += 4) {
  2015. X    mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
  2016. X    mdContext->digest[ii+1] =
  2017. X      (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
  2018. X    mdContext->digest[ii+2] =
  2019. X      (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
  2020. X    mdContext->digest[ii+3] =
  2021. X      (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
  2022. X  }
  2023. X}
  2024. X
  2025. X/* Basic MD5 step. Transforms buf based on in.  */
  2026. Xstatic void Transform (buf, in)
  2027. XUINT4 *buf;
  2028. XUINT4 *in;
  2029. X{
  2030. X  UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
  2031. X
  2032. X  /* Round 1 */
  2033. X#define S11 7
  2034. X#define S12 12
  2035. X#define S13 17
  2036. X#define S14 22
  2037. X  FF ( a, b, c, d, in[ 0], S11, 0xd76aa478); /* 1 */
  2038. X  FF ( d, a, b, c, in[ 1], S12, 0xe8c7b756); /* 2 */
  2039. X  FF ( c, d, a, b, in[ 2], S13, 0x242070db); /* 3 */
  2040. X  FF ( b, c, d, a, in[ 3], S14, 0xc1bdceee); /* 4 */
  2041. X  FF ( a, b, c, d, in[ 4], S11, 0xf57c0faf); /* 5 */
  2042. X  FF ( d, a, b, c, in[ 5], S12, 0x4787c62a); /* 6 */
  2043. X  FF ( c, d, a, b, in[ 6], S13, 0xa8304613); /* 7 */
  2044. X  FF ( b, c, d, a, in[ 7], S14, 0xfd469501); /* 8 */
  2045. X  FF ( a, b, c, d, in[ 8], S11, 0x698098d8); /* 9 */
  2046. X  FF ( d, a, b, c, in[ 9], S12, 0x8b44f7af); /* 10 */
  2047. X  FF ( c, d, a, b, in[10], S13, 0xffff5bb1); /* 11 */
  2048. X  FF ( b, c, d, a, in[11], S14, 0x895cd7be); /* 12 */
  2049. X  FF ( a, b, c, d, in[12], S11, 0x6b901122); /* 13 */
  2050. X  FF ( d, a, b, c, in[13], S12, 0xfd987193); /* 14 */
  2051. X  FF ( c, d, a, b, in[14], S13, 0xa679438e); /* 15 */
  2052. X  FF ( b, c, d, a, in[15], S14, 0x49b40821); /* 16 */
  2053. X
  2054. X  /* Round 2 */
  2055. X#define S21 5
  2056. X#define S22 9
  2057. X#define S23 14
  2058. X#define S24 20
  2059. X  GG ( a, b, c, d, in[ 1], S21, 0xf61e2562); /* 17 */
  2060. X  GG ( d, a, b, c, in[ 6], S22, 0xc040b340); /* 18 */
  2061. X  GG ( c, d, a, b, in[11], S23, 0x265e5a51); /* 19 */
  2062. X  GG ( b, c, d, a, in[ 0], S24, 0xe9b6c7aa); /* 20 */
  2063. X  GG ( a, b, c, d, in[ 5], S21, 0xd62f105d); /* 21 */
  2064. X  GG ( d, a, b, c, in[10], S22,  0x2441453); /* 22 */
  2065. X  GG ( c, d, a, b, in[15], S23, 0xd8a1e681); /* 23 */
  2066. X  GG ( b, c, d, a, in[ 4], S24, 0xe7d3fbc8); /* 24 */
  2067. X  GG ( a, b, c, d, in[ 9], S21, 0x21e1cde6); /* 25 */
  2068. X  GG ( d, a, b, c, in[14], S22, 0xc33707d6); /* 26 */
  2069. X  GG ( c, d, a, b, in[ 3], S23, 0xf4d50d87); /* 27 */
  2070. X  GG ( b, c, d, a, in[ 8], S24, 0x455a14ed); /* 28 */
  2071. X  GG ( a, b, c, d, in[13], S21, 0xa9e3e905); /* 29 */
  2072. X  GG ( d, a, b, c, in[ 2], S22, 0xfcefa3f8); /* 30 */
  2073. X  GG ( c, d, a, b, in[ 7], S23, 0x676f02d9); /* 31 */
  2074. X  GG ( b, c, d, a, in[12], S24, 0x8d2a4c8a); /* 32 */
  2075. X
  2076. X  /* Round 3 */
  2077. X#define S31 4
  2078. X#define S32 11
  2079. X#define S33 16
  2080. X#define S34 23
  2081. X  HH ( a, b, c, d, in[ 5], S31, 0xfffa3942); /* 33 */
  2082. X  HH ( d, a, b, c, in[ 8], S32, 0x8771f681); /* 34 */
  2083. X  HH ( c, d, a, b, in[11], S33, 0x6d9d6122); /* 35 */
  2084. X  HH ( b, c, d, a, in[14], S34, 0xfde5380c); /* 36 */
  2085. X  HH ( a, b, c, d, in[ 1], S31, 0xa4beea44); /* 37 */
  2086. X  HH ( d, a, b, c, in[ 4], S32, 0x4bdecfa9); /* 38 */
  2087. X  HH ( c, d, a, b, in[ 7], S33, 0xf6bb4b60); /* 39 */
  2088. X  HH ( b, c, d, a, in[10], S34, 0xbebfbc70); /* 40 */
  2089. X  HH ( a, b, c, d, in[13], S31, 0x289b7ec6); /* 41 */
  2090. X  HH ( d, a, b, c, in[ 0], S32, 0xeaa127fa); /* 42 */
  2091. X  HH ( c, d, a, b, in[ 3], S33, 0xd4ef3085); /* 43 */
  2092. X  HH ( b, c, d, a, in[ 6], S34,  0x4881d05); /* 44 */
  2093. X  HH ( a, b, c, d, in[ 9], S31, 0xd9d4d039); /* 45 */
  2094. X  HH ( d, a, b, c, in[12], S32, 0xe6db99e5); /* 46 */
  2095. X  HH ( c, d, a, b, in[15], S33, 0x1fa27cf8); /* 47 */
  2096. X  HH ( b, c, d, a, in[ 2], S34, 0xc4ac5665); /* 48 */
  2097. X
  2098. X  /* Round 4 */
  2099. X#define S41 6
  2100. X#define S42 10
  2101. X#define S43 15
  2102. X#define S44 21
  2103. X  II ( a, b, c, d, in[ 0], S41, 0xf4292244); /* 49 */
  2104. X  II ( d, a, b, c, in[ 7], S42, 0x432aff97); /* 50 */
  2105. X  II ( c, d, a, b, in[14], S43, 0xab9423a7); /* 51 */
  2106. X  II ( b, c, d, a, in[ 5], S44, 0xfc93a039); /* 52 */
  2107. X  II ( a, b, c, d, in[12], S41, 0x655b59c3); /* 53 */
  2108. X  II ( d, a, b, c, in[ 3], S42, 0x8f0ccc92); /* 54 */
  2109. X  II ( c, d, a, b, in[10], S43, 0xffeff47d); /* 55 */
  2110. X  II ( b, c, d, a, in[ 1], S44, 0x85845dd1); /* 56 */
  2111. X  II ( a, b, c, d, in[ 8], S41, 0x6fa87e4f); /* 57 */
  2112. X  II ( d, a, b, c, in[15], S42, 0xfe2ce6e0); /* 58 */
  2113. X  II ( c, d, a, b, in[ 6], S43, 0xa3014314); /* 59 */
  2114. X  II ( b, c, d, a, in[13], S44, 0x4e0811a1); /* 60 */
  2115. X  II ( a, b, c, d, in[ 4], S41, 0xf7537e82); /* 61 */
  2116. X  II ( d, a, b, c, in[11], S42, 0xbd3af235); /* 62 */
  2117. X  II ( c, d, a, b, in[ 2], S43, 0x2ad7d2bb); /* 63 */
  2118. X  II ( b, c, d, a, in[ 9], S44, 0xeb86d391); /* 64 */
  2119. X
  2120. X  buf[0] += a;
  2121. X  buf[1] += b;
  2122. X  buf[2] += c;
  2123. X  buf[3] += d;
  2124. X}
  2125. X
  2126. END_OF_FILE
  2127. if test 10291 -ne `wc -c <'tripwire-1.0/sigs/md5/md5.c'`; then
  2128.     echo shar: \"'tripwire-1.0/sigs/md5/md5.c'\" unpacked with wrong size!
  2129. fi
  2130. # end of 'tripwire-1.0/sigs/md5/md5.c'
  2131. fi
  2132. if test -f 'tripwire-1.0/include/tripwire.h' -a "${1}" != "-c" ; then 
  2133.   echo shar: Will not clobber existing file \"'tripwire-1.0/include/tripwire.h'\"
  2134. else
  2135. echo shar: Extracting \"'tripwire-1.0/include/tripwire.h'\" \(7233 characters\)
  2136. sed "s/^X//" >'tripwire-1.0/include/tripwire.h' <<'END_OF_FILE'
  2137. X/* $Id: tripwire.h,v 1.2 92/11/03 02:47:05 genek Exp $ */
  2138. X
  2139. X/************************************************************************
  2140. X *
  2141. X *   All files in the distribution of Tripwire are Copyright 1992 by the
  2142. X *   Purdue Research Foundation of Purdue University.  All rights
  2143. X *   reserved.  Some individual files in this distribution may be covered
  2144. X *   by other copyrights, as noted in their embedded comments.
  2145. X *
  2146. X *   Redistribution and use in source and binary forms are permitted
  2147. X *   provided that this entire copyright notice is duplicated in all such
  2148. X *   copies, and that any documentation, announcements, and other
  2149. X *   materials related to such distribution and use acknowledge that the
  2150. X *   software was developed at Purdue University, W. Lafayette, IN by
  2151. X *   Gene Kim and Eugene Spafford.  No charge, other than an "at-cost"
  2152. X *   distribution fee, may be charged for copies, derivations, or
  2153. X *   distributions of this material without the express written consent
  2154. X *   of the copyright holder.  Neither the name of the University nor the
  2155. X *   names of the authors may be used to endorse or promote products
  2156. X *   derived from this material without specific prior written
  2157. X *   permission.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
  2158. X *   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
  2159. X *   IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR ANY PARTICULAR
  2160. X *   PURPOSE.
  2161. X *
  2162. X ************************************************************************/
  2163. X
  2164. X/*
  2165. X * tripwire.h
  2166. X *
  2167. X *    common definitions for Tripwire
  2168. X *
  2169. X * Gene Kim
  2170. X * Purdue University
  2171. X * October 18, 1992
  2172. X */
  2173. X
  2174. X/* version information */
  2175. X
  2176. X#define VERSION_NUM     "1.0"
  2177. X#define DB_VERSION_NUM    1
  2178. X
  2179. X/* For signature routines prototypes: */
  2180. X
  2181. X#include "../sigs/snefru/snefru.h"
  2182. X#include "../sigs/md5/md5.h"
  2183. X#include "../sigs/crc32/crc32.h"
  2184. X#include "../sigs/crc/crc.h"
  2185. X#include "../sigs/md2/md2.h"
  2186. X#include "../sigs/md4/md4.h"
  2187. X
  2188. X/* essential includes common to all sources files */
  2189. X
  2190. X#include <errno.h>
  2191. X
  2192. X
  2193. X/* get any missing inode typedefs */
  2194. X
  2195. X#include "../include/inode.h"
  2196. X
  2197. X/* database record format */
  2198. X/* filename: (entrynumber, ignorevec, st_mode, st_ino, st_nlink,
  2199. X *        st_uid, st_gid, st_size,
  2200. X *        ltob64(statbuf->st_atime, vec64_a),
  2201. X *        ltob64(statbuf->st_mtime, vec64_m),
  2202. X *        ltob64(statbuf->st_ctime, vec64_c), sig1, sig2);
  2203. X */
  2204. X
  2205. X# define DB_RECORD_FORMAT "%ld %s %lo %lu %lu %lu %lu %lu %s %s %s %s %s %s %s %s %s %s %s %s %s\n"
  2206. X#define DB_RECORD_FIELDS 21
  2207. X
  2208. X/* system defaults */
  2209. X
  2210. Xextern int db_version_num;
  2211. Xextern char *config_file;    
  2212. Xextern char *config_path;    
  2213. Xextern char *database_file;    
  2214. Xextern char *database_path;    
  2215. Xextern char tempdatabase_file[];
  2216. Xextern int debuglevel, verbosity, quiet, printpreprocess;
  2217. Xextern char *specified_dbasefile, *specified_configfile;
  2218. Xextern char *progname;
  2219. Xextern char *defaultignore;
  2220. Xextern char *db_record_format;
  2221. Xextern struct list *filelist;
  2222. Xextern struct list *toc_list;
  2223. Xextern char *version_num;
  2224. Xextern struct list *entry_list;
  2225. Xextern char backupfile[];
  2226. Xextern int printhex;
  2227. Xextern int runtimeignore;
  2228. X
  2229. X/* debugging verbosity */
  2230. X
  2231. X#define SPDEBUG(x) if (debuglevel > (x))
  2232. X
  2233. X#define TRUE 1
  2234. X#define FALSE 0
  2235. X
  2236. X#define SIG_MAX_LEN 200
  2237. X
  2238. X/* ignore vector flags */
  2239. X/*    note:  as an optimization, IGNORE_0 .. IGNORE_9 are ordered.
  2240. X *    do not change the ordering of these vectors!
  2241. X */
  2242. X
  2243. X#define IGNORE_P    0x1
  2244. X#define IGNORE_I    0x2
  2245. X#define IGNORE_N    0x4
  2246. X#define IGNORE_U    0x8
  2247. X#define IGNORE_G    0x10
  2248. X#define IGNORE_S    0x20
  2249. X#define IGNORE_A    0x40
  2250. X#define IGNORE_M    0x80
  2251. X#define IGNORE_C    0x100
  2252. X#define IGNORE_0    0x200
  2253. X#define IGNORE_1    0x400
  2254. X#define IGNORE_2    0x800
  2255. X#define IGNORE_3    0x1000
  2256. X#define IGNORE_4    0x2000
  2257. X#define IGNORE_5    0x4000
  2258. X#define IGNORE_6    0x8000
  2259. X#define IGNORE_7    0x10000
  2260. X#define IGNORE_8    0x20000
  2261. X#define IGNORE_9    0x40000
  2262. X#define IGNORE_0_9    (IGNORE_0|IGNORE_1|IGNORE_2|IGNORE_3|IGNORE_4|IGNORE_5|IGNORE_6|IGNORE_7|IGNORE_8|IGNORE_9)
  2263. X
  2264. X/* filelist flags */
  2265. X#define FLAG_CHANGED     1
  2266. X#define FLAG_NOOPEN    2
  2267. X#define FLAG_SYMLINK    4
  2268. X#define FLAG_SEEN    8
  2269. X#define FLAG_UPDATE    16
  2270. X
  2271. X/* prunelist flags */
  2272. X#define PRUNE_ALL    1
  2273. X#define PRUNE_ONE    2
  2274. X
  2275. X/* database_build() modes */
  2276. X
  2277. X#define DBASE_PERMANENT        0
  2278. X#define DBASE_TEMPORARY     1
  2279. X#define DBASE_UPDATE         2
  2280. X
  2281. X/* diff lists */
  2282. Xextern struct list *diff_added_list,
  2283. X           *diff_deleted_list,
  2284. X           *diff_changed_list;
  2285. Xextern int     diff_added_num,
  2286. X            diff_changed_num,
  2287. X        diff_deleted_num;
  2288. Xextern int    files_scanned_num;
  2289. X
  2290. X/* diff parsing */
  2291. X
  2292. Xstruct diff_bucket {
  2293. X    int     arg1, arg2, arg3, arg4;
  2294. X    int        diffmode;
  2295. X};
  2296. X
  2297. X/* diff_parsing() types */
  2298. X#define DIFF_SAME     0
  2299. X#define DIFF_CHANGED    1
  2300. X#define DIFF_ADDED    2
  2301. X#define DIFF_DELETED    3
  2302. X
  2303. X/* signature functions */
  2304. X#define NUM_SIGS    10
  2305. Xextern int (*pf_signatures[NUM_SIGS]) ();
  2306. Xextern char *signames[NUM_SIGS];
  2307. X
  2308. X/* prototypes */
  2309. X
  2310. X/*** Do not remove this line.  Protyping depends on it! ***/
  2311. X#if defined(__STDC__) || defined(__cplusplus)
  2312. X#define P_(s) s
  2313. X#else
  2314. X#define P_(s) ()
  2315. X#endif
  2316. X
  2317. X/* config.parse.c */
  2318. Xvoid configfile_read P_((struct list **pp_list, struct list **pp_entry_list));
  2319. X/* main.c */
  2320. Xint main P_((int argc, char *argv[]));
  2321. X/* list.c */
  2322. Xvoid list_set P_((char *pc_name, char *pc_value, int priority, struct list **pp_list));
  2323. Xchar *list_lookup P_((char *pc_name, struct list **pp_list));
  2324. Xint list_isthere P_((char *pc_name, struct list **pp_list));
  2325. Xvoid list_unset P_((char *pc_name, struct list **pp_list));
  2326. Xint list_setflag P_((char *pc_name, int flag, struct list **pp_list));
  2327. Xint list_getflag P_((char *pc_name, struct list **pp_list));
  2328. Xvoid list_print P_((struct list **pp_list));
  2329. Xvoid list_reset P_((struct list **pp_list));
  2330. Xint list_init P_((void));
  2331. Xint list_open P_((struct list **pp_list));
  2332. Xstruct list_elem *list_get P_((struct list **pp_list));
  2333. Xint list_close P_((struct list **pp_list));
  2334. X/* ignorevec.c */
  2335. Xint ignore_vec_to_scalar P_((char *s));
  2336. Xvoid ignore_configvec_to_dvec P_((char *s));
  2337. X/* dbase.build.c */
  2338. Xvoid database_build P_((struct list **pp_list, int mode, struct list **pp_entry_list));
  2339. X/* utils.c */
  2340. Xvoid warn_with_err P_((char *format, char *name));
  2341. Xvoid die_with_err P_((char *format, char *name));
  2342. Xvoid filename_hostname_expand P_((char **ps));
  2343. Xint slash_count P_((char *pathname));
  2344. Xvoid string_split_space P_((char *string, char *s, char *t));
  2345. Xint string_split_ch P_((char *string, char *s, char *t, int ch));
  2346. Xvoid chop P_((char *s));
  2347. Xvoid filename_escape_expand P_((char *filename));
  2348. Xvoid filename_escape P_((char *filename));
  2349. Xchar *ltob64 P_((register unsigned long num, char *vec64));
  2350. Xlong b64tol P_((char *vec));
  2351. Xvoid direntry_print P_((char *name, struct stat statbuf, int mode));
  2352. X/* preen.c */
  2353. Xvoid preen_gather P_((void));
  2354. Xvoid preen_update P_((char *entry));
  2355. X/* preen.interp.c */
  2356. Xvoid preen_interp P_((FILE *fpin));
  2357. X/* preen.report.c */
  2358. Xvoid preen_report P_((void));
  2359. X/* nullsig.c */
  2360. Xint sig_null_get P_((int fd_in, char *ps_signature, int siglen));
  2361. X/* config.prim.c */
  2362. Xvoid tw_mac_define P_((char *varname, char *varvalue));
  2363. Xchar *tw_mac_dereference P_((char *varname));
  2364. Xvoid tw_mac_undef P_((char *varname));
  2365. Xint tw_mac_ifdef P_((char *varname));
  2366. Xint tw_mac_ifhost P_((char *hostname));
  2367. X/* dbase.update.c */
  2368. Xvoid database_update_markentries P_((struct list **pp_list, int flagentry));
  2369. X/* config.pre.c */
  2370. Xvoid tw_macro_parse P_((char *filename, FILE *fpin, FILE *fpout, struct list **pp_entry_list));
  2371. END_OF_FILE
  2372. if test 7233 -ne `wc -c <'tripwire-1.0/include/tripwire.h'`; then
  2373.     echo shar: \"'tripwire-1.0/include/tripwire.h'\" unpacked with wrong size!
  2374. fi
  2375. # end of 'tripwire-1.0/include/tripwire.h'
  2376. fi
  2377. if test -f 'tripwire-1.0/sigs/crc/crc.h' -a "${1}" != "-c" ; then 
  2378.   echo shar: Will not clobber existing file \"'tripwire-1.0/sigs/crc/crc.h'\"
  2379. else
  2380. echo shar: Extracting \"'tripwire-1.0/sigs/crc/crc.h'\" \(77 characters\)
  2381. sed "s/^X//" >'tripwire-1.0/sigs/crc/crc.h' <<'END_OF_FILE'
  2382. X/* $Id: crc.h,v 1.1.1.2 92/11/02 18:20:43 genek Exp $ */
  2383. X
  2384. Xint sig_crc_get();
  2385. END_OF_FILE
  2386. if test 77 -ne `wc -c <'tripwire-1.0/sigs/crc/crc.h'`; then
  2387.     echo shar: \"'tripwire-1.0/sigs/crc/crc.h'\" unpacked with wrong size!
  2388. fi
  2389. # end of 'tripwire-1.0/sigs/crc/crc.h'
  2390. fi
  2391. echo shar: End of archive 4 \(of 8\).
  2392. cp /dev/null ark4isdone
  2393. MISSING=""
  2394. for I in 1 2 3 4 5 6 7 8 ; do
  2395.     if test ! -f ark${I}isdone ; then
  2396.     MISSING="${MISSING} ${I}"
  2397.     fi
  2398. done
  2399. if test "${MISSING}" = "" ; then
  2400.     echo You have unpacked all 8 archives.
  2401.     echo "Now read the README file"
  2402.     rm -f ark[1-9]isdone
  2403. else
  2404.     echo You still need to unpack the following archives:
  2405.     echo "        " ${MISSING}
  2406. fi
  2407. ##  End of shell archive.
  2408. exit 0
  2409. -- 
  2410. Gene Spafford
  2411. Software Engineering Research Center & Dept. of Computer Sciences
  2412. Purdue University, W. Lafayette IN 47907-1398
  2413. Internet:  spaf@cs.purdue.edu    phone:  (317) 494-7825
  2414.