Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 200811 | Differences between
and this patch

Collapse All | Expand All

(-)vsftpd-2.0.6.orig/features.c (-1 / +9 lines)
Lines 42-48 Link Here
42
  vsf_cmdio_write_raw(p_sess, " REST STREAM\r\n");
42
  vsf_cmdio_write_raw(p_sess, " REST STREAM\r\n");
43
  vsf_cmdio_write_raw(p_sess, " SIZE\r\n");
43
  vsf_cmdio_write_raw(p_sess, " SIZE\r\n");
44
  vsf_cmdio_write_raw(p_sess, " TVFS\r\n");
44
  vsf_cmdio_write_raw(p_sess, " TVFS\r\n");
45
  vsf_cmdio_write_raw(p_sess, " UTF8\r\n");
45
  if (tunable_charset_filter_enable)
46
  {
47
    vsf_cmdio_write_raw(p_sess, " UTF8 OFF\r\n");
48
    vsf_cmdio_write_raw(p_sess, " UTF8 ON\r\n");
49
  }
50
  else
51
  {
52
    vsf_cmdio_write_raw(p_sess, " UTF8\r\n");
53
  }
46
  vsf_cmdio_write(p_sess, FTP_FEAT, "End");
54
  vsf_cmdio_write(p_sess, FTP_FEAT, "End");
47
}
55
}
48
56
(-)vsftpd-2.0.6.orig/main.c (+18 lines)
Lines 22-27 Link Here
22
#include "tcpwrap.h"
22
#include "tcpwrap.h"
23
#include "vsftpver.h"
23
#include "vsftpver.h"
24
#include "ssl.h"
24
#include "ssl.h"
25
#include "iconv.h"
25
26
26
/*
27
/*
27
 * Forward decls of helper functions
28
 * Forward decls of helper functions
Lines 34-39 Link Here
34
int
35
int
35
main(int argc, const char* argv[])
36
main(int argc, const char* argv[])
36
{
37
{
38
  iconv_t cd;
37
  struct vsf_session the_session =
39
  struct vsf_session the_session =
38
  {
40
  {
39
    /* Control connection */
41
    /* Control connection */
Lines 106-111 Link Here
106
    }
108
    }
107
    vsf_sysutil_free(p_statbuf);
109
    vsf_sysutil_free(p_statbuf);
108
  }
110
  }
111
  if (tunable_charset_filter_enable == 1)
112
  {
113
    if ((cd = iconv_open(tunable_charset_client, tunable_charset_server))!=(iconv_t)-1)
114
    {
115
      iconv_close(cd);
116
      tunable_charset_filter_enable=1;
117
    }
118
      else
119
    {
120
      tunable_charset_filter_enable = 0;
121
    }
122
  }
123
  /* Save tunable_charset_filter_enable value to protect 
124
   * from runtime change when it is disabled 
125
   */
126
  tunable_charset_filter_config_enable = tunable_charset_filter_enable;
109
  /* Resolve pasv_address if required */
127
  /* Resolve pasv_address if required */
110
  if (tunable_pasv_address && tunable_pasv_addr_resolve)
128
  if (tunable_pasv_address && tunable_pasv_addr_resolve)
