Skip to content

Commit

Permalink
Merge branch 'bareos-15.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Oct 23, 2015
2 parents eeca53f + 34bc648 commit c923d61
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
27 changes: 20 additions & 7 deletions src/dird/ua_restore.c
Expand Up @@ -232,12 +232,16 @@ bool restore_cmd(UAContext *ua, const char *cmd)
goto bail_out;
}

get_client_name(ua, &rx);
if (!get_client_name(ua, &rx)) {
goto bail_out;
}
if (!rx.ClientName) {
ua->error_msg(_("No Client resource found!\n"));
goto bail_out;
}
get_restore_client_name(ua, rx);
if (!get_restore_client_name(ua, rx)) {
goto bail_out;
}

escaped_bsr_name = escape_filename(jcr->RestoreBootstrap);

Expand Down Expand Up @@ -393,6 +397,7 @@ static bool get_client_name(UAContext *ua, RESTORE_CTX *rx)
{
int i;
CLIENT_DBR cr;
memset(&cr, 0, sizeof(cr));

/*
* If no client name specified yet, get it now
Expand All @@ -408,15 +413,18 @@ static bool get_client_name(UAContext *ua, RESTORE_CTX *rx)
if (i >= 0) {
if (!is_name_valid(ua->argv[i], ua->errmsg)) {
ua->error_msg("%s argument: %s", ua->argk[i], ua->errmsg);
return 0;
return false;
}
bstrncpy(cr.Name, ua->argv[i], sizeof(cr.Name));
if (!db_get_client_record(ua->jcr, ua->db, &cr)) {
ua->error_msg("invalid %s argument: %s\n", ua->argk[i], ua->argv[i]);
return false;
}

rx->ClientName = bstrdup(ua->argv[i]);
return true;
}
memset(&cr, 0, sizeof(cr));
if (!get_client_dbr(ua, &cr)) {
return 0;
return false;
}
rx->ClientName = bstrdup(cr.Name);
}
Expand All @@ -438,7 +446,12 @@ static bool get_restore_client_name(UAContext *ua, RESTORE_CTX &rx)
if (i >= 0) {
if (!is_name_valid(ua->argv[i], ua->errmsg)) {
ua->error_msg("%s argument: %s", ua->argk[i], ua->errmsg);
return 0;
return false;
}

if (!GetClientResWithName(ua->argv[i])) {
ua->error_msg("invalid %s argument: %s\n", ua->argk[i], ua->argv[i]);
return false;
}
rx.RestoreClientName = bstrdup(ua->argv[i]);
return true;
Expand Down
23 changes: 14 additions & 9 deletions src/dird/ua_run.c
Expand Up @@ -2107,11 +2107,14 @@ static bool scan_command_line_arguments(UAContext *ua, RUN_CTX &rc)
rc.client = rc.job->client; /* use default */
}

if (rc.client && !acl_access_ok(ua, Client_ACL, rc.client->name(), true)) {
ua->error_msg(_("No authorization. Client \"%s\".\n"), rc.client->name());
return false;
if (rc.client) {
if (!acl_access_ok(ua, Client_ACL, rc.client->name(), true)) {
ua->error_msg(_("No authorization. Client \"%s\".\n"), rc.client->name());
return false;
} else {
Dmsg1(800, "Using client=%s\n", rc.client->name());
}
}
Dmsg1(800, "Using client=%s\n", rc.client->name());

if (rc.restore_client_name) {
rc.client = GetClientResWithName(rc.restore_client_name);
Expand All @@ -2125,13 +2128,15 @@ static bool scan_command_line_arguments(UAContext *ua, RUN_CTX &rc)
rc.client = rc.job->client; /* use default */
}

if (rc.client && !acl_access_ok(ua, Client_ACL, rc.client->name(), true)) {
ua->error_msg(_("No authorization. Client \"%s\".\n"), rc.client->name());
return false;
if (rc.client) {
if (!acl_access_ok(ua, Client_ACL, rc.client->name(), true)) {
ua->error_msg(_("No authorization. Client \"%s\".\n"), rc.client->name());
return false;
} else {
Dmsg1(800, "Using restore client=%s\n", rc.client->name());
}
}

Dmsg1(800, "Using restore client=%s\n", rc.client->name());

if (rc.fileset_name) {
rc.fileset = GetFileSetResWithName(rc.fileset_name);
if (!rc.fileset) {
Expand Down

0 comments on commit c923d61

Please sign in to comment.