Ignore:
Timestamp:
06/06/06 15:01:09 (13 years ago)
Author:
spascoe
Message:

Python code on the server will now receive the private string from the
client. This is the basic requirement for doing bbftp authentication
within python.

Slightly higher level message passing functions ndg_message_send/recv are now
bound to python callbacks bbftpd.send and bbftpd.recv.

Location:
TI05-delivery/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/bbftp-client-3.2.0/bbftpc/bbftp_private_user.c

    r1078 r1100  
    129129int bbftp_private_auth(char *logmessage)  
    130130{ 
    131   char msg[NDG_MESSAGE_LEN]; 
     131  char *msg; 
    132132  char default_privatestr[] = "none"; 
    133    
     133  int len; 
     134 
    134135  /* Send version verification message.  */ 
    135   sprintf(msg, "%.*s", NDG_MESSAGE_LEN - 1, NDG_HANDSHAKE); 
    136   if (bbftp_private_send(msg, NDG_MESSAGE_LEN, logmessage) == -1) { 
    137     return -1; 
    138   } 
    139  
     136  if (ndg_message_send(NDG_HANDSHAKE, strlen(NDG_HANDSHAKE) + 1, logmessage) == -1) { 
     137    return -1; 
     138  } 
     139   
    140140  /* Receive response */ 
    141   if (bbftp_private_recv(msg, NDG_MESSAGE_LEN, logmessage) == -1) { 
    142     return -1; 
    143   } 
    144  
     141  if (ndg_message_recv(&msg, &len, logmessage) == -1) { 
     142    return -1; 
     143  } 
     144   
    145145  if (debug) { 
    146146    printmessage(stdout,CASE_NORMAL,0,0,"Received Auth handshake: %s\n", msg) ; 
    147147  } 
     148  free(msg); 
    148149 
    149150  /* Send the privatestr */ 
     
    212213  } 
    213214 
    214   if (bbftp_private_recv(buffer, *length, logmessage) == -1) { 
     215  if (bbftp_private_recv(*buffer, *length, logmessage) == -1) { 
    215216    free(*buffer); *buffer = NULL; 
    216217    return -1; 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd.c

    r1079 r1100  
    952952#ifdef NDG_AUTH 
    953953                sprintf(logmessage,"%s                   NDG private autentication/authorisation extensions \n", logmessage); 
    954 #endif NDG_AUTH 
     954#endif // NDG_AUTH 
    955955#endif 
    956956#ifdef NDG_PYTHON_EMBED 
     
    961961                    sprintf(logmessage,"%s                   data ports range = [%d-%d] \n", logmessage,pasvport_min, pasvport_max) ; 
    962962                } 
     963#endif // NDG_PYTHON_EMBED 
    963964#ifdef CERTIFICATE_AUTH 
    964965                if (accept_pass_only) { 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private_user.c

    r1078 r1100  
    4747 
    4848#endif 
    49  
    50 /* prototypes */ 
    51 static int ndg_message_recv(char **buffer, int *length, char *logmessage); 
    52 static int ndg_message_send(char *buffer, int length, char *logmessage); 
    5349 
    5450 
     
    111107#ifdef NDG_PYTHON_EMBED 
    112108  char *username; 
    113  
     109   
    114110  if (bbftpd_private_auth_callback(logmessage) == -1) { 
    115111    return -1; 
     
    118114    return -1; 
    119115  } 
    120     
     116   
    121117  sprintf(currentusername, "%.*s", MAXLEN, username); 
    122118#else 
    123119  char *privatestr; 
    124120  int privatestr_len; 
    125  
    126   char msg[NDG_MESSAGE_LEN]; 
     121   
     122  char *msg; 
     123  int len; 
     124   
    127125  /* Receive version verification message.  */ 
    128   if (bbftpd_private_recv(msg, NDG_MESSAGE_LEN, logmessage) == -1) { 
    129     return -1; 
    130   } 
    131   else { 
    132     syslog(LOG_DEBUG, "Received auth message: %s", msg); 
    133   } 
     126  if (ndg_message_recv(&msg, &len, logmessage) == -1) { 
     127    return -1; 
     128  } 
     129  syslog(LOG_DEBUG, "Received auth message: %s", msg); 
     130  free(msg); 
    134131 
    135132  /* Send response */ 
    136   sprintf(msg, "%.*s", NDG_MESSAGE_LEN - 1, NDG_HANDSHAKE); 
    137   if (bbftpd_private_send(msg, NDG_MESSAGE_LEN, logmessage) == -1) { 
     133  if (ndg_message_send(NDG_HANDSHAKE, strlen(NDG_HANDSHAKE) + 1, logmessage) == -1) { 
    138134    return -1; 
    139135  } 
     
    145141 
    146142  syslog(LOG_INFO, "Private string: %s", privatestr); 
     143  free(privatestr); 
    147144 
    148145#endif 
     
    263260 * @return 0 if OK, -1 if error 
    264261 */ 
    265 static int ndg_message_send(char *buffer, int length, char *logmessage) { 
     262int ndg_message_send(char *buffer, int length, char *logmessage) { 
    266263  char ctrl[NDG_MESSAGE_LEN]; 
    267264 
     
    286283 * @return 0 if OK, -1 if error 
    287284 */ 
    288 static int ndg_message_recv(char **buffer, int *length, char *logmessage) { 
     285int ndg_message_recv(char **buffer, int *length, char *logmessage) { 
    289286  char ctrl[NDG_MESSAGE_LEN]; 
    290287 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/daemon_proto.h

    r1064 r1100  
    7171int bbftpd_private_authz_retr(char *path, char *logmessage); 
    7272int bbftpd_private_authz_store(char *path, char *logmessage); 
     73int ndg_message_send(char *buffer, int buffertosendlength, char *logmessage) ; 
     74int ndg_message_recv(char **buffer, int *length, char *logmessage) ; 
     75 
    7376#endif // NDG_AUTH 
     77 
    7478/* 
    7579** Prototype for retr routines 
  • TI05-delivery/trunk/src/python_ext/bbftpd.c

    r1075 r1100  
    2121 
    2222int bbftpd_main(int argc, char **argv, char **envp); 
    23 int bbftpd_private_send(char *buffertosend, int buffertosendlength, char *logmessage) ; 
    24 int bbftpd_private_recv(char *buffertorecv, int lengthtorecv, char *logmessage) ; 
     23int ndg_message_send(char *buffer, int buffertosendlength, char *logmessage) ; 
     24int ndg_message_recv(char **buffer, int *length, char *logmessage) ; 
    2525 
    2626/* 
     
    117117  } 
    118118 
    119   if (bbftpd_private_send(buffer, len, logmessage) == -1) { 
     119  if (ndg_message_send(buffer, len, logmessage) == -1) { 
    120120    PyErr_SetString(PyExc_IOError, logmessage); 
    121121    return NULL; 
     
    129129  char *buffer, logmessage[1024]; 
    130130  int len; 
    131  
    132   if (!PyArg_ParseTuple(args, "i", &len)) { 
     131  PyObject *ret; 
     132 
     133  if (!PyArg_ParseTuple(args, "")) { 
    133134    return NULL; 
    134135  } 
     
    138139    return NULL; 
    139140  } 
    140   if ((buffer = (char*)malloc(len*sizeof(char))) == NULL) { 
    141     PyErr_NoMemory(); 
    142     return NULL; 
    143   } 
    144  
    145   if (bbftpd_private_recv(buffer, len, logmessage) == -1) { 
     141 
     142  if (ndg_message_recv(&buffer, &len, logmessage) == -1) { 
    146143    PyErr_SetString(PyExc_IOError, logmessage); 
    147144    free(buffer); 
     
    149146  } 
    150147 
    151   return Py_BuildValue("s#", buffer, len); 
    152 } 
     148  ret = Py_BuildValue("s#", buffer, len); 
     149  free(buffer); 
     150  return ret; 
     151} 
     152 
    153153 
    154154 
Note: See TracChangeset for help on using the changeset viewer.