"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "commands.c" between
bftpd-5.3.tar.gz and bftpd-5.4.tar.gz

About: bftpd is a Linux FTP server (with "chroot"-environment).

commands.c  (bftpd-5.3):commands.c  (bftpd-5.4)
skipping to change at line 865 skipping to change at line 865
return; return;
} }
} /* end of while */ } /* end of while */
} }
void command_retr(char *filename) void command_retr(char *filename)
{ {
int num_clients = 1; int num_clients = 1;
int new_num_clients = 1; /* number of connectiosn to the server */ int new_num_clients; /* number of connections to the server */
int my_buffer_size; /* size of the transfer buffer to use */ int my_buffer_size; /* size of the transfer buffer to use */
char *mapped = NULL; char *mapped = NULL;
char *buffer; char *buffer;
int xfer_delay; int xfer_delay;
struct timeval wait_time; struct timeval wait_time;
unsigned long get_value; unsigned long get_value;
ssize_t send_status; ssize_t send_status;
int change_buffer_size = FALSE; int change_buffer_size = FALSE;
#if (defined(WANT_GZIP) || defined(HAVE_ZLIB_H)) #if (defined(WANT_GZIP) || defined(HAVE_ZLIB_H))
gzFile gzfile; gzFile gzfile;
#endif #endif
int phile; int phile;
int i, whattodo = DO_NORMAL; ssize_t i;
int whattodo = DO_NORMAL;
struct stat statbuf; struct stat statbuf;
#if (defined(WANT_TAR) && defined(WANT_GZIP)) #if (defined(WANT_TAR) && defined(WANT_GZIP))
int filedes[2]; int filedes[2];
#endif #endif
#if (defined(WANT_TAR) || defined(WANT_GZIP)) #if (defined(WANT_TAR) || defined(WANT_GZIP))
char *foo; char *foo;
#endif #endif
#ifdef WANT_TAR #ifdef WANT_TAR
char *argv[4]; char *argv[4];
#endif #endif
skipping to change at line 1014 skipping to change at line 1015
if (change_buffer_size) if (change_buffer_size)
{ {
num_clients = bftpdutmp_usercount("*"); num_clients = bftpdutmp_usercount("*");
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
else else
my_buffer_size = xfer_bufsize; my_buffer_size = xfer_bufsize;
close(filedes[1]); close(filedes[1]);
gzfile = gzdopen(sock, "wb"); gzfile = gzdopen(sock, "wb");
while ((i = read(filedes[0], buffer, my_buffer_size))) { i = read(filedes[0], buffer, my_buffer_size);
while (i > 0) {
gzwrite(gzfile, buffer, i); gzwrite(gzfile, buffer, i);
test_abort(1, phile, sock); test_abort(1, phile, sock);
/* check for a change in number of connections */ /* check for a change in number of connections */
if (change_buffer_size) if (change_buffer_size)
{ {
new_num_clients = bftpdutmp_usercount("*"); new_num_clients = bftpdutmp_usercount("*");
if (new_num_clients != num_clients) if (new_num_clients != num_clients)
{ {
num_clients = new_num_clients; num_clients = new_num_clients;
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
} }
/* pause between transfers */ /* pause between transfers */
if (xfer_delay) if (xfer_delay)
{ {
wait_time.tv_sec = 0; wait_time.tv_sec = 0;
wait_time.tv_usec = xfer_delay; wait_time.tv_usec = xfer_delay;
select( 0, NULL, NULL, NULL, &wait_time); select( 0, NULL, NULL, NULL, &wait_time);
} }
i = read(filedes[0], buffer, my_buffer_size);
} // end of while } // end of while
free(buffer); free(buffer);
gzclose(gzfile); gzclose(gzfile);
wait(NULL); /* Kill the zombie */ wait(NULL); /* Kill the zombie */
} else { } else {
stderr = devnull; stderr = devnull;
close(filedes[0]); close(filedes[0]);
close(fileno(stdout)); close(fileno(stdout));
dup2(filedes[1], fileno(stdout)); dup2(filedes[1], fileno(stdout));
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0);
skipping to change at line 1112 skipping to change at line 1115
if (change_buffer_size) if (change_buffer_size)
{ {
num_clients = bftpdutmp_usercount("*"); num_clients = bftpdutmp_usercount("*");
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
else else
my_buffer_size = xfer_bufsize; my_buffer_size = xfer_bufsize;
/* Use "wb9" for maximum compression, uses more CPU time... */ /* Use "wb9" for maximum compression, uses more CPU time... */
gzfile = gzdopen(sock, "wb"); gzfile = gzdopen(sock, "wb");
while ((i = read(phile, buffer, my_buffer_size))) { i = read(phile, buffer, my_buffer_size);
while (i > 0) {
gzwrite(gzfile, buffer, i); gzwrite(gzfile, buffer, i);
test_abort(1, phile, sock); test_abort(1, phile, sock);
if (change_buffer_size) if (change_buffer_size)
{ {
new_num_clients = bftpdutmp_usercount("*"); new_num_clients = bftpdutmp_usercount("*");
if ( new_num_clients != num_clients ) if ( new_num_clients != num_clients )
{ {
num_clients = new_num_clients; num_clients = new_num_clients;
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
} }
/* pause between transfers */ /* pause between transfers */
if (xfer_delay) if (xfer_delay)
{ {
wait_time.tv_sec = 0; wait_time.tv_sec = 0;
wait_time.tv_usec = xfer_delay; wait_time.tv_usec = xfer_delay;
select( 0, NULL, NULL, NULL, &wait_time); select( 0, NULL, NULL, NULL, &wait_time);
} }
i = read(phile, buffer, my_buffer_size)
} }
free(buffer); free(buffer);
close(phile); close(phile);
gzclose(gzfile); gzclose(gzfile);
break; break;
#endif #endif
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
case DO_GZUNZIP: case DO_GZUNZIP:
if ( dataconn() ) if ( dataconn() )
skipping to change at line 1235 skipping to change at line 1240
return; return;
} }
if (change_buffer_size) if (change_buffer_size)
{ {
num_clients = bftpdutmp_usercount("*"); num_clients = bftpdutmp_usercount("*");
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
else else
my_buffer_size = xfer_bufsize; my_buffer_size = xfer_bufsize;
while ((i = read(phile, buffer, my_buffer_size))) { i = read(phile, buffer, my_buffer_size);
while (i > 0) {
if (test_abort(1, phile, sock)) { if (test_abort(1, phile, sock)) {
free(buffer); free(buffer);
return; return;
} }
if (xfertype == TYPE_ASCII) { if (xfertype == TYPE_ASCII) {
buffer[i] = '\0'; buffer[i] = '\0';
i += replace(buffer, "\n", "\r\n", xfer_bufsize); i += replace(buffer, "\n", "\r\n", xfer_bufsi
} ze);
}
send_status = send(sock, buffer, i, 0); send_status = send(sock, buffer, i, 0);
// check for dropped connection // check for dropped connection
if (send_status < 0) if (send_status < 0)
{ {
free(buffer); free(buffer);
close(phile); close(phile);
close(sock); close(sock);
alarm(control_timeout); alarm(control_timeout);
control_printf(SL_SUCCESS, "426 Transfer abor ted."); control_printf(SL_SUCCESS, "426 Transfer abor ted.");
control_printf(SL_SUCCESS, "226 Aborted."); control_printf(SL_SUCCESS, "226 Aborted.");
skipping to change at line 1274 skipping to change at line 1280
my_buffer_size = get_buffer_size(num_clients); my_buffer_size = get_buffer_size(num_clients);
} }
/* pause between transfers */ /* pause between transfers */
if (xfer_delay) if (xfer_delay)
{ {
wait_time.tv_sec = 0; wait_time.tv_sec = 0;
wait_time.tv_usec = xfer_delay; wait_time.tv_usec = xfer_delay;
select( 0, NULL, NULL, NULL, &wait_time); select( 0, NULL, NULL, NULL, &wait_time);
} }
i = read(phile, buffer, my_buffer_size);
} // end of while } // end of while
free(buffer); free(buffer);
} }
close(phile); close(phile);
close(sock); close(sock);
offset = 0; offset = 0;
alarm(control_timeout); alarm(control_timeout);
control_printf(SL_SUCCESS, "226 File transmission successful."); control_printf(SL_SUCCESS, "226 File transmission successful.");
bftpd_log("File transmission of '%s' successful.\n", filename); bftpd_log("File transmission of '%s' successful.\n", filename);
 End of changes. 9 change blocks. 
10 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)