Linux – ProFTPD on Debian: Set read, execution and write permissions to new uploaded files (and then delete it by software)

debianfile-permissionsftplinuxproftpd

I have activated an FTP server with ProFTPD on Debian Server 8.11.

I would like that the new uploaded files via FTP has 2 features:

  1. read, execution and write permissions of the user&group (by default when i upload files the permission are 644, i need 775 i think)
  2. It is finally possible to delete them by software (this is possibile with www-data + rwx permission to group, any way to give it to my ftpgroup?)

I gave the 775 permissions to my folder:

drwxrwxr-x 2 user_ftp ftpgroup 192512 Mar 21 10:55 my_folder

Thanks a lot for the collaboration,

Greetings,

Gian Marco

Best Answer

For 1: It is for security reasons not permitted to allow default execute-bits on files, and they are also not really needed. (If You want to execute the file on some machine You can change the execute bit there before execute.) It would be possible to allow ftp-users changing file permissions explicitly to have execute bits set after upload. So two options: automate on server or on client that the bits get set if You really need them on files.

Maybe You should elaborate first on why You want them 775 or such by default, then You could get an answer.

That said, You can of course compile a patched ProFTPD Yourself (which starts persmissions / umask calculation by 7 instead of 6) and set Umask Configuration to 002 for files.

http://www.proftpd.org/docs/howto/Umask.html

For 2: there are different possibilities, depends on Your exact use case. A generic solution that should work also with ProFTPD is to make a group www-data the owning group of the parent directory and set the directories Set-GID bit. Set the directory Umask in ProFTPD to 77x. This would cause all uploaded content (including created diretories) into that directory to have owner group www-data, with the directory Umask setting new directories to be group-writable.

Alternatively a ProFTPD specific approach to Force a Owner Group would be to set the UserOwner Parameter for the Directories where this shall apply (http://www.proftpd.org/docs/directives/linked/config_ref_UserOwner.html).

Related Topic