int main(void)
{
	struct nfct_labelmap *l;

	l = nfct_labelmap_new("/");
	assert(l == NULL);

	l = nfct_labelmap_new(NULL);
	if (l) {
		puts("default connlabel.conf:");
		dump_map(l);
		nfct_labelmap_destroy(l);
	} else {
		puts("no default config found");
	}

	l = nfct_labelmap_new("qa-connlabel.conf");
	if (!l)
		l = nfct_labelmap_new("qa/qa-connlabel.conf");
	assert(l);
	puts("qa-connlabel.conf:");
	dump_map(l);
	print_label(l);
	nfct_labelmap_destroy(l);

	return 0;
}
Esempio n. 2
0
/* cannot do this via _init, else static builds might spew error message
 * for every iptables invocation.
 */
static void connlabel_open(void)
{
	if (map)
		return;

	map = nfct_labelmap_new(NULL);
	if (!map && errno)
		xtables_error(RESOURCE_PROBLEM, "cannot open connlabel.conf: %s\n",
			strerror(errno));
}
Esempio n. 3
0
/* cannot do this via _init, else static builds might spew error message
 * for every iptables invocation.
 */
static int connlabel_open(void)
{
	const char *fname;

	if (map)
		return 0;

	map = nfct_labelmap_new(NULL);
	if (map != NULL)
		return 0;

	fname = nfct_labels_get_path();
	if (errno) {
		fprintf(stderr, "Warning: cannot open %s: %s\n",
			fname, strerror(errno));
	} else {
		xtables_error(RESOURCE_PROBLEM,
			"cannot parse %s: no labels found", fname);
	}
	return 1;
}