summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/extra_opts.c28
-rw-r--r--lib/maxfd.c5
-rw-r--r--lib/output.c11
-rw-r--r--lib/parse_ini.c112
-rw-r--r--lib/tests/test_base64.c271
-rw-r--r--lib/tests/test_cmd.c27
-rw-r--r--lib/tests/test_generic_output.c6
-rw-r--r--lib/tests/test_ini1.c51
-rw-r--r--lib/tests/test_opts1.c34
-rw-r--r--lib/tests/test_opts2.c69
-rw-r--r--lib/tests/test_tcp.c23
-rw-r--r--lib/utils_base.c4
-rw-r--r--lib/utils_cmd.c95
-rw-r--r--lib/utils_tcp.c25
-rw-r--r--lib/utils_tcp.h3
15 files changed, 478 insertions, 286 deletions
diff --git a/lib/extra_opts.c b/lib/extra_opts.c
index 88787336..857b34b4 100644
--- a/lib/extra_opts.c
+++ b/lib/extra_opts.c
@@ -27,12 +27,13 @@
27 27
28/* FIXME: copied from utils.h; we should move a bunch of libs! */ 28/* FIXME: copied from utils.h; we should move a bunch of libs! */
29bool is_option2(char *str) { 29bool is_option2(char *str) {
30 if (!str) 30 if (!str) {
31 return false; 31 return false;
32 else if (strspn(str, "-") == 1 || strspn(str, "-") == 2) 32 } else if (strspn(str, "-") == 1 || strspn(str, "-") == 2) {
33 return true; 33 return true;
34 else 34 } else {
35 return false; 35 return false;
36 }
36} 37}
37 38
38/* this is the externally visible function used by plugins */ 39/* this is the externally visible function used by plugins */
@@ -56,8 +57,9 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
56 /* It is a single argument with value */ 57 /* It is a single argument with value */
57 argptr = argv[i] + 13; 58 argptr = argv[i] + 13;
58 /* Delete the extra opts argument */ 59 /* Delete the extra opts argument */
59 for (j = i; j < *argc; j++) 60 for (j = i; j < *argc; j++) {
60 argv[j] = argv[j + 1]; 61 argv[j] = argv[j + 1];
62 }
61 i--; 63 i--;
62 *argc -= 1; 64 *argc -= 1;
63 } else if (strcmp(argv[i], "--extra-opts") == 0) { 65 } else if (strcmp(argv[i], "--extra-opts") == 0) {
@@ -65,8 +67,9 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
65 /* It is a argument with separate value */ 67 /* It is a argument with separate value */
66 argptr = argv[i + 1]; 68 argptr = argv[i + 1];
67 /* Delete the extra-opts argument/value */ 69 /* Delete the extra-opts argument/value */
68 for (j = i; j < *argc - 1; j++) 70 for (j = i; j < *argc - 1; j++) {
69 argv[j] = argv[j + 2]; 71 argv[j] = argv[j + 2];
72 }
70 i -= 2; 73 i -= 2;
71 *argc -= 2; 74 *argc -= 2;
72 ea_num--; 75 ea_num--;
@@ -74,8 +77,9 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
74 /* It has no value */ 77 /* It has no value */
75 optfound = 1; 78 optfound = 1;
76 /* Delete the extra opts argument */ 79 /* Delete the extra opts argument */
77 for (j = i; j < *argc; j++) 80 for (j = i; j < *argc; j++) {
78 argv[j] = argv[j + 1]; 81 argv[j] = argv[j + 1];
82 }
79 i--; 83 i--;
80 *argc -= 1; 84 *argc -= 1;
81 } 85 }
@@ -94,16 +98,18 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
94 /* append the list to extra_args */ 98 /* append the list to extra_args */
95 if (extra_args == NULL) { 99 if (extra_args == NULL) {
96 extra_args = ea1; 100 extra_args = ea1;
97 while ((ea1 = ea1->next)) 101 while ((ea1 = ea1->next)) {
98 ea_num++; 102 ea_num++;
103 }
99 } else { 104 } else {
100 ea_tmp = extra_args; 105 ea_tmp = extra_args;
101 while (ea_tmp->next) { 106 while (ea_tmp->next) {
102 ea_tmp = ea_tmp->next; 107 ea_tmp = ea_tmp->next;
103 } 108 }
104 ea_tmp->next = ea1; 109 ea_tmp->next = ea1;
105 while ((ea1 = ea1->next)) 110 while ((ea1 = ea1->next)) {
106 ea_num++; 111 ea_num++;
112 }
107 } 113 }
108 ea1 = ea_tmp = NULL; 114 ea1 = ea_tmp = NULL;
109 } 115 }
@@ -116,8 +122,9 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
116 122
117 /* done processing arguments. now create a new argv array... */ 123 /* done processing arguments. now create a new argv array... */
118 argv_new = (char **)malloc((ea_num + 1) * sizeof(char **)); 124 argv_new = (char **)malloc((ea_num + 1) * sizeof(char **));
119 if (argv_new == NULL) 125 if (argv_new == NULL) {
120 die(STATE_UNKNOWN, _("malloc() failed!\n")); 126 die(STATE_UNKNOWN, _("malloc() failed!\n"));
127 }
121 128
122 /* starting with program name */ 129 /* starting with program name */
123 argv_new[0] = argv[0]; 130 argv_new[0] = argv[0];
@@ -130,8 +137,9 @@ char **np_extra_opts(int *argc, char **argv, const char *plugin_name) {
130 free(ea1); 137 free(ea1);
131 } 138 }
132 /* finally the rest of the argv array */ 139 /* finally the rest of the argv array */
133 for (i = 1; i < *argc; i++) 140 for (i = 1; i < *argc; i++) {
134 argv_new[argc_new++] = argv[i]; 141 argv_new[argc_new++] = argv[i];
142 }
135 *argc = argc_new; 143 *argc = argc_new;
136 /* and terminate. */ 144 /* and terminate. */
137 argv_new[argc_new] = NULL; 145 argv_new[argc_new] = NULL;
diff --git a/lib/maxfd.c b/lib/maxfd.c
index ca5b6e54..9b58d8e3 100644
--- a/lib/maxfd.c
+++ b/lib/maxfd.c
@@ -31,10 +31,11 @@ long mp_open_max(void) {
31#ifdef _SC_OPEN_MAX 31#ifdef _SC_OPEN_MAX
32 errno = 0; 32 errno = 0;
33 if ((maxfd = sysconf(_SC_OPEN_MAX)) < 0) { 33 if ((maxfd = sysconf(_SC_OPEN_MAX)) < 0) {
34 if (errno == 0) 34 if (errno == 0) {
35 maxfd = DEFAULT_MAXFD; /* it's indeterminate */ 35 maxfd = DEFAULT_MAXFD; /* it's indeterminate */
36 else 36 } else {
37 die(STATE_UNKNOWN, _("sysconf error for _SC_OPEN_MAX\n")); 37 die(STATE_UNKNOWN, _("sysconf error for _SC_OPEN_MAX\n"));
38 }
38 } 39 }
39#elif defined(OPEN_MAX) 40#elif defined(OPEN_MAX)
40 return OPEN_MAX 41 return OPEN_MAX
diff --git a/lib/output.c b/lib/output.c
index 34ff7dab..f283969f 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -377,7 +377,9 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch
377 377
378 while (tmp_string != NULL) { 378 while (tmp_string != NULL) {
379 *tmp_string = '\0'; 379 *tmp_string = '\0';
380 asprintf(&intermediate_string, "%s%s\n%s", intermediate_string,check.output, generate_indentation_string(indentation+1)); // one more indentation to make it look better 380 asprintf(&intermediate_string, "%s%s\n%s", intermediate_string, check.output,
381 generate_indentation_string(
382 indentation + 1)); // one more indentation to make it look better
381 383
382 if (*(tmp_string + 1) != '\0') { 384 if (*(tmp_string + 1) != '\0') {
383 check.output = tmp_string + 1; 385 check.output = tmp_string + 1;
@@ -394,13 +396,14 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch
394 // add the rest (if any) 396 // add the rest (if any)
395 if (have_residual_chars) { 397 if (have_residual_chars) {
396 char *tmp = check.output; 398 char *tmp = check.output;
397 xasprintf(&check.output, "%s\n%s%s", intermediate_string, generate_indentation_string(indentation+1), tmp); 399 xasprintf(&check.output, "%s\n%s%s", intermediate_string,
400 generate_indentation_string(indentation + 1), tmp);
398 } else { 401 } else {
399 check.output = intermediate_string; 402 check.output = intermediate_string;
400 } 403 }
401 } 404 }
402 asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)), 405 asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation),
403 check.output); 406 state_text(mp_compute_subcheck_state(check)), check.output);
404 407
405 subchecks = check.subchecks; 408 subchecks = check.subchecks;
406 409
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 1289aae2..4c3c1b93 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -40,19 +40,22 @@ typedef struct {
40 char *stanza; 40 char *stanza;
41} np_ini_info; 41} np_ini_info;
42 42
43static char *default_ini_file_names[] = {"monitoring-plugins.ini", "plugins.ini", "nagios-plugins.ini", NULL}; 43static char *default_ini_file_names[] = {"monitoring-plugins.ini", "plugins.ini",
44 "nagios-plugins.ini", NULL};
44 45
45static char *default_ini_path_names[] = { 46static char *default_ini_path_names[] = {
46 "/usr/local/etc/monitoring-plugins/monitoring-plugins.ini", "/usr/local/etc/monitoring-plugins.ini", 47 "/usr/local/etc/monitoring-plugins/monitoring-plugins.ini",
47 "/etc/monitoring-plugins/monitoring-plugins.ini", "/etc/monitoring-plugins.ini", 48 "/usr/local/etc/monitoring-plugins.ini", "/etc/monitoring-plugins/monitoring-plugins.ini",
49 "/etc/monitoring-plugins.ini",
48 /* deprecated path names (for backward compatibility): */ 50 /* deprecated path names (for backward compatibility): */
49 "/etc/nagios/plugins.ini", "/usr/local/nagios/etc/plugins.ini", "/usr/local/etc/nagios/plugins.ini", "/etc/opt/nagios/plugins.ini", 51 "/etc/nagios/plugins.ini", "/usr/local/nagios/etc/plugins.ini",
50 "/etc/nagios-plugins.ini", "/usr/local/etc/nagios-plugins.ini", "/etc/opt/nagios-plugins.ini", NULL}; 52 "/usr/local/etc/nagios/plugins.ini", "/etc/opt/nagios/plugins.ini", "/etc/nagios-plugins.ini",
53 "/usr/local/etc/nagios-plugins.ini", "/etc/opt/nagios-plugins.ini", NULL};
51 54
52/* eat all characters from a FILE pointer until n is encountered */ 55/* eat all characters from a FILE pointer until n is encountered */
53#define GOBBLE_TO(f, c, n) \ 56#define GOBBLE_TO(f, c, n) \
54 do { \ 57 do { \
55 (c) = fgetc((f)); \ 58 (c) = fgetc((f)); \
56 } while ((c) != EOF && (c) != (n)) 59 } while ((c) != EOF && (c) != (n))
57 60
58/* internal function that returns the constructed defaults options */ 61/* internal function that returns the constructed defaults options */
@@ -87,8 +90,9 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in
87 i->stanza = strdup(def_stanza); 90 i->stanza = strdup(def_stanza);
88 } 91 }
89 92
90 if (i->stanza == NULL) 93 if (i->stanza == NULL) {
91 die(STATE_UNKNOWN, _("malloc() failed!\n")); 94 die(STATE_UNKNOWN, _("malloc() failed!\n"));
95 }
92 96
93 /* check whether there's an @file part */ 97 /* check whether there's an @file part */
94 if (stanza_len == locator_len) { 98 if (stanza_len == locator_len) {
@@ -99,8 +103,9 @@ static void parse_locator(const char *locator, const char *def_stanza, np_ini_in
99 i->file_string_on_heap = true; 103 i->file_string_on_heap = true;
100 } 104 }
101 105
102 if (i->file == NULL || i->file[0] == '\0') 106 if (i->file == NULL || i->file[0] == '\0') {
103 die(STATE_UNKNOWN, _("Cannot find config file in any standard location.\n")); 107 die(STATE_UNKNOWN, _("Cannot find config file in any standard location.\n"));
108 }
104} 109}
105 110
106/* 111/*
@@ -112,26 +117,31 @@ np_arg_list *np_get_defaults(const char *locator, const char *default_section) {
112 np_ini_info i; 117 np_ini_info i;
113 int is_suid_plugin = mp_suid(); 118 int is_suid_plugin = mp_suid();
114 119
115 if (is_suid_plugin && idpriv_temp_drop() == -1) 120 if (is_suid_plugin && idpriv_temp_drop() == -1) {
116 die(STATE_UNKNOWN, _("Cannot drop privileges: %s\n"), strerror(errno)); 121 die(STATE_UNKNOWN, _("Cannot drop privileges: %s\n"), strerror(errno));
122 }
117 123
118 parse_locator(locator, default_section, &i); 124 parse_locator(locator, default_section, &i);
119 inifile = strcmp(i.file, "-") == 0 ? stdin : fopen(i.file, "r"); 125 inifile = strcmp(i.file, "-") == 0 ? stdin : fopen(i.file, "r");
120 126
121 if (inifile == NULL) 127 if (inifile == NULL) {
122 die(STATE_UNKNOWN, _("Can't read config file: %s\n"), strerror(errno)); 128 die(STATE_UNKNOWN, _("Can't read config file: %s\n"), strerror(errno));
123 if (!read_defaults(inifile, i.stanza, &defaults)) 129 }
130 if (!read_defaults(inifile, i.stanza, &defaults)) {
124 die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file); 131 die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), i.stanza, i.file);
132 }
125 133
126 if (i.file_string_on_heap) { 134 if (i.file_string_on_heap) {
127 free(i.file); 135 free(i.file);
128 } 136 }
129 137
130 if (inifile != stdin) 138 if (inifile != stdin) {
131 fclose(inifile); 139 fclose(inifile);
140 }
132 free(i.stanza); 141 free(i.stanza);
133 if (is_suid_plugin && idpriv_temp_restore() == -1) 142 if (is_suid_plugin && idpriv_temp_restore() == -1) {
134 die(STATE_UNKNOWN, _("Cannot restore privileges: %s\n"), strerror(errno)); 143 die(STATE_UNKNOWN, _("Cannot restore privileges: %s\n"), strerror(errno));
144 }
135 145
136 return defaults; 146 return defaults;
137} 147}
@@ -158,8 +168,9 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts) {
158 /* our little stanza-parsing state machine */ 168 /* our little stanza-parsing state machine */
159 while ((c = fgetc(f)) != EOF) { 169 while ((c = fgetc(f)) != EOF) {
160 /* gobble up leading whitespace */ 170 /* gobble up leading whitespace */
161 if (isspace(c)) 171 if (isspace(c)) {
162 continue; 172 continue;
173 }
163 switch (c) { 174 switch (c) {
164 /* globble up comment lines */ 175 /* globble up comment lines */
165 case ';': 176 case ';':
@@ -172,9 +183,11 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts) {
172 for (i = 0; i < stanza_len; i++) { 183 for (i = 0; i < stanza_len; i++) {
173 c = fgetc(f); 184 c = fgetc(f);
174 /* strip leading whitespace */ 185 /* strip leading whitespace */
175 if (i == 0) 186 if (i == 0) {
176 for (; isspace(c); c = fgetc(f)) 187 for (; isspace(c); c = fgetc(f)) {
177 continue; 188 continue;
189 }
190 }
178 /* nope, read to the end of the line */ 191 /* nope, read to the end of the line */
179 if (c != stanza[i]) { 192 if (c != stanza[i]) {
180 GOBBLE_TO(f, c, '\n'); 193 GOBBLE_TO(f, c, '\n');
@@ -185,10 +198,12 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts) {
185 if (i == stanza_len) { 198 if (i == stanza_len) {
186 c = fgetc(f); 199 c = fgetc(f);
187 /* strip trailing whitespace */ 200 /* strip trailing whitespace */
188 for (; isspace(c); c = fgetc(f)) 201 for (; isspace(c); c = fgetc(f)) {
189 continue; 202 continue;
190 if (c == ']') 203 }
204 if (c == ']') {
191 stanzastate = RIGHTSTANZA; 205 stanzastate = RIGHTSTANZA;
206 }
192 } 207 }
193 break; 208 break;
194 /* otherwise, we're in the body of a stanza or a parse error */ 209 /* otherwise, we're in the body of a stanza or a parse error */
@@ -239,12 +254,13 @@ static int add_option(FILE *f, np_arg_list **optlst) {
239 if (linebuf == NULL || read_pos + read_sz >= linebuf_sz) { 254 if (linebuf == NULL || read_pos + read_sz >= linebuf_sz) {
240 linebuf_sz = linebuf_sz > 0 ? linebuf_sz << 1 : read_sz; 255 linebuf_sz = linebuf_sz > 0 ? linebuf_sz << 1 : read_sz;
241 linebuf = realloc(linebuf, linebuf_sz); 256 linebuf = realloc(linebuf, linebuf_sz);
242 if (linebuf == NULL) 257 if (linebuf == NULL) {
243 die(STATE_UNKNOWN, _("malloc() failed!\n")); 258 die(STATE_UNKNOWN, _("malloc() failed!\n"));
259 }
244 } 260 }
245 if (fgets(&linebuf[read_pos], (int)read_sz, f) == NULL) 261 if (fgets(&linebuf[read_pos], (int)read_sz, f) == NULL) {
246 done_reading = 1; 262 done_reading = 1;
247 else { 263 } else {
248 read_pos = strlen(linebuf); 264 read_pos = strlen(linebuf);
249 if (linebuf[read_pos - 1] == '\n') { 265 if (linebuf[read_pos - 1] == '\n') {
250 linebuf[--read_pos] = '\0'; 266 linebuf[--read_pos] = '\0';
@@ -256,38 +272,46 @@ static int add_option(FILE *f, np_arg_list **optlst) {
256 /* all that to read one line, isn't C fun? :) now comes the parsing :/ */ 272 /* all that to read one line, isn't C fun? :) now comes the parsing :/ */
257 273
258 /* skip leading whitespace */ 274 /* skip leading whitespace */
259 for (optptr = linebuf; optptr < lineend && isspace(*optptr); optptr++) 275 for (optptr = linebuf; optptr < lineend && isspace(*optptr); optptr++) {
260 continue; 276 continue;
277 }
261 /* continue to '=' or EOL, watching for spaces that might precede it */ 278 /* continue to '=' or EOL, watching for spaces that might precede it */
262 for (eqptr = optptr; eqptr < lineend && *eqptr != '='; eqptr++) { 279 for (eqptr = optptr; eqptr < lineend && *eqptr != '='; eqptr++) {
263 if (isspace(*eqptr) && optend == NULL) 280 if (isspace(*eqptr) && optend == NULL) {
264 optend = eqptr; 281 optend = eqptr;
265 else 282 } else {
266 optend = NULL; 283 optend = NULL;
284 }
267 } 285 }
268 if (optend == NULL) 286 if (optend == NULL) {
269 optend = eqptr; 287 optend = eqptr;
288 }
270 --optend; 289 --optend;
271 /* ^[[:space:]]*=foo is a syntax error */ 290 /* ^[[:space:]]*=foo is a syntax error */
272 if (optptr == eqptr) 291 if (optptr == eqptr) {
273 die(STATE_UNKNOWN, "%s\n", _("Config file error")); 292 die(STATE_UNKNOWN, "%s\n", _("Config file error"));
293 }
274 /* continue from '=' to start of value or EOL */ 294 /* continue from '=' to start of value or EOL */
275 for (valptr = eqptr + 1; valptr < lineend && isspace(*valptr); valptr++) 295 for (valptr = eqptr + 1; valptr < lineend && isspace(*valptr); valptr++) {
276 continue; 296 continue;
297 }
277 /* continue to the end of value */ 298 /* continue to the end of value */
278 for (valend = valptr; valend < lineend; valend++) 299 for (valend = valptr; valend < lineend; valend++) {
279 continue; 300 continue;
301 }
280 --valend; 302 --valend;
281 /* finally trim off trailing spaces */ 303 /* finally trim off trailing spaces */
282 for (; isspace(*valend); valend--) 304 for (; isspace(*valend); valend--) {
283 continue; 305 continue;
306 }
284 /* calculate the length of "--foo" */ 307 /* calculate the length of "--foo" */
285 opt_len = (size_t)(1 + optend - optptr); 308 opt_len = (size_t)(1 + optend - optptr);
286 /* 1-character params needs only one dash */ 309 /* 1-character params needs only one dash */
287 if (opt_len == 1) 310 if (opt_len == 1) {
288 cfg_len = 1 + (opt_len); 311 cfg_len = 1 + (opt_len);
289 else 312 } else {
290 cfg_len = 2 + (opt_len); 313 cfg_len = 2 + (opt_len);
314 }
291 /* if valptr<lineend then we have to also allocate space for "=bar" */ 315 /* if valptr<lineend then we have to also allocate space for "=bar" */
292 if (valptr < lineend) { 316 if (valptr < lineend) {
293 equals = value = 1; 317 equals = value = 1;
@@ -300,8 +324,9 @@ static int add_option(FILE *f, np_arg_list **optlst) {
300 cfg_len += 1; 324 cfg_len += 1;
301 } 325 }
302 /* a line with no equal sign isn't valid */ 326 /* a line with no equal sign isn't valid */
303 if (equals == 0) 327 if (equals == 0) {
304 die(STATE_UNKNOWN, "%s\n", _("Config file error")); 328 die(STATE_UNKNOWN, "%s\n", _("Config file error"));
329 }
305 330
306 /* okay, now we have all the info we need, so we create a new np_arg_list 331 /* okay, now we have all the info we need, so we create a new np_arg_list
307 * element and set the argument... 332 * element and set the argument...
@@ -329,11 +354,12 @@ static int add_option(FILE *f, np_arg_list **optlst) {
329 optnew->arg[read_pos] = '\0'; 354 optnew->arg[read_pos] = '\0';
330 355
331 /* ...and put that to the end of the list */ 356 /* ...and put that to the end of the list */
332 if (*optlst == NULL) 357 if (*optlst == NULL) {
333 *optlst = optnew; 358 *optlst = optnew;
334 else { 359 } else {
335 while (opttmp->next != NULL) 360 while (opttmp->next != NULL) {
336 opttmp = opttmp->next; 361 opttmp = opttmp->next;
362 }
337 opttmp->next = optnew; 363 opttmp->next = optnew;
338 } 364 }
339 365
@@ -344,7 +370,8 @@ static int add_option(FILE *f, np_arg_list **optlst) {
344static char *default_file(void) { 370static char *default_file(void) {
345 char *ini_file; 371 char *ini_file;
346 372
347 if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL || (ini_file = default_file_in_path()) != NULL) { 373 if ((ini_file = getenv("MP_CONFIG_FILE")) != NULL ||
374 (ini_file = default_file_in_path()) != NULL) {
348 return ini_file; 375 return ini_file;
349 } 376 }
350 377
@@ -360,16 +387,19 @@ static char *default_file_in_path(void) {
360 char *config_path, **file; 387 char *config_path, **file;
361 char *dir, *ini_file, *tokens; 388 char *dir, *ini_file, *tokens;
362 389
363 if ((config_path = getenv("NAGIOS_CONFIG_PATH")) == NULL) 390 if ((config_path = getenv("NAGIOS_CONFIG_PATH")) == NULL) {
364 return NULL; 391 return NULL;
392 }
365 /* shall we spit out a warning that NAGIOS_CONFIG_PATH is deprecated? */ 393 /* shall we spit out a warning that NAGIOS_CONFIG_PATH is deprecated? */
366 394
367 if ((tokens = strdup(config_path)) == NULL) 395 if ((tokens = strdup(config_path)) == NULL) {
368 die(STATE_UNKNOWN, "%s\n", _("Insufficient Memory")); 396 die(STATE_UNKNOWN, "%s\n", _("Insufficient Memory"));
397 }
369 for (dir = strtok(tokens, ":"); dir != NULL; dir = strtok(NULL, ":")) { 398 for (dir = strtok(tokens, ":"); dir != NULL; dir = strtok(NULL, ":")) {
370 for (file = default_ini_file_names; *file != NULL; file++) { 399 for (file = default_ini_file_names; *file != NULL; file++) {
371 if ((asprintf(&ini_file, "%s/%s", dir, *file)) < 0) 400 if ((asprintf(&ini_file, "%s/%s", dir, *file)) < 0) {
372 die(STATE_UNKNOWN, "%s\n", _("Insufficient Memory")); 401 die(STATE_UNKNOWN, "%s\n", _("Insufficient Memory"));
402 }
373 if (access(ini_file, F_OK) == 0) { 403 if (access(ini_file, F_OK) == 0) {
374 free(tokens); 404 free(tokens);
375 return ini_file; 405 return ini_file;
diff --git a/lib/tests/test_base64.c b/lib/tests/test_base64.c
index 94cb5aa9..798244da 100644
--- a/lib/tests/test_base64.c
+++ b/lib/tests/test_base64.c
@@ -180,117 +180,168 @@ int main(int argc, char **argv) {
180#endif 180#endif
181 181
182 char random[1024] = { 182 char random[1024] = {
183 0x0b, 0x30, 0x44, 0x62, 0x7c, 0x22, 0x1f, 0x0d, 0x05, 0x67, 0x2c, 0x2a, 0x39, 0x21, 0x46, 0x08, 0x50, 0x66, 0x34, 0x37, 0x0b, 0x45, 183 0x0b, 0x30, 0x44, 0x62, 0x7c, 0x22, 0x1f, 0x0d, 0x05, 0x67, 0x2c, 0x2a, 0x39, 0x21, 0x46,
184 0x4b, 0x38, 0x32, 0x06, 0x7a, 0x3e, 0x7f, 0x0c, 0x40, 0x18, 0x6b, 0x2d, 0x60, 0x4c, 0x60, 0x0c, 0x23, 0x43, 0x3b, 0x3e, 0x1b, 0x16, 184 0x08, 0x50, 0x66, 0x34, 0x37, 0x0b, 0x45, 0x4b, 0x38, 0x32, 0x06, 0x7a, 0x3e, 0x7f, 0x0c,
185 0x04, 0x46, 0x58, 0x3f, 0x40, 0x6a, 0x11, 0x05, 0x63, 0x71, 0x14, 0x35, 0x47, 0x79, 0x13, 0x6f, 0x6b, 0x27, 0x18, 0x5b, 0x48, 0x27, 185 0x40, 0x18, 0x6b, 0x2d, 0x60, 0x4c, 0x60, 0x0c, 0x23, 0x43, 0x3b, 0x3e, 0x1b, 0x16, 0x04,
186 0x3e, 0x6f, 0x15, 0x33, 0x4f, 0x3e, 0x5e, 0x51, 0x73, 0x68, 0x25, 0x0f, 0x06, 0x5b, 0x7c, 0x72, 0x75, 0x3e, 0x3f, 0x1b, 0x5c, 0x6d, 186 0x46, 0x58, 0x3f, 0x40, 0x6a, 0x11, 0x05, 0x63, 0x71, 0x14, 0x35, 0x47, 0x79, 0x13, 0x6f,
187 0x6a, 0x39, 0x7c, 0x63, 0x63, 0x60, 0x6c, 0x7a, 0x33, 0x76, 0x52, 0x13, 0x25, 0x33, 0x7d, 0x65, 0x23, 0x27, 0x11, 0x06, 0x06, 0x47, 187 0x6b, 0x27, 0x18, 0x5b, 0x48, 0x27, 0x3e, 0x6f, 0x15, 0x33, 0x4f, 0x3e, 0x5e, 0x51, 0x73,
188 0x71, 0x1e, 0x14, 0x74, 0x63, 0x70, 0x2d, 0x15, 0x27, 0x18, 0x51, 0x06, 0x05, 0x33, 0x11, 0x2c, 0x6b, 0x00, 0x2d, 0x77, 0x20, 0x48, 188 0x68, 0x25, 0x0f, 0x06, 0x5b, 0x7c, 0x72, 0x75, 0x3e, 0x3f, 0x1b, 0x5c, 0x6d, 0x6a, 0x39,
189 0x0d, 0x73, 0x51, 0x45, 0x25, 0x7f, 0x7f, 0x35, 0x26, 0x2e, 0x26, 0x53, 0x24, 0x68, 0x1e, 0x0e, 0x58, 0x3a, 0x59, 0x50, 0x56, 0x37, 189 0x7c, 0x63, 0x63, 0x60, 0x6c, 0x7a, 0x33, 0x76, 0x52, 0x13, 0x25, 0x33, 0x7d, 0x65, 0x23,
190 0x5f, 0x66, 0x01, 0x4c, 0x5a, 0x64, 0x32, 0x50, 0x7b, 0x6a, 0x20, 0x72, 0x2b, 0x1d, 0x7e, 0x43, 0x7b, 0x61, 0x42, 0x0b, 0x61, 0x73, 190 0x27, 0x11, 0x06, 0x06, 0x47, 0x71, 0x1e, 0x14, 0x74, 0x63, 0x70, 0x2d, 0x15, 0x27, 0x18,
191 0x24, 0x79, 0x3a, 0x6b, 0x4a, 0x79, 0x6e, 0x09, 0x0f, 0x27, 0x2d, 0x0c, 0x5e, 0x32, 0x4b, 0x0d, 0x79, 0x46, 0x39, 0x21, 0x0a, 0x26, 191 0x51, 0x06, 0x05, 0x33, 0x11, 0x2c, 0x6b, 0x00, 0x2d, 0x77, 0x20, 0x48, 0x0d, 0x73, 0x51,
192 0x5f, 0x3a, 0x00, 0x26, 0x3f, 0x13, 0x2e, 0x7e, 0x50, 0x2b, 0x67, 0x46, 0x72, 0x3f, 0x3b, 0x01, 0x46, 0x1b, 0x0b, 0x35, 0x49, 0x39, 192 0x45, 0x25, 0x7f, 0x7f, 0x35, 0x26, 0x2e, 0x26, 0x53, 0x24, 0x68, 0x1e, 0x0e, 0x58, 0x3a,
193 0x19, 0x70, 0x3d, 0x02, 0x41, 0x0e, 0x38, 0x05, 0x76, 0x65, 0x4f, 0x31, 0x6c, 0x5e, 0x17, 0x04, 0x15, 0x36, 0x26, 0x64, 0x34, 0x14, 193 0x59, 0x50, 0x56, 0x37, 0x5f, 0x66, 0x01, 0x4c, 0x5a, 0x64, 0x32, 0x50, 0x7b, 0x6a, 0x20,
194 0x17, 0x7c, 0x0e, 0x0b, 0x5b, 0x55, 0x53, 0x6b, 0x00, 0x42, 0x41, 0x4f, 0x02, 0x5c, 0x13, 0x0a, 0x2c, 0x2c, 0x3e, 0x10, 0x14, 0x33, 194 0x72, 0x2b, 0x1d, 0x7e, 0x43, 0x7b, 0x61, 0x42, 0x0b, 0x61, 0x73, 0x24, 0x79, 0x3a, 0x6b,
195 0x45, 0x7c, 0x7a, 0x5a, 0x31, 0x61, 0x39, 0x08, 0x22, 0x6a, 0x1e, 0x0f, 0x6f, 0x1b, 0x6c, 0x13, 0x5e, 0x79, 0x20, 0x79, 0x50, 0x62, 195 0x4a, 0x79, 0x6e, 0x09, 0x0f, 0x27, 0x2d, 0x0c, 0x5e, 0x32, 0x4b, 0x0d, 0x79, 0x46, 0x39,
196 0x06, 0x2c, 0x76, 0x17, 0x04, 0x2b, 0x2a, 0x75, 0x1f, 0x0c, 0x37, 0x4e, 0x0f, 0x7b, 0x2d, 0x34, 0x75, 0x60, 0x31, 0x74, 0x2e, 0x0a, 196 0x21, 0x0a, 0x26, 0x5f, 0x3a, 0x00, 0x26, 0x3f, 0x13, 0x2e, 0x7e, 0x50, 0x2b, 0x67, 0x46,
197 0x4a, 0x11, 0x6c, 0x49, 0x25, 0x01, 0x3a, 0x3d, 0x22, 0x1e, 0x6d, 0x18, 0x51, 0x78, 0x2d, 0x62, 0x31, 0x4c, 0x50, 0x40, 0x17, 0x4b, 197 0x72, 0x3f, 0x3b, 0x01, 0x46, 0x1b, 0x0b, 0x35, 0x49, 0x39, 0x19, 0x70, 0x3d, 0x02, 0x41,
198 0x6f, 0x22, 0x00, 0x7f, 0x61, 0x2a, 0x34, 0x3e, 0x00, 0x5f, 0x2f, 0x5f, 0x2f, 0x14, 0x2a, 0x55, 0x27, 0x1f, 0x46, 0x1f, 0x12, 0x46, 198 0x0e, 0x38, 0x05, 0x76, 0x65, 0x4f, 0x31, 0x6c, 0x5e, 0x17, 0x04, 0x15, 0x36, 0x26, 0x64,
199 0x5e, 0x1e, 0x0c, 0x7c, 0x38, 0x01, 0x61, 0x64, 0x76, 0x22, 0x6e, 0x08, 0x20, 0x38, 0x4f, 0x73, 0x72, 0x55, 0x12, 0x42, 0x19, 0x50, 199 0x34, 0x14, 0x17, 0x7c, 0x0e, 0x0b, 0x5b, 0x55, 0x53, 0x6b, 0x00, 0x42, 0x41, 0x4f, 0x02,
200 0x61, 0x43, 0x77, 0x7d, 0x41, 0x2e, 0x35, 0x4f, 0x3d, 0x31, 0x28, 0x58, 0x67, 0x1b, 0x03, 0x51, 0x20, 0x32, 0x1c, 0x08, 0x6e, 0x37, 200 0x5c, 0x13, 0x0a, 0x2c, 0x2c, 0x3e, 0x10, 0x14, 0x33, 0x45, 0x7c, 0x7a, 0x5a, 0x31, 0x61,
201 0x75, 0x37, 0x44, 0x4f, 0x68, 0x19, 0x07, 0x64, 0x14, 0x28, 0x25, 0x2b, 0x69, 0x35, 0x18, 0x27, 0x26, 0x14, 0x13, 0x70, 0x42, 0x19, 201 0x39, 0x08, 0x22, 0x6a, 0x1e, 0x0f, 0x6f, 0x1b, 0x6c, 0x13, 0x5e, 0x79, 0x20, 0x79, 0x50,
202 0x12, 0x75, 0x3e, 0x02, 0x5d, 0x7c, 0x13, 0x1f, 0x16, 0x53, 0x3b, 0x74, 0x48, 0x3c, 0x5e, 0x39, 0x6c, 0x1c, 0x1c, 0x74, 0x39, 0x1f, 202 0x62, 0x06, 0x2c, 0x76, 0x17, 0x04, 0x2b, 0x2a, 0x75, 0x1f, 0x0c, 0x37, 0x4e, 0x0f, 0x7b,
203 0x00, 0x1b, 0x06, 0x0a, 0x68, 0x3b, 0x52, 0x4f, 0x1e, 0x6e, 0x3c, 0x35, 0x0c, 0x38, 0x0e, 0x0b, 0x3b, 0x1a, 0x76, 0x23, 0x29, 0x53, 203 0x2d, 0x34, 0x75, 0x60, 0x31, 0x74, 0x2e, 0x0a, 0x4a, 0x11, 0x6c, 0x49, 0x25, 0x01, 0x3a,
204 0x1e, 0x5f, 0x41, 0x0c, 0x4b, 0x0a, 0x65, 0x28, 0x78, 0x67, 0x48, 0x59, 0x26, 0x6d, 0x31, 0x76, 0x23, 0x70, 0x61, 0x64, 0x3b, 0x38, 204 0x3d, 0x22, 0x1e, 0x6d, 0x18, 0x51, 0x78, 0x2d, 0x62, 0x31, 0x4c, 0x50, 0x40, 0x17, 0x4b,
205 0x79, 0x66, 0x74, 0x53, 0x2c, 0x64, 0x64, 0x54, 0x03, 0x54, 0x65, 0x44, 0x4c, 0x18, 0x4f, 0x48, 0x20, 0x4f, 0x72, 0x10, 0x3f, 0x0c, 205 0x6f, 0x22, 0x00, 0x7f, 0x61, 0x2a, 0x34, 0x3e, 0x00, 0x5f, 0x2f, 0x5f, 0x2f, 0x14, 0x2a,
206 0x52, 0x2d, 0x03, 0x14, 0x03, 0x51, 0x42, 0x10, 0x77, 0x6a, 0x34, 0x06, 0x32, 0x03, 0x72, 0x14, 0x7c, 0x08, 0x5d, 0x52, 0x1a, 0x62, 206 0x55, 0x27, 0x1f, 0x46, 0x1f, 0x12, 0x46, 0x5e, 0x1e, 0x0c, 0x7c, 0x38, 0x01, 0x61, 0x64,
207 0x7c, 0x3e, 0x30, 0x7e, 0x5f, 0x7f, 0x54, 0x0f, 0x44, 0x49, 0x5d, 0x5e, 0x10, 0x6a, 0x06, 0x2b, 0x06, 0x53, 0x10, 0x39, 0x37, 0x32, 207 0x76, 0x22, 0x6e, 0x08, 0x20, 0x38, 0x4f, 0x73, 0x72, 0x55, 0x12, 0x42, 0x19, 0x50, 0x61,
208 0x4a, 0x4e, 0x3d, 0x2b, 0x65, 0x38, 0x39, 0x07, 0x72, 0x54, 0x64, 0x4d, 0x56, 0x6a, 0x03, 0x22, 0x70, 0x7b, 0x5f, 0x60, 0x0b, 0x2a, 208 0x43, 0x77, 0x7d, 0x41, 0x2e, 0x35, 0x4f, 0x3d, 0x31, 0x28, 0x58, 0x67, 0x1b, 0x03, 0x51,
209 0x0b, 0x6b, 0x10, 0x64, 0x14, 0x05, 0x22, 0x00, 0x73, 0x40, 0x23, 0x5b, 0x51, 0x1f, 0x2b, 0x1a, 0x5d, 0x69, 0x7a, 0x46, 0x0c, 0x5f, 209 0x20, 0x32, 0x1c, 0x08, 0x6e, 0x37, 0x75, 0x37, 0x44, 0x4f, 0x68, 0x19, 0x07, 0x64, 0x14,
210 0x32, 0x4b, 0x4a, 0x28, 0x52, 0x79, 0x5b, 0x12, 0x42, 0x18, 0x00, 0x5d, 0x27, 0x31, 0x53, 0x3c, 0x4c, 0x36, 0x4e, 0x38, 0x3f, 0x72, 210 0x28, 0x25, 0x2b, 0x69, 0x35, 0x18, 0x27, 0x26, 0x14, 0x13, 0x70, 0x42, 0x19, 0x12, 0x75,
211 0x03, 0x71, 0x02, 0x5b, 0x36, 0x59, 0x7f, 0x75, 0x6e, 0x08, 0x54, 0x0d, 0x34, 0x1c, 0x34, 0x57, 0x5d, 0x69, 0x48, 0x00, 0x3b, 0x05, 211 0x3e, 0x02, 0x5d, 0x7c, 0x13, 0x1f, 0x16, 0x53, 0x3b, 0x74, 0x48, 0x3c, 0x5e, 0x39, 0x6c,
212 0x07, 0x6e, 0x27, 0x65, 0x6e, 0x40, 0x3d, 0x3a, 0x4f, 0x72, 0x5d, 0x39, 0x16, 0x0f, 0x63, 0x12, 0x12, 0x15, 0x3a, 0x70, 0x0d, 0x57, 212 0x1c, 0x1c, 0x74, 0x39, 0x1f, 0x00, 0x1b, 0x06, 0x0a, 0x68, 0x3b, 0x52, 0x4f, 0x1e, 0x6e,
213 0x18, 0x0d, 0x5e, 0x3d, 0x22, 0x68, 0x68, 0x7c, 0x6d, 0x4f, 0x0c, 0x7b, 0x09, 0x2d, 0x4a, 0x73, 0x20, 0x47, 0x07, 0x57, 0x75, 0x5d, 213 0x3c, 0x35, 0x0c, 0x38, 0x0e, 0x0b, 0x3b, 0x1a, 0x76, 0x23, 0x29, 0x53, 0x1e, 0x5f, 0x41,
214 0x53, 0x70, 0x34, 0x21, 0x40, 0x57, 0x51, 0x5e, 0x49, 0x44, 0x00, 0x54, 0x27, 0x04, 0x68, 0x7e, 0x59, 0x56, 0x58, 0x74, 0x14, 0x3c, 214 0x0c, 0x4b, 0x0a, 0x65, 0x28, 0x78, 0x67, 0x48, 0x59, 0x26, 0x6d, 0x31, 0x76, 0x23, 0x70,
215 0x16, 0x33, 0x41, 0x16, 0x4b, 0x2f, 0x49, 0x37, 0x0a, 0x54, 0x08, 0x08, 0x1f, 0x39, 0x67, 0x76, 0x28, 0x28, 0x07, 0x1d, 0x61, 0x47, 215 0x61, 0x64, 0x3b, 0x38, 0x79, 0x66, 0x74, 0x53, 0x2c, 0x64, 0x64, 0x54, 0x03, 0x54, 0x65,
216 0x51, 0x4d, 0x75, 0x26, 0x52, 0x47, 0x47, 0x0c, 0x57, 0x58, 0x74, 0x3e, 0x62, 0x6c, 0x58, 0x3a, 0x44, 0x1e, 0x16, 0x2e, 0x21, 0x1c, 216 0x44, 0x4c, 0x18, 0x4f, 0x48, 0x20, 0x4f, 0x72, 0x10, 0x3f, 0x0c, 0x52, 0x2d, 0x03, 0x14,
217 0x73, 0x45, 0x67, 0x74, 0x4f, 0x33, 0x66, 0x0e, 0x74, 0x66, 0x26, 0x1f, 0x2e, 0x38, 0x44, 0x40, 0x7e, 0x2a, 0x50, 0x52, 0x5e, 0x43, 217 0x03, 0x51, 0x42, 0x10, 0x77, 0x6a, 0x34, 0x06, 0x32, 0x03, 0x72, 0x14, 0x7c, 0x08, 0x5d,
218 0x01, 0x7a, 0x38, 0x49, 0x3c, 0x55, 0x4d, 0x5a, 0x44, 0x08, 0x26, 0x59, 0x4d, 0x45, 0x0b, 0x48, 0x0a, 0x33, 0x5e, 0x4a, 0x4d, 0x75, 218 0x52, 0x1a, 0x62, 0x7c, 0x3e, 0x30, 0x7e, 0x5f, 0x7f, 0x54, 0x0f, 0x44, 0x49, 0x5d, 0x5e,
219 0x16, 0x17, 0x63, 0x46, 0x01, 0x2a, 0x55, 0x7b, 0x0f, 0x02, 0x73, 0x6a, 0x4b, 0x7f, 0x75, 0x65, 0x3c, 0x4c, 0x33, 0x39, 0x6c, 0x74, 219 0x10, 0x6a, 0x06, 0x2b, 0x06, 0x53, 0x10, 0x39, 0x37, 0x32, 0x4a, 0x4e, 0x3d, 0x2b, 0x65,
220 0x05, 0x60, 0x0f, 0x7f, 0x2d, 0x41, 0x4d, 0x4d, 0x46, 0x71, 0x09, 0x6f, 0x4f, 0x60, 0x15, 0x0f, 0x46, 0x73, 0x63, 0x4c, 0x5e, 0x74, 220 0x38, 0x39, 0x07, 0x72, 0x54, 0x64, 0x4d, 0x56, 0x6a, 0x03, 0x22, 0x70, 0x7b, 0x5f, 0x60,
221 0x30, 0x0d, 0x28, 0x43, 0x08, 0x72, 0x32, 0x04, 0x2e, 0x31, 0x29, 0x27, 0x44, 0x6d, 0x13, 0x17, 0x48, 0x0f, 0x49, 0x52, 0x10, 0x13, 221 0x0b, 0x2a, 0x0b, 0x6b, 0x10, 0x64, 0x14, 0x05, 0x22, 0x00, 0x73, 0x40, 0x23, 0x5b, 0x51,
222 0x7f, 0x17, 0x16, 0x62, 0x79, 0x35, 0x78, 0x3e, 0x01, 0x7c, 0x2e, 0x0f, 0x76, 0x3e, 0x5e, 0x53, 0x6c, 0x5b, 0x5f, 0x7c, 0x19, 0x41, 222 0x1f, 0x2b, 0x1a, 0x5d, 0x69, 0x7a, 0x46, 0x0c, 0x5f, 0x32, 0x4b, 0x4a, 0x28, 0x52, 0x79,
223 0x02, 0x2f, 0x17, 0x64, 0x41, 0x75, 0x10, 0x04, 0x47, 0x7c, 0x3d, 0x4b, 0x52, 0x00, 0x10, 0x5d, 0x51, 0x4e, 0x7a, 0x27, 0x25, 0x55, 223 0x5b, 0x12, 0x42, 0x18, 0x00, 0x5d, 0x27, 0x31, 0x53, 0x3c, 0x4c, 0x36, 0x4e, 0x38, 0x3f,
224 0x40, 0x12, 0x35, 0x60, 0x05, 0x1b, 0x34, 0x2d, 0x04, 0x7a, 0x6a, 0x69, 0x02, 0x79, 0x03, 0x3a, 0x2f, 0x06, 0x0a, 0x79, 0x7b, 0x12, 224 0x72, 0x03, 0x71, 0x02, 0x5b, 0x36, 0x59, 0x7f, 0x75, 0x6e, 0x08, 0x54, 0x0d, 0x34, 0x1c,
225 0x5d, 0x7c, 0x52, 0x29, 0x47, 0x58, 0x12, 0x73, 0x3f, 0x27, 0x56, 0x05, 0x0c, 0x48, 0x32, 0x58, 0x6b, 0x57, 0x5c, 0x03, 0x64, 0x56, 225 0x34, 0x57, 0x5d, 0x69, 0x48, 0x00, 0x3b, 0x05, 0x07, 0x6e, 0x27, 0x65, 0x6e, 0x40, 0x3d,
226 0x11, 0x52, 0x7a, 0x30, 0x36, 0x29, 0x17, 0x3b, 0x68, 0x7a, 0x7c, 0x05, 0x6b, 0x6b, 0x13, 0x6a, 0x24, 0x5c, 0x68, 0x42, 0x18, 0x32, 226 0x3a, 0x4f, 0x72, 0x5d, 0x39, 0x16, 0x0f, 0x63, 0x12, 0x12, 0x15, 0x3a, 0x70, 0x0d, 0x57,
227 0x03, 0x73, 0x6e, 0x04, 0x21, 0x2e, 0x01, 0x04, 0x63, 0x7d, 0x44, 0x41, 0x12, 0x31, 0x0b, 0x15, 0x1f, 0x70, 0x00, 0x2e, 0x66, 0x14, 227 0x18, 0x0d, 0x5e, 0x3d, 0x22, 0x68, 0x68, 0x7c, 0x6d, 0x4f, 0x0c, 0x7b, 0x09, 0x2d, 0x4a,
228 0x3c, 0x7f, 0x2b, 0x00, 0x1f, 0x0c, 0x28, 0x59, 0x0a, 0x16, 0x49, 0x5a, 0x5c, 0x64, 0x65, 0x4b, 0x11, 0x29, 0x15, 0x36, 0x5a, 0x65, 228 0x73, 0x20, 0x47, 0x07, 0x57, 0x75, 0x5d, 0x53, 0x70, 0x34, 0x21, 0x40, 0x57, 0x51, 0x5e,
229 0x19, 0x4f, 0x60, 0x23, 0x3a, 0x3a, 0x13, 0x25, 0x02, 0x78, 0x4c, 0x54}; 229 0x49, 0x44, 0x00, 0x54, 0x27, 0x04, 0x68, 0x7e, 0x59, 0x56, 0x58, 0x74, 0x14, 0x3c, 0x16,
230 0x33, 0x41, 0x16, 0x4b, 0x2f, 0x49, 0x37, 0x0a, 0x54, 0x08, 0x08, 0x1f, 0x39, 0x67, 0x76,
231 0x28, 0x28, 0x07, 0x1d, 0x61, 0x47, 0x51, 0x4d, 0x75, 0x26, 0x52, 0x47, 0x47, 0x0c, 0x57,
232 0x58, 0x74, 0x3e, 0x62, 0x6c, 0x58, 0x3a, 0x44, 0x1e, 0x16, 0x2e, 0x21, 0x1c, 0x73, 0x45,
233 0x67, 0x74, 0x4f, 0x33, 0x66, 0x0e, 0x74, 0x66, 0x26, 0x1f, 0x2e, 0x38, 0x44, 0x40, 0x7e,
234 0x2a, 0x50, 0x52, 0x5e, 0x43, 0x01, 0x7a, 0x38, 0x49, 0x3c, 0x55, 0x4d, 0x5a, 0x44, 0x08,
235 0x26, 0x59, 0x4d, 0x45, 0x0b, 0x48, 0x0a, 0x33, 0x5e, 0x4a, 0x4d, 0x75, 0x16, 0x17, 0x63,
236 0x46, 0x01, 0x2a, 0x55, 0x7b, 0x0f, 0x02, 0x73, 0x6a, 0x4b, 0x7f, 0x75, 0x65, 0x3c, 0x4c,
237 0x33, 0x39, 0x6c, 0x74, 0x05, 0x60, 0x0f, 0x7f, 0x2d, 0x41, 0x4d, 0x4d, 0x46, 0x71, 0x09,
238 0x6f, 0x4f, 0x60, 0x15, 0x0f, 0x46, 0x73, 0x63, 0x4c, 0x5e, 0x74, 0x30, 0x0d, 0x28, 0x43,
239 0x08, 0x72, 0x32, 0x04, 0x2e, 0x31, 0x29, 0x27, 0x44, 0x6d, 0x13, 0x17, 0x48, 0x0f, 0x49,
240 0x52, 0x10, 0x13, 0x7f, 0x17, 0x16, 0x62, 0x79, 0x35, 0x78, 0x3e, 0x01, 0x7c, 0x2e, 0x0f,
241 0x76, 0x3e, 0x5e, 0x53, 0x6c, 0x5b, 0x5f, 0x7c, 0x19, 0x41, 0x02, 0x2f, 0x17, 0x64, 0x41,
242 0x75, 0x10, 0x04, 0x47, 0x7c, 0x3d, 0x4b, 0x52, 0x00, 0x10, 0x5d, 0x51, 0x4e, 0x7a, 0x27,
243 0x25, 0x55, 0x40, 0x12, 0x35, 0x60, 0x05, 0x1b, 0x34, 0x2d, 0x04, 0x7a, 0x6a, 0x69, 0x02,
244 0x79, 0x03, 0x3a, 0x2f, 0x06, 0x0a, 0x79, 0x7b, 0x12, 0x5d, 0x7c, 0x52, 0x29, 0x47, 0x58,
245 0x12, 0x73, 0x3f, 0x27, 0x56, 0x05, 0x0c, 0x48, 0x32, 0x58, 0x6b, 0x57, 0x5c, 0x03, 0x64,
246 0x56, 0x11, 0x52, 0x7a, 0x30, 0x36, 0x29, 0x17, 0x3b, 0x68, 0x7a, 0x7c, 0x05, 0x6b, 0x6b,
247 0x13, 0x6a, 0x24, 0x5c, 0x68, 0x42, 0x18, 0x32, 0x03, 0x73, 0x6e, 0x04, 0x21, 0x2e, 0x01,
248 0x04, 0x63, 0x7d, 0x44, 0x41, 0x12, 0x31, 0x0b, 0x15, 0x1f, 0x70, 0x00, 0x2e, 0x66, 0x14,
249 0x3c, 0x7f, 0x2b, 0x00, 0x1f, 0x0c, 0x28, 0x59, 0x0a, 0x16, 0x49, 0x5a, 0x5c, 0x64, 0x65,
250 0x4b, 0x11, 0x29, 0x15, 0x36, 0x5a, 0x65, 0x19, 0x4f, 0x60, 0x23, 0x3a, 0x3a, 0x13, 0x25,
251 0x02, 0x78, 0x4c, 0x54};
230 char b64_known[1369] = { 252 char b64_known[1369] = {
231 0x43, 0x7a, 0x42, 0x45, 0x59, 0x6e, 0x77, 0x69, 0x48, 0x77, 0x30, 0x46, 0x5a, 0x79, 0x77, 0x71, 0x4f, 0x53, 0x46, 0x47, 0x43, 0x46, 253 0x43, 0x7a, 0x42, 0x45, 0x59, 0x6e, 0x77, 0x69, 0x48, 0x77, 0x30, 0x46, 0x5a, 0x79, 0x77,
232 0x42, 0x6d, 0x4e, 0x44, 0x63, 0x4c, 0x52, 0x55, 0x73, 0x34, 0x4d, 0x67, 0x5a, 0x36, 0x50, 0x6e, 0x38, 0x4d, 0x51, 0x42, 0x68, 0x72, 254 0x71, 0x4f, 0x53, 0x46, 0x47, 0x43, 0x46, 0x42, 0x6d, 0x4e, 0x44, 0x63, 0x4c, 0x52, 0x55,
233 0x4c, 0x57, 0x42, 0x4d, 0x59, 0x41, 0x77, 0x6a, 0x51, 0x7a, 0x73, 0x2b, 0x47, 0x78, 0x59, 0x45, 0x52, 0x6c, 0x67, 0x2f, 0x51, 0x47, 255 0x73, 0x34, 0x4d, 0x67, 0x5a, 0x36, 0x50, 0x6e, 0x38, 0x4d, 0x51, 0x42, 0x68, 0x72, 0x4c,
234 0x6f, 0x52, 0x42, 0x57, 0x4e, 0x78, 0x46, 0x44, 0x56, 0x48, 0x65, 0x52, 0x4e, 0x76, 0x61, 0x79, 0x63, 0x59, 0x57, 0x30, 0x67, 0x6e, 256 0x57, 0x42, 0x4d, 0x59, 0x41, 0x77, 0x6a, 0x51, 0x7a, 0x73, 0x2b, 0x47, 0x78, 0x59, 0x45,
235 0x50, 0x6d, 0x38, 0x56, 0x4d, 0x30, 0x38, 0x2b, 0x58, 0x6c, 0x46, 0x7a, 0x61, 0x43, 0x55, 0x50, 0x42, 0x6c, 0x74, 0x38, 0x63, 0x6e, 257 0x52, 0x6c, 0x67, 0x2f, 0x51, 0x47, 0x6f, 0x52, 0x42, 0x57, 0x4e, 0x78, 0x46, 0x44, 0x56,
236 0x55, 0x2b, 0x50, 0x78, 0x74, 0x63, 0x62, 0x57, 0x6f, 0x35, 0x66, 0x47, 0x4e, 0x6a, 0x59, 0x47, 0x78, 0x36, 0x4d, 0x33, 0x5a, 0x53, 258 0x48, 0x65, 0x52, 0x4e, 0x76, 0x61, 0x79, 0x63, 0x59, 0x57, 0x30, 0x67, 0x6e, 0x50, 0x6d,
237 0x45, 0x79, 0x55, 0x7a, 0x66, 0x57, 0x55, 0x6a, 0x4a, 0x78, 0x45, 0x47, 0x42, 0x6b, 0x64, 0x78, 0x48, 0x68, 0x52, 0x30, 0x59, 0x33, 259 0x38, 0x56, 0x4d, 0x30, 0x38, 0x2b, 0x58, 0x6c, 0x46, 0x7a, 0x61, 0x43, 0x55, 0x50, 0x42,
238 0x41, 0x74, 0x46, 0x53, 0x63, 0x59, 0x55, 0x51, 0x59, 0x46, 0x4d, 0x78, 0x45, 0x73, 0x61, 0x77, 0x41, 0x74, 0x64, 0x79, 0x42, 0x49, 260 0x6c, 0x74, 0x38, 0x63, 0x6e, 0x55, 0x2b, 0x50, 0x78, 0x74, 0x63, 0x62, 0x57, 0x6f, 0x35,
239 0x44, 0x58, 0x4e, 0x52, 0x52, 0x53, 0x56, 0x2f, 0x66, 0x7a, 0x55, 0x6d, 0x4c, 0x69, 0x5a, 0x54, 0x4a, 0x47, 0x67, 0x65, 0x44, 0x6c, 261 0x66, 0x47, 0x4e, 0x6a, 0x59, 0x47, 0x78, 0x36, 0x4d, 0x33, 0x5a, 0x53, 0x45, 0x79, 0x55,
240 0x67, 0x36, 0x57, 0x56, 0x42, 0x57, 0x4e, 0x31, 0x39, 0x6d, 0x41, 0x55, 0x78, 0x61, 0x5a, 0x44, 0x4a, 0x51, 0x65, 0x32, 0x6f, 0x67, 262 0x7a, 0x66, 0x57, 0x55, 0x6a, 0x4a, 0x78, 0x45, 0x47, 0x42, 0x6b, 0x64, 0x78, 0x48, 0x68,
241 0x63, 0x69, 0x73, 0x64, 0x66, 0x6b, 0x4e, 0x37, 0x59, 0x55, 0x49, 0x4c, 0x59, 0x58, 0x4d, 0x6b, 0x65, 0x54, 0x70, 0x72, 0x53, 0x6e, 263 0x52, 0x30, 0x59, 0x33, 0x41, 0x74, 0x46, 0x53, 0x63, 0x59, 0x55, 0x51, 0x59, 0x46, 0x4d,
242 0x6c, 0x75, 0x43, 0x51, 0x38, 0x6e, 0x4c, 0x51, 0x78, 0x65, 0x4d, 0x6b, 0x73, 0x4e, 0x65, 0x55, 0x59, 0x35, 0x49, 0x51, 0x6f, 0x6d, 264 0x78, 0x45, 0x73, 0x61, 0x77, 0x41, 0x74, 0x64, 0x79, 0x42, 0x49, 0x44, 0x58, 0x4e, 0x52,
243 0x58, 0x7a, 0x6f, 0x41, 0x4a, 0x6a, 0x38, 0x54, 0x4c, 0x6e, 0x35, 0x51, 0x4b, 0x32, 0x64, 0x47, 0x63, 0x6a, 0x38, 0x37, 0x41, 0x55, 265 0x52, 0x53, 0x56, 0x2f, 0x66, 0x7a, 0x55, 0x6d, 0x4c, 0x69, 0x5a, 0x54, 0x4a, 0x47, 0x67,
244 0x59, 0x62, 0x43, 0x7a, 0x56, 0x4a, 0x4f, 0x52, 0x6c, 0x77, 0x50, 0x51, 0x4a, 0x42, 0x44, 0x6a, 0x67, 0x46, 0x64, 0x6d, 0x56, 0x50, 266 0x65, 0x44, 0x6c, 0x67, 0x36, 0x57, 0x56, 0x42, 0x57, 0x4e, 0x31, 0x39, 0x6d, 0x41, 0x55,
245 0x4d, 0x57, 0x78, 0x65, 0x46, 0x77, 0x51, 0x56, 0x4e, 0x69, 0x5a, 0x6b, 0x4e, 0x42, 0x51, 0x58, 0x66, 0x41, 0x34, 0x4c, 0x57, 0x31, 267 0x78, 0x61, 0x5a, 0x44, 0x4a, 0x51, 0x65, 0x32, 0x6f, 0x67, 0x63, 0x69, 0x73, 0x64, 0x66,
246 0x56, 0x54, 0x61, 0x77, 0x42, 0x43, 0x51, 0x55, 0x38, 0x43, 0x58, 0x42, 0x4d, 0x4b, 0x4c, 0x43, 0x77, 0x2b, 0x45, 0x42, 0x51, 0x7a, 268 0x6b, 0x4e, 0x37, 0x59, 0x55, 0x49, 0x4c, 0x59, 0x58, 0x4d, 0x6b, 0x65, 0x54, 0x70, 0x72,
247 0x52, 0x58, 0x78, 0x36, 0x57, 0x6a, 0x46, 0x68, 0x4f, 0x51, 0x67, 0x69, 0x61, 0x68, 0x34, 0x50, 0x62, 0x78, 0x74, 0x73, 0x45, 0x31, 269 0x53, 0x6e, 0x6c, 0x75, 0x43, 0x51, 0x38, 0x6e, 0x4c, 0x51, 0x78, 0x65, 0x4d, 0x6b, 0x73,
248 0x35, 0x35, 0x49, 0x48, 0x6c, 0x51, 0x59, 0x67, 0x59, 0x73, 0x64, 0x68, 0x63, 0x45, 0x4b, 0x79, 0x70, 0x31, 0x48, 0x77, 0x77, 0x33, 270 0x4e, 0x65, 0x55, 0x59, 0x35, 0x49, 0x51, 0x6f, 0x6d, 0x58, 0x7a, 0x6f, 0x41, 0x4a, 0x6a,
249 0x54, 0x67, 0x39, 0x37, 0x4c, 0x54, 0x52, 0x31, 0x59, 0x44, 0x46, 0x30, 0x4c, 0x67, 0x70, 0x4b, 0x45, 0x57, 0x78, 0x4a, 0x4a, 0x51, 271 0x38, 0x54, 0x4c, 0x6e, 0x35, 0x51, 0x4b, 0x32, 0x64, 0x47, 0x63, 0x6a, 0x38, 0x37, 0x41,
250 0x45, 0x36, 0x50, 0x53, 0x49, 0x65, 0x62, 0x52, 0x68, 0x52, 0x65, 0x43, 0x31, 0x69, 0x4d, 0x55, 0x78, 0x51, 0x51, 0x42, 0x64, 0x4c, 272 0x55, 0x59, 0x62, 0x43, 0x7a, 0x56, 0x4a, 0x4f, 0x52, 0x6c, 0x77, 0x50, 0x51, 0x4a, 0x42,
251 0x62, 0x79, 0x49, 0x41, 0x66, 0x32, 0x45, 0x71, 0x4e, 0x44, 0x34, 0x41, 0x58, 0x79, 0x39, 0x66, 0x4c, 0x78, 0x51, 0x71, 0x56, 0x53, 273 0x44, 0x6a, 0x67, 0x46, 0x64, 0x6d, 0x56, 0x50, 0x4d, 0x57, 0x78, 0x65, 0x46, 0x77, 0x51,
252 0x63, 0x66, 0x52, 0x68, 0x38, 0x53, 0x52, 0x6c, 0x34, 0x65, 0x44, 0x48, 0x77, 0x34, 0x41, 0x57, 0x46, 0x6b, 0x64, 0x69, 0x4a, 0x75, 274 0x56, 0x4e, 0x69, 0x5a, 0x6b, 0x4e, 0x42, 0x51, 0x58, 0x66, 0x41, 0x34, 0x4c, 0x57, 0x31,
253 0x43, 0x43, 0x41, 0x34, 0x54, 0x33, 0x4e, 0x79, 0x56, 0x52, 0x4a, 0x43, 0x47, 0x56, 0x42, 0x68, 0x51, 0x33, 0x64, 0x39, 0x51, 0x53, 275 0x56, 0x54, 0x61, 0x77, 0x42, 0x43, 0x51, 0x55, 0x38, 0x43, 0x58, 0x42, 0x4d, 0x4b, 0x4c,
254 0x34, 0x31, 0x54, 0x7a, 0x30, 0x78, 0x4b, 0x46, 0x68, 0x6e, 0x47, 0x77, 0x4e, 0x52, 0x49, 0x44, 0x49, 0x63, 0x43, 0x47, 0x34, 0x33, 276 0x43, 0x77, 0x2b, 0x45, 0x42, 0x51, 0x7a, 0x52, 0x58, 0x78, 0x36, 0x57, 0x6a, 0x46, 0x68,
255 0x64, 0x54, 0x64, 0x45, 0x54, 0x32, 0x67, 0x5a, 0x42, 0x32, 0x51, 0x55, 0x4b, 0x43, 0x55, 0x72, 0x61, 0x54, 0x55, 0x59, 0x4a, 0x79, 277 0x4f, 0x51, 0x67, 0x69, 0x61, 0x68, 0x34, 0x50, 0x62, 0x78, 0x74, 0x73, 0x45, 0x31, 0x35,
256 0x59, 0x55, 0x45, 0x33, 0x42, 0x43, 0x47, 0x52, 0x4a, 0x31, 0x50, 0x67, 0x4a, 0x64, 0x66, 0x42, 0x4d, 0x66, 0x46, 0x6c, 0x4d, 0x37, 278 0x35, 0x49, 0x48, 0x6c, 0x51, 0x59, 0x67, 0x59, 0x73, 0x64, 0x68, 0x63, 0x45, 0x4b, 0x79,
257 0x64, 0x45, 0x67, 0x38, 0x58, 0x6a, 0x6c, 0x73, 0x48, 0x42, 0x78, 0x30, 0x4f, 0x52, 0x38, 0x41, 0x47, 0x77, 0x59, 0x4b, 0x61, 0x44, 279 0x70, 0x31, 0x48, 0x77, 0x77, 0x33, 0x54, 0x67, 0x39, 0x37, 0x4c, 0x54, 0x52, 0x31, 0x59,
258 0x74, 0x53, 0x54, 0x78, 0x35, 0x75, 0x50, 0x44, 0x55, 0x4d, 0x4f, 0x41, 0x34, 0x4c, 0x4f, 0x78, 0x70, 0x32, 0x49, 0x79, 0x6c, 0x54, 280 0x44, 0x46, 0x30, 0x4c, 0x67, 0x70, 0x4b, 0x45, 0x57, 0x78, 0x4a, 0x4a, 0x51, 0x45, 0x36,
259 0x48, 0x6c, 0x39, 0x42, 0x44, 0x45, 0x73, 0x4b, 0x5a, 0x53, 0x68, 0x34, 0x5a, 0x30, 0x68, 0x5a, 0x4a, 0x6d, 0x30, 0x78, 0x64, 0x69, 281 0x50, 0x53, 0x49, 0x65, 0x62, 0x52, 0x68, 0x52, 0x65, 0x43, 0x31, 0x69, 0x4d, 0x55, 0x78,
260 0x4e, 0x77, 0x59, 0x57, 0x51, 0x37, 0x4f, 0x48, 0x6c, 0x6d, 0x64, 0x46, 0x4d, 0x73, 0x5a, 0x47, 0x52, 0x55, 0x41, 0x31, 0x52, 0x6c, 282 0x51, 0x51, 0x42, 0x64, 0x4c, 0x62, 0x79, 0x49, 0x41, 0x66, 0x32, 0x45, 0x71, 0x4e, 0x44,
261 0x52, 0x45, 0x77, 0x59, 0x54, 0x30, 0x67, 0x67, 0x54, 0x33, 0x49, 0x51, 0x50, 0x77, 0x78, 0x53, 0x4c, 0x51, 0x4d, 0x55, 0x41, 0x31, 283 0x34, 0x41, 0x58, 0x79, 0x39, 0x66, 0x4c, 0x78, 0x51, 0x71, 0x56, 0x53, 0x63, 0x66, 0x52,
262 0x46, 0x43, 0x45, 0x48, 0x64, 0x71, 0x4e, 0x41, 0x59, 0x79, 0x41, 0x33, 0x49, 0x55, 0x66, 0x41, 0x68, 0x64, 0x55, 0x68, 0x70, 0x69, 284 0x68, 0x38, 0x53, 0x52, 0x6c, 0x34, 0x65, 0x44, 0x48, 0x77, 0x34, 0x41, 0x57, 0x46, 0x6b,
263 0x66, 0x44, 0x34, 0x77, 0x66, 0x6c, 0x39, 0x2f, 0x56, 0x41, 0x39, 0x45, 0x53, 0x56, 0x31, 0x65, 0x45, 0x47, 0x6f, 0x47, 0x4b, 0x77, 285 0x64, 0x69, 0x4a, 0x75, 0x43, 0x43, 0x41, 0x34, 0x54, 0x33, 0x4e, 0x79, 0x56, 0x52, 0x4a,
264 0x5a, 0x54, 0x45, 0x44, 0x6b, 0x33, 0x4d, 0x6b, 0x70, 0x4f, 0x50, 0x53, 0x74, 0x6c, 0x4f, 0x44, 0x6b, 0x48, 0x63, 0x6c, 0x52, 0x6b, 286 0x43, 0x47, 0x56, 0x42, 0x68, 0x51, 0x33, 0x64, 0x39, 0x51, 0x53, 0x34, 0x31, 0x54, 0x7a,
265 0x54, 0x56, 0x5a, 0x71, 0x41, 0x79, 0x4a, 0x77, 0x65, 0x31, 0x39, 0x67, 0x43, 0x79, 0x6f, 0x4c, 0x61, 0x78, 0x42, 0x6b, 0x46, 0x41, 287 0x30, 0x78, 0x4b, 0x46, 0x68, 0x6e, 0x47, 0x77, 0x4e, 0x52, 0x49, 0x44, 0x49, 0x63, 0x43,
266 0x55, 0x69, 0x41, 0x48, 0x4e, 0x41, 0x49, 0x31, 0x74, 0x52, 0x48, 0x79, 0x73, 0x61, 0x58, 0x57, 0x6c, 0x36, 0x52, 0x67, 0x78, 0x66, 288 0x47, 0x34, 0x33, 0x64, 0x54, 0x64, 0x45, 0x54, 0x32, 0x67, 0x5a, 0x42, 0x32, 0x51, 0x55,
267 0x4d, 0x6b, 0x74, 0x4b, 0x4b, 0x46, 0x4a, 0x35, 0x57, 0x78, 0x4a, 0x43, 0x47, 0x41, 0x42, 0x64, 0x4a, 0x7a, 0x46, 0x54, 0x50, 0x45, 289 0x4b, 0x43, 0x55, 0x72, 0x61, 0x54, 0x55, 0x59, 0x4a, 0x79, 0x59, 0x55, 0x45, 0x33, 0x42,
268 0x77, 0x32, 0x54, 0x6a, 0x67, 0x2f, 0x63, 0x67, 0x4e, 0x78, 0x41, 0x6c, 0x73, 0x32, 0x57, 0x58, 0x39, 0x31, 0x62, 0x67, 0x68, 0x55, 290 0x43, 0x47, 0x52, 0x4a, 0x31, 0x50, 0x67, 0x4a, 0x64, 0x66, 0x42, 0x4d, 0x66, 0x46, 0x6c,
269 0x44, 0x54, 0x51, 0x63, 0x4e, 0x46, 0x64, 0x64, 0x61, 0x55, 0x67, 0x41, 0x4f, 0x77, 0x55, 0x48, 0x62, 0x69, 0x64, 0x6c, 0x62, 0x6b, 291 0x4d, 0x37, 0x64, 0x45, 0x67, 0x38, 0x58, 0x6a, 0x6c, 0x73, 0x48, 0x42, 0x78, 0x30, 0x4f,
270 0x41, 0x39, 0x4f, 0x6b, 0x39, 0x79, 0x58, 0x54, 0x6b, 0x57, 0x44, 0x32, 0x4d, 0x53, 0x45, 0x68, 0x55, 0x36, 0x63, 0x41, 0x31, 0x58, 292 0x52, 0x38, 0x41, 0x47, 0x77, 0x59, 0x4b, 0x61, 0x44, 0x74, 0x53, 0x54, 0x78, 0x35, 0x75,
271 0x47, 0x41, 0x31, 0x65, 0x50, 0x53, 0x4a, 0x6f, 0x61, 0x48, 0x78, 0x74, 0x54, 0x77, 0x78, 0x37, 0x43, 0x53, 0x31, 0x4b, 0x63, 0x79, 293 0x50, 0x44, 0x55, 0x4d, 0x4f, 0x41, 0x34, 0x4c, 0x4f, 0x78, 0x70, 0x32, 0x49, 0x79, 0x6c,
272 0x42, 0x48, 0x42, 0x31, 0x64, 0x31, 0x58, 0x56, 0x4e, 0x77, 0x4e, 0x43, 0x46, 0x41, 0x56, 0x31, 0x46, 0x65, 0x53, 0x55, 0x51, 0x41, 294 0x54, 0x48, 0x6c, 0x39, 0x42, 0x44, 0x45, 0x73, 0x4b, 0x5a, 0x53, 0x68, 0x34, 0x5a, 0x30,
273 0x56, 0x43, 0x63, 0x45, 0x61, 0x48, 0x35, 0x5a, 0x56, 0x6c, 0x68, 0x30, 0x46, 0x44, 0x77, 0x57, 0x4d, 0x30, 0x45, 0x57, 0x53, 0x79, 295 0x68, 0x5a, 0x4a, 0x6d, 0x30, 0x78, 0x64, 0x69, 0x4e, 0x77, 0x59, 0x57, 0x51, 0x37, 0x4f,
274 0x39, 0x4a, 0x4e, 0x77, 0x70, 0x55, 0x43, 0x41, 0x67, 0x66, 0x4f, 0x57, 0x64, 0x32, 0x4b, 0x43, 0x67, 0x48, 0x48, 0x57, 0x46, 0x48, 296 0x48, 0x6c, 0x6d, 0x64, 0x46, 0x4d, 0x73, 0x5a, 0x47, 0x52, 0x55, 0x41, 0x31, 0x52, 0x6c,
275 0x55, 0x55, 0x31, 0x31, 0x4a, 0x6c, 0x4a, 0x48, 0x52, 0x77, 0x78, 0x58, 0x57, 0x48, 0x51, 0x2b, 0x59, 0x6d, 0x78, 0x59, 0x4f, 0x6b, 297 0x52, 0x45, 0x77, 0x59, 0x54, 0x30, 0x67, 0x67, 0x54, 0x33, 0x49, 0x51, 0x50, 0x77, 0x78,
276 0x51, 0x65, 0x46, 0x69, 0x34, 0x68, 0x48, 0x48, 0x4e, 0x46, 0x5a, 0x33, 0x52, 0x50, 0x4d, 0x32, 0x59, 0x4f, 0x64, 0x47, 0x59, 0x6d, 298 0x53, 0x4c, 0x51, 0x4d, 0x55, 0x41, 0x31, 0x46, 0x43, 0x45, 0x48, 0x64, 0x71, 0x4e, 0x41,
277 0x48, 0x79, 0x34, 0x34, 0x52, 0x45, 0x42, 0x2b, 0x4b, 0x6c, 0x42, 0x53, 0x58, 0x6b, 0x4d, 0x42, 0x65, 0x6a, 0x68, 0x4a, 0x50, 0x46, 299 0x59, 0x79, 0x41, 0x33, 0x49, 0x55, 0x66, 0x41, 0x68, 0x64, 0x55, 0x68, 0x70, 0x69, 0x66,
278 0x56, 0x4e, 0x57, 0x6b, 0x51, 0x49, 0x4a, 0x6c, 0x6c, 0x4e, 0x52, 0x51, 0x74, 0x49, 0x43, 0x6a, 0x4e, 0x65, 0x53, 0x6b, 0x31, 0x31, 300 0x44, 0x34, 0x77, 0x66, 0x6c, 0x39, 0x2f, 0x56, 0x41, 0x39, 0x45, 0x53, 0x56, 0x31, 0x65,
279 0x46, 0x68, 0x64, 0x6a, 0x52, 0x67, 0x45, 0x71, 0x56, 0x58, 0x73, 0x50, 0x41, 0x6e, 0x4e, 0x71, 0x53, 0x33, 0x39, 0x31, 0x5a, 0x54, 301 0x45, 0x47, 0x6f, 0x47, 0x4b, 0x77, 0x5a, 0x54, 0x45, 0x44, 0x6b, 0x33, 0x4d, 0x6b, 0x70,
280 0x78, 0x4d, 0x4d, 0x7a, 0x6c, 0x73, 0x64, 0x41, 0x56, 0x67, 0x44, 0x33, 0x38, 0x74, 0x51, 0x55, 0x31, 0x4e, 0x52, 0x6e, 0x45, 0x4a, 302 0x4f, 0x50, 0x53, 0x74, 0x6c, 0x4f, 0x44, 0x6b, 0x48, 0x63, 0x6c, 0x52, 0x6b, 0x54, 0x56,
281 0x62, 0x30, 0x39, 0x67, 0x46, 0x51, 0x39, 0x47, 0x63, 0x32, 0x4e, 0x4d, 0x58, 0x6e, 0x51, 0x77, 0x44, 0x53, 0x68, 0x44, 0x43, 0x48, 303 0x5a, 0x71, 0x41, 0x79, 0x4a, 0x77, 0x65, 0x31, 0x39, 0x67, 0x43, 0x79, 0x6f, 0x4c, 0x61,
282 0x49, 0x79, 0x42, 0x43, 0x34, 0x78, 0x4b, 0x53, 0x64, 0x45, 0x62, 0x52, 0x4d, 0x58, 0x53, 0x41, 0x39, 0x4a, 0x55, 0x68, 0x41, 0x54, 304 0x78, 0x42, 0x6b, 0x46, 0x41, 0x55, 0x69, 0x41, 0x48, 0x4e, 0x41, 0x49, 0x31, 0x74, 0x52,
283 0x66, 0x78, 0x63, 0x57, 0x59, 0x6e, 0x6b, 0x31, 0x65, 0x44, 0x34, 0x42, 0x66, 0x43, 0x34, 0x50, 0x64, 0x6a, 0x35, 0x65, 0x55, 0x32, 305 0x48, 0x79, 0x73, 0x61, 0x58, 0x57, 0x6c, 0x36, 0x52, 0x67, 0x78, 0x66, 0x4d, 0x6b, 0x74,
284 0x78, 0x62, 0x58, 0x33, 0x77, 0x5a, 0x51, 0x51, 0x49, 0x76, 0x46, 0x32, 0x52, 0x42, 0x64, 0x52, 0x41, 0x45, 0x52, 0x33, 0x77, 0x39, 306 0x4b, 0x4b, 0x46, 0x4a, 0x35, 0x57, 0x78, 0x4a, 0x43, 0x47, 0x41, 0x42, 0x64, 0x4a, 0x7a,
285 0x53, 0x31, 0x49, 0x41, 0x45, 0x46, 0x31, 0x52, 0x54, 0x6e, 0x6f, 0x6e, 0x4a, 0x56, 0x56, 0x41, 0x45, 0x6a, 0x56, 0x67, 0x42, 0x52, 307 0x46, 0x54, 0x50, 0x45, 0x77, 0x32, 0x54, 0x6a, 0x67, 0x2f, 0x63, 0x67, 0x4e, 0x78, 0x41,
286 0x73, 0x30, 0x4c, 0x51, 0x52, 0x36, 0x61, 0x6d, 0x6b, 0x43, 0x65, 0x51, 0x4d, 0x36, 0x4c, 0x77, 0x59, 0x4b, 0x65, 0x58, 0x73, 0x53, 308 0x6c, 0x73, 0x32, 0x57, 0x58, 0x39, 0x31, 0x62, 0x67, 0x68, 0x55, 0x44, 0x54, 0x51, 0x63,
287 0x58, 0x58, 0x78, 0x53, 0x4b, 0x55, 0x64, 0x59, 0x45, 0x6e, 0x4d, 0x2f, 0x4a, 0x31, 0x59, 0x46, 0x44, 0x45, 0x67, 0x79, 0x57, 0x47, 309 0x4e, 0x46, 0x64, 0x64, 0x61, 0x55, 0x67, 0x41, 0x4f, 0x77, 0x55, 0x48, 0x62, 0x69, 0x64,
288 0x74, 0x58, 0x58, 0x41, 0x4e, 0x6b, 0x56, 0x68, 0x46, 0x53, 0x65, 0x6a, 0x41, 0x32, 0x4b, 0x52, 0x63, 0x37, 0x61, 0x48, 0x70, 0x38, 310 0x6c, 0x62, 0x6b, 0x41, 0x39, 0x4f, 0x6b, 0x39, 0x79, 0x58, 0x54, 0x6b, 0x57, 0x44, 0x32,
289 0x42, 0x57, 0x74, 0x72, 0x45, 0x32, 0x6f, 0x6b, 0x58, 0x47, 0x68, 0x43, 0x47, 0x44, 0x49, 0x44, 0x63, 0x32, 0x34, 0x45, 0x49, 0x53, 311 0x4d, 0x53, 0x45, 0x68, 0x55, 0x36, 0x63, 0x41, 0x31, 0x58, 0x47, 0x41, 0x31, 0x65, 0x50,
290 0x34, 0x42, 0x42, 0x47, 0x4e, 0x39, 0x52, 0x45, 0x45, 0x53, 0x4d, 0x51, 0x73, 0x56, 0x48, 0x33, 0x41, 0x41, 0x4c, 0x6d, 0x59, 0x55, 312 0x53, 0x4a, 0x6f, 0x61, 0x48, 0x78, 0x74, 0x54, 0x77, 0x78, 0x37, 0x43, 0x53, 0x31, 0x4b,
291 0x50, 0x48, 0x38, 0x72, 0x41, 0x42, 0x38, 0x4d, 0x4b, 0x46, 0x6b, 0x4b, 0x46, 0x6b, 0x6c, 0x61, 0x58, 0x47, 0x52, 0x6c, 0x53, 0x78, 313 0x63, 0x79, 0x42, 0x48, 0x42, 0x31, 0x64, 0x31, 0x58, 0x56, 0x4e, 0x77, 0x4e, 0x43, 0x46,
292 0x45, 0x70, 0x46, 0x54, 0x5a, 0x61, 0x5a, 0x52, 0x6c, 0x50, 0x59, 0x43, 0x4d, 0x36, 0x4f, 0x68, 0x4d, 0x6c, 0x41, 0x6e, 0x68, 0x4d, 314 0x41, 0x56, 0x31, 0x46, 0x65, 0x53, 0x55, 0x51, 0x41, 0x56, 0x43, 0x63, 0x45, 0x61, 0x48,
293 0x56, 0x41, 0x3d, 0x3d, 0x00}; 315 0x35, 0x5a, 0x56, 0x6c, 0x68, 0x30, 0x46, 0x44, 0x77, 0x57, 0x4d, 0x30, 0x45, 0x57, 0x53,
316 0x79, 0x39, 0x4a, 0x4e, 0x77, 0x70, 0x55, 0x43, 0x41, 0x67, 0x66, 0x4f, 0x57, 0x64, 0x32,
317 0x4b, 0x43, 0x67, 0x48, 0x48, 0x57, 0x46, 0x48, 0x55, 0x55, 0x31, 0x31, 0x4a, 0x6c, 0x4a,
318 0x48, 0x52, 0x77, 0x78, 0x58, 0x57, 0x48, 0x51, 0x2b, 0x59, 0x6d, 0x78, 0x59, 0x4f, 0x6b,
319 0x51, 0x65, 0x46, 0x69, 0x34, 0x68, 0x48, 0x48, 0x4e, 0x46, 0x5a, 0x33, 0x52, 0x50, 0x4d,
320 0x32, 0x59, 0x4f, 0x64, 0x47, 0x59, 0x6d, 0x48, 0x79, 0x34, 0x34, 0x52, 0x45, 0x42, 0x2b,
321 0x4b, 0x6c, 0x42, 0x53, 0x58, 0x6b, 0x4d, 0x42, 0x65, 0x6a, 0x68, 0x4a, 0x50, 0x46, 0x56,
322 0x4e, 0x57, 0x6b, 0x51, 0x49, 0x4a, 0x6c, 0x6c, 0x4e, 0x52, 0x51, 0x74, 0x49, 0x43, 0x6a,
323 0x4e, 0x65, 0x53, 0x6b, 0x31, 0x31, 0x46, 0x68, 0x64, 0x6a, 0x52, 0x67, 0x45, 0x71, 0x56,
324 0x58, 0x73, 0x50, 0x41, 0x6e, 0x4e, 0x71, 0x53, 0x33, 0x39, 0x31, 0x5a, 0x54, 0x78, 0x4d,
325 0x4d, 0x7a, 0x6c, 0x73, 0x64, 0x41, 0x56, 0x67, 0x44, 0x33, 0x38, 0x74, 0x51, 0x55, 0x31,
326 0x4e, 0x52, 0x6e, 0x45, 0x4a, 0x62, 0x30, 0x39, 0x67, 0x46, 0x51, 0x39, 0x47, 0x63, 0x32,
327 0x4e, 0x4d, 0x58, 0x6e, 0x51, 0x77, 0x44, 0x53, 0x68, 0x44, 0x43, 0x48, 0x49, 0x79, 0x42,
328 0x43, 0x34, 0x78, 0x4b, 0x53, 0x64, 0x45, 0x62, 0x52, 0x4d, 0x58, 0x53, 0x41, 0x39, 0x4a,
329 0x55, 0x68, 0x41, 0x54, 0x66, 0x78, 0x63, 0x57, 0x59, 0x6e, 0x6b, 0x31, 0x65, 0x44, 0x34,
330 0x42, 0x66, 0x43, 0x34, 0x50, 0x64, 0x6a, 0x35, 0x65, 0x55, 0x32, 0x78, 0x62, 0x58, 0x33,
331 0x77, 0x5a, 0x51, 0x51, 0x49, 0x76, 0x46, 0x32, 0x52, 0x42, 0x64, 0x52, 0x41, 0x45, 0x52,
332 0x33, 0x77, 0x39, 0x53, 0x31, 0x49, 0x41, 0x45, 0x46, 0x31, 0x52, 0x54, 0x6e, 0x6f, 0x6e,
333 0x4a, 0x56, 0x56, 0x41, 0x45, 0x6a, 0x56, 0x67, 0x42, 0x52, 0x73, 0x30, 0x4c, 0x51, 0x52,
334 0x36, 0x61, 0x6d, 0x6b, 0x43, 0x65, 0x51, 0x4d, 0x36, 0x4c, 0x77, 0x59, 0x4b, 0x65, 0x58,
335 0x73, 0x53, 0x58, 0x58, 0x78, 0x53, 0x4b, 0x55, 0x64, 0x59, 0x45, 0x6e, 0x4d, 0x2f, 0x4a,
336 0x31, 0x59, 0x46, 0x44, 0x45, 0x67, 0x79, 0x57, 0x47, 0x74, 0x58, 0x58, 0x41, 0x4e, 0x6b,
337 0x56, 0x68, 0x46, 0x53, 0x65, 0x6a, 0x41, 0x32, 0x4b, 0x52, 0x63, 0x37, 0x61, 0x48, 0x70,
338 0x38, 0x42, 0x57, 0x74, 0x72, 0x45, 0x32, 0x6f, 0x6b, 0x58, 0x47, 0x68, 0x43, 0x47, 0x44,
339 0x49, 0x44, 0x63, 0x32, 0x34, 0x45, 0x49, 0x53, 0x34, 0x42, 0x42, 0x47, 0x4e, 0x39, 0x52,
340 0x45, 0x45, 0x53, 0x4d, 0x51, 0x73, 0x56, 0x48, 0x33, 0x41, 0x41, 0x4c, 0x6d, 0x59, 0x55,
341 0x50, 0x48, 0x38, 0x72, 0x41, 0x42, 0x38, 0x4d, 0x4b, 0x46, 0x6b, 0x4b, 0x46, 0x6b, 0x6c,
342 0x61, 0x58, 0x47, 0x52, 0x6c, 0x53, 0x78, 0x45, 0x70, 0x46, 0x54, 0x5a, 0x61, 0x5a, 0x52,
343 0x6c, 0x50, 0x59, 0x43, 0x4d, 0x36, 0x4f, 0x68, 0x4d, 0x6c, 0x41, 0x6e, 0x68, 0x4d, 0x56,
344 0x41, 0x3d, 0x3d, 0x00};
294 char *b64_test; 345 char *b64_test;
295 346
296 plan_tests(1); 347 plan_tests(1);
diff --git a/lib/tests/test_cmd.c b/lib/tests/test_cmd.c
index c8867dfb..ade0da90 100644
--- a/lib/tests/test_cmd.c
+++ b/lib/tests/test_cmd.c
@@ -67,7 +67,8 @@ int main(int argc, char **argv) {
67 result = cmd_run_array(command_line, &chld_out, &chld_err, 0); 67 result = cmd_run_array(command_line, &chld_out, &chld_err, 0);
68 ok(chld_out.lines == 1, "(array) Check for expected number of stdout lines"); 68 ok(chld_out.lines == 1, "(array) Check for expected number of stdout lines");
69 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines"); 69 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines");
70 ok(strcmp(chld_out.line[0], "this is test one") == 0, "(array) Check for expected stdout output"); 70 ok(strcmp(chld_out.line[0], "this is test one") == 0,
71 "(array) Check for expected stdout output");
71 ok(result == 0, "(array) Checking exit code"); 72 ok(result == 0, "(array) Checking exit code");
72 73
73 /* ensure everything is empty again */ 74 /* ensure everything is empty again */
@@ -82,7 +83,8 @@ int main(int argc, char **argv) {
82 83
83 ok(chld_out.lines == 1, "(string) Check for expected number of stdout lines"); 84 ok(chld_out.lines == 1, "(string) Check for expected number of stdout lines");
84 ok(chld_err.lines == 0, "(string) Check for expected number of stderr lines"); 85 ok(chld_err.lines == 0, "(string) Check for expected number of stderr lines");
85 ok(strcmp(chld_out.line[0], "this is test one") == 0, "(string) Check for expected stdout output"); 86 ok(strcmp(chld_out.line[0], "this is test one") == 0,
87 "(string) Check for expected stdout output");
86 ok(result == 0, "(string) Checking exit code"); 88 ok(result == 0, "(string) Checking exit code");
87 89
88 diag("Running plain echo command, set two"); 90 diag("Running plain echo command, set two");
@@ -104,7 +106,8 @@ int main(int argc, char **argv) {
104 result = cmd_run_array(command_line, &chld_out, &chld_err, 0); 106 result = cmd_run_array(command_line, &chld_out, &chld_err, 0);
105 ok(chld_out.lines == 1, "(array) Check for expected number of stdout lines"); 107 ok(chld_out.lines == 1, "(array) Check for expected number of stdout lines");
106 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines"); 108 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines");
107 ok(strcmp(chld_out.line[0], "this is test two") == 0, "(array) Check for expected stdout output"); 109 ok(strcmp(chld_out.line[0], "this is test two") == 0,
110 "(array) Check for expected stdout output");
108 ok(result == 0, "(array) Checking exit code"); 111 ok(result == 0, "(array) Checking exit code");
109 112
110 /* ensure everything is empty again */ 113 /* ensure everything is empty again */
@@ -119,7 +122,8 @@ int main(int argc, char **argv) {
119 122
120 ok(chld_out.lines == 1, "(string) Check for expected number of stdout lines"); 123 ok(chld_out.lines == 1, "(string) Check for expected number of stdout lines");
121 ok(chld_err.lines == 0, "(string) Check for expected number of stderr lines"); 124 ok(chld_err.lines == 0, "(string) Check for expected number of stderr lines");
122 ok(strcmp(chld_out.line[0], "this is test one") == 0, "(string) Check for expected stdout output"); 125 ok(strcmp(chld_out.line[0], "this is test one") == 0,
126 "(string) Check for expected stdout output");
123 ok(result == 0, "(string) Checking exit code"); 127 ok(result == 0, "(string) Checking exit code");
124 128
125 /* ensure everything is empty again */ 129 /* ensure everything is empty again */
@@ -130,7 +134,8 @@ int main(int argc, char **argv) {
130 ok(chld_err.lines == 0, "(initialised) Checking stderr is reset"); 134 ok(chld_err.lines == 0, "(initialised) Checking stderr is reset");
131 ok(result == UNSET, "(initialised) Checking exit code is reset"); 135 ok(result == UNSET, "(initialised) Checking exit code is reset");
132 136
133 /* Pass linefeeds via parameters through - those should be evaluated by echo to give multi line output */ 137 /* Pass linefeeds via parameters through - those should be evaluated by echo to give multi line
138 * output */
134 command_line[0] = strdup("/bin/echo"); 139 command_line[0] = strdup("/bin/echo");
135 command_line[1] = strdup("this is a test via echo\nline two\nit's line 3"); 140 command_line[1] = strdup("this is a test via echo\nline two\nit's line 3");
136 command_line[2] = strdup("and (note space between '3' and 'and') $$ will not get evaluated"); 141 command_line[2] = strdup("and (note space between '3' and 'and') $$ will not get evaluated");
@@ -138,9 +143,12 @@ int main(int argc, char **argv) {
138 result = cmd_run_array(command_line, &chld_out, &chld_err, 0); 143 result = cmd_run_array(command_line, &chld_out, &chld_err, 0);
139 ok(chld_out.lines == 3, "(array) Check for expected number of stdout lines"); 144 ok(chld_out.lines == 3, "(array) Check for expected number of stdout lines");
140 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines"); 145 ok(chld_err.lines == 0, "(array) Check for expected number of stderr lines");
141 ok(strcmp(chld_out.line[0], "this is a test via echo") == 0, "(array) Check line 1 for expected stdout output"); 146 ok(strcmp(chld_out.line[0], "this is a test via echo") == 0,
142 ok(strcmp(chld_out.line[1], "line two") == 0, "(array) Check line 2 for expected stdout output"); 147 "(array) Check line 1 for expected stdout output");
143 ok(strcmp(chld_out.line[2], "it's line 3 and (note space between '3' and 'and') $$ will not get evaluated") == 0, 148 ok(strcmp(chld_out.line[1], "line two") == 0,
149 "(array) Check line 2 for expected stdout output");
150 ok(strcmp(chld_out.line[2],
151 "it's line 3 and (note space between '3' and 'and') $$ will not get evaluated") == 0,
144 "(array) Check line 3 for expected stdout output"); 152 "(array) Check line 3 for expected stdout output");
145 ok(result == 0, "(array) Checking exit code"); 153 ok(result == 0, "(array) Checking exit code");
146 154
@@ -171,7 +179,8 @@ int main(int argc, char **argv) {
171 179
172 ok(chld_out.lines == 0, "/bin/sh returns no stdout when file is missing..."); 180 ok(chld_out.lines == 0, "/bin/sh returns no stdout when file is missing...");
173 ok(chld_err.lines == 1, "...but does give an error line"); 181 ok(chld_err.lines == 1, "...but does give an error line");
174 ok(strstr(chld_err.line[0], "non-existent-file") != NULL, "And missing filename is in error message"); 182 ok(strstr(chld_err.line[0], "non-existent-file") != NULL,
183 "And missing filename is in error message");
175 ok(result != 0, "Get non-zero return code from /bin/sh"); 184 ok(result != 0, "Get non-zero return code from /bin/sh");
176 185
177 /* ensure everything is empty again */ 186 /* ensure everything is empty again */
diff --git a/lib/tests/test_generic_output.c b/lib/tests/test_generic_output.c
index e67aefc9..e4a78bcd 100644
--- a/lib/tests/test_generic_output.c
+++ b/lib/tests/test_generic_output.c
@@ -110,7 +110,8 @@ void test_two_subchecks(void) {
110 sc1.output = "foobar"; 110 sc1.output = "foobar";
111 sc1 = mp_set_subcheck_state(sc1, STATE_WARNING); 111 sc1 = mp_set_subcheck_state(sc1, STATE_WARNING);
112 112
113 ok(mp_compute_subcheck_state(sc1) == STATE_WARNING, "Test subcheck state directly after setting it"); 113 ok(mp_compute_subcheck_state(sc1) == STATE_WARNING,
114 "Test subcheck state directly after setting it");
114 115
115 mp_perfdata pd1 = perfdata_init(); 116 mp_perfdata pd1 = perfdata_init();
116 117
@@ -129,7 +130,8 @@ void test_two_subchecks(void) {
129 130
130 mp_add_subcheck_to_subcheck(&sc1, sc2); 131 mp_add_subcheck_to_subcheck(&sc1, sc2);
131 132
132 ok(mp_compute_subcheck_state(sc1) == STATE_WARNING, "Test subcheck state after adding a subcheck"); 133 ok(mp_compute_subcheck_state(sc1) == STATE_WARNING,
134 "Test subcheck state after adding a subcheck");
133 135
134 mp_check check = mp_check_init(); 136 mp_check check = mp_check_init();
135 mp_add_subcheck_to_check(&check, sc1); 137 mp_add_subcheck_to_check(&check, sc1);
diff --git a/lib/tests/test_ini1.c b/lib/tests/test_ini1.c
index 246c1250..3792d142 100644
--- a/lib/tests/test_ini1.c
+++ b/lib/tests/test_ini1.c
@@ -42,8 +42,9 @@ char *list2str(np_arg_list *optlst) {
42 free(optltmp); 42 free(optltmp);
43 } 43 }
44 /* Strip last whitespace */ 44 /* Strip last whitespace */
45 if (strlen(optstr) > 1) 45 if (strlen(optstr) > 1) {
46 optstr[strlen(optstr) - 1] = '\0'; 46 optstr[strlen(optstr) - 1] = '\0';
47 }
47 48
48 return optstr; 49 return optstr;
49} 50}
@@ -54,15 +55,18 @@ int main(int argc, char **argv) {
54 plan_tests(12); 55 plan_tests(12);
55 56
56 optstr = list2str(np_get_defaults("section@./config-tiny.ini", "check_disk")); 57 optstr = list2str(np_get_defaults("section@./config-tiny.ini", "check_disk"));
57 ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "config-tiny.ini's section as expected"); 58 ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"),
59 "config-tiny.ini's section as expected");
58 my_free(optstr); 60 my_free(optstr);
59 61
60 optstr = list2str(np_get_defaults("@./config-tiny.ini", "section")); 62 optstr = list2str(np_get_defaults("@./config-tiny.ini", "section"));
61 ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"), "Used default section name, without specific"); 63 ok(!strcmp(optstr, "--one=two --Foo=Bar --this=Your Mother! --blank"),
64 "Used default section name, without specific");
62 my_free(optstr); 65 my_free(optstr);
63 66
64 optstr = list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk")); 67 optstr = list2str(np_get_defaults("Section Two@./config-tiny.ini", "check_disk"));
65 ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), "config-tiny.ini's Section Two as expected"); 68 ok(!strcmp(optstr, "--something else=blah --remove=whitespace"),
69 "config-tiny.ini's Section Two as expected");
66 my_free(optstr); 70 my_free(optstr);
67 71
68 optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk")); 72 optstr = list2str(np_get_defaults("/path/to/file.txt@./config-tiny.ini", "check_disk"));
@@ -70,15 +74,18 @@ int main(int argc, char **argv) {
70 my_free(optstr); 74 my_free(optstr);
71 75
72 optstr = list2str(np_get_defaults("section2@./config-tiny.ini", "check_disk")); 76 optstr = list2str(np_get_defaults("section2@./config-tiny.ini", "check_disk"));
73 ok(!strcmp(optstr, "--this=that"), "config-tiny.ini's section2 with whitespace before section name"); 77 ok(!strcmp(optstr, "--this=that"),
78 "config-tiny.ini's section2 with whitespace before section name");
74 my_free(optstr); 79 my_free(optstr);
75 80
76 optstr = list2str(np_get_defaults("section3@./config-tiny.ini", "check_disk")); 81 optstr = list2str(np_get_defaults("section3@./config-tiny.ini", "check_disk"));
77 ok(!strcmp(optstr, "--this=that"), "config-tiny.ini's section3 with whitespace after section name"); 82 ok(!strcmp(optstr, "--this=that"),
83 "config-tiny.ini's section3 with whitespace after section name");
78 my_free(optstr); 84 my_free(optstr);
79 85
80 optstr = list2str(np_get_defaults("check_mysql@./plugin.ini", "check_disk")); 86 optstr = list2str(np_get_defaults("check_mysql@./plugin.ini", "check_disk"));
81 ok(!strcmp(optstr, "--username=operator --password=secret"), "plugin.ini's check_mysql as expected"); 87 ok(!strcmp(optstr, "--username=operator --password=secret"),
88 "plugin.ini's check_mysql as expected");
82 my_free(optstr); 89 my_free(optstr);
83 90
84 optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk")); 91 optstr = list2str(np_get_defaults("check_mysql2@./plugin.ini", "check_disk"));
@@ -90,29 +97,39 @@ int main(int argc, char **argv) {
90 my_free(optstr); 97 my_free(optstr);
91 98
92 optstr = list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk")); 99 optstr = list2str(np_get_defaults("Section Two@./config-dos.ini", "check_disk"));
93 ok(!strcmp(optstr, "--something else=blah --remove=whitespace"), "config-dos.ini's Section Two as expected"); 100 ok(!strcmp(optstr, "--something else=blah --remove=whitespace"),
101 "config-dos.ini's Section Two as expected");
94 my_free(optstr); 102 my_free(optstr);
95 103
96 optstr = list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk")); 104 optstr = list2str(np_get_defaults("section_twice@./plugin.ini", "check_disk"));
97 ok(!strcmp(optstr, "--foo=bar --bar=foo"), "plugin.ini's section_twice defined twice in the file"); 105 ok(!strcmp(optstr, "--foo=bar --bar=foo"),
106 "plugin.ini's section_twice defined twice in the file");
98 my_free(optstr); 107 my_free(optstr);
99 108
100 optstr = list2str(np_get_defaults("tcp_long_lines@plugins.ini", "check_tcp")); 109 optstr = list2str(np_get_defaults("tcp_long_lines@plugins.ini", "check_tcp"));
101 ok(!strcmp(optstr, "--escape --send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar " 110 ok(!strcmp(optstr, "--escape --send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
111 "yadda Foo bar BAZ yadda yadda yadda Foo bar "
102 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 112 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
103 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " 113 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar "
114 "BAZ yadda yadda yadda Foo bar BAZ yadda "
104 "yadda yadda Foo bar BAZ yadda yadda yadda Foo " 115 "yadda yadda Foo bar BAZ yadda yadda yadda Foo "
105 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 116 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
117 "yadda yadda Foo bar BAZ yadda yadda "
106 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " 118 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
107 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda --expect=Foo bar BAZ yadda yadda " 119 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
120 "yadda --expect=Foo bar BAZ yadda yadda "
108 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " 121 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
109 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo " 122 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
123 "yadda Foo bar BAZ yadda yadda yadda Foo "
110 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 124 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
111 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " 125 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar "
126 "BAZ yadda yadda yadda Foo bar BAZ yadda "
112 "yadda yadda Foo bar BAZ yadda yadda yadda Foo " 127 "yadda yadda Foo bar BAZ yadda yadda yadda Foo "
113 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 128 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
129 "yadda yadda Foo bar BAZ yadda yadda "
114 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " 130 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
115 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo " 131 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
132 "yadda Foo bar BAZ yadda yadda yadda Foo "
116 "bar BAZ yadda yadda yadda --jail"), 133 "bar BAZ yadda yadda yadda --jail"),
117 "Long options"); 134 "Long options");
118 my_free(optstr); 135 my_free(optstr);
diff --git a/lib/tests/test_opts1.c b/lib/tests/test_opts1.c
index 984183d3..99da5596 100644
--- a/lib/tests/test_opts1.c
+++ b/lib/tests/test_opts1.c
@@ -47,16 +47,18 @@ void my_free(int *argc, char **newargv, char **argv) {
47 printf("'%s' ", newargv[i]); 47 printf("'%s' ", newargv[i]);
48 /* Stop freeing when we get to the start of the original array */ 48 /* Stop freeing when we get to the start of the original array */
49 if (freeflag) { 49 if (freeflag) {
50 if (newargv[i] == argv[1]) 50 if (newargv[i] == argv[1]) {
51 freeflag = 0; 51 freeflag = 0;
52 else 52 } else {
53 free(newargv[i]); 53 free(newargv[i]);
54 }
54 } 55 }
55 } 56 }
56 printf("\n"); 57 printf("\n");
57 /* Free only if it's a different array */ 58 /* Free only if it's a different array */
58 if (newargv != argv) 59 if (newargv != argv) {
59 free(newargv); 60 free(newargv);
61 }
60 *argc = 0; 62 *argc = 0;
61} 63}
62#endif 64#endif
@@ -69,8 +71,9 @@ int array_diff(int i1, char **a1, int i2, char **a2) {
69 return 0; 71 return 0;
70 } 72 }
71 for (i = 0; i <= i1; i++) { 73 for (i = 0; i <= i1; i++) {
72 if (a1[i] == NULL && a2[i] == NULL) 74 if (a1[i] == NULL && a2[i] == NULL) {
73 continue; 75 continue;
76 }
74 if (a1[i] == NULL || a2[i] == NULL) { 77 if (a1[i] == NULL || a2[i] == NULL) {
75 printf(" Argument # %i null in one array!\n", i); 78 printf(" Argument # %i null in one array!\n", i);
76 return 0; 79 return 0;
@@ -110,27 +113,36 @@ int main(int argc, char **argv) {
110 { 113 {
111 char *argv_test[] = {"prog_name", "--extra-opts=@./config-opts.ini", (char *)NULL}; 114 char *argv_test[] = {"prog_name", "--extra-opts=@./config-opts.ini", (char *)NULL};
112 argc_test = 2; 115 argc_test = 2;
113 char *argv_known[] = {"prog_name", "--foo=Bar", "--this=Your Mother!", "--blank", (char *)NULL}; 116 char *argv_known[] = {"prog_name", "--foo=Bar", "--this=Your Mother!", "--blank",
117 (char *)NULL};
114 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk"); 118 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk");
115 ok(array_diff(argc_test, argv_new, 4, argv_known), "Only extra opts using default section"); 119 ok(array_diff(argc_test, argv_new, 4, argv_known), "Only extra opts using default section");
116 my_free(&argc_test, argv_new, argv_test); 120 my_free(&argc_test, argv_new, argv_test);
117 } 121 }
118 122
119 { 123 {
120 char *argv_test[] = {"prog_name", "--extra-opts=sect1@./config-opts.ini", "--extra-opts", "sect2@./config-opts.ini", (char *)NULL}; 124 char *argv_test[] = {"prog_name", "--extra-opts=sect1@./config-opts.ini", "--extra-opts",
125 "sect2@./config-opts.ini", (char *)NULL};
121 argc_test = 4; 126 argc_test = 4;
122 char *argv_known[] = {"prog_name", "--one=two", "--something else=oops", "--this=that", (char *)NULL}; 127 char *argv_known[] = {"prog_name", "--one=two", "--something else=oops", "--this=that",
128 (char *)NULL};
123 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk"); 129 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk");
124 ok(array_diff(argc_test, argv_new, 4, argv_known), "Only extra opts specified twice"); 130 ok(array_diff(argc_test, argv_new, 4, argv_known), "Only extra opts specified twice");
125 my_free(&argc_test, argv_new, argv_test); 131 my_free(&argc_test, argv_new, argv_test);
126 } 132 }
127 133
128 { 134 {
129 char *argv_test[] = {"prog_name", "--arg1=val1", "--extra-opts=@./config-opts.ini", "--extra-opts", "sect1@./config-opts.ini", 135 char *argv_test[] = {"prog_name",
130 "--arg2", (char *)NULL}; 136 "--arg1=val1",
137 "--extra-opts=@./config-opts.ini",
138 "--extra-opts",
139 "sect1@./config-opts.ini",
140 "--arg2",
141 (char *)NULL};
131 argc_test = 6; 142 argc_test = 6;
132 char *argv_known[] = {"prog_name", "--foo=Bar", "--this=Your Mother!", "--blank", "--one=two", 143 char *argv_known[] = {"prog_name", "--foo=Bar", "--this=Your Mother!",
133 "--arg1=val1", "--arg2", (char *)NULL}; 144 "--blank", "--one=two", "--arg1=val1",
145 "--arg2", (char *)NULL};
134 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk"); 146 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk");
135 ok(array_diff(argc_test, argv_new, 7, argv_known), "twice extra opts using two sections"); 147 ok(array_diff(argc_test, argv_new, 7, argv_known), "twice extra opts using two sections");
136 my_free(&argc_test, argv_new, argv_test); 148 my_free(&argc_test, argv_new, argv_test);
diff --git a/lib/tests/test_opts2.c b/lib/tests/test_opts2.c
index 23496617..d1b0aca3 100644
--- a/lib/tests/test_opts2.c
+++ b/lib/tests/test_opts2.c
@@ -30,16 +30,18 @@ void my_free(int *argc, char **newargv, char **argv) {
30 printf("'%s' ", newargv[i]); 30 printf("'%s' ", newargv[i]);
31 /* Stop freeing when we get to the start of the original array */ 31 /* Stop freeing when we get to the start of the original array */
32 if (freeflag) { 32 if (freeflag) {
33 if (newargv[i] == argv[1]) 33 if (newargv[i] == argv[1]) {
34 freeflag = 0; 34 freeflag = 0;
35 else 35 } else {
36 free(newargv[i]); 36 free(newargv[i]);
37 }
37 } 38 }
38 } 39 }
39 printf("\n"); 40 printf("\n");
40 /* Free only if it's a different array */ 41 /* Free only if it's a different array */
41 if (newargv != argv) 42 if (newargv != argv) {
42 free(newargv); 43 free(newargv);
44 }
43 *argc = 0; 45 *argc = 0;
44} 46}
45 47
@@ -51,8 +53,9 @@ int array_diff(int i1, char **a1, int i2, char **a2) {
51 return 0; 53 return 0;
52 } 54 }
53 for (i = 0; i <= i1; i++) { 55 for (i = 0; i <= i1; i++) {
54 if (a1[i] == NULL && a2[i] == NULL) 56 if (a1[i] == NULL && a2[i] == NULL) {
55 continue; 57 continue;
58 }
56 if (a1[i] == NULL || a2[i] == NULL) { 59 if (a1[i] == NULL || a2[i] == NULL) {
57 printf(" Argument # %i null in one array!\n", i); 60 printf(" Argument # %i null in one array!\n", i);
58 return 0; 61 return 0;
@@ -90,7 +93,8 @@ int main(int argc, char **argv) {
90 } 93 }
91 94
92 { 95 {
93 char *argv_test[] = {"prog_name", "arg1", "--extra-opts=section1", "--arg3", "val2", (char *)NULL}; 96 char *argv_test[] = {"prog_name", "arg1", "--extra-opts=section1",
97 "--arg3", "val2", (char *)NULL};
94 argc_test = 5; 98 argc_test = 5;
95 char *argv_known[] = {"prog_name", "--foobar=baz", "arg1", "--arg3", "val2", (char *)NULL}; 99 char *argv_known[] = {"prog_name", "--foobar=baz", "arg1", "--arg3", "val2", (char *)NULL};
96 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk"); 100 argv_new = np_extra_opts(&argc_test, argv_test, "check_disk");
@@ -108,30 +112,39 @@ int main(int argc, char **argv) {
108 } 112 }
109 113
110 { 114 {
111 char *argv_test[] = {"check_tcp", "--extra-opts", "--extra-opts=tcp_long_lines", (char *)NULL}; 115 char *argv_test[] = {"check_tcp", "--extra-opts", "--extra-opts=tcp_long_lines",
116 (char *)NULL};
112 argc_test = 3; 117 argc_test = 3;
113 char *argv_known[] = { 118 char *argv_known[] = {"check_tcp",
114 "check_tcp", 119 "--timeout=10",
115 "--timeout=10", 120 "--escape",
116 "--escape", 121 "--send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda "
117 "--send=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 122 "Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
118 "yadda Foo bar BAZ yadda " 123 "yadda Foo bar BAZ yadda "
119 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 124 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
120 "yadda Foo bar BAZ " 125 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
121 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " 126 "yadda Foo bar BAZ "
122 "yadda yadda Foo bar " 127 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
123 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda", 128 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
124 "--expect=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 129 "yadda yadda Foo bar "
125 "yadda Foo bar BAZ yadda " 130 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
126 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda " 131 "yadda yadda yadda Foo bar BAZ yadda yadda yadda",
127 "yadda Foo bar BAZ " 132 "--expect=Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
128 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda " 133 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
129 "yadda yadda Foo bar " 134 "yadda Foo bar BAZ yadda "
130 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ " 135 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
131 "yadda yadda yadda Foo " 136 "yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda "
132 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda", 137 "yadda Foo bar BAZ "
133 "--jail", 138 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
134 (char *)NULL}; 139 "yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ yadda "
140 "yadda yadda Foo bar "
141 "BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
142 "yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
143 "yadda yadda yadda Foo "
144 "bar BAZ yadda yadda yadda Foo bar BAZ yadda yadda yadda Foo bar BAZ "
145 "yadda yadda yadda Foo bar BAZ yadda yadda yadda",
146 "--jail",
147 (char *)NULL};
135 argv_new = np_extra_opts(&argc_test, argv_test, "check_tcp"); 148 argv_new = np_extra_opts(&argc_test, argv_test, "check_tcp");
136 ok(array_diff(argc_test, argv_new, 6, argv_known), "Long lines test"); 149 ok(array_diff(argc_test, argv_new, 6, argv_known), "Long lines test");
137 my_free(&argc_test, argv_new, argv_test); 150 my_free(&argc_test, argv_new, argv_test);
diff --git a/lib/tests/test_tcp.c b/lib/tests/test_tcp.c
index 1b3003e9..de3a2102 100644
--- a/lib/tests/test_tcp.c
+++ b/lib/tests/test_tcp.c
@@ -32,19 +32,28 @@ int main(void) {
32 server_expect[1] = strdup("bb"); 32 server_expect[1] = strdup("bb");
33 server_expect[2] = strdup("CC"); 33 server_expect[2] = strdup("CC");
34 34
35 ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, 35 ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) ==
36 NP_MATCH_SUCCESS,
36 "Test matching any string at the beginning (first expect string)"); 37 "Test matching any string at the beginning (first expect string)");
37 ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_SUCCESS, 38 ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) ==
39 NP_MATCH_SUCCESS,
38 "Test matching any string at the beginning (second expect string)"); 40 "Test matching any string at the beginning (second expect string)");
39 ok(np_expect_match("b", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_RETRY, 41 ok(np_expect_match("b", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_RETRY,
40 "Test matching any string at the beginning (substring match)"); 42 "Test matching any string at the beginning (substring match)");
41 ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, 43 ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) ==
44 NP_MATCH_FAILURE,
42 "Test with strings not matching at the beginning"); 45 "Test with strings not matching at the beginning");
43 ok(np_expect_match("XX CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) == NP_MATCH_FAILURE, "Test matching any string"); 46 ok(np_expect_match("XX CC XX", server_expect, server_expect_count, NP_MATCH_EXACT) ==
44 ok(np_expect_match("XX", server_expect, server_expect_count, 0) == NP_MATCH_RETRY, "Test not matching any string"); 47 NP_MATCH_FAILURE,
45 ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_SUCCESS, 48 "Test matching any string");
49 ok(np_expect_match("XX", server_expect, server_expect_count, 0) == NP_MATCH_RETRY,
50 "Test not matching any string");
51 ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) ==
52 NP_MATCH_SUCCESS,
46 "Test matching all strings"); 53 "Test matching all strings");
47 ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, "Test not matching all strings"); 54 ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, NP_MATCH_ALL) ==
55 NP_MATCH_RETRY,
56 "Test not matching all strings");
48 ok(np_expect_match("XX XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY, 57 ok(np_expect_match("XX XX", server_expect, server_expect_count, NP_MATCH_ALL) == NP_MATCH_RETRY,
49 "Test not matching any string (testing all)"); 58 "Test not matching any string (testing all)");
50 59
diff --git a/lib/utils_base.c b/lib/utils_base.c
index e95eeaf0..69024bc9 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -254,7 +254,7 @@ bool check_range(double value, range *my_range) {
254 yes = false; 254 yes = false;
255 } 255 }
256 256
257 if (!my_range->end_infinity&& !my_range->start_infinity) { 257 if (!my_range->end_infinity && !my_range->start_infinity) {
258 if ((my_range->start <= value) && (value <= my_range->end)) { 258 if ((my_range->start <= value) && (value <= my_range->end)) {
259 return no; 259 return no;
260 } 260 }
@@ -268,7 +268,7 @@ bool check_range(double value, range *my_range) {
268 return yes; 268 return yes;
269 } 269 }
270 270
271 if (my_range->start_infinity && !my_range->end_infinity ) { 271 if (my_range->start_infinity && !my_range->end_infinity) {
272 if (value <= my_range->end) { 272 if (value <= my_range->end) {
273 return no; 273 return no;
274 } 274 }
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 9b222409..d1feaa33 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -71,7 +71,7 @@ extern char **environ;
71#endif 71#endif
72 72
73#ifndef WIFEXITED 73#ifndef WIFEXITED
74# define WIFEXITED(stat_val) (((stat_val)&255) == 0) 74# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
75#endif 75#endif
76 76
77/* 4.3BSD Reno <signal.h> doesn't define SIG_ERR */ 77/* 4.3BSD Reno <signal.h> doesn't define SIG_ERR */
@@ -103,8 +103,9 @@ void cmd_init(void) {
103 maxfd = MAXFD_LIMIT; 103 maxfd = MAXFD_LIMIT;
104 } 104 }
105 105
106 if (!_cmd_pids) 106 if (!_cmd_pids) {
107 _cmd_pids = calloc(maxfd, sizeof(pid_t)); 107 _cmd_pids = calloc(maxfd, sizeof(pid_t));
108 }
108} 109}
109 110
110/* Start running a command, array style */ 111/* Start running a command, array style */
@@ -116,13 +117,15 @@ static int _cmd_open(char *const *argv, int *pfd, int *pfderr) {
116 117
117 int i = 0; 118 int i = 0;
118 119
119 if (!_cmd_pids) 120 if (!_cmd_pids) {
120 CMD_INIT; 121 CMD_INIT;
122 }
121 123
122 setenv("LC_ALL", "C", 1); 124 setenv("LC_ALL", "C", 1);
123 125
124 if (pipe(pfd) < 0 || pipe(pfderr) < 0 || (pid = fork()) < 0) 126 if (pipe(pfd) < 0 || pipe(pfderr) < 0 || (pid = fork()) < 0) {
125 return -1; /* errno set by the failing function */ 127 return -1; /* errno set by the failing function */
128 }
126 129
127 /* child runs exceve() and _exit. */ 130 /* child runs exceve() and _exit. */
128 if (pid == 0) { 131 if (pid == 0) {
@@ -147,9 +150,11 @@ static int _cmd_open(char *const *argv, int *pfd, int *pfderr) {
147 * This is executed in a separate address space (pure child), 150 * This is executed in a separate address space (pure child),
148 * so we don't have to worry about async safety */ 151 * so we don't have to worry about async safety */
149 long maxfd = mp_open_max(); 152 long maxfd = mp_open_max();
150 for (i = 0; i < maxfd; i++) 153 for (i = 0; i < maxfd; i++) {
151 if (_cmd_pids[i] > 0) 154 if (_cmd_pids[i] > 0) {
152 close(i); 155 close(i);
156 }
157 }
153 158
154 execve(argv[0], argv, environ); 159 execve(argv[0], argv, environ);
155 _exit(STATE_UNKNOWN); 160 _exit(STATE_UNKNOWN);
@@ -172,17 +177,21 @@ static int _cmd_close(int fd) {
172 177
173 /* make sure the provided fd was opened */ 178 /* make sure the provided fd was opened */
174 long maxfd = mp_open_max(); 179 long maxfd = mp_open_max();
175 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0) 180 if (fd < 0 || fd > maxfd || !_cmd_pids || (pid = _cmd_pids[fd]) == 0) {
176 return -1; 181 return -1;
182 }
177 183
178 _cmd_pids[fd] = 0; 184 _cmd_pids[fd] = 0;
179 if (close(fd) == -1) 185 if (close(fd) == -1) {
180 return -1; 186 return -1;
187 }
181 188
182 /* EINTR is ok (sort of), everything else is bad */ 189 /* EINTR is ok (sort of), everything else is bad */
183 while (waitpid(pid, &status, 0) < 0) 190 while (waitpid(pid, &status, 0) < 0) {
184 if (errno != EINTR) 191 if (errno != EINTR) {
185 return -1; 192 return -1;
193 }
194 }
186 195
187 /* return child's termination status */ 196 /* return child's termination status */
188 return (WIFEXITED(status)) ? WEXITSTATUS(status) : -1; 197 return (WIFEXITED(status)) ? WEXITSTATUS(status) : -1;
@@ -212,15 +221,17 @@ static int _cmd_fetch_output(int fd, output *op, int flags) {
212 221
213 /* some plugins may want to keep output unbroken, and some commands 222 /* some plugins may want to keep output unbroken, and some commands
214 * will yield no output, so return here for those */ 223 * will yield no output, so return here for those */
215 if (flags & CMD_NO_ARRAYS || !op->buf || !op->buflen) 224 if (flags & CMD_NO_ARRAYS || !op->buf || !op->buflen) {
216 return op->buflen; 225 return op->buflen;
226 }
217 227
218 /* and some may want both */ 228 /* and some may want both */
219 if (flags & CMD_NO_ASSOC) { 229 if (flags & CMD_NO_ASSOC) {
220 buf = malloc(op->buflen); 230 buf = malloc(op->buflen);
221 memcpy(buf, op->buf, op->buflen); 231 memcpy(buf, op->buf, op->buflen);
222 } else 232 } else {
223 buf = op->buf; 233 buf = op->buf;
234 }
224 235
225 op->line = NULL; 236 op->line = NULL;
226 op->lens = NULL; 237 op->lens = NULL;
@@ -241,8 +252,9 @@ static int _cmd_fetch_output(int fd, output *op, int flags) {
241 op->line[lineno] = &buf[i]; 252 op->line[lineno] = &buf[i];
242 253
243 /* hop to next newline or end of buffer */ 254 /* hop to next newline or end of buffer */
244 while (buf[i] != '\n' && i < op->buflen) 255 while (buf[i] != '\n' && i < op->buflen) {
245 i++; 256 i++;
257 }
246 buf[i] = '\0'; 258 buf[i] = '\0';
247 259
248 /* calculate the string length using pointer difference */ 260 /* calculate the string length using pointer difference */
@@ -262,30 +274,36 @@ int cmd_run(const char *cmdstring, output *out, output *err, int flags) {
262 char *cmd = NULL; 274 char *cmd = NULL;
263 char *str = NULL; 275 char *str = NULL;
264 276
265 if (cmdstring == NULL) 277 if (cmdstring == NULL) {
266 return -1; 278 return -1;
279 }
267 280
268 /* initialize the structs */ 281 /* initialize the structs */
269 if (out) 282 if (out) {
270 memset(out, 0, sizeof(output)); 283 memset(out, 0, sizeof(output));
271 if (err) 284 }
285 if (err) {
272 memset(err, 0, sizeof(output)); 286 memset(err, 0, sizeof(output));
287 }
273 288
274 /* make copy of command string so strtok() doesn't silently modify it */ 289 /* make copy of command string so strtok() doesn't silently modify it */
275 /* (the calling program may want to access it later) */ 290 /* (the calling program may want to access it later) */
276 cmdlen = strlen(cmdstring); 291 cmdlen = strlen(cmdstring);
277 if ((cmd = malloc(cmdlen + 1)) == NULL) 292 if ((cmd = malloc(cmdlen + 1)) == NULL) {
278 return -1; 293 return -1;
294 }
279 memcpy(cmd, cmdstring, cmdlen); 295 memcpy(cmd, cmdstring, cmdlen);
280 cmd[cmdlen] = '\0'; 296 cmd[cmdlen] = '\0';
281 297
282 /* This is not a shell, so we don't handle "???" */ 298 /* This is not a shell, so we don't handle "???" */
283 if (strstr(cmdstring, "\"")) 299 if (strstr(cmdstring, "\"")) {
284 return -1; 300 return -1;
301 }
285 302
286 /* allow single quotes, but only if non-whitesapce doesn't occur on both sides */ 303 /* allow single quotes, but only if non-whitesapce doesn't occur on both sides */
287 if (strstr(cmdstring, " ' ") || strstr(cmdstring, "'''")) 304 if (strstr(cmdstring, " ' ") || strstr(cmdstring, "'''")) {
288 return -1; 305 return -1;
306 }
289 307
290 /* each arg must be whitespace-separated, so args can be a maximum 308 /* each arg must be whitespace-separated, so args can be a maximum
291 * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ 309 * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */
@@ -304,8 +322,9 @@ int cmd_run(const char *cmdstring, output *out, output *err, int flags) {
304 322
305 if (strstr(str, "'") == str) { /* handle SIMPLE quoted strings */ 323 if (strstr(str, "'") == str) { /* handle SIMPLE quoted strings */
306 str++; 324 str++;
307 if (!strstr(str, "'")) 325 if (!strstr(str, "'")) {
308 return -1; /* balanced? */ 326 return -1; /* balanced? */
327 }
309 cmd = 1 + strstr(str, "'"); 328 cmd = 1 + strstr(str, "'");
310 str[strcspn(str, "'")] = 0; 329 str[strcspn(str, "'")] = 0;
311 } else { 330 } else {
@@ -317,8 +336,9 @@ int cmd_run(const char *cmdstring, output *out, output *err, int flags) {
317 } 336 }
318 } 337 }
319 338
320 if (cmd && strlen(cmd) == strspn(cmd, " \t\r\n")) 339 if (cmd && strlen(cmd) == strspn(cmd, " \t\r\n")) {
321 cmd = NULL; 340 cmd = NULL;
341 }
322 342
323 argv[i++] = str; 343 argv[i++] = str;
324 } 344 }
@@ -330,50 +350,61 @@ int cmd_run_array(char *const *argv, output *out, output *err, int flags) {
330 int fd, pfd_out[2], pfd_err[2]; 350 int fd, pfd_out[2], pfd_err[2];
331 351
332 /* initialize the structs */ 352 /* initialize the structs */
333 if (out) 353 if (out) {
334 memset(out, 0, sizeof(output)); 354 memset(out, 0, sizeof(output));
335 if (err) 355 }
356 if (err) {
336 memset(err, 0, sizeof(output)); 357 memset(err, 0, sizeof(output));
358 }
337 359
338 if ((fd = _cmd_open(argv, pfd_out, pfd_err)) == -1) 360 if ((fd = _cmd_open(argv, pfd_out, pfd_err)) == -1) {
339 die(STATE_UNKNOWN, _("Could not open pipe: %s\n"), argv[0]); 361 die(STATE_UNKNOWN, _("Could not open pipe: %s\n"), argv[0]);
362 }
340 363
341 if (out) 364 if (out) {
342 out->lines = _cmd_fetch_output(pfd_out[0], out, flags); 365 out->lines = _cmd_fetch_output(pfd_out[0], out, flags);
343 if (err) 366 }
367 if (err) {
344 err->lines = _cmd_fetch_output(pfd_err[0], err, flags); 368 err->lines = _cmd_fetch_output(pfd_err[0], err, flags);
369 }
345 370
346 return _cmd_close(fd); 371 return _cmd_close(fd);
347} 372}
348 373
349int cmd_file_read(const char *filename, output *out, int flags) { 374int cmd_file_read(const char *filename, output *out, int flags) {
350 int fd; 375 int fd;
351 if (out) 376 if (out) {
352 memset(out, 0, sizeof(output)); 377 memset(out, 0, sizeof(output));
378 }
353 379
354 if ((fd = open(filename, O_RDONLY)) == -1) { 380 if ((fd = open(filename, O_RDONLY)) == -1) {
355 die(STATE_UNKNOWN, _("Error opening %s: %s"), filename, strerror(errno)); 381 die(STATE_UNKNOWN, _("Error opening %s: %s"), filename, strerror(errno));
356 } 382 }
357 383
358 if (out) 384 if (out) {
359 out->lines = _cmd_fetch_output(fd, out, flags); 385 out->lines = _cmd_fetch_output(fd, out, flags);
386 }
360 387
361 if (close(fd) == -1) 388 if (close(fd) == -1) {
362 die(STATE_UNKNOWN, _("Error closing %s: %s"), filename, strerror(errno)); 389 die(STATE_UNKNOWN, _("Error closing %s: %s"), filename, strerror(errno));
390 }
363 391
364 return 0; 392 return 0;
365} 393}
366 394
367void timeout_alarm_handler(int signo) { 395void timeout_alarm_handler(int signo) {
368 if (signo == SIGALRM) { 396 if (signo == SIGALRM) {
369 printf(_("%s - Plugin timed out after %d seconds\n"), state_text(timeout_state), timeout_interval); 397 printf(_("%s - Plugin timed out after %d seconds\n"), state_text(timeout_state),
398 timeout_interval);
370 399
371 long maxfd = mp_open_max(); 400 long maxfd = mp_open_max();
372 if (_cmd_pids) 401 if (_cmd_pids) {
373 for (long int i = 0; i < maxfd; i++) { 402 for (long int i = 0; i < maxfd; i++) {
374 if (_cmd_pids[i] != 0) 403 if (_cmd_pids[i] != 0) {
375 kill(_cmd_pids[i], SIGKILL); 404 kill(_cmd_pids[i], SIGKILL);
405 }
376 } 406 }
407 }
377 408
378 exit(timeout_state); 409 exit(timeout_state);
379 } 410 }
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c
index daae1d54..1482458b 100644
--- a/lib/utils_tcp.c
+++ b/lib/utils_tcp.c
@@ -29,18 +29,21 @@
29#include "common.h" 29#include "common.h"
30#include "utils_tcp.h" 30#include "utils_tcp.h"
31 31
32#define VERBOSE(message) \ 32#define VERBOSE(message) \
33 do { \ 33 do { \
34 if (flags & NP_MATCH_VERBOSE) \ 34 if (flags & NP_MATCH_VERBOSE) \
35 puts(message); \ 35 puts(message); \
36 } while (0) 36 } while (0)
37 37
38enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, int flags) { 38enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count,
39 int flags) {
39 int i, match = 0, partial = 0; 40 int i, match = 0, partial = 0;
40 41
41 for (i = 0; i < expect_count; i++) { 42 for (i = 0; i < expect_count; i++) {
42 if (flags & NP_MATCH_VERBOSE) 43 if (flags & NP_MATCH_VERBOSE) {
43 printf("looking for [%s] %s [%s]\n", server_expect[i], (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); 44 printf("looking for [%s] %s [%s]\n", server_expect[i],
45 (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status);
46 }
44 47
45 if (flags & NP_MATCH_EXACT) { 48 if (flags & NP_MATCH_EXACT) {
46 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) { 49 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) {
@@ -60,10 +63,12 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp
60 VERBOSE("couldn't find it"); 63 VERBOSE("couldn't find it");
61 } 64 }
62 65
63 if ((flags & NP_MATCH_ALL && match == expect_count) || (!(flags & NP_MATCH_ALL) && match >= 1)) 66 if ((flags & NP_MATCH_ALL && match == expect_count) ||
67 (!(flags & NP_MATCH_ALL) && match >= 1)) {
64 return NP_MATCH_SUCCESS; 68 return NP_MATCH_SUCCESS;
65 else if (partial > 0 || !(flags & NP_MATCH_EXACT)) 69 } else if (partial > 0 || !(flags & NP_MATCH_EXACT)) {
66 return NP_MATCH_RETRY; 70 return NP_MATCH_RETRY;
67 else 71 } else {
68 return NP_MATCH_FAILURE; 72 return NP_MATCH_FAILURE;
73 }
69} 74}
diff --git a/lib/utils_tcp.h b/lib/utils_tcp.h
index a7d83c59..e5cdbb82 100644
--- a/lib/utils_tcp.h
+++ b/lib/utils_tcp.h
@@ -17,4 +17,5 @@ enum np_match_result {
17 NP_MATCH_RETRY 17 NP_MATCH_RETRY
18}; 18};
19 19
20enum np_match_result np_expect_match(char *status, char **server_expect, int server_expect_count, int flags); 20enum np_match_result np_expect_match(char *status, char **server_expect, int server_expect_count,
21 int flags);