From f8be1148343d33d71c9ceb83a35a7033a69ea41a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 10 Mar 2008 16:13:48 +0000 Subject: [PATCH] kes Implement FD version to allow easier protocol changes. 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 | 14 ++++--- bacula/src/dird/dird_conf.c | 1 + bacula/src/dird/dird_conf.h | 1 + bacula/src/dird/restore.c | 4 +- bacula/src/dird/ua_acl.c | 2 +- bacula/src/dird/ua_run.c | 68 +++++++++++++++++++++++++-------- bacula/src/filed/authenticate.c | 8 +++- bacula/src/jcr.h | 1 + bacula/technotes-2.3 | 4 ++ 9 files changed, 76 insertions(+), 27 deletions(-) diff --git a/bacula/src/dird/authenticate.c b/bacula/src/dird/authenticate.c index 61c9ccfe85..9e83cffbe1 100644 --- a/bacula/src/dird/authenticate.c +++ b/bacula/src/dird/authenticate.c @@ -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, "msg); + Dmsg1(110, "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()); diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index d428169ab5..03d5933979 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -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}, diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 2fad99e157..f525562e12 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -185,6 +185,7 @@ enum { FileSet_ACL, Catalog_ACL, Where_ACL, + PluginOptions_ACL, Num_ACL /* keep last */ }; diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 2a73362e51..1905458279 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -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"; diff --git a/bacula/src/dird/ua_acl.c b/bacula/src/dird/ua_acl.c index a8873123a2..eee496379c 100644 --- a/bacula/src/dird/ua_acl.c +++ b/bacula/src/dird/ua_acl.c @@ -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. diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 95787bcd42..e3b6e72bbb 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -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; } diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index 0f0e01081b..474577de98 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -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. @@ -39,7 +39,11 @@ 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; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 88fd2b5890..36494a89f8 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -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 */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 7b93ba75b8..3c4a0c7d43 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -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 -- 2.39.5