Ignore:
Timestamp:
30/05/06 16:49:09 (14 years ago)
Author:
spascoe
Message:

A python module which provides a function to start the daemon can be
built using the setup.py script. This method of invoking the server
has been briefly tested but no test cases yet.

I've taken out the initialisation/finalisation hooks from the auth API because
we shouldn't need them now. They were written assuming the python interpretter
was going to be embedded within bbftpd, but I've inverted the embedding by
wrapping bbftpd.c:main in a python extension function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private.c

    r975 r1064  
    179179    ** Now give hand to user routine 
    180180    */ 
     181 
    181182    if ( bbftpd_private_auth(logmessage) < 0 ) { 
    182183        syslog(BBFTPD_ERR,"bbftpd_private_auth failed : %s",logmessage) ; 
     
    184185        return -1 ; 
    185186    } 
    186 #ifdef NDG_AUTH 
    187     ndg_atexit_status = NDG_INCHILD; 
    188 #endif // NDG_AUTH 
    189187 
    190188    return 0 ; 
     
    352350} 
    353351 
    354  
    355 #ifdef NDG_AUTH 
    356 /* 
    357 ** bbftpd_private_initialise : 
    358 ** 
    359 **      Routine to initialise the private authentication infrastructure. 
    360 **      This function is mainly a wrapper around bbftpd_private_init(), 
    361 **      except that it also sets up an atexit function. 
    362 */ 
    363 int bbftpd_private_initialise(char *logmessage) { 
    364   struct sigaction sga; 
    365  
    366   /* Set signal handlers for the daemon. 
    367    */ 
    368   sga.sa_handler = bbftpd_private_sigaction ; 
    369   sigemptyset(&(sga.sa_mask)); 
    370   sga.sa_flags = 0  ; 
    371   if ( sigaction(SIGTERM,&sga,0) < 0 ) { 
    372     syslog(BBFTPD_ERR,"Error sigaction SIGCTERM : %s",strerror(errno)) ; 
    373     return -1; 
    374   } 
    375  
    376  
    377   if (atexit(bbftpd_private_atexit) != 0) { 
    378     sprintf(logmessage, "atexit failure"); 
    379     return -1; 
    380   } 
    381   ndg_atexit_status = NDG_INFATHER; 
    382   return bbftpd_private_init(logmessage); 
    383 } 
    384  
    385 /* 
    386 ** bbftpd_private_sigaction(int sig) 
    387 ** 
    388 **      Routine to exit gracefully if SIGTERM is sent.  The daemon process 
    389 **      will not call any atexit() functions on receipt of SIGTERM by default. 
    390 **      This function is a signal handler to change this behaviour. 
    391 */ 
    392 void bbftpd_private_sigaction(int sig) 
    393 { 
    394   // Hopefully calling atexit() handlers. 
    395   exit(0); 
    396 } 
    397  
    398  
    399 /* 
    400 ** bbftpd_private_atexit : 
    401 ** 
    402 **      Routine to be registered with atexit() for cleaning up the private authentication 
    403 **      infrastructure.  This function must know whether the server is in a connected or 
    404 **      unconnected state, therefore the global variable ndg_atexit_status is used. 
    405 */ 
    406 void bbftpd_private_atexit(void) 
    407 { 
    408   if (ndg_atexit_status == NDG_INFATHER) { 
    409     bbftpd_private_finalise(); 
    410   } 
    411   else if (ndg_atexit_status == NDG_INCHILD) { 
    412     bbftpd_private_auth_finalise(); 
    413   } 
    414   else { 
    415     syslog(BBFTPD_ERR, "ndg_atexit_status unrecognised: %d", ndg_atexit_status); 
    416     fprintf(stderr, "ndg_atexit_status unrecognised: %d", ndg_atexit_status); 
    417   } 
    418 } 
    419 #endif // NDG_AUTH 
Note: See TracChangeset for help on using the changeset viewer.