]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Implement FD version to allow easier protocol changes.
authorKern Sibbald <kern@sibbald.com>
Mon, 10 Mar 2008 16:13:48 +0000 (16:13 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 10 Mar 2008 16:13:48 +0000 (16:13 +0000)
kes  Add Plugin Options string -- not yet passed to FD.
kes  Implement PluginOptions ACL.

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

bacula/src/dird/authenticate.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/restore.c
bacula/src/dird/ua_acl.c
bacula/src/dird/ua_run.c
bacula/src/filed/authenticate.c
bacula/src/jcr.h
bacula/technotes-2.3

index 61c9ccfe854b8ade8c5f3c6c272359975e861394..9e83cffbe1b27373015785b9ab2c5a7d1e65ea31 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2001-2008 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.
@@ -50,8 +50,9 @@ extern DIRRES *director;
 static char hello[]    = "Hello Director %s calling\n";
 
 /* Response from Storage daemon */
-static char OKhello[]   = "3000 OK Hello\n";
-static char FDOKhello[] = "2000 OK Hello\n";
+static char OKhello[]      = "3000 OK Hello\n";
+static char FDOKhello[]    = "2000 OK Hello\n";
+static char FDOKnewHello[] = "2000 OK Hello %d\n";
 
 /* Sent to User Agent */
 static char Dir_sorry[]  = "1999 You are not authorized.\n";
@@ -249,7 +250,6 @@ int authenticate_file_daemon(JCR *jcr)
    if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {
       /* Engage TLS! Full Speed Ahead! */
       if (!bnet_tls_client(client->tls_ctx, fd, client->tls_allowed_cns)) {
-
          stop_bsock_timer(tid);
          Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed with FD at \"%s:%d\".\n"),
               fd->host(), fd->port());
@@ -269,9 +269,11 @@ int authenticate_file_daemon(JCR *jcr)
          fd->host(), fd->port(), fd->bstrerror());
       return 0;
    }
-   Dmsg1(110, "<stored: %s", fd->msg);
+   Dmsg1(110, "<filed: %s", fd->msg);
    stop_bsock_timer(tid);
-   if (strncmp(fd->msg, FDOKhello, sizeof(FDOKhello)) != 0) {
+   jcr->FDVersion = 0;
+   if (strncmp(fd->msg, FDOKhello, sizeof(FDOKhello)) != 0 &&
+       sscanf(fd->msg, FDOKnewHello, &jcr->FDVersion) != 1) {
       Dmsg0(dbglvl, _("File daemon rejected Hello command\n"));
       Jmsg(jcr, M_FATAL, 0, _("File daemon at \"%s:%d\" rejected Hello command\n"),
            fd->host(), fd->port());
index d428169ab5af4a3a4997683949bdf44a5e0db273..03d59339791887463b23a97aaea5eeeb640ef620 100644 (file)
@@ -155,6 +155,7 @@ static RES_ITEM con_items[] = {
    {"filesetacl",  store_acl,      ITEM(res_con.ACL_lists), FileSet_ACL, 0, 0},
    {"catalogacl",  store_acl,      ITEM(res_con.ACL_lists), Catalog_ACL, 0, 0},
    {"whereacl",    store_acl,      ITEM(res_con.ACL_lists), Where_ACL, 0, 0},
+   {"pluginoptionsacl",     store_acl,       ITEM(res_con.ACL_lists), PluginOptions_ACL, 0, 0},
    {"tlsauthenticate",      store_bool,      ITEM(res_con.tls_authenticate), 0, 0, 0},
    {"tlsenable",            store_bool,      ITEM(res_con.tls_enable), 0, 0, 0},
    {"tlsrequire",           store_bool,      ITEM(res_con.tls_require), 0, 0, 0},
index 2fad99e1572dfe8597030c89731fff70b0b2004e..f525562e1254d41cb5c705a4290b4745d314727e 100644 (file)
@@ -185,6 +185,7 @@ enum {
    FileSet_ACL,
    Catalog_ACL,
    Where_ACL,
+   PluginOptions_ACL,
    Num_ACL                            /* keep last */
 };
 
index 2a73362e51c65e9a0185c9aae149e777f23fca72..19054582793447c43339df29822c1f8d1f1628a3 100644 (file)
@@ -50,9 +50,9 @@
 #include "dird.h"
 
 /* Commands sent to File daemon */
-static char restorecmd[]        = "restore replace=%c prelinks=%d where=%s\n";
+static char restorecmd[]  = "restore replace=%c prelinks=%d where=%s\n";
 static char restorecmdR[] = "restore replace=%c prelinks=%d regexwhere=%s\n";
-static char storaddr[]   = "storage address=%s port=%d ssl=0\n";
+static char storaddr[]    = "storage address=%s port=%d ssl=0\n";
 
 /* Responses received from File daemon */
 static char OKrestore[]   = "2000 OK restore\n";
index a8873123a2cd213e32f1fc178005a0a62770e6f8..eee496379c0c9f220e8554fde2add3b07eec40a2 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2004-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2004-2008 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.
index 95787bcd422018709c4eac6d07ef52065fb4ba03..e3b6e72bbb01a1b30f21873b0837f4776ac8ec67 100644 (file)
@@ -229,6 +229,9 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc)
          add_prompt(ua, _("Replace"));       /* 10 */
          add_prompt(ua, _("JobId"));         /* 11 */
       }
+      if (jcr->JobType == JT_BACKUP || jcr->JobType == JT_RESTORE) {
+         add_prompt(ua, _("Plugin Options")); /* 12 */
+      }
       switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) {
       case 0:
          /* Level */
@@ -294,7 +297,7 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc)
             jcr->JobPriority = ua->pint32_val;
          }
          goto try_again;
