コード例 #1
0
ファイル: sd_cmds.c プロジェクト: NilByMouth/bareos
/*
 * Establish a connection with the Storage daemon and perform authentication.
 */
bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
                               int max_retry_time, bool verbose)
{
   BSOCK *sd;
   STORERES *store;
   utime_t heart_beat;

   if (jcr->store_bsock) {
      return true;                    /* already connected */
   }

   sd = New(BSOCK_TCP);

   /*
    * If there is a write storage use it
    */
   if (jcr->res.wstore) {
      store = jcr->res.wstore;
   } else {
      store = jcr->res.rstore;
   }

   if (store->heartbeat_interval) {
      heart_beat = store->heartbeat_interval;
   } else {
      heart_beat = me->heartbeat_interval;
   }

   /*
    * Open message channel with the Storage daemon
    */
   Dmsg2(100, "bnet_connect to Storage daemon %s:%d\n", store->address, store->SDport);
   sd->set_source_address(me->DIRsrc_addr);
   if (!sd->connect(jcr, retry_interval, max_retry_time, heart_beat, _("Storage daemon"),
                    store->address, NULL, store->SDport, verbose)) {
      delete sd;
      sd = NULL;
   }

   if (sd == NULL) {
      return false;
   }
   sd->res = (RES *)store;        /* save pointer to other end */
   jcr->store_bsock = sd;

   if (!authenticate_storage_daemon(jcr, store)) {
      sd->close();
      delete jcr->store_bsock;
      jcr->store_bsock = NULL;
      return false;
   }

   return true;
}
コード例 #2
0
ファイル: authenticate.cpp プロジェクト: NilByMouth/bareos
int authenticate_daemon(MonitorItem* item, JCR *jcr)
{
   switch (item->type()) {
   case R_DIRECTOR:
      return authenticate_director(jcr);
   case R_CLIENT:
      return authenticate_file_daemon(jcr, (CLIENTRES*)item->resource());
   case R_STORAGE:
      return authenticate_storage_daemon(jcr, (STORERES*)item->resource());
   default:
      printf(_("Error, currentitem is not a Client or a Storage..\n"));
      return FALSE;
   }
   return false;
}
コード例 #3
0
ファイル: check_bacula.c プロジェクト: rkorzeniewski/bacula
static int authenticate_daemon(monitoritem* item) {

   DIRRES *d;
   CLIENT *f;
   STORE *s;

   switch (item->type) {
   case R_DIRECTOR:
      d = (DIRRES *)item->resource;
      return authenticate_director(item->D_sock, d->hdr.name, d->password);
      break;
   case R_CLIENT:
      f = (CLIENT *)item->resource;
      return authenticate_file_daemon(item->D_sock, f->hdr.name, f->password);
      break;
   case R_STORAGE:
      s = (STORE *)item->resource;
      return authenticate_storage_daemon(item->D_sock, s->hdr.name, s->password);
      break;
   default:
      printf("Error, currentitem is not a Client or a Storage..\n");
      return FALSE;
   }
}