diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wg2nd.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/wg2nd.cpp b/src/wg2nd.cpp index 9397a0b..deb3212 100644 --- a/src/wg2nd.cpp +++ b/src/wg2nd.cpp @@ -372,7 +372,7 @@ namespace wg2nd { } static std::string _gen_netdev_cfg(Config const & cfg, uint32_t fwd_table, std::filesystem::path const & private_keyfile, - std::vector<SystemdFilespec> & symmetric_keyfiles) { + std::filesystem::path const & output_path, std::vector<SystemdFilespec> & symmetric_keyfiles) { std::stringstream netdev; netdev << "# Autogenerated by wg2nd\n"; @@ -429,7 +429,7 @@ namespace wg2nd { .contents = peer.preshared_key + "\n", }); - netdev << "PresharedKeyFile = " << filename << "\n"; + netdev << "PresharedKeyFile = " << (output_path / filename).c_str() << "\n"; } for(Cidr const & cidr : peer.allowed_ips) { @@ -571,12 +571,15 @@ namespace wg2nd { std::vector<SystemdFilespec> symmetric_keyfiles; std::filesystem::path keyfile_path; + std::filesystem::path output_path; if(keyfile_or_output_path.has_filename()) { keyfile_path = keyfile_or_output_path; + output_path = keyfile_or_output_path.parent_path(); } else { std::string private_keyfile = private_keyfile_name(cfg.intf.private_key); keyfile_path = keyfile_or_output_path / private_keyfile; + output_path = keyfile_or_output_path; } std::vector<std::string> warnings; @@ -601,7 +604,7 @@ if(!cfg.intf.field_.empty()) { \ return SystemdConfig { .netdev = { .name = basename + ".netdev", - .contents = _gen_netdev_cfg(cfg, fwd_table, keyfile_path, symmetric_keyfiles), + .contents = _gen_netdev_cfg(cfg, fwd_table, keyfile_path, output_path, symmetric_keyfiles), }, .network = { .name = basename + ".network", |