-      case 7:
+      case 7: 
          /* Pool or Bootstrap depending on JobType */
          if (jcr->JobType == JT_BACKUP ||
              jcr->JobType == JT_COPY ||
@@ -381,6 +384,17 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc)
             ua->send_msg(_("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
          }
          goto try_again;
+      case 12:        
+         /* Plugin Options */
+         if (!get_cmd(ua, _("Please Plugin Options string: "))) {
+            break;
+         }
+         if (jcr->plugin_options) {
+            free(jcr->plugin_options);
+            jcr->plugin_options = NULL;
+         }
+         jcr->plugin_options = bstrdup(ua->cmd);
+         goto try_again;
       case -1:                        /* error or cancel */
          goto bail_out;
       default:
@@ -429,7 +443,6 @@ static bool reset_restore_context(UAContext *ua, JCR *jcr, run_ctx &rc)
       rc.where = NULL;
    }
 
-
    if (rc.regexwhere) {
       if (jcr->RegexWhere) {
          free(jcr->RegexWhere);
@@ -758,7 +771,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                         "Pool:     %s (From %s)\n"
                         "Storage:  %s (From %s)\n"
                         "When:     %s\n"
-                        "Priority: %d\n"),
+                        "Priority: %d\n"
+                        "%s%s%s"),
                  _("Backup"),
                  job->name(),
                  level_to_str(jcr->JobLevel),
@@ -767,7 +781,10 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  NPRT(jcr->pool->name()), jcr->pool_source,
                  jcr->wstore?jcr->wstore->name():"*None*", jcr->wstore_source,
                  bstrutime(dt, sizeof(dt), jcr->sched_time),
-                 jcr->JobPriority);
+                 jcr->JobPriority,
+                 jcr->plugin_options?"Plugin Options: ":"",
+                 jcr->plugin_options?jcr->plugin_options:"",
+                 jcr->plugin_options?"\n":"");
       } else {  /* JT_VERIFY */
          const char *Name;
          if (jcr->verify_job) {
@@ -834,7 +851,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                         "Storage:         %s\n"
                         "When:            %s\n"
                         "Catalog:         %s\n"
-                        "Priority:        %d\n"),
+                        "Priority:        %d\n"
+                        "Plugin Options:  %s\n"),
                  job->name(),
                  NPRT(jcr->RestoreBootstrap), 
                  jcr->RegexWhere?jcr->RegexWhere:job->RegexWhere,
@@ -845,7 +863,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->rstore->name(),
                  bstrutime(dt, sizeof(dt), jcr->sched_time),
                  jcr->catalog->name(),
