From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/115229-check_tcp.c.diff | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 web/attachments/115229-check_tcp.c.diff (limited to 'web/attachments/115229-check_tcp.c.diff') diff --git a/web/attachments/115229-check_tcp.c.diff b/web/attachments/115229-check_tcp.c.diff new file mode 100644 index 0000000..bd40d79 --- /dev/null +++ b/web/attachments/115229-check_tcp.c.diff @@ -0,0 +1,102 @@ +--- check_tcp.c.orig Thu Jan 6 12:20:54 2005 ++++ check_tcp.c Thu Jan 6 12:31:24 2005 +@@ -63,6 +63,11 @@ + MAXBUF = 1024 + }; + ++enum { ++ CRLF = 1, ++ LF = 2 ++}; ++ + int process_arguments (int, char **); + int my_recv (void); + void print_help (void); +@@ -100,6 +105,7 @@ + int sd = 0; + char *buffer; + int expect_mismatch_state = STATE_WARNING; ++int lineterm = CRLF; + int exact_matching = TRUE; + + int +@@ -312,7 +318,9 @@ + while ((i = my_recv ()) > 0) { + buffer[i] = '\0'; + asprintf (&status, "%s%s", status, buffer); +- if (buffer[i-2] == '\r' && buffer[i-1] == '\n') ++ if (buffer[i-2] == '\r' && buffer[i-1] == '\n' && lineterm == CRLF) ++ break; ++ if (buffer[i-1] == '\n' && lineterm == LF) + break; + if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes) + break; +@@ -421,6 +429,7 @@ + {"delay", required_argument, 0, 'd'}, + {"refuse", required_argument, 0, 'r'}, + {"mismatch", required_argument, 0, 'M'}, ++ {"lineterm", required_argument, 0, 'l'}, + {"use-ipv4", no_argument, 0, '4'}, + {"use-ipv6", no_argument, 0, '6'}, + {"verbose", no_argument, 0, 'v'}, +@@ -454,7 +463,7 @@ + } + + while (1) { +- c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", ++ c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:l:", + longopts, &option); + + if (c == -1 || c == EOF || c == 1) +@@ -566,13 +575,31 @@ + else + usage4 (_("Mismatch must be one of ok, warn, crit")); + break; ++ case 'l': ++ if (is_intpos (optarg)) { ++ int num = atoi(optarg); ++ ++ switch (num) { ++ case 1: ++ lineterm = CRLF; ++ break; ++ case 2: ++ lineterm = LF; ++ break; ++ default: ++ usage4 (_("Line termination must be 1 (CRLF) or 2 (LF)")); ++ break; ++ } ++ } else ++ usage4 (_("Line termination must be a positive integer")); ++ break; + case 'd': + if (is_intpos (optarg)) + delay = atoi (optarg); + else + usage4 (_("Delay must be a positive integer")); + break; +- case 'D': /* Check SSL cert validity - days 'til certificate expiration */ ++ case 'D': /* Check SSL cert validity - days 'til certificate expiration */ + #ifdef HAVE_SSL + if (!is_intnonneg (optarg)) + usage2 ("invalid certificate expiration period", optarg); +@@ -784,6 +811,8 @@ + Accept tcp refusals with states ok, warn, crit (default: crit)\n\ + -M, --mismatch=ok|warn|crit\n\ + Accept expected string mismatches with states ok, warn, crit (default: warn)\n\ ++ -l, --lineterm=1|2\r\ ++ Line termination expected from remote peer (1 is CRLF; 2 is LF only)\n\ + -j, --jail\n\ + Hide output from TCP socket\n\ + -m, --maxbytes=INTEGER\n\ +@@ -817,6 +846,7 @@ + Usage: %s -H host -p port [-w ] [-c ]\n\ + [-s ] [-e ] [-q ]\n\ + [-m ] [-d ] [-t ]\n\ +- [-r ] [-M ] [-v] [-4|-6] [-j]\n\ +- [-D ] [-S ]\n", progname); ++ [-r ] [-M ] [-l <1|2>] [-v]\n\ ++ [-4|-6] [-j] [-D ] [-S ]\n", ++ progname); + } -- cgit v1.2.3-74-g34f1