2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-10-10 00:34:32 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-10-10 00:34:32 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.cntlm;
|
|
|
|
uid = config.ids.uids.cntlm;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
2012-06-08 16:29:31 +02:00
|
|
|
services.cntlm = {
|
2011-10-10 00:34:32 +02:00
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the cntlm, which start a local proxy.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
description = ''
|
|
|
|
Proxy account name, without the possibility to include domain name ('at' sign is interpreted literally).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
domain = mkOption {
|
|
|
|
description = ''Proxy account domain/workgroup name.'';
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
default = "/etc/cntlm.password";
|
2014-04-14 16:26:48 +02:00
|
|
|
type = types.str;
|
2011-10-10 00:34:32 +02:00
|
|
|
description = ''Proxy account password. Note: use chmod 0600 on /etc/cntlm.password for security.'';
|
|
|
|
};
|
|
|
|
|
|
|
|
netbios_hostname = mkOption {
|
2013-10-30 11:02:04 +01:00
|
|
|
type = types.str;
|
2011-10-10 00:34:32 +02:00
|
|
|
description = ''
|
2012-06-08 16:29:31 +02:00
|
|
|
The hostname of your machine.
|
2011-10-10 00:34:32 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
proxy = mkOption {
|
|
|
|
description = ''
|
|
|
|
A list of NTLM/NTLMv2 authenticating HTTP proxies.
|
|
|
|
|
|
|
|
Parent proxy, which requires authentication. The same as proxy on the command-line, can be used more than once to specify unlimited
|
|
|
|
number of proxies. Should one proxy fail, cntlm automatically moves on to the next one. The connect request fails only if the whole
|
|
|
|
list of proxies is scanned and (for each request) and found to be invalid. Command-line takes precedence over the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = [3128];
|
|
|
|
description = "Specifies on which ports the cntlm daemon listens.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Verbatim contents of <filename>cntlm.conf</filename>.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.cntlm.enable {
|
2015-11-29 01:30:42 +01:00
|
|
|
systemd.services.cntlm = {
|
|
|
|
description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
|
|
|
User = "cntlm";
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.cntlm}/bin/cntlm -U cntlm \
|
|
|
|
-c ${pkgs.writeText "cntlm_config" cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2012-06-08 16:29:31 +02:00
|
|
|
services.cntlm.netbios_hostname = mkDefault config.networking.hostName;
|
|
|
|
|
2015-11-29 01:30:42 +01:00
|
|
|
users.extraUsers.cntlm = {
|
2012-06-08 16:29:31 +02:00
|
|
|
name = "cntlm";
|
|
|
|
description = "cntlm system-wide daemon";
|
|
|
|
home = "/var/empty";
|
2011-10-10 00:34:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
services.cntlm.extraConfig =
|
|
|
|
''
|
|
|
|
# Cntlm Authentication Proxy Configuration
|
|
|
|
Username ${cfg.username}
|
|
|
|
Domain ${cfg.domain}
|
|
|
|
Password ${cfg.password}
|
|
|
|
Workstation ${cfg.netbios_hostname}
|
|
|
|
${concatMapStrings (entry: "Proxy ${entry}\n") cfg.proxy}
|
|
|
|
|
|
|
|
${concatMapStrings (port: ''
|
|
|
|
Listen ${toString port}
|
|
|
|
'') cfg.port}
|
2015-11-29 01:30:42 +01:00
|
|
|
'';
|
2011-10-10 00:34:32 +02:00
|
|
|
};
|
2012-06-08 16:29:31 +02:00
|
|
|
|
2011-10-10 00:34:32 +02:00
|
|
|
}
|