VSFTPD – Default Permissions for New Files vs New Directories

vsftpd

I'm running vsftpd and have a specific question:

The file_open_mode and local_umask options let me configure, what permissions a newly created file/folder should have.

The problem:
I want 0660 for new files but 0770 for new folders (All files and folders should be readable and writable by owner and group – folders need the executable bit so that it's possible to open them)

How can I configure that?

(I searched this forum, google, vsftpd.man page, tutorials, manuals..)

Best Answer

TL;DR:

The default file_open_mode of 0666 and local_umask of 0007 will give you file permissions of 0660 and directory permissions of 0770.

File permissions

As you already pointed out, files are created with the permissions set in file_open_mode (modified by the local_umask). Therefore, to get files created with 0660 you can keep the default file_open_mode and modify it with a local_umask of 0007 to get 0660 as the result.

Directory permissions

Directories are created with mode 0777 modified by the local_umask. The only supporting documentation I found about this is in the source code itself. As there is no official browser-readable source code available, I can only link to an unofficial source code mirror at https://github.com/dagwieers/vsftpd/blob/3.0.2/postlogin.c#L1179 where the "tunable umask" in the comment refers to the local_umask configuration.

  /* NOTE! Actual permissions will be governed by the tunable umask */
  retval = str_mkdir(&p_sess->ftp_arg_str, 0777);