NAS520 Can't activate FTP-Server

2

All Replies

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    You added a line to vsftpd_start.sh? How? That file is supposed to be read-only.
  • Mark
    Mark Posts: 11  Freshman Member
    edited February 2018

    Of course, you're right, I have tried so many things.

    Actually I enabled the Tweak, then changed "pure-ftpd" by adding the lines:-

    echo `date` " : Start of $0 " >>/i-data/2ce21ab4/Public/Mark.txt
    chmod 666 /i-data/2ce21ab4/Public/Mark.txt

    at the start of the script.


    Manually running vsftpd_start_sh generates the output, whereas enbling FTPD via the admin web I/F, generates nothing.

    (I wanted to try something simple before I made the changes you detailed above, just to make sue that that script was actually being called - and it seems that it is not)

    There is another copy of pure-ftpd in ram_bin. This appears to be the original Binary - How can this be changed to use the tweaks script version??

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    There is another copy of pure-ftpd in ram_bin. This appears to be the original Binary - How can this be changed to use the tweaks script version??

    That's not how it works. There is some big file /firmware/mnt/sysdisk/sysdisk.img containing an ext2 filesystem, which is loopmounted on /ram_bin/. Then /ram_bin/usr/ is mounted on /usr/. So the binary in /ram_bin/usr/ is the same one as the binary in /usr/.

    The Tweaks package mounts a (writable) script on /usr/local/sbin/pure-ftpd, to catch all calls to the binary. After the script has done it's job (passing some commandline arguments), if passes execution to the original binary in /ram_bin/usr/local/sbin/pure_ftpd. 

    So if you would hook this one, all filesystem existences of pure_ftpd are shadowed, and it's no longer possible to execute it.


    According to grep the script /usr/local/sbin/vsftpd_start.sh is called from /usr/local/apache/web_framework/models/ftp_main_model.pyc. I used uncompyle6 to make that readable, to see if there are any obvious blocking conditions. 

    Not as far as I can see. It just reads some database, to generate the arguments file, and to see if the ftp service is enabled at all.

    You can create a small python script ftp.py to see if your database is damaged:

    <p>import ftp_main_model</p><p>info = ftp_main_model.get_ftp_info()</p><p>print info</p>

    Execute it:

    <p>PYTHONPATH=/usr/local/apache/web_framework/models/ /usr/bin/python ftp.py<br></p><p></p>

    On my box the output is 

    <p>{'anonymous_dl_speed': '0', 'cmd_port': '21', 'normal_dl_speed': '0', 'client_charset': 'SHIFT_JIS', 'conn_limit': '20', 'active': 'true', 'idle_timeout': '15', 'normal_up_speed': '0', 'with_encrypt': 'false', 'data_port_max': '65535', 'data_port_min': '1024', 'allow_anonymous': 'n', 'data_port_range_set': 'auto', 'anonymous_up_speed': '0'}</p><p></p>

    Here the 'active': 'true' defines that the service should be active. It's actually the 'enabled' flag.


    You can also try to start it with 'ftp_main_model.ftp_srv_start()'. I attached the decompyled script for reference.


  • Mark
    Mark Posts: 11  Freshman Member

    Running the python script gets the same structure as your box, but all values say "None"

    {'anonymous_dl_speed': None, 'cmd_port': None, 'normal_dl_speed': None, 'client_charset': None, 'conn_limit': None, 'active': None, 'idle_timeout': None, 'normal_up_speed': None, 'with_encrypt': None, 'data_port_max': None, 'data_port_min': None, 'allow_anonymous': None, 'data_port_range_set': None, 'anonymous_up_speed': None}

    This is getting a bit beyond my experiences. I am used to normal UNIX systems, but not this type of box.

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    Running the python script gets the same structure as your box, but all values say "None"
    In that case it's clear. The database is damaged. I did some research, and I think the database is located in /etc/zyxel/py_conf. (A flash partition containing user settings is mounted on /etc/zyxel/, so the search was rather limited).
    That is a flat textfile, on my box it contains 
    <div>[system]</div><div>&nbsp; &nbsp; hostname = NAS540</div><div>&nbsp; &nbsp; [[fw_upgrade]]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; auto_check = false</div><div>&nbsp; &nbsp; [[service]]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; [[[http]]]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; port = 80</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; additional_port = -1</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; virtual_port = -1</div><div><snip></div><div>&nbsp; &nbsp; &nbsp; &nbsp; [[[ftp]]]</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; active = true</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; with_encrypt = false</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn_limit = 20</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idle_timeout = 15</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd_port = 21</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allow_anonymous = n</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_port_range_set = auto</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_port_min = 1024</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_port_max = 65535</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; normal_up_speed = 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; normal_dl_speed = 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anonymous_up_speed = 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anonymous_dl_speed = 0</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; srv_charset = utf-8</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client_charset = SHIFT_JIS</div><div>&nbsp; &nbsp; &nbsp; &nbsp; [[[printer]]]</div><div><snip></div><br>
    So have a look if your file has the same structure.

    A factory reset should solve this, as it erases the whole flash partition. So this file should be replaced.

    This is getting a bit beyond my experiences. I am used to normal UNIX systems, but not this type of box.
    This has nothing to do with Unix, or Linux, or whatever. It's just the way ZyXEL decided to write their webinterface backend. Could also have been a Windows server.
  • Mark
    Mark Posts: 11  Freshman Member

    Below is a snippet from my py_conf file.


    The FTP bits look Ok, but Active is False.   This is because whenever I enable it, re-sets itself.

    [system]
        hostname = ""
        domainname = ""
        description = ""
        [[console]]
            name = ""
            speed = ""
        [[domain]]
            name = ""
            timeout = ""
            retry = ""

    <<SNIP>>
      
      [[service]]
            [[[http]]]
                port = 80
            [[[https]]]
                active = false
                force_https = false
                port = 443
            [[[ftp]]]
                [[[[ftp_allow_user]]]]
                [[[[ftp_deny_user]]]]
                [[[[ftp_trust_addr]]]]
                    name = ftp
                    port = 21
                    active = no
                    connlimit = 10
                    timeout = 15
                    anonymous = no
                    ZldFtpFileManage = yes
                    cert = default
                    orig_cert = ""
                    tls = no
                    auth = default
                    cli_charset = utf-8
                    srv_charset = utf-8
                    firstport = 1024
                    lastport = 65535
                    pasv = no
                    normal_upload_bandwidth = 0
                    normal_download_bandwidth = 0
                    anonymous_upload_bandwidth = 0
                    anonymous_download_bandwidth = 0
    <<SNIP>>


    How do I carry out a factory reset? without losing all my settings? - Is that even possible?


    BTW - I appreciate your help with this, Looks like you've spent a lot of time on this for me :)

     

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
            [[[ftp]]]
                [[[[ftp_allow_user]]]]
                [[[[ftp_deny_user]]]]
                [[[[ftp_trust_addr]]]]
                    name = ftp
                    port = 21
                    active = no

    Really? In that case the 'active' is on the wrong level, it's inside [[[[ftp_trust_addr]]]]. Looking at the file each section is closed by a section of the same level, or a lower level. (Lower as in nearer to the root).

    So you can try to put the 3 '4-deep' sections at the end of the [[[ftp]]] section, and run the ftp_info script again, to see if the 'None's are gone.

    BTW, you have a lot more ftp settings than I do. Isn't that strange?

    How do I carry out a factory reset? without losing all my settings? - Is that even possible?
    No, that's not possible. A factory reset is wiping all user settings. But not the user data. You can perform a factory reset in the Control Panel->Configuration Backup menu.
    I appreciate your help with this
    You're welcome.


  • Mark
    Mark Posts: 11  Freshman Member

    Moving those lines makes no difference. The script still shows "None" for everything. Attempting to Enable FTP via the web I/F, re-creates the FTP section in this py_conf and puts the 3 lines back.

    I will do some more playing with this and if all else fails (which I suspect it will), then I will do a reset.

    Will post my end result and method.

  • Mark
    Mark Posts: 11  Freshman Member

    Just one more question on this....

    My Nas has 2 4Gb disks installed as RAID 1 - mirrored (lets call them A and B).  My thoughts are....
    1) Remove disk B so that the NAS will still function with disk A (In degraded mode).
    2) Factory Reset as suggested
    3) See if that has fixed the problem.

    If all was fixed, I could then re-install the disk B and recover the Raid volumes. - Job done

    My real question is.....
    If The reset made no difference, Could simply swap disk A (the newly updated one) with disk B (The original unchanged one) and bring the NAS up. ?? This ought to leave me where I first started, although degraded.

    Then I could add back the removed disk A, and the NAS would re-build this to mirror disk B

    Does this sound like it will work?? 

    If the HDD's themselves contain all the config information, then this should be Ok, but I am just concerned that something may be updated in the flash memory relating to the disk config etc which would prevent this from working.

    I do have backups to another NAS, but would like to avoid the headache of using that option.

    What are your thoughts?

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    edited February 2018

    What are your thoughts?

    The script /usr/local/btn/reset_and_reboot.sh is called when you perform a factory reset by the reset button, and it's content is this:

    #!/bin/sh
    if [ -e /etc/zyxel/pkg_conf/status ]; then
     cp -a /etc/zyxel/pkg_conf/status /i-data/.system/zy-pkgs/status.packageinstinfo
     sync
     sleep 1
    fi
    rm -rf /i-data/.media/twonkymedia
    rm -rf /etc/zyxel/conf
    rm -rf /etc/zyxel/webdav
    rm -rf /etc/zyxel/storage/*
    umount /etc/zyxel
    ubirmvol /dev/ubi3 -N ubi_config
    ubidetach -m 3
    rm -rf /etc/zyxel/

    #remove desktop config by hazel
    [ -e "/i-data/.system/guicfg" ] && rm -rf /i-data/.system/guicfg
    reboot

     So what does it do? It erases the directories twonkymedia and guicfg on the primary ('system') data partition, and it erases the content of the ubi3 flash partition. By fiddling with the disks before performing a factory reset you can save your twonkymedia and guicfg partition. The first one contains (I think) a database of your media files, the 2nd one the configuration of your (web)gui desktop. Why bother?

Consumer Product Help Center