From: Kern Sibbald Date: Sat, 24 Jan 2009 17:56:41 +0000 (+0000) Subject: Modify search for .conf file so that if one is given on X-Git-Tag: Release-3.0.0~278 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c8e598db31d2f582ee60f528cfa57c9d2cd78a02;p=bacula%2Fbacula 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8400 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index b8b065f621..48fe7487f0 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -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. diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 6595c7d2e8..077ff4c707 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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. diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index f85798d8fc..8bf7b18a8f 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -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 @@ bool CONFIG::parse_config() 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 @@ const char *get_default_configdir() #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) { - if (first_path_separator(config_file) != NULL) { - return false; - } + int file_length = strlen(config_file) + 1; - struct stat st; - - if (stat(config_file, &st) == 0) { - return false; + /* If a full path specified, use it */ + if (first_path_separator(config_file) != NULL) { + if (file_length > max_path) { + return false; + } + bstrncpy(full_path, config_file, file_length); + return true; } + /* 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 @@ find_config_file(const char *config_file, char *full_path, int max_path) 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; } diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index e525fe41da..3ecd8e50fd 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -11,6 +11,11 @@ mixed priorities 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