Bug report with proposed solution for mounting external drives for ftp access

Hello Guys,

I registered to inform you about something I would classify as a bug. I realized this when I used an external drive with my WD My Cloud and trying to access the drive via ftp. It simply was not visible on the ftp, but was accessible as samba share.

I digged a bit in the scripts and found this:

/etc/init.d/mountDataVolume.sh 

[...]
        ## initialze bind mount dir (/nfs)
        /usr/local/sbin/updateShareBindMntDir.sh --init
[...]

 /usr/local/sbin/updateShareBindMntDir.sh

[...]

init_mounts()
{
        mount | grep -q "${SHARE_BIND_MNT_DIR}/"
        if [$? -ne 0]; then
                # initial clean up of MNT dir
                rm -rvf ${SHARE_BIND_MNT_DIR}/*
        fi
        for D in `find /shares/ -maxdepth 1 -mindepth 1 -type d -not -name ".*"`; do
                share_name=$(basename $D)
                add_mount "${share_name}"
        done
}


[...]

The init_mounts() function searches /shares for directories (find -type >d<) and bind mounts these to SHARE_BIND_MNT_DIR (default: /nfs) by calling add_mount(). This is the directory where ftp users will drop in after logging in.

The problem: find -type d will not find symlinks and external drives are represented by a symlink from /shares to /var/media/EXTERNALDRIVE

I propose adding the following code at the end of init_mounts()

for D in `find /shares/ -maxdepth 1 -mindepth 1 -type l -not -name ".*"`; do
                share_name=$(basename $D)
                add_mount "${share_name}"
        done

That will look for symlinks in /shares and call add_mount() for each symlink to bind mount it to SHARE_BIND_MNT.

I think this is not intended aka a bug because I found this comment for add_mount():

# - If <share_name> is a symlink to an external volume, then create the bind mount
# directly to the external volume.

As it seems from this comment add_mount() supports symlinks but init_mounts does not feed it any.

I tried this solution myself and it works flawlessly.

Yours sincerely,

schnip

3 Likes

Nice find!