vsftpd编译安装
侧边栏壁纸
博主昵称
yuc

  • 累计撰写 291 篇文章
  • 累计收到 0 条评论

vsftpd编译安装

yuc
yuc
2024-04-25 / 最后修改: 2024-04-25 04:07 / 0 评论 / 7 阅读 / 正在检测是否收录...
目的

本次编译安装是为了解决vsftpd的日志 /var/log/xferlog 记录的日志不能显示中文的问题

步骤
  1. 在官网下载源码包
  2. 解压
  3. 安装依赖包
yum -y install gcc gcc-c++ db4-utils pam-devel libcap openssl-devel libcap-devel tcp_wrappers-devel
  1. 修改支持pam, tcp_wrapper, ssl, 修改xferlog支持中文,修改编译一定会出现的错误(无法创建普通文件“/usr/local/man/man8/vsftpd.8”:没有那个文件或目录) ]
    修改源码文件builddefs.h对应三行的undef为define 修改源码文件logging.c,str_replace_unprintable(p_str, '?'); 这一行,注意注释方式 修改源码文件Makefile最后几行,修改如下,只需要修改/usr/local/man和/usr/share/man就行了
  2. make && make install 编译安装
  3. 复制Redhat/vsftpd.pam到/etc/pam.d/vsftpd
  4. 配置服务脚本
#!/bin/bash
#
# vsftpd      This Shell script takes care of starting and stopping
#             standalone vsftpd.
#
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program
#              that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd/vsftpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/local/sbin/vsftpd ] || exit 0
RETVAL=0
prog="vsftpd"
start() {
    # Start daemons.
    if [ -d /etc/vsftpd ] ; then
            for i in `ls /etc/vsftpd/*.conf`; do
                    site=`basename $i .conf`
                    echo -n $"Starting $prog for $site: "
                    /usr/local/sbin/vsftpd $i &
                    RETVAL=$?
                    [ $RETVAL -eq 0 ] && {
                       touch /var/lock/subsys/$prog
                       success $"$prog $site"
                    }
                    echo
            done
    else
            RETVAL=1
    fi
    return $RETVAL
}
stop() {
    # Stop daemons.
    echo -n $"Shutting down $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
    return $RETVAL
}
# See how we were called.
case "$1" in
start)
    start
    ;;
stop)
    stop
    ;;
restart|reload)
    stop
    start
    RETVAL=$?
    ;;
condrestart)
    if [ -f /var/lock/subsys/$prog ]; then
        stop
        start
        RETVAL=$?
    fi
    ;;
status)
    status $prog
    RETVAL=$?
    ;;
*)
    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
    exit 1
esac
exit $RETVAL
  1. 因为版本较高,安全性不同,如果用户被限制在了主目录下,那么这个用户不应该有主目录的写权限,报错 500 OOPS: vsftpd: refusing to run with writable root inside chroot () 解决办法: a. 设置主目录不可写 b. 配置allow_writeable_chroot=YES
0

评论

博主关闭了当前页面的评论