aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/audit/audisp/plugins/remote/remote-config.c
blob: 841a1ed35c81af333f6be664d46e3680857b4062 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
/* remote-config.c -- 
 * Copyright 2008,2009,2011,2015 Red Hat Inc., Durham, North Carolina.
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors:
 *   Steve Grubb <sgrubb@redhat.com>
 * 
 */

#include "config.h"
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <syslog.h>
#include <ctype.h>
#include <limits.h>
#include "remote-config.h"

/* Local prototypes */
struct nv_pair
{
	const char *name;
	const char *value;
	const char *option;
};

struct kw_pair 
{
	const char *name;
	int (*parser)(struct nv_pair *, int, remote_conf_t *);
	int max_options;
};

struct nv_list
{ 
	const char *name;
	int option;
};

static char *get_line(FILE *f, char *buf);
static int nv_split(char *buf, struct nv_pair *nv);
static const struct kw_pair *kw_lookup(const char *val);
static int server_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int port_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int local_port_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int transport_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int mode_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int queue_file_parser(struct nv_pair *nv, int line,
		remote_conf_t *config);
static int depth_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int format_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int heartbeat_timeout_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int enable_krb5_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int krb5_principal_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int krb5_client_name_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int krb5_key_file_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int network_retry_time_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int max_tries_per_record_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int max_time_per_record_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
#define AP(x) static int x##_action_parser(struct nv_pair *nv, int line,  \
		remote_conf_t *config);
AP(network_failure)
AP(disk_low)
AP(disk_full)
AP(disk_error)
AP(generic_error)
AP(generic_warning)
AP(queue_error)
#undef AP
static int remote_ending_action_parser(struct nv_pair *nv, int line,
                remote_conf_t *config);
static int overflow_action_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config);
static int sanity_check(remote_conf_t *config, const char *file);

static const struct kw_pair keywords[] = 
{
  {"remote_server",    server_parser,		0 },
  {"port",             port_parser,		0 },
  {"local_port",       local_port_parser,	0 },
  {"transport",        transport_parser,	0 },
  {"mode",             mode_parser,		0 },
  {"queue_file",       queue_file_parser,	0 },
  {"queue_depth",      depth_parser,		0 },
  {"format",           format_parser,		0 },
  {"network_retry_time",     network_retry_time_parser,         0 },
  {"max_tries_per_record",   max_tries_per_record_parser,       0 },
  {"max_time_per_record",    max_time_per_record_parser,        0 },
  {"heartbeat_timeout",      heartbeat_timeout_parser,          0 },
  {"enable_krb5",            enable_krb5_parser,                0 },
  {"krb5_principal",         krb5_principal_parser,             0 },
  {"krb5_client_name",       krb5_client_name_parser,           0 },
  {"krb5_key_file",          krb5_key_file_parser,              0 },
  {"network_failure_action", network_failure_action_parser,	1 },
  {"disk_low_action",        disk_low_action_parser,		1 },
  {"disk_full_action",       disk_full_action_parser,		1 },
  {"disk_error_action",      disk_error_action_parser,		1 },
  {"remote_ending_action",   remote_ending_action_parser,	1 },
  {"generic_error_action",   generic_error_action_parser,	1 },
  {"generic_warning_action", generic_warning_action_parser,	1 },
  {"queue_error_action",     queue_error_action_parser,		1 },
  {"overflow_action",        overflow_action_parser,		1 },
  { NULL,                    NULL,                              0 }
};

static const struct nv_list transport_words[] =
{
  {"tcp",  T_TCP  },
  { NULL,  0 }
};

static const struct nv_list mode_words[] =
{
  {"immediate",  M_IMMEDIATE },
  {"forward",    M_STORE_AND_FORWARD },
  { NULL,  0 }
};

static const struct nv_list fail_action_words[] =
{
  {"ignore",   FA_IGNORE },
  {"syslog",   FA_SYSLOG },
  {"exec",     FA_EXEC },
  {"suspend",  FA_SUSPEND },
  {"single",   FA_SINGLE },
  {"halt",     FA_HALT },
  {"stop",     FA_STOP },
  { NULL,  0 }
};

