]> git.sur5r.net Git - bacula/bacula/commitdiff
Misc bug fixes
authorKern Sibbald <kern@sibbald.com>
Wed, 2 Jun 2004 20:00:22 +0000 (20:00 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 2 Jun 2004 20:00:22 +0000 (20:00 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1382 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/dird.c
bacula/src/dird/query.sql
bacula/src/stored/block.c
bacula/src/stored/btape.c
bacula/src/stored/butil.c
bacula/src/stored/stored_conf.c
bacula/src/tools/Makefile.in
bacula/src/tools/dbcheck.c
bacula/src/version.h

index b8ff96b8ace7cfeeee24913eb61fad7c74cfe9f7..2e3843a2b37d040cfc0ce37be3e4aa1b423eba24 100644 (file)
@@ -349,6 +349,9 @@ void reload_config(int sig)
    int njobs = 0;
    int table, rtable;
 
+   Jmsg(NULL, M_ERROR, 0, _("Command not implemented\n"));
+   return;
+
    if (already_here) {
       abort();                       /* Oops, recursion -> die */
    }
index 9495f2c1f44683abd280f7dd4d9ef4a9c486e341..a145cc6d2ceffd76d8c838b4ce7ec29ef1e77a4f 100644 (file)
@@ -128,7 +128,7 @@ INSERT INTO temp2 SELECT Job.JobId,Job.StartTime,Media.VolumeName,
  AND JobMedia.MediaId=Media.MediaId
  GROUP BY Job.JobId;
 # list results
-SELECT * from temp2;
+SELECT DISTINCT VolumeName from temp2;
 !DROP TABLE temp;
 !DROP TABLE temp2;
 # 10
index 85f92eed33b877d26317ee75bf913968d505ad82..cd33bf46b6f2c049bdade461ebddef192dbc1eaa 100644 (file)
@@ -689,7 +689,7 @@ int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_bloc
    DCR *dcr = jcr->dcr;
 
    if (!dcr) {
-      Jmsg(jcr, M_ABORT, 0, _("DCR is NULL!\n"));
+      Jmsg0(jcr, M_ABORT, 0, _("DCR is NULL!\n"));
    }
    if (dev_state(dev, ST_EOT)) {
       return 0;
index 151554940850e92abe5e2b5d57fc0100107f5934..6521425ecf3caa317411e1d7b2d389cf2d96ccc0 100644 (file)
@@ -1890,8 +1890,8 @@ This may take a long time -- hours! ...\n\n");
                 strerror(errno));
    }
 
-   /* Release the device */
-   if (!release_device(jcr)) {
+   /* Release the device if multiple tapes being used */
+   if (!simple && !release_device(jcr)) {
       Pmsg0(-1, _("Error in release_device\n"));
       ok = false;
    }
index 4d439b5048a49c4112c72bc34433d27816355895..9f811f289240566e4211b628e2327f0632371548 100644 (file)
@@ -100,6 +100,10 @@ DEVICE *setup_to_access_device(JCR *jcr, int read_access)
    pm_strcpy(&jcr->dev_name, device->device_name);
    
    dev = init_dev(NULL, device);
+   if (!dev) {
+      Jmsg1(jcr, M_FATAL, 0, _("Cannot init device %s\n"), jcr->dev_name);
+      return NULL;
+   }
    jcr->device->dev = dev;
    new_dcr(jcr, dev);       
    if (!dev || !first_open_device(dev)) {
index ebdc1a6f63485cb37842b1ae6b6de151138e86dd..7f619e9c6a09a76561755fec18c9a4bcb8d923ab 100644 (file)
@@ -146,7 +146,7 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...
    char buf[MAXSTRING];
    int recurse = 1;
    if (res == NULL) {
-      sendit(sock, _("Warning: no %s resource (%d) defined.\n"), res_to_str(type), type);
+      sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), res_to_str(type), type);
       return;
    }
    sendit(sock, "dump_resource type=%d\n", type);
@@ -342,13 +342,13 @@ void save_resource(int type, RES_ITEM *items, int pass)
    for (i=0; items[i].name; i++) {
       if (items[i].flags & ITEM_REQUIRED) {
         if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {  
-            Emsg2(M_ABORT, 0, _("%s item is required in %s resource, but not found.\n"),
+            Emsg2(M_ERROR_TERM, 0, _("\"%s\" item is required in \"%s\" resource, but not found.\n"),
              items[i].name, resources[rindex]);
          }
       }
       /* If this triggers, take a look at lib/parse_conf.h */
       if (i >= MAX_RES_ITEMS) {
-         Emsg1(M_ABORT, 0, _("Too many items in %s resource\n"), resources[rindex]);
+         Emsg1(M_ERROR_TERM, 0, _("Too many items in \"%s\" resource\n"), resources[rindex]);
       }
    }
 
@@ -368,7 +368,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
         /* Resources containing a resource */
         case R_STORAGE:
            if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) {
-               Emsg1(M_ABORT, 0, "Cannot find Storage resource %s\n", res_all.res_dir.hdr.name);
+               Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name);
            }
            res->res_store.messages = res_all.res_store.messages;
            break;
