Changeset 1117 for TI05-delivery
- Timestamp:
- 07/06/06 11:59:39 (15 years ago)
- Location:
- TI05-delivery/trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd.c
r1100 r1117 115 115 #else 116 116 #define OPTIONS "bd:e:fl:m:R:suvw:" 117 #endif 118 119 #ifdef NDG_AUTH 120 #include <ndg.h> 117 121 #endif 118 122 -
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private_user.c
r1100 r1117 37 37 #include <bbftpd_private_user.h> 38 38 39 #ifdef NDG_PYTHON_EMBED40 #include <Python.h>41 #endif42 43 39 extern char currentusername[MAXLEN] ; 44 45 #ifdef NDG_PYTHON_EMBED46 int bbftpd_private_auth_callback(char *logmessage);47 48 #endif49 50 40 51 41 … … 102 92 *******************************************************************************/ 103 93 94 #ifdef NDG_AUTH 95 96 /* The real private authorisation is defined here. */ 97 #include "ndg.c" 98 99 #else 100 104 101 int bbftpd_private_auth(char *logmessage) 105 102 { 106 107 #ifdef NDG_PYTHON_EMBED 108 char *username; 109 110 if (bbftpd_private_auth_callback(logmessage) == -1) { 111 return -1; 112 } 113 if ((username = bbftpd_private_auth_getusername(logmessage)) == NULL) { 114 return -1; 115 } 116 117 sprintf(currentusername, "%.*s", MAXLEN, username); 118 #else 119 char *privatestr; 120 int privatestr_len; 121 122 char *msg; 123 int len; 124 125 /* Receive version verification message. */ 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); 131 132 /* Send response */ 133 if (ndg_message_send(NDG_HANDSHAKE, strlen(NDG_HANDSHAKE) + 1, logmessage) == -1) { 134 return -1; 135 } 136 137 /* Receive the privatestr */ 138 if (ndg_message_recv(&privatestr, &privatestr_len, logmessage) == -1) { 139 return -1; 140 } 141 142 syslog(LOG_INFO, "Private string: %s", privatestr); 143 free(privatestr); 144 145 #endif 146 147 return 0 ; 103 return 0 ; 148 104 } 149 105 150 151 #ifdef NDG_AUTH152 153 /*154 ** bbftpd_private_authz_control :155 **156 ** Routine to authorise bbftp control commands.157 **158 ** INPUT variables:159 ** msgcode : The message code from struct message160 ** transferoptions : TROPT_* options161 ** path : path to apply command to162 **163 ** OUTPUT variables:164 ** logmessage : to write the error message in case of failure165 **166 ** RETURN:167 ** -1 Authorisation failed168 ** 0 OK169 **170 **171 */172 int bbftpd_private_authz_control(int msgcode, int transferoption, char *path, char *logmessage)173 {174 175 switch (msgcode) {176 case MSG_CHDIR_V2:177 syslog(LOG_DEBUG, "Authz: MSG_DIR 0x%x %s", transferoption, path);178 break;179 case MSG_LIST_V2:180 syslog(LOG_DEBUG, "Authz: MSG_LIST_V2 0x%x %s", transferoption, path);181 break;182 case MSG_MKDIR_V2:183 syslog(LOG_DEBUG, "Authz: MSG_MKDIR_V2 0x%x %s", transferoption, path);184 break;185 case MSG_RM:186 syslog(LOG_DEBUG, "Authz: MSG_RM 0x%x %s", transferoption, path);187 break;188 case MSG_STAT:189 syslog(LOG_DEBUG, "Authz: MSG_STAT 0x%x %s", transferoption, path);190 break;191 case MSG_DF:192 syslog(LOG_DEBUG, "Authz: MSG_DF 0x%x %s", transferoption, path);193 break;194 default:195 sprintf(logmessage, "Unrecognised message to authorise %d", msgcode);196 return -1;197 }198 199 return 0;200 }201 202 203 /*204 ** bbftpd_private_authz_retr :205 **206 ** Routine to authorise file retrieve requests.207 **208 ** INPUT variables:209 ** path: the file to retrieve210 **211 ** OUTPUT variables:212 ** logmessage : to write the error message in case of failure213 **214 ** RETURN:215 ** -1 Authorisation failed216 ** 0 OK217 **218 */219 int bbftpd_private_authz_retr(char *path, char *logmessage)220 {221 syslog(LOG_DEBUG, "Authz: RETR %s", path);222 return 0;223 }224 225 /*226 ** bbftpd_private_authz_store :227 **228 ** Routine to authorise file store requests.229 **230 ** INPUT variables:231 ** path: the file to store232 **233 ** OUTPUT variables:234 ** logmessage : to write the error message in case of failure235 **236 ** RETURN:237 ** -1 Authorisation failed238 ** 0 OK239 **240 */241 242 int bbftpd_private_authz_store(char *path, char *logmessage)243 {244 syslog(LOG_DEBUG, "Authz: STORE %s", path);245 return 0;246 }247 248 249 /*250 * Higher level message transfer functions.251 *252 */253 254 /**255 * Send a message, declaring it's length to the client.256 *257 * @param buffer a pointer to the message buffer258 * @param length the number of bytes to send259 * @param[out] loggmessage is filled with the error message on error260 * @return 0 if OK, -1 if error261 */262 int ndg_message_send(char *buffer, int length, char *logmessage) {263 char ctrl[NDG_MESSAGE_LEN];264 265 sprintf(ctrl, "NDG-msg: %i", length);266 if (bbftpd_private_send(ctrl, NDG_MESSAGE_LEN, logmessage) == -1) {267 return -1;268 }269 270 if (bbftpd_private_send(buffer, length, logmessage) == -1) {271 return -1;272 }273 274 return 0;275 }276 277 /**278 * Receive a message of variable length279 *280 * @param[out] buffer is set to newly allocated message buffer281 * @param[out] length is set to the length of the message282 * @param[out] logmessage is filled with the logmessage on error283 * @return 0 if OK, -1 if error284 */285 int ndg_message_recv(char **buffer, int *length, char *logmessage) {286 char ctrl[NDG_MESSAGE_LEN];287 288 if (bbftpd_private_recv(ctrl, NDG_MESSAGE_LEN, logmessage) == -1) {289 return -1;290 }291 if (sscanf(ctrl, "NDG-msg: %i", length) != 1) {292 sprintf(logmessage, "ndg_message_recv ctrl error: %40s", ctrl);293 return -1;294 }295 296 if ((*buffer = (char *)malloc(*length * sizeof(char))) == NULL) {297 sprintf(logmessage, "ngd_message_recv malloc error");298 return -1;299 }300 301 if (bbftpd_private_recv(*buffer, *length, logmessage) == -1) {302 free(*buffer); *buffer = NULL;303 return -1;304 }305 306 return 0;307 }308 309 310 311 312 106 #endif // NDG_AUTH -
TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/bbftpd_private_user.h
r1077 r1117 39 39 **/ 40 40 41 #define NDG_FTP_VERSION "v0.0.1" 42 #define NDG_FTP_PROTOCOL ("NDG-bbFTP" NDG_BBFTP_VERSION) 43 44 /* The logmessage size limit is hard coded into the bbFTP source. I define a macro here to avoid 45 buffer overflows. 46 */ 47 #define NDG_MAX_LOGMESSAGE 1024 48 #define NDG_MESSAGE_LEN 256 49 50 #define NDG_STR(s) #s 51 #define NDG_XSTR(s) NDG_STR(s) 52 #define NDG_HANDSHAKE ("NDG-Delivery-server " NDG_XSTR(NDG_DELIVERY_VERSION)) 41 #ifdef NDG_AUTH 42 #include <ndg.h> 43 #endif -
TI05-delivery/trunk/src/bbftp-server-3.2.0/includes/daemon_proto.h
r1100 r1117 67 67 */ 68 68 int bbftpd_private_auth(char *logmessage) ; 69 #ifdef NDG_AUTH70 int bbftpd_private_authz_control(int msgcode, int transferoption, char *path, char *logmessage);71 int bbftpd_private_authz_retr(char *path, char *logmessage);72 int bbftpd_private_authz_store(char *path, char *logmessage);73 int ndg_message_send(char *buffer, int buffertosendlength, char *logmessage) ;74 int ndg_message_recv(char **buffer, int *length, char *logmessage) ;75 76 #endif // NDG_AUTH77 78 69 /* 79 70 ** Prototype for retr routines
Note: See TracChangeset
for help on using the changeset viewer.