File: taint.h

package info (click to toggle)
atheme-services 7.2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,992 kB
  • sloc: ansic: 93,230; sh: 7,440; php: 5,032; perl: 3,327; makefile: 1,261; sed: 16; ruby: 15; python: 3
file content (40 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2010 William Pitcock <nenolod@atheme.org>.
 * Rights to this code are as documented in doc/LICENSE.
 *
 * Management of tainted running configuration reasons and status.
 */

#ifndef ATHEME_TAINT_H
#define ATHEME_TAINT_H

typedef struct {
	char condition[BUFSIZE];
	char file[BUFSIZE];
	int line;
	char buf[BUFSIZE];
	mowgli_node_t node;
} taint_reason_t;

E mowgli_list_t taint_list;

#define IS_TAINTED	MOWGLI_LIST_LENGTH(&taint_list)
#define TAINT_ON(cond, reason) \
	if ((cond))						\
	{							\
		taint_reason_t *tr;				\
		tr = scalloc(sizeof(taint_reason_t), 1);	\
		mowgli_strlcpy(tr->condition, #cond, BUFSIZE);	\
		mowgli_strlcpy(tr->file, __FILE__, BUFSIZE);	\
		tr->line = __LINE__;				\
		mowgli_strlcpy(tr->buf, (reason), BUFSIZE);	\
		mowgli_node_add(tr, &tr->node, &taint_list);	\
		slog(LG_ERROR, "TAINTED: %s", (reason));	\
		if (!config_options.allow_taint)		\
		{						\
			slog(LG_ERROR, "exiting due to taint");	\
			exit(EXIT_FAILURE);			\
		}						\
	}

#endif