@@ -422,7 +422,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
         for (next=resources[rindex].res_head; next->next; next=next->next) {
            if (strcmp(next->name, res->res_dir.hdr.name) == 0) {
               Emsg2(M_ERROR_TERM, 0,
-                  _("Attempt to define second %s resource named \"%s\" is not permitted.\n"),
+                  _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"),
                  resources[rindex].name, res->res_dir.hdr.name);
            }
         }
index ced8002607464dfbed55b84c81fb81f5be459c82..739c71f43c9ca21358d238e96414a77f14332934 100644 (file)
@@ -28,6 +28,8 @@ FINDOBJS = testfind.o
 # these are the objects that are changed by the .configure process
 EXTRAOBJS = @OBJLIST@
 
+DIRCONFOBJS = ../dird/dird_conf.o ../dird/run_conf.o ../dird/inc_conf.o
+
 .SUFFIXES:     .c .o
 .PHONY:
 .DONTCARE:
@@ -43,8 +45,8 @@ all: Makefile bsmtp dbcheck testfind testls
 bsmtp: bsmtp.o ../lib/libbac.a        
        $(CXX) $(LDFLAGS) -L../lib -o $@ bsmtp.o -lbac -lm $(LIBS) $(DLIB)
 
-dbcheck: dbcheck.o ../lib/libbac.a ../cats/libsql.a
-       $(CXX) $(LDFLAGS) -L../lib -L../cats -o $@ dbcheck.o -lsql -lbac -lm $(LIBS) $(DB_LIBS)
+dbcheck: dbcheck.o ../lib/libbac.a ../cats/libsql.a $(DIRCONFOBJS)
+       $(CXX) $(LDFLAGS) -L../lib -L../cats -o $@ dbcheck.o $(DIRCONFOBJS) -lsql -lbac -lm $(LIBS) $(DB_LIBS)
 
 testfind: ../findlib/libfind.a ../lib/libbac.a $(FINDOBJS)
        $(CXX) -g $(LDFLAGS) -L. -L../lib -L../findlib -o $@ $(FINDOBJS) \
index 86df726e8ee47583a7edb033a4e9f6e9b2205286..875072ab09207d8e1fb53d3882fcb29aeef7c4eb 100644 (file)
@@ -9,7 +9,7 @@
  *
  */
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -30,6 +30,7 @@
 
 #include "bacula.h"
 #include "cats/cats.h"
