如何在运行时加载Strongswan插件

时间:2019-12-24 17:11:01

标签: linux plugins centos6 strongswan

我们为 libcharon 开发了一个插件,该插件可以调用我们的代码。因为我们正在使用此插件编译Strongswan,所以这在我们的应用程序和Strongswan之间造成了不必要的耦合。

我们将此插件称为 MyPlugin 。 它的配置如下:

$ cat /etc/strongswan/strongswan.d/charon/myplugin.conf
myplugin {

    # Whether to load the plugin. Can also be an integer to increase the
    # priority of this plugin.
    load = yes

    proxy
    {
        # Should send to proxy
          send_to_proxy = yes
    }
    log
    {
                # Should save to file
                  log_path = /var/log/myplugin.log
                  log_ips = yes
    }
}

我们想通过将此插件编译为应用程序的一部分,实现Strongswan接口来逆转这种依赖性。

问题是,strongswan支持吗? 可以将插件部署在已运行Strongswan的计算机上,并让Strongswan加载并使用它吗?怎么样?

我们正在CentOS 6上运行Strongswan 5.1.5。

1 个答案:

答案 0 :(得分:0)

是的,您可以这样做。但是,有一些警告:

  • strongSwan不提供任何稳定的API。因此,仅当您针对将最终加载该插件的strongSwan版本的标头编译插件时,这才安全地工作。
  • 您将需要从正在编译的构建(或相同平台的等效配置的构建)中获取config.h。编译插件时,您可以通过-include传递路径。
  • 通过配置代码段加载插件需要一个适当的strongswan.conf文件(即启用modular plugin loading并在strongswan.d中包含配置代码段,您可以在其中放置插件的代码段-{{3} }应该可以正常工作。)
  • 第三方插件可能存在许可问题,无论是否在树外(strongSwan都是根据GPLv2许可的,但是可以使用商业许可)。

您可以找到树外插件the default的示例。