]> git.ipfire.org Git - thirdparty/bacula.git/commit
Fix #9305 At restore time, show wrong Backup Client when modifying client
authorAlain Spineux <alain@baculasystems.com>
Tue, 5 Jul 2022 10:35:30 +0000 (12:35 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
commit0fdc0a106e32c8ca525bde50b98020e202fa706e
tree8f7187c2740b7a6f0bde2d1e062bcd142c7a817f
parentfb10bd775e339d26bdf626f07bb614098a31b176
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