Debian Codegraph @

include/taint.h

raw
1 /*
2 * Copyright (c) 2010 William Pitcock <[email protected]>.
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * Management of tainted running configuration reasons and status.
6 */
7
8 #ifndef ATHEME_TAINT_H
9 #define ATHEME_TAINT_H
10
11 typedef struct {
12 char condition[BUFSIZE];
13 char file[BUFSIZE];
14 int line;
15 char buf[BUFSIZE];
16 mowgli_node_t node;
17 } taint_reason_t;
18
19 E mowgli_list_t taint_list;
20
21 #define IS_TAINTED MOWGLI_LIST_LENGTH(&taint_list)
22 #define TAINT_ON(cond, reason) \
23 if ((cond)) \
24 { \
25 taint_reason_t *tr; \
26 tr = scalloc(sizeof(taint_reason_t), 1); \
27 mowgli_strlcpy(tr->condition, #cond, BUFSIZE); \
28 mowgli_strlcpy(tr->file, __FILE__, BUFSIZE); \
29 tr->line = __LINE__; \
30 mowgli_strlcpy(tr->buf, (reason), BUFSIZE); \
31 mowgli_node_add(tr, &tr->node, &taint_list); \
32 slog(LG_ERROR, "TAINTED: %s", (reason)); \
33 if (!config_options.allow_taint) \
34 { \
35 slog(LG_ERROR, "exiting due to taint"); \
36 exit(EXIT_FAILURE); \
37 } \
38 }
39
40 #endif