cntlm service: cleanup non working config options (#26578)
- extraConfig was not working - add possibility to add cntlm.conf in verbatime form - create cntlm user as system user - add no proxy option
This commit is contained in:
parent
5172e1afee
commit
c9802321c1
@ -5,15 +5,33 @@ with lib;
|
|||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.cntlm;
|
cfg = config.services.cntlm;
|
||||||
uid = config.ids.uids.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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
options = {
|
options.services.cntlm = {
|
||||||
|
|
||||||
services.cntlm = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
@ -40,6 +58,7 @@ in
|
|||||||
|
|
||||||
netbios_hostname = mkOption {
|
netbios_hostname = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
default = "";
|
||||||
description = ''
|
description = ''
|
||||||
The hostname of your machine.
|
The hostname of your machine.
|
||||||
'';
|
'';
|
||||||
@ -53,6 +72,15 @@ in
|
|||||||
number of proxies. Should one proxy fail, cntlm automatically moves on to the next one. The connect request fails only if the whole
|
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.
|
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 {
|
port = mkOption {
|
||||||
@ -61,6 +89,12 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
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;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
description = "Verbatim contents of <filename>cntlm.conf</filename>.";
|
description = "Verbatim contents of <filename>cntlm.conf</filename>.";
|
||||||
@ -68,47 +102,25 @@ in
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf config.services.cntlm.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services.cntlm = {
|
systemd.services.cntlm = {
|
||||||
description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
|
description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "forking";
|
|
||||||
User = "cntlm";
|
User = "cntlm";
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.cntlm}/bin/cntlm -U cntlm \
|
${pkgs.cntlm}/bin/cntlm -U cntlm -c ${configFile} -v -f
|
||||||
-c ${pkgs.writeText "cntlm_config" cfg.extraConfig}
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.cntlm.netbios_hostname = mkDefault config.networking.hostName;
|
|
||||||
|
|
||||||
users.extraUsers.cntlm = {
|
users.extraUsers.cntlm = {
|
||||||
name = "cntlm";
|
name = "cntlm";
|
||||||
description = "cntlm system-wide daemon";
|
description = "cntlm system-wide daemon";
|
||||||
home = "/var/empty";
|
isSystemUser = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
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}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user