vsftpd_koi8r-cp1251.diff
diff -Naur vsftpd-2.0.3/ls.c vsftpd-2.0.3.patched/ls.c
--- vsftpd-2.0.3/ls.c 2004-07-02 15:23:34.000000000 +0400
+++ vsftpd-2.0.3.patched/ls.c 2006-06-12 13:09:19.000000000 +0400
@@ -15,6 +15,17 @@
#include "sysutil.h"
#include "tunables.h"+#include <string.h>
+
+const int koi8r_cp1251[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 160, 155, 176, 157, 183, 159, 160, 161, 162, 184, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 168, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 169, 254, 224, 225, 246, 228, 229, 244, 227, 245, 232, 233, 234, 235, 236, 237, 238, 239, 255, 240, 241, 242, 243, 230, 226, 252, 251, 231, 248, 253, 249, 247, 250, 222, 192, 193, 214, 196, 197, 212, 195, 213, 200, 201, 202, 203, 204, 205, 206, 207, 223, 208, 209, 210, 211, 198, 194, 220, 219, 199, 216, 221, 217, 215, 218};
+void local2remote(struct mystr *local_)
+{ char* local = local_->PRIVATE_HANDS_OFF_p_buf;
+ int i;
+ for (i=0; i<local_->PRIVATE_HANDS_OFF_len; i++)
+ local[i]=(char)koi8r_cp1251[(unsigned char)local[i]];
+
+}
+
static void build_dir_line(struct mystr* p_str,
const struct mystr* p_filename_str,
const struct vsf_sysutil_statbuf* p_stat);
@@ -432,6 +443,7 @@
tunable_use_localtime));
str_append_char(p_str, ' ');
/* Filename */
+ local2remote(p_filename_str);
str_append_str(p_str, p_filename_str);
str_append_text(p_str, "\r\n");
}
diff -Naur vsftpd-2.0.3/postlogin.c vsftpd-2.0.3.patched/postlogin.c
--- vsftpd-2.0.3/postlogin.c 2005-03-19 14:15:59.000000000 +0300
+++ vsftpd-2.0.3.patched/postlogin.c 2006-06-12 13:08:44.000000000 +0400
@@ -76,6 +76,14 @@
static int data_transfer_checks_ok(struct vsf_session* p_sess);
static void resolve_tilde(struct mystr* p_str, struct vsf_session* p_sess);
+const int cp1251_koi8r[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 154, 161, 162, 163, 164, 165, 166, 167, 179, 191, 170, 171, 172, 173, 174, 175, 156, 177, 178, 179, 180, 181, 182, 158, 163, 185, 186, 187, 188, 189, 190, 191, 225, 226, 247, 231, 228, 229, 246, 250, 233, 234, 235, 236, 237, 238, 239, 240, 242, 243, 244, 245, 230, 232, 227, 254, 251, 253, 255, 249, 248, 252, 224, 241, 193, 194, 215, 199, 196, 197, 214, 218, 201, 202, 203, 204, 205, 206, 207, 208, 210, 211, 212, 213, 198, 200, 195, 222, 219, 221, 223, 217, 216, 220, 192, 209};
+void remote2local(struct mystr *local_)
+{ char* local = local_->PRIVATE_HANDS_OFF_p_buf;
+ int i;
+ for (i=0; i<local_->PRIVATE_HANDS_OFF_len; i++)
+ local[i]=(char)cp1251_koi8r[(unsigned char)local[i]];
+}
+
void
process_post_login(struct vsf_session* p_sess)
{
@@ -160,6 +168,7 @@
else if (str_equal_text(&p_sess->ftp_cmd_str, "CWD") ||
str_equal_text(&p_sess->ftp_cmd_str, "XCWD"))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_cwd(p_sess);
}
else if (str_equal_text(&p_sess->ftp_cmd_str, "CDUP") ||
@@ -182,6 +191,7 @@
else if (tunable_download_enable &&
str_equal_text(&p_sess->ftp_cmd_str, "RETR"))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_retr(p_sess);
}
else if (str_equal_text(&p_sess->ftp_cmd_str, "NOOP"))
@@ -215,6 +225,7 @@
(tunable_anon_upload_enable || !p_sess->is_anonymous) &&
str_equal_text(&p_sess->ftp_cmd_str, "STOR"))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_stor(p_sess);
}
else if (tunable_write_enable &&
@@ -222,6 +233,7 @@
(str_equal_text(&p_sess->ftp_cmd_str, "MKD") ||
str_equal_text(&p_sess->ftp_cmd_str, "XMKD")))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_mkd(p_sess);
}
else if (tunable_write_enable &&
@@ -229,12 +241,14 @@
(str_equal_text(&p_sess->ftp_cmd_str, "RMD") ||
str_equal_text(&p_sess->ftp_cmd_str, "XRMD")))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_rmd(p_sess);
}
else if (tunable_write_enable &&
(tunable_anon_other_write_enable || !p_sess->is_anonymous) &&
str_equal_text(&p_sess->ftp_cmd_str, "DELE"))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_dele(p_sess);
}
else if (str_equal_text(&p_sess->ftp_cmd_str, "REST"))
@@ -345,11 +359,13 @@
else if (str_equal_text(&p_sess->ftp_cmd_str, "STAT") &&
str_isempty(&p_sess->ftp_arg_str))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_stat(p_sess);
}
else if (tunable_dirlist_enable &&
str_equal_text(&p_sess->ftp_cmd_str, "STAT"))
{
+ remote2local(&p_sess->ftp_arg_str);
handle_stat_file(p_sess);
}
else if (tunable_ssl_enable && str_equal_text(&p_sess->ftp_cmd_str, "PBSZ"))
@@ -1245,6 +1261,7 @@
handle_dir_common(p_sess, 0, 0);
}
+
static void
prepend_path_to_filename(struct mystr* p_str)
{