111
  {
129
  {
(-)vsftpd-2.0.6.orig/opts.c (-4 / +38 lines)
Lines 10-27 Link Here
10
#include "ftpcodes.h"
10
#include "ftpcodes.h"
11
#include "ftpcmdio.h"
11
#include "ftpcmdio.h"
12
#include "session.h"
12
#include "session.h"
13
#include "tunables.h"
13
14
14
void
15
void
15
handle_opts(struct vsf_session* p_sess)
16
handle_opts(struct vsf_session* p_sess)
16
{
17
{
17
  str_upper(&p_sess->ftp_arg_str);
18
  struct mystr opts = INIT_MYSTR;
18
  if (str_equal_text(&p_sess->ftp_arg_str, "UTF8 ON"))
19
  struct mystr prm  = INIT_MYSTR;
20
21
  str_copy(&opts, &p_sess->ftp_arg_str);
22
  str_upper(&opts);
23
  str_split_char(&opts, &prm, ' ');
24
25
  if (str_equal_text(&opts, "UTF8"))
19
  {
26
  {
20
    vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode.");
27
    if (str_equal_text(&prm, "ON"))
28
    {
29
      if (tunable_charset_filter_config_enable)
30
      {
31
        tunable_charset_filter_enable = 0;
32
        vsf_cmdio_write(p_sess, FTP_OPTSOK, "UTF8 option is On.");
33
      }
34
      else
35
      {
36
        vsf_cmdio_write(p_sess, FTP_OPTSOK, "Always in UTF8 mode.");
37
      }
38
    }
39
    else
40
    if (tunable_charset_filter_config_enable)
41
    {
42
      if (str_equal_text(&prm, "OFF"))
43
      {
44
        tunable_charset_filter_enable = 1;
45
        vsf_cmdio_write(p_sess, FTP_OPTSOK, "UTF8 option is Off.");
46
      }
47
      else
48
      {
49
        vsf_cmdio_write(p_sess, FTP_BADOPTS, "Invalid UTF8 option.");
50
      }
51
    }
52
    else
53
    {
54
      vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
55
    }
21
  }
56
  }
22
  else
57
  else
23
  {
58
  {
24
    vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
59
    vsf_cmdio_write(p_sess, FTP_BADOPTS, "Option not understood.");
25
  }
60
  }
26
}
61
}
27
(-)vsftpd-2.0.6.orig/parseconf.c (+3 lines)
Lines 102-107 Link Here
102
  { "debug_ssl", &tunable_debug_ssl },
102
  { "debug_ssl", &tunable_debug_ssl },
103
  { "require_cert", &tunable_require_cert },
103
  { "require_cert", &tunable_require_cert },
104
  { "validate_cert", &tunable_validate_cert },
104
  { "validate_cert", &tunable_validate_cert },
105
  { "charset_filter_enable", &tunable_charset_filter_enable },
105
  { 0, 0 }
106
  { 0, 0 }
106
};
107
};
107
108
Lines 173-178 Link Here
173
  { "rsa_private_key_file", &tunable_rsa_private_key_file },
174
  { "rsa_private_key_file", &tunable_rsa_private_key_file },
174
  { "dsa_private_key_file", &tunable_dsa_private_key_file },
175
  { "dsa_private_key_file", &tunable_dsa_private_key_file },
175
  { "ca_certs_file", &tunable_ca_certs_file },
176
  { "ca_certs_file", &tunable_ca_certs_file },
177
  { "charset_client", &tunable_charset_client },
178
  { "charset_server", &tunable_charset_server },
176
  { 0, 0 }
179
  { 0, 0 }
177
};
180
};
178
181
(-)vsftpd-2.0.6.orig/postlogin.c (+11 lines)
Lines 1785-1790 Link Here
1785
    vsf_cmdio_write_raw(p_sess, vsf_sysutil_ulong_to_str(p_sess->num_clients));
1785
    vsf_cmdio_write_raw(p_sess, vsf_sysutil_ulong_to_str(p_sess->num_clients));
1786
    vsf_cmdio_write_raw(p_sess, "\r\n");
1786
    vsf_cmdio_write_raw(p_sess, "\r\n");
1787
  }
1787
  }
1788
  if (tunable_charset_filter_enable)
1789
  {
1790
    vsf_cmdio_write_raw(p_sess, "     Server charset is ");
1791
    vsf_cmdio_write_raw(p_sess, tunable_charset_server);
1792
    vsf_cmdio_write_raw(p_sess, "\r\n");
1793
    vsf_cmdio_write_raw(p_sess, "     Remote charset is ");
1794
    vsf_cmdio_write_raw(p_sess, tunable_charset_client);
1795
    vsf_cmdio_write_raw(p_sess, "\r\n");
1796
    vsf_cmdio_write_raw(p_sess, "     Use OPTS UTF8 ON to enable UTF8!!");
1797
    vsf_cmdio_write_raw(p_sess, "\r\n");
1798
  }
1788
  vsf_cmdio_write_raw(p_sess,
1799
  vsf_cmdio_write_raw(p_sess,
1789
    "     vsFTPd " VSF_VERSION " - secure, fast, stable\r\n");
1800
    "     vsFTPd " VSF_VERSION " - secure, fast, stable\r\n");
