Create directory under user's root directory, automatically

emedeiros

Cadet
Joined
Jul 19, 2019
Messages
3
I'm new to FreeNAS and FreeBSD, and I'm setting the FTP server so the NAS can be the destination for the local computers' backups tasks. I followed the instructions on the official documentation (11.2-U5 User Guide) to make FTP in chroot and to use FTPS.

One thing I didn't like: the root FTP directory is the user's system root directory, so those files like ".cshrc", ".login", ".login_conf" etc... are accessible via FTP. How are those files starting with a dot, in the root directory of an user, called, by the way?

With some research about ProFTPD I found out that I could set the users' root FTP directories to be a directory inside the user's system root directories, by passing an argument using the FreeNAS interface (Services / FTP / Advanced Mode / Auxiliary parameters): "DefaultRoot ~/ftp !wheel". The default argument inside proftpd.conf is "DefaultRoot ~ !wheel", and as far as I understand it specifies that the root FTP directory for all users is their root directory (because of "~"), except for the members of the "wheel" group (because the "!wheel").

By replacing "~" with "~/ftp" ("ftp" was my choice for the name of a directory) I was successfully able to accomplish what I intended, but there is a problem: the "ftp" directory must already exist for this to work, so the users are able to use FTP. In my scenario the "ftp" directories already existed, because the clients of the backup tasks had already created them, and I just removed the "/ftp" part of the destination paths on the clients and everything worked well.

But what about new FTP users? How can I make that directory be created automatically inside an user's system root directory, before or during their first FTP login, whether using resources from FreeBSD, FreeNAS or ProFTPD?

I found the CreateHome directive of ProFTPD, but I'm afraid it can be intended to create the very user's FreeBSD root directory, I don't know. I created a directory "/mnt/mypool/mainftp/skel/ftp", then I added the following argument to be passed in the FTP settings: "CreateHome on skel /mnt/mypool/mainftp/skel". Then created a new user. Didn't seem to work, but I did it just now, while I was typing this post, didn't look further.

Even if everybody on this sub tell me that there is absolutely no possible danger in letting the FTP users having access to those files on their root folder, I still would like to figure this out.

Thank you all in advance!
 
Top