summaryrefslogtreecommitdiffstats
path: root/web/attachments/26227-check_procs-pch.txt
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/26227-check_procs-pch.txt')
-rw-r--r--web/attachments/26227-check_procs-pch.txt135
1 files changed, 135 insertions, 0 deletions
diff --git a/web/attachments/26227-check_procs-pch.txt b/web/attachments/26227-check_procs-pch.txt
new file mode 100644
index 0000000..e3f8bd1
--- /dev/null
+++ b/web/attachments/26227-check_procs-pch.txt
@@ -0,0 +1,135 @@
1--- plugins/check_procs.c.orig Tue Jun 11 09:08:00 2002
2+++ plugins/check_procs.c Tue Jun 11 13:47:52 2002
3@@ -68,6 +68,14 @@
4 char *format = NULL;
5 char tmp[MAX_INPUT_BUFFER];
6
7+#ifdef HAVE_REGEX_H
8+#include <regex.h>
9+regex_t argsre, progre;
10+int cflags = 0;
11+char errbuf[MAX_INPUT_BUFFER];
12+int excode;
13+#endif
14+
15 int
16 main (int argc, char **argv)
17 {
18@@ -91,6 +99,21 @@
19 if (process_arguments (argc, argv) == ERROR)
20 usage ("Unable to parse command line\n");
21
22+#if HAVE_REGEX_H
23+ if ((options & ARGS) && cflags) {
24+ if ((excode = regcomp (&argsre, args, cflags)) != 0) {
25+ printf ("Could Not Compile Regular Expression\n");
26+ return STATE_UNKNOWN;
27+ }
28+ }
29+ if ((options & PROG) && cflags) {
30+ if ((excode = regcomp (&progre, prog, cflags)) != 0) {
31+ printf ("Could Not Compile Regular Expression\n");
32+ return STATE_UNKNOWN;
33+ }
34+ }
35+#endif
36+
37 /* run the command */
38 if (verbose)
39 printf ("%s\n", PS_COMMAND);
40@@ -121,10 +144,34 @@
41 strip (procargs);
42 if ((options & STAT) && (strstr (statopts, procstat)))
43 resultsum |= STAT;
44- if ((options & ARGS) && (strstr (procargs, args) == procargs))
45+ if ((options & ARGS) && !cflags && (strstr (procargs, args) == procargs))
46 resultsum |= ARGS;
47- if ((options & PROG) && (strcmp (prog, procprog) == 0))
48+ if ((options & PROG) && !cflags && (strcmp (prog, procprog) == 0))
49 resultsum |= PROG;
50+#if HAVE_REGEX_H
51+ if ((options & ARGS) && cflags) {
52+ excode = regexec (&argsre, procargs, (size_t) 0, NULL, 0);
53+ if (excode == 0) {
54+ resultsum |= ARGS;
55+ }
56+ else if (excode != REG_NOMATCH) {
57+ regerror (excode, &argsre, errbuf, MAX_INPUT_BUFFER);
58+ printf ("Execute Error: %s\n", errbuf);
59+ exit (STATE_CRITICAL);
60+ }
61+ }
62+ if ((options & PROG) && cflags) {
63+ excode = regexec (&progre, procprog, (size_t) 0, NULL, 0);
64+ if (excode == 0) {
65+ resultsum |= PROG;
66+ }
67+ else if (excode != REG_NOMATCH) {
68+ regerror (excode, &argsre, errbuf, MAX_INPUT_BUFFER);
69+ printf ("Execute Error: %s\n", errbuf);
70+ exit (STATE_CRITICAL);
71+ }
72+ }
73+#endif
74 if ((options & PPID) && (procppid == ppid))
75 resultsum |= PPID;
76 if ((options & USER) && (procuid == uid))
77@@ -263,6 +310,9 @@
78 {"help", no_argument, 0, 'h'},
79 {"version", no_argument, 0, 'V'},
80 {"verbose", no_argument, 0, 'v'},
81+ {"regex", no_argument, 0, 'r'},
82+ {"ereg", no_argument, 0, 'r'},
83+ {"eregi", no_argument, 0, 'R'},
84 {0, 0, 0, 0}
85 };
86 #endif
87@@ -270,10 +320,10 @@
88 while (1) {
89 #ifdef HAVE_GETOPT_H
90 c =
91- getopt_long (argc, argv, "+Vvht:c:w:p:s:u:C:a:", long_options,
92+ getopt_long (argc, argv, "+VvhRrt:c:w:p:s:u:C:a:", long_options,
93 &option_index);
94 #else
95- c = getopt (argc, argv, "+Vvht:c:w:p:s:u:C:a:");
96+ c = getopt (argc, argv, "+VvhRrt:c:w:p:s:u:C:a:");
97 #endif
98
99 if (c == EOF)
100@@ -419,6 +469,22 @@
101 case 'v': /* command */
102 verbose = TRUE;
103 break;
104+ case 'R': /* regex */
105+#ifdef HAVE_REGEX_H
106+ cflags = REG_ICASE | REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
107+#else
108+ printf ("PROCS UNKNOWN: call for regex which was not a compiled option");
109+ exit (STATE_UNKNOWN);
110+#endif
111+ break;
112+ case 'r': /* regex */
113+#ifdef HAVE_REGEX_H
114+ cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
115+#else
116+ printf ("PROCS UNKNOWN: call for regex which was not a compiled option");
117+ exit (STATE_UNKNOWN);
118+#endif
119+ break;
120 }
121 }
122 return i;
123@@ -492,7 +558,11 @@
124 " -a, --argument-array=STRING\n"
125 " Only scan for ARGS that match up to the length of the given STRING\n"
126 " -C, --command=COMMAND\n"
127- " Only scan for exact matches to the named COMMAND.\n\n"
128+ " Only scan for exact matches to the named COMMAND.\n"
129+ " -r, --ereg\n"
130+ " Treat the -a or -C argument as an extended regular expression\n"
131+ " -R, --eregi\n"
132+ " Treat the -a or -C argument as a case-insensitive extended regular expression\n\n"
133 "RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n"
134 "specified 'max:min', a warning status will be generated if the\n"
135