From 35d5bf1cecf5e01cb6668199a6e2ac839f89093e Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 18 Jul 2005 11:49:31 +0000 Subject: [PATCH 1/1] - Move Python variables from Job to Bacula. They are DirName, Version, ConfigFile, and WorkingDir - Fix delete of bootstrap to only occur on Bacula created filenames. - Allow cancelling a Job name that is not active. It is sent to the daemons. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2210 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/examples/python/DirStartUp.py | 2 +- bacula/kernstodo | 17 +++++------- bacula/kes-1.37 | 7 +++++ bacula/src/dird/fd_cmds.c | 5 +++- bacula/src/dird/job.c | 12 ++++----- bacula/src/dird/protos.h | 40 ++++++++++++++-------------- bacula/src/dird/pythondir.c | 38 +++++++++----------------- bacula/src/dird/ua_cmds.c | 8 +++--- bacula/src/filed/filed.c | 2 +- bacula/src/lib/pythonlib.c | 8 +++++- bacula/src/tools/bsmtp.c | 18 +++++-------- bacula/src/tools/dbcheck.c | 15 ++++------- bacula/src/tools/fstype.c | 18 +++++-------- bacula/src/tools/testfind.c | 18 +++++-------- bacula/src/version.h | 4 +-- 15 files changed, 95 insertions(+), 117 deletions(-) diff --git a/bacula/examples/python/DirStartUp.py b/bacula/examples/python/DirStartUp.py index e364f7b8ee..00cedc1b05 100644 --- a/bacula/examples/python/DirStartUp.py +++ b/bacula/examples/python/DirStartUp.py @@ -54,6 +54,7 @@ class JobEvents: if (job.JobId < 2): startid = job.run("run kernsave") job.JobReport = "Python started new Job: jobid=%d\n" % startid + print "name=%s version=%s conf=%s working=%s" % (bacula.Name, bacula.Version, bacula.ConfigFile, bacula.WorkingDir) def JobRun(self, job): noop = 1 @@ -82,7 +83,6 @@ class JobEvents: self.fd = open('m.py', 'rb') jobid = self.job.JobId print "Open: JobId=%d" % jobid - print "name=%s" % bacula.name # Read file data into Bacula memory buffer (mem) # return length read. 0 => EOF, -1 => error diff --git a/bacula/kernstodo b/bacula/kernstodo index 67fc9569b6..514adabb7f 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -1,22 +1,15 @@ Kern's ToDo List - 15 July 2005 + 18 July 2005 Major development: Project Developer ======= ========= -TLS Landon Fuller -Unicode in Win32 Thorsten Engel (done) -VSS Thorsten Engel (in beta testing) Version 1.37 Kern (see below) ======================================================== Final items for 1.37 before release: -1. Fix the remaining bugs that I am aware of and new ones that come up - during testing. +1. Fix bugs - --without-openssl breaks at least on Solaris. -- bsr-opt-test fails. bsr deleted. Fix. -- Allow cancel of unknown Job -- State not saved when closing Win32 FD by icon - Move Python daemon variables from Job to Bacula object. WorkingDir, ConfigFile @@ -24,7 +17,7 @@ Final items for 1.37 before release: 7. Write a bacula-web document 8. Take one more try at making DVD writing work. 9. Run the regression scripts on Solaris and FreeBSD -- Figure out how to package docs and gui programs. +- Figure out how to package gui, and rescue programs. - Test TLS. Document: @@ -1373,3 +1366,7 @@ Block Position: 0 - Port limiting -m in iptables to prevent DoS attacks could cause broken pipes on Bacula. 6. Build and test the Volume Shadow Copy (VSS) for Win32. +- Allow cancel of unknown Job +- State not saved when closing Win32 FD by icon +- bsr-opt-test fails. bsr deleted. Fix. + diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 05c83d6770..6e7ad8f133 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,13 @@ General: Changes to 1.37.31: +18Jul05 +- Move Python variables from Job to Bacula. They are + DirName, Version, ConfigFile, and WorkingDir +- Fix delete of bootstrap to only occur on Bacula created + filenames. +- Allow cancelling a Job name that is not active. It is + sent to the daemons. 17Jul05 - Fix name space pollution by OpenSSL 0.9.8 reported by Matthias Kurz -- applied his patch. diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 5e813666a9..c2f55318f7 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -449,7 +449,10 @@ bool send_bootstrap_file(JCR *jcr) } bnet_sig(fd, BNET_EOD); fclose(bs); - unlink(jcr->RestoreBootstrap); + if (jcr->unlink_bsr) { + unlink(jcr->RestoreBootstrap); + jcr->unlink_bsr = false; + } if (!response(jcr, fd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 659dd931db..03cbfac60c 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -356,10 +356,10 @@ bail_out: * Cancel a job -- typically called by the UA (Console program), but may also * be called by the job watchdog. * - * Returns: 1 if cancel appears to be successful - * 0 on failure. Message sent to ua->jcr. + * Returns: true if cancel appears to be successful + * false on failure. Message sent to ua->jcr. */ -int cancel_job(UAContext *ua, JCR *jcr) +bool cancel_job(UAContext *ua, JCR *jcr) { BSOCK *sd, *fd; @@ -376,7 +376,7 @@ int cancel_job(UAContext *ua, JCR *jcr) bsendmsg(ua, _("JobId %d, Job %s marked to be canceled.\n"), jcr->JobId, jcr->Job); jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */ - return 1; + return true; default: @@ -407,7 +407,7 @@ int cancel_job(UAContext *ua, JCR *jcr) } if (!connect_to_storage_daemon(ua->jcr, 10, SDConnectTimeout, 1)) { bsendmsg(ua, _("Failed to connect to Storage daemon.\n")); - return 0; + return false; } Dmsg0(200, "Connected to storage daemon\n"); sd = ua->jcr->store_bsock; @@ -421,7 +421,7 @@ int cancel_job(UAContext *ua, JCR *jcr) } } - return 1; + return true; } diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index bfe42e9b01..0d983686fa 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -68,7 +68,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp); /* fd_cmds.c */ extern int connect_to_file_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern bool send_include_list(JCR *jcr); extern bool send_exclude_list(JCR *jcr); extern bool send_bootstrap_file(JCR *jcr); @@ -76,7 +76,7 @@ extern bool send_level_command(JCR *jcr); extern int get_attributes_and_put_in_catalog(JCR *jcr); extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId); extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, - char *link, char *attr, int stream); + char *link, char *attr, int stream); extern void get_level_since_time(JCR *jcr, char *since, int since_len); extern int send_run_before_and_after_commands(JCR *jcr); @@ -94,7 +94,7 @@ extern void update_job_end_record(JCR *jcr); extern bool get_or_create_client_record(JCR *jcr); extern bool get_or_create_fileset_record(JCR *jcr, FILESET_DBR *fsr); extern JobId_t run_job(JCR *jcr); -extern int cancel_job(UAContext *ua, JCR *jcr); +extern bool cancel_job(UAContext *ua, JCR *jcr); extern void init_jcr_job_record(JCR *jcr); extern void copy_storage(JCR *new_jcr, JCR *old_jcr); extern void set_storage(JCR *jcr, STORE *store); @@ -110,7 +110,7 @@ extern void mount_request(JCR *jcr, BSOCK *bs, char *buf); /* msgchan.c */ extern bool connect_to_storage_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern int start_storage_daemon_job(JCR *jcr, alist *store, int append); extern int start_storage_daemon_message_thread(JCR *jcr); extern int bget_dirmsg(BSOCK *bs); @@ -172,28 +172,28 @@ JCR *new_control_jcr(const char *base_name, int job_type); void free_ua_context(UAContext *ua); /* ua_select.c */ -STORE *select_storage_resource(UAContext *ua); -JOB *select_job_resource(UAContext *ua); -JOB *select_restore_job_resource(UAContext *ua); -CLIENT *select_client_resource(UAContext *ua); +STORE *select_storage_resource(UAContext *ua); +JOB *select_job_resource(UAContext *ua); +JOB *select_restore_job_resource(UAContext *ua); +CLIENT *select_client_resource(UAContext *ua); FILESET *select_fileset_resource(UAContext *ua); -int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); -int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); -bool select_pool_dbr(UAContext *ua, POOL_DBR *pr); -int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); - -void start_prompt(UAContext *ua, const char *msg); -void add_prompt(UAContext *ua, const char *prompt); -int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt); +int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); +int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); +bool select_pool_dbr(UAContext *ua, POOL_DBR *pr); +int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); + +void start_prompt(UAContext *ua, const char *msg); +void add_prompt(UAContext *ua, const char *prompt); +int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt); CAT *get_catalog_resource(UAContext *ua); STORE *get_storage_resource(UAContext *ua, int use_default); -int get_media_type(UAContext *ua, char *MediaType, int max_media); -bool get_pool_dbr(UAContext *ua, POOL_DBR *pr); -int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); +int get_media_type(UAContext *ua, char *MediaType, int max_media); +bool get_pool_dbr(UAContext *ua, POOL_DBR *pr); +int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); POOL *get_pool_resource(UAContext *ua); POOL *select_pool_resource(UAContext *ua); CLIENT *get_client_resource(UAContext *ua); -int get_job_dbr(UAContext *ua, JOB_DBR *jr); +int get_job_dbr(UAContext *ua, JOB_DBR *jr); int find_arg_keyword(UAContext *ua, const char **list); int find_arg(UAContext *ua, const char *keyword); diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index 25dcac8bd6..64388426b8 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -59,7 +59,6 @@ struct s_vars { /* Read-only variables */ static struct s_vars getvars[] = { { N_("Job"), "s"}, - { N_("DirName"), "s"}, { N_("Level"), "s"}, { N_("Type"), "s"}, { N_("JobId"), "i"}, @@ -72,9 +71,6 @@ static struct s_vars getvars[] = { { N_("JobName"), "s"}, { N_("JobStatus"), "s"}, { N_("Priority"), "i"}, - { N_("Version"), "(ss)"}, - { N_("ConfigFile"), "s"}, - { N_("WorkingDir"), "s"}, { N_("CatalogRes"), "(sssssis)"}, { NULL, NULL} @@ -121,17 +117,15 @@ PyObject *job_getattr(PyObject *self, char *attrname) switch (i) { case 0: /* Job */ return Py_BuildValue(getvars[i].fmt, jcr->job->hdr.name); - case 1: /* Director's name */ - return Py_BuildValue(getvars[i].fmt, my_name); - case 2: /* level */ + case 1: /* level */ return Py_BuildValue(getvars[i].fmt, job_level_to_str(jcr->JobLevel)); - case 3: /* type */ + case 2: /* type */ return Py_BuildValue(getvars[i].fmt, job_type_to_str(jcr->JobType)); - case 4: /* JobId */ + case 3: /* JobId */ return Py_BuildValue(getvars[i].fmt, jcr->JobId); - case 5: /* Client */ + case 4: /* Client */ return Py_BuildValue(getvars[i].fmt, jcr->client->hdr.name); - case 6: /* NumVols */ + case 5: /* NumVols */ POOL_DBR pr; memset(&pr, 0, sizeof(pr)); bstrncpy(pr.Name, jcr->pool->hdr.name, sizeof(pr.Name)); @@ -142,29 +136,23 @@ PyObject *job_getattr(PyObject *self, char *attrname) bsnprintf(errmsg, sizeof(errmsg), "Pool record not found."); goto bail_out; } - case 7: /* Pool */ + case 6: /* Pool */ return Py_BuildValue(getvars[i].fmt, jcr->pool->hdr.name); - case 8: /* Storage */ + case 7: /* Storage */ return Py_BuildValue(getvars[i].fmt, jcr->store->hdr.name); - case 9: + case 8: return Py_BuildValue(getvars[i].fmt, jcr->catalog->hdr.name); - case 10: /* MediaType */ + case 9: /* MediaType */ return Py_BuildValue(getvars[i].fmt, jcr->store->media_type); - case 11: /* JobName */ + case 10: /* JobName */ return Py_BuildValue(getvars[i].fmt, jcr->Job); - case 12: /* JobStatus */ + case 11: /* JobStatus */ buf[1] = 0; buf[0] = jcr->JobStatus; return Py_BuildValue(getvars[i].fmt, buf); - case 13: /* Priority */ + case 12: /* Priority */ return Py_BuildValue(getvars[i].fmt, jcr->JobPriority); - case 14: /* Version */ - return Py_BuildValue(getvars[i].fmt, VERSION, BDATE); - case 15: /* Config Dir */ - return Py_BuildValue(getvars[i].fmt, configfile); - case 16: /* Working Dir */ - return Py_BuildValue(getvars[i].fmt, director->working_directory); - case 17: /* CatalogRes */ + case 13: /* CatalogRes */ return Py_BuildValue(getvars[i].fmt, jcr->catalog->db_name, jcr->catalog->db_address, jcr->catalog->db_user, jcr->catalog->db_password, diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 00002fc96d..ba2208487c 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -372,7 +372,7 @@ static int cancel_cmd(UAContext *ua, const char *cmd) } JobId = str_to_int64(ua->argv[i]); if (!(jcr=get_jcr_by_id(JobId))) { - bsendmsg(ua, _("JobId %s is not running.\n"), ua->argv[i]); + bsendmsg(ua, _("JobId %s is not running. Use Job name to cancel inactive jobs.\n"), ua->argv[i]); return 1; } break; @@ -381,8 +381,9 @@ static int cancel_cmd(UAContext *ua, const char *cmd) break; } if (!(jcr=get_jcr_by_partial_name(ua->argv[i]))) { - bsendmsg(ua, _("Job %s is not running.\n"), ua->argv[i]); - return 1; + bsendmsg(ua, _("Warning Job %s is not running. Continuing anyway ...\n"), ua->argv[i]); + jcr = new_jcr(sizeof(JCR), dird_free_jcr); + bstrncpy(jcr->Job, ua->argv[i], sizeof(jcr->Job)); } break; } @@ -437,7 +438,6 @@ static int cancel_cmd(UAContext *ua, const char *cmd) ret = cancel_job(ua, jcr); free_jcr(jcr); - return ret; } diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index f0b21b02a9..8fdbea3044 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -49,7 +49,7 @@ const int win32_client = 0; #define CONFIG_FILE "./bacula-fd.conf" /* default config file */ -static char *configfile = NULL; +char *configfile = NULL; static bool foreground = false; static bool inetd_request = false; static workq_t dir_workq; /* queue of work from Director */ diff --git a/bacula/src/lib/pythonlib.c b/bacula/src/lib/pythonlib.c index 957e0e4bce..884727193d 100644 --- a/bacula/src/lib/pythonlib.c +++ b/bacula/src/lib/pythonlib.c @@ -30,6 +30,8 @@ #undef _POSIX_C_SOURCE #include +extern char *configfile; + /* Imported subroutines */ //extern PyMethodDef JobMethods[]; extern PyObject *job_getattr(PyObject *self, char *attrname); @@ -55,6 +57,7 @@ static PyMethodDef BaculaMethods[] = { {NULL, NULL, 0, NULL} /* last item */ }; +static char my_version[] = VERSION " " BDATE; /* * This is a Bacula Job type as defined in Python. We store a pointer @@ -97,7 +100,10 @@ void init_python_interpreter(const char *progname, const char *scripts, Py_Initialize(); PyEval_InitThreads(); bacula_module = Py_InitModule("bacula", BaculaMethods); - PyModule_AddStringConstant(bacula_module, "name", my_name); + PyModule_AddStringConstant(bacula_module, "Name", my_name); + PyModule_AddStringConstant(bacula_module, "Version", my_version); + PyModule_AddStringConstant(bacula_module, "ConfigFile", configfile); + PyModule_AddStringConstant(bacula_module, "WorkingDir", (char *)working_directory); if (!bacula_module) { Jmsg0(NULL, M_ERROR_TERM, 0, "Could not initialize Python\n"); } diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index 3fddb610cb..bc83bd4f59 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -1,23 +1,17 @@ /* - Copyright (C) 2000-2004 Kern Sibbald and John Walker + Copyright (C) 2001-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ - /* Derived from a SMTPclient: diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 70cb29f3d7..94e03848e9 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -12,19 +12,14 @@ Copyright (C) 2002-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/tools/fstype.c b/bacula/src/tools/fstype.c index c164292453..38795b2f4f 100644 --- a/bacula/src/tools/fstype.c +++ b/bacula/src/tools/fstype.c @@ -6,24 +6,18 @@ * Version $Id$ * */ - /* - Copyright (C) 2004 Kern Sibbald + Copyright (C) 2004-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/tools/testfind.c b/bacula/src/tools/testfind.c index 18cc25dd71..0b676f02f2 100644 --- a/bacula/src/tools/testfind.c +++ b/bacula/src/tools/testfind.c @@ -1,24 +1,18 @@ /* * Test program for find files */ - /* - Copyright (C) 2000-2003 Kern Sibbald and John Walker + Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ diff --git a/bacula/src/version.h b/bacula/src/version.h index cb7cc7e033..2180d613fa 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.31" -#define BDATE "17 July 2005" -#define LSMDATE "17Jul05" +#define BDATE "18 July 2005" +#define LSMDATE "18Jul05" /* Debug flags */ #undef DEBUG -- 2.39.5