From f250f69ee8fe38d0855d2db68157157c5fb9c7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Wed, 19 Aug 2009 20:20:51 +0000 Subject: [PATCH] Adding xinetd with a possible tftpd server. svn path=/nixos/trunk/; revision=16784 --- modules/module-list.nix | 1 + modules/services/networking/xinetd.nix | 95 ++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 modules/services/networking/xinetd.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 68f00dace2b..af19ece8f1d 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -69,6 +69,7 @@ ./services/networking/ssh/lshd.nix ./services/networking/ssh/sshd.nix ./services/networking/vsftpd.nix + ./services/networking/xinetd.nix ./services/networking/wpa_supplicant.nix ./services/printing/cupsd.nix ./services/scheduling/atd.nix diff --git a/modules/services/networking/xinetd.nix b/modules/services/networking/xinetd.nix new file mode 100644 index 00000000000..a1a69a71955 --- /dev/null +++ b/modules/services/networking/xinetd.nix @@ -0,0 +1,95 @@ +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption mkIf; + + options = { + services = { + xinetd = { + enable = mkOption { + default = false; + description = " + Whether to enable the vsftpd FTP server. + "; + }; + + tftpd = { + enable = mkOption { + default = false; + description = " + Whether to enable the anonymous FTP user. + "; + }; + + path = mkOption { + default = "/home/tftp"; + description = " + Where the tftp server files are stored + "; + }; + }; + }; + }; + }; +in + +###### implementation + +let + + inherit (config.services.xinetd) tftpd; + inherit (pkgs) xinetd; + + tftpservice = '' + service tftp + { + protocol = udp + port = 69 + socket_type = dgram + wait = yes + user = nobody + server = ${pkgs.netkittftp}/sbin/in.tftpd + server_args = ${tftpd.path} + disable = no + } + ''; + + configFile = pkgs.writeText "xinetd.conf" '' + defaults + { + log_type = SYSLOG daemon info + log_on_failure = HOST + log_on_success = PID HOST DURATION EXIT + } + ${if tftpd.enable then tftpservice else ""} + ''; + +in + +mkIf config.services.xinetd.enable { + require = [ + options + ]; + + services = { + extraJobs = [{ + name = "xinetd"; + + job = '' + description "xinetd server" + + start on network-interfaces/started + stop on network-interfaces/stop + + start script + + mkdir -p ${tftpd.path} + end script + + respawn ${xinetd}/sbin/xinetd -stayalive -f ${configFile} + ''; + + }]; + }; +}