1790
  vsf_cmdio_write(p_sess, FTP_STATOK, "End of status");
1801
  vsf_cmdio_write(p_sess, FTP_STATOK, "End of status");
(-)vsftpd-2.0.6.orig/readwrite.c (+10 lines)
Lines 15-25 Link Here
15
#include "privsock.h"
15
#include "privsock.h"
16
#include "defs.h"
16
#include "defs.h"
17
#include "sysutil.h"
17
#include "sysutil.h"
18
#include "str.h"
19
#include "tunables.h"
18
20
19
int
21
int
20
ftp_write_str(const struct vsf_session* p_sess, const struct mystr* p_str,
22
ftp_write_str(const struct vsf_session* p_sess, const struct mystr* p_str,
21
              enum EVSFRWTarget target)
23
              enum EVSFRWTarget target)
22
{
24
{
25
  if(tunable_charset_filter_enable)
26
  {
27
    str_iconv_write(p_str);
28
  }
23
  if (target == kVSFRWData)
29
  if (target == kVSFRWData)
24
  {
30
  {
25
    if (p_sess->data_use_ssl)
31
    if (p_sess->data_use_ssl)
Lines 94-98 Link Here
94
    str_netfd_alloc(
100
    str_netfd_alloc(
95
      p_str, VSFTP_COMMAND_FD, '\n', p_buf, VSFTP_MAX_COMMAND_LINE);
101
      p_str, VSFTP_COMMAND_FD, '\n', p_buf, VSFTP_MAX_COMMAND_LINE);
96
  }
102
  }
103
  if(tunable_charset_filter_enable)
104
  {
105
    str_iconv_read(p_str);
106
  }
97
}
107
}
98
108
(-)vsftpd-2.0.6.orig/str.c (+106 lines)
Lines 19-24 Link Here
19
/* Ick. Its for die() */
19
/* Ick. Its for die() */
20
#include "utility.h"
20
#include "utility.h"
21
#include "sysutil.h"
21
#include "sysutil.h"
22
#include "stdio.h"
23
#include "errno.h"
24
#include "tunables.h"
25
26
/* For iconv read and write */
27
#define ICONV_READ 0
28
#define ICONV_WRITE 1
22
29
23
/* File local functions */
30
/* File local functions */
24
static void str_split_text_common(struct mystr* p_src, struct mystr* p_rhs,
31
static void str_split_text_common(struct mystr* p_src, struct mystr* p_rhs,
Lines 666-668 Link Here
666
  }
673
  }
