| 1 | /* |
| 2 | * AIDE (Advanced Intrusion Detection Environment) |
| 3 | * |
| 4 | * Copyright (C) 1999-2007, 2010-2013, 2016, 2018-2025 Rami Lehti, |
| 5 | * Pablo Virolainen, Mike Markley, Richard van den Berg, |
| 6 | * Hannes von Haugwitz |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of the |
| 11 | * License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #include "config.h"cxx . . $ `<file>/include/config.h`/ |
| 24 | #include "aide.h"cxx . . $ `<file>/include/aide.h`/ |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <stdio.h> |
| 29 | #include <time.h> |
| 30 | #include <stdarg.h> |
| 31 | #include <stdbool.h> |
| 32 | #include <unistd.h> |
| 33 | #include "db_config.h"cxx . . $ `<file>/include/db_config.h`/ |
| 34 | #include "gen_list.h"cxx . . $ `<file>/include/gen_list.h`/ |
| 35 | #include "hashsum.h"cxx . . $ `<file>/include/hashsum.h`/ |
| 36 | #include "log.h"cxx . . $ `<file>/include/log.h`/ |
| 37 | #include "progress.h"cxx . . $ `<file>/include/progress.h`/ |
| 38 | #include "url.h"cxx . . $ `<file>/include/url.h`/ |
| 39 | #include "db.h"cxx . . $ `<file>/include/db.h`/ |
| 40 | #ifdef WITH_CURL |
| 41 | #include "fopen.h" |
| 42 | #endif |
| 43 | |
| 44 | #include "attributes.h"cxx . . $ `<file>/include/attributes.h`/ |
| 45 | |
| 46 | #include <errno.h> |
| 47 | |
| 48 | #include "base64.h"cxx . . $ `<file>/include/base64.h`/ |
| 49 | #include "db_line.h"cxx . . $ `<file>/include/db_line.h`/ |
| 50 | #include "db_file.h"cxx . . $ `<file>/include/db_file.h`/ |
| 51 | #include "util.h"cxx . . $ `<file>/include/util.h`/ |
| 52 | #include "errorcodes.h"cxx . . $ `<file>/include/errorcodes.h`/ |
| 53 | |
| 54 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 55 | #include <zlib.h> |
| 56 | #endif |
| 57 | |
| 58 | #define BUFSIZEcxx . . $ `src/db_file.c:58:9`! 16384 |
| 59 | |
| 60 | #include "md.h"cxx . . $ `<file>/include/md.h`/ |
| 61 | |
| 62 | |
| 63 | |
| 64 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! db_parse_speccxx . . $ db_parse_spec(b27ce90c5996ec8a).(databasecxx . . $ database#* db, char **saveptr){ |
| 65 | char *token = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 66 | |
| 67 | DB_ATTR_TYPEcxx . . $ `include/attributes.h:25:9`! seen_attrs = 0LLU; |
| 68 | |
| 69 | db->fieldscxx . . $ database#fields. = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(1*sizeof(ATTRIBUTEcxx . . $ ATTRIBUTE#)); |
| 70 | |
| 71 | while ((token = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, " ", saveptr)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 72 | if (strncmpcxx . . $ strncmp(fd278af2f295fa2e).("@@", token, 2) == 0) { |
| 73 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_ERROR, "unexpected token while reading db_spec: '%s'", token); |
| 74 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 75 | } else { |
| 76 | ATTRIBUTEcxx . . $ ATTRIBUTE# l; |
| 77 | db->fieldscxx . . $ database#fields. = checked_realloccxx . . $ checked_realloc(417ab160f6baadc6).(db->fieldscxx . . $ database#fields., (db->num_fieldscxx . . $ database#num_fields.+1)*sizeof(ATTRIBUTEcxx . . $ ATTRIBUTE#)); |
| 78 | db->fieldscxx . . $ database#fields.[db->num_fieldscxx . . $ database#num_fields.]=attr_unknowncxx . . $ attr_unknown.; |
| 79 | for (l=0;l<num_attrscxx . . $ num_attrs.;l++){ |
| 80 | if (attributescxx . . $ attributes.[l].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name. && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(attributescxx . . $ attributes.[l].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name.,token)==0) { |
| 81 | if (ATTRcxx . . $ `include/attributes.h:28:9`!(l)&seen_attrs) { |
| 82 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "@@db_spec: skip redefined field '%s' at position %i", token, db->num_fields) |
| 83 | db->fieldscxx . . $ database#fields.[db->num_fieldscxx . . $ database#num_fields.]=attr_unknowncxx . . $ attr_unknown.; |
| 84 | } else { |
| 85 | db->fieldscxx . . $ database#fields.[db->num_fieldscxx . . $ database#num_fields.]=l; |
| 86 | seen_attrs |= ATTRcxx . . $ `include/attributes.h:28:9`!(l); |
| 87 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_DEBUG, "@@db_spec: define field '%s' at position %i", token, db->num_fields) |
| 88 | } |
| 89 | db->num_fieldscxx . . $ database#num_fields.++; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | if(l==attr_unknowncxx . . $ attr_unknown.){ |
| 94 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "@@db_spec: skip unknown field '%s' at position %i", token, db->num_fields); |
| 95 | db->fieldscxx . . $ database#fields.[db->num_fieldscxx . . $ database#num_fields.]=attr_unknowncxx . . $ attr_unknown.; |
| 96 | db->num_fieldscxx . . $ database#num_fields.++; |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /* Lets generate attr from db_order if database does not have attr */ |
| 102 | confcxx . . $ conf.->attrcxx . . $ db_config#attr.=DB_ATTR_UNDEFcxx . . $ `include/attributes.h:26:9`!; |
| 103 | |
| 104 | for (int i=0;i<db->num_fieldscxx . . $ database#num_fields.;i++) { |
| 105 | if (db->fieldscxx . . $ database#fields.[i] == attr_attrcxx . . $ attr_attr.) { |
| 106 | confcxx . . $ conf.->attrcxx . . $ db_config#attr.=1; |
| 107 | } |
| 108 | } |
| 109 | if (confcxx . . $ conf.->attrcxx . . $ db_config#attr.==DB_ATTR_UNDEFcxx . . $ `include/attributes.h:26:9`!) { |
| 110 | confcxx . . $ conf.->attrcxx . . $ db_config#attr.=0; |
| 111 | for(int i=0;i<db->num_fieldscxx . . $ database#num_fields.;i++) { |
| 112 | confcxx . . $ conf.->attrcxx . . $ db_config#attr.|=1LL<<db->fieldscxx . . $ database#fields.[i]; |
| 113 | } |
| 114 | char *str; |
| 115 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "missing attr field, generated attr field from dbspec: %s (comparison may be incorrect)", str = diff_database_attributes(0, conf->attr)) |
| 116 | freecxx . . $ free(5d22bdacc48458e8).(str); |
| 117 | } |
| 118 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 119 | } |
| 120 | |
| 121 | static char *fgets_wrappercxx . . $ fgets_wrapper(5a609ca8c98a6673).(char *ptr, size_t size, databasecxx . . $ database# *db) { |
| 122 | char * buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 123 | |
| 124 | #ifdef WITH_CURL |
| 125 | switch ((db->url)->type) { |
| 126 | case url_http: |
| 127 | case url_https: |
| 128 | case url_ftp: { |
| 129 | buf = url_fgets(ptr, size, (URL_FILE *)db->fp); |
| 130 | if (!buf) { |
| 131 | log_msg(LOG_LEVEL_ERROR, "url_fgets failed for %s", (db->url)->raw); |
| 132 | exit(IO_ERROR); |
| 133 | } |
| 134 | break; |
| 135 | } |
| 136 | default: |
| 137 | #endif |
| 138 | |
| 139 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 140 | if (db->gzpcxx . . $ database#gzp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 141 | db->gzpcxx . . $ database#gzp.=gzdopencxx . . $ gzdopen(22355c0c2644e5c0).(filenocxx . . $ fileno(89bc1efcdac0ca22).((FILEcxx . . $ FILE# *)db->fpcxx . . $ database#fp.),"rb"); |
| 142 | if (db->gzpcxx . . $ database#gzp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 143 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR., "gzdopen failed for %s", (db->urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw.); |
| 144 | exitcxx . . $ exit(3ca292c338df9bb3).(IO_ERRORcxx . . $ `include/errorcodes.h:29:9`!); |
| 145 | } |
| 146 | } |
| 147 | buf = gzgetscxx . . $ gzgets(5977f83a54bc0c37).(db->gzpcxx . . $ database#gzp., ptr, size); |
| 148 | if (!buf && !gzeofcxx . . $ gzeof(4d4947b8d23ad0c4).(db->gzpcxx . . $ database#gzp.)) { |
| 149 | int gzerrnum; |
| 150 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR., "gzgets failed for %s: %s", (db->urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw., gzerrorcxx . . $ gzerror(57e2cfef56dee254).(db->gzpcxx . . $ database#gzp., &gzerrnum)); |
| 151 | exitcxx . . $ exit(3ca292c338df9bb3).(IO_ERRORcxx . . $ `include/errorcodes.h:29:9`!); |
| 152 | } |
| 153 | #else |
| 154 | buf = fgets(ptr, size, db->fp); |
| 155 | if (ferror(db->fp)) { |
| 156 | log_msg(LOG_LEVEL_ERROR, "fgets failed for %s: %s", (db->url)->raw, strerror(errno)); |
| 157 | exit(IO_ERROR); |
| 158 | } |
| 159 | #endif |
| 160 | #ifdef WITH_CURL |
| 161 | } |
| 162 | #endif |
| 163 | if (buf && db->mdccxx . . $ database#mdc.) { |
| 164 | update_mdcxx . . $ update_md(29e99b095fc90fd4).(db->mdccxx . . $ database#mdc., buf, strlencxx . . $ strlen(751346f8406fd082).(buf)); |
| 165 | } |
| 166 | return buf; |
| 167 | } |
| 168 | |
| 169 | static char *get_next_dblinecxx . . $ get_next_dbline(a1e9c9ac1af12962).(databasecxx . . $ database# *db) { |
| 170 | char buffer[2048]; |
| 171 | char *line = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 172 | size_t len = 0; |
| 173 | |
| 174 | while (fgets_wrappercxx . . $ fgets_wrapper(5a609ca8c98a6673).(buffer, sizeof(buffer), db) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 175 | size_t buffer_len = strlencxx . . $ strlen(751346f8406fd082).(buffer); |
| 176 | line = checked_realloccxx . . $ checked_realloc(417ab160f6baadc6).(line, buffer_len + len + 1); |
| 177 | strncpycxx . . $ strncpy(255158a415b673b0).(line + len, buffer, buffer_len+1); |
| 178 | len += buffer_len; |
| 179 | /* remove newline character */ |
| 180 | if (line[len-1] == '\n') { |
| 181 | line[len-1] = '\0'; |
| 182 | break; |
| 183 | } |
| 184 | } |
| 185 | return line; |
| 186 | } |
| 187 | |
| 188 | db_entry_tcxx . . $ db_entry_t# db_readline_filecxx . . $ db_readline_file(9768d9fab7f01dc3).(databasecxx . . $ database#* db, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! include_limited_entries) { |
| 189 | char **s = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 190 | char *saveptr, *token; |
| 191 | char *line = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 192 | |
| 193 | db_entry_tcxx . . $ db_entry_t# entry = { .line = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, .limit = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`! }; |
| 194 | |
| 195 | while ((line = get_next_dblinecxx . . $ get_next_dbline(a1e9c9ac1af12962).(db)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 196 | db->linenocxx . . $ database#lineno.++; |
| 197 | LOG_LEVELcxx . . $ LOG_LEVEL# db_parse_log_level = LOG_LEVEL_DEBUGcxx . . $ LOG_LEVEL_DEBUG.; |
| 198 | switch (line[0]) { |
| 199 | case '#': |
| 200 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "db_read_file: skip comment line: '%s'", line) |
| 201 | break; |
| 202 | case '\0': |
| 203 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "%s", "db_read_file: skip empty line") |
| 204 | break; |
| 205 | default: |
| 206 | saveptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 207 | token = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(line, " ", &saveptr); |
| 208 | if (token == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 209 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip line (no token found): '%s'", line) |
| 210 | break; |
| 211 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("@@db_spec", token) == 0) { |
| 212 | if (db->fieldscxx . . $ database#fields.) { |
| 213 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip additional '%s' line", token) |
| 214 | } else { |
| 215 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "db_read_file: parse '%s'", token) |
| 216 | db_parse_speccxx . . $ db_parse_spec(b27ce90c5996ec8a).(db, &saveptr); |
| 217 | } |
| 218 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("@@begin_db", token) == 0) { |
| 219 | if (db->flagscxx . . $ database#flags.&DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.) { |
| 220 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip additional '%s' line", token) |
| 221 | } else { |
| 222 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "%s", "db_read_file: start reading database (found '@@begin_db')") |
| 223 | db->flagscxx . . $ database#flags. |= DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.; |
| 224 | } |
| 225 | if ((token = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "\n", &saveptr)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 226 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip unexpected string after '@@begin_db': '%s'", token) |
| 227 | } |
| 228 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("@@end_db", token) == 0) { |
| 229 | if (db->flagscxx . . $ database#flags.&DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.) { |
| 230 | db->flagscxx . . $ database#flags. &= ~(DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.); |
| 231 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "%s", "db_read_file: stop reading database (found '@@end_db')") |
| 232 | if ((token = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, "\n", &saveptr)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 233 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip unexpected string after '@@end_db': '%s'", token) |
| 234 | } |
| 235 | return entry; |
| 236 | } else { |
| 237 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_ERROR, "%s", "unexpected '@@end_db', expected '@@begin_db'") |
| 238 | exitcxx . . $ exit(3ca292c338df9bb3).(DATABASE_ERRORcxx . . $ `include/errorcodes.h:36:9`!); |
| 239 | } |
| 240 | } else if (db->flagscxx . . $ database#flags.&DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.) { |
| 241 | if (*token != '/') { |
| 242 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip line with invalid path: '%s'", token) |
| 243 | break; |
| 244 | } else { |
| 245 | decode_stringcxx . . $ decode_string(fda57c8427c60377).(token); |
| 246 | if (check_limitcxx . . $ check_limit(29f6a365c6b3226d).(token, truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)) { |
| 247 | if (include_limited_entries) { |
| 248 | entry.limitcxx . . $ $anonymous_type_392304a1032d2441_1#limit. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 249 | db_parse_log_level = LOG_LEVEL_LIMITcxx . . $ LOG_LEVEL_LIMIT.; |
| 250 | } else { |
| 251 | progress_statuscxx . . $ progress_status(a36c9239dfdba10f).(PROGRESS_SKIPPEDcxx . . $ PROGRESS_SKIPPED., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "db_read_file: parse '%s'", token) |
| 256 | s = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(sizeof(char*)*num_attrscxx . . $ num_attrs.); |
| 257 | for(ATTRIBUTEcxx . . $ ATTRIBUTE# j=0; j<num_attrscxx . . $ num_attrs.; j++){ |
| 258 | s[j]=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 259 | } |
| 260 | int i = 0; |
| 261 | while(token != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 262 | if (token[0] == '#') { |
| 263 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "%s", "db_read_file: skip inline comment") |
| 264 | break; |
| 265 | } else if (i >= db->num_fieldscxx . . $ database#num_fields.) { |
| 266 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip unexpected string '%s')", token); |
| 267 | } else if (db->fieldscxx . . $ database#fields.[i] != attr_unknowncxx . . $ attr_unknown.) { |
| 268 | s[db->fieldscxx . . $ database#fields.[i]] = checked_strdupcxx . . $ checked_strdup(42228c1987407501).(token); |
| 269 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "db_read_file: '%s' set field '%s' (position %d): '%s'", s[0], attributes[db->fields[i]].db_name, i, token) |
| 270 | } else { |
| 271 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "skip unknown/redefined field at position: %d: '%s'", i, token); |
| 272 | } |
| 273 | token = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, " ", &saveptr); |
| 274 | i++; |
| 275 | } |
| 276 | if (i<db->num_fieldscxx . . $ database#num_fields.) { |
| 277 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_WARNING, "skip cutoff database line '%s' found (field '%s' (position: %d) is missing)", s[0], attributes[db->fields[i]].db_name, i) |
| 278 | for(int a=0;a<i;a++){ |
| 279 | freecxx . . $ free(5d22bdacc48458e8).(s[db->fieldscxx . . $ database#fields.[a]]); |
| 280 | s[db->fieldscxx . . $ database#fields.[a]] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 281 | } |
| 282 | freecxx . . $ free(5d22bdacc48458e8).(s); |
| 283 | s = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 284 | } else { |
| 285 | entry.linecxx . . $ $anonymous_type_392304a1032d2441_1#line. = db_char2linecxx . . $ db_char2line(237a20c9d441aa86).(s, db); |
| 286 | for(int j=0;j<db->num_fieldscxx . . $ database#num_fields.;j++){ |
| 287 | if(db->fieldscxx . . $ database#fields.[j]!=attr_unknowncxx . . $ attr_unknown. && |
| 288 | s[db->fieldscxx . . $ database#fields.[j]]!=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!){ |
| 289 | freecxx . . $ free(5d22bdacc48458e8).(s[db->fieldscxx . . $ database#fields.[j]]); |
| 290 | s[db->fieldscxx . . $ database#fields.[j]]=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 291 | } |
| 292 | } |
| 293 | freecxx . . $ free(5d22bdacc48458e8).(s); |
| 294 | return entry; |
| 295 | } |
| 296 | } |
| 297 | } else { |
| 298 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(db_parse_log_level, "skip line '%s' ('@@begin_db' not (yet) found)", line) |
| 299 | } |
| 300 | } |
| 301 | freecxx . . $ free(5d22bdacc48458e8).(line); |
| 302 | line = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 303 | } |
| 304 | if (db->flagscxx . . $ database#flags.&DB_FLAG_PARSEcxx . . $ DB_FLAG_PARSE.) { |
| 305 | LOG_DB_FORMAT_LINEcxx . . $ `include/db.h:72:9`!(LOG_LEVEL_ERROR, "%s", "missing '@@end_db' (incomplete database file)") |
| 306 | exitcxx . . $ exit(3ca292c338df9bb3).(DATABASE_ERRORcxx . . $ `include/errorcodes.h:36:9`!); |
| 307 | } else { |
| 308 | /* empty database */ |
| 309 | return entry; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | static int str_formatcxx . . $ str_format(1127c6317f9cbc38).(char *, int n, const char*, ...) |
| 314 | #ifdef __GNUC__cxx . . $ `<built-in>:8:9`! |
| 315 | __attribute__ ((format (printf, 3, 4))) |
| 316 | #endif |
| 317 | ; |
| 318 | static int str_formatcxx . . $ str_format(1127c6317f9cbc38).(char *str, int n, const char* format, ...) { |
| 319 | va_listcxx . . $ va_list# ap; |
| 320 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, format); |
| 321 | int len = vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, 0, format, ap); |
| 322 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap); |
| 323 | if (str) { |
| 324 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, format); |
| 325 | vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(&str[n], len+1, format, ap); |
| 326 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap); |
| 327 | } |
| 328 | return len; |
| 329 | } |
| 330 | |
| 331 | static int str_filenamecxx . . $ str_filename(af8bdd87a9908ae9).(char *str, int n, char *path) { |
| 332 | char *safe_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 333 | int len = 0; |
| 334 | if (contains_unsafecxx . . $ contains_unsafe(5c4306d8553b3696).(path)) { |
| 335 | safe_path = encode_stringcxx . . $ encode_string(a8b8e32347182212).(path); |
| 336 | } |
| 337 | len = str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n+len, "%s", safe_path?safe_path:path); |
| 338 | freecxx . . $ free(5d22bdacc48458e8).(safe_path); |
| 339 | return len; |
| 340 | } |
| 341 | |
| 342 | static int str_linknamecxx . . $ str_linkname(af8bdd87a9908ae9).(char *str, int n, char *path) { |
| 343 | char *safe_path = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 344 | int len = 0; |
| 345 | if (path == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 346 | len = str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %s", "0"); |
| 347 | return len; |
| 348 | } |
| 349 | if (*path == '\0') { |
| 350 | len = str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %s", "0-"); |
| 351 | return len; |
| 352 | } |
| 353 | if (contains_unsafecxx . . $ contains_unsafe(5c4306d8553b3696).(path)) { |
| 354 | safe_path = encode_stringcxx . . $ encode_string(a8b8e32347182212).(path); |
| 355 | } |
| 356 | len += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %s%s", *path == '0'?"0":"", safe_path?safe_path:path); |
| 357 | freecxx . . $ free(5d22bdacc48458e8).(safe_path); |
| 358 | return len; |
| 359 | } |
| 360 | |
| 361 | static int byte_base64cxx . . $ byte_base64(475f291f8c537214).(char *str, int n, bytecxx . . $ byte# *src, int src_len) { |
| 362 | char *enc = src ? encode_base64cxx . . $ encode_base64(ea9ec9b3a5ad8ddb).(src, src_len) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 363 | int len = str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %s", enc ? enc : "0"); |
| 364 | freecxx . . $ free(5d22bdacc48458e8).(enc); |
| 365 | return len; |
| 366 | } |
| 367 | |
| 368 | #define CASE_BYTE_BASE64cxx . . $ `src/db_file.c:368:9`!(attr, src, src_len) case attr : { n += byte_base64(str, n, src, src_len); break; } |
| 369 | |
| 370 | #define CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(x) CASE_BYTE_BASE64cxx . . $ `src/db_file.c:368:9`!(attr_ ##x, line->hashsums[hash_ ##x], hashsums[hash_ ##x].length) |
| 371 | |
| 372 | #ifdef WITH_XATTR |
| 373 | static int str_xattr(char *str, int n, xattrs_type *xattrs) { |
| 374 | if (xattrs) { |
| 375 | size_t m = 0; |
| 376 | m = str_format(str, n, " %lu", xattrs->num); |
| 377 | xattr_node *xattr = xattrs->ents; |
| 378 | for (size_t i = xattrs->num; i > 0; --i) { |
| 379 | char *enc_key = NULL; |
| 380 | if (contains_unsafe(xattr->key)) { |
| 381 | enc_key = encode_string(xattr->key); |
| 382 | } |
| 383 | char *enc_value = encode_base64(xattr->val, xattr->vsz); |
| 384 | m += str_format(str, n + m, ",%s,%s", enc_key?enc_key:xattr->key, enc_value?enc_value:"0"); |
| 385 | free(enc_key); |
| 386 | free(enc_value); |
| 387 | ++xattr; |
| 388 | } |
| 389 | return m; |
| 390 | } else { |
| 391 | return str_format(str, n, " %lu", 0LU); |
| 392 | } |
| 393 | } |
| 394 | #endif |
| 395 | |
| 396 | #ifdef WITH_ACL |
| 397 | static int str_acl(char *str, int n, acl_type *acl) { |
| 398 | #ifdef WITH_POSIX_ACL |
| 399 | if (acl) { |
| 400 | char *enc_acl_a = acl->acl_a ? encode_base64((byte *)acl->acl_a, strlen(acl->acl_a)) : NULL; |
| 401 | char *enc_acl_d = acl->acl_d ? encode_base64((byte *)acl->acl_d, strlen(acl->acl_d)) : NULL; |
| 402 | int len = str_format(str, n, " %s,%s,%s", "POSIX", enc_acl_a ? enc_acl_a : "0", enc_acl_d ? enc_acl_d : "0"); |
| 403 | free(enc_acl_d); |
| 404 | free(enc_acl_a); |
| 405 | return len; |
| 406 | } else { |
| 407 | return str_format(str, n, " %lu", 0LU); |
| 408 | } |
| 409 | #endif |
| 410 | } |
| 411 | #endif |
| 412 | |
| 413 | static int construct_database_linecxx . . $ construct_database_line(76fb5cdc45418b5a).(db_linecxx . . $ db_line# *line, char *str) { |
| 414 | int n = 0; |
| 415 | |
| 416 | for (ATTRIBUTEcxx . . $ ATTRIBUTE# i = 0; i < num_attrscxx . . $ num_attrs.; ++i) { |
| 417 | if (attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name. && ATTRcxx . . $ `include/attributes.h:28:9`!(i) & confcxx . . $ conf.->db_out_attrscxx . . $ db_config#db_out_attrs.) { |
| 418 | switch (i) { |
| 419 | case attr_filenamecxx . . $ attr_filename.: { |
| 420 | n += str_filenamecxx . . $ str_filename(af8bdd87a9908ae9).(str, n, line->filenamecxx . . $ db_line#filename.); |
| 421 | break; |
| 422 | } |
| 423 | case attr_attrcxx . . $ attr_attr.: { |
| 424 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %llu", line->attrcxx . . $ db_line#attr.); |
| 425 | break; |
| 426 | } |
| 427 | case attr_inodecxx . . $ attr_inode.: { |
| 428 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %li", line->inodecxx . . $ db_line#inode.); |
| 429 | break; |
| 430 | } |
| 431 | case attr_sizecxx . . $ attr_size.: { |
| 432 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %lli", line->sizecxx . . $ db_line#size.); |
| 433 | break; |
| 434 | } |
| 435 | case attr_bcountcxx . . $ attr_bcount.: { |
| 436 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %lli", line->bcountcxx . . $ db_line#bcount.); |
| 437 | break; |
| 438 | } |
| 439 | case attr_permcxx . . $ attr_perm.: { |
| 440 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %lo", (long)line->permcxx . . $ db_line#perm.); |
| 441 | break; |
| 442 | } |
| 443 | case attr_uidcxx . . $ attr_uid.: { |
| 444 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %li", line->uidcxx . . $ db_line#uid.); |
| 445 | break; |
| 446 | } |
| 447 | case attr_gidcxx . . $ attr_gid.: { |
| 448 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %li", line->gidcxx . . $ db_line#gid.); |
| 449 | break; |
| 450 | } |
| 451 | case attr_atimecxx . . $ attr_atime.: { |
| 452 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %ld", (long)line->atimecxx . . $ db_line#atime.); |
| 453 | break; |
| 454 | } |
| 455 | case attr_ctimecxx . . $ attr_ctime.: { |
| 456 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %ld", (long)line->ctimecxx . . $ db_line#ctime.); |
| 457 | break; |
| 458 | } |
| 459 | case attr_mtimecxx . . $ attr_mtime.: { |
| 460 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %ld", (long)line->mtimecxx . . $ db_line#mtime.); |
| 461 | break; |
| 462 | } |
| 463 | case attr_linknamecxx . . $ attr_linkname.: { |
| 464 | n += str_linknamecxx . . $ str_linkname(af8bdd87a9908ae9).(str, n, line->linknamecxx . . $ db_line#linkname.); |
| 465 | break; |
| 466 | ; |
| 467 | } |
| 468 | case attr_linkcountcxx . . $ attr_linkcount.: { |
| 469 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %li", line->nlinkcxx . . $ db_line#nlink.); |
| 470 | break; |
| 471 | } |
| 472 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(md5) |
| 473 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha1) |
| 474 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(rmd160) |
| 475 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(tiger) |
| 476 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(crc32) |
| 477 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(crc32b) |
| 478 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(haval) |
| 479 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(gostr3411_94) |
| 480 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(stribog256) |
| 481 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(stribog512) |
| 482 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha256) |
| 483 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha512) |
| 484 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(whirlpool) |
| 485 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha512_256) |
| 486 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha3_256) |
| 487 | CASE_HASHSUMcxx . . $ `src/db_file.c:370:9`!(sha3_512) |
| 488 | case attr_aclcxx . . $ attr_acl.: { |
| 489 | #ifdef WITH_ACL |
| 490 | n += str_acl(str, n, line->acl); |
| 491 | #endif |
| 492 | break; |
| 493 | } |
| 494 | case attr_xattrscxx . . $ attr_xattrs.: { |
| 495 | #ifdef WITH_XATTR |
| 496 | n += str_xattr(str, n, line->xattrs); |
| 497 | #endif |
| 498 | break; |
| 499 | } |
| 500 | case attr_selinuxcxx . . $ attr_selinux.: { |
| 501 | #ifdef WITH_SELINUX |
| 502 | n += byte_base64(str, n, (byte *)line->cntx, line->cntx ? strlen(line->cntx) : 0); |
| 503 | #endif |
| 504 | break; |
| 505 | } |
| 506 | case attr_e2fsattrscxx . . $ attr_e2fsattrs.: { |
| 507 | #ifdef WITH_E2FSATTRS |
| 508 | n += str_format(str, n, " %lu", line->e2fsattrs); |
| 509 | #endif |
| 510 | break; |
| 511 | } |
| 512 | case attr_capabilitiescxx . . $ attr_capabilities.: { |
| 513 | #ifdef WITH_CAPABILITIES |
| 514 | n += byte_base64(str, n, (byte *)line->capabilities, |
| 515 | line->capabilities ? strlen(line->capabilities) : 0); |
| 516 | #endif |
| 517 | break; |
| 518 | } |
| 519 | case attr_fs_typecxx . . $ attr_fs_type. : { |
| 520 | #ifdef HAVE_FSTYPEcxx . . $ `./include/config.h:53:9`! |
| 521 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %llu", (unsigned long long) line->fs_typecxx . . $ db_line#fs_type.); |
| 522 | #endif |
| 523 | break; |
| 524 | } |
| 525 | case attr_ftypecxx . . $ attr_ftype.: |
| 526 | case attr_bsizecxx . . $ attr_bsize.: |
| 527 | case attr_rdevcxx . . $ attr_rdev.: |
| 528 | case attr_devcxx . . $ attr_dev.: |
| 529 | case attr_allhashsumscxx . . $ attr_allhashsums.: |
| 530 | case attr_sizegcxx . . $ attr_sizeg.: |
| 531 | case attr_checkinodecxx . . $ attr_checkinode.: |
| 532 | case attr_allownewfilecxx . . $ attr_allownewfile.: |
| 533 | case attr_allowrmfilecxx . . $ attr_allowrmfile.: |
| 534 | case attr_growingcxx . . $ attr_growing.: |
| 535 | case attr_compressedcxx . . $ attr_compressed.: |
| 536 | case attr_unknowncxx . . $ attr_unknown.: { |
| 537 | /* nothing to write to database */ |
| 538 | break; |
| 539 | } |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | if (str) { |
| 544 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(&str[n], 2, "\n"); |
| 545 | } |
| 546 | n++; |
| 547 | |
| 548 | return n; |
| 549 | } |
| 550 | |
| 551 | static void handle_io_error_on_writecxx . . $ handle_io_error_on_write(fda57c8427c60377).(char *function_str) { |
| 552 | if (confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..urlcxx . . $ database#url.->typecxx . . $ url_t#type. == url_filecxx . . $ url_file. && confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..flagscxx . . $ database#flags.&DB_FLAG_CREATEDcxx . . $ DB_FLAG_CREATED.) { |
| 553 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR., "%s failed for %s (remove incompletely written database)", function_str, ((confcxx . . $ conf.->database_outcxx . . $ db_config#database_out.).urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw.); |
| 554 | unlinkcxx . . $ unlink(5c4306d8553b3696).(confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..urlcxx . . $ database#url.->valuecxx . . $ url_t#value.); |
| 555 | } else { |
| 556 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR., "%s failed for %s", function_str, ((confcxx . . $ conf.->database_outcxx . . $ db_config#database_out.).urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw.); |
| 557 | } |
| 558 | exitcxx . . $ exit(3ca292c338df9bb3).(IO_ERRORcxx . . $ `include/errorcodes.h:29:9`!); |
| 559 | } |
| 560 | |
| 561 | static void db_out_writecxx . . $ db_out_write(a14cc78460091691).(char * str, size_t len) { |
| 562 | if ((confcxx . . $ conf.->database_outcxx . . $ db_config#database_out.).mdccxx . . $ database#mdc.) { |
| 563 | update_mdcxx . . $ update_md(29e99b095fc90fd4).((confcxx . . $ conf.->database_outcxx . . $ db_config#database_out.).mdccxx . . $ database#mdc., str, len); |
| 564 | } |
| 565 | |
| 566 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 567 | if(confcxx . . $ conf.->gzip_dboutcxx . . $ db_config#gzip_dbout.) { |
| 568 | if (gzwritecxx . . $ gzwrite(9d7625dd6ec66fb9).((confcxx . . $ conf.->database_outcxx . . $ db_config#database_out.).gzpcxx . . $ database#gzp., str, len) < (int) len) { |
| 569 | handle_io_error_on_writecxx . . $ handle_io_error_on_write(fda57c8427c60377).("gzwrite"); |
| 570 | } |
| 571 | } else { |
| 572 | #endif |
| 573 | if (fwritecxx . . $ fwrite(ab0609fa07c47d6e).(str, sizeof(char), len, confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..fpcxx . . $ database#fp.) < len) { |
| 574 | handle_io_error_on_writecxx . . $ handle_io_error_on_write(fda57c8427c60377).("fwrite"); |
| 575 | } |
| 576 | if (fflushcxx . . $ fflush(89bc1efcdac0ca22).(confcxx . . $ conf.->database_outcxx . . $ db_config#database_out..fpcxx . . $ database#fp.) != 0) { |
| 577 | handle_io_error_on_writecxx . . $ handle_io_error_on_write(fda57c8427c60377).("fflush"); |
| 578 | } |
| 579 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 580 | } |
| 581 | #endif |
| 582 | } |
| 583 | |
| 584 | int db_writeline_filecxx . . $ db_writeline_file(9bfc5d8be61eb86d).(db_linecxx . . $ db_line#* line) { |
| 585 | |
| 586 | char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 587 | int n = construct_database_linecxx . . $ construct_database_line(76fb5cdc45418b5a).(line, str); |
| 588 | |
| 589 | str = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(n+1); |
| 590 | construct_database_linecxx . . $ construct_database_line(76fb5cdc45418b5a).(line, str); |
| 591 | |
| 592 | db_out_writecxx . . $ db_out_write(a14cc78460091691).(str, n); |
| 593 | |
| 594 | freecxx . . $ free(5d22bdacc48458e8).(str); |
| 595 | |
| 596 | return RETOKcxx . . $ `include/db_config.h:45:9`!; |
| 597 | } |
| 598 | |
| 599 | static int construct_database_headercxx . . $ construct_database_header(18eb2be692ee2bf2).(db_configcxx . . $ db_config# *dbconf, char *str) { |
| 600 | int n = 0; |
| 601 | |
| 602 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, "%s", "@@begin_db\n"); |
| 603 | if (dbconf->database_add_metadatacxx . . $ db_config#database_add_metadata.) { |
| 604 | time_tcxx . . $ time_t# db_gen_time = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 605 | char *time_str = get_time_stringcxx . . $ get_time_string(4e4bbfda8d4b3d77).(&db_gen_time); |
| 606 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, |
| 607 | "# This file was generated by Aide, version %s\n" |
| 608 | "# Time of generation was %s\n", |
| 609 | confcxx . . $ conf.->aide_versioncxx . . $ db_config#aide_version., time_str); |
| 610 | freecxx . . $ free(5d22bdacc48458e8).(time_str); |
| 611 | } |
| 612 | if (dbconf->config_versioncxx . . $ db_config#config_version.) { |
| 613 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, |
| 614 | "# The config version used to generate this file was:\n" |
| 615 | "# %s\n", |
| 616 | dbconf->config_versioncxx . . $ db_config#config_version.); |
| 617 | } |
| 618 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, "%s", "@@db_spec"); |
| 619 | for (ATTRIBUTEcxx . . $ ATTRIBUTE# i = 0; i < num_attrscxx . . $ num_attrs.; ++i) { |
| 620 | if (attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name. && attributescxx . . $ attributes.[i].attrcxx . . $ $anonymous_type_bb8296fff58edf70_1#attr. & confcxx . . $ conf.->db_out_attrscxx . . $ db_config#db_out_attrs.) { |
| 621 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, " %s", attributescxx . . $ attributes.[i].db_namecxx . . $ $anonymous_type_bb8296fff58edf70_1#db_name.); |
| 622 | } |
| 623 | } |
| 624 | n += str_formatcxx . . $ str_format(1127c6317f9cbc38).(str, n, "%s", "\n"); |
| 625 | return n; |
| 626 | } |
| 627 | |
| 628 | int db_writespec_filecxx . . $ db_writespec_file(d87c77e6d45fe0c5).(db_configcxx . . $ db_config#* dbconf) { |
| 629 | char *str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 630 | int n = construct_database_headercxx . . $ construct_database_header(18eb2be692ee2bf2).(dbconf, str); |
| 631 | |
| 632 | str = checked_malloccxx . . $ checked_malloc(bfcfa4d6b7f7ef64).(n+1); |
| 633 | construct_database_headercxx . . $ construct_database_header(18eb2be692ee2bf2).(dbconf, str); |
| 634 | |
| 635 | db_out_writecxx . . $ db_out_write(a14cc78460091691).(str, n); |
| 636 | |
| 637 | freecxx . . $ free(5d22bdacc48458e8).(str); |
| 638 | |
| 639 | return RETOKcxx . . $ `include/db_config.h:45:9`!; |
| 640 | } |
| 641 | |
| 642 | int db_close_filecxx . . $ db_close_file(d87c77e6d45fe0c5).(db_configcxx . . $ db_config#* dbconf){ |
| 643 | |
| 644 | if(dbconf->database_outcxx . . $ db_config#database_out..fpcxx . . $ database#fp. |
| 645 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 646 | || dbconf->database_outcxx . . $ db_config#database_out..gzpcxx . . $ database#gzp. |
| 647 | #endif |
| 648 | ){ |
| 649 | char *end_db_str = "@@end_db\n"; |
| 650 | db_out_writecxx . . $ db_out_write(a14cc78460091691).(end_db_str, strlencxx . . $ strlen(751346f8406fd082).(end_db_str)); |
| 651 | } |
| 652 | |
| 653 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 654 | if(dbconf->gzip_dboutcxx . . $ db_config#gzip_dbout.){ |
| 655 | if(gzclosecxx . . $ gzclose(4d4947b8d23ad0c4).(dbconf->database_outcxx . . $ db_config#database_out..gzpcxx . . $ database#gzp.)){ |
| 656 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR.,"unable to gzclose database '%s': %s", (dbconf->database_outcxx . . $ db_config#database_out..urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 657 | return RETFAILcxx . . $ `include/db_config.h:46:9`!; |
| 658 | } |
| 659 | dbconf->database_outcxx . . $ db_config#database_out..gzpcxx . . $ database#gzp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 660 | }else { |
| 661 | #endif |
| 662 | if(fclosecxx . . $ fclose(89bc1efcdac0ca22).(dbconf->database_outcxx . . $ db_config#database_out..fpcxx . . $ database#fp.)){ |
| 663 | log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR.,"unable to close database '%s': %s", (dbconf->database_outcxx . . $ db_config#database_out..urlcxx . . $ database#url.)->rawcxx . . $ url_t#raw., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 664 | return RETFAILcxx . . $ `include/db_config.h:46:9`!; |
| 665 | } |
| 666 | dbconf->database_outcxx . . $ db_config#database_out..fpcxx . . $ database#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 667 | #ifdef WITH_ZLIBcxx . . $ `./include/config.h:266:9`! |
| 668 | } |
| 669 | #endif |
| 670 | |
| 671 | return RETOKcxx . . $ `include/db_config.h:45:9`!; |
| 672 | } |
| 673 | // vi: ts=8 sw=8 |