2009-02-28 20:01:49 +00:00
|
|
|
{ vsftpd, anonymousUser, localUsers
|
2008-08-04 10:36:11 +01:00
|
|
|
, anonymousUploadEnable, anonymousMkdirEnable, writeEnable
|
2009-03-22 15:32:09 +00:00
|
|
|
, chrootlocaluser, userlistenable, userlistdeny
|
2008-08-04 10:36:11 +01:00
|
|
|
}:
|
2008-02-07 12:41:18 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
] ++
|
2008-02-07 13:37:20 +00:00
|
|
|
(if anonymousUser then [
|
2008-02-07 12:41:18 +00:00
|
|
|
{ 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
|
|
|
|
" +
|
2008-02-07 13:37:20 +00:00
|
|
|
(if anonymousUser then
|
2008-02-07 12:41:18 +00:00
|
|
|
"anonymous_enable=YES"
|
|
|
|
else
|
|
|
|
"anonymous_enable=NO") +
|
2009-02-28 20:01:49 +00:00
|
|
|
(if localUsers then
|
|
|
|
"
|
|
|
|
local_enable=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
local_enable=NO"
|
|
|
|
) +
|
2008-08-04 10:36:11 +01:00
|
|
|
(if writeEnable then
|
|
|
|
"
|
|
|
|
write_enable=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
write_enable=NO"
|
|
|
|
) +
|
|
|
|
(if anonymousUploadEnable then
|
|
|
|
"
|
|
|
|
anon_upload_enable=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
anon_upload_enable=NO"
|
|
|
|
) +
|
|
|
|
(if anonymousMkdirEnable then
|
|
|
|
"
|
|
|
|
anon_mkdir_write_enable=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
anon_mkdir_write_enable=NO"
|
|
|
|
) +
|
2009-03-22 15:32:09 +00:00
|
|
|
(if chrootlocaluser then
|
|
|
|
"
|
|
|
|
chroot_local_user=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
chroot_local_user=NO"
|
|
|
|
) +
|
|
|
|
(if userlistenable then
|
|
|
|
"
|
|
|
|
userlist_enable=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
userlist_enable=NO"
|
|
|
|
) +
|
|
|
|
(if userlistdeny then
|
|
|
|
"
|
|
|
|
userlist_deny=YES"
|
|
|
|
else
|
|
|
|
"
|
|
|
|
userlist_deny=NO"
|
|
|
|
) +
|
2008-02-07 12:41:18 +00:00
|
|
|
"
|
|
|
|
background=NO
|
|
|
|
listen=YES
|
|
|
|
nopriv_user=vsftpd
|
|
|
|
secure_chroot_dir=/var/ftp/empty
|
|
|
|
EOF
|
|
|
|
|
2009-02-28 20:01:49 +00:00
|
|
|
" +
|
|
|
|
(if anonymousUser then
|
|
|
|
"
|
2008-02-07 12:41:18 +00:00
|
|
|
mkdir -p /home/ftp &&
|
|
|
|
chown -R ftp:ftp /home/ftp
|
2009-02-28 20:01:49 +00:00
|
|
|
"
|
|
|
|
else "") +
|
|
|
|
"
|
|
|
|
mkdir -p /var/ftp/empty &&
|
|
|
|
chown vsftpd /var/ftp/empty
|
2008-02-07 12:41:18 +00:00
|
|
|
end script
|
|
|
|
|
|
|
|
respawn ${vsftpd}/sbin/vsftpd /etc/vsftpd.conf
|
|
|
|
";
|
|
|
|
|
|
|
|
}
|