Proftpd not restarting

Discussion in 'Installation/Configuration' started by Davide, Aug 29, 2006.

  1. Davide

    Davide Member HowtoForge Supporter

    I'm having a problem in Debian Sarge that is getting me mad.

    Everything runs ok, but from while to while proftpd process gets into state "D" when ispconfig restarts it at 23:59 every night. It happens sometimes from day to day, sometimes lasts one week even 10 days. But sooner or later, I know proftpd will hang and the only solutions is reboot whole machine to get ftp working again.

    It seems a Debian/proftpd bug (I got it hanged manually restarted), but I post here with the hope someone had this problem before than me (and found a solution ;)

    I also liked to know if I can try installing vsftp without breaking all the ispconfig installtion.

    Thank you very much!
     
  2. Ben

    Ben ISPConfig Developer ISPConfig Developer

    so you mean restarting by hand (not from the ipsconfig webinterface) even does not help?

    Well I did not find any solution except using vsftpd again (but I don't mind because I never need anonymous ftp...)

    another one having the same problem at the moment told sth. about logrotation....
     
  3. Davide

    Davide Member HowtoForge Supporter

    Even a "kill -9" doesn't work. proftpd process enters "D state":

    5 65534 24973 1 16 0 4904 2308 lock_p Ds ? 0:00 proftpd: (accepting connections)

    and the only way I found (by experimentation, and searching the web) of restarting ftp was rebooting machine.

    Even an ISPConfig update hanged at the moment of restarting ftp (luckily, it was at the very end of the upgrade, and all was ok after rebooting).

    I have no (almost) problem in changing proftpd by vsftpd, but I'm not sure if it will break someting else....

    Will ISPconfig detect vsftp without problems now that is already installed and running with proftpd?

    P.S. What do you mean with "...told sth. about logrotation...."?
     
    Last edited: Aug 29, 2006
  4. falko

    falko Super Moderator ISPConfig Developer

    What's the output of
    Code:
    netstat -tap
    ? What's in /etc/proftpd.conf and /etc/proftpd_ispconfig.conf?
     
  5. Davide

    Davide Member HowtoForge Supporter

    Proftpd.comf:

    #
    # /etc/proftpd.conf -- This is a basic ProFTPD configuration file.
    # To really apply changes reload proftpd after modifications.
    #

    ServerName "Servidor FTP de Auria"
    ServerType standalone
    DeferWelcome off

    MultilineRFC2228 on
    DefaultServer on
    ShowSymlinks on

    TimeoutNoTransfer 600
    TimeoutStalled 600
    TimeoutIdle 1200

    DisplayLogin welcome.msg
    DisplayFirstChdir .message
    ListOptions "-l"

    DenyFilter \*.*/


    ### Perfect Setup
    DefaultRoot ~
    IdentLookups off
    ServerIdent on "Servidor FTP de Auria"

    # Uncomment this if you are using NIS or LDAP to retrieve passwords:
    #PersistentPasswd off

    # Uncomment this if you would use TLS module:
    #TLSEngine on

    # Uncomment this if you would use quota module:
    #Quotas on

    # Uncomment this if you would use ratio module:
    #Ratios on

    # Port 21 is the standard FTP port.
    Port 21

    # To prevent DoS attacks, set the maximum number of child processes
    # to 30. If you need to allow more than 30 concurrent connections
    # at once, simply increase this value. Note that this ONLY works
    # in standalone mode, in inetd mode you should use an inetd server
    # that allows you to limit maximum number of processes per service
    # (such as xinetd)
    MaxInstances 30

    # Set the user and group that the server normally runs at.
    User nobody
    Group nogroup

    # Umask 022 is a good standard umask to prevent new files and dirs
    # (second parm) from being group and world writable.
    Umask 022 022
    # Normally, we want files to be overwriteable.
    AllowOverwrite on

    # Delay engine reduces impact of the so-called Timing Attack described in
    # http://security.lss.hr/index.php?page=details&ID=LSS-2004-10-02
    # It is on by default.
    #DelayEngine off

    # A basic anonymous configuration, no upload directories.

    # <Anonymous ~ftp>
    # User ftp
    # Group nogroup
    # # We want clients to be able to login with "anonymous" as well as "ftp"
    # UserAlias anonymous ftp
    # # Cosmetic changes, all files belongs to ftp user
    # DirFakeUser on ftp
    # DirFakeGroup on ftp
    #
    # RequireValidShell off
    #
    # # Limit the maximum number of anonymous logins
    # MaxClients 10
    #
    # # We want 'welcome.msg' displayed at login, and '.message' displayed
    # # in each newly chdired directory.
    # DisplayLogin welcome.msg
    # DisplayFirstChdir .message
    #
    # # Limit WRITE everywhere in the anonymous chroot
    # <Directory *>
    # <Limit WRITE>
    # DenyAll
    # </Limit>
    # </Directory>
    #
    # # Uncomment this if you're brave.
    # # <Directory incoming>
    # # # Umask 022 is a good standard umask to prevent new files and dirs
    # # # (second parm) from being group and world writable.
    # # Umask 022 022
    # # <Limit READ WRITE>
    # # DenyAll
    # # </Limit>
    # # <Limit STOR>
    # # AllowAll
    # # </Limit>
    # # </Directory>
    #
    # </Anonymous>


    Include /etc/proftpd_ispconfig.conf


    proftpd_ispconfig.conf:

    ###################################
    #
    # ISPConfig proftpd Configuration File
    # Version 1.0
    #
    ###################################
    DefaultAddress 127.0.0.1
    <VirtualHost 192.168.0.100>
    DefaultRoot ~
    AllowOverwrite on
    Umask 002
    </VirtualHost>
    <VirtualHost ww.xx.yy.zz>
    DefaultRoot ~
    AllowOverwrite on
    Umask 002
    </VirtualHost>


    I'd like also to say that while proftpd doesn't hangs, it works perfectly.
     
  6. Davide

    Davide Member HowtoForge Supporter

    I've got proftpd hanged again at 0:00

    Output of "netstat -tap" now is as follows:

    tcp 0 0 *:ftp *:* LISTEN 14122/proftpd: (acc
    tcp 0 0 localhost:ftp localhost:52538 ESTABLISHED-
    tcp 1 0 localhost:ftp localhost:52632 CLOSE_WAIT -
    tcp 0 0 localhost:52632 localhost:ftp FIN_WAIT2 -
    tcp 0 0 localhost:52538 localhost:ftp ESTABLISHED20091/php


    Every process who tries to connect to port 21 hangs with state "CLOSE WAIT"
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    any errors in your syslog or xferlog ?
     
  8. Davide

    Davide Member HowtoForge Supporter

    I don't get any errors, nor in syslog nor in xferlog

    Following is the difference between a "clean" and a "hanged" restart in syslog:

    OK:

    Aug 31 23:59:01 eneri /USR/SBIN/CRON[5873]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/cleanup.php &> /dev/null)
    Aug 31 23:59:01 eneri /USR/SBIN/CRON[5876]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/mail_logs.php &> /dev/null)
    Aug 31 23:59:01 eneri /USR/SBIN/CRON[5879]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/ftp_logs.php &> /dev/null)
    Aug 31 23:59:02 eneri postfix/postfix-script: stopping the Postfix mail system
    Aug 31 23:59:02 eneri postfix/master[31077]: terminating on signal 15
    Aug 31 23:59:02 eneri proftpd[3247]: localhost - ProFTPD killed (signal 15)
    Aug 31 23:59:02 eneri proftpd[3247]: localhost - ProFTPD 1.2.10 standalone mode SHUTDOWN
    Aug 31 23:59:02 eneri proftpd[5963]: localhost - ProFTPD 1.2.10 (stable) (built do mrt 22 18:28:32 CET 2001) standalone mode STARTUP
    Aug 31 23:59:03 eneri postfix/postfix-script: starting the Postfix mail system
    Aug 31 23:59:03 eneri postfix/master[6155]: daemon started -- version 2.1.5

    Not OK:

    Aug 30 23:59:01 eneri /USR/SBIN/CRON[18079]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/ftp_logs.php &> /dev/null)
    Aug 30 23:59:01 eneri /USR/SBIN/CRON[18081]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/cleanup.php &> /dev/null)
    Aug 30 23:59:01 eneri /USR/SBIN/CRON[18084]: (root) CMD (/root/ispconfig/php/php /root/ispconfig/scripts/shell/mail_logs.php &> /dev/null)
    Aug 30 23:59:01 eneri proftpd[14122]: localhost - ProFTPD killed (signal 15)
    Aug 30 23:59:01 eneri postfix/postfix-script: stopping the Postfix mail system
    Aug 30 23:59:01 eneri postfix/master[12878]: terminating on signal 15
    Aug 30 23:59:02 eneri postfix/postfix-script: starting the Postfix mail system
    Aug 30 23:59:02 eneri postfix/master[18298]: daemon started -- version 2.1.5


    In xferlog all is normal...
    There's no difference between an "OK" day and a "not OK" one
     
  9. falko

    falko Super Moderator ISPConfig Developer

    What's in /etc/init.d/proftpd?
     
  10. Davide

    Davide Member HowtoForge Supporter

    I've no changed this script as it comes with Debian Sarge:

    #!/bin/sh

    # Start the proftpd FTP daemon.

    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    DAEMON=/usr/sbin/proftpd
    NAME=proftpd

    # Defaults
    RUN="no"
    OPTIONS=""

    PIDFILE=`grep -i 'pidfile' /etc/proftpd.conf | sed -e 's/pidfile[\t ]\+//i'`
    if [ "x$PIDFILE" = "x" ];
    then
    PIDFILE=/var/run/proftpd.pid
    fi

    # Read config (will override defaults)
    [ -r /etc/default/proftpd ] && . /etc/default/proftpd

    trap "" 1
    trap "" 15

    test -f $DAEMON || exit 0

    #
    # Servertype could be inetd|standalone|none.
    # In all cases check against inetd and xinetd support.
    #
    if ! egrep -qi "^[[:space:]]*ServerType.*standalone" /etc/proftpd.conf
    then
    if [ $(dpkg-divert --list xinetd|wc -l) -eq 1 ]
    then
    if egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.conf -o \
    egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.d/* 2>/dev/null
    then
    RUN="no"
    INETD="yes"
    else
    if ! egrep -qi "^[[:space:]]*ServerType.*inetd" /etc/proftpd.conf
    then
    RUN="yes"
    INETD="no"
    else
    RUN="no"
    INETD="no"
    fi
    fi
    else
    if egrep -qi "^ftp.*/usr/sbin/proftpd" /etc/inetd.conf 2>/dev/null
    then
    RUN="no"
    INETD="yes"
    else
    if ! egrep -qi "^[[:space:]]*ServerType.*inetd" /etc/proftpd.conf
    then
    RUN="yes"
    INETD="no"
    else
    RUN="no"
    INETD="no"
    fi
    fi
    fi
    fi

    start()
    {
    if start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
    --exec $DAEMON -- $OPTIONS ; then
    echo "$NAME."
    else
    echo "."
    fi
    }

    signal()
    {
    if [ "$1" = "stop" ]; then
    SIGNAL="TERM"
    else
    if [ "$1" = "reload" ]; then
    SIGNAL="HUP"
    else
    echo "ERR: wrong parameter given to signal()"
    fi
    fi
    if start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"; then
    echo "$NAME."
    else
    SIGNAL="KILL"
    if start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"; then
    echo "$NAME."
    else
    echo "."
    fi
    fi
    if [ "$SIGNAL" = "KILL" ]; then
    rm -f "$PIDFILE"
    fi
    }

    case "$1" in
    start)
    if [ "x$RUN" = "xyes" ] ; then
    echo -n "Starting ProFTPD ftp daemon: "
    start
    else
    if [ "x$INETD" = "xyes" ] ; then
    echo "ProFTPd is started from inetd/xinetd."
    else
    echo "ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration."
    fi
    fi
    ;;

    force-start)
    if [ "x$INETD" = "xyes" ] ; then
    echo "Warning: ProFTPd is started from inetd/xinetd (trying to start anyway)."
    fi
    echo -n "Starting ProFTPD ftp daemon: "
    start
    ;;

    stop)
    if [ "x$RUN" = "xyes" ] ; then
    echo -n "Stopping ProFTPD ftp daemon: "
    signal stop
    else
    if [ "x$INETD" = "xyes" ] ; then
    echo "ProFTPd is started from inetd/xinetd."
    else
    echo "ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration."
    fi
    fi
    ;;

    force-stop)
    if [ "x$INETD" = "xyes" ] ; then
    echo "Warning: ProFTPd is started from inetd/xinetd (trying to kill anyway)."
    fi
    echo -n "Stopping ProFTPD ftp daemon: "
    signal stop
    ;;

    reload)
    echo -n "Reloading $NAME configuration..."
    signal reload
    echo " done."
    ;;

    force-reload|restart)
    if [ "x$RUN" = "xyes" ] ; then
    echo -n "Restarting ProFTPD ftp daemon."
    signal stop
    echo -n "."
    sleep 2
    echo -n "."
    start
    echo " done."
    else
    if [ "x$INETD" = "xyes" ] ; then
    echo "ProFTPd is started from inetd."
    else
    echo "ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration."
    fi
    fi
    ;;

    *)
    echo "Usage: /etc/init.d/$NAME {start|force-start|stop|force-stop|reload|restart|force-reload}"
    exit 1
    ;;
    esac

    exit 0
     
  11. falko

    falko Super Moderator ISPConfig Developer

    You can try this: Open /rrot/ispconfig/scripts/shell/ftp_logs.php and replace

    PHP:
    if($dienst["dienst_ftp_status"] == "on"){
      if(
    $dist_ftp_version == "standalone"){
        
    $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "start");
      } else {
        
    $mod->system->daemon_init($dist_ftp_version"start");
      }
    }
    with

    PHP:
    if($dienst["dienst_ftp_status"] == "on"){
      
    sleep(5);
      if(
    $dist_ftp_version == "standalone"){
        
    $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "start");
      } else {
        
    $mod->system->daemon_init($dist_ftp_version"start");
      }
    }
     
  12. Davide

    Davide Member HowtoForge Supporter

    I have changed it.

    At this moment, machine has an uptime of 6 days. I will post about any problem.

    Thank you!
     
  13. Davide

    Davide Member HowtoForge Supporter

    Sorry for my late answer, I was on holidays until yesterday

    proftpd hanged again, two times since the change in the restart script.
    It seems that the sleep hasn't solved anything...

    Any idea? Should I try vsftpd?
     
  14. falko

    falko Super Moderator ISPConfig Developer

    Does this happen at the same time of day, or do times differ? If it's always the same time of day, it could be a cron job that causes the problem...
     
  15. Davide

    Davide Member HowtoForge Supporter

    It always happens at 23:59, with the restart script.

    I have the following entries in root crontab:

    crontab -l
    30 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/logs.php &> /dev/null
    59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/ftp_logs.php &> /dev/null
    59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/mail_logs.php &> /dev/null
    59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/cleanup.php &> /dev/null
    0 4 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/webalizer.php &> /dev/null
    0,30 * * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/check_services.php &> /dev/null
    15 3,15 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/quota_msg.php &> /dev/null
    40 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/traffic.php &> /dev/null
    05 02 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/backup.php &> /dev/null
     
  16. falko

    falko Super Moderator ISPConfig Developer

    It's this cron job. Open /root/ispconfig/scripts/shell/ftp_logs.php and change

    Code:
    if($dienst["dienst_ftp_status"] == "on"){
      if($dist_ftp_version == "standalone"){
        $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "stop");
      } else {
        $mod->system->daemon_init($dist_ftp_version, "stop");
      }
    }
    $mod->log->caselog("cp -f $ftp_log $ftp_log.$datum", $FILE, __LINE__);
    if($server["server_ftp_log_save"]){
      $mod->log->caselog("touch $ftp_log.ispconfigsave", $FILE, __LINE__);
      $mod->log->caselog("cat $ftp_log >> $ftp_log.ispconfigsave", $FILE, __LINE__);
    }
    
    $fp = fopen($ftp_log, "w");
    fwrite($fp, "");
    fclose($fp);
    
    if($dienst["dienst_ftp_status"] == "on"){
      if($dist_ftp_version == "standalone"){
        $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "start");
      } else {
        $mod->system->daemon_init($dist_ftp_version, "start");
      }
    }
    to

    Code:
    if($dienst["dienst_ftp_status"] == "on"){
      if($dist_ftp_version == "standalone"){
        $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "stop");
      } else {
        $mod->system->daemon_init($dist_ftp_version, "stop");
      }
    }
    $mod->log->caselog("cp -f $ftp_log $ftp_log.$datum", $FILE, __LINE__);
    if($server["server_ftp_log_save"]){
      $mod->log->caselog("touch $ftp_log.ispconfigsave", $FILE, __LINE__);
      $mod->log->caselog("cat $ftp_log >> $ftp_log.ispconfigsave", $FILE, __LINE__);
    }
    
    $fp = fopen($ftp_log, "w");
    fwrite($fp, "");
    fclose($fp);
    
    [B][COLOR="Red"]sleep(5);[/COLOR][/B]
    
    if($dienst["dienst_ftp_status"] == "on"){
      if($dist_ftp_version == "standalone"){
        $mod->system->daemon_init($mod->system->server_conf["server_ftp_typ"], "start");
      } else {
        $mod->system->daemon_init($dist_ftp_version, "start");
      }
    }
     
  17. Davide

    Davide Member HowtoForge Supporter

    As you suggested in a previous post, I have already already changed that, but it hasn't solved the problem.

    Thank you!
     
  18. falko

    falko Super Moderator ISPConfig Developer

    Then I'm at my wit's end...
     
  19. yahooadam

    yahooadam New Member

    hi

    i think i may have been having a similar problem to you, but mine is regular like yours
    ProtFTP continues running, seeming to be ok, however when you try to connect with an FTP client it gets denied (wrong u/name and password i believe)

    as i dont have the problem at this second i cant detail the problem

    anyway, i found doing /etc/init.d/proftpd restart fixes the problem

    however this may not work for you, worth a try though
     
  20. Davide

    Davide Member HowtoForge Supporter

    No, the only solution to my problem is rebooting machine. Even kill -9 doesn't work.
    proftpd enters "D" state, and it doesn't respond to any signal.

    falko: I want to try vsftpd. Can I uninstall proftpd and install vsftpd with no problem? Shoud I reinstall ispconfig after doing that?

    Tahnk you very much
     

Share This Page