]> git.sur5r.net Git - bacula/bacula/commitdiff
- Change cats/sql.c to elimate %-*s format, which I think is turned
authorKern Sibbald <kern@sibbald.com>
Mon, 24 Jul 2006 13:43:18 +0000 (13:43 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 24 Jul 2006 13:43:18 +0000 (13:43 +0000)
  off in bsnprintf.
- Add Comment field to llist of a volume.
- Allow true/false in some yes/no questions.
- Implement update volume enable=(on|off|true|false|archived|0|1|2)
- Remove a few /n's when scanning commands from another daemon. This
  permits adding additional fields later.
- Modify dbcheck to handle ctl-d and to delete Log table entries.
- Update README.mingw

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3175 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/kes-1.39
bacula/src/cats/sql.c
bacula/src/cats/sql_list.c
bacula/src/dird/run_conf.c
bacula/src/dird/ua_update.c
bacula/src/filed/authenticate.c
bacula/src/filed/job.c
bacula/src/tools/dbcheck.c
bacula/src/win32/README.mingw32

index 3a1c4d1e6dc6868dcd42e6b12aca5835076ed954..51d2a2c1028dbb63607c255ee48f2c1d80d184f5 100644 (file)
@@ -23,14 +23,13 @@ Document:
 - Document setting my.cnf to big file usage.
 - Add example of proper index output to doc.
    show index from File;
+- Correct the Include syntax in the m4.xxx files in examples/conf
 
 Priority:
 
 For 1.39:
 - Remove queue.c code.
-- Correct the Include syntax in the m4.xxx files in examples/conf
-- Get Perl replacement for bregex.c
-- Fix auth compatibility with 1.38
+- Fix ClientRunBefore/AfterJob compatibility.
 - Fix re-read of last block to check if job has actually written
   a block, and check if block was written by a different job
   (i.e. multiple simultaneous jobs writing).
@@ -55,6 +54,8 @@ For 1.39:
      target slot. The catalog should be updated accordingly.
   .move transfer device=xxx fromslot=yyy toslot=zzz
 
+Low priority:
+- Get Perl replacement for bregex.c
 
 - Given all the problems with FIFOs, I think the solution is to do something a
   little different, though I will look at the code and see if there is not some
@@ -1622,4 +1623,7 @@ Block Position: 0
     LocationId
     NewState???
 - Add Comment to Media record
+- Fix auth compatibility with 1.38
+- Update dbcheck to include Log table
+- Update llist to include new fields.
 
index 3b4b6cf28e57129d9acafb3e26ee850dcd1afd91..d48a51b92adb2b26c0443ecfcaebccd0427f6f71 100644 (file)
@@ -2,6 +2,16 @@
                         Kern Sibbald
 
 General:
+24Jul06
+- Change cats/sql.c to elimate %-*s format, which I think is turned
+  off in bsnprintf.
+- Add Comment field to llist of a volume.
+- Allow true/false in some yes/no questions.
+- Implement update volume enable=(on|off|true|false|archived|0|1|2)
+- Remove a few /n's when scanning commands from another daemon. This
+  permits adding additional fields later.
+- Modify dbcheck to handle ctl-d and to delete Log table entries.
+- Update README.mingw
 22Jul06
 - Tweak authentication to work with 1.38.x FDs. 
 - Tweak catalog make scripts.
index 9844f1458f10441af4ebf24766b8dcbfa3f8b7a4..d1ab64267224107e1a57563219ca73e0075d8420 100644 (file)
@@ -485,9 +485,11 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t
    send(ctx, "|");
    sql_field_seek(mdb, 0);
    for (i = 0; i < sql_num_fields(mdb); i++) {
+      char fmtbuf[50]; 
       Dmsg1(800, "list_result looking at field %d\n", i);
       field = sql_fetch_field(mdb);
-      bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, field->name);
+      bsnprintf(fmtbuf, sizeof(fmtbuf), "%%-%ds }", (int)field->max_length);
+      bsnprintf(buf, sizeof(buf), fmtbuf, field->name);
       send(ctx, buf);
    }
    send(ctx, "\n");
index 1f6cbb6376b10be10d0e4aa78392a88e67ad0abf..2eff15952affc5a9712b0146545a4624dc4dfe27 100644 (file)
@@ -151,7 +151,8 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
             "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention,"
             "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
             "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId,"
