]>
Commit | Line | Data |
---|---|---|
501f141c JB |
1 | --- cyrus-sasl-2.1.28/saslauthd/Makefile.am.orig 2022-02-18 22:50:42.000000000 +0100 |
2 | +++ cyrus-sasl-2.1.28/saslauthd/Makefile.am 2022-05-23 18:49:42.340529846 +0200 | |
ccc7c536 | 3 | @@ -1,5 +1,7 @@ |
53445750 | 4 | AUTOMAKE_OPTIONS = 1.7 |
ccc7c536 | 5 | sbin_PROGRAMS = saslauthd testsaslauthd |
f91fdf36 | 6 | +nagios_PROGRAMS = check_saslauthd |
faea6fc5 | 7 | +nagiosdir = @libdir@/nagios/plugins |
53445750 ER |
8 | EXTRA_PROGRAMS = saslcache |
9 | ||
b0aee5d1 JR |
10 | LTLIBOBJS = @LTLIBOBJS@ |
11 | @@ -30,6 +32,10 @@ saslauthd_LDADD = @SASL_KRB_LIB@ \ | |
53445750 ER |
12 | testsaslauthd_SOURCES = testsaslauthd.c utils.c |
13 | testsaslauthd_LDADD = @LIB_SOCKET@ | |
14 | ||
15 | +check_saslauthd_SOURCES = testsaslauthd.c utils.c | |
16 | +check_saslauthd_LDADD = @LIB_SOCKET@ | |
17 | +check_saslauthd_CFLAGS = -DNAGIOS_PLUGIN | |
18 | + | |
19 | saslcache_SOURCES = saslcache.c | |
20 | ||
501f141c | 21 | EXTRA_DIST = testsaslauthd.8 saslauthd.mdoc include \ |
b0aee5d1 JR |
22 | diff -urNp -x '*.orig' cyrus-sasl-2.1.27.org/saslauthd/testsaslauthd.c cyrus-sasl-2.1.27/saslauthd/testsaslauthd.c |
23 | --- cyrus-sasl-2.1.27.org/saslauthd/testsaslauthd.c 2018-11-08 18:29:57.000000000 +0100 | |
24 | +++ cyrus-sasl-2.1.27/saslauthd/testsaslauthd.c 2021-09-28 23:58:31.072659837 +0200 | |
25 | @@ -58,6 +58,13 @@ | |
53445750 ER |
26 | #endif |
27 | #include <assert.h> | |
28 | ||
29 | +#ifdef NAGIOS_PLUGIN | |
30 | +#define STATE_OK 0 | |
31 | +#define STATE_WARNING 1 | |
32 | +#define STATE_CRITICAL 2 | |
33 | +#define STATE_UNKNOWN 3 | |
34 | +#endif | |
35 | + | |
36 | #include "globals.h" | |
37 | #include "utils.h" | |
38 | ||
b0aee5d1 | 39 | @@ -244,7 +251,11 @@ static int saslauthd_verify_password(con |
53445750 ER |
40 | } |
41 | ||
42 | printf("NO \"authentication failed\"\n"); | |
43 | +#ifdef NAGIOS_PLUGIN | |
44 | + return 1; | |
45 | +#else | |
46 | return -1; | |
47 | +#endif | |
48 | } | |
49 | ||
50 | int | |
b0aee5d1 | 51 | @@ -291,7 +302,11 @@ main(int argc, char *argv[]) |
53445750 ER |
52 | " [-r realm] [-s servicename]\n" |
53 | " [-f socket path] [-R repeatnum]\n", | |
54 | argv[0], argv[0]); | |
55 | +#ifdef NAGIOS_PLUGIN | |
56 | + exit(STATE_UNKNOWN); | |
57 | +#else | |
58 | exit(1); | |
59 | +#endif | |
60 | } | |
61 | ||
62 | if (!repeat) repeat = 1; | |
b0aee5d1 | 63 | @@ -300,7 +315,23 @@ main(int argc, char *argv[]) |
53445750 ER |
64 | printf("%d: ", c); |
65 | result = saslauthd_verify_password(path, user, password, service, realm); | |
66 | } | |
67 | +#ifdef NAGIOS_PLUGIN | |
68 | + switch (result) { | |
69 | + case -1: | |
70 | + return STATE_CRITICAL; | |
71 | + | |
72 | + case 0: // auth ok | |
73 | + return STATE_OK; | |
74 | + | |
75 | + case 1: // auth fail | |
76 | + return STATE_WARNING; | |
77 | + | |
78 | + default: | |
79 | + return STATE_UNKNOWN; | |
80 | + } | |
81 | +#else | |
82 | return result; | |
83 | +#endif | |
84 | } | |
85 | ||
86 |