* Modularised the xinetd service. tftp has been factored out into a
separate module, which just declares a configuration value that causes the xinetd module to add it to xinetd.conf. Also Nixified the service declarations to abstract over the inetd implementation. * Renamed the services.xinetd.tftpd options to services.tftpd. The fact that the tftpd module uses xinetd is an implementation detail. * xinetd: use -dontfork to let Upstart monitor it, and use -syslog to get error messages at startup. svn path=/nixos/trunk/; revision=16803
This commit is contained in:
parent
fb730174a1
commit
8e6ad840f2
@ -68,9 +68,10 @@
|
|||||||
./services/networking/portmap.nix
|
./services/networking/portmap.nix
|
||||||
./services/networking/ssh/lshd.nix
|
./services/networking/ssh/lshd.nix
|
||||||
./services/networking/ssh/sshd.nix
|
./services/networking/ssh/sshd.nix
|
||||||
|
./services/networking/tftpd.nix
|
||||||
./services/networking/vsftpd.nix
|
./services/networking/vsftpd.nix
|
||||||
./services/networking/xinetd.nix
|
|
||||||
./services/networking/wpa_supplicant.nix
|
./services/networking/wpa_supplicant.nix
|
||||||
|
./services/networking/xinetd.nix
|
||||||
./services/printing/cupsd.nix
|
./services/printing/cupsd.nix
|
||||||
./services/scheduling/atd.nix
|
./services/scheduling/atd.nix
|
||||||
./services/scheduling/cron.nix
|
./services/scheduling/cron.nix
|
||||||
|
43
modules/services/networking/tftpd.nix
Normal file
43
modules/services/networking/tftpd.nix
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
services.tftpd.enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable the anonymous FTP user.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.tftpd.path = mkOption {
|
||||||
|
default = "/home/tftp";
|
||||||
|
description = ''
|
||||||
|
Where the tftp server files are stored
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = mkIf config.services.tftpd.enable {
|
||||||
|
|
||||||
|
services.xinetd.enable = true;
|
||||||
|
|
||||||
|
services.xinetd.services = singleton
|
||||||
|
{ name = "tftp";
|
||||||
|
protocol = "udp";
|
||||||
|
server = "${pkgs.netkittftp}/sbin/in.tftpd";
|
||||||
|
serverArgs = "${config.services.tftpd.path}";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -1,95 +1,135 @@
|
|||||||
{pkgs, config, ...}:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
###### interface
|
with pkgs.lib;
|
||||||
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
|
let
|
||||||
|
|
||||||
inherit (config.services.xinetd) tftpd;
|
cfg = config.services.xinetd;
|
||||||
|
|
||||||
inherit (pkgs) xinetd;
|
inherit (pkgs) xinetd;
|
||||||
|
|
||||||
tftpservice = ''
|
configFile = pkgs.writeText "xinetd.conf"
|
||||||
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
|
defaults
|
||||||
{
|
{
|
||||||
log_type = SYSLOG daemon info
|
log_type = SYSLOG daemon info
|
||||||
log_on_failure = HOST
|
log_on_failure = HOST
|
||||||
log_on_success = PID HOST DURATION EXIT
|
log_on_success = PID HOST DURATION EXIT
|
||||||
}
|
}
|
||||||
${if tftpd.enable then tftpservice else ""}
|
|
||||||
|
${concatMapStrings makeService cfg.services}
|
||||||
|
'';
|
||||||
|
|
||||||
|
makeService = srv:
|
||||||
|
''
|
||||||
|
service ${srv.name}
|
||||||
|
{
|
||||||
|
protocol = ${srv.protocol}
|
||||||
|
${optionalString srv.unlisted "type = UNLISTED"}
|
||||||
|
socket_type = ${if srv.protocol == "udp" then "dgram" else "stream"}
|
||||||
|
${if srv.port != 0 then "port = ${toString srv.port}" else ""}
|
||||||
|
wait = ${if srv.protocol == "udp" then "yes" else "no"}
|
||||||
|
user = ${srv.user}
|
||||||
|
server = ${srv.server}
|
||||||
|
${optionalString (srv.serverArgs != "") "server_args = ${srv.serverArgs}"}
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
mkIf config.services.xinetd.enable {
|
{
|
||||||
require = [
|
|
||||||
options
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
###### interface
|
||||||
extraJobs = [{
|
|
||||||
name = "xinetd";
|
|
||||||
|
|
||||||
job = ''
|
options = {
|
||||||
description "xinetd server"
|
|
||||||
|
|
||||||
start on network-interfaces/started
|
services.xinetd.enable = mkOption {
|
||||||
stop on network-interfaces/stop
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable the xinetd super-server daemon.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
start script
|
services.xinetd.services = mkOption {
|
||||||
|
default = [];
|
||||||
mkdir -p ${tftpd.path}
|
description = ''
|
||||||
end script
|
A list of services provided by xinetd.
|
||||||
|
|
||||||
respawn ${xinetd}/sbin/xinetd -stayalive -f ${configFile}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}];
|
type = types.list types.optionSet;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
example = "login";
|
||||||
|
description = "Name of the service.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protocol = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "tcp";
|
||||||
|
description =
|
||||||
|
"Protocol of the service. Usually <literal>tcp</literal> or <literal>udp</literal>.";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 0;
|
||||||
|
example = 123;
|
||||||
|
description = "Port number of the service.";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "nobody";
|
||||||
|
description = "User account for the service";
|
||||||
|
};
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
example = "/foo/bin/ftpd";
|
||||||
|
description = "Path of the program that implements the service.";
|
||||||
|
};
|
||||||
|
|
||||||
|
serverArgs = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "";
|
||||||
|
description = "Command-line arguments for the server program.";
|
||||||
|
};
|
||||||
|
|
||||||
|
unlisted = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether this server is listed in
|
||||||
|
<filename>/etc/services</filename>. If so, the port
|
||||||
|
number can be omitted.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
jobs = singleton
|
||||||
|
{ name = "xinetd";
|
||||||
|
|
||||||
|
description = "xinetd server";
|
||||||
|
|
||||||
|
startOn = "network-interfaces/started";
|
||||||
|
stopOn = "network-interfaces/stop";
|
||||||
|
|
||||||
|
exec = "${xinetd}/sbin/xinetd -syslog daemon -dontfork -stayalive -f ${configFile}";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ in
|
|||||||
|
|
||||||
config = mkIf (xcfg.enable && cfg.enable) {
|
config = mkIf (xcfg.enable && cfg.enable) {
|
||||||
|
|
||||||
# If KDE 4 is enabled, make it default desktop manager (unless
|
# If KDE 4 is enabled, make it the default desktop manager (unless
|
||||||
# overriden by the user's configuration).
|
# overriden by the user's configuration).
|
||||||
# !!! doesn't work yet ("Multiple definitions. Only one is allowed
|
# !!! doesn't work yet ("Multiple definitions. Only one is allowed
|
||||||
# for this option.")
|
# for this option.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user