-            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId"
+            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId, "
+            "Comment"
             " FROM Media WHERE Media.VolumeName='%s'", mdbr->VolumeName);
       } else {
          Mmsg(mdb->cmd, "SELECT MediaId,VolumeName,Slot,PoolId,"
@@ -160,7 +161,8 @@ db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
             "VolCapacityBytes,VolStatus,Enabled,Recycle,VolRetention,"
             "VolUseDuration,MaxVolJobs,MaxVolFiles,MaxVolBytes,InChanger,"
             "EndFile,EndBlock,VolParts,LabelType,StorageId,DeviceId,"
-            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId"
+            "LocationId,RecycleCount,InitialWrite,ScratchPoolId,RecyclePoolId, "
+            "Comment"
             " FROM Media WHERE Media.PoolId=%s ORDER BY MediaId", 
             edit_int64(mdbr->PoolId, ed1));
       }
index b7eb4896d06ce16be75bf567f0c31d71ae612806..394fbe4731460c199b772f6ca3b899456f78dde6 100644 (file)
@@ -197,10 +197,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
             switch (RunFields[i].token) {
             case 's':                 /* Data spooling */
                token = lex_get_token(lc, T_NAME);
-               if (strcasecmp(lc->str, "yes") == 0) {
+               if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) {
                   lrun.spool_data = true;
                   lrun.spool_data_set = true;
-               } else if (strcasecmp(lc->str, "no") == 0) {
+               } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) {
                   lrun.spool_data = false;
                   lrun.spool_data_set = true;
                } else {
@@ -209,10 +209,10 @@ void store_run(LEX *lc, RES_ITEM *item, int index, int pass)
                break;
             case 'W':                 /* Write part after job */
                token = lex_get_token(lc, T_NAME);
-               if (strcasecmp(lc->str, "yes") == 0) {
+               if (strcasecmp(lc->str, "yes") == 0 || strcasecmp(lc->str, "true") == 0) {
                   lrun.write_part_after_job = true;
                   lrun.write_part_after_job_set = true;
-               } else if (strcasecmp(lc->str, "no") == 0) {
+               } else if (strcasecmp(lc->str, "no") == 0 || strcasecmp(lc->str, "false") == 0) {
                   lrun.write_part_after_job = false;
                   lrun.write_part_after_job_set = true;
                } else {
index 2422f46a00f8bb6403d1c0db5ab09c6a236da719..f8bf9c3f072b4dbf123a2dc124b30aad1ef25b76 100644 (file)
@@ -365,6 +365,29 @@ static void update_all_vols_from_pool(UAContext *ua)
    }
 }
 
+static void update_volenabled(UAContext *ua, char *val, MEDIA_DBR *mr)
+{
+   if (strcasecmp(val, "yes") == 0 || strcasecmp(val, "true") == 0) {
+      mr->Enabled = 1;
+   } else if (strcasecmp(val, "no") == 0 || strcasecmp(val, "false") == 0) {
+      mr->Enabled = 0;
+   } else if (strcasecmp(val, "archived") == 0) { 
+      mr->Enabled = 2;
+   } else {
+      mr->Enabled = atoi(val);
+   }
+   if (mr->Enabled < 0 || mr->Enabled > 2) {
+      bsendmsg(ua, _("Invalid Enabled, it must be 0, 1, or 2\n"));
+      return;
+   }
+   if (!db_update_media_record(ua->jcr, ua->db, mr)) {
+      bsendmsg(ua, _("Error updating media record Enabled: ERR=%s"), db_strerror(ua->db));
+   } else {
+      bsendmsg(ua, _("New Enabled is: %d\n"), mr->Enabled);
+   }
+}
+
+
 
 /*
  * Update a media record -- allows you to change the
@@ -381,18 +404,19 @@ static int update_volume(UAContext *ua)
    bool done = false;
    int i;
    const char *kw[] = {
-      NT_("VolStatus"),                /* 0 */
-      NT_("VolRetention"),             /* 1 */
-      NT_("VolUse"),                   /* 2 */
-      NT_("MaxVolJobs"),               /* 3 */
-      NT_("MaxVolFiles"),              /* 4 */
-      NT_("MaxVolBytes"),              /* 5 */
-      NT_("Recycle"),                  /* 6 */
-      NT_("InChanger"),                /* 7 */
-      NT_("Slot"),                     /* 8 */
-      NT_("Pool"),                     /* 9 */
-      NT_("FromPool"),                 /* 10 */
-      NT_("AllFromPool"),              /* 11 !!! see below !!! */
+      _("VolStatus"),                /* 0 */
+      _("VolRetention"),             /* 1 */
+      _("VolUse"),                   /* 2 */
+      _("MaxVolJobs"),               /* 3 */
+      _("MaxVolFiles"),              /* 4 */
+      _("MaxVolBytes"),              /* 5 */
+      _("Recycle"),                  /* 6 */
+      _("InChanger"),                /* 7 */
+      _("Slot"),                     /* 8 */
+      _("Pool"),                     /* 9 */
+      _("FromPool"),                 /* 10 */
+      _("AllFromPool"),              /* 11 !!! see below !!! */
+      _("Enabled"),                  /* 12 */
       NULL };
 
 #define AllFromPool 11               /* keep this updated with above */
