From 0fdc0a106e32c8ca525bde50b98020e202fa706e Mon Sep 17 00:00:00 2001 From: Alain Spineux Date: Tue, 5 Jul 2022 12:35:30 +0200 Subject: [PATCH] Fix #9305 At restore time, show wrong Backup Client when modifying client There is two values : Backup Client: this is related to the backup job, then this is immutable as the job already ran Restore Client: this is related to the restore, this can change In a "normal" restore, the values that are assigned are as follow : Backup Client: rc.client ? rc.client->hdr.name : jcr->job->client->hdr.name Restore Client: jcr->client->name() We can see the values that have changed before and after the "mod" ua_run.c:173-0 ASX rc.client=0x55af0c0d5aa8 jcr->job->client->hdr.name=1-fd rc.client->hdr.name=1-fd jcr->client->name()=1-fd ua_run.c:173-0 ASX rc.client=0x55af0c0d7eb8 jcr->job->client->hdr.name=1-fd rc.client->hdr.name=2-fd jcr->client->name()=2-fd The value jcr->job->client->hdr.name did not change has expected (it should be immutable) and should be used instead of the conditional for the "Backup Client" value When doing the mod, the code does case 4: /* Client */ { int32_t jt = rc.job ? rc.job->JobType : JT_SYSTEM; rc.client = select_client_resource(ua, jt); if (rc.client) { jcr->client = rc.client; goto try_again; } } Then both the rc.client and the jcr->client are modified I think the right solution is just to use jcr->job->client->hdr.name instead of the conditional rc.client ? rc.client->hdr.name : jcr->job->client->hdr.name --- bacula/src/dird/ua_run.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index d014d93e3..05467a3eb 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -173,7 +173,7 @@ int run_cmd(UAContext *ua, const char *cmd) * allow him to modify them. */ if (!display_job_parameters(ua, jcr, rc.job, rc.verify_list, rc.jid, rc.replace, - rc.client ? rc.client->hdr.name : jcr->job->client->hdr.name)) { + jcr->job->client->hdr.name)) { break; /* error get out of while loop */ } -- 2.47.3