summaryrefslogtreecommitdiff
path: root/tests/syslog_inject.c
blob: a5d77b1a3bd5600f4e04ec7c9f90a75b75e5c9f8 (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
/* This tool deliberately logs a message with the a trailing LF */
/* Options:
 * -l: inject linefeed at end of message
 * -c: inject control character in middle of message
 */
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <string.h>

static inline void usage(void) {
	fprintf(stderr, "Usage: syslog_inject [-l] [-c]\n");
	exit(1);
}

int main(int argc, char *argv[])
{
	if(argc != 2)
		usage();
	if(!strcmp(argv[1], "-l"))
		syslog(LOG_NOTICE, "test\n");
	else if(!strcmp(argv[1], "-c"))
		syslog(LOG_NOTICE, "test 1\t2");
	else
		usage();

	return 0;
}