--- cyrus-sasl-2.1.28/saslauthd/Makefile.am.orig 2022-02-18 22:50:42.000000000 +0100 +++ cyrus-sasl-2.1.28/saslauthd/Makefile.am 2022-05-23 18:49:42.340529846 +0200 @@ -1,5 +1,7 @@ AUTOMAKE_OPTIONS = 1.7 sbin_PROGRAMS = saslauthd testsaslauthd +nagios_PROGRAMS = check_saslauthd +nagiosdir = @libdir@/nagios/plugins EXTRA_PROGRAMS = saslcache LTLIBOBJS = @LTLIBOBJS@ @@ -30,6 +32,10 @@ saslauthd_LDADD = @SASL_KRB_LIB@ \ testsaslauthd_SOURCES = testsaslauthd.c utils.c testsaslauthd_LDADD = @LIB_SOCKET@ +check_saslauthd_SOURCES = testsaslauthd.c utils.c +check_saslauthd_LDADD = @LIB_SOCKET@ +check_saslauthd_CFLAGS = -DNAGIOS_PLUGIN + saslcache_SOURCES = saslcache.c EXTRA_DIST = testsaslauthd.8 saslauthd.mdoc include \ diff -urNp -x '*.orig' cyrus-sasl-2.1.27.org/saslauthd/testsaslauthd.c cyrus-sasl-2.1.27/saslauthd/testsaslauthd.c --- cyrus-sasl-2.1.27.org/saslauthd/testsaslauthd.c 2018-11-08 18:29:57.000000000 +0100 +++ cyrus-sasl-2.1.27/saslauthd/testsaslauthd.c 2021-09-28 23:58:31.072659837 +0200 @@ -58,6 +58,13 @@ #endif #include +#ifdef NAGIOS_PLUGIN +#define STATE_OK 0 +#define STATE_WARNING 1 +#define STATE_CRITICAL 2 +#define STATE_UNKNOWN 3 +#endif + #include "globals.h" #include "utils.h" @@ -244,7 +251,11 @@ static int saslauthd_verify_password(con } printf("NO \"authentication failed\"\n"); +#ifdef NAGIOS_PLUGIN + return 1; +#else return -1; +#endif } int @@ -291,7 +302,11 @@ main(int argc, char *argv[]) " [-r realm] [-s servicename]\n" " [-f socket path] [-R repeatnum]\n", argv[0], argv[0]); +#ifdef NAGIOS_PLUGIN + exit(STATE_UNKNOWN); +#else exit(1); +#endif } if (!repeat) repeat = 1; @@ -300,7 +315,23 @@ main(int argc, char *argv[]) printf("%d: ", c); result = saslauthd_verify_password(path, user, password, service, realm); } +#ifdef NAGIOS_PLUGIN + switch (result) { + case -1: + return STATE_CRITICAL; + + case 0: // auth ok + return STATE_OK; + + case 1: // auth fail + return STATE_WARNING; + + default: + return STATE_UNKNOWN; + } +#else return result; +#endif }