diff --git a/system/options.nix b/system/options.nix index 912a6de6b4b5..a8ddd3996038 100644 --- a/system/options.nix +++ b/system/options.nix @@ -1847,6 +1847,13 @@ in "; }; + localUsers = mkOption { + default = false; + description = " + Whether to enable FTP for the local users. + "; + }; + writeEnable = mkOption { default = false; description = " diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index fa92cd57c8f3..4569a9ff1ab2 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -308,7 +308,7 @@ let ++ optional config.services.vsftpd.enable (import ../upstart-jobs/vsftpd.nix { inherit (pkgs) vsftpd; - inherit (config.services.vsftpd) anonymousUser + inherit (config.services.vsftpd) anonymousUser localUsers writeEnable anonymousUploadEnable anonymousMkdirEnable; }) diff --git a/upstart-jobs/vsftpd.nix b/upstart-jobs/vsftpd.nix index 01a509ea679a..f24ae0490267 100644 --- a/upstart-jobs/vsftpd.nix +++ b/upstart-jobs/vsftpd.nix @@ -1,4 +1,4 @@ -{ vsftpd, anonymousUser +{ vsftpd, anonymousUser, localUsers , anonymousUploadEnable, anonymousMkdirEnable, writeEnable }: @@ -42,6 +42,13 @@ start script "anonymous_enable=YES" else "anonymous_enable=NO") + +(if localUsers then +" +local_enable=YES" +else +" +local_enable=NO" +) + (if writeEnable then " write_enable=YES" @@ -70,8 +77,16 @@ nopriv_user=vsftpd secure_chroot_dir=/var/ftp/empty EOF +" + + (if anonymousUser then +" mkdir -p /home/ftp && chown -R ftp:ftp /home/ftp +" + else "") + +" + mkdir -p /var/ftp/empty && + chown vsftpd /var/ftp/empty end script respawn ${vsftpd}/sbin/vsftpd /etc/vsftpd.conf