If the path is still outside /mnt/ after all the previous checks and
enforces have been applied, overwrite the path to "/mnt/".
This is usefull in the following scenario:
- "/mnt/tmp" is a soft link to "/tmp"
- $path is pushed from the web gui as "/"
- $dirpath is pushed from the web gui as "tmp"
The init script prepends "/mnt/", the $path becomes "/mnt/tmp".
Further, the smb.conf would receive "path = /mnt/tmp" and
samba would export for share "/tmp".
A while-loop (that always prepends "/mnt/" to $(readlink -f $path)
if it does not start with "/mnt")
would not prevent this case exactly because
the soft link and the target directory have the same name,
thus the loop would never end.
When checknig that path starts with /mnt/, path should not include
softlinks, "." or "..". This prevents the obvoius case of sharing the
"/mnt/../" path, which will jump out of the restricted /mnt/.
Assuming that path and dirpath are both empty, path becomes
"/", which is not empty. The -z $path check after was useless.
Changed the order of this two operations.