static const struct nv_list overflow_action_words[] =
{
  {"ignore",   OA_IGNORE },
  {"syslog",   OA_SYSLOG },
  {"suspend",  OA_SUSPEND },
  {"single",   OA_SINGLE },
  {"halt",     OA_HALT },
  { NULL,  0 }
};

static const struct nv_list format_words[] =
{
  {"ascii",    F_ASCII },
  {"managed",  F_MANAGED },
  { NULL,  0 }
};

#ifdef USE_GSSAPI
static const struct nv_list enable_krb5_values[] =
{
  {"yes",  1 },
  {"no", 0 },
  { NULL,  0 }
};
#endif

/*
 * Set everything to its default value
*/
void clear_config(remote_conf_t *config)
{
	config->remote_server = NULL;
	config->port = 60;
	config->local_port = 0;
	config->transport = T_TCP;
	config->mode = M_IMMEDIATE;
	config->queue_file = NULL;
	config->queue_depth = 2048;
	config->format = F_MANAGED;

	config->network_retry_time = 1;
	config->max_tries_per_record = 3;
	config->max_time_per_record = 5;
	config->heartbeat_timeout = 0;

#define IA(x,f) config->x##_action = f; config->x##_exe = NULL
	IA(network_failure, FA_STOP);
	IA(disk_low, FA_IGNORE);
	IA(disk_full, FA_IGNORE);
	IA(disk_error, FA_SYSLOG);
	IA(remote_ending, FA_RECONNECT);
	IA(generic_error, FA_SYSLOG);
	IA(generic_warning, FA_SYSLOG);
	IA(queue_error, FA_STOP);
#undef IA
	config->overflow_action = OA_SYSLOG;

	config->enable_krb5 = 0;
	config->krb5_principal = NULL;
	config->krb5_client_name = NULL;
	config->krb5_key_file = NULL;
}

int load_config(remote_conf_t *config, const char *file)
{
	int fd, rc, mode, lineno = 1;
	struct stat st;
	FILE *f;
	char buf[128];

	clear_config(config);

	/* open the file */
	mode = O_RDONLY;
	rc = open(file, mode);
	if (rc < 0) {
		if (errno != ENOENT) {
			syslog(LOG_ERR, "Error opening %s (%s)", file,
				strerror(errno));
			return 1;
		}
		syslog(LOG_WARNING,
			"Config file %s doesn't exist, skipping", file);
		return 0;
	}
	fd = rc;

	/* check the file's permissions: owned by root, not world writable,
	 * not symlink.
	 */
	if (fstat(fd, &st) < 0) {
		syslog(LOG_ERR, "Error fstat'ing config file (%s)", 
			strerror(errno));
		close(fd);
		return 1;
	}
	if (st.st_uid != 0) {
		syslog(LOG_ERR, "Error - %s isn't owned by root", 
			file);
		close(fd);
		return 1;
	}
	if ((st.st_mode & S_IWOTH) == S_IWOTH) {
		syslog(LOG_ERR, "Error - %s is world writable", 
			file);
		close(fd);
		return 1;
	}
	if (!S_ISREG(st.st_mode)) {
		syslog(LOG_ERR, "Error - %s is not a regular file", 
			file);
		close(fd);
		return 1;
	}

	/* it's ok, read line by line */
	f = fdopen(fd, "rm");
	if (f == NULL) {
		syslog(LOG_ERR, "Error - fdopen failed (%s)", 
			strerror(errno));
		close(fd);
		return 1;
	}

	while (get_line(f, buf)) {
		// convert line into name-value pair
		const struct kw_pair *kw;
		struct nv_pair nv;
		rc = nv_split(buf, &nv);
		switch (rc) {
			case 0: // fine
				break;
			case 1: // not the right number of tokens.
				syslog(LOG_ERR, 
				"Wrong number of arguments for line %d in %s", 
					lineno, file);
				break;
			case 2: // no '=' sign
				syslog(LOG_ERR, 
					"Missing equal sign for line %d in %s", 
					lineno, file);
				break;
			default: // something else went wrong... 
				syslog(LOG_ERR, 
					"Unknown error for line %d in %s", 
					lineno, file);
				break;
		}
		if (nv.name == NULL) {
			lineno++;
			continue;
		}
		if (nv.value == NULL) {
			fclose(f);
			return 1;
		}

		/* identify keyword or error */
		kw = kw_lookup(nv.name);
		if (kw->name == NULL) {
			syslog(LOG_ERR, 
				"Unknown keyword \"%s\" in line %d of %s", 
				nv.name, lineno, file);
			fclose(f);
			return 1;
		}

		/* Check number of options */
		if (kw->max_options == 0 && nv.option != NULL) {
			syslog(LOG_ERR, 
				"Keyword \"%s\" has invalid option "
				"\"%s\" in line %d of %s", 
				nv.name, nv.option, lineno, file);
			fclose(f);
			return 1;
		}

		/* dispatch to keyword's local parser */
		rc = kw->parser(&nv, lineno, config);
		if (rc != 0) {
			fclose(f);
			return 1; // local parser puts message out
		}

		lineno++;
	}

	fclose(f);
	if (lineno > 1)
		return sanity_check(config, file);
	return 0;
}

