src/dird/ua_cmds.c
bool open_client_db(UAContext *ua)
{
   int i;
   CAT *catalog;
   CLIENT *client;
   JOB *job;

   /* Try for catalog keyword */
   i = find_arg_with_value(ua, NT_("catalog"));
   if (i >= 0) {
      if (!acl_access_ok(ua, Catalog_ACL, ua->argv[i])) {
         ua->error_msg(_("No authorization for Catalog \"%s\"\n"), ua->argv[i]);
         return false;
      }
      catalog = GetCatalogResWithName(ua->argv[i]);
      if (catalog) {
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }

   /* Try for client keyword */
   i = find_arg_with_value(ua, NT_("client"));
   if (i >= 0) {
      if (!acl_access_client_ok(ua, ua->argv[i], JT_BACKUP_RESTORE)) {
         ua->error_msg(_("No authorization for Client \"%s\"\n"), ua->argv[i]);
         return false;
      }
      client = GetClientResWithName(ua->argv[i]);
      if (client) {
         catalog = client->catalog;
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) {
            ua->error_msg(_("No authorization for Catalog \"%s\"\n"), catalog->name());
            return false;
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }

   /* Try for Job keyword */
   i = find_arg_with_value(ua, NT_("job"));
   if (i >= 0) {
      if (!acl_access_ok(ua, Job_ACL, ua->argv[i])) {
         ua->error_msg(_("No authorization for Job \"%s\"\n"), ua->argv[i]);
         return false;
      }
      job = GetJobResWithName(ua->argv[i]);
      if (job) {
         catalog = job->client->catalog;
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) {
            ua->error_msg(_("No authorization for Catalog \"%s\"\n"), catalog->name());
            return false;
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }

   return open_db(ua);
}
/*
 * This call explicitly checks for a catalog=xxx and
 *  if given, opens that catalog.  It also checks for
 *  client=xxx and if found, opens the catalog
 *  corresponding to that client. If we still don't
 *  have a catalog, look for a Job keyword and get the
 *  catalog from its client record.
 */
This call explicitly checks for a catalog=xxx and
if given, opens that catalog.  It also checks for
client=xxx and if found, opens the catalog
corresponding to that client. If we still don't
have a catalog, look for a Job keyword and get the
catalog from its client record.
This call explicitly checks for a catalog = xxx and if given opens that catalog . It also checks for client = xxx and if found opens the catalog corresponding to that client . If we still don ' t have a catalog look for a Job keyword and get the catalog from its client record .
bool open_client_db(UAContext *ua)
{
   int i;
   CAT *catalog;
   CLIENT *client;
   JOB *job;
   i = find_arg_with_value(ua, NT_("catalog"));
   if (i >= 0) {
      if (!acl_access_ok(ua, Catalog_ACL, ua->argv[i])) {
         ua->error_msg(_("No authorization for Catalog \"%s\"\n"), ua->argv[i]);
         return false;
      }
      catalog = GetCatalogResWithName(ua->argv[i]);
      if (catalog) {
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }
   i = find_arg_with_value(ua, NT_("client"));
   if (i >= 0) {
      if (!acl_access_client_ok(ua, ua->argv[i], JT_BACKUP_RESTORE)) {
         ua->error_msg(_("No authorization for Client \"%s\"\n"), ua->argv[i]);
         return false;
      }
      client = GetClientResWithName(ua->argv[i]);
      if (client) {
         catalog = client->catalog;
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) {
            ua->error_msg(_("No authorization for Catalog \"%s\"\n"), catalog->name());
            return false;
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }
   i = find_arg_with_value(ua, NT_("job"));
   if (i >= 0) {
      if (!acl_access_ok(ua, Job_ACL, ua->argv[i])) {
         ua->error_msg(_("No authorization for Job \"%s\"\n"), ua->argv[i]);
         return false;
      }
      job = GetJobResWithName(ua->argv[i]);
      if (job) {
         catalog = job->client->catalog;
         if (ua->catalog && ua->catalog != catalog) {
            close_db(ua);
         }
         if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) {
            ua->error_msg(_("No authorization for Catalog \"%s\"\n"), catalog->name());
            return false;
         }
         ua->catalog = catalog;
         return open_db(ua);
      }
   }
   return open_db(ua);
}
bool open_client_db ( UAContext * ua ) { int i ; CAT * catalog ; CLIENT * client ; JOB * job ; i = find_arg_with_value ( ua , NT_ ( " " ) ) ; if ( i >= 0 ) { if ( ! acl_access_ok ( ua , Catalog_ACL , ua -> argv [ i ] ) ) { ua -> error_msg ( _ ( " \" \" \n " ) , ua -> argv [ i ] ) ; return false ; } catalog = GetCatalogResWithName ( ua -> argv [ i ] ) ; if ( catalog ) { if ( ua -> catalog && ua -> catalog != catalog ) { close_db ( ua ) ; } ua -> catalog = catalog ; return open_db ( ua ) ; } } i = find_arg_with_value ( ua , NT_ ( " " ) ) ; if ( i >= 0 ) { if ( ! acl_access_client_ok ( ua , ua -> argv [ i ] , JT_BACKUP_RESTORE ) ) { ua -> error_msg ( _ ( " \" \" \n " ) , ua -> argv [ i ] ) ; return false ; } client = GetClientResWithName ( ua -> argv [ i ] ) ; if ( client ) { catalog = client -> catalog ; if ( ua -> catalog && ua -> catalog != catalog ) { close_db ( ua ) ; } if ( ! acl_access_ok ( ua , Catalog_ACL , catalog -> name ( ) ) ) { ua -> error_msg ( _ ( " \" \" \n " ) , catalog -> name ( ) ) ; return false ; } ua -> catalog = catalog ; return open_db ( ua ) ; } } i = find_arg_with_value ( ua , NT_ ( " " ) ) ; if ( i >= 0 ) { if ( ! acl_access_ok ( ua , Job_ACL , ua -> argv [ i ] ) ) { ua -> error_msg ( _ ( " \" \" \n " ) , ua -> argv [ i ] ) ; return false ; } job = GetJobResWithName ( ua -> argv [ i ] ) ; if ( job ) { catalog = job -> client -> catalog ; if ( ua -> catalog && ua -> catalog != catalog ) { close_db ( ua ) ; } if ( ! acl_access_ok ( ua , Catalog_ACL , catalog -> name ( ) ) ) { ua -> error_msg ( _ ( " \" \" \n " ) , catalog -> name ( ) ) ; return false ; } ua -> catalog = catalog ; return open_db ( ua ) ; } } return open_db ( ua ) ; }
This call explicitly checks for a catalog=xxx and
  if given, opens that catalog.
This call explicitly checks for a catalog = xxx and if given opens that catalog .
/* Try for catalog keyword */ /* Try for client keyword */ /* Try for Job keyword */