-                 jcr->JobPriority);
+                 jcr->JobPriority,
+                 NPRT(jcr->plugin_options));
 
          } else {
             ua->send_msg(_("Run Restore job\n"
@@ -859,7 +878,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                         "Storage:         %s\n"
                         "When:            %s\n"
                         "Catalog:         %s\n"
-                        "Priority:        %d\n"),
+                        "Priority:        %d\n"
+                        "Plugin Options:  %s\n"),
                  job->name(),
                  NPRT(jcr->RestoreBootstrap), 
                  jcr->where?jcr->where:NPRT(job->RestoreWhere), 
@@ -870,7 +890,8 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                  jcr->rstore->name(),
                  bstrutime(dt, sizeof(dt), jcr->sched_time),
                  jcr->catalog->name(),
-                 jcr->JobPriority);
+                 jcr->JobPriority,
+                 NPRT(jcr->plugin_options));
          }
 
       } else {
@@ -890,20 +911,22 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char
                          jcr->where?jcr->where:NPRT(job->RestoreWhere));
          }
 
-         ua->send_msg(_("Replace:    %s\n"
-                        "Client:     %s\n"
-                        "Storage:    %s\n"
-                        "JobId:      %s\n"
-                        "When:       %s\n"
-                        "Catalog:    %s\n"
-                        "Priority:   %d\n"),
+         ua->send_msg(_("Replace:         %s\n"
+                        "Client:          %s\n"
+                        "Storage:         %s\n"
+                        "JobId:           %s\n"
+                        "When:            %s\n"
+                        "Catalog:         %s\n"
+                        "Priority:        %d\n"
+                        "Plugin Options:  %s\n"),
               replace,
               jcr->client->name(),
               jcr->rstore->name(),
               jcr->RestoreJobId==0?"*None*":edit_uint64(jcr->RestoreJobId, ec1),
               bstrutime(dt, sizeof(dt), jcr->sched_time),
               jcr->catalog->name(),
-              jcr->JobPriority);
+              jcr->JobPriority,
+              NPRT(jcr->plugin_options));
       }
       break;
    case JT_COPY:
@@ -979,6 +1002,7 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
       "pool",                         /* 22 */
       "backupclient",                 /* 23 */
       "restoreclient",                /* 24 */
+      "pluginoptions",                /* 25 */
       NULL};
 
 #define YES_POS 14
@@ -1184,6 +1208,18 @@ static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc)
                rc.restore_client_name = ua->argv[i];
                kw_ok = true;
                break;
+            case 25: /* pluginoptions */
+               if (rc.plugin_options) {
+                  ua->send_msg(_("Plugin Options specified twice.\n"));
+                  return false;
+               }
+               rc.plugin_options = ua->argv[i];
+               if (!acl_access_ok(ua, PluginOptions_ACL, rc.plugin_options)) {
+                  ua->send_msg(_("No authoriztion for \"PluginOptions\" specification.\n"));
+                  return false;
+               }
+               kw_ok = true;
+               break;
             default:
                break;
             }
index 0f0e01081b750ea3ec1851ecb79c19c267896b26..474577de982dfd6192de386e07effac0c9c262d4 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 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.
 
 const int dbglvl = 50;
 
-static char OK_hello[]  = "2000 OK Hello\n";
+/* Version at end of Hello
+ *   prior to 10Mar08 no version
+ *   1 10Mar08
+ */
+static char OK_hello[]  = "2000 OK Hello 1\n";
 static char Dir_sorry[] = "2999 No go\n";
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
index 88fd2b5890395dae832ef3de706c6a9dc672523d..36494a89f81edbcdefc59232f648e28e4193e50d 100644 (file)
@@ -277,6 +277,7 @@ public:
    int replace;                       /* Replace option */
    int NumVols;                       /* Number of Volume used in pool */
    int reschedule_count;              /* Number of times rescheduled */
+   int FDVersion;                     /* File daemon version number */
    int64_t spool_size;                /* Spool size for this job */
    bool spool_data;                   /* Spool data in SD */
    bool acquired_resource_locks;      /* set if resource locks acquired */
index 7b93ba75b81d7bd0573392718fd85de3b64d0dd8..3c4a0c7d4322b269f9d9cb3ae3c9655fdfc44ffa 100644 (file)
@@ -1,6 +1,10 @@
               Technical notes on version 2.3
 
 General:
+10Mar08
+kes  Implement FD version to allow easier protocol changes.
+kes  Add Plugin Options string -- not yet passed to FD.
+kes  Implement PluginOptions ACL.
 09Mar08
 kes  Attempt to correct problems with restores with autochangers and
      use counts going negative