summaryrefslogtreecommitdiff
path: root/tests/syslog_inject.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-02-23 11:27:02 +0100
committerMichael Biebl <biebl@debian.org>2011-02-23 11:27:02 +0100
commit0116bd2a5f70ce1065933c47903a3bb4cd4fe9e0 (patch)
treeedc0fcff16e528fed98fe3bf77d566c32552835b /tests/syslog_inject.c
parent4d8f0c039c4fa44bb43d3cdbb0674cde8bb66de4 (diff)
downloadrsyslog-upstream/5.7.5.tar.gz
Imported Upstream version 5.7.5upstream/5.7.5
Diffstat (limited to 'tests/syslog_inject.c')
-rw-r--r--tests/syslog_inject.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/syslog_inject.c b/tests/syslog_inject.c
new file mode 100644
index 0000000..a5d77b1
--- /dev/null
+++ b/tests/syslog_inject.c
@@ -0,0 +1,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;
+}