Changeset 1064 for TI05-delivery
- Timestamp:
- 30/05/06 16:49:09 (15 years ago)
- Location:
- TI05-delivery/trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/trunk/src/Makefile
r999 r1064 9 9 BBFTPC=bbftp-client-3.2.0/bbftpc 10 10 11 all: 11 all: server client 12 13 server: 14 make -C $(BBFTPD) 15 16 client: 12 17 make -C $(BBFTPC) 13 make -C $(BBFTPD)14 18 15 19 # Configure and build bbftp … … 23 27 24 28 clean: 25 make -C $(BBFTPC) clean26 make -C $(BBFTPD) clean29 -rm $(BBFTPD)/*.o $(BBFTPD)/bbftpd 30 -rm $(BBFTPC)/*.o $(BBFTPC)/bbftp -
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd.c
r973 r1064 116 116 #define OPTIONS "bd:e:fl:m:R:suvw:" 117 117 #endif 118 119 #ifdef NDG_PYTHON_EMBED 120 #include <Python.h> 121 extern char **environ; 122 123 #endif // NDG_PYTHON_EMBED 124 118 125 /* 119 126 ** Common variables for BBFTP protocole version 1 and 2 … … 383 390 struct timeval tstart; 384 391 392 #ifdef NDG_PYTHON_EMBED 393 bbftpd_main (argc, argv, envp) 394 #else 385 395 main (argc,argv,envp) 396 #endif //NDG_PYTHON_EMBED 386 397 int argc ; 387 398 char **argv ; … … 790 801 } 791 802 #endif 792 #ifdef NDG_AUTH793 if ( bbftpd_private_initialise(logmessage) == -1) {794 syslog(BBFTPD_ERR, "bbftpd_private_init failure: %s", logmessage);795 //!TODO: Should I write to stderr in all daemon modes (be_daemon)?796 fprintf(stderr, "bbftpd_private_init failure: %s", logmessage);797 exit(1);798 }799 #endif // NDG_AUTH800 803 if ( be_daemon == 2 ) { 801 804 /* … … 1084 1087 state = S_PROTWAIT ; 1085 1088 sprintf(logmessage,"bbftpd version %s : OK",VERSION) ; 1089 syslog(BBFTPD_DEBUG, "Lets send the auth reply ..."); 1086 1090 reply(MSG_OK,logmessage) ; 1087 1091 } else { … … 1402 1406 #endif 1403 1407 1408 #ifdef NDG_PYTHON_EMBED 1409 /* 1410 When embedding in python main is replaced by a simple python function call. 1411 */ 1412 static PyObject *bbftpd_run(PyObject *self, PyObject *args) { 1413 int argc, i; 1414 char **argv, **arg_p; 1415 1416 /* 1417 * Convert arguments into a standard argv sequence. 1418 */ 1419 argc = PyTuple_GET_SIZE(args); 1420 if ((argv = (char*)malloc(argc*sizeof(char*))) == NULL) { 1421 PyErr_SetString(PyExc_MemoryError, "malloc failed"); 1422 return NULL; 1423 } 1424 1425 arg_p = argv; 1426 for (i==0; i<argc; i++) { 1427 if ((*arg_p = PyString_AsString(PyTuple_GET_ITEM(args, i))) == NULL) { 1428 free(argv); 1429 return NULL; 1430 } 1431 arg_p++; 1432 } 1433 1434 bbftpd_main(argc, argv, environ); 1435 1436 // I'm not sure we ever get here. 1437 free(argv); 1438 Py_RETURN_NONE; 1439 } 1440 1441 static PyMethodDef BbftpdMethods[] = { 1442 {"run", bbftpd_run, METH_VARARGS, "Execute the bbftpd server"}, 1443 {NULL, NULL, 0, NULL} 1444 }; 1445 1446 PyMODINIT_FUNC initbbftpd(void) { 1447 (void) Py_InitModule("bbftpd", BbftpdMethods); 1448 } 1449 1450 #endif // NDG_PYTHON_EMBED -
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private.c
r975 r1064 179 179 ** Now give hand to user routine 180 180 */ 181 181 182 if ( bbftpd_private_auth(logmessage) < 0 ) { 182 183 syslog(BBFTPD_ERR,"bbftpd_private_auth failed : %s",logmessage) ; … … 184 185 return -1 ; 185 186 } 186 #ifdef NDG_AUTH187 ndg_atexit_status = NDG_INCHILD;188 #endif // NDG_AUTH189 187 190 188 return 0 ; … … 352 350 } 353 351 354 355 #ifdef NDG_AUTH356 /*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 process389 ** 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 authentication403 ** infrastructure. This function must know whether the server is in a connected or404 ** 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 -
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private_user.c
r1003 r1064 39 39 extern char currentusername[MAXLEN] ; 40 40 41 42 41 43 /******************************************************************************* 42 44 ** bbftpd_private_auth : * … … 109 111 110 112 /* 111 * bbftpd_private_init :112 *113 * Routine to initialise private authentication. This function will be114 * called before bbftpd begins listening for connections and therefore115 * before the fork() that occurs when a client connects.116 *117 * OUTPUT variable :118 * logmessage : to write the error message in case of error119 *120 * RETURN:121 * -1 Unrecoverable error122 * 0 OK123 *124 */125 126 int bbftpd_private_init(char *logmessage)127 {128 syslog(LOG_DEBUG, "initialising private authentication");129 return 0;130 }131 132 /*133 * bbftpd_private_finalise :134 *135 * Routine to clean up the private authentication infrastructure when the136 * daemon exits. This function is the counterpart of bbftpd_private_init and137 * will be called from the daemon process during exit. NOTE: it will not138 * be aware of any actions of child processes.139 *140 */141 142 void bbftpd_private_finalise(void)143 {144 syslog(LOG_DEBUG, "finalising private authentication in server");145 return;146 }147 148 /*149 * bbftpd_private_auth_finalise :150 *151 * Routine to clean up the private authentication infrastructure for each child.152 * This function is the counterpart of bbftpd_private_auth and will be called from153 * each child of the daemon during exit.154 *155 */156 157 void bbftpd_private_auth_finalise(void)158 {159 syslog(LOG_DEBUG, "finalising private authentication in connection");160 return;161 }162 163 /*164 113 ** bbftpd_private_authz_control : 165 114 ** -
TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/bbftpd_private.h
r973 r1064 41 41 RSA *hisrsa ; 42 42 43 #ifdef NDG_AUTH44 /*45 ** NDG authentication global variables.46 */47 #define NDG_INFATHER 148 #define NDG_INCHILD 249 int ndg_atexit_status ;50 #endif // NDG_AUTH -
TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/bbftpd_private_user.h
r802 r1064 28 28 *****************************************************************************/ 29 29 30 #include <Python.h> 31 30 32 /* 31 33 ** This include must contain all global variable to be used for private -
TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/daemon_proto.h
r988 r1064 63 63 int bbftpd_private_send(char *buffertosend, int buffertosendlength, char *logmessage) ; 64 64 int bbftpd_private_recv(char *buffertorecv, int lengthtorecv, char *logmessage) ; 65 #ifdef NDG_AUTH66 int bbftpd_private_initialise(char *logmessage);67 void bbftpd_private_sigaction(int sig);68 void bbftpd_private_atexit(void);69 #endif // NDG_AUTH70 65 /* 71 66 ** Prototype for user private authentication routines … … 73 68 int bbftpd_private_auth(char *logmessage) ; 74 69 #ifdef NDG_AUTH 75 int bbftpd_private_init(char *logmessage);76 void bbftpd_private_finalise(void);77 void bbftpd_private_auth_finalise(void);78 70 int bbftpd_private_authz_control(int msgcode, int transferoption, char *path, char *logmessage); 79 71 int bbftpd_private_authz_retr(char *path, char *logmessage); -
TI05-delivery/trunk/test/test_bbftpd.py
r1003 r1064 14 14 class ExtendedAPITestCase(unittest.TestCase): 15 15 """Test the basic bbftp private authentication API with stub extensions. 16 17 This test case runs bbftpd without python embedding and checks the auth API 18 is being called correctly. 16 19 """ 17 20 … … 52 55 self.fail(e) 53 56 54 self.assert_(self._findLines(['.* initialising private auth.*', '.*finalising private auth.*'], lines))57 self.assert_(self._findLines(['.*Starting bbftpd in background mode'], lines)) 55 58 56 59 def testDir(self): … … 207 210 return True 208 211 212 209 213 if __name__ == '__main__': 210 214 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.