src/stored/bsdjson.c
static int check_resources()
{
   bool OK = true;
   bool tls_needed;
   AUTOCHANGER *changer;
   DEVRES *device;

   me = (STORES *)GetNextRes(R_STORAGE, NULL);
   if (!me) {
      Jmsg1(NULL, M_ERROR, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }

   if (GetNextRes(R_STORAGE, (RES *)me) != NULL) {
      Jmsg1(NULL, M_ERROR, 0, _("Only one Storage resource permitted in %s\n"),
         configfile);
      OK = false;
   }
   if (GetNextRes(R_DIRECTOR, NULL) == NULL) {
      Jmsg1(NULL, M_ERROR, 0, _("No Director resource defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }
   if (GetNextRes(R_DEVICE, NULL) == NULL){
      Jmsg1(NULL, M_ERROR, 0, _("No Device resource defined in %s. Cannot continue.\n"),
           configfile);
      OK = false;
   }

   if (!me->messages) {
      me->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
      if (!me->messages) {
         Jmsg1(NULL, M_ERROR, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
            configfile);
         OK = false;
      }
   }

   if (!me->working_directory) {
      Jmsg1(NULL, M_ERROR, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }

   DIRRES *director;
   STORES *store;
   foreach_res(store, R_STORAGE) {
      /* tls_require implies tls_enable */
      if (store->tls_require) {
         if (have_tls) {
            store->tls_enable = true;
         } else {
            Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
            OK = false;
            continue;
         }
      }

      tls_needed = store->tls_enable || store->tls_authenticate;

      if (!store->tls_certfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Certificate\" file not defined for Storage \"%s\" in %s.\n"),
              store->hdr.name, configfile);
         OK = false;
      }

      if (!store->tls_keyfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Key\" file not defined for Storage \"%s\" in %s.\n"),
              store->hdr.name, configfile);
         OK = false;
      }

      if ((!store->tls_ca_certfile && !store->tls_ca_certdir) && tls_needed && store->tls_verify_peer) {
         Jmsg(NULL, M_FATAL, 0, _("Neither \"TLS CA Certificate\""
              " or \"TLS CA Certificate Dir\" are defined for Storage \"%s\" in %s."
              " At least one CA certificate store is required"
              " when using \"TLS Verify Peer\".\n"),
              store->hdr.name, configfile);
         OK = false;
      }
   }

   foreach_res(director, R_DIRECTOR) {
      /* tls_require implies tls_enable */
      if (director->tls_require) {
         director->tls_enable = true;
      }

      tls_needed = director->tls_enable || director->tls_authenticate;

      if (!director->tls_certfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Certificate\" file not defined for Director \"%s\" in %s.\n"),
              director->hdr.name, configfile);
         OK = false;
      }

      if (!director->tls_keyfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Key\" file not defined for Director \"%s\" in %s.\n"),
              director->hdr.name, configfile);
         OK = false;
      }

      if ((!director->tls_ca_certfile && !director->tls_ca_certdir) && tls_needed && director->tls_verify_peer) {
         Jmsg(NULL, M_FATAL, 0, _("Neither \"TLS CA Certificate\""
              " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
              " At least one CA certificate store is required"
              " when using \"TLS Verify Peer\".\n"),
              director->hdr.name, configfile);
         OK = false;
      }
   }

   foreach_res(changer, R_AUTOCHANGER) {
      foreach_alist(device, changer->device) {
         device->cap_bits |= CAP_AUTOCHANGER;
      }
   }

   return OK;
}
/* Check Configuration file for necessary info */
Check Configuration file for necessary info
Check Configuration file for necessary info
static int check_resources()
{
   bool OK = true;
   bool tls_needed;
   AUTOCHANGER *changer;
   DEVRES *device;
   me = (STORES *)GetNextRes(R_STORAGE, NULL);
   if (!me) {
      Jmsg1(NULL, M_ERROR, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }
   if (GetNextRes(R_STORAGE, (RES *)me) != NULL) {
      Jmsg1(NULL, M_ERROR, 0, _("Only one Storage resource permitted in %s\n"),
         configfile);
      OK = false;
   }
   if (GetNextRes(R_DIRECTOR, NULL) == NULL) {
      Jmsg1(NULL, M_ERROR, 0, _("No Director resource defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }
   if (GetNextRes(R_DEVICE, NULL) == NULL){
      Jmsg1(NULL, M_ERROR, 0, _("No Device resource defined in %s. Cannot continue.\n"),
           configfile);
      OK = false;
   }
   if (!me->messages) {
      me->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
      if (!me->messages) {
         Jmsg1(NULL, M_ERROR, 0, _("No Messages resource defined in %s. Cannot continue.\n"),
            configfile);
         OK = false;
      }
   }
   if (!me->working_directory) {
      Jmsg1(NULL, M_ERROR, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
         configfile);
      OK = false;
   }
   DIRRES *director;
   STORES *store;
   foreach_res(store, R_STORAGE) {
      if (store->tls_require) {
         if (have_tls) {
            store->tls_enable = true;
         } else {
            Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
            OK = false;
            continue;
         }
      }
      tls_needed = store->tls_enable || store->tls_authenticate;
      if (!store->tls_certfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Certificate\" file not defined for Storage \"%s\" in %s.\n"),
              store->hdr.name, configfile);
         OK = false;
      }
      if (!store->tls_keyfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Key\" file not defined for Storage \"%s\" in %s.\n"),
              store->hdr.name, configfile);
         OK = false;
      }
      if ((!store->tls_ca_certfile && !store->tls_ca_certdir) && tls_needed && store->tls_verify_peer) {
         Jmsg(NULL, M_FATAL, 0, _("Neither \"TLS CA Certificate\""
              " or \"TLS CA Certificate Dir\" are defined for Storage \"%s\" in %s."
              " At least one CA certificate store is required"
              " when using \"TLS Verify Peer\".\n"),
              store->hdr.name, configfile);
         OK = false;
      }
   }
   foreach_res(director, R_DIRECTOR) {
      if (director->tls_require) {
         director->tls_enable = true;
      }
      tls_needed = director->tls_enable || director->tls_authenticate;
      if (!director->tls_certfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Certificate\" file not defined for Director \"%s\" in %s.\n"),
              director->hdr.name, configfile);
         OK = false;
      }
      if (!director->tls_keyfile && tls_needed) {
         Jmsg(NULL, M_FATAL, 0, _("\"TLS Key\" file not defined for Director \"%s\" in %s.\n"),
              director->hdr.name, configfile);
         OK = false;
      }
      if ((!director->tls_ca_certfile && !director->tls_ca_certdir) && tls_needed && director->tls_verify_peer) {
         Jmsg(NULL, M_FATAL, 0, _("Neither \"TLS CA Certificate\""
              " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
              " At least one CA certificate store is required"
              " when using \"TLS Verify Peer\".\n"),
              director->hdr.name, configfile);
         OK = false;
      }
   }
   foreach_res(changer, R_AUTOCHANGER) {
      foreach_alist(device, changer->device) {
         device->cap_bits |= CAP_AUTOCHANGER;
      }
   }
   return OK;
}
static int check_resources ( ) { bool OK = true ; bool tls_needed ; AUTOCHANGER * changer ; DEVRES * device ; me = ( STORES * ) GetNextRes ( R_STORAGE , NULL ) ; if ( ! me ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } if ( GetNextRes ( R_STORAGE , ( RES * ) me ) != NULL ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } if ( GetNextRes ( R_DIRECTOR , NULL ) == NULL ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } if ( GetNextRes ( R_DEVICE , NULL ) == NULL ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } if ( ! me -> messages ) { me -> messages = ( MSGS * ) GetNextRes ( R_MSGS , NULL ) ; if ( ! me -> messages ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } } if ( ! me -> working_directory ) { Jmsg1 ( NULL , M_ERROR , 0 , _ ( " \n " ) , configfile ) ; OK = false ; } DIRRES * director ; STORES * store ; foreach_res ( store , R_STORAGE ) { if ( store -> tls_require ) { if ( have_tls ) { store -> tls_enable = true ; } else { Jmsg ( NULL , M_FATAL , 0 , _ ( " \n " ) ) ; OK = false ; continue ; } } tls_needed = store -> tls_enable || store -> tls_authenticate ; if ( ! store -> tls_certfile && tls_needed ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" \" \" \n " ) , store -> hdr . name , configfile ) ; OK = false ; } if ( ! store -> tls_keyfile && tls_needed ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" \" \" \n " ) , store -> hdr . name , configfile ) ; OK = false ; } if ( ( ! store -> tls_ca_certfile && ! store -> tls_ca_certdir ) && tls_needed && store -> tls_verify_peer ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" " " \" \" \" \" " " " " \" \" \n " ) , store -> hdr . name , configfile ) ; OK = false ; } } foreach_res ( director , R_DIRECTOR ) { if ( director -> tls_require ) { director -> tls_enable = true ; } tls_needed = director -> tls_enable || director -> tls_authenticate ; if ( ! director -> tls_certfile && tls_needed ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" \" \" \n " ) , director -> hdr . name , configfile ) ; OK = false ; } if ( ! director -> tls_keyfile && tls_needed ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" \" \" \n " ) , director -> hdr . name , configfile ) ; OK = false ; } if ( ( ! director -> tls_ca_certfile && ! director -> tls_ca_certdir ) && tls_needed && director -> tls_verify_peer ) { Jmsg ( NULL , M_FATAL , 0 , _ ( " \" \" " " \" \" \" \" " " " " \" \" \n " ) , director -> hdr . name , configfile ) ; OK = false ; } } foreach_res ( changer , R_AUTOCHANGER ) { foreach_alist ( device , changer -> device ) { device -> cap_bits |= CAP_AUTOCHANGER ; } } return OK ; }
Check Configuration file for necessary info
Check Configuration file for necessary info
/* tls_require implies tls_enable */ /* tls_require implies tls_enable */