]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix dird/ua_cmds.c so that a cancel command checks if the
authorKern Sibbald <kern@sibbald.com>
Thu, 8 Feb 2007 10:56:41 +0000 (10:56 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 8 Feb 2007 10:56:41 +0000 (10:56 +0000)
     console is authorized to cancel the job.  This fixes bug
     #767.
kes  Modify SD so that the VolCatJobs medium record is updated
     at the beginning of a Job rather than the end.  This
     fixes bug #775 where exceeding MaxVolJobs caused jobs
     to fail.
kes  Added a mutex around getting and setting Volume information
     so that multiple simultaneous jobs will single thread.
     Switch to using Subversion
kes  Remove src/pygtk-console/ from configure

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.0@4146 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/autoconf/configure.in
bacula/configure
bacula/src/dird/ua_cmds.c
bacula/src/stored/acquire.c
bacula/src/stored/askdir.c
bacula/src/stored/block.c
bacula/src/stored/device.c
bacula/technotes-2.0

index 8a0c153d9922f0c6165a059e8b681a51e229393f..4ba634568aa84ce6877a62a2e902be6bd0c5dc6b 100644 (file)
@@ -2049,7 +2049,6 @@ AC_OUTPUT([autoconf/Make.common \
           src/cats/drop_bacula_tables \
           src/cats/drop_bacula_database \
           src/findlib/Makefile \
-          src/pygtk-console/Makefile \
           src/tools/Makefile \
           po/Makefile.in \
           $PFILES ],  
index 5e768c366024b6865bb0e81008c777847f898b12..a3816265f53d8e400b051952e0c7f1c6586c56ea 100755 (executable)
@@ -33785,7 +33785,7 @@ if test "x${subsysdir}" = "x${sbindir}" ; then
    exit 1
 fi
 
-ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/dvd-simulator scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/pygtk-console/Makefile src/tools/Makefile po/Makefile.in $PFILES"
+ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/dvd-simulator scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile po/Makefile.in $PFILES"
 
 ac_config_commands="$ac_config_commands default"
 
@@ -34439,7 +34439,6 @@ do
     "src/cats/drop_bacula_tables") CONFIG_FILES="$CONFIG_FILES src/cats/drop_bacula_tables" ;;
     "src/cats/drop_bacula_database") CONFIG_FILES="$CONFIG_FILES src/cats/drop_bacula_database" ;;
     "src/findlib/Makefile") CONFIG_FILES="$CONFIG_FILES src/findlib/Makefile" ;;
-    "src/pygtk-console/Makefile") CONFIG_FILES="$CONFIG_FILES src/pygtk-console/Makefile" ;;
     "src/tools/Makefile") CONFIG_FILES="$CONFIG_FILES src/tools/Makefile" ;;
     "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;;
     "$PFILES") CONFIG_FILES="$CONFIG_FILES $PFILES" ;;
index d5bf15931e1cc9a139d7b5d3431a23a6ceb61990..268e5158b27f7d02544dcb77bcea7216d6dc6e92 100644 (file)
@@ -423,16 +423,25 @@ static int cancel_cmd(UAContext *ua, const char *cmd)
       }
 
    }
