diff options
Diffstat (limited to 'web/attachments/418216-check_smtp.c.reworked.patch')
| -rw-r--r-- | web/attachments/418216-check_smtp.c.reworked.patch | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/web/attachments/418216-check_smtp.c.reworked.patch b/web/attachments/418216-check_smtp.c.reworked.patch new file mode 100644 index 0000000..729986c --- /dev/null +++ b/web/attachments/418216-check_smtp.c.reworked.patch | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | diff -ru nagios-plugins-1.4.15.orig/plugins/check_smtp.c nagios-plugins-1.4.15/plugins/check_smtp.c | ||
| 2 | --- nagios-plugins-1.4.15.orig/plugins/check_smtp.c 2010-07-27 20:47:16.000000000 +0000 | ||
| 3 | +++ nagios-plugins-1.4.15/plugins/check_smtp.c 2011-07-15 10:51:11.000000000 +0000 | ||
| 4 | @@ -114,6 +114,7 @@ | ||
| 5 | TCP_PROTOCOL = 1, | ||
| 6 | UDP_PROTOCOL = 2, | ||
| 7 | }; | ||
| 8 | +int ignore_send_quit_failure = FALSE; | ||
| 9 | |||
| 10 | |||
| 11 | int | ||
| 12 | @@ -129,6 +130,9 @@ | ||
| 13 | char *error_msg = ""; | ||
| 14 | struct timeval tv; | ||
| 15 | |||
| 16 | + /* catch pipe errors in read.write */ | ||
| 17 | + (void) signal (SIGPIPE, SIG_IGN); | ||
| 18 | + | ||
| 19 | setlocale (LC_ALL, ""); | ||
| 20 | bindtextdomain (PACKAGE, LOCALEDIR); | ||
| 21 | textdomain (PACKAGE); | ||
| 22 | @@ -476,6 +480,7 @@ | ||
| 23 | {"help", no_argument, 0, 'h'}, | ||
| 24 | {"starttls",no_argument,0,'S'}, | ||
| 25 | {"certificate",required_argument,0,'D'}, | ||
| 26 | + {"ignore-quit-failure",no_argument,0,'q'}, | ||
| 27 | {0, 0, 0, 0} | ||
| 28 | }; | ||
| 29 | |||
| 30 | @@ -492,7 +497,7 @@ | ||
| 31 | } | ||
| 32 | |||
| 33 | while (1) { | ||
| 34 | - c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:", | ||
| 35 | + c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", | ||
| 36 | longopts, &option); | ||
| 37 | |||
| 38 | if (c == -1 || c == EOF) | ||
| 39 | @@ -579,6 +584,9 @@ | ||
| 40 | case 'v': /* verbose */ | ||
| 41 | verbose++; | ||
| 42 | break; | ||
| 43 | + case 'q': | ||
| 44 | + ignore_send_quit_failure++; /* ignore problem sending QUIT */ | ||
| 45 | + break; | ||
| 46 | case 't': /* timeout */ | ||
| 47 | if (is_intnonneg (optarg)) { | ||
| 48 | socket_timeout = atoi (optarg); | ||
| 49 | @@ -662,8 +670,21 @@ | ||
| 50 | smtp_quit(void) | ||
| 51 | { | ||
| 52 | int bytes; | ||
| 53 | + int n; | ||
| 54 | + | ||
| 55 | + n = my_send(SMTP_QUIT, strlen(SMTP_QUIT)); | ||
| 56 | + if(n != 0) { | ||
| 57 | + if(ignore_send_quit_failure) { | ||
| 58 | + if(verbose) { | ||
| 59 | + printf( | ||
| 60 | + _("Connection closed by server before sending QUIT command\n")); | ||
| 61 | + } | ||
| 62 | + return; | ||
| 63 | + } | ||
| 64 | + die (STATE_UNKNOWN, | ||
| 65 | + _("Connection closed by server before sending QUIT command\n")); | ||
| 66 | + } | ||
| 67 | |||
| 68 | - my_send(SMTP_QUIT, strlen(SMTP_QUIT)); | ||
| 69 | if (verbose) | ||
| 70 | printf(_("sent %s\n"), "QUIT"); | ||
| 71 | |||
| 72 | @@ -797,7 +818,9 @@ | ||
| 73 | printf (" %s\n", _("SMTP AUTH username")); | ||
| 74 | printf (" %s\n", "-P, --authpass=STRING"); | ||
| 75 | printf (" %s\n", _("SMTP AUTH password")); | ||
| 76 | - | ||
| 77 | + printf (" %s\n", "-q, --ignore-quit-failure"); | ||
| 78 | + printf (" %s\n", _("Ignore failure when sending QUIT command to server")); | ||
| 79 | + | ||
| 80 | printf (UT_WARN_CRIT); | ||
| 81 | |||
| 82 | printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | ||
| 83 | @@ -821,6 +844,6 @@ | ||
| 84 | printf ("%s\n", _("Usage:")); | ||
| 85 | printf ("%s -H host [-p port] [-e expect] [-C command] [-f from addr]", progname); | ||
| 86 | printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]\n"); | ||
| 87 | - printf ("[-F fqdn] [-S] [-D days] [-v] [-4|-6]\n"); | ||
| 88 | + printf ("[-F fqdn] [-S] [-D days] [-v] [-4|-6] [-q]\n"); | ||
| 89 | } | ||
| 90 | |||
