]> git.sur5r.net Git - bacula/bacula/commitdiff
- Implement using pg_config for finding PostgreSQL files.
authorKern Sibbald <kern@sibbald.com>
Fri, 21 Apr 2006 11:25:15 +0000 (11:25 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 21 Apr 2006 11:25:15 +0000 (11:25 +0000)
  Fixes bug #600. Patch supplied by user.
- Remove -t option from mktemp in mtx_changer.in and use
  working directory. Fixes bug #578.
- Update job start time after the any run before job so that
  files created by the script are only backed up once. Fixes
  bug #599.
- Strip trailing newline only from filenames entered in
  the restore command when reading a file. This permits
  the user to enter filenames with trailing spaces. Fixes
  bug #549. The user supplied a patch that I modified slightly.
- Use the most recent time (st_mtime, st_ctime) in the dir
  command in restore. This gives the user a better idea of what
  the newest file really is. This fixes bug #574. The fix
  was suggested by the user.
- Implement a compatible version of base64. This permits external
  programs to duplicate Bacula's base64 algorithm using standard
  routines. This fixes bugs #296, and 565. Patch submitted by
  author of bug #565.
  ================= Note ========================
  Previous Signatures stored in the database are no longer
  compatible with this. The main downside is for Verify jobs,
  and doing an InitCatalog run will fix the problem. Also, the
  authentication between the deamons is changed, so all daemons
  must be simultaneously upgraded.
  ==============================================
  If you don't like this fix, set:
    const bool compatible = true;
  to
    const bool compatible = false;
  in src/lib/base64.c

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

bacula/autoconf/bacula-macros/db.m4
bacula/kes-1.39
bacula/scripts/mtx-changer.in
bacula/src/dird/job.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_tree.c
bacula/src/dird/ua_update.c
bacula/src/lib/base64.c
bacula/src/lib/cram-md5.c
bacula/src/lib/md5.c
bacula/src/version.h

index 8428ab8a8887c8400d1044709392caeabc72c099..f3cc016021680109d0e1e7a784c9ec4924854aaf 100644 (file)
@@ -288,7 +288,12 @@ AC_ARG_WITH(postgresql,
           AC_MSG_ERROR("You can configure for only one database.");
       fi
       if test "$withval" = "yes"; then
-          if test -f /usr/local/include/libpq-fe.h; then
+          PG_CONFIG=`which pg_config`
+          if test -n "$PG_CONFIG";then
+              POSTGRESQL_INCDIR=`"$PG_CONFIG" --includedir`
+              POSTGRESQL_LIBDIR=`"$PG_CONFIG" --libdir`
+              POSTGRESQL_BINDIR=`"$PG_CONFIG" --bindir`
+          elif test -f /usr/local/include/libpq-fe.h; then
               POSTGRESQL_INCDIR=/usr/local/include
               POSTGRESQL_LIBDIR=/usr/local/lib
               POSTGRESQL_BINDIR=/usr/local/bin
index 878edca5f012a562d5e39affed528219a6d5322f..e4cfdb04f185520dd7cbfef33d14cc67f226d73a 100644 (file)
@@ -2,6 +2,38 @@
                         Kern Sibbald
 
 General:
+21Apr06
+- Implement using pg_config for finding PostgreSQL files.
+  Fixes bug #600. Patch supplied by user.
+- Remove -t option from mktemp in mtx_changer.in and use
+  working directory. Fixes bug #578.
+- Update job start time after the any run before job so that
+  files created by the script are only backed up once. Fixes
+  bug #599.
+- Strip trailing newline only from filenames entered in
+  the restore command when reading a file. This permits
+  the user to enter filenames with trailing spaces. Fixes
+  bug #549. The user supplied a patch that I modified slightly.
+- Use the most recent time (st_mtime, st_ctime) in the dir
+  command in restore. This gives the user a better idea of what
+  the newest file really is. This fixes bug #574. The fix
+  was suggested by the user.
+- Implement a compatible version of base64. This permits external
+  programs to duplicate Bacula's base64 algorithm using standard
+  routines. This fixes bugs #296, and 565. Patch submitted by   
+  author of bug #565.  
+  ================= Note ========================
+  Previous Signatures stored in the database are no longer
+  compatible with this. The main downside is for Verify jobs,
+  and doing an InitCatalog run will fix the problem. Also, the
+  authentication between the deamons is changed, so all daemons
+  must be simultaneously upgraded.
+  ==============================================
+  If you don't like this fix, set:
+    const bool compatible = true;
+  to
+    const bool compatible = false;
+  in src/lib/base64.c
 20Apr06
 - Ensure that DB signature is never NULL.
 - Ensure that DB table names are not translated.
index 152bda5979b387e53ba8799cfcba5daa4ad9fe1c..5bd399fec70132a18673720c2ffa6866a0a99932 100644 (file)
@@ -54,7 +54,7 @@ debug() {
 # Create a temporary file
 #
 make_temp_file() {
-  TMPFILE=`mktemp -t mtx.XXXXXXXXXX`
+  TMPFILE=`mktemp @working_dir@/mtx.XXXXXXXXXX`
   if test x${TMPFILE} = x; then
      TMPFILE="@working_dir@/mtx.$$"
      if test -f ${TMPFILE}; then
index 280159e84a981b050c0eeecdfd41ed6098e2515a..339fb408440e625d7e7a5707915fecbdcad288a7 100644 (file)
@@ -265,7 +265,19 @@ static void *job_thread(void *arg)
             goto bail_out;
          }
       }
-
+      /*
+       * We re-update the job start record so that the start
+       *  time is set after the run before job.  This avoids
+       *  that any files created by the run before job will
+       *  be saved twice.  They will be backed up in the current
+       *  job, but not in the next one unless they are changed.
+       *  Without this, they will be backed up in this job and
+       *  in the next job run because in that case, their date
+       *   is after the start of this run.
+       */
+      if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
+         Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
+      }
       generate_job_event(jcr, "JobRun");
 
       switch (jcr->JobType) {
index 1034e1b420965a107765da0d25b6e73b219a4516..428523aa71540711aaa746f16b46be01bc5da77b 100644 (file)
@@ -722,7 +722,7 @@ static bool insert_file_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *f
 {
    char ed1[50];
 
-   strip_trailing_junk(file);
+   strip_trailing_newline(file);
    split_path_and_filename(rx, file);
    if (*rx->JobIds == 0) {
       Mmsg(rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, 
index 4011f18a54972c1bc77516a1cc437584bb22fb17..a4064369779d6f0a5e7c15613a9ab7c8dda8d68a 100644 (file)
@@ -472,6 +472,7 @@ static void ls_output(char *buf, const char *fname, const char *tag,
    char ec1[30];
    char en1[30], en2[30];
    int n;
+   time_t time;
 
    p = encode_mode(statp->st_mode, buf);
    if (dot_cmd) {
@@ -495,7 +496,13 @@ static void ls_output(char *buf, const char *fname, const char *tag,
       p += n;
       n = sprintf(p, "%10.10s  ", edit_uint64(statp->st_size, ec1));
       p += n;
-      p = encode_time(statp->st_ctime, p);
+      if (statp->st_ctime > statp->st_mtime) {
+         time = statp->st_ctime;
+      } else {
+         time = statp->st_mtime;
+      }
+      /* Display most recent time */
+      p = encode_time(time, p);
       *p++ = ' ';
       *p++ = *tag;
    }
index e08705d4409ea86f6c2f6289456fa564dd774d67..ccf7db8916af20a9364df3dcd63fee241eb50c03 100644 (file)
@@ -460,28 +460,29 @@ static int update_volume(UAContext *ua)
    }
 
    for ( ; !done; ) {
-      bsendmsg(ua, _("Updating Volume \"%s\"\n"), mr.VolumeName);
       start_prompt(ua, _("Parameters to modify:\n"));
-      add_prompt(ua, _("Volume Status"));
-      add_prompt(ua, _("Volume Retention Period"));
-      add_prompt(ua, _("Volume Use Duration"));
-      add_prompt(ua, _("Maximum Volume Jobs"));
-      add_prompt(ua, _("Maximum Volume Files"));
-      add_prompt(ua, _("Maximum Volume Bytes"));
-      add_prompt(ua, _("Recycle Flag"));
-      add_prompt(ua, _("Slot"));
-      add_prompt(ua, _("InChanger Flag"));
-      add_prompt(ua, _("Volume Files"));
-      add_prompt(ua, _("Pool"));
-      add_prompt(ua, _("Volume from Pool"));
-      add_prompt(ua, _("All Volumes from Pool"));
-      add_prompt(ua, _("Done"));
+      add_prompt(ua, _("Volume Status"));              /* 0 */
+      add_prompt(ua, _("Volume Retention Period"));    /* 1 */
+      add_prompt(ua, _("Volume Use Duration"));        /* 2 */
+      add_prompt(ua, _("Maximum Volume Jobs"));        /* 3 */
+      add_prompt(ua, _("Maximum Volume Files"));       /* 4 */
+      add_prompt(ua, _("Maximum Volume Bytes"));       /* 5 */
+      add_prompt(ua, _("Recycle Flag"));               /* 6 */
+      add_prompt(ua, _("Slot"));                       /* 7 */
+      add_prompt(ua, _("InChanger Flag"));             /* 8 */
+      add_prompt(ua, _("Volume Files"));               /* 9 */
+      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 */
       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) {
+      if (i != 12 && i != 13) {
          if (!select_media_dbr(ua, &mr)) {  /* Get Volume record */
             return 0;
          }
+         bsendmsg(ua, _("Updating Volume \"%s\"\n"), mr.VolumeName);
       }
       switch (i) {
       case 0:                         /* Volume Status */
index dbfcbd60bf46ed99e0ce3e669881a0b89dd809ae..b59411dfb4ca6f4b03e5d68178cc60952dc7b959 100644 (file)
@@ -6,7 +6,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -23,6 +23,8 @@
 
 #include "bacula.h"
 
+const bool compatible = true;
+
 #ifdef TEST_MODE
 #include <glob.h>
 #endif
@@ -141,7 +143,11 @@ bin_to_base64(char *buf, char *bin, int len)
    for (i=0; i<len; ) {
       if (rem < 6) {
          reg <<= 8;
-         reg |= (int8_t)bin[i++];
+         if (compatible) {
+            reg |= (int8_t)bin[i++] & 0xFF;
+         } else {
+           reg |= (int8_t)bin[i++];
+         }
          rem += 8;
       }
       save = reg;
@@ -155,7 +161,11 @@ bin_to_base64(char *buf, char *bin, int len)
       for (i=1; i<rem; i++) {
          mask = (mask << 1) | 1;
       }
-      buf[j++] = base64_digits[reg & mask];
+      if (compatible) {
+         buf[j++] = base64_digits[(reg & mask) << 6 - rem];
+      } else {
+         buf[j++] = base64_digits[reg & mask];
+      }
    }
    buf[j] = 0;
    return j;
index c0f898ec1c65131d3bc679c7d4e1cac2b1485f14..5026bc73aa307ea77003c581dbb5ca6344c480f7 100644 (file)
@@ -8,7 +8,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2000-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
index 0f52e9908b1920e75523e41e55e9b8990747b82d..0725dc5eaa8b37483d7213857f00eaaadd57e026 100644 (file)
@@ -252,6 +252,21 @@ void MD5Transform(uint32_t buf[4], uint32_t in[16])
 
 #ifdef MD5_SUM
 #define OUTPUT_BASE64 1
+
+static void usage()
+{
+   fprintf(stderr,
+"\n"
+"Usage: md5sum [-d decode] <data-file>\n"
+"       -d          decode the data file\n"
+"       -?          print this message.\n"
+"\n\n");
+
+   exit(1);
+}
+
+static bool decode = false;
+
 /*
  * Reads a single ASCII file and prints the HEX md5 sum.
  */
@@ -262,16 +277,35 @@ int main(int argc, char *argv[])
    MD5Context ctx;
    char buf[5000];
    char signature[20];
+   int ch;
+
+   while ((ch = getopt(argc, argv, "d?")) != -1) {
+      switch (ch) {
+      case 'd':
+         decode = true;                
+         break;
+      case '?':
+      default:
+         usage();
+      }
+   }
+
+   argc -= optind;
+   argv += optind;
 
    if (argc < 1) {
       printf("Must have filename\n");
       exit(1);
    }
-   fd = fopen(argv[1], "r");
+
+   fd = fopen(argv[0], "r");
    if (!fd) {
-      printf("Could not open %s: ERR=%s\n", argv[1], strerror(errno));
+      printf("Could not open %s: ERR=%s\n", argv[0], strerror(errno));
       exit(1);
    }
+   if (decode) {
+      goto decode_it;
+   }
    MD5Init(&ctx);
    while (fgets(buf, sizeof(buf), fd)) {
       MD5Update(&ctx, (unsigned char *)buf, strlen(buf));
@@ -286,6 +320,35 @@ int main(int argc, char *argv[])
    bin_to_base64(MD5buf, (char *)signature, 16); /* encode 16 bytes */
    printf("  %s", MD5buf);
 #endif
-   printf("  %s\n", argv[1]);
+   printf("  %s\n", argv[0]);
+   exit(0);
+
+decode_it:
+   while (fgets(buf, sizeof(buf), fd)) {
+      char bin[40];
+      unsigned char *p = (unsigned char *)buf;
+      unsigned char ch;
+      int val;
+      for (int i=0; i < 16; i++) {
+         if (*p <= '9') {
+            val = *p - '0';
+         } else {
+            val = *p - 'a' + 10;
+         }
+         ch = val << 4;
+         p++;
+         if (*p <= '9') {
+            val = *p - '0';
+         } else {
+            val = *p - 'a' + 10;
+         }
+         signature[i] = ch + val;
+         p++;
+      }
+      signature[16] = 0;
+      printf("%s", buf);
+      bin_to_base64(bin, (char *)signature, 16);
+      printf("%s\n", bin);
+   }
 }
 #endif
index b3097e87e599e7bba7df206158f615846487636d..d69c8365620a94a042f376020d4bdc03b0a601c7 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "1.39.9"
-#define BDATE   "20 April 2006"
-#define LSMDATE "20Apr06"
+#define BDATE   "21 April 2006"
+#define LSMDATE "21Apr06"
 
 /* Debug flags */
 #undef  DEBUG