]> git.sur5r.net Git - bacula/bacula/commitdiff
Check for incorrect duration and size modifiers in conf files.
authorKern Sibbald <kern@sibbald.com>
Thu, 23 Jun 2005 21:06:15 +0000 (21:06 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 23 Jun 2005 21:06:15 +0000 (21:06 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2163 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/kes-1.37
bacula/src/dird/dird_conf.c
bacula/src/lib/edit.c
bacula/src/lib/protos.h
bacula/src/lib/pythonlib.c
bacula/src/version.h

index 8afdc5d36132d7fef26654dfbf70d3943b76d933..f7401507908d385d2f37f58f70a25bc82dd8c3d7 100644 (file)
@@ -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.
-
index a1354e431d8aa6b034f4858bfd7b09a2e5f72340..380bf4629995918ee43023f1c559c00b0e9e44b3 100644 (file)
@@ -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
index 95170737c45650e0f99e4ddbfe9aa84d99d4f23a..905bae027f27e3c5faac55b078f9daaca8f891b4 100644 (file)
    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.
 
  */
 
index bcebed3909de38f54e68cbd15694cf4238d5fe78..c579569b37b761132799787d76fc4c496ab62d2b 100644 (file)
@@ -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;
 }
 
 /*
index 75e140ae5f73d1a75a0c971414f47cc5263a6955..5e8cad4fd9395de5aa74d265e15f3dd4ba8ff5f5 100644 (file)
@@ -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);
index cbfe67bd4224354f0266ee31b24602049469fd8b..8d00e343d9239427ee71cd0e74345db91dbb047b 100644 (file)
@@ -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.
 
  */
 
index 52122dc263c57a6f99d01e9d3636c5d16c65da2a..cec8eccc958d048319a37dd4504ac7237c622b67 100644 (file)
@@ -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