src/dird/ua_output.c
bool acl_access_jobid_ok(UAContext *ua, const char *jobids)
{
   char     *tmp=NULL, *p;
   bool      ret=false;
   JOB_DBR   jr;
   uint32_t  jid;

   if (!jobids) {
      return false;
   }

   if (!is_a_number_list(jobids)) {
      return false;
   }

   /* If no console resource => default console and all is permitted */
   if (!ua || !ua->cons) {
      Dmsg0(1400, "Root cons access OK.\n");
      return true;     /* No cons resource -> root console OK for everything */
   }

   alist *list = ua->cons->ACL_lists[Job_ACL];
   if (!list) {                       /* empty list */
      return false;                   /* List empty, reject everything */
   }

   /* Special case *all* gives full access */
   if (list->size() == 1 && strcasecmp("*all*", (char *)list->get(0)) == 0) {
      return true;
   }

   /* If we can't open the database, just say no */
   if (!open_new_client_db(ua)) {
      return false;
   }

   p = tmp = bstrdup(jobids);

   while (get_next_jobid_from_list(&p, &jid) > 0) {
      memset(&jr, 0, sizeof(jr));
      jr.JobId = jid;

      if (db_get_job_record(ua->jcr, ua->db, &jr)) {
         for (int i=0; i<list->size(); i++) {
            if (strcasecmp(jr.Name, (char *)list->get(i)) == 0) {
               Dmsg3(1400, "ACL found %s in %d %s\n", jr.Name,
                     Job_ACL, (char *)list->get(i));
               ret = true;
               goto bail_out;
            }
         }
      }
   }

bail_out:
   if (tmp) {
      free(tmp);
   }
   return ret;
}
/*
 * Check if the access is permitted for a list of jobids
 *
 * Not in ua_acl.c because it's using db access, and tools such
 * as bdirjson are not linked with cats.
 */
Check if the access is permitted for a list of jobids
Not in ua_acl.c because it's using db access, and tools such
as bdirjson are not linked with cats.
Check if the access is permitted for a list of jobids Not in ua_acl . c because it ' s using db access and tools such as bdirjson are not linked with cats .
bool acl_access_jobid_ok(UAContext *ua, const char *jobids)
{
   char     *tmp=NULL, *p;
   bool      ret=false;
   JOB_DBR   jr;
   uint32_t  jid;
   if (!jobids) {
      return false;
   }
   if (!is_a_number_list(jobids)) {
      return false;
   }
   if (!ua || !ua->cons) {
      Dmsg0(1400, "Root cons access OK.\n");
      return true;     
   }
   alist *list = ua->cons->ACL_lists[Job_ACL];
   if (!list) {                       
      return false;                   
   }
   if (list->size() == 1 && strcasecmp("*all*", (char *)list->get(0)) == 0) {
      return true;
   }
   if (!open_new_client_db(ua)) {
      return false;
   }
   p = tmp = bstrdup(jobids);
   while (get_next_jobid_from_list(&p, &jid) > 0) {
      memset(&jr, 0, sizeof(jr));
      jr.JobId = jid;
      if (db_get_job_record(ua->jcr, ua->db, &jr)) {
         for (int i=0; i<list->size(); i++) {
            if (strcasecmp(jr.Name, (char *)list->get(i)) == 0) {
               Dmsg3(1400, "ACL found %s in %d %s\n", jr.Name,
                     Job_ACL, (char *)list->get(i));
               ret = true;
               goto bail_out;
            }
         }
      }
   }
bail_out:
   if (tmp) {
      free(tmp);
   }
   return ret;
}
bool acl_access_jobid_ok ( UAContext * ua , const char * jobids ) { char * tmp = NULL , * p ; bool ret = false ; JOB_DBR jr ; uint32_t jid ; if ( ! jobids ) { return false ; } if ( ! is_a_number_list ( jobids ) ) { return false ; } if ( ! ua || ! ua -> cons ) { Dmsg0 ( 1400 , " \n " ) ; return true ; } alist * list = ua -> cons -> ACL_lists [ Job_ACL ] ; if ( ! list ) { return false ; } if ( list -> size ( ) == 1 && strcasecmp ( " " , ( char * ) list -> get ( 0 ) ) == 0 ) { return true ; } if ( ! open_new_client_db ( ua ) ) { return false ; } p = tmp = bstrdup ( jobids ) ; while ( get_next_jobid_from_list ( & p , & jid ) > 0 ) { memset ( & jr , 0 , sizeof ( jr ) ) ; jr . JobId = jid ; if ( db_get_job_record ( ua -> jcr , ua -> db , & jr ) ) { for ( int i = 0 ; i < list -> size ( ) ; i ++ ) { if ( strcasecmp ( jr . Name , ( char * ) list -> get ( i ) ) == 0 ) { Dmsg3 ( 1400 , " \n " , jr . Name , Job_ACL , ( char * ) list -> get ( i ) ) ; ret = true ; goto bail_out ; } } } } bail_out : if ( tmp ) { free ( tmp ) ; } return ret ; }
Check if the access is permitted for a list of jobids
 Not in ua_acl.c because it's using db access, and tools such
 as bdirjson are not linked with cats.
Check if the access is permitted for a list of jobids Not in ua_acl . c because it ' s using db access and tools such as bdirjson are not linked with cats .
/* If no console resource => default console and all is permitted */ /* No cons resource -> root console OK for everything */ /* empty list */ /* List empty, reject everything */ /* Special case *all* gives full access */ /* If we can't open the database, just say no */