static char *get_line(FILE *f, char *buf)
{
	if (fgets_unlocked(buf, 128, f)) {
		/* remove newline */
		char *ptr = strchr(buf, 0x0a);
		if (ptr)
			*ptr = 0;
		return buf;
	}
	return NULL;
}

static int nv_split(char *buf, struct nv_pair *nv)
{
	/* Get the name part */
	char *ptr, *saved;

	nv->name = NULL;
	nv->value = NULL;
	nv->option = NULL;
	ptr = strtok_r(buf, " ", &saved);
	if (ptr == NULL)
		return 0; /* If there's nothing, go to next line */
	if (ptr[0] == '#')
		return 0; /* If there's a comment, go to next line */
	nv->name = ptr;

	/* Check for a '=' */
	ptr = strtok_r(NULL, " ", &saved);
	if (ptr == NULL)
		return 1;
	if (strcmp(ptr, "=") != 0)
		return 2;

	/* get the value */
	ptr = strtok_r(NULL, " ", &saved);
	if (ptr == NULL)
		return 1;
	nv->value = ptr;

	/* See if there's an option */
	ptr = strtok_r(NULL, " ", &saved);
	if (ptr) {
		nv->option = ptr;

		/* Make sure there's nothing else */
		ptr = strtok_r(NULL, " ", &saved);
		if (ptr)
			return 1;
	}

	/* Everything is OK */
	return 0;
}

static const struct kw_pair *kw_lookup(const char *val)
{
	int i = 0;
	while (keywords[i].name != NULL) {
		if (strcasecmp(keywords[i].name, val) == 0)
			break;
		i++;
	}
	return &keywords[i];
}

static int check_exe_name(const char *val, int line)
{
	struct stat buf;

	if (val == NULL) {
		syslog(LOG_ERR, "Executable path needed for line %d", line);
		return -1;
	}

	if (*val != '/') {
		syslog(LOG_ERR, "Absolute path needed for %s - line %d",
			val, line);
		return -1;
	}

	if (stat(val, &buf) < 0) {
		syslog(LOG_ERR, "Unable to stat %s (%s) - line %d", val,
			strerror(errno), line);
		return -1;
	}
	if (!S_ISREG(buf.st_mode)) {
		syslog(LOG_ERR, "%s is not a regular file - line %d", val,
			line);
		return -1;
	}
	if (buf.st_uid != 0) {
		syslog(LOG_ERR, "%s is not owned by root - line %d", val,
			line);
		return -1;
	}
	if ((buf.st_mode & (S_IRWXU|S_IRWXG|S_IWOTH)) !=
			   (S_IRWXU|S_IRGRP|S_IXGRP)) {
		syslog(LOG_ERR, "%s permissions should be 0750 - line %d", val,
			line);
		return -1;
	}
	return 0;
}
 
