The following two patches are to address some issues I had trying to setup
an ftp server with btrfs.
vsftpd.patch :
Patched to create an "upload" directory with the correct permissions if
cfg.anonymousUser is true and cfg.anonymousUploadEnable is also true.
Previously, an upload directory would have to be manually created. Also, I
added an "additionalConfig" parameter to contain any additional text which
needs to be added to "vsftpd.conf".
filesystems.patch:
Fixed for use with BTRFS filesystems. The fix involves doing a "modprobe
btrfs" and "btrfs device scan" prior to mountall.
Index: nixos/modules/services/networking/vsftpd.nix
===================================================================
--- nixos/modules/services/networking/vsftpd.nix (revision 32476)
+++ nixos/modules/services/networking/vsftpd.nix (working copy)
@@ -71,6 +71,11 @@
description = "Whether users are excluded.";
};
+ additionalConfig = mkOption {
+ default = " " ;
+ description = "Any additional configuration options." ;
+ } ;
+
};
};
@@ -100,11 +105,18 @@
};
jobs.vsftpd =
+ let
+ uploadDirCmd = if cfg.anonymousUploadEnable then ''
+ mkdir -p ${cfg.anonymousUserHome}/upload
+ chmod 755 ${cfg.anonymousUserHome}/upload
+ '' else "" ;
+ in
{ description = "vsftpd server";
startOn = "started network-interfaces";
stopOn = "stopping network-interfaces";
+
preStart =
''
# !!! Why isn't this generated in the normal way?
@@ -117,6 +129,7 @@
${yesNoOption cfg.chrootlocalUser "chroot_local_user"}
${yesNoOption cfg.userlistEnable "userlist_enable"}
${yesNoOption cfg.userlistDeny "userlist_deny"}
+ ${cfg.additionalConfig}
background=NO
listen=YES
nopriv_user=vsftpd
@@ -124,8 +137,10 @@
EOF
${if cfg.anonymousUser then ''
- mkdir -p -m 555 ${cfg.anonymousUserHome}
- chown -R ftp:ftp ${cfg.anonymousUserHome}
+ mkdir -p ${cfg.anonymousUserHome}
+ chmod 555 ${cfg.anonymousUserHome}
+ '' + uploadDirCmd + ''
+ chown -R ftp:ftp ${cfg.anonymousUserHome}
'' else ""}
'';
Index: nixos/modules/tasks/filesystems.nix
===================================================================
--- nixos/modules/tasks/filesystems.nix (revision 32476)
+++ nixos/modules/tasks/filesystems.nix (working copy)
@@ -173,8 +173,10 @@
script =
''
exec > /dev/console 2>&1
+ export PATH=${config.system.sbin.mount}/bin:${makeSearchPath "sbin" ([pkgs.utillinux] ++ fsPackages)}:$PATH
echo "mounting filesystems..."
- export PATH=${config.system.sbin.mount}/bin:${makeSearchPath "sbin" ([pkgs.utillinux] ++ fsPackages)}:$PATH
+ ${config.system.sbin.modprobe}/sbin/modprobe btrfs
+ ${pkgs.btrfsProgs}/bin/btrfs device scan
${pkgs.mountall}/sbin/mountall
'';
};
_______________________________________________
nix-dev mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-dev