Vsftpd Chinese garbled code resolution process in CentOS 6.4

Time:2021-9-13

The Windows client accesses the FTP application server with a garbled code. This is caused by the incompatibility between UTF-8 and GBK. This problem can be solved by compiling and installing the source code.

Garbled code resolution process

1. First, use RPM – e vsftpd to uninstall the default vsftpd application server installed on the system:

[[email protected] ~]# rpm -e vsftpd

2. From http://vault.centos.org/6.3/updates/Source/SPackages/ Download vsftpd-2.2.2-11.el6 from the website_ 3.1.src.rpm source package.

3. Use rpm -ivh vsftpd-2.2.2-11.el6_ 3.1.src.rpm install the package:

[[email protected] birdofprey]# rpm -ivh vsftpd-2.2.2-11.el6_3.1.src.rpm

During installation, the system will prompt the following errors

warning: vsftpd-2.2.2-11.el6_3.1.src.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

1:vsftpd warning: user mockbuild does not exist – using root

########################################### [100%]

warning: user mockbuild does not exist – using root

warning: group mockbuild does not exist – using root

warning: user mockbuild does not exist – using root

warning: group mockbuild does not exist – using root

warning: user mockbuild does not exist – using root

warning: group mockbuild does not exist – using root

At this point, you need to use the addUser mockbuild command to create a mockbuild user

[[email protected] birdofprey]# adduser mockbuild

4. Reuse rpm -ivh vsftpd-2.2.2-11.el6_ 3.1.src.rpm install the package:

[[email protected] birdofprey]# rpm -ivh vsftpd-2.2.2-11.el6_3.1.src.rpm

warning: vsftpd-2.2.2-11.el6_3.1.src.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

1:vsftpd ########################################### [100%]

5. Use the command CD / root / rpmbuild / sources / vsftpd / sources to enter the vsftpd source package directory, and use tar -zxvf vsftpd-2.2.2.tar.gz to unzip the vsftpd-2.2.2.tar.gz source package:

[[email protected] SOURCES]# tar -zxvf vsftpd-2.2.2.tar.gz

6. Use the command CD vsftdp-2.2.2 to enter the vsfftpd-2.2.2 source directory:

[[email protected] SOURCES]# cd vsftpd-2.2.2

7. Use the command VI features. C to modify the features. C file; Change the line content to: VSF_ cmdio_ write_ raw(p_sess, ” UTF8\r\n”);

Modified to: / / VSF_ cmdio_ write_ raw(p_sess, ” UTF8\r\n”)。

8. Modify the opts. C file with the command VI opts. C;

Put handle_ The opts function is modified as follows:

Copy code

The code is as follows:

void
handle_opts(struct vsf_session* p_sess)
{
str_upper(&p_sess->ftp_arg_str);
//if (str_equal_text(&p_sess->ftp_arg_str, “UTF8 ON”))
//{
//vsf_cmdio_write(p_sess, FTP_OPTSOK, “Always in UTF8 mode.”);
//}
//else
//{
//vsf_cmdio_write(p_sess, FTP_BADOPTS, “Option not understood.”);
//}
}

9. Return to the upper directory and use the tar – zcvf vsftpd-2.2.2.tar.gz vsftpd-2.2.2/ command to recompress the vsftpd-2.2.tar.gz file:

[[email protected] SOURCES]# tar -zcvf vsftpd-2.2.2.tar.gz vsftpd-2.2.2/

Using LS – command, we can see that the creation time of vsftpd-2.2.tar.gz file in the list has been the current creation time, as shown below:

Copy code

The code is as follows:

-Rw-rw-r –. 1 mockbuild mockbuild 186982 May 3 15:39 vsftpd-2.2.2.tar.gz
-Rw-r — R –. 1 mockbuild mockbuild 2828 February 13 00:06 vsftpd-2.2.2-uint-uidgid.patch
-Rw-r — R –. 1 mockbuild mockbuild 1640 February 13 00:06 vsftpd-2.2.2-v6only.patch
-Rw-r — R –. 1 mockbuild mockbuild 514 February 13 00:06 vsftpd-close-std-fds.patch
-Rwxr-xr-x. 1 mockbuild 338 February 13 00:06 vsftpd_ conf_ migrate.sh
-Rw-r — R –. 1 mockbuild mockbuild 125 February 13 00:06 vsftpd.ftpusers
-Rwxr-xr-x. 1 mockbuild 2824 February 13 00:06 vsftpd.init
-Rw-r — R –. 1 mockbuild mockbuild 335 February 13 00:06 vsftpd.pam
-Rw-r — R –. 1 mockbuild mockbuild 361 February 13 00:06 vsftpd.user_ list
-Rw-r — R –. 1 mockbuild 345 February 13 00:06 vsftpd.xinetd

