1 /*-
2 ***********************************************************************
3 *
4 * $Id: properties.c,v 1.67 2014/07/18 06:40:44 mavrik Exp $
5 *
6 ***********************************************************************
7 *
8 * Copyright 2000-2014 The FTimes Project, All Rights Reserved.
9 *
10 ***********************************************************************
11 */
12 #include "all-includes.h"
13
14 /*-
15 ***********************************************************************
16 *
17 * Defines
18 *
19 ***********************************************************************
20 */
21 #define PROPERTIES_MAX_RECURSION_LEVEL 3
22 #define PROPERTIES_MAX_LINE 8192
23 #define PROPERTIES_COMMENT_C '#'
24 #define PROPERTIES_COMMENT_S "#"
25 #define PROPERTIES_SEPARATOR_C '='
26 #define PROPERTIES_SEPARATOR_S "="
27
28
29 /*-
30 ***********************************************************************
31 *
32 * Macros
33 *
34 ***********************************************************************
35 */
36 #define DUPLICATE_ERROR(b) \
37 if ((b) == TRUE) \
38 { \
39 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Duplicate controls aren't allowed.", acRoutine, pcControl); \
40 return ER; \
41 }
42
43 #define EVALUATE_TWOSTATE(pc, s1, s2, result) \
44 if (strcasecmp(pc, s1) == 0) \
45 { \
46 result = TRUE; \
47 } \
48 else if (strcasecmp(pc, s2) == 0) \
49 { \
50 result = FALSE; \
51 } \
52 else \
53 { \
54 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be [%s|%s].", acRoutine, pcControl, pc, s1, s2); \
55 return ER; \
56 }
57
58
59 /*-
60 ***********************************************************************
61 *
62 * PropertiesTestFile
63 *
64 ***********************************************************************
65 */
66 int
PropertiesTestFile(FTIMES_PROPERTIES * psProperties,char * pcError)67 PropertiesTestFile(FTIMES_PROPERTIES *psProperties, char *pcError)
68 {
69 char acLocalError[MESSAGE_SIZE] = "";
70 int iError;
71
72 iError = PropertiesReadFile(psProperties->acConfigFile, psProperties, acLocalError);
73 if (iError != ER_OK)
74 {
75 fprintf(stdout, "SyntaxCheck Failed --> %s\n", acLocalError);
76 }
77 else
78 {
79 fprintf(stdout, "SyntaxCheck Passed\n");
80 }
81
82 return ER_OK;
83 }
84
85
86 /*-
87 ***********************************************************************
88 *
89 * PropertiesReadFile
90 *
91 ***********************************************************************
92 */
93 int
PropertiesReadFile(char * pcFilename,FTIMES_PROPERTIES * psProperties,char * pcError)94 PropertiesReadFile(char *pcFilename, FTIMES_PROPERTIES *psProperties, char *pcError)
95 {
96 const char acRoutine[] = "PropertiesReadFile()";
97 char acLocalError[MESSAGE_SIZE] = "";
98 char acLine[PROPERTIES_MAX_LINE];
99 char *pc;
100 int iError;
101 int iLength;
102 int iLineNumber;
103 FILE *pFile;
104 struct stat statEntry;
105
106 /*-
107 *********************************************************************
108 *
109 * Check recursion level. Abort, if the level is too high.
110 *
111 *********************************************************************
112 */
113 if (psProperties->iImportRecursionLevel > PROPERTIES_MAX_RECURSION_LEVEL)
114 {
115 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s], Imports may not exceed %d levels of recursion.", acRoutine, pcFilename, PROPERTIES_MAX_RECURSION_LEVEL);
116 return ER_ReadPropertiesFile;
117 }
118
119 if (strcmp(pcFilename, "-") == 0)
120 {
121 pFile = stdin;
122 }
123 else
124 {
125 iError = stat(pcFilename, &statEntry);
126 if (iError == -1)
127 {
128 /*-
129 *****************************************************************
130 *
131 * Return OK if the specified config file (Import) doesn't exist.
132 * By making this allowance, an admin can (more easily) create a
133 * generic config file that spans multiple clients or an entire
134 * FTimes deployment. If the recursion level is zero, then we are
135 * dealing with a command line config file, and in that case, the
136 * file must exist.
137 *
138 *****************************************************************
139 */
140 if (psProperties->iImportRecursionLevel > 0 && errno == ENOENT)
141 {
142 return ER_OK;
143 }
144 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s]: %s", acRoutine, pcFilename, strerror(errno));
145 return ER_ReadPropertiesFile;
146 }
147
148 if (!((statEntry.st_mode & S_IFMT) == S_IFREG))
149 {
150 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s]: A regular file is required.", acRoutine, pcFilename);
151 return ER_ReadPropertiesFile;
152 }
153
154 if ((pFile = fopen(pcFilename, "r")) == NULL)
155 {
156 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s]: %s", acRoutine, pcFilename, strerror(errno));
157 return ER_ReadPropertiesFile;
158 }
159 }
160
161 for (acLine[0] = 0, iLineNumber = 1; fgets(acLine, PROPERTIES_MAX_LINE, pFile) != NULL; acLine[0] = 0, iLineNumber++)
162 {
163 /*-
164 *******************************************************************
165 *
166 * Ignore full line comments.
167 *
168 *******************************************************************
169 */
170 if (acLine[0] == PROPERTIES_COMMENT_C)
171 {
172 continue;
173 }
174
175 /*-
176 *******************************************************************
177 *
178 * Remove EOL characters.
179 *
180 *******************************************************************
181 */
182 if (SupportChopEOLs(acLine, feof(pFile) ? 0 : 1, acLocalError) == ER)
183 {
184 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s], Line = [%d]: %s", acRoutine, pcFilename, iLineNumber, acLocalError);
185 if (pFile != stdin)
186 {
187 fclose(pFile);
188 }
189 return ER_ReadPropertiesFile;
190 }
191
192 /*-
193 *******************************************************************
194 *
195 * Look for the first imbedded comment and mark it.
196 *
197 *******************************************************************
198 */
199 if ((pc = strstr(acLine, PROPERTIES_COMMENT_S)) != NULL)
200 {
201 *pc = 0;
202 }
203 iLength = strlen(acLine);
204
205 /*-
206 *******************************************************************
207 *
208 * Burn any trailing white space off line.
209 *
210 *******************************************************************
211 */
212 while (iLength > 0 && isspace((int) acLine[iLength - 1]))
213 {
214 acLine[iLength--] = 0;
215 }
216
217 /*-
218 *******************************************************************
219 *
220 * If there's anything left over, process it.
221 *
222 *******************************************************************
223 */
224 if (iLength)
225 {
226 iError = PropertiesReadLine(acLine, psProperties, acLocalError);
227 if (iError != ER_OK)
228 {
229 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s], Line = [%d]: %s", acRoutine, pcFilename, iLineNumber, acLocalError);
230 if (pFile != stdin)
231 {
232 fclose(pFile);
233 }
234 return ER_ReadPropertiesFile;
235 }
236 }
237 }
238 if (ferror(pFile))
239 {
240 snprintf(pcError, MESSAGE_SIZE, "%s: File = [%s], Line = [%d]: %s", acRoutine, pcFilename, iLineNumber, strerror(errno));
241 if (pFile != stdin)
242 {
243 fclose(pFile);
244 }
245 return ER_ReadPropertiesFile;
246 }
247 if (pFile != stdin)
248 {
249 fclose(pFile);
250 }
251
252 return ER_OK;
253 }
254
255
256 /*-
257 ***********************************************************************
258 *
259 * PropertiesReadLine
260 *
261 ***********************************************************************
262 */
263 int
PropertiesReadLine(char * pcLine,FTIMES_PROPERTIES * psProperties,char * pcError)264 PropertiesReadLine(char *pcLine, FTIMES_PROPERTIES *psProperties, char *pcError)
265 {
266 const char acRoutine[] = "PropertiesReadLine()";
267 char acLocalError[MESSAGE_SIZE] = "";
268 #ifdef USE_SSL
269 char acTempFile[FTIMES_MAX_PATH];
270 #endif
271 char *pc;
272 char *pcControl;
273 char *pcEnd;
274 int iError;
275 int iRunMode;
276 int iValue;
277 APP_UI64 ui64Value = 0;
278 unsigned int iLength;
279
280 /*-
281 *********************************************************************
282 *
283 * Process one line of input from the config file. It is assumed that
284 * the input string has already been stripped of comments and EOLs.
285 * The string is expected to have the following form: "control:value"
286 *
287 *********************************************************************
288 */
289
290 /*-
291 *********************************************************************
292 *
293 * Look for the first separator, and mark it to isolate the control.
294 *
295 *********************************************************************
296 */
297 if ((pc = strstr(pcLine, PROPERTIES_SEPARATOR_S)) == NULL)
298 {
299 snprintf(pcError, MESSAGE_SIZE, "%s: Line does not contain a control/value separator (i.e. '%s').", acRoutine, PROPERTIES_SEPARATOR_S);
300 return ER;
301 }
302 *pc++ = 0;
303 pcControl = pcLine;
304
305 /*-
306 *********************************************************************
307 *
308 * Burn any leading white space off value.
309 *
310 *********************************************************************
311 */
312 while (isspace((int) *pc))
313 {
314 pc++;
315 }
316
317 /*-
318 *********************************************************************
319 *
320 * Burn any trailing white space off value.
321 *
322 *********************************************************************
323 */
324 iLength = strlen(pc);
325 if (iLength > 0)
326 {
327 pcEnd = &pc[iLength - 1];
328 while (iLength > 0 && isspace((int) *pcEnd))
329 {
330 *pcEnd-- = 0;
331 iLength--;
332 }
333 }
334
335 /*-
336 *********************************************************************
337 *
338 * Burn any leading white space off control.
339 *
340 *********************************************************************
341 */
342 while (isspace((int) *pcControl))
343 {
344 pcControl++;
345 }
346
347 /*-
348 *********************************************************************
349 *
350 * Burn any trailing white space off control.
351 *
352 *********************************************************************
353 */
354 iLength = strlen(pcControl);
355 if (iLength > 0)
356 {
357 pcEnd = &pcControl[iLength - 1];
358 while (iLength > 0 && isspace((int) *pcEnd))
359 {
360 *pcEnd-- = 0;
361 iLength--;
362 }
363 }
364
365 /*-
366 *********************************************************************
367 *
368 * At this point pc should be pointing at a control value. Sift
369 * through the various controls and do the appropriate things. If
370 * the control is unrecognized, complain about it.
371 *
372 *********************************************************************
373 */
374 iLength = strlen(pc);
375
376 iRunMode = (psProperties->iRunMode == FTIMES_CFGTEST) ? psProperties->iTestRunMode : psProperties->iRunMode;
377
378 if (strcasecmp(pcControl, KEY_AnalyzeBlockSize) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeBlockSize, iRunMode))
379 {
380 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeBlockSizeFound);
381 while (iLength > 0)
382 {
383 if (!isdigit((int) pc[iLength - 1]))
384 {
385 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
386 return ER;
387 }
388 iLength--;
389 }
390 iValue = atoi(pc);
391 if (iValue < FTIMES_MIN_BLOCK_SIZE || iValue > FTIMES_MAX_BLOCK_SIZE)
392 {
393 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value out of range.", acRoutine, pcControl, pc);
394 return ER;
395 }
396 else
397 {
398 psProperties->iAnalyzeBlockSize = iValue;
399 AnalyzeSetBlockSize(psProperties->iAnalyzeBlockSize);
400 }
401 psProperties->sFound.bAnalyzeBlockSizeFound = TRUE;
402 }
403
404 else if (strcasecmp(pcControl, KEY_AnalyzeByteCount) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeByteCount, iRunMode))
405 {
406 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeByteCountFound);
407 iError = SupportStringToUInt64(pc, &ui64Value, acLocalError);
408 if (iError != ER_OK)
409 {
410 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
411 return ER;
412 }
413 else
414 {
415 psProperties->ui64AnalyzeByteCount = ui64Value;
416 }
417 psProperties->sFound.bAnalyzeByteCountFound = TRUE;
418 }
419
420 else if (strcasecmp(pcControl, KEY_AnalyzeCarrySize) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeCarrySize, iRunMode))
421 {
422 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeCarrySizeFound);
423 while (iLength > 0)
424 {
425 if (!isdigit((int) pc[iLength - 1]))
426 {
427 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
428 return ER;
429 }
430 iLength--;
431 }
432 iValue = atoi(pc);
433 if (iValue < 0 || iValue > FTIMES_MAX_BLOCK_SIZE) /* A carry size of zero is OK. */
434 {
435 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value out of range.", acRoutine, pcControl, pc);
436 return ER;
437 }
438 else
439 {
440 psProperties->iAnalyzeCarrySize = iValue;
441 AnalyzeSetCarrySize(psProperties->iAnalyzeCarrySize);
442 }
443 psProperties->sFound.bAnalyzeCarrySizeFound = TRUE;
444 }
445
446 else if (strcasecmp(pcControl, KEY_AnalyzeDeviceFiles) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeDeviceFiles, iRunMode))
447 {
448 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeDeviceFilesFound);
449 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bAnalyzeDeviceFiles);
450 psProperties->sFound.bAnalyzeDeviceFilesFound = TRUE;
451 }
452
453 else if (strcasecmp(pcControl, KEY_AnalyzeMaxDps) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeMaxDps, iRunMode))
454 {
455 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeMaxDpsFound);
456 while (iLength > 0)
457 {
458 if (!isdigit((int) pc[iLength - 1]))
459 {
460 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
461 return ER;
462 }
463 iLength--;
464 }
465 iValue = atoi(pc);
466 if (iValue < 0 || iValue > FTIMES_MAX_KBPS)
467 {
468 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value out of range.", acRoutine, pcControl, pc);
469 return ER;
470 }
471 else
472 {
473 psProperties->iAnalyzeMaxDps = iValue;
474 }
475 psProperties->sFound.bAnalyzeMaxDpsFound = TRUE;
476 }
477
478 else if ((strcasecmp(pcControl, KEY_AnalyzeRemoteFiles) == 0 || strcasecmp(pcControl, KEY_MapRemoteFiles) == 0) && RUN_MODE_IS_SET(MODES_AnalyzeRemoteFiles, iRunMode))
479 {
480 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeRemoteFilesFound);
481 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bAnalyzeRemoteFiles);
482 psProperties->sFound.bAnalyzeRemoteFilesFound = TRUE;
483 }
484
485 else if (strcasecmp(pcControl, KEY_AnalyzeStartOffset) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeStartOffset, iRunMode))
486 {
487 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeStartOffsetFound);
488 iError = SupportStringToUInt64(pc, &ui64Value, acLocalError);
489 if (iError != ER_OK)
490 {
491 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
492 return ER;
493 }
494 else
495 {
496 psProperties->ui64AnalyzeStartOffset = ui64Value;
497 }
498 psProperties->sFound.bAnalyzeStartOffsetFound = TRUE;
499 }
500
501 #ifdef USE_XMAGIC
502 else if (strcasecmp(pcControl, KEY_AnalyzeStepSize) == 0 && RUN_MODE_IS_SET(MODES_AnalyzeStepSize, iRunMode))
503 {
504 DUPLICATE_ERROR(psProperties->sFound.bAnalyzeStepSizeFound);
505 while (iLength > 0)
506 {
507 if (!isdigit((int) pc[iLength - 1]))
508 {
509 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
510 return ER;
511 }
512 iLength--;
513 }
514 iValue = atoi(pc);
515 if (iValue < FTIMES_MIN_BLOCK_SIZE || iValue > FTIMES_MAX_BLOCK_SIZE)
516 {
517 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value out of range.", acRoutine, pcControl, pc);
518 return ER;
519 }
520 else
521 {
522 psProperties->iAnalyzeStepSize = iValue;
523 AnalyzeSetStepSize(psProperties->iAnalyzeStepSize);
524 }
525 psProperties->sFound.bAnalyzeStepSizeFound = TRUE;
526 }
527 #endif
528
529 else if (strcasecmp(pcControl, KEY_BaseName) == 0 && RUN_MODE_IS_SET(MODES_BaseName, iRunMode))
530 {
531 DUPLICATE_ERROR(psProperties->sFound.bBaseNameFound);
532 if (iLength < 1 || iLength > FTIMES_MAX_PATH - 1)
533 {
534 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
535 return ER;
536 }
537 while (iLength > 0)
538 {
539 if (!isalnum((int) pc[iLength - 1]) && pc[iLength - 1] != '_' && pc[iLength - 1] != '-' && pc[iLength - 1] != '.')
540 {
541 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], BaseNames must constructed from the following character set: [0-9a-zA-Z._-].", acRoutine, pcControl);
542 return ER;
543 }
544 iLength--;
545 }
546 strncpy(psProperties->acBaseName, pc, FTIMES_MAX_PATH);
547 psProperties->sFound.bBaseNameFound = TRUE;
548 }
549
550 else if (strcasecmp(pcControl, KEY_BaseNameSuffix) == 0 && RUN_MODE_IS_SET(MODES_BaseNameSuffix, iRunMode))
551 {
552 DUPLICATE_ERROR(psProperties->sFound.bBaseNameSuffixFound);
553 if (strcasecmp(pc, "datetime") == 0)
554 {
555 strncpy(psProperties->acBaseNameSuffix, psProperties->acDateTime, FTIMES_SUFFIX_SIZE);
556 }
557 else if (strcasecmp(pc, "none") == 0)
558 {
559 psProperties->acBaseNameSuffix[0] = 0;
560 }
561 else if (strcasecmp(pc, "pid") == 0)
562 {
563 strncpy(psProperties->acBaseNameSuffix, psProperties->acPid, FTIMES_SUFFIX_SIZE);
564 }
565 else
566 {
567 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value must be [datetime|none|pid].", acRoutine, pcControl);
568 return ER;
569 }
570 psProperties->sFound.bBaseNameSuffixFound = TRUE;
571 }
572
573 else if (strcasecmp(pcControl, KEY_Compress) == 0 && RUN_MODE_IS_SET(MODES_Compress, iRunMode))
574 {
575 DUPLICATE_ERROR(psProperties->sFound.bCompressFound);
576 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bCompress);
577 psProperties->sFound.bCompressFound = TRUE;
578 }
579
580 else if (strcasecmp(pcControl, KEY_DigStringNoCase) == 0 && RUN_MODE_IS_SET(MODES_DigStringNoCase, iRunMode))
581 {
582 iError = DigAddDigString(pc, DIG_STRING_TYPE_NOCASE, acLocalError);
583 if (iError != ER_OK)
584 {
585 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
586 return ER;
587 }
588 }
589
590 else if ((strcasecmp(pcControl, KEY_DigStringNormal) == 0 || strcasecmp(pcControl, KEY_DigString) == 0) && RUN_MODE_IS_SET(MODES_DigStringNormal, iRunMode))
591 {
592 iError = DigAddDigString(pc, DIG_STRING_TYPE_NORMAL, acLocalError);
593 if (iError != ER_OK)
594 {
595 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
596 return ER;
597 }
598 }
599
600 #ifdef USE_PCRE
601 else if (strcasecmp(pcControl, KEY_DigStringRegExp) == 0 && RUN_MODE_IS_SET(MODES_DigStringRegExp, iRunMode))
602 {
603 iError = DigAddDigString(pc, DIG_STRING_TYPE_REGEXP, acLocalError);
604 if (iError != ER_OK)
605 {
606 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
607 return ER;
608 }
609 }
610 #endif
611
612 #ifdef USE_XMAGIC
613 else if (strcasecmp(pcControl, KEY_DigStringXMagic) == 0 && RUN_MODE_IS_SET(MODES_DigStringXMagic, iRunMode))
614 {
615 iError = DigAddDigString(pc, DIG_STRING_TYPE_XMAGIC, acLocalError);
616 if (iError != ER_OK)
617 {
618 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
619 return ER;
620 }
621 }
622 #endif
623
624 else if (strcasecmp(pcControl, KEY_EnableRecursion) == 0 && RUN_MODE_IS_SET(MODES_EnableRecursion, iRunMode))
625 {
626 DUPLICATE_ERROR(psProperties->sFound.bEnableRecursionFound);
627 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bEnableRecursion);
628 psProperties->sFound.bEnableRecursionFound = TRUE;
629 }
630
631 else if (strcasecmp(pcControl, KEY_Exclude) == 0 && RUN_MODE_IS_SET(MODES_Exclude, iRunMode))
632 {
633 iError = SupportAddToList(pc, &psProperties->psExcludeList, "Exclude", acLocalError);
634 if (iError != ER_OK)
635 {
636 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
637 return ER;
638 }
639 }
640
641 #ifdef USE_PCRE
642 else if (strcasecmp(pcControl, KEY_ExcludeFilter) == 0 && RUN_MODE_IS_SET(MODES_ExcludeFilter, iRunMode))
643 {
644 iError = SupportAddFilter(pc, &psProperties->psExcludeFilterList, acLocalError);
645 if (iError != ER_OK)
646 {
647 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
648 return ER;
649 }
650 }
651
652 else if (strcasecmp(pcControl, KEY_ExcludeFilterMd5) == 0 && RUN_MODE_IS_SET(MODES_ExcludeFilterMd5, iRunMode))
653 {
654 iError = SupportAddFilter(pc, &psProperties->psExcludeFilterMd5List, acLocalError);
655 if (iError != ER_OK)
656 {
657 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
658 return ER;
659 }
660 psProperties->bHaveAttributeFilters = TRUE;
661 }
662
663 else if (strcasecmp(pcControl, KEY_ExcludeFilterSha1) == 0 && RUN_MODE_IS_SET(MODES_ExcludeFilterSha1, iRunMode))
664 {
665 iError = SupportAddFilter(pc, &psProperties->psExcludeFilterSha1List, acLocalError);
666 if (iError != ER_OK)
667 {
668 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
669 return ER;
670 }
671 psProperties->bHaveAttributeFilters = TRUE;
672 }
673
674 else if (strcasecmp(pcControl, KEY_ExcludeFilterSha256) == 0 && RUN_MODE_IS_SET(MODES_ExcludeFilterSha256, iRunMode))
675 {
676 iError = SupportAddFilter(pc, &psProperties->psExcludeFilterSha256List, acLocalError);
677 if (iError != ER_OK)
678 {
679 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
680 return ER;
681 }
682 psProperties->bHaveAttributeFilters = TRUE;
683 }
684 #endif
685
686 else if (strcasecmp(pcControl, KEY_ExcludesMustExist) == 0 && RUN_MODE_IS_SET(MODES_ExcludesMustExist, iRunMode))
687 {
688 DUPLICATE_ERROR(psProperties->sFound.bExcludesMustExistFound);
689 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bExcludesMustExist);
690 psProperties->sFound.bExcludesMustExistFound = TRUE;
691 }
692
693 else if (strcasecmp(pcControl, KEY_FieldMask) == 0 && RUN_MODE_IS_SET(MODES_FieldMask, iRunMode))
694 {
695 DUPLICATE_ERROR(psProperties->sFound.bFieldMaskFound);
696 psProperties->psFieldMask = MaskParseMask(pc, MASK_RUNMODE_TYPE_MAP, acLocalError);
697 if (psProperties->psFieldMask == NULL)
698 {
699 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], %s", acRoutine, pcControl, acLocalError);
700 return ER;
701 }
702 psProperties->sFound.bFieldMaskFound = TRUE;
703 }
704
705 #ifdef USE_FILE_HOOKS
706 else if (strcasecmp(pcControl, KEY_FileHook) == 0 && RUN_MODE_IS_SET(MODES_FileHook, iRunMode))
707 {
708 iError = HookAddHook(pc, &psProperties->psFileHookList, acLocalError);
709 if (iError != ER_OK)
710 {
711 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
712 return ER;
713 }
714 }
715 #endif
716
717 else if (strcasecmp(pcControl, KEY_FileSizeLimit) == 0 && RUN_MODE_IS_SET(MODES_FileSizeLimit, iRunMode))
718 {
719 DUPLICATE_ERROR(psProperties->sFound.bFileSizeLimitFound);
720 while (iLength > 0)
721 {
722 if (!isdigit((int) pc[iLength - 1]))
723 {
724 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
725 return ER;
726 }
727 iLength--;
728 }
729 psProperties->ulFileSizeLimit = strtoul(pc, NULL, 10);
730 if (errno == ERANGE)
731 {
732 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s]: %s", acRoutine, pcControl, pc, strerror(errno));
733 return ER;
734 }
735 psProperties->sFound.bFileSizeLimitFound = TRUE;
736 }
737
738 else if (strcasecmp(pcControl, KEY_GetAndExec) == 0 && RUN_MODE_IS_SET(MODES_GetAndExec, iRunMode))
739 {
740 DUPLICATE_ERROR(psProperties->sFound.bGetAndExecFound);
741 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bGetAndExec);
742 psProperties->sFound.bGetAndExecFound = TRUE;
743 }
744
745 else if (strcasecmp(pcControl, KEY_GetFileName) == 0 && RUN_MODE_IS_SET(MODES_GetFileName, iRunMode))
746 {
747 DUPLICATE_ERROR(psProperties->sFound.bGetFileNameFound);
748 if (iLength < 1 || iLength > FTIMES_MAX_PATH - 1)
749 {
750 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
751 return ER;
752 }
753 strncpy(psProperties->acGetFileName, pc, FTIMES_MAX_PATH);
754 psProperties->sFound.bGetFileNameFound = TRUE;
755 }
756
757 else if (strcasecmp(pcControl, KEY_HashDirectories) == 0 && RUN_MODE_IS_SET(MODES_HashDirectories, iRunMode))
758 {
759 DUPLICATE_ERROR(psProperties->sFound.bHashDirectoriesFound);
760 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bHashDirectories);
761 psProperties->sFound.bHashDirectoriesFound = TRUE;
762 }
763
764 else if (strcasecmp(pcControl, KEY_HashSymbolicLinks) == 0 && RUN_MODE_IS_SET(MODES_HashSymbolicLinks, iRunMode))
765 {
766 DUPLICATE_ERROR(psProperties->sFound.bHashSymbolicLinksFound);
767 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bHashSymbolicLinks);
768 psProperties->sFound.bHashSymbolicLinksFound = TRUE;
769 }
770
771 else if (strcasecmp(pcControl, KEY_Import) == 0 && RUN_MODE_IS_SET(MODES_Import, iRunMode))
772 {
773 psProperties->iImportRecursionLevel++;
774 iError = PropertiesReadFile(pc, psProperties, acLocalError);
775 if (iError != ER_OK)
776 {
777 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
778 return ER;
779 }
780 psProperties->iImportRecursionLevel--;
781 }
782
783 else if (strcasecmp(pcControl, KEY_Include) == 0 && RUN_MODE_IS_SET(MODES_Include, iRunMode))
784 {
785 iError = SupportAddToList(pc, &psProperties->psIncludeList, "Include", acLocalError);
786 if (iError != ER_OK)
787 {
788 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
789 return ER;
790 }
791 }
792
793 #ifdef USE_PCRE
794 else if (strcasecmp(pcControl, KEY_IncludeFilter) == 0 && RUN_MODE_IS_SET(MODES_IncludeFilter, iRunMode))
795 {
796 iError = SupportAddFilter(pc, &psProperties->psIncludeFilterList, acLocalError);
797 if (iError != ER_OK)
798 {
799 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
800 return ER;
801 }
802 }
803
804 else if (strcasecmp(pcControl, KEY_IncludeFilterMd5) == 0 && RUN_MODE_IS_SET(MODES_IncludeFilterMd5, iRunMode))
805 {
806 iError = SupportAddFilter(pc, &psProperties->psIncludeFilterMd5List, acLocalError);
807 if (iError != ER_OK)
808 {
809 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
810 return ER;
811 }
812 psProperties->bHaveAttributeFilters = TRUE;
813 }
814
815 else if (strcasecmp(pcControl, KEY_IncludeFilterSha1) == 0 && RUN_MODE_IS_SET(MODES_IncludeFilterSha1, iRunMode))
816 {
817 iError = SupportAddFilter(pc, &psProperties->psIncludeFilterSha1List, acLocalError);
818 if (iError != ER_OK)
819 {
820 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
821 return ER;
822 }
823 psProperties->bHaveAttributeFilters = TRUE;
824 }
825
826 else if (strcasecmp(pcControl, KEY_IncludeFilterSha256) == 0 && RUN_MODE_IS_SET(MODES_IncludeFilterSha256, iRunMode))
827 {
828 iError = SupportAddFilter(pc, &psProperties->psIncludeFilterSha256List, acLocalError);
829 if (iError != ER_OK)
830 {
831 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
832 return ER;
833 }
834 psProperties->bHaveAttributeFilters = TRUE;
835 }
836 #endif
837
838 else if (strcasecmp(pcControl, KEY_IncludesMustExist) == 0 && RUN_MODE_IS_SET(MODES_IncludesMustExist, iRunMode))
839 {
840 DUPLICATE_ERROR(psProperties->sFound.bIncludesMustExistFound);
841 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bIncludesMustExist);
842 psProperties->sFound.bIncludesMustExistFound = TRUE;
843 }
844
845 else if (strcasecmp(pcControl, KEY_LogDigStrings) == 0 && RUN_MODE_IS_SET(MODES_LogDigStrings, iRunMode))
846 {
847 DUPLICATE_ERROR(psProperties->sFound.bLogDigStringsFound);
848 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bLogDigStrings);
849 psProperties->sFound.bLogDigStringsFound = TRUE;
850 }
851
852 else if (strcasecmp(pcControl, KEY_LogDir) == 0 && RUN_MODE_IS_SET(MODES_LogDir, iRunMode))
853 {
854 DUPLICATE_ERROR(psProperties->sFound.bLogDirFound);
855 if (psProperties->iRunMode != FTIMES_CFGTEST || psProperties->iTestLevel == FTIMES_TEST_STRICT)
856 {
857 iError = SupportExpandDirectoryPath(pc, psProperties->acLogDirName, FTIMES_MAX_PATH, acLocalError);
858 if (iError != ER_OK)
859 {
860 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
861 return ER;
862 }
863 }
864 psProperties->sFound.bLogDirFound = TRUE;
865 }
866
867 else if (strcasecmp(pcControl, KEY_MagicFile) == 0 && RUN_MODE_IS_SET(MODES_MagicFile, iRunMode))
868 {
869 DUPLICATE_ERROR(psProperties->sFound.bMagicFileFound);
870 if (iLength < 1 || iLength > FTIMES_MAX_PATH - 1)
871 {
872 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
873 return ER;
874 }
875 strncpy(psProperties->acMagicFileName, pc, FTIMES_MAX_PATH);
876 psProperties->sFound.bMagicFileFound = TRUE;
877 }
878
879 else if (strcasecmp(pcControl, KEY_MatchLimit) == 0 && RUN_MODE_IS_SET(MODES_MatchLimit, iRunMode))
880 {
881 DUPLICATE_ERROR(psProperties->sFound.bMatchLimitFound);
882 while (iLength > 0)
883 {
884 if (!isdigit((int) pc[iLength - 1]))
885 {
886 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be an integer.", acRoutine, pcControl, pc);
887 return ER;
888 }
889 iLength--;
890 }
891 iValue = atoi(pc);
892 if (iValue < FTIMES_MIN_STRING_REPEATS || iValue > FTIMES_MAX_STRING_REPEATS)
893 {
894 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%d], Value is out of range.", acRoutine, pcControl, iValue);
895 return ER;
896 }
897 else
898 {
899 psProperties->iMatchLimit = iValue;
900 }
901 psProperties->sFound.bMatchLimitFound = TRUE;
902 }
903
904 else if (strcasecmp(pcControl, KEY_NewLine) == 0 && RUN_MODE_IS_SET(MODES_NewLine, iRunMode))
905 {
906 DUPLICATE_ERROR(psProperties->sFound.bNewLineFound);
907 if (strcasecmp(pc, "LF") == 0)
908 {
909 strncpy(psProperties->acNewLine, LF, NEWLINE_LENGTH);
910 }
911 else if (strcasecmp(pc, "CRLF") == 0)
912 {
913 strncpy(psProperties->acNewLine, CRLF, NEWLINE_LENGTH);
914 }
915 else
916 {
917 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value must be [LF|CRLF].", acRoutine, pcControl);
918 return ER;
919 }
920 psProperties->sFound.bNewLineFound = TRUE;
921 }
922
923 else if (strcasecmp(pcControl, KEY_OutDir) == 0 && RUN_MODE_IS_SET(MODES_OutDir, iRunMode))
924 {
925 DUPLICATE_ERROR(psProperties->sFound.bOutDirFound);
926 if (psProperties->iRunMode != FTIMES_CFGTEST || psProperties->iTestLevel == FTIMES_TEST_STRICT)
927 {
928 iError = SupportExpandDirectoryPath(pc, psProperties->acOutDirName, FTIMES_MAX_PATH, acLocalError);
929 if (iError != ER_OK)
930 {
931 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
932 return ER;
933 }
934 }
935 psProperties->sFound.bOutDirFound = TRUE;
936 }
937
938 else if (strcasecmp(pcControl, KEY_Priority) == 0 && RUN_MODE_IS_SET(MODES_Priority, iRunMode))
939 {
940 DUPLICATE_ERROR(psProperties->sFound.bPriorityFound);
941 if (iLength < 1 || iLength > FTIMES_MAX_PRIORITY_LENGTH - 1)
942 {
943 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
944 return ER_Length;
945 }
946 strncpy(psProperties->acPriority, pc, FTIMES_MAX_PRIORITY_LENGTH);
947 psProperties->sFound.bPriorityFound = TRUE;
948 }
949
950 else if (strcasecmp(pcControl, KEY_RequirePrivilege) == 0 && RUN_MODE_IS_SET(MODES_RequirePrivilege, iRunMode))
951 {
952 DUPLICATE_ERROR(psProperties->sFound.bRequirePrivilegeFound);
953 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bRequirePrivilege);
954 psProperties->sFound.bRequirePrivilegeFound = TRUE;
955 }
956
957 else if (strcasecmp(pcControl, KEY_RunType) == 0 && RUN_MODE_IS_SET(MODES_RunType, iRunMode))
958 {
959 DUPLICATE_ERROR(psProperties->sFound.bRunTypeFound);
960 if (strcasecmp(pc, "baseline") == 0)
961 {
962 strncpy(psProperties->acRunType, "baseline", RUNTYPE_BUFSIZE);
963 }
964 else if (strcasecmp(pc, "linktest") == 0)
965 {
966 strncpy(psProperties->acRunType, "linktest", RUNTYPE_BUFSIZE);
967 }
968 else if (strcasecmp(pc, "snapshot") == 0)
969 {
970 strncpy(psProperties->acRunType, "snapshot", RUNTYPE_BUFSIZE);
971 }
972 else
973 {
974 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value must be [baseline|linktest|snapshot].", acRoutine, pcControl);
975 return ER;
976 }
977 psProperties->sFound.bRunTypeFound = TRUE;
978 }
979
980 #ifdef USE_SSL
981 else if (strcasecmp(pcControl, KEY_SSLBundledCAsFile) == 0 && RUN_MODE_IS_SET(MODES_SSLBundledCAsFile, iRunMode))
982 {
983 DUPLICATE_ERROR(psProperties->sFound.bSSLBundledCAsFileFound);
984 if (psProperties->iRunMode != FTIMES_CFGTEST || psProperties->iTestLevel == FTIMES_TEST_STRICT)
985 {
986 iError = SupportExpandPath(pc, acTempFile, FTIMES_MAX_PATH, 1, acLocalError);
987 if (iError != ER_OK)
988 {
989 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
990 return ER;
991 }
992 iError = SslSetBundledCAsFile(psProperties->psSslProperties, acTempFile, acLocalError);
993 if (iError != ER_OK)
994 {
995 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
996 return ER;
997 }
998 }
999 psProperties->sFound.bSSLBundledCAsFileFound = TRUE;
1000 }
1001
1002 else if (strcasecmp(pcControl, KEY_SSLExpectedPeerCN) == 0 && RUN_MODE_IS_SET(MODES_SSLExpectedPeerCN, iRunMode))
1003 {
1004 DUPLICATE_ERROR(psProperties->sFound.bSSLExpectedPeerCNFound);
1005 iError = SslSetExpectedPeerCN(psProperties->psSslProperties, pc, acLocalError);
1006 if (iError != ER_OK)
1007 {
1008 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1009 return ER;
1010 }
1011 psProperties->sFound.bSSLExpectedPeerCNFound = TRUE;
1012 }
1013
1014 else if (strcasecmp(pcControl, KEY_SSLMaxChainLength) == 0 && RUN_MODE_IS_SET(MODES_SSLMaxChainLength, iRunMode))
1015 {
1016 DUPLICATE_ERROR(psProperties->sFound.bSSLMaxChainLengthFound);
1017 while (iLength > 0)
1018 {
1019 if (!isdigit((int) pc[iLength - 1]))
1020 {
1021 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%s], Value must be 1-10.", acRoutine, pcControl, pc);
1022 return ER;
1023 }
1024 iLength--;
1025 }
1026 iValue = atoi(pc);
1027 if (iValue < 1 || iValue > 10 /*SSL_MAX_CHAIN_LENGTH*/)
1028 {
1029 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value = [%d], Value must be 1-10.", acRoutine, pcControl, iValue);
1030 return ER;
1031 }
1032 else
1033 {
1034 psProperties->psSslProperties->iMaxChainLength = iValue;
1035 }
1036 psProperties->sFound.bSSLMaxChainLengthFound = TRUE;
1037 }
1038
1039 else if (strcasecmp(pcControl, KEY_SSLPassPhrase) == 0 && RUN_MODE_IS_SET(MODES_SSLPassPhrase, iRunMode))
1040 {
1041 DUPLICATE_ERROR(psProperties->sFound.bSSLPassPhraseFound);
1042 iError = SslSetPassPhrase(psProperties->psSslProperties, pc, acLocalError);
1043 if (iError != ER_OK)
1044 {
1045 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1046 return ER;
1047 }
1048 psProperties->sFound.bSSLPassPhraseFound = TRUE;
1049 }
1050
1051 else if (strcasecmp(pcControl, KEY_SSLPrivateKeyFile) == 0 && RUN_MODE_IS_SET(MODES_SSLPrivateKeyFile, iRunMode))
1052 {
1053 DUPLICATE_ERROR(psProperties->sFound.bSSLPrivateKeyFileFound);
1054 if (psProperties->iRunMode != FTIMES_CFGTEST || psProperties->iTestLevel == FTIMES_TEST_STRICT)
1055 {
1056 iError = SupportExpandPath(pc, acTempFile, FTIMES_MAX_PATH, 1, acLocalError);
1057 if (iError != ER_OK)
1058 {
1059 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1060 return ER;
1061 }
1062 iError = SslSetPrivateKeyFile(psProperties->psSslProperties, acTempFile, acLocalError);
1063 if (iError != ER_OK)
1064 {
1065 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1066 return ER;
1067 }
1068 }
1069 psProperties->sFound.bSSLPrivateKeyFileFound = TRUE;
1070 }
1071
1072 else if (strcasecmp(pcControl, KEY_SSLPublicCertFile) == 0 && RUN_MODE_IS_SET(MODES_SSLPublicCertFile, iRunMode))
1073 {
1074 DUPLICATE_ERROR(psProperties->sFound.bSSLPublicCertFileFound);
1075 if (psProperties->iRunMode != FTIMES_CFGTEST || psProperties->iTestLevel == FTIMES_TEST_STRICT)
1076 {
1077 iError = SupportExpandPath(pc, acTempFile, FTIMES_MAX_PATH, 1, acLocalError);
1078 if (iError != ER_OK)
1079 {
1080 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1081 return ER;
1082 }
1083 iError = SslSetPublicCertFile(psProperties->psSslProperties, acTempFile, acLocalError);
1084 if (iError != ER_OK)
1085 {
1086 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1087 return ER;
1088 }
1089 }
1090 psProperties->sFound.bSSLPublicCertFileFound = TRUE;
1091 }
1092
1093 else if (strcasecmp(pcControl, KEY_SSLUseCertificate) == 0 && RUN_MODE_IS_SET(MODES_SSLUseCertificate, iRunMode))
1094 {
1095 DUPLICATE_ERROR(psProperties->sFound.bSSLUseCertificateFound);
1096 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->psSslProperties->iUseCertificate);
1097 psProperties->sFound.bSSLUseCertificateFound = TRUE;
1098 }
1099
1100 else if (strcasecmp(pcControl, KEY_SSLVerifyPeerCert) == 0 && RUN_MODE_IS_SET(MODES_SSLVerifyPeerCert, iRunMode))
1101 {
1102 DUPLICATE_ERROR(psProperties->sFound.bSSLVerifyPeerCertFound);
1103 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->psSslProperties->iVerifyPeerCert);
1104 psProperties->sFound.bSSLVerifyPeerCertFound = TRUE;
1105 }
1106 #endif
1107
1108 else if (strcasecmp(pcControl, KEY_StrictControls) == 0 && RUN_MODE_IS_SET(MODES_StrictControls, iRunMode))
1109 {
1110 EVALUATE_TWOSTATE(pc, "y", "n", psProperties->bStrictControls);
1111 }
1112
1113 else if (strcasecmp(pcControl, KEY_URLAuthType) == 0 && RUN_MODE_IS_SET(MODES_URLAuthType, iRunMode))
1114 {
1115 DUPLICATE_ERROR(psProperties->sFound.bURLAuthTypeFound);
1116 if (strcasecmp(pc, "basic") == 0)
1117 {
1118 psProperties->iURLAuthType = HTTP_AUTH_TYPE_BASIC;
1119 }
1120 else if (strcasecmp(pc, "none") == 0)
1121 {
1122 psProperties->iURLAuthType = HTTP_AUTH_TYPE_NONE;
1123 }
1124 else
1125 {
1126 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value must be [basic|none].", acRoutine, pcControl);
1127 return ER;
1128 }
1129 psProperties->sFound.bURLAuthTypeFound = TRUE;
1130 }
1131
1132 else if (strcasecmp(pcControl, KEY_URLGetRequest) == 0 && RUN_MODE_IS_SET(MODES_URLGetRequest, iRunMode))
1133 {
1134 DUPLICATE_ERROR(psProperties->sFound.bURLGetRequestFound);
1135 if (strcasecmp(pc, "DigConfig") == 0)
1136 {
1137 strncpy(psProperties->acURLGetRequest, "DigConfig", GET_REQUEST_BUFSIZE);
1138 psProperties->iNextRunMode = FTIMES_DIGMODE;
1139 }
1140 else if (strcasecmp(pc, "MapConfig") == 0)
1141 {
1142 strncpy(psProperties->acURLGetRequest, "MapConfig", GET_REQUEST_BUFSIZE);
1143 psProperties->iNextRunMode = FTIMES_MAPMODE;
1144 }
1145 else
1146 {
1147 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Value must be [DigConfig|MapConfig].", acRoutine, pcControl);
1148 return ER;
1149 }
1150 psProperties->sFound.bURLGetRequestFound = TRUE;
1151 }
1152
1153 else if (strcasecmp(pcControl, KEY_URLGetURL) == 0 && RUN_MODE_IS_SET(MODES_URLGetURL, iRunMode))
1154 {
1155 DUPLICATE_ERROR(psProperties->sFound.bURLGetURLFound);
1156 if (iLength < 1 || iLength > FTIMES_MAX_PATH - 1)
1157 {
1158 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
1159 return ER;
1160 }
1161 psProperties->psGetURL = HttpParseUrl(pc, acLocalError);
1162 if (psProperties->psGetURL == NULL)
1163 {
1164 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1165 return ER;
1166 }
1167 psProperties->sFound.bURLGetURLFound = TRUE;
1168 }
1169
1170 else if (strcasecmp(pcControl, KEY_URLPassword) == 0 && RUN_MODE_IS_SET(MODES_URLPassword, iRunMode))
1171 {
1172 DUPLICATE_ERROR(psProperties->sFound.bURLPasswordFound);
1173 if (iLength < 1 || iLength > FTIMES_MAX_PASSWORD_LENGTH - 1)
1174 {
1175 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
1176 return ER;
1177 }
1178 strncpy(psProperties->acURLPassword, pc, FTIMES_MAX_PASSWORD_LENGTH);
1179 psProperties->sFound.bURLPasswordFound = TRUE;
1180 }
1181
1182 else if (strcasecmp(pcControl, KEY_URLPutSnapshot) == 0 && RUN_MODE_IS_SET(MODES_URLPutSnapshot, iRunMode))
1183 {
1184 DUPLICATE_ERROR(psProperties->sFound.bURLPutSnapshotFound);
1185 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bURLPutSnapshot);
1186 psProperties->sFound.bURLPutSnapshotFound = TRUE;
1187 }
1188
1189 else if (strcasecmp(pcControl, KEY_URLPutURL) == 0 && RUN_MODE_IS_SET(MODES_URLPutURL, iRunMode))
1190 {
1191 DUPLICATE_ERROR(psProperties->sFound.bURLPutURLFound);
1192 if (iLength < 1 || iLength > FTIMES_MAX_PATH - 1)
1193 {
1194 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
1195 return ER;
1196 }
1197 psProperties->psPutURL = HttpParseUrl(pc, acLocalError);
1198 if (psProperties->psPutURL == NULL)
1199 {
1200 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s]: %s", acRoutine, pcControl, acLocalError);
1201 return ER;
1202 }
1203 psProperties->sFound.bURLPutURLFound = TRUE;
1204 }
1205
1206 else if (strcasecmp(pcControl, KEY_URLUnlinkOutput) == 0 && RUN_MODE_IS_SET(MODES_URLUnlinkOutput, iRunMode))
1207 {
1208 DUPLICATE_ERROR(psProperties->sFound.bURLUnlinkOutputFound);
1209 EVALUATE_TWOSTATE(pc, "Y", "N", psProperties->bURLUnlinkOutput);
1210 psProperties->sFound.bURLUnlinkOutputFound = TRUE;
1211 }
1212
1213 else if (strcasecmp(pcControl, KEY_URLUsername) == 0 && RUN_MODE_IS_SET(MODES_URLUsername, iRunMode))
1214 {
1215 DUPLICATE_ERROR(psProperties->sFound.bURLUsernameFound);
1216 if (iLength < 1 || iLength > FTIMES_MAX_USERNAME_LENGTH - 1)
1217 {
1218 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], Invalid length [%d].", acRoutine, pcControl, iLength);
1219 return ER;
1220 }
1221 strncpy(psProperties->acURLUsername, pc, FTIMES_MAX_USERNAME_LENGTH);
1222 psProperties->sFound.bURLUsernameFound = TRUE;
1223 }
1224
1225 else
1226 {
1227 if (psProperties->bStrictControls)
1228 {
1229 snprintf(pcError, MESSAGE_SIZE, "%s: Control = [%s], The specified control is not valid in this mode of operation.", acRoutine, pcControl);
1230 return ER;
1231 }
1232 }
1233
1234 return ER_OK;
1235 }
1236
1237
1238 /*-
1239 ***********************************************************************
1240 *
1241 * PropertiesDisplaySettings
1242 *
1243 ***********************************************************************
1244 */
1245 void
PropertiesDisplaySettings(FTIMES_PROPERTIES * psProperties)1246 PropertiesDisplaySettings(FTIMES_PROPERTIES *psProperties)
1247 {
1248 char acMessage[MESSAGE_SIZE];
1249 #ifdef USE_FILE_HOOKS
1250 char *pcExpression = NULL;
1251 #endif
1252 DIG_STRING *psDigString;
1253 FILE_LIST *psList;
1254 #ifdef USE_PCRE
1255 FILTER_LIST *psFilterList;
1256 #endif
1257 #ifdef USE_FILE_HOOKS
1258 HOOK_LIST *psHook = NULL;
1259 #endif
1260 int i;
1261
1262 if (RUN_MODE_IS_SET(MODES_AnalyzeBlockSize, psProperties->iRunMode))
1263 {
1264 snprintf(acMessage, MESSAGE_SIZE, "%s=%d", KEY_AnalyzeBlockSize, psProperties->iAnalyzeBlockSize);
1265 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1266 }
1267
1268 if (RUN_MODE_IS_SET(MODES_AnalyzeByteCount, psProperties->iRunMode))
1269 {
1270 #ifdef WIN32
1271 snprintf(acMessage, MESSAGE_SIZE, "%s=%I64u", KEY_AnalyzeByteCount, (APP_UI64) psProperties->ui64AnalyzeByteCount);
1272 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1273 #else
1274 #ifdef USE_AP_SNPRINTF
1275 snprintf(acMessage, MESSAGE_SIZE, "%s=%qu", KEY_AnalyzeByteCount, (unsigned long long) psProperties->ui64AnalyzeByteCount);
1276 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1277 #else
1278 snprintf(acMessage, MESSAGE_SIZE, "%s=%llu", KEY_AnalyzeByteCount, (unsigned long long) psProperties->ui64AnalyzeByteCount);
1279 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1280 #endif
1281 #endif
1282 }
1283
1284 if (RUN_MODE_IS_SET(MODES_AnalyzeCarrySize, psProperties->iRunMode))
1285 {
1286 snprintf(acMessage, MESSAGE_SIZE, "%s=%d", KEY_AnalyzeCarrySize, psProperties->iAnalyzeCarrySize);
1287 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1288 }
1289
1290 if (RUN_MODE_IS_SET(MODES_AnalyzeStartOffset, psProperties->iRunMode))
1291 {
1292 #ifdef WIN32
1293 snprintf(acMessage, MESSAGE_SIZE, "%s=%I64u", KEY_AnalyzeStartOffset, (APP_UI64) psProperties->ui64AnalyzeStartOffset);
1294 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1295 #else
1296 #ifdef USE_AP_SNPRINTF
1297 snprintf(acMessage, MESSAGE_SIZE, "%s=%qu", KEY_AnalyzeStartOffset, (unsigned long long) psProperties->ui64AnalyzeStartOffset);
1298 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1299 #else
1300 snprintf(acMessage, MESSAGE_SIZE, "%s=%llu", KEY_AnalyzeStartOffset, (unsigned long long) psProperties->ui64AnalyzeStartOffset);
1301 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1302 #endif
1303 #endif
1304 }
1305
1306 #ifdef USE_XMAGIC
1307 if (RUN_MODE_IS_SET(MODES_AnalyzeStepSize, psProperties->iRunMode))
1308 {
1309 snprintf(acMessage, MESSAGE_SIZE, "%s=%d", KEY_AnalyzeStepSize, psProperties->iAnalyzeStepSize);
1310 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1311 }
1312 #endif
1313
1314 if (RUN_MODE_IS_SET(MODES_AnalyzeDeviceFiles, psProperties->iRunMode))
1315 {
1316 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_AnalyzeDeviceFiles, psProperties->bAnalyzeDeviceFiles ? "Y" : "N");
1317 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1318 }
1319
1320 if (RUN_MODE_IS_SET(MODES_AnalyzeMaxDps, psProperties->iRunMode))
1321 {
1322 snprintf(acMessage, MESSAGE_SIZE, "%s=%d (KB/s)", KEY_AnalyzeMaxDps, psProperties->iAnalyzeMaxDps);
1323 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1324 }
1325
1326 if (RUN_MODE_IS_SET(MODES_AnalyzeRemoteFiles, psProperties->iRunMode))
1327 {
1328 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_AnalyzeRemoteFiles, psProperties->bAnalyzeRemoteFiles ? "Y" : "N");
1329 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1330 }
1331
1332 if (RUN_MODE_IS_SET(MODES_BaseName, psProperties->iRunMode))
1333 {
1334 if (psProperties->acBaseName[0])
1335 {
1336 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_BaseName, psProperties->acBaseName);
1337 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1338 }
1339 }
1340
1341 if (RUN_MODE_IS_SET(MODES_BaseNameSuffix, psProperties->iRunMode))
1342 {
1343 if (psProperties->acBaseNameSuffix[0])
1344 {
1345 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_BaseNameSuffix, psProperties->acBaseNameSuffix);
1346 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1347 }
1348 }
1349
1350 if (RUN_MODE_IS_SET(MODES_Compress, psProperties->iRunMode))
1351 {
1352 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_Compress, psProperties->bCompress ? "Y" : "N");
1353 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1354 }
1355
1356 if (RUN_MODE_IS_SET(MODES_EnableRecursion, psProperties->iRunMode))
1357 {
1358 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_EnableRecursion, psProperties->bEnableRecursion ? "Y" : "N");
1359 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1360 }
1361
1362 if (RUN_MODE_IS_SET(MODES_ExcludesMustExist, psProperties->iRunMode))
1363 {
1364 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_ExcludesMustExist, psProperties->bExcludesMustExist ? "Y" : "N");
1365 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1366 }
1367
1368 if (RUN_MODE_IS_SET(MODES_FieldMask, psProperties->iRunMode))
1369 {
1370 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_FieldMask, psProperties->psFieldMask->pcMask);
1371 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1372 }
1373
1374 if (RUN_MODE_IS_SET(MODES_FileSizeLimit, psProperties->iRunMode))
1375 {
1376 snprintf(acMessage, MESSAGE_SIZE, "%s=%lu", KEY_FileSizeLimit, psProperties->ulFileSizeLimit);
1377 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1378 }
1379
1380 if (RUN_MODE_IS_SET(MODES_GetAndExec, psProperties->iRunMode))
1381 {
1382 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_GetAndExec, psProperties->bGetAndExec ? "Y" : "N");
1383 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1384 }
1385
1386 if (RUN_MODE_IS_SET(MODES_GetFileName, psProperties->iRunMode))
1387 {
1388 if (psProperties->acGetFileName[0])
1389 {
1390 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_GetFileName, psProperties->acGetFileName);
1391 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1392 }
1393 }
1394
1395 if (RUN_MODE_IS_SET(MODES_HashDirectories, psProperties->iRunMode))
1396 {
1397 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_HashDirectories, psProperties->bHashDirectories ? "Y" : "N");
1398 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1399 }
1400
1401 if (RUN_MODE_IS_SET(MODES_HashSymbolicLinks, psProperties->iRunMode))
1402 {
1403 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_HashSymbolicLinks, psProperties->bHashSymbolicLinks ? "Y" : "N");
1404 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1405 }
1406
1407 if (RUN_MODE_IS_SET(MODES_IncludesMustExist, psProperties->iRunMode))
1408 {
1409 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_IncludesMustExist, psProperties->bIncludesMustExist ? "Y" : "N");
1410 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1411 }
1412
1413 if (RUN_MODE_IS_SET(MODES_LogDir, psProperties->iRunMode))
1414 {
1415 if (psProperties->acLogDirName[0])
1416 {
1417 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_LogDir, psProperties->acLogDirName);
1418 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1419 }
1420 }
1421
1422 if (RUN_MODE_IS_SET(MODES_MagicFile, psProperties->iRunMode))
1423 {
1424 if (psProperties->acMagicFileName[0])
1425 {
1426 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_MagicFile, psProperties->acMagicFileName);
1427 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1428 }
1429 }
1430
1431 if (RUN_MODE_IS_SET(MODES_MatchLimit, psProperties->iRunMode))
1432 {
1433 snprintf(acMessage, MESSAGE_SIZE, "%s=%d", KEY_MatchLimit, psProperties->iMatchLimit);
1434 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1435 }
1436
1437 if (RUN_MODE_IS_SET(MODES_NewLine, psProperties->iRunMode))
1438 {
1439 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_NewLine, (strcmp(psProperties->acNewLine, LF) == 0) ? "LF" : "CRLF");
1440 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1441 }
1442
1443 if (RUN_MODE_IS_SET(MODES_OutDir, psProperties->iRunMode))
1444 {
1445 if (psProperties->acOutDirName[0])
1446 {
1447 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_OutDir, psProperties->acOutDirName);
1448 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1449 }
1450 }
1451
1452 if (RUN_MODE_IS_SET(MODES_Priority, psProperties->iRunMode))
1453 {
1454 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_Priority, psProperties->acPriority);
1455 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1456 }
1457
1458 if (RUN_MODE_IS_SET(MODES_RequirePrivilege, psProperties->iRunMode))
1459 {
1460 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_RequirePrivilege, psProperties->bRequirePrivilege ? "Y" : "N");
1461 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1462 }
1463
1464 if (RUN_MODE_IS_SET(MODES_RunType, psProperties->iRunMode))
1465 {
1466 if (psProperties->acRunType[0])
1467 {
1468 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_RunType, psProperties->acRunType);
1469 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1470 }
1471 }
1472
1473 if (RUN_MODE_IS_SET(MODES_URLGetURL, psProperties->iRunMode))
1474 {
1475 if (psProperties->psGetURL)
1476 {
1477 snprintf(acMessage, MESSAGE_SIZE, "%s=%s://%s:%s%s",
1478 KEY_URLGetURL,
1479 #ifdef USE_SSL
1480 (psProperties->psGetURL->iScheme == HTTP_SCHEME_HTTPS) ? "https" : "http",
1481 #else
1482 "http",
1483 #endif
1484 psProperties->psGetURL->pcHost,
1485 psProperties->psGetURL->pcPort,
1486 psProperties->psGetURL->pcPath
1487 );
1488 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1489 }
1490 }
1491
1492 if (RUN_MODE_IS_SET(MODES_URLGetRequest, psProperties->iRunMode))
1493 {
1494 if (psProperties->acURLGetRequest[0])
1495 {
1496 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_URLGetRequest, psProperties->acURLGetRequest);
1497 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1498 }
1499 }
1500
1501 /*-
1502 *********************************************************************
1503 *
1504 * Conditionally print URL/SSL properties.
1505 *
1506 *********************************************************************
1507 */
1508 if (RUN_MODE_IS_SET(MODES_URLPutSnapshot, psProperties->iRunMode) && psProperties->bURLPutSnapshot)
1509 {
1510 if (RUN_MODE_IS_SET(MODES_URLPutSnapshot, psProperties->iRunMode))
1511 {
1512 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_URLPutSnapshot, psProperties->bURLPutSnapshot ? "Y" : "N");
1513 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1514 }
1515
1516 if (RUN_MODE_IS_SET(MODES_URLPutURL, psProperties->iRunMode))
1517 {
1518 if (psProperties->bURLPutSnapshot && psProperties->psPutURL)
1519 {
1520 snprintf(acMessage, MESSAGE_SIZE, "%s=%s://%s:%s%s",
1521 KEY_URLPutURL,
1522 #ifdef USE_SSL
1523 (psProperties->psPutURL->iScheme == HTTP_SCHEME_HTTPS) ? "https" : "http",
1524 #else
1525 "http",
1526 #endif
1527 psProperties->psPutURL->pcHost,
1528 psProperties->psPutURL->pcPort,
1529 psProperties->psPutURL->pcPath
1530 );
1531 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1532 }
1533 }
1534
1535 if (RUN_MODE_IS_SET(MODES_URLUnlinkOutput, psProperties->iRunMode))
1536 {
1537 if (psProperties->bURLPutSnapshot)
1538 {
1539 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_URLUnlinkOutput, psProperties->bURLUnlinkOutput ? "Y" : "N");
1540 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1541 }
1542 }
1543
1544 if (RUN_MODE_IS_SET(MODES_URLAuthType, psProperties->iRunMode))
1545 {
1546 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_URLAuthType, (psProperties->iURLAuthType == HTTP_AUTH_TYPE_BASIC) ? "basic" : "none");
1547 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1548 }
1549
1550 if (RUN_MODE_IS_SET(MODES_URLUsername, psProperties->iRunMode))
1551 {
1552 if (psProperties->acURLUsername[0])
1553 {
1554 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_URLUsername, psProperties->acURLUsername);
1555 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1556 }
1557 }
1558
1559 if (RUN_MODE_IS_SET(MODES_URLPassword, psProperties->iRunMode))
1560 {
1561 if (psProperties->acURLPassword[0])
1562 {
1563 snprintf(acMessage, MESSAGE_SIZE, "%s=########", KEY_URLPassword);
1564 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1565 }
1566 }
1567
1568 #ifdef USE_SSL
1569 if (RUN_MODE_IS_SET(MODES_SSLVerifyPeerCert, psProperties->iRunMode))
1570 {
1571 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLVerifyPeerCert, psProperties->psSslProperties->iVerifyPeerCert ? "Y" : "N");
1572 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1573 }
1574
1575 if (RUN_MODE_IS_SET(MODES_SSLBundledCAsFile, psProperties->iRunMode))
1576 {
1577 if (psProperties->psSslProperties->iVerifyPeerCert && psProperties->psSslProperties->pcBundledCAsFile[0])
1578 {
1579 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLBundledCAsFile, psProperties->psSslProperties->pcBundledCAsFile);
1580 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1581 }
1582 }
1583
1584 if (RUN_MODE_IS_SET(MODES_SSLExpectedPeerCN, psProperties->iRunMode))
1585 {
1586 if (psProperties->psSslProperties->iVerifyPeerCert && psProperties->psSslProperties->pcExpectedPeerCN[0])
1587 {
1588 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLExpectedPeerCN, psProperties->psSslProperties->pcExpectedPeerCN);
1589 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1590 }
1591 }
1592
1593 if (RUN_MODE_IS_SET(MODES_SSLMaxChainLength, psProperties->iRunMode))
1594 {
1595 if (psProperties->psSslProperties->iVerifyPeerCert)
1596 {
1597 snprintf(acMessage, MESSAGE_SIZE, "%s=%d", KEY_SSLMaxChainLength, psProperties->psSslProperties->iMaxChainLength);
1598 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1599 }
1600 }
1601
1602 if (RUN_MODE_IS_SET(MODES_SSLUseCertificate, psProperties->iRunMode))
1603 {
1604 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLUseCertificate, psProperties->psSslProperties->iUseCertificate ? "Y" : "N");
1605 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1606 }
1607
1608 if (RUN_MODE_IS_SET(MODES_SSLPrivateKeyFile, psProperties->iRunMode))
1609 {
1610 if (psProperties->psSslProperties->iUseCertificate && psProperties->psSslProperties->pcPrivateKeyFile[0])
1611 {
1612 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLPrivateKeyFile, psProperties->psSslProperties->pcPrivateKeyFile);
1613 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1614 }
1615 }
1616
1617 if (RUN_MODE_IS_SET(MODES_SSLPublicCertFile, psProperties->iRunMode))
1618 {
1619 if (psProperties->psSslProperties->iUseCertificate && psProperties->psSslProperties->pcPublicCertFile[0])
1620 {
1621 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_SSLPublicCertFile, psProperties->psSslProperties->pcPublicCertFile);
1622 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1623 }
1624 }
1625
1626 if (RUN_MODE_IS_SET(MODES_SSLPassPhrase, psProperties->iRunMode))
1627 {
1628 if (psProperties->psSslProperties->iUseCertificate && psProperties->psSslProperties->pcPassPhrase[0])
1629 {
1630 snprintf(acMessage, MESSAGE_SIZE, "%s=########", KEY_SSLPassPhrase);
1631 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1632 }
1633 }
1634 #endif
1635 }
1636
1637 if (RUN_MODE_IS_SET(MODES_DigStringNormal, psProperties->iRunMode) && psProperties->bLogDigStrings)
1638 {
1639 for (i = 0; i < DIG_MAX_CHAINS; i++)
1640 {
1641 for (psDigString = DigGetSearchList(DIG_STRING_TYPE_NORMAL, i); psDigString != NULL; psDigString = psDigString->psNext)
1642 {
1643 snprintf(acMessage, MESSAGE_SIZE, "%s=%s%s%s",
1644 KEY_DigStringNormal,
1645 psDigString->pucEncodedString,
1646 (psDigString->pcTag[0]) ? " " : "",
1647 (psDigString->pcTag[0]) ? psDigString->pcTag : ""
1648 );
1649 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1650 }
1651 }
1652 }
1653
1654 if (RUN_MODE_IS_SET(MODES_DigStringNoCase, psProperties->iRunMode) && psProperties->bLogDigStrings)
1655 {
1656 for (i = 0; i < DIG_MAX_CHAINS; i++)
1657 {
1658 for (psDigString = DigGetSearchList(DIG_STRING_TYPE_NOCASE, i); psDigString != NULL; psDigString = psDigString->psNext)
1659 {
1660 snprintf(acMessage, MESSAGE_SIZE, "%s=%s%s%s",
1661 KEY_DigStringNoCase,
1662 psDigString->pucEncodedString,
1663 (psDigString->pcTag[0]) ? " " : "",
1664 (psDigString->pcTag[0]) ? psDigString->pcTag : ""
1665 );
1666 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1667 }
1668 }
1669 }
1670
1671 #ifdef USE_PCRE
1672 if (RUN_MODE_IS_SET(MODES_DigStringRegExp, psProperties->iRunMode) && psProperties->bLogDigStrings)
1673 {
1674 for (psDigString = DigGetSearchList(DIG_STRING_TYPE_REGEXP, 0); psDigString != NULL; psDigString = psDigString->psNext)
1675 {
1676 snprintf(acMessage, MESSAGE_SIZE, "%s=%s%s%s",
1677 KEY_DigStringRegExp,
1678 psDigString->pucEncodedString,
1679 (psDigString->pcTag[0]) ? " " : "",
1680 (psDigString->pcTag[0]) ? psDigString->pcTag : ""
1681 );
1682 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1683 }
1684 }
1685 #endif
1686
1687 #ifdef USE_XMAGIC
1688 if (RUN_MODE_IS_SET(MODES_DigStringXMagic, psProperties->iRunMode) && psProperties->bLogDigStrings)
1689 {
1690 for (psDigString = DigGetSearchList(DIG_STRING_TYPE_XMAGIC, 0); psDigString != NULL; psDigString = psDigString->psNext)
1691 {
1692 snprintf(acMessage, MESSAGE_SIZE, "%s=%s%s%s",
1693 KEY_DigStringXMagic,
1694 psDigString->pucEncodedString,
1695 (psDigString->pcTag[0]) ? " " : "",
1696 (psDigString->pcTag[0]) ? psDigString->pcTag : ""
1697 );
1698 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1699 }
1700 }
1701 #endif
1702
1703 if (RUN_MODE_IS_SET(MODES_Include, psProperties->iRunMode))
1704 {
1705 for (psList = psProperties->psIncludeList; psList != NULL; psList = psList->psNext)
1706 {
1707 snprintf(acMessage, MESSAGE_SIZE, "%s=file://%s", KEY_Include, psList->pcEncodedPath);
1708 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1709 }
1710 }
1711
1712 if (RUN_MODE_IS_SET(MODES_Exclude, psProperties->iRunMode))
1713 {
1714 for (psList = psProperties->psExcludeList; psList != NULL; psList = psList->psNext)
1715 {
1716 snprintf(acMessage, MESSAGE_SIZE, "%s=file://%s", KEY_Exclude, psList->pcEncodedPath);
1717 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1718 }
1719 }
1720
1721 #ifdef USE_PCRE
1722 if (RUN_MODE_IS_SET(MODES_IncludeFilter, psProperties->iRunMode))
1723 {
1724 for (psFilterList = psProperties->psIncludeFilterList; psFilterList != NULL; psFilterList = psFilterList->psNext)
1725 {
1726 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_IncludeFilter, psFilterList->pcFilter);
1727 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1728 }
1729 }
1730
1731 if (RUN_MODE_IS_SET(MODES_ExcludeFilter, psProperties->iRunMode))
1732 {
1733 for (psFilterList = psProperties->psExcludeFilterList; psFilterList != NULL; psFilterList = psFilterList->psNext)
1734 {
1735 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_ExcludeFilter, psFilterList->pcFilter);
1736 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1737 }
1738 }
1739
1740 if (RUN_MODE_IS_SET(MODES_IncludeFilterMd5, psProperties->iRunMode))
1741 {
1742 for (psFilterList = psProperties->psIncludeFilterMd5List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1743 {
1744 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_IncludeFilterMd5, psFilterList->pcFilter);
1745 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1746 }
1747 }
1748
1749 if (RUN_MODE_IS_SET(MODES_ExcludeFilterMd5, psProperties->iRunMode))
1750 {
1751 for (psFilterList = psProperties->psExcludeFilterMd5List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1752 {
1753 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_ExcludeFilterMd5, psFilterList->pcFilter);
1754 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1755 }
1756 }
1757
1758 if (RUN_MODE_IS_SET(MODES_IncludeFilterSha1, psProperties->iRunMode))
1759 {
1760 for (psFilterList = psProperties->psIncludeFilterSha1List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1761 {
1762 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_IncludeFilterSha1, psFilterList->pcFilter);
1763 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1764 }
1765 }
1766
1767 if (RUN_MODE_IS_SET(MODES_ExcludeFilterSha1, psProperties->iRunMode))
1768 {
1769 for (psFilterList = psProperties->psExcludeFilterSha1List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1770 {
1771 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_ExcludeFilterSha1, psFilterList->pcFilter);
1772 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1773 }
1774 }
1775
1776 if (RUN_MODE_IS_SET(MODES_IncludeFilterSha256, psProperties->iRunMode))
1777 {
1778 for (psFilterList = psProperties->psIncludeFilterSha256List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1779 {
1780 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_IncludeFilterSha256, psFilterList->pcFilter);
1781 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1782 }
1783 }
1784
1785 if (RUN_MODE_IS_SET(MODES_ExcludeFilterSha256, psProperties->iRunMode))
1786 {
1787 for (psFilterList = psProperties->psExcludeFilterSha256List; psFilterList != NULL; psFilterList = psFilterList->psNext)
1788 {
1789 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_ExcludeFilterSha256, psFilterList->pcFilter);
1790 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1791 }
1792 }
1793 #endif
1794
1795 #ifdef USE_FILE_HOOKS
1796 {
1797 if (RUN_MODE_IS_SET(MODES_FileHook, psProperties->iRunMode))
1798 {
1799 for (psHook = psProperties->psFileHookList; psHook != NULL; psHook = psHook->psNext)
1800 {
1801 pcExpression = KlelExpressionToString(psHook->psContext, KLEL_EXPRESSION_PLUS_EVERYTHING);
1802 snprintf(acMessage, MESSAGE_SIZE, "%s=%s", KEY_FileHook, pcExpression);
1803 free(pcExpression);
1804 MessageHandler(MESSAGE_QUEUE_IT, MESSAGE_INFORMATION, MESSAGE_PROPERTY_STRING, acMessage);
1805 }
1806 }
1807 }
1808 #endif
1809 }
1810