[syslog-ng] [PATCH 2/2] pdbtool: Test file accessibility in test mode.

Gergely Nagy algernon at balabit.hu
Mon Oct 31 18:16:12 CET 2011


When run in test mode (pdbtool test), check that a file exists, before
trying to load it, and return a sensible error message in case it does
not.

Reported-By: Peter Czanik <czanik at balabit.hu>
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 modules/dbparser/pdbtool.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/modules/dbparser/pdbtool.c b/modules/dbparser/pdbtool.c
index c2f9117..b11a91a 100644
--- a/modules/dbparser/pdbtool.c
+++ b/modules/dbparser/pdbtool.c
@@ -684,6 +684,13 @@ pdbtool_test(int argc, char *argv[])
 
   for (arg_pos = 1; arg_pos < argc; arg_pos++)
     {
+      if (access (argv[arg_pos], R_OK) == -1)
+	{
+	  fprintf(stderr, "%s: Unable to access the patterndb file\n", argv[arg_pos]);
+	  failed_to_validate = TRUE;
+	  continue;
+	}
+
       if (test_validate)
         {
           gchar cmd[1024];
-- 
1.7.7.1




More information about the syslog-ng mailing list