static int server_parser(struct nv_pair *nv, int line, 
		remote_conf_t *config)
{
	if (nv->value)
		config->remote_server = strdup(nv->value);
	else
		config->remote_server = NULL;
	return 0;
}

static int parse_uint (const struct nv_pair *nv, int line, unsigned int *valp,
		unsigned int min, unsigned int max)
{
	const char *ptr = nv->value;
	unsigned int i;

	/* check that all chars are numbers */
	for (i=0; ptr[i]; i++) {
		if (!isdigit(ptr[i])) {
			syslog(LOG_ERR,
				"Value %s should only be numbers - line %d",
				nv->value, line);
			return 1;
		}
	}

	/* convert to unsigned int */
	errno = 0;
	i = strtoul(nv->value, NULL, 10);
	if (errno) {
		syslog(LOG_ERR,
			"Error converting string to a number (%s) - line %d",
			strerror(errno), line);
		return 1;
	}
	/* Check its range */
	if (min != 0 && i < (int)min) {
		syslog(LOG_ERR,
			"Error - converted number (%s) is too small - line %d",
			nv->value, line);
		return 1;
	}
	if (max != 0 && i > max) {
		syslog(LOG_ERR,
			"Error - converted number (%s) is too large - line %d",
			nv->value, line);
		return 1;
	}
	*valp = (unsigned int)i;
	return 0;
}

static int port_parser(struct nv_pair *nv, int line, remote_conf_t *config)
{
	return parse_uint (nv, line, &(config->port), 0, 65535);
}

static int local_port_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	if ((strcasecmp(nv->value, "any") == 0))
		return 0;	// The default is 0, which means any port
	return parse_uint (nv, line, &(config->local_port), 0, 65535);
}

static int transport_parser(struct nv_pair *nv, int line, remote_conf_t *config)
{
	int i;
	for (i=0; transport_words[i].name != NULL; i++) {
		if (strcasecmp(nv->value, transport_words[i].name) == 0) {
			config->transport = transport_words[i].option;
			return 0;
		}
	}
	syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
	return 1;
}

static int mode_parser(struct nv_pair *nv, int line, remote_conf_t *config)
{
	int i;
	for (i=0; mode_words[i].name != NULL; i++) {
		if (strcasecmp(nv->value, mode_words[i].name) == 0) {
			config->mode = mode_words[i].option;
			return 0;
		}
	}
	syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
	return 1;
}

static int queue_file_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	if (nv->value) {
		if (*nv->value != '/') {
			syslog(LOG_ERR, "Absolute path needed for %s - line %d",
			       nv->value, line);
			return 1;
		}
		config->queue_file = strdup(nv->value);
	} else
		config->queue_file = NULL;
	return 0;
}

static int depth_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	return parse_uint (nv, line, &(config->queue_depth), 1, INT_MAX);
}

static int action_parser(struct nv_pair *nv, int line,
			 failure_action_t *actp, const char **exep)
{
	int i;
	for (i=0; fail_action_words[i].name != NULL; i++) {
		if (strcasecmp(nv->value, fail_action_words[i].name) == 0) {
			if (fail_action_words[i].option == FA_EXEC) {
				if (check_exe_name(nv->option, line))
					return 1;
				*exep = strdup(nv->option);
			}
			*actp = fail_action_words[i].option;
			return 0;
		}
	}
	syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
 	return 1;
}

#define AP(x) \
static int x##_action_parser(struct nv_pair *nv, int line, \
	remote_conf_t *config) \
{ \
	return action_parser(nv,line,&(config->x##_action),&(config->x##_exe));\
} \

AP(network_failure)
AP(disk_low)
AP(disk_full)
AP(disk_error)
AP(generic_error)
AP(generic_warning)
AP(queue_error)
#undef AP

static int overflow_action_parser(struct nv_pair *nv, int line,
	remote_conf_t *config)
{
        int i;

        for (i=0; overflow_action_words[i].name != NULL; i++) {
                if (strcasecmp(nv->value, overflow_action_words[i].name) == 0) {
                        config->overflow_action = overflow_action_words[i].option;
                        return 0;
                }
        }
        syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
        return 1;
}

static int remote_ending_action_parser(struct nv_pair *nv, int line,
                remote_conf_t *config)
{
	if (strcasecmp(nv->value, "reconnect") == 0) {
		config->remote_ending_action = FA_RECONNECT;
		return 0;
	}
	return action_parser(nv, line, &config->remote_ending_action,
			&config->remote_ending_exe);
}

static int format_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	int i;
	for (i=0; format_words[i].name != NULL; i++) {
		if (strcasecmp(nv->value, format_words[i].name) == 0) {
			config->format = format_words[i].option;
			return 0;
		}
	}
	syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
 	return 1;
}

static int network_retry_time_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	return parse_uint(nv, line, &config->network_retry_time, 1, INT_MAX);
}

