static void emit_greeting(struct vsf_session* p_sess) { struct mystr str_log_line = INIT_MYSTR; /* Check for client limits (standalone mode only) */ if (tunable_max_clients > 0 && p_sess->num_clients > tunable_max_clients) { str_alloc_text(&str_log_line, "Connection refused: too many sessions."); vsf_log_line(p_sess, kVSFLogEntryConnection, &str_log_line); vsf_cmdio_write_noblock(p_sess, FTP_TOO_MANY_USERS, "There are too many connected users, please try later."); vsf_sysutil_exit(0); } if (tunable_max_per_ip > 0 && p_sess->num_this_ip > tunable_max_per_ip) { str_alloc_text(&str_log_line, "Connection refused: too many sessions for this address."); vsf_log_line(p_sess, kVSFLogEntryConnection, &str_log_line); vsf_cmdio_write_noblock(p_sess, FTP_IP_LIMIT, "There are too many connections from your internet address."); vsf_sysutil_exit(0); } if (!p_sess->tcp_wrapper_ok) { str_alloc_text(&str_log_line, "Connection refused: tcp_wrappers denial."); vsf_log_line(p_sess, kVSFLogEntryConnection, &str_log_line); vsf_cmdio_write_noblock(p_sess, FTP_IP_DENY, "Service not available."); vsf_sysutil_exit(0); } vsf_log_line(p_sess, kVSFLogEntryConnection, &str_log_line); if (!str_isempty(&p_sess->banner_str)) { vsf_banner_write(p_sess, &p_sess->banner_str, FTP_GREET); str_free(&p_sess->banner_str); vsf_cmdio_write(p_sess, FTP_GREET, ""); } else if (tunable_ftpd_banner == 0) { vsf_cmdio_write(p_sess, FTP_GREET, "(vsFTPd " VSF_VERSION ")"); } else { vsf_cmdio_write(p_sess, FTP_GREET, tunable_ftpd_banner); } }
static void emit_greeting(struct vsf_session* p_sess) { if (!str_isempty(&p_sess->banner_str)) { vsf_banner_write(p_sess, &p_sess->banner_str, FTP_GREET); str_free(&p_sess->banner_str); vsf_cmdio_write(p_sess, FTP_GREET, ""); } else if (tunable_ftpd_banner == 0) { vsf_cmdio_write(p_sess, FTP_GREET, "(vsFTPd " VSF_VERSION ")"); } else { vsf_cmdio_write(p_sess, FTP_GREET, tunable_ftpd_banner); } }
void vsf_banner_dir_changed(struct vsf_session* p_sess, int ftpcode) { struct mystr dir_str = INIT_MYSTR; /* Do nothing if .message support is off */ if (!tunable_dirmessage_enable) { return; } if (p_sess->p_visited_dir_list == 0) { struct mystr_list the_list = INIT_STRLIST; p_sess->p_visited_dir_list = vsf_sysutil_malloc(sizeof(struct mystr_list)); *p_sess->p_visited_dir_list = the_list; } str_getcwd(&dir_str); /* Do nothing if we already visited this directory */ if (!str_list_contains_str(p_sess->p_visited_dir_list, &dir_str)) { /* Just in case, cap the max. no of visited directories we'll remember */ if (str_list_get_length(p_sess->p_visited_dir_list) < VSFTP_MAX_VISIT_REMEMBER) { str_list_add(p_sess->p_visited_dir_list, &dir_str, 0); } /* If we have a .message file, squirt it out prepended by the ftpcode and * the continuation mark '-' */ { struct mystr msg_file_str = INIT_MYSTR; if (tunable_message_file) { (void) str_fileread(&msg_file_str, tunable_message_file, VSFTP_MAX_MSGFILE_SIZE); } vsf_banner_write(p_sess, &msg_file_str, ftpcode); str_free(&msg_file_str); } } str_free(&dir_str); }