+#include "dird/dird_conf.h"
 
 typedef struct s_id_ctx {
    uint32_t *Id;                     /* ids to be modified */
@@ -82,8 +83,10 @@ static int yes_no(char *prompt);
 static void usage()
 {
    fprintf(stderr,
-"Usage: dbcheck [-d debug_level] <working-directory> <bacula-databse> <user> <password>\n"
+"Usage: dbcheck [-c config] [-C catalogname] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>]\n"
 "       -b              batch mode\n"
+"       -C              catalogname in the director configfile\n"
+"       -c              director configfilename\n"
 "       -dnn            set debug level to nn\n"
 "       -f              fix inconsistencies\n"
 "       -v              verbose\n"
@@ -94,7 +97,9 @@ static void usage()
 int main (int argc, char *argv[])
 {
    int ch;
-   char *user, *password, *db_name;
+   char *user, *password, *db_name, *dbhost;
+   char *configfile = NULL;
+   char *catalogname = NULL;
 
    my_name_is(argc, argv, "dbcheck");
    init_msg(NULL, NULL);             /* setup message handler */
@@ -103,12 +108,20 @@ int main (int argc, char *argv[])
    memset(&name_list, 0, sizeof(name_list));
 
 
-   while ((ch = getopt(argc, argv, "bd:fv?")) != -1) {
+   while ((ch = getopt(argc, argv, "bc:C:d:fv?")) != -1) {
       switch (ch) {
       case 'b':                    /* batch */
         batch = true;
         break;
 
+      case 'C':                    /* CatalogName */
+         catalogname = optarg;
+        break;
+
+      case 'c':                    /* configfile */
+         configfile = optarg;
+        break;
+
       case 'd':                    /* debug level */
         debug_level = atoi(optarg);
         if (debug_level <= 0)
@@ -131,38 +144,78 @@ int main (int argc, char *argv[])
    argc -= optind;
    argv += optind;
 
-   if (argc > 4) {
-      Pmsg0(0, _("Wrong number of arguments.\n"));
-      usage();
-   }
-
-   if (argc < 1) {
-      Pmsg0(0, _("Working directory not supplied.\n"));
-      usage();
-   }
+   if (configfile) {
+      CAT *catalog = NULL;
+      int found = 0;
+      if (argc > 0) {
+         Pmsg0(0, _("Warning skipping the additional parameters for working directory/dbname/user/password/host.\n"));
+      }
+      parse_config(configfile);
+      LockRes();
+      foreach_res(catalog, R_CATALOG) {
+        if (catalogname && !strcmp(catalog->hdr.name, catalogname)) { 
+           ++found;
+           break;
+        } else if (!catalogname) { // stop on first if no catalogname is given
+          ++found;
+          break;
+        }
+      }
+      UnlockRes();
+      if (!found) {
+        if (catalogname) {
+            Pmsg2(0, "Error can not find the Catalog name[%s] in the given config file [%s]\n", catalogname, configfile);
+        } else {
+            Pmsg1(0, "Error there is no Catalog section in the given config file [%s]\n", configfile);
+        }
+        return 1;
+      } else {
+         db_name = catalog->db_name;
+         user = catalog->db_user;
+         password = catalog->db_password;
+          dbhost = (catalog->db_address[0] == '\0') ? NULL : catalog->db_address;
+      }
+   } else {
+      if (argc > 5) {
+         Pmsg0(0, _("Wrong number of arguments.\n"));
+        usage();
+      }
 
-   /* This is needed by SQLite to find the db */
-   working_directory = argv[0];
-   db_name = "bacula";
-   user = db_name;
-   password = "";
+      if (argc < 1) {
+         Pmsg0(0, _("Working directory not supplied.\n"));
+        usage();
+      }
 
-   if (argc == 2) {
-      db_name = argv[1];
+      /* This is needed by SQLite to find the db */
+      working_directory = argv[0];
+      db_name = "bacula";
       user = db_name;
-   } else if (argc == 3) {
-      db_name = argv[1];
-      user = argv[2];
-   } else if (argc == 4) {
-      db_name = argv[1];
-      user = argv[2];
-      password = argv[3];
+      password = "";
+      dbhost = NULL;
+
+      if (argc == 2) {
+        db_name = argv[1];
+        user = db_name;
+      } else if (argc == 3) {
+        db_name = argv[1];
+        user = argv[2];
+      } else if (argc == 4) {
+        db_name = argv[1];
+        user = argv[2];
+        password = argv[3];
+      } else if (argc == 5) {
+        db_name = argv[1];
+        user = argv[2];
+        password = argv[3];
+        dbhost = argv[4];
+      }
    }
 
    /* Open database */
-   db = db_init_database(NULL, db_name, user, password, NULL, 0, NULL);
+   db = db_init_database(NULL, db_name, user, password, dbhost, 0, NULL);
    if (!db_open_database(NULL, db)) {
       Emsg1(M_FATAL, 0, "%s", db_strerror(db));
+         return 1;
    }
 
    if (batch) {
index 70903504ac66e6f7715169583907d6ac0a91080e..f07b7fd32d45497a12b6b5e0ddb009474fac2c11 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.34.3"
 #define VSTRING "1"
-#define BDATE   "01 June 2004"
-#define LSMDATE "01Jun04"
+#define BDATE   "02 June 2004"
+#define LSMDATE "02Jun04"
 
 /* Debug flags */
 #undef  DEBUG