1 | /* SAMHAIN file system integrity testing */
|
---|
2 | /* Copyright (C) 1999 Rainer Wichmann */
|
---|
3 | /* */
|
---|
4 | /* This program is free software; you can redistribute it */
|
---|
5 | /* and/or modify */
|
---|
6 | /* it under the terms of the GNU General Public License as */
|
---|
7 | /* published by */
|
---|
8 | /* the Free Software Foundation; either version 2 of the License, or */
|
---|
9 | /* (at your option) any later version. */
|
---|
10 | /* */
|
---|
11 | /* This program is distributed in the hope that it will be useful, */
|
---|
12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
---|
13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
---|
14 | /* GNU General Public License for more details. */
|
---|
15 | /* */
|
---|
16 | /* You should have received a copy of the GNU General Public License */
|
---|
17 | /* along with this program; if not, write to the Free Software */
|
---|
18 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
---|
19 |
|
---|
20 |
|
---|
21 | #ifndef SH_HASH_H
|
---|
22 | #define SH_HASH_H
|
---|
23 |
|
---|
24 | #include <limits.h>
|
---|
25 |
|
---|
26 | #include "samhain.h"
|
---|
27 | #include "sh_unix.h"
|
---|
28 | #include "sh_error.h"
|
---|
29 |
|
---|
30 | /* format a uint64
|
---|
31 | */
|
---|
32 | char * sh_hash_size_format(void);
|
---|
33 |
|
---|
34 | /* report on a missing file
|
---|
35 | */
|
---|
36 | int hashreport_missing( char *fullpath, int level);
|
---|
37 |
|
---|
38 | /* write database to stdout
|
---|
39 | */
|
---|
40 | int sh_hash_pushdata_stdout (const char * str);
|
---|
41 |
|
---|
42 | /* version string for database
|
---|
43 | */
|
---|
44 | int sh_hash_version_string(const char * str);
|
---|
45 |
|
---|
46 | /* List database content
|
---|
47 | */
|
---|
48 | int sh_hash_list_db (const char * db_file);
|
---|
49 |
|
---|
50 | /* List database content for a single file
|
---|
51 | */
|
---|
52 | int set_list_file (const char * c);
|
---|
53 |
|
---|
54 | /* List database content with full detail
|
---|
55 | */
|
---|
56 | int set_full_detail (const char * c);
|
---|
57 |
|
---|
58 | /* List database content with full detail, comma delimited
|
---|
59 | */
|
---|
60 | int set_list_delimited (const char * c);
|
---|
61 |
|
---|
62 | /* Read the database from disk.
|
---|
63 | */
|
---|
64 | void sh_hash_init (void);
|
---|
65 |
|
---|
66 | /* Check whether a file is present in the database.
|
---|
67 | */
|
---|
68 | int sh_hash_have_it (char * newname);
|
---|
69 |
|
---|
70 | /* Get a file if it is present in the database.
|
---|
71 | */
|
---|
72 | int sh_hash_get_it (char * newname, file_type * tmpFile);
|
---|
73 |
|
---|
74 | /* Delete the database from memory.
|
---|
75 | */
|
---|
76 | void sh_hash_hashdelete (void);
|
---|
77 |
|
---|
78 | /* Insert a file into the database.
|
---|
79 | */
|
---|
80 | void sh_hash_pushdata (file_type * buf, char * fileHash);
|
---|
81 |
|
---|
82 | /* reset sh_hash_pushdata to use 'update' in daemon mode
|
---|
83 | */
|
---|
84 | void sh_hash_pushdata_reset (void);
|
---|
85 |
|
---|
86 | /* Insert a file into the in-memory database.
|
---|
87 | */
|
---|
88 | void sh_hash_pushdata_memory (file_type * theFile, char * fileHash);
|
---|
89 |
|
---|
90 | /* Get file flags from in-memory database
|
---|
91 | */
|
---|
92 | int sh_hash_getflags (char * filename);
|
---|
93 |
|
---|
94 | /* Set file flags in in-memory database
|
---|
95 | */
|
---|
96 | int sh_hash_setflags (char * filename, int flags);
|
---|
97 |
|
---|
98 | /* Set a file flag in in-memory database
|
---|
99 | */
|
---|
100 | void sh_hash_addflag (char * filename, int flag);
|
---|
101 |
|
---|
102 | /* Compare a file with its status in the database.
|
---|
103 | */
|
---|
104 | int sh_hash_compdata (int class, file_type * theFile, char * fileHash,
|
---|
105 | char * policy_override, int severity_override);
|
---|
106 |
|
---|
107 | /* Search for files in the database that have been deleted from disk.
|
---|
108 | */
|
---|
109 | void sh_hash_unvisited (ShErrLevel level);
|
---|
110 |
|
---|
111 | /* Set a file's status to 'visited'. This is required for
|
---|
112 | * files that should be ignored, and may be present in the
|
---|
113 | * database, but not on disk.
|
---|
114 | */
|
---|
115 | int sh_hash_set_visited (char * newname);
|
---|
116 |
|
---|
117 | /* As above, but only set the 'visited' flag
|
---|
118 | */
|
---|
119 | int sh_hash_set_visited_true (char * newname);
|
---|
120 |
|
---|
121 | /* cause the record to be deleted without a 'missing' message
|
---|
122 | */
|
---|
123 | int sh_hash_set_missing (char * newname);
|
---|
124 |
|
---|
125 | /* Make a complete directory tree invisible
|
---|
126 | */
|
---|
127 | int hash_remove_tree (char * s);
|
---|
128 |
|
---|
129 | /* Make every entry visible
|
---|
130 | */
|
---|
131 | int hash_full_tree (void);
|
---|
132 |
|
---|
133 | /* Insert data
|
---|
134 | */
|
---|
135 | void sh_hash_push2db (char * key, unsigned long val1,
|
---|
136 | unsigned long val2, unsigned long val3,
|
---|
137 | unsigned char * str, int size);
|
---|
138 |
|
---|
139 | /* Retrieve data
|
---|
140 | */
|
---|
141 | char * sh_hash_db2pop (char * key, unsigned long * val1,
|
---|
142 | unsigned long * val2, unsigned long * val3,
|
---|
143 | int * size);
|
---|
144 |
|
---|
145 | /* Write out database
|
---|
146 | */
|
---|
147 | int sh_hash_writeout(void);
|
---|
148 | #endif
|
---|