10. Enter the specs directory under the source package and use the rpmbuild – BB vsftpd.spec command to generate vsftpd-2.2.2-11.el6.1.x86_ 64.rpm:

[[email protected] SPECS]# rpmbuild -bb vsftpd.spec

At this time, because the system lacks dependent packages, the following error will be reported:

error: Failed build dependencies:

libcap-devel is needed by vsftpd-2.2.2-11.el6.1.x86_64

tcp_wrappers-devel is needed by vsftpd-2.2.2-11.el6.1.x86_64

We can find the following RPM package from centos6.4 installation disk for manual installation. The package name is as follows:

libattr-2.4.44-7.el6.i686.rpm libcap-devel-2.16-5.5.el6.x86_64.rpm

libattr-2.4.44-7.el6.x86_64.rpm tcp_wrappers-devel-7.6-57.el6.i686.rpm

libattr-devel-2.4.44-7.el6.i686.rpm tcp_wrappers-devel-7.6-57.el6.x86_64.rpm

libattr-devel-2.4.44-7.el6.x86_64.rpm tcp_wrappers-libs-7.6-57.el6.i686.rpm

libcap-2.16-5.5.el6.i686.rpm tcp_wrappers-libs-7.6-57.el6.x86_64.rpm

libcap-2.16-5.5.el6.x86_64.rpm vsftpd-2.2.2-11.el6_3.1.src.rpm

libcap-devel-2.16-5.5.el6.i686.rpm

11. Use the RPM – IVH *. RPM – force — nodeps command to forcibly install the above packages:

[[email protected] rpm]# rpm -ivh *.rpm –force –nodeps

warning: libattr-2.4.44-7.el6.i686.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

Preparing… ########################################### [100%]

1:libattr ########################################### [ 8%]

2:libcap ########################################### [ 17%]

3:tcp_wrappers-libs ########################################### [ 25%]

4:libattr ########################################### [ 33%]

5:libcap ########################################### [ 42%]

6:tcp_wrappers-libs ########################################### [ 50%]

7:tcp_wrappers-devel ########################################### [ 58%]

8:libcap-devel ########################################### [ 67%]

9:libattr-devel ########################################### [ 75%]

10:tcp_wrappers-devel ########################################### [ 83%]

11:libcap-devel ########################################### [ 92%]

12:libattr-devel ########################################### [100%]

12. Use rpmbuild – BB vsftpd.spec to vsftpd-2.2.2-11.el6.1.x86 again_ Recompile the 64.rpm package:

[[email protected] SPECS]# rpmbuild -bb vsftpd.spec

13. Enter x86_ 64 directory. You can see that relevant RPM packages have been generated under this directory:

The command mode is as follows:

Copy code

The code is as follows:

[[email protected] RPMS]# cd x86_64/
[[email protected] x86_64]# ls
vsftpd-2.2.2-11.el6.1.x86_64.rpm vsftpd-debuginfo-2.2.2-11.el6.1.x86_64.rpm

14. Reinstall the vsftpd application server component package with source code modification:

[[email protected] x86_64]# rpm -ivh vsftpd-2.2.2-11.el6.1.x86_64.rpm

Preparing… ########################################### [100%]

1:vsftpd ########################################### [100%]

15. Centos6.4 modify the system default character set:

[[email protected] /]# vi /etc/sysconfig/i18n

Revise the original document as follows:

Copy code

The code is as follows:

#LANG=”zh_CN.UTF-8″
LANG=”zh_CN.GB18030″
SUPPORTED=”zh_CN.GB18030:zh_CN:zh:zh_CN.GB2312:en_US.UTF-8:en_US:en”
SYSFONT=”latarcyrheb-sun16″

At this time, all modifications have been completed. After restarting the FTP application server, we use IE browser and early application software to test in Windows system, and the Chinese garbled code problem disappears. The solution is also applicable to the garbled code problem caused by the compatibility of vsftpd with Windows client character set in rhel6 series operating system.