-   /* If we still do not have a jcr,
-    *   throw up a list and ask the user to select one.
-    */
-   if (!jcr) {
+   if (jcr) {
+      if (jcr->job && !acl_access_ok(ua, Job_ACL, jcr->job->name())) {
+         bsendmsg(ua, _("Unauthorized command from this console.\n"));
+         return 1;
+      }
+   } else {
+     /*
+      * If we still do not have a jcr,
+      *   throw up a list and ask the user to select one.
+      */
       char buf[1000];
       /* Count Jobs running */
       foreach_jcr(jcr) {
          if (jcr->JobId == 0) {      /* this is us */
             continue;
          }
+         if (!acl_access_ok(ua, Job_ACL, jcr->job->name())) {
+            continue;               /* skip not authorized */
+         }
          njobs++;
       }
       endeach_jcr(jcr);
index 9fa9f79c9589f70aacc3b34fa6f1ca124a9c35eb..69c8fa204974dcca0a62544272b6460269abbe2d 100644 (file)
@@ -8,7 +8,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -406,6 +406,8 @@ DCR *acquire_device_for_append(DCR *dcr)
    if (jcr->NumWriteVolumes == 0) {
       jcr->NumWriteVolumes = 1;
    }
+   dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
+   dir_update_volume_info(dcr, false);        /* send Volume info to Director */
    P(dev->mutex);
    if (dcr->reserved_device) {
       dev->reserved_device--;
@@ -486,7 +488,6 @@ bool release_device(DCR *dcr)
          }
          if (!dev->at_weot()) {
             dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
-            dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
             /* Note! do volume update before close, which zaps VolCatInfo */
             Dmsg0(100, "dir_update_vol_info. Release0\n");
             dir_update_volume_info(dcr, false); /* send Volume info to Director */
index a42863cabbeca313cb6ec80e367a77140939d77d..6525bfe7ded24a4533be291cb28309fdd7e8f2fa 100644 (file)
@@ -9,7 +9,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -62,6 +62,8 @@ static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%lu"
 
 static char OK_create[] = "1000 OK CreateJobMedia\n";
 
+static pthread_mutex_t vol_info_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 #ifdef needed
 
 static char Device_update[] = "DevUpd Job=%s device=%s "
@@ -155,6 +157,11 @@ bool dir_send_job_status(JCR *jcr)
  * and
  *   dir_find_next_appendable_volume()
  *
+ *  NOTE!!! All calls to this routine must be protected by
+ *          locking vol_info_mutex before calling it so that
+ *          we don't have one thread modifying the parameters
+ *          and another reading them.
+ *
  *  Returns: true  on success and vol info in dcr->VolCatInfo
  *           false on failure
  */
@@ -214,6 +221,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing)
     JCR *jcr = dcr->jcr;
     BSOCK *dir = jcr->dir_bsock;
 
+    P(vol_info_mutex);
     bstrncpy(dcr->VolCatInfo.VolCatName, dcr->VolumeName, sizeof(dcr->VolCatInfo.VolCatName));
     bash_spaces(dcr->VolCatInfo.VolCatName);
     bnet_fsend(dir, Get_Vol_Info, jcr->Job, dcr->VolCatInfo.VolCatName,
@@ -221,6 +229,7 @@ bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing)
     Dmsg1(100, ">dird: %s", dir->msg);
     unbash_spaces(dcr->VolCatInfo.VolCatName);
     bool ok = do_get_volume_info(dcr);
+    V(vol_info_mutex);
     return ok;
 }
 
@@ -247,6 +256,7 @@ bool dir_find_next_appendable_volume(DCR *dcr)
      *   drive, so we continue looking for a not in use Volume.
      */
     lock_reservations();
+    P(vol_info_mutex);
     for (int vol_index=1;  vol_index < 20; vol_index++) {
        bash_spaces(dcr->media_type);
        bash_spaces(dcr->pool_name);
@@ -273,10 +283,12 @@ bool dir_find_next_appendable_volume(DCR *dcr)
     if (found) {
        Dmsg0(400, "dir_find_next_appendable_volume return true\n");
        new_volume(dcr, dcr->VolumeName);   /* reserve volume */
+       V(vol_info_mutex);
        unlock_reservations();
        return true;
     }
     dcr->VolumeName[0] = 0;
+    V(vol_info_mutex);
     unlock_reservations();
     return false;
 }
@@ -296,6 +308,7 @@ bool dir_update_volume_info(DCR *dcr, bool label)
    VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
    char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50];
    int InChanger;
+   bool ok = false;
    POOL_MEM VolumeName;
 
    /* If system job, do not update catalog */
@@ -314,6 +327,8 @@ bool dir_update_volume_info(DCR *dcr, bool label)
       return false;
    }
 
+   /* Lock during Volume update */
+   P(vol_info_mutex);
    Dmsg1(100, "Update cat VolFiles=%d\n", dev->file);
    /* Just labeled or relabeled the tape */
    if (label) {
@@ -340,12 +355,16 @@ bool dir_update_volume_info(DCR *dcr, bool label)
       Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
       Dmsg2(100, _("Didn't get vol info vol=%s: ERR=%s"), 
          vol->VolCatName, jcr->errmsg);
-      return false;
+      goto bail_out;
    }
    Dmsg1(420, "get_volume_info(): %s", dir->msg);
    /* Update dev Volume info in case something changed (e.g. expired) */
    dev->VolCatInfo = dcr->VolCatInfo;
-   return true;
+   ok = true;
+
+bail_out:
+   V(vol_info_mutex);
+   return ok;
 }
 
 /*
index 8ebdaf7edff00a1cdec6593edb31949ce3aad031..2c3f08e56cc206d4a52887bb5688727c1fa8c904 100644 (file)
@@ -11,7 +11,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -729,7 +729,6 @@ static bool terminate_writing_volume(DCR *dcr)
    }
    bstrncpy(dev->VolCatInfo.VolCatStatus, "Full", sizeof(dev->VolCatInfo.VolCatStatus));
    dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
-   dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
    
    if (dev->is_dvd()) {
       if (!dvd_write_part(dcr)) {             /* write last part */
index 4884d3cc71ef644ca39dd02676e7f7ab73152f4d..b70902ef00abfe610d0c311832adac4f4d7be8fc 100644 (file)
@@ -122,6 +122,9 @@ bool fixup_device_block_write_error(DCR *dcr)
    }
    P(dev->mutex);                  /* lock again */
 
+   dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
+   dir_update_volume_info(dcr, false);        /* send Volume info to Director */
+
    Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
       dcr->VolumeName, dev->print_name(), bstrftime(dt, sizeof(dt), time(NULL)));
 
index 572a2827adfd99b8845fcbd86b4d00f6ba097d6b..afaca2d1c8d31e67b9bdb143274d36fe07f709ee 100644 (file)
@@ -1,6 +1,19 @@
               Technical notes on version 2.0
 
 General:
+08Feb07
+kes  Fix dird/ua_cmds.c so that a cancel command checks if the
+     console is authorized to cancel the job.  This fixes bug 
+     #767.
+kes  Modify SD so that the VolCatJobs medium record is updated
+     at the beginning of a Job rather than the end.  This
+     fixes bug #775 where exceeding MaxVolJobs caused jobs
+     to fail.
+kes  Added a mutex around getting and setting Volume information
+     so that multiple simultaneous jobs will single thread.
+07Feb07
+     Switch to using Subversion
+kes  Remove src/pygtk-console/ from configure
 06Feb07
 kes  Delete src/lib/btree.c from win32 build, then add rblist.c
      plus the entrypoints.