~ubuntu-branches/ubuntu/utopic/vsftpd/utopic-proposed

« back to all changes in this revision

Viewing changes to prelogin.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-21 14:07:17 UTC
  • mfrom: (2.3.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100621140717-fnd7ghb4s1vholau
Tags: 2.3.0~pre2-3ubuntu1
* Merge from debian unstable:
  - Use snakeoil SSL certificates and key.
  - debian/rules, debian/vsftpd.upstart: migrate vsftpd to upstart
  - Add apport hook: (LP: #513978): 
    - debian/vsftpd.apport: Added.
    - debian/control: Build-depends on dh-apport.
    - debian/rules: Add --with apport.
  - Dropped:
    + debian/patches/07_vsftpd-enable-utf8.patch: Add support for UTF8:
      Use the debian version instead.
  - Add debian/watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
static void parse_username_password(struct vsf_session* p_sess);
32
32
static void handle_user_command(struct vsf_session* p_sess);
33
33
static void handle_pass_command(struct vsf_session* p_sess);
 
34
static void handle_get(struct vsf_session* p_sess);
34
35
static void check_login_delay();
35
36
static void check_login_fails(struct vsf_session* p_sess);
36
37
 
54
55
  {
55
56
    ssl_control_handshake(p_sess);
56
57
  }
57
 
  emit_greeting(p_sess);
 
58
  if (tunable_ftp_enable)
 
59
  {
 
60
    emit_greeting(p_sess);
 
61
  }
58
62
  parse_username_password(p_sess);
59
63
}
60
64
 
117
121
  {
118
122
    vsf_cmdio_get_cmd_and_arg(p_sess, &p_sess->ftp_cmd_str,
119
123
                              &p_sess->ftp_arg_str, 1);
120
 
    if (str_equal_text(&p_sess->ftp_cmd_str, "USER"))
121
 
    {
122
 
      handle_user_command(p_sess);
123
 
    }
124
 
    else if (str_equal_text(&p_sess->ftp_cmd_str, "PASS"))
125
 
    {
126
 
      handle_pass_command(p_sess);
127
 
    }
128
 
    else if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT"))
129
 
    {
130
 
      vsf_cmdio_write_exit(p_sess, FTP_GOODBYE, "Goodbye.");
131
 
    }
132
 
    else if (str_equal_text(&p_sess->ftp_cmd_str, "FEAT"))
133
 
    {
134
 
      handle_feat(p_sess);
135
 
    }
136
 
    else if (str_equal_text(&p_sess->ftp_cmd_str, "OPTS"))
137
 
    {
138
 
      handle_opts(p_sess);
139
 
    }
140
 
    else if (tunable_ssl_enable &&
141
 
             str_equal_text(&p_sess->ftp_cmd_str, "AUTH") &&
142
 
             !p_sess->control_use_ssl)
143
 
    {
144
 
      handle_auth(p_sess);
145
 
    }
146
 
    else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "PBSZ"))
147
 
    {
148
 
      handle_pbsz(p_sess);
149
 
    }
150
 
    else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "PROT"))
151
 
    {
152
 
      handle_prot(p_sess);
153
 
    }
154
 
    else if (str_isempty(&p_sess->ftp_cmd_str) &&
155
 
             str_isempty(&p_sess->ftp_arg_str))
156
 
    {
157
 
      /* Deliberately ignore to avoid NAT device bugs. ProFTPd does the same. */
158
 
    }
159
 
    else
160
 
    {
161
 
      vsf_cmdio_write(p_sess, FTP_LOGINERR,
162
 
                      "Please login with USER and PASS.");
 
124
    if (tunable_ftp_enable)
 
125
    {
 
126
      if (str_equal_text(&p_sess->ftp_cmd_str, "USER"))
 
127
      {
 
128
        handle_user_command(p_sess);
 
129
      }
 
130
      else if (str_equal_text(&p_sess->ftp_cmd_str, "PASS"))
 
131
      {
 
132
        handle_pass_command(p_sess);
 
133
      }
 
134
      else if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT"))
 
135
      {
 
136
        vsf_cmdio_write_exit(p_sess, FTP_GOODBYE, "Goodbye.");
 
137
      }
 
138
      else if (str_equal_text(&p_sess->ftp_cmd_str, "FEAT"))
 
139
      {
 
140
        handle_feat(p_sess);
 
141
      }
 
142
      else if (str_equal_text(&p_sess->ftp_cmd_str, "OPTS"))
 
143
      {
 
144
        handle_opts(p_sess);
 
145
      }
 
146
      else if (tunable_ssl_enable &&
 
147
               str_equal_text(&p_sess->ftp_cmd_str, "AUTH") &&
 
148
               !p_sess->control_use_ssl)
 
149
      {
 
150
        handle_auth(p_sess);
 
151
      }
 
152
      else if (tunable_ssl_enable &&
 
153
               str_equal_text(&p_sess->ftp_cmd_str, "PBSZ"))
 
154
      {
 
155
        handle_pbsz(p_sess);
 
156
      }
 
157
      else if (tunable_ssl_enable &&
 
158
               str_equal_text(&p_sess->ftp_cmd_str, "PROT"))
 
159
      {
 
160
        handle_prot(p_sess);
 
161
      }
 
162
      else if (str_isempty(&p_sess->ftp_cmd_str) &&
 
163
               str_isempty(&p_sess->ftp_arg_str))
 
164
      {
 
165
        /* Deliberately ignore to avoid NAT device bugs, as per ProFTPd. */
 
166
      }
 
167
      else
 
168
      {
 
169
        vsf_cmdio_write(p_sess, FTP_LOGINERR,
 
170
                        "Please login with USER and PASS.");
 
171
      }
 
172
    }
 
173
    else if (tunable_http_enable)
 
174
    {
 
175
      if (str_equal_text(&p_sess->ftp_cmd_str, "GET"))
 
176
      {
 
177
        handle_get(p_sess);
 
178
      }
 
179
      else
 
180
      {
 
181
        vsf_cmdio_write(p_sess, FTP_LOGINERR, "Bad HTTP verb.");
 
182
      }
 
183
      vsf_sysutil_exit(0);
163
184
    }
164
185
  }
165
186
}
166
187
 
167
188
static void
 
189
handle_get(struct vsf_session* p_sess)
 
190
{
 
191
  p_sess->is_http = 1;
 
192
  str_copy(&p_sess->http_get_arg, &p_sess->ftp_arg_str);
 
193
  str_alloc_text(&p_sess->user_str, "FTP");
 
194
  str_alloc_text(&p_sess->ftp_arg_str, "<http>");
 
195
  handle_pass_command(p_sess);
 
196
}
 
197
 
 
198
static void
168
199
handle_user_command(struct vsf_session* p_sess)
169
200
{
170
201
  /* SECURITY: If we're in anonymous only-mode, immediately reject