From 9b84e05c08407c1a3836aa53c305630317090c3c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 23 Jun 2005 21:06:15 +0000 Subject: [PATCH] Check for incorrect duration and size modifiers in conf files. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2163 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kernstodo | 4 +++- bacula/kes-1.37 | 6 +++-- bacula/src/dird/dird_conf.c | 15 +++++-------- bacula/src/lib/edit.c | 44 ++++++++++++++++++++----------------- bacula/src/lib/protos.h | 4 ++-- bacula/src/lib/pythonlib.c | 16 +++++--------- bacula/src/version.h | 4 ++-- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/bacula/kernstodo b/bacula/kernstodo index 8afdc5d361..f740150790 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -49,6 +49,9 @@ Document: - Document the multiple-drive-changer.txt script. For 1.37: +- Refuse to prune last valid Full backup. Same goes for Catalog. +- Why is SpoolDirectory = /home/bacula/spool; not reported + as an error when writing a DVD? - Add setting Volume State via Python. - Make bootstrap file handle multiple MediaTypes (SD) - --without-openssl breaks at least on Solaris. @@ -1286,4 +1289,3 @@ Block Position: 0 - Implement "PreferMountedVolumes = yes|no" in Job resource. ## Integrate web-bacula into a new Bacula project with bimagemgr. - diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index a1354e431d..380bf46299 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,11 +4,13 @@ General: Changes to 1.37.26: +23Jun05 +- Check for incorrect duration and size modifiers in conf files. 22Jun05: - Make Version a tuple (version, build-date) -- Add CatalogRes tuple (DbName, Address, User, Password, +- Add CatalogRes tuple (DBName, Address, User, Password, Socket, Port) -- Add Version, ConfigDir, and WorkingDir as Python attributes +- Add Version, ConfigFile, and WorkingDir as Python attributes in the Director. - Implement code (principally for Win32) that on failure to create a file, it will cd into the directory and attempt diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 95170737c4..905bae027f 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -25,19 +25,14 @@ Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as ammended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/lib/edit.c b/bacula/src/lib/edit.c index bcebed3909..c579569b37 100644 --- a/bacula/src/lib/edit.c +++ b/bacula/src/lib/edit.c @@ -218,10 +218,10 @@ static bool get_modifier(char *str, char *num, int num_len, char *mod, int mod_l /* * Convert a string duration to utime_t (64 bit seconds) - * Returns 0: if error - 1: if OK, and value stored in value + * Returns false: if error + true: if OK, and value stored in value */ -int duration_to_utime(char *str, utime_t *value) +bool duration_to_utime(char *str, utime_t *value) { int i, mod_len; double val, total = 0.0; @@ -239,12 +239,12 @@ int duration_to_utime(char *str, utime_t *value) while (*str) { if (!get_modifier(str, num_str, sizeof(num_str), mod_str, sizeof(mod_str))) { - return 0; + return false; } /* Now find the multiplier corresponding to the modifier */ mod_len = strlen(mod_str); if (mod_len == 0) { - i = 1; /* assume seconds */ + i = 1; /* default to seconds */ } else { for (i=0; mod[i]; i++) { if (strncasecmp(mod_str, mod[i], mod_len) == 0) { @@ -252,19 +252,19 @@ int duration_to_utime(char *str, utime_t *value) } } if (mod[i] == NULL) { - i = 1; /* no modifier, assume secs */ + return false; } } Dmsg2(900, "str=%s: mult=%d\n", num_str, mult[i]); errno = 0; val = strtod(num_str, NULL); if (errno != 0 || val < 0) { - return 0; + return false; } total += val * mult[i]; } *value = (utime_t)total; - return 1; + return true; } /* @@ -298,10 +298,10 @@ char *edit_utime(utime_t val, char *buf, int buf_len) /* * Convert a size in bytes to uint64_t - * Returns 0: if error - 1: if OK, and value stored in value + * Returns false: if error + true: if OK, and value stored in value */ -int size_to_uint64(char *str, int str_len, uint64_t *value) +bool size_to_uint64(char *str, int str_len, uint64_t *value) { int i, mod_len; double val; @@ -321,22 +321,26 @@ int size_to_uint64(char *str, int str_len, uint64_t *value) } /* Now find the multiplier corresponding to the modifier */ mod_len = strlen(mod_str); - for (i=0; mod[i]; i++) { - if (strncasecmp(mod_str, mod[i], mod_len) == 0) { - break; + if (mod_len == 0) { + i = 0; /* default with no modifier = 1 */ + } else { + for (i=0; mod[i]; i++) { + if (strncasecmp(mod_str, mod[i], mod_len) == 0) { + break; + } + } + if (mod[i] == NULL) { + return false; } - } - if (mod[i] == NULL) { - i = 0; /* no modifier found, assume 1 */ } Dmsg2(900, "str=%s: mult=%d\n", str, mult[i]); errno = 0; val = strtod(num_str, NULL); if (errno != 0 || val < 0) { - return 0; + return false; } - *value = (utime_t)(val * mult[i]); - return 1; + *value = (utime_t)(val * mult[i]); + return true; } /* diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 75e140ae5f..5e8cad4fd9 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -123,8 +123,8 @@ char * edit_uint64_with_commas (uint64_t val, char *buf); char * add_commas (char *val, char *buf); char * edit_uint64 (uint64_t val, char *buf); char * edit_int64 (int64_t val, char *buf); -int duration_to_utime (char *str, utime_t *value); -int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); +bool duration_to_utime (char *str, utime_t *value); +bool size_to_uint64(char *str, int str_len, uint64_t *rtn_value); char *edit_utime (utime_t val, char *buf, int buf_len); bool is_a_number (const char *num); bool is_an_integer (const char *n); diff --git a/bacula/src/lib/pythonlib.c b/bacula/src/lib/pythonlib.c index cbfe67bd42..8d00e343d9 100644 --- a/bacula/src/lib/pythonlib.c +++ b/bacula/src/lib/pythonlib.c @@ -7,24 +7,18 @@ * Version $Id$ * */ - /* Copyright (C) 2004-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as ammended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/version.h b/bacula/src/version.h index 52122dc263..cec8eccc95 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.26" -#define BDATE "22 June 2005" -#define LSMDATE "22Jun05" +#define BDATE "23 June 2005" +#define LSMDATE "23Jun05" /* Debug flags */ #undef DEBUG -- 2.39.5