static int max_tries_per_record_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	return parse_uint(nv, line, &config->max_tries_per_record, 1, INT_MAX);
}

static int max_time_per_record_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	return parse_uint(nv, line, &(config->max_time_per_record), 1, INT_MAX);
}

static int heartbeat_timeout_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
	return parse_uint (nv, line, &(config->heartbeat_timeout), 0, INT_MAX);
}

static int enable_krb5_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
#ifndef USE_GSSAPI
	syslog(LOG_INFO,
		"GSSAPI support is not enabled, ignoring value at line %d",
		line);
	return 0;
#else
	unsigned long i;

	for (i=0; enable_krb5_values[i].name != NULL; i++) {
		if (strcasecmp(nv->value, enable_krb5_values[i].name) == 0) {
			config->enable_krb5 = enable_krb5_values[i].option;
			return 0;
		}
	}
	syslog(LOG_ERR, "Option %s not found - line %d", nv->value, line);
	return 1;
#endif
}

static int krb5_principal_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
#ifndef USE_GSSAPI
	syslog(LOG_INFO,
		"GSSAPI support is not enabled, ignoring value at line %d",
		line);
#else
	if (config->krb5_principal)
		free ((char *)config->krb5_principal);

	config->krb5_principal = strdup(nv->value);
#endif
	return 0;
}

static int krb5_client_name_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
#ifndef USE_GSSAPI
	syslog(LOG_INFO,
		"GSSAPI support is not enabled, ignoring value at line %d",
		line);
#else
	if (config->krb5_client_name)
		free ((char *)config->krb5_client_name);

	config->krb5_client_name = strdup(nv->value);
#endif
	return 0;
}

static int krb5_key_file_parser(struct nv_pair *nv, int line,
		remote_conf_t *config)
{
#ifndef USE_GSSAPI
        syslog(LOG_INFO,
                "GSSAPI support is not enabled, ignoring value at line %d",
                line);
#else
	if (config->krb5_key_file)
		free ((char *)config->krb5_key_file);

	config->krb5_key_file = strdup(nv->value);
#endif
	return 0;
}

/*
 * This function is where we do the integrated check of the audispd config
 * options. At this point, all fields have been read. Returns 0 if no
 * problems and 1 if problems detected.
 */
static int sanity_check(remote_conf_t *config, const char *file)
{
	/* Error checking */
// server should have string
// port should be less that 32k
// queue_depth should be less than 100k
// If fail_action is F_EXEC, fail_exec must exist
	if (config->mode == M_STORE_AND_FORWARD
	    && config->format != F_MANAGED) {
		syslog(LOG_ERR, "\"mode=forward\" is valid only with "
		       "\"format=managed\"");
		return 1;
	}
	return 0;
}

void free_config(remote_conf_t *config)
{
	free((void *)config->remote_server);
	free((void *)config->queue_file);
	free((void *)config->network_failure_exe);
	free((void *)config->disk_low_exe);
	free((void *)config->disk_full_exe);
	free((void *)config->disk_error_exe);
	free((void *)config->remote_ending_exe);
	free((void *)config->generic_error_exe);
	free((void *)config->generic_warning_exe);
	free((void *)config->queue_error_exe);
	free((void *)config->krb5_principal);
	free((void *)config->krb5_client_name);
	free((void *)config->krb5_key_file);
}