@@ -401,6 +425,7 @@ static int update_volume(UAContext *ua)
       int j;
       POOL_DBR pr;
       if ((j=find_arg_with_value(ua, kw[i])) > 0) {
+         /* If all from pool don't select a media record */
          if (i != AllFromPool && !select_media_dbr(ua, &mr)) {
             return 0;
          }
@@ -447,6 +472,9 @@ static int update_volume(UAContext *ua)
          case 11:
             update_all_vols_from_pool(ua);
             return 1;
+         case 12:
+            update_volenabled(ua, ua->argv[j], &mr);
+            break;
          }
          done = true;
       }
@@ -467,11 +495,12 @@ static int update_volume(UAContext *ua)
       add_prompt(ua, _("Pool"));                       /* 10 */
       add_prompt(ua, _("Volume from Pool"));           /* 11 */
       add_prompt(ua, _("All Volumes from Pool"));      /* 12 */
-      add_prompt(ua, _("Done"));                       /* 13 */
+      add_prompt(ua, _("Enabled")),                    /* 13 */
+      add_prompt(ua, _("Done"));                       /* 14 */
       i = do_prompt(ua, "", _("Select parameter to modify"), NULL, 0);  
 
-      /* For All Volumes from Pool we don't need a Volume record */
-      if (i != 12 && i != 13) {
+      /* For All Volumes from Pool and Done, we don't need a Volume record */
+      if (i != 12 && i != 14) {
          if (!select_media_dbr(ua, &mr)) {  /* Get Volume record */
             return 0;
          }
@@ -621,6 +650,24 @@ static int update_volume(UAContext *ua)
       case 12:
          update_all_vols_from_pool(ua);
          return 1;
+
+      case 13:
+         bsendmsg(ua, _("Current Enabled is: %d\n"), mr.Enabled);
+         if (!get_cmd(ua, _("Enter new Enabled: "))) {
+            return 0;
+         }
+         if (strcasecmp(ua->cmd, "yes") == 0 || strcasecmp(ua->cmd, "true") == 0) {
+            mr.Enabled = 1;
+         } else if (strcasecmp(ua->cmd, "no") == 0 || strcasecmp(ua->cmd, "false") == 0) {
+            mr.Enabled = 0;
+         } else if (strcasecmp(ua->cmd, "archived") == 0) { 
+            mr.Enabled = 2;
+         } else {
+            mr.Enabled = atoi(ua->cmd);
+         }
+         update_volenabled(ua, ua->cmd, &mr);
+         break;
+
       default:                        /* Done or error */
          bsendmsg(ua, _("Selection terminated.\n"));
          return 1;
index 556eff2e0bd1553a60fcfb3808558f6fe13b056d..0ca88dfdc7e362373e977a6366a821fec724b9e3 100644 (file)
@@ -59,8 +59,8 @@ static bool authenticate(int rcode, BSOCK *bs, JCR* jcr)
    dirname = check_pool_memory_size(dirname, bs->msglen);
 
    if (sscanf(bs->msg, "Hello Director %s calling", dirname) != 1) {
-       char addr[64];
-       char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who : addr;
+      char addr[64];
+      char *who = bnet_get_peer(bs, addr, sizeof(addr)) ? bs->who : addr;
       bs->msg[100] = 0;
       Dmsg2(50, "Bad Hello command from Director at %s: %s\n",
             bs->who, bs->msg);
index 5513b7da323e61763b507d5fc231bf2b76ef96f5..9142c8e818379c468a187535d7a4c106513cf2de 100644 (file)
@@ -97,15 +97,16 @@ static struct s_cmds cmds[] = {
 
 /* Commands received from director that need scanning */
 static char jobcmd[]      = "JobId=%d Job=%127s SDid=%d SDtime=%d Authorization=%100s";
-static char storaddr[]    = "storage address=%s port=%d ssl=%d\n";
+static char storaddr[]    = "storage address=%s port=%d ssl=%d";
 static char sessioncmd[]  = "session %127s %ld %ld %ld %ld %ld %ld\n";
 static char restorecmd[]  = "restore replace=%c prelinks=%d where=%s\n";
 static char restorecmd1[] = "restore replace=%c prelinks=%d where=\n";
-static char verifycmd[]   = "verify level=%30s\n";
-static char estimatecmd[] = "estimate listing=%d\n";
-static char runbefore[]   = "RunBeforeJob %s\n";
-static char runafter[]    = "RunAfterJob %s\n";
-static char runscript[]   = "Run OnSuccess=%u OnFailure=%u AbortOnError=%u When=%u Command=%s\n";
+static char verifycmd[]   = "verify level=%30s";
+static char estimatecmd[] = "estimate listing=%d";
+static char runbefore[]   = "RunBeforeJob %s";
+static char runafter[]    = "RunAfterJob %s";
+static char runscript[]   = "Run OnSuccess=%u OnFailure=%u AbortOnError=%u When=%u Command=%s";
+
 /* Responses sent to Director */
 static char errmsg[]      = "2999 Invalid command\n";
 static char no_auth[]     = "2998 No Authorization\n";
index 66ae3858cd343c46a85feac6b1144592425d9c54..d473899c3681b5560a3aa045f8e4e7526993feb2 100644 (file)
@@ -56,7 +56,8 @@ static bool batch = false;
 static B_DB *db;
 static ID_LIST id_list;
 static NAME_LIST name_list;
-static char buf[2000];
+static char buf[20000];
+static bool quit = false;
 
 #define MAX_ID_LIST_LEN 10000000
 
@@ -81,7 +82,7 @@ static void eliminate_restore_records();
 static void repair_bad_paths();
 static void repair_bad_filenames();
 static void do_interactive_mode();
-static int yes_no(const char *prompt);
+static bool yes_no(const char *prompt);
 
 
 static void usage()
@@ -266,7 +267,6 @@ int main (int argc, char *argv[])
 
 static void do_interactive_mode()
 {
-   bool quit = false;
    const char *cmd;
 
    printf(_("Hello, this is the database check/correct program.\n"));
@@ -468,7 +468,7 @@ static int id_list_handler(void *ctx, int num_fields, char **row)
    }
    if (lst->num_ids == lst->max_ids) {
       if (lst->max_ids == 0) {
-         lst->max_ids = 1000;
+         lst->max_ids = 10000;
          lst->Id = (uint32_t *)bmalloc(sizeof(uint32_t) * lst->max_ids);
       } else {
          lst->max_ids = (lst->max_ids * 3) / 2;
@@ -522,7 +522,7 @@ static int name_list_handler(void *ctx, int num_fields, char **row)
    }
    if (name->num_ids == name->max_ids) {
       if (name->max_ids == 0) {
-         name->max_ids = 1000;
+         name->max_ids = 10000;
          name->name = (char **)bmalloc(sizeof(char *) * name->max_ids);
       } else {
          name->max_ids = (name->max_ids * 3) / 2;
@@ -590,6 +590,9 @@ static void eliminate_duplicate_filenames()
    if (name_list.num_ids && verbose && yes_no(_("Print the list? (yes/no): "))) {
       print_name_list(&name_list);
    }
+   if (quit) {
+      return;
+   }
    if (fix) {
       /* Loop through list of duplicate names */
       for (int i=0; i<name_list.num_ids; i++) {
@@ -644,6 +647,9 @@ static void eliminate_duplicate_paths()
    if (name_list.num_ids && verbose && yes_no(_("Print them? (yes/no): "))) {
       print_name_list(&name_list);
    }
+   if (quit) {
+      return;
+   }
    if (fix) {
       /* Loop through list of duplicate names */
       for (int i=0; i<name_list.num_ids; i++) {
@@ -701,6 +707,9 @@ static void eliminate_orphaned_jobmedia_records()
          }
       }
    }
+   if (quit) {
+      return;
+   }
 
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned JobMedia records.\n"), id_list.num_ids);
@@ -733,7 +742,9 @@ static void eliminate_orphaned_file_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned File records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM File WHERE FileId=%u", &id_list);
@@ -761,7 +772,9 @@ static void eliminate_orphaned_path_records()
          db_sql_query(db, buf, print_name_handler, NULL);
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned Path records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Path WHERE PathId=%u", &id_list);
@@ -789,7 +802,9 @@ static void eliminate_orphaned_filename_records()
          db_sql_query(db, buf, print_name_handler, NULL);
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned Filename records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Filename WHERE FilenameId=%u", &id_list);
@@ -820,7 +835,9 @@ static void eliminate_orphaned_fileset_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned FileSet records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM FileSet WHERE FileSetId=%u", &id_list);
@@ -858,7 +875,9 @@ static void eliminate_orphaned_client_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned Client records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Client WHERE ClientId=%u", &id_list);
@@ -896,10 +915,16 @@ static void eliminate_orphaned_job_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d orphaned Job records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
+      printf(_("Deleting JobMedia records of orphaned Job records.\n"));
+      delete_id_list("DELETE FROM JobMedia WHERE JobId=%u", &id_list);
+      printf(_("Deleting Log records of orphaned Job records.\n"));
+      delete_id_list("DELETE FROM Log WHERE JobId=%u", &id_list);
    }
 }
 
@@ -927,7 +952,9 @@ static void eliminate_admin_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d Admin Job records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
@@ -957,7 +984,9 @@ static void eliminate_restore_records()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       printf(_("Deleting %d Restore Job records.\n"), id_list.num_ids);
       delete_id_list("DELETE FROM Job WHERE JobId=%u", &id_list);
@@ -991,7 +1020,9 @@ static void repair_bad_filenames()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       POOLMEM *name = get_pool_memory(PM_FNAME);
       char esc_name[5000];
@@ -1049,7 +1080,9 @@ static void repair_bad_paths()
          }
       }
    }
-
+   if (quit) {
+      return;
+   }
    if (fix && id_list.num_ids > 0) {
       POOLMEM *name = get_pool_memory(PM_FNAME);
       char esc_name[5000];
@@ -1087,17 +1120,23 @@ static char *get_cmd(const char *prompt)
    static char cmd[1000];
 
    printf("%s", prompt);
-   if (fgets(cmd, sizeof(cmd), stdin) == NULL)
+   if (fgets(cmd, sizeof(cmd), stdin) == NULL) {
+      printf("\n");
+      quit = true;
       return NULL;
-   printf("\n");
+   }
    strip_trailing_junk(cmd);
    return cmd;
 }
 
-static int yes_no(const char *prompt)
+static bool yes_no(const char *prompt)
 {
    char *cmd;
    cmd = get_cmd(prompt);
+   if (!cmd) {
+      quit = true;
+      return false;
+   }
    return (strcasecmp(cmd, "yes") == 0) || (strcasecmp(cmd, _("yes")) == 0);
 }
 
index 9a57ba5eabc11fc6737ca3a76202dacc7b66b7be..e4263614754da06cfb6e494e4ce633247442d7a4 100644 (file)
@@ -52,8 +52,16 @@ the following once:
 
 The above only needs to be done once unless we change the cross-tools 
 version.  In general, you can run the script multiple times with no
-problem. For it to work, you must have a valid gcc compiler installed on
-your system as well as wget and texinfo.  There may be other dependencies.
+problem. For it to work, you must have at a minimum the following:
+
+  gcc
+  g++
+  wget
+  texinfo
+  bison
+  man2html
+
+and possibly other packages.
 
 After building the cross-tools, you can proceed to build the depkgs-win32 
 packages, which must use the cross-tools compiler.