Example #1
0
void
init_connection(struct vsf_session* p_sess)
{
  if (tunable_setproctitle_enable)
  {
    vsf_sysutil_setproctitle("not logged in");
  }
  
  #ifdef VSF_BUILD_SQLITE
  /* In stealth mode we wont answer the connection unless the remote host
   * is known to our database.
   */
  if (tunable_sqlite_enable && tunable_stealth_mode)
  {
    int retval = vsf_db_check_remote_host(&p_sess->remote_ip_str);
    if (retval == 0)
    {
      /* The IP check failed we drop the connection silently. */
      vsf_sysutil_shutdown_read_failok(VSFTP_COMMAND_FD);
      vsf_sysutil_exit(0);        
    }
  }
  #endif
    
  /* Before we talk to the remote, make sure an alarm is set up in case
   * writing the initial greetings should block.
   */
  vsf_cmdio_set_alarm(p_sess);
  emit_greeting(p_sess);
  parse_username_password(p_sess);
}
Example #2
0
static void
handle_alarm_timeout(void* p_private)
{
  struct vsf_session* p_sess = (struct vsf_session*) p_private;
  p_sess->idle_timeout = 1;
  vsf_sysutil_activate_noblock(VSFTP_COMMAND_FD);
  vsf_sysutil_shutdown_read_failok(VSFTP_COMMAND_FD);
}
Example #3
0
void
vsf_cmdio_write_exit(struct vsf_session* p_sess, int status, const char* p_text)
{
  /* Unblock any readers on the dying control channel. This is needed for SSL
   * connections, where the SSL control channel slave is in a separate
   * process.
   */
  vsf_sysutil_shutdown_read_failok(VSFTP_COMMAND_FD);
  ftp_write_text_common(p_sess, status, p_text, 1, ' ');
  vsf_sysutil_shutdown_failok(VSFTP_COMMAND_FD);
  vsf_sysutil_exit(0);
}
Example #4
0
static void
handle_sigalrm(void* p_private)
{
  struct vsf_session* p_sess = (struct vsf_session*) p_private;
  if (!p_sess->data_progress)
  {
    p_sess->data_timeout = 1;
    vsf_sysutil_shutdown_failok(p_sess->data_fd);
    vsf_sysutil_shutdown_read_failok(VSFTP_COMMAND_FD);
    vsf_sysutil_activate_noblock(VSFTP_COMMAND_FD);
  }
  else
  {
    p_sess->data_progress = 0;
    start_data_alarm(p_sess);
  }
}