diff options
Diffstat (limited to 'web/attachments/115229-check_tcp.c.diff')
-rw-r--r-- | web/attachments/115229-check_tcp.c.diff | 102 |
1 files changed, 102 insertions, 0 deletions
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 @@ | |||
1 | --- check_tcp.c.orig Thu Jan 6 12:20:54 2005 | ||
2 | +++ check_tcp.c Thu Jan 6 12:31:24 2005 | ||
3 | @@ -63,6 +63,11 @@ | ||
4 | MAXBUF = 1024 | ||
5 | }; | ||
6 | |||
7 | +enum { | ||
8 | + CRLF = 1, | ||
9 | + LF = 2 | ||
10 | +}; | ||
11 | + | ||
12 | int process_arguments (int, char **); | ||
13 | int my_recv (void); | ||
14 | void print_help (void); | ||
15 | @@ -100,6 +105,7 @@ | ||
16 | int sd = 0; | ||
17 | char *buffer; | ||
18 | int expect_mismatch_state = STATE_WARNING; | ||
19 | +int lineterm = CRLF; | ||
20 | int exact_matching = TRUE; | ||
21 | |||
22 | int | ||
23 | @@ -312,7 +318,9 @@ | ||
24 | while ((i = my_recv ()) > 0) { | ||
25 | buffer[i] = '\0'; | ||
26 | asprintf (&status, "%s%s", status, buffer); | ||
27 | - if (buffer[i-2] == '\r' && buffer[i-1] == '\n') | ||
28 | + if (buffer[i-2] == '\r' && buffer[i-1] == '\n' && lineterm == CRLF) | ||
29 | + break; | ||
30 | + if (buffer[i-1] == '\n' && lineterm == LF) | ||
31 | break; | ||
32 | if (maxbytes>0 && strlen(status) >= (unsigned)maxbytes) | ||
33 | break; | ||
34 | @@ -421,6 +429,7 @@ | ||
35 | {"delay", required_argument, 0, 'd'}, | ||
36 | {"refuse", required_argument, 0, 'r'}, | ||
37 | {"mismatch", required_argument, 0, 'M'}, | ||
38 | + {"lineterm", required_argument, 0, 'l'}, | ||
39 | {"use-ipv4", no_argument, 0, '4'}, | ||
40 | {"use-ipv6", no_argument, 0, '6'}, | ||
41 | {"verbose", no_argument, 0, 'v'}, | ||
42 | @@ -454,7 +463,7 @@ | ||
43 | } | ||
44 | |||
45 | while (1) { | ||
46 | - c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:", | ||
47 | + c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:jD:M:l:", | ||
48 | longopts, &option); | ||
49 | |||
50 | if (c == -1 || c == EOF || c == 1) | ||
51 | @@ -566,13 +575,31 @@ | ||
52 | else | ||
53 | usage4 (_("Mismatch must be one of ok, warn, crit")); | ||
54 | break; | ||
55 | + case 'l': | ||
56 | + if (is_intpos (optarg)) { | ||
57 | + int num = atoi(optarg); | ||
58 | + | ||
59 | + switch (num) { | ||
60 | + case 1: | ||
61 | + lineterm = CRLF; | ||
62 | + break; | ||
63 | + case 2: | ||
64 | + lineterm = LF; | ||
65 | + break; | ||
66 | + default: | ||
67 | + usage4 (_("Line termination must be 1 (CRLF) or 2 (LF)")); | ||
68 | + break; | ||
69 | + } | ||
70 | + } else | ||
71 | + usage4 (_("Line termination must be a positive integer")); | ||
72 | + break; | ||
73 | case 'd': | ||
74 | if (is_intpos (optarg)) | ||
75 | delay = atoi (optarg); | ||
76 | else | ||
77 | usage4 (_("Delay must be a positive integer")); | ||
78 | break; | ||
79 | - case 'D': /* Check SSL cert validity - days 'til certificate expiration */ | ||
80 | + case 'D': /* Check SSL cert validity - days 'til certificate expiration */ | ||
81 | #ifdef HAVE_SSL | ||
82 | if (!is_intnonneg (optarg)) | ||
83 | usage2 ("invalid certificate expiration period", optarg); | ||
84 | @@ -784,6 +811,8 @@ | ||
85 | Accept tcp refusals with states ok, warn, crit (default: crit)\n\ | ||
86 | -M, --mismatch=ok|warn|crit\n\ | ||
87 | Accept expected string mismatches with states ok, warn, crit (default: warn)\n\ | ||
88 | + -l, --lineterm=1|2\r\ | ||
89 | + Line termination expected from remote peer (1 is CRLF; 2 is LF only)\n\ | ||
90 | -j, --jail\n\ | ||
91 | Hide output from TCP socket\n\ | ||
92 | -m, --maxbytes=INTEGER\n\ | ||
93 | @@ -817,6 +846,7 @@ | ||
94 | Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\ | ||
95 | [-s <send string>] [-e <expect string>] [-q <quit string>]\n\ | ||
96 | [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\ | ||
97 | - [-r <refuse state>] [-M <mismatch state>] [-v] [-4|-6] [-j]\n\ | ||
98 | - [-D <days to cert expiry>] [-S <use SSL>]\n", progname); | ||
99 | + [-r <refuse state>] [-M <mismatch state>] [-l <1|2>] [-v]\n\ | ||
100 | + [-4|-6] [-j] [-D <days to cert expiry>] [-S <use SSL>]\n", | ||
101 | + progname); | ||
102 | } | ||