src/filed/job.c
void *handle_connection_request(void *caller)
{
   BSOCK *bs = (BSOCK *)caller;

   if (bs->recv() > 0) {
      if (strncmp(bs->msg, "Ping", 4) == 0) {
         bs->fsend("2000 Ping OK\n");
         bs->destroy();
         return NULL;
      }
      if (bs->msglen < 25 || bs->msglen > 500) {
         goto bail_out;
      }
      if (strncmp(bs->msg, "Hello FD: Bacula Storage", 20) ==0) {
         return handle_storage_connection(bs);
      }
      if (strncmp(bs->msg, "Hello ", 5) == 0) {
         return handle_director_request(bs);
      }
   }
bail_out:
   Dmsg2(100, "Bad command from %s. Len=%d.\n", bs->who(), bs->msglen);
   char addr[64];
   char *who = bs->get_peer(addr, sizeof(addr)) ? bs->who() : addr;
   Qmsg2(NULL, M_SECURITY, 0, _("FD expecting Hello got bad command from %s. Len=%d.\n"), who, bs->msglen);
   sleep(5);
   bs->destroy();
   return NULL;
}
/*
 * Accept requests from a Director or a Storage daemon
 */
Accept requests from a Director or a Storage daemon
Accept requests from a Director or a Storage daemon
void *handle_connection_request(void *caller)
{
   BSOCK *bs = (BSOCK *)caller;
   if (bs->recv() > 0) {
      if (strncmp(bs->msg, "Ping", 4) == 0) {
         bs->fsend("2000 Ping OK\n");
         bs->destroy();
         return NULL;
      }
      if (bs->msglen < 25 || bs->msglen > 500) {
         goto bail_out;
      }
      if (strncmp(bs->msg, "Hello FD: Bacula Storage", 20) ==0) {
         return handle_storage_connection(bs);
      }
      if (strncmp(bs->msg, "Hello ", 5) == 0) {
         return handle_director_request(bs);
      }
   }
bail_out:
   Dmsg2(100, "Bad command from %s. Len=%d.\n", bs->who(), bs->msglen);
   char addr[64];
   char *who = bs->get_peer(addr, sizeof(addr)) ? bs->who() : addr;
   Qmsg2(NULL, M_SECURITY, 0, _("FD expecting Hello got bad command from %s. Len=%d.\n"), who, bs->msglen);
   sleep(5);
   bs->destroy();
   return NULL;
}
void * handle_connection_request ( void * caller ) { BSOCK * bs = ( BSOCK * ) caller ; if ( bs -> recv ( ) > 0 ) { if ( strncmp ( bs -> msg , " " , 4 ) == 0 ) { bs -> fsend ( " \n " ) ; bs -> destroy ( ) ; return NULL ; } if ( bs -> msglen < 25 || bs -> msglen > 500 ) { goto bail_out ; } if ( strncmp ( bs -> msg , " " , 20 ) == 0 ) { return handle_storage_connection ( bs ) ; } if ( strncmp ( bs -> msg , " " , 5 ) == 0 ) { return handle_director_request ( bs ) ; } } bail_out : Dmsg2 ( 100 , " \n " , bs -> who ( ) , bs -> msglen ) ; char addr [ 64 ] ; char * who = bs -> get_peer ( addr , sizeof ( addr ) ) ? bs -> who ( ) : addr ; Qmsg2 ( NULL , M_SECURITY , 0 , _ ( " \n " ) , who , bs -> msglen ) ; sleep ( 5 ) ; bs -> destroy ( ) ; return NULL ; }
Accept requests from a Director or a Storage daemon
Accept requests from a Director or a Storage daemon