Skip to content

Commit

Permalink
dird: Validate client and storage for native restore.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Sep 1, 2016
1 parent 5f25695 commit dcfec26
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/dird/restore.c
Expand Up @@ -385,6 +385,36 @@ static inline bool do_native_restore_bootstrap(JCR *jcr)
return false;
}

static inline bool validate_client(JCR *jcr)
{
switch (jcr->res.client->Protocol) {
case APT_NATIVE:
return true;
default:
Jmsg(jcr, M_FATAL, 0, _("Client %s has illegal backup protocol %s for Native restore\n"),
jcr->res.client->name(), auth_protocol_to_str(jcr->res.client->Protocol));
return false;
}
}

static inline bool validate_storage(JCR *jcr)
{
STORERES *store;

foreach_alist(store, jcr->res.rstorage) {
switch (store->Protocol) {
case APT_NATIVE:
continue;
default:
Jmsg(jcr, M_FATAL, 0, _("Storage %s has illegal backup protocol %s for Native restore\n"),
store->name(), auth_protocol_to_str(store->Protocol));
return false;
}
}

return true;
}

/**
* Do a restore initialization.
*
Expand All @@ -395,6 +425,13 @@ bool do_native_restore_init(JCR *jcr)
{
free_wstorage(jcr); /* we don't write */

/*
* Validate that we have a native client and storage(s).
*/
if (!validate_client(jcr) || !validate_storage(jcr)) {
return false;
}

return true;
}

Expand Down

0 comments on commit dcfec26

Please sign in to comment.