[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bacula-commits
Subject:    [Bacula-commits] SF.net SVN: bacula:[8400] trunk/bacula
From:       kerns () users ! sourceforge ! net
Date:       2009-01-24 17:56:41
Message-ID: E1LQmkL-0007sm-P4 () bj8yhf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 8400
          http://bacula.svn.sourceforge.net/bacula/?rev=8400&view=rev
Author:   kerns
Date:     2009-01-24 17:56:41 +0000 (Sat, 24 Jan 2009)

Log Message:
-----------
Modify search for .conf file so that if one is given on
     the command line, it will be used, otherwise it will use
     the SYSCONF directory.  It will no longer look in the current
     directory unless explicitly requested on the command line.
     This fixes bug #1189.

Modified Paths:
--------------
    trunk/bacula/src/dird/dird.c
    trunk/bacula/src/dird/dird_conf.c
    trunk/bacula/src/lib/parse_conf.c
    trunk/bacula/technotes-2.5

Modified: trunk/bacula/src/dird/dird.c
===================================================================
--- trunk/bacula/src/dird/dird.c	2009-01-24 15:54:47 UTC (rev 8399)
+++ trunk/bacula/src/dird/dird.c	2009-01-24 17:56:41 UTC (rev 8400)
@@ -1,7 +1,7 @@
 /*
    Bacula ® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.

Modified: trunk/bacula/src/dird/dird_conf.c
===================================================================
--- trunk/bacula/src/dird/dird_conf.c	2009-01-24 15:54:47 UTC (rev 8399)
+++ trunk/bacula/src/dird/dird_conf.c	2009-01-24 17:56:41 UTC (rev 8400)
@@ -1,7 +1,7 @@
 /*
    Bacula ® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.

Modified: trunk/bacula/src/lib/parse_conf.c
===================================================================
--- trunk/bacula/src/lib/parse_conf.c	2009-01-24 15:54:47 UTC (rev 8399)
+++ trunk/bacula/src/lib/parse_conf.c	2009-01-24 17:56:41 UTC (rev 8400)
@@ -1,7 +1,7 @@
 /*
    Bacula ® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -846,16 +846,17 @@
 
    if (first && (errstat=rwl_init(&res_lock)) != 0) {
       berrno be;
-      Emsg1(M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
+      Jmsg1(NULL, M_ABORT, 0, _("Unable to initialize resource lock. ERR=%s\n"),
             be.bstrerror(errstat));
    }
    first = false;
 
    char *full_path = (char *)alloca(MAX_PATH + 1);
 
-   if (find_config_file(cf, full_path, MAX_PATH +1)) {
-      cf = full_path;
+   if (!find_config_file(cf, full_path, MAX_PATH +1)) {
+      Jmsg0(NULL, M_ABORT, 0, _("Config filename too long.\n"));
    }
+   cf = full_path;
 
    /* Make two passes. The first builds the name symbol table,
     * and the second picks up the items.
@@ -1022,24 +1023,29 @@
 #endif
 }
 
+/*
+ * Returns false on error
+ *         true  on OK, with full_path set to where config file should be 
+ */
 static bool
 find_config_file(const char *config_file, char *full_path, int max_path)
 {
+   int file_length = strlen(config_file) + 1;
+
+   /* If a full path specified, use it */
    if (first_path_separator(config_file) != NULL) {
-      return false;
+      if (file_length > max_path) {
+         return false;
+      }
+      bstrncpy(full_path, config_file, file_length);
+      return true;
    }
 
-   struct stat st;
-
-   if (stat(config_file, &st) == 0) {
-      return false;
-   }
-
+   /* config_file is default file name, now find default dir */
    const char *config_dir = get_default_configdir();
    int dir_length = strlen(config_dir);
-   int file_length = strlen(config_file);
 
-   if ((dir_length + 1 + file_length + 1) > max_path) {
+   if ((dir_length + 1 + file_length) > max_path) {
       return false;
    }
 
@@ -1049,7 +1055,7 @@
       full_path[dir_length++] = '/';
    }
 
-   memcpy(&full_path[dir_length], config_file, file_length + 1);
+   memcpy(&full_path[dir_length], config_file, file_length);
 
    return true;
 }

Modified: trunk/bacula/technotes-2.5
===================================================================
--- trunk/bacula/technotes-2.5	2009-01-24 15:54:47 UTC (rev 8399)
+++ trunk/bacula/technotes-2.5	2009-01-24 17:56:41 UTC (rev 8400)
@@ -11,6 +11,11 @@
 
 General:
 24Jan09
+kes  Modify search for .conf file so that if one is given on
+     the command line, it will be used, otherwise it will use
+     the SYSCONF directory.  It will no longer look in the current
+     directory unless explicitly requested on the command line.
+     This fixes bug #1189.
 kes  Fail a job that references a plugin if no Plugin Directory is
      defined.
 22Jan09


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Bacula-commits mailing list
Bacula-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic