From: Michal Rakowski Date: Thu, 22 Jul 2021 15:21:46 +0000 (+0200) Subject: Fix #7600 About variable for PreviousJobId in mail messages X-Git-Tag: Release-11.3.2~428 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3d0449922bc0f7625ebf543b0f271e523800bd8;p=thirdparty%2Fbacula.git Fix #7600 About variable for PreviousJobId in mail messages --- diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index aa9e4f25c..be82c4ab1 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -2754,6 +2754,12 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param, char *b static char no[] = "no"; ASSERTD(buflen > 255, "buflen must be long enough to hold an ip address"); + if (!jcr) { + /* Guard in case when user wants to use some per-job variable in the daemon's messages */ + Dmsg1(400, "Got null jcr in the callback for param: %s!\n", param); + return NULL; + } + switch (param[0]) { case 'f': if (jcr->fileset) { @@ -2767,6 +2773,11 @@ extern "C" char *job_code_callback_director(JCR *jcr, const char* param, char *b return bstrncpy(buf, tmp.c_str(), buflen); } break; + case 'm': + if (jcr->previous_jr.JobId) { + return edit_uint64(jcr->previous_jr.JobId, buf); + } + break; case 'p': if (jcr->pool) { return jcr->pool->name(); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 66736f518..9312e3fb3 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -842,6 +842,7 @@ void decode_session_key(char *decode, char *session, char *key, int maxlen) * %j = Unique Job id * %l = job level * %n = Unadorned Job name + * %m = Previous JobId for job being copied/migrated * %o = Job Priority * %p = Pool name (Director) * %P = Process PID