blob: 5b5068e43d7c1c1e3bd81a77b6175a92484f5b13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.cntlm;
configFile = if cfg.configText != "" then
pkgs.writeText "cntlm.conf" ''
${cfg.configText}
''
else
pkgs.writeText "lighttpd.conf" ''
# Cntlm Authentication Proxy Configuration
Username ${cfg.username}
Domain ${cfg.domain}
Password ${cfg.password}
${optionalString (cfg.netbios_hostname != "") "Workstation ${cfg.netbios_hostname}"}
${concatMapStrings (entry: "Proxy ${entry}\n") cfg.proxy}
${optionalString (cfg.noproxy != []) "NoProxy ${concatStringsSep ", " cfg.noproxy}"}
${concatMapStrings (port: ''
Listen ${toString port}
'') cfg.port}
${cfg.extraConfig}
'';
in
{
options.services.cntlm = {
enable = mkEnableOption "cntlm, which starts 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";
type = types.str;
description = ''Proxy account password. Note: use chmod 0600 on /etc/cntlm.password for security.'';
};
netbios_hostname = mkOption {
type = types.str;
default = "";
description = ''
The hostname of your machine.
'';
};
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.
'';
example = [ "proxy.example.com:81" ];
};
noproxy = mkOption {
description = ''
A list of domains where the proxy is skipped.
'';
default = [];
example = [ "*.example.com" "example.com" ];
};
port = mkOption {
default = [3128];
description = "Specifies on which ports the cntlm daemon listens.";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = "Additional config appended to the end of the generated <filename>cntlm.conf</filename>.";
};
configText = mkOption {
type = types.lines;
default = "";
description = "Verbatim contents of <filename>cntlm.conf</filename>.";
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services.cntlm = {
description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "cntlm";
ExecStart = ''
${pkgs.cntlm}/bin/cntlm -U cntlm -c ${configFile} -v -f
'';
};
};
users.users.cntlm = {
name = "cntlm";
description = "cntlm system-wide daemon";
isSystemUser = true;
};
};
}
|