667
}
674
}
668
675
676
void
677
str_iconv_inout(struct mystr* p_str, char io_direction)
678
{
679
  iconv_t cd;
680
  char *from_buf;
681
  char *dyn_from_buf, *to_buf, *dyn_to_buf;
682
  size_t from_len;
683
  size_t dyn_from_len, to_len, dyn_to_len;
684
  size_t print_buf;
685
686
  from_buf = str_getbuf(p_str);
687
  from_len = str_getlen(p_str);
688
689
  p_str->p_buf = 0;
690
  str_free(p_str);
691
692
  private_str_alloc_memchunk(p_str, from_buf, from_len);
693
  str_reserve(p_str, 2*from_len);
694
  p_str->len=2*from_len;
695
  vsf_sysutil_memclr(p_str->p_buf, p_str->len+1);
696
  dyn_from_buf = from_buf;
697
  dyn_from_len = from_len;
698
  to_buf = p_str->p_buf;
699
  dyn_to_buf = to_buf;
700
  to_len = p_str->len;
701
  dyn_to_len = to_len;
702
703
  if(io_direction == ICONV_READ)
704
  {
705
    if((cd = vsf_sysutil_iconv_init_read())==(iconv_t)(-1))
706
    {
707
      bug("str_iconv_read");
708
    }
709
  }
710
  else
711
  {
712
    if((cd = vsf_sysutil_iconv_init_write())==(iconv_t)(-1))
713
    {
714
      bug("str_iconv_write");
715
    }
716
  }
717
718
  while(vsf_sysutil_iconv(cd, &dyn_from_buf, &dyn_from_len, &dyn_to_buf, &dyn_to_len)==(size_t)(-1))
719
  {
720
    switch(errno)
721
    {
722
    case EILSEQ:
723
      if((dyn_to_buf<to_buf+to_len)&&(dyn_to_buf>=to_buf))
724
      {
725
        vsf_sysutil_memcpy(dyn_to_buf, dyn_from_buf, 1);
726
        dyn_to_buf+=1;
727
        dyn_to_len-=1;
728
        dyn_from_buf+=1;
729
        dyn_from_len = from_buf + from_len -dyn_from_buf;
730
        if(dyn_from_len==0) break;
731
      }
732
      else
733
      {
734
        break;
735
      }
736
      continue;
737
738
    case EINVAL:
739
      break;
740
741
    case E2BIG:
742
      str_reserve(p_str, to_len+dyn_from_len);
743
      p_str->len=to_len+dyn_from_len;
744
      dyn_to_len+=dyn_from_len;
745
      dyn_to_buf = p_str->p_buf + (dyn_to_buf-to_buf);
746
      to_buf = p_str->p_buf;
747
      to_len = p_str->len;
748
      continue;
749
750
    default:
751
      die("iconv set strange errno. Should not happenned!");
752
      break;
753
    }
754
    break;
755
  }
756
757
  str_trunc(p_str, (p_str->len)-dyn_to_len);
758
759
  vsf_sysutil_iconv_close(cd);
760
  vsf_sysutil_free(from_buf);
761
}
762
763
void
764
str_iconv_read(struct mystr* p_str)
765
{
766
  str_iconv_inout(p_str, ICONV_READ);
767
}
768
769
void
770
str_iconv_write(struct mystr* p_str)
771
{
772
  str_iconv_inout(p_str, ICONV_WRITE);
773
}
774
(-)vsftpd-2.0.6.orig/str.h (+4 lines)
Lines 120-124 Link Here
120
int str_contains_line(const struct mystr* p_str,
120
int str_contains_line(const struct mystr* p_str,
121
                      const struct mystr* p_line_str);
121
                      const struct mystr* p_line_str);
122
122
123
/* Locale string conversion */
124
void str_iconv_read(struct mystr* p_str);
125
void str_iconv_write(struct mystr* p_str);
126
123
#endif /* VSFTP_STR_H */
127
#endif /* VSFTP_STR_H */
124
128
(-)vsftpd-2.0.6.orig/sysutil.c (+61 lines)
Lines 53-58 Link Here
53
#include <syslog.h>
53
#include <syslog.h>
54
#include <utime.h>
54
#include <utime.h>
55
#include <netdb.h>
55
#include <netdb.h>
56
#include <iconv.h>
56
57
57
/* Private variables to this file */
58
/* Private variables to this file */
58
/* Current umask() */
59
/* Current umask() */
Lines 2650-2652 Link Here
2650
  return utime(p_file, &new_times);
2651
  return utime(p_file, &new_times);
2651
}
2652
}
2652
2653
2654
iconv_t
2655
vsf_sysutil_iconv_init_read(void)
2656
{
2657
  iconv_t cd;
2658
2659
  if((cd=iconv_open(tunable_charset_server, tunable_charset_client))==(iconv_t)(-1))
2660
  {
2661
    if(errno==EINVAL)
2662
    {
2663
      vsf_sysutil_free(tunable_charset_server);
2664
      tunable_charset_server=vsf_sysutil_strdup("UTF8");
2665
      vsf_sysutil_free(tunable_charset_client);
2666
      tunable_charset_client=vsf_sysutil_strdup("UTF8");
2667
      return iconv_open(tunable_charset_server, tunable_charset_client);
2668
    }
2669
    else
2670
    {
2671
      bug("iconv_open error!");
2672
    }
2673
  }
2674
2675
  return cd;
2676
}
2677
2678
iconv_t
2679
vsf_sysutil_iconv_init_write(void)
2680
{
2681
  iconv_t cd;
2682
2683
  if((cd=iconv_open(tunable_charset_client, tunable_charset_server))==(iconv_t)(-1))
2684
  {
2685
    if(errno==EINVAL)
2686
    {
2687
      vsf_sysutil_free(tunable_charset_server);
2688
      tunable_charset_server=vsf_sysutil_strdup("UTF8");
2689
      vsf_sysutil_free(tunable_charset_client);
2690
      tunable_charset_client=vsf_sysutil_strdup("UTF8");
2691
      return iconv_open(tunable_charset_server, tunable_charset_client);
2692
    }
2693
    else
2694
    {
2695
      bug("iconv_open error!");
2696
    }
2697
  }
2698
  return cd;
2699
}
2700
2701
int
2702
vsf_sysutil_iconv_close(iconv_t cd)
2703
{
2704
  return iconv_close(cd);
2705
}
2706
2707
2708
size_t
2709
vsf_sysutil_iconv(iconv_t cd, char **inbuf, size_t *inbytes, char **outbuf, size_t *outbytes)
2710
{
2711
  return iconv(cd, inbuf, inbytes, outbuf, outbytes);
2712
}
2713
(-)vsftpd-2.0.6.orig/sysutil.h (+15 lines)
Lines 7-12 Link Here
7
#include "filesize.h"
7
#include "filesize.h"
8
#endif
8
#endif
9
9
10
#ifndef VSF_SYSUTIL_ICONV_H
11
#include "iconv.h"
12
#endif
13
14
#ifndef VSF_SYSUTIL_STDDEF_H
15
#include "stddef.h"
16
#endif
17
10
/* Return value queries */
18
/* Return value queries */
11
int vsf_sysutil_retval_is_error(int retval);
19
int vsf_sysutil_retval_is_error(int retval);
12
enum EVSFSysUtilError
20
enum EVSFSysUtilError
Lines 330-334 Link Here
330
void vsf_sysutil_sleep(double seconds);
338
void vsf_sysutil_sleep(double seconds);
331
int vsf_sysutil_setmodtime(const char* p_file, long the_time, int is_localtime);
339
int vsf_sysutil_setmodtime(const char* p_file, long the_time, int is_localtime);
332
340
341
/* Locale string conversion */
342
343
iconv_t vsf_sysutil_iconv_init_read(void);
344
iconv_t vsf_sysutil_iconv_init_write(void);
345
int vsf_sysutil_iconv_close(iconv_t cd);
346
size_t vsf_sysutil_iconv(iconv_t cd, char **inbuf, size_t *inbytes, char **outbuf, size_t *outbytes);
347
333
#endif /* VSF_SYSUTIL_H */
348
#endif /* VSF_SYSUTIL_H */
334
349
(-)vsftpd-2.0.6.orig/tunables.c (+4 lines)
Lines 68-73 Link Here
68
int tunable_tilde_user_enable = 0;
68
int tunable_tilde_user_enable = 0;
69
int tunable_force_anon_logins_ssl = 0;
69
int tunable_force_anon_logins_ssl = 0;
70
int tunable_force_anon_data_ssl = 0;
70
int tunable_force_anon_data_ssl = 0;
71
int tunable_charset_filter_enable = 0;
72
int tunable_charset_filter_config_enable = 0;
71
int tunable_mdtm_write = 1;
73
int tunable_mdtm_write = 1;
72
int tunable_lock_upload_files = 1;
74
int tunable_lock_upload_files = 1;
73
int tunable_pasv_addr_resolve = 0;
75
int tunable_pasv_addr_resolve = 0;
Lines 131-134 Link Here
131
const char* tunable_rsa_private_key_file = 0;
133
const char* tunable_rsa_private_key_file = 0;
132
const char* tunable_dsa_private_key_file = 0;
134
const char* tunable_dsa_private_key_file = 0;
133
const char* tunable_ca_certs_file = 0;
135
const char* tunable_ca_certs_file = 0;
136
const char* tunable_charset_client = "UTF-8";
137
const char* tunable_charset_server = "UTF-8";
134
138
(-)vsftpd-2.0.6.orig/tunables.h (+4 lines)
Lines 64-69 Link Here
64
extern int tunable_tilde_user_enable;         /* Support e.g. ~chris */
64
extern int tunable_tilde_user_enable;         /* Support e.g. ~chris */
65
extern int tunable_force_anon_logins_ssl;     /* Require anon logins use SSL */
65
extern int tunable_force_anon_logins_ssl;     /* Require anon logins use SSL */
66
extern int tunable_force_anon_data_ssl;       /* Require anon data uses SSL */
66
extern int tunable_force_anon_data_ssl;       /* Require anon data uses SSL */
67
extern int tunable_charset_filter_enable;     /* Enable charset transfer (may be changed at runtime if config allows) */
68
extern int tunable_charset_filter_config_enable; /* Is charset transfer enabled at config? */
67
extern int tunable_mdtm_write;                /* Allow MDTM to set timestamps */
69
extern int tunable_mdtm_write;                /* Allow MDTM to set timestamps */
68
extern int tunable_lock_upload_files;         /* Lock uploading files */
70
extern int tunable_lock_upload_files;         /* Lock uploading files */
69
extern int tunable_pasv_addr_resolve;         /* DNS resolve pasv_addr */
71
extern int tunable_pasv_addr_resolve;         /* DNS resolve pasv_addr */
Lines 125-130 Link Here
125
extern const char* tunable_rsa_private_key_file;
127
extern const char* tunable_rsa_private_key_file;
126
extern const char* tunable_dsa_private_key_file;
128
extern const char* tunable_dsa_private_key_file;
127
extern const char* tunable_ca_certs_file;
129
extern const char* tunable_ca_certs_file;
130
extern const char* tunable_charset_client;
131
extern const char* tunable_charset_server;
128
132
129
#endif /* VSF_TUNABLES_H */
133
#endif /* VSF_TUNABLES_H */
130
134
(-)vsftpd-2.0.6.orig/vsftpd.conf.5 (-2 / +29 lines)
Lines 112-117 Link Here
112
112
113
Default: NO
113
Default: NO
114
.TP
114
.TP
115
.B charset_filter_enable
116
When enabled, vsftpd will setup a character set filter. This filter will be
117
disabled per client on OPTS UTF8 ON request and may be enabled again with
118
OPTS UTF8 OFF.
119
.B Warning!
120
This option brokes RFC2640 (FTP i18n), but it seems to be the only way to
121
support dumb non-UTF8 clients. It is not recommended because it depends on the
122
implementation of external glibc library. vsftpd can't ensure the security.
123
124
Default: NO
125
.TP
115
.B check_shell
126
.B check_shell
116
Note! This option only has an effect for non-PAM builds of vsftpd. If disabled,
127
Note! This option only has an effect for non-PAM builds of vsftpd. If disabled,
117
vsftpd will not check /etc/shells for a valid user shell for local logins.
128
vsftpd will not check /etc/shells for a valid user shell for local logins.
Lines 591-598 Link Here
591
Default: 0 (unlimited)
602
Default: 0 (unlimited)
592
.TP
603
.TP
593
.B anon_umask
604
.B anon_umask
594
The value that the umask for file creation is set to for anonymous users. NOTE! If you want to specify octal values, remember the "0" prefix otherwise the
605
The value that the umask for file creation is set to for anonymous users.
595
value will be treated as a base 10 integer!
606
NOTE! If you want to specify octal values, remember the "0" prefix otherwise
607
the value will be treated as a base 10 integer!
596
608
597
Default: 077
609
Default: 077
598
.TP
610
.TP
Lines 736-741 Link Here
736
748
737
Default: (none)
749
Default: (none)
738
.TP
750
.TP
751
.B charset_client
752
For this option to take effect,
753
.BR charset_filter_enable 
754
must be set. This option set the character set for client side.
755
756
Default: UTF-8
757
.TP
758
.B charset_server
759
For this option to take effect,
760
.BR charset_filter_enable 
761
must be set. This option set the character set for server side.
762
763
Default: UTF-8
764
.TP
739
.B chown_username
765
.B chown_username
740
This is the name of the user who is given ownership of anonymously uploaded
766
This is the name of the user who is given ownership of anonymously uploaded
741
files. This option is only relevant if another option,
767
files. This option is only relevant if another option,
Lines 997-1000 Link Here
997
1023
998
.SH AUTHOR
1024
.SH AUTHOR
999
scarybeasts@gmail.com
1025
scarybeasts@gmail.com
1026
wzhou@princeton.edu
1000
1027

Return to bug 200811