"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "main.c" between
bftpd-6.0.tar.gz and bftpd-6.1.tar.gz

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

main.c  (bftpd-6.0):main.c  (bftpd-6.1)
skipping to change at line 65 skipping to change at line 65
#include "logging.h" #include "logging.h"
#include "dirlist.h" #include "dirlist.h"
#include "bftpdutmp.h" #include "bftpdutmp.h"
#include "options.h" #include "options.h"
#include "login.h" #include "login.h"
#include "list.h" #include "list.h"
int global_argc; int global_argc;
char **global_argv; char **global_argv;
char **my_argv_list; // jesse char **my_argv_list; // jesse
char *configpath;
int daemonmode;
char *pre_write_script;
char *post_write_script;
struct sockaddr_in name; struct sockaddr_in name;
int isparent = 1; int isparent = 1;
int listensocket, sock; int listensocket, main_sock;
FILE *passwdfile = NULL, *groupfile = NULL, *devnull; FILE *passwdfile = NULL, *groupfile = NULL, *devnull;
struct sockaddr_in remotename; struct sockaddr_in remotename;
char *remotehostname = NULL; char *remotehostname = NULL;
int control_timeout, data_timeout; int control_timeout, data_timeout;
int alarm_type = 0; int alarm_type = 0;
struct bftpd_list_element *child_list; struct bftpd_list_element *child_list;
/* Command line parameters */ /* Command line parameters */
char *configpath = PATH_BFTPD_CONF; char *configpath = PATH_BFTPD_CONF;
skipping to change at line 109 skipping to change at line 114
if (groupfile) if (groupfile)
fclose(groupfile); fclose(groupfile);
config_end(); config_end();
bftpd_log("Quitting.\n"); bftpd_log("Quitting.\n");
bftpd_statuslog(1, 0, "quit"); bftpd_statuslog(1, 0, "quit");
bftpdutmp_end(); bftpdutmp_end();
log_end(); log_end();
login_end(); login_end();
bftpd_cwd_end(); bftpd_cwd_end();
if (daemonmode) { if (daemonmode) {
close(sock); close(main_sock);
close(0); close(0);
close(1); close(1);
close(2); close(2);
} }
} }
/* /*
This function causes the program to This function causes the program to
re-read parts of the config file. re-read parts of the config file.
skipping to change at line 281 skipping to change at line 286
/* check for open stdin, stdout, stderr */ /* check for open stdin, stdout, stderr */
if (listensocket >= 3) if (listensocket >= 3)
{ {
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
close(i); /* Remove fd pointing to the cons ole */ close(i); /* Remove fd pointing to the cons ole */
open("/dev/null", O_RDWR); /* Create fd pointing now here */ open("/dev/null", O_RDWR); /* Create fd pointing now here */
} }
} }
my_length = sizeof(new); my_length = sizeof(new);
while ((sock = accept(listensocket, (struct sockaddr *) &new, &my _length))) { while ((main_sock = accept(listensocket, (struct sockaddr *) &new , &my_length))) {
pid_t pid; pid_t pid;
/* If accept() becomes interrupted by SIGCHLD, it will re turn -1. /* If accept() becomes interrupted by SIGCHLD, it will re turn -1.
* So in order not to create a child process when that ha ppens, * So in order not to create a child process when that ha ppens,
* we have to check if accept() returned an error. * we have to check if accept() returned an error.
*/ */
if (sock > 0) { if (main_sock > 0) {
pid = fork(); pid = fork();
if (!pid) { /* child */ if (!pid) { /* child */
close(0); close(0);
close(1); close(1);
close(2); close(2);
isparent = 0; isparent = 0;
dup2(sock, fileno(stdin)); dup2(main_sock, fileno(stdin));
dup2(sock, fileno(stderr)); dup2(main_sock, fileno(stderr));
break; break;
} else { /* parent */ } else { /* parent */
struct bftpd_childpid *tmp_pid = malloc(s izeof(struct bftpd_childpid)); struct bftpd_childpid *tmp_pid = malloc(s izeof(struct bftpd_childpid));
tmp_pid->pid = pid; tmp_pid->pid = pid;
tmp_pid->sock = sock; tmp_pid->sock = main_sock;
bftpd_list_add(&child_list, tmp_pid); bftpd_list_add(&child_list, tmp_pid);
} }
} }
} }
} }
/* Child only. From here on... */ /* Child only. From here on... */
devnull = fopen("/dev/null", "w"); devnull = fopen("/dev/null", "w");
if (! devnull) if (! devnull)
fprintf(stderr, "Fopen failed: %s\n", strerror(errno)); fprintf(stderr, "Fopen failed: %s\n", strerror(errno));
global_argc = argc; global_argc = argc;
global_argv = argv; global_argv = argv;
if ( (! global_argv) || (! global_argv[0] ) )
{
fprintf(stderr, "Process was run with no name.\n");
exit(1);
}
init_everything(); init_everything();
atexit(end_child); atexit(end_child);
signal(SIGTERM, handler_sigterm); signal(SIGTERM, handler_sigterm);
signal(SIGALRM, handler_sigalrm); signal(SIGALRM, handler_sigalrm);
/* If we do not have getpwnam() for some reason, then /* If we do not have getpwnam() for some reason, then
we must use FILE_AUTH or exit. */ we must use FILE_AUTH or exit. */
#ifdef NO_GETPWNAM #ifdef NO_GETPWNAM
{ {
char *file_auth_option; char *file_auth_option;
 End of changes. 8 change blocks. 
7 lines changed or deleted 17 lines changed or added

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