mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-17 14:19:58 +03:00
Merge pull request #31019 from teto/strongswan_rebased
[RFC/RDY] make l2tp work with Strongswan
This commit is contained in:
commit
9936ed4920
@ -335,6 +335,7 @@ in {
|
||||
|
||||
preStart = ''
|
||||
mkdir -m 700 -p /etc/NetworkManager/system-connections
|
||||
mkdir -m 700 -p /etc/ipsec.d
|
||||
mkdir -m 755 -p ${stateDirs}
|
||||
'';
|
||||
};
|
||||
|
@ -32,13 +32,13 @@ let
|
||||
${caConf}
|
||||
'';
|
||||
|
||||
strongswanConf = {setup, connections, ca, secrets, managePlugins, enabledPlugins}: toFile "strongswan.conf" ''
|
||||
strongswanConf = {setup, connections, ca, secretsFile, managePlugins, enabledPlugins}: toFile "strongswan.conf" ''
|
||||
charon {
|
||||
${if managePlugins then "load_modular = no" else ""}
|
||||
${if managePlugins then ("load = " + (concatStringsSep " " enabledPlugins)) else ""}
|
||||
plugins {
|
||||
stroke {
|
||||
secrets_file = ${ipsecSecrets secrets}
|
||||
secrets_file = ${secretsFile}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,18 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = with cfg; mkIf enable {
|
||||
|
||||
config = with cfg;
|
||||
let
|
||||
secretsFile = ipsecSecrets cfg.secrets;
|
||||
in
|
||||
mkIf enable
|
||||
{
|
||||
|
||||
# here we should use the default strongswan ipsec.secrets and
|
||||
# append to it (default one is empty so not a pb for now)
|
||||
environment.etc."ipsec.secrets".source = secretsFile;
|
||||
|
||||
systemd.services.strongswan = {
|
||||
description = "strongSwan IPSec Service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
@ -143,11 +154,15 @@ in
|
||||
wants = [ "keys.target" ];
|
||||
after = [ "network-online.target" "keys.target" ];
|
||||
environment = {
|
||||
STRONGSWAN_CONF = strongswanConf { inherit setup connections ca secrets managePlugins enabledPlugins; };
|
||||
STRONGSWAN_CONF = strongswanConf { inherit setup connections ca secretsFile managePlugins enabledPlugins; };
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.strongswan}/sbin/ipsec start --nofork";
|
||||
};
|
||||
preStart = ''
|
||||
# with 'nopeerdns' setting, ppp writes into this folder
|
||||
mkdir -m 700 -p /etc/ppp
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ stdenv.mkDerivation rec {
|
||||
postPatch = ''
|
||||
sed -i -e 's%"\(/usr/sbin\|/usr/pkg/sbin\|/usr/local/sbin\)/[^"]*",%%g' ./src/nm-l2tp-service.c
|
||||
|
||||
substituteInPlace ./Makefile.am \
|
||||
--replace '$(sysconfdir)/dbus-1/system.d' "$out/etc/dbus-1/system.d"
|
||||
|
||||
substituteInPlace ./src/nm-l2tp-service.c \
|
||||
--replace /sbin/ipsec ${strongswan}/bin/ipsec \
|
||||
--replace /sbin/xl2tpd ${xl2tpd}/bin/xl2tpd
|
||||
|
@ -76,6 +76,11 @@ stdenv.mkDerivation rec {
|
||||
"--enable-sqlite" ]
|
||||
++ optional enableNetworkManager "--enable-nm";
|
||||
|
||||
postInstall = ''
|
||||
# this is needed for l2tp
|
||||
echo "include /etc/ipsec.secrets" >> $out/etc/ipsec.secrets
|
||||
'';
|
||||
|
||||
NIX_LDFLAGS = "-lgcc_s" ;
|
||||
|
||||
meta = {
|
||||
|
Loading…
Reference in New Issue
Block a user