mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-16 17:14:00 +00:00
Merge pull request #241680 from 4z3/networking.nftables.checkRulesetRedirects
This commit is contained in:
commit
ca6ed1cc8d
@ -70,6 +70,26 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
networking.nftables.checkRulesetRedirects = mkOption {
|
||||
type = types.addCheck (types.attrsOf types.path) (attrs: all types.path.check (attrNames attrs));
|
||||
default = {
|
||||
"/etc/hosts" = config.environment.etc.hosts.source;
|
||||
"/etc/protocols" = config.environment.etc.protocols.source;
|
||||
"/etc/services" = config.environment.etc.services.source;
|
||||
};
|
||||
defaultText = literalExpression ''
|
||||
{
|
||||
"/etc/hosts" = config.environment.etc.hosts.source;
|
||||
"/etc/protocols" = config.environment.etc.protocols.source;
|
||||
"/etc/services" = config.environment.etc.services.source;
|
||||
}
|
||||
'';
|
||||
description = mdDoc ''
|
||||
Set of paths that should be intercepted and rewritten while checking the ruleset
|
||||
using `pkgs.buildPackages.libredirect`.
|
||||
'';
|
||||
};
|
||||
|
||||
networking.nftables.preCheckRuleset = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
@ -282,7 +302,7 @@ in
|
||||
cp $out ruleset.conf
|
||||
sed 's|include "${deletionsScriptVar}"||' -i ruleset.conf
|
||||
${cfg.preCheckRuleset}
|
||||
export NIX_REDIRECTS=/etc/protocols=${pkgs.buildPackages.iana-etc}/etc/protocols:/etc/services=${pkgs.buildPackages.iana-etc}/etc/services
|
||||
export NIX_REDIRECTS=${escapeShellArg (concatStringsSep ":" (mapAttrsToList (n: v: "${n}=${v}") cfg.checkRulesetRedirects))}
|
||||
LD_PRELOAD="${pkgs.buildPackages.libredirect}/lib/libredirect.so ${pkgs.buildPackages.lklWithFirewall.lib}/lib/liblkl-hijack.so" \
|
||||
${pkgs.buildPackages.nftables}/bin/nft --check --file ruleset.conf
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user