Added vsftpd upstart job

svn path=/nixos/trunk/; revision=10540
This commit is contained in:
Sander van der Burg 2008-02-07 12:41:18 +00:00
parent 8bf1cade68
commit 76897682c4
4 changed files with 84 additions and 1 deletions

View File

@ -8,6 +8,8 @@
messagebus = 4; # D-Bus messagebus = 4; # D-Bus
haldaemon = 5; haldaemon = 5;
nagios = 6; nagios = 6;
vsftpd = 7;
ftp = 8;
nixbld = 30000; # start of range of uids nixbld = 30000; # start of range of uids
nobody = 65534; nobody = 65534;
}; };
@ -16,6 +18,8 @@
root = 0; root = 0;
wheel = 1; wheel = 1;
haldaemon = 5; haldaemon = 5;
vsftpd = 7;
ftp = 8;
audio = 17; audio = 17;
users = 100; users = 100;
nixbld = 30000; nixbld = 30000;

View File

@ -1365,7 +1365,22 @@
}; };
vsftpd = {
enable = mkOption {
default = false;
description = "
Whether to enable the vsftpd FTP server.
";
};
anonymous_user = mkOption {
default = false;
description = "
Whether to enable the anonymous FTP user.
";
};
};
printing = { printing = {
enable = mkOption { enable = mkOption {

View File

@ -218,6 +218,13 @@ let
inherit config pkgs; inherit config pkgs;
}) })
# VSFTPd server
++ optional config.services.vsftpd.enable
(import ../upstart-jobs/vsftpd.nix {
inherit (pkgs) vsftpd;
inherit (config.services.vsftpd) anonymous_user;
})
# X Font Server # X Font Server
++ optional config.services.xfs.enable ++ optional config.services.xfs.enable
(import ../upstart-jobs/xfs.nix { (import ../upstart-jobs/xfs.nix {

57
upstart-jobs/vsftpd.nix Normal file
View File

@ -0,0 +1,57 @@
{ vsftpd, anonymous_user }:
{
name = "vsftpd";
groups = [
{ name = "ftp";
gid = (import ../system/ids.nix).gids.ftp;
}
];
users = [
{ name = "vsftpd";
uid = (import ../system/ids.nix).uids.vsftpd;
description = "VSFTPD user";
home = "/homeless-shelter";
}
] ++
(if anonymous_user then [
{ name = "ftp";
uid = (import ../system/ids.nix).uids.ftp;
group = "ftp";
description = "Anonymous ftp user";
home = "/home/ftp";
}
]
else
[]);
job = "
description \"vsftpd server\"
start on network-interfaces/started
stop on network-interfaces/stop
start script
cat > /etc/vsftpd.conf <<EOF
" +
(if anonymous_user then
"anonymous_enable=YES"
else
"anonymous_enable=NO") +
"
background=NO
listen=YES
nopriv_user=vsftpd
secure_chroot_dir=/var/ftp/empty
EOF
mkdir -p /home/ftp &&
chown -R ftp:ftp /home/ftp
end script
respawn ${vsftpd}/sbin/vsftpd /etc/vsftpd.conf
";
}