stroke_socket_t *socket;
};
+METHOD(plugin_t, get_name, char*,
+ private_stroke_plugin_t *this)
+{
+ return "stroke";
+}
+
/**
- * Implementation of stroke_plugin_t.destroy
+ * Register stroke plugin features
*/
-static void destroy(private_stroke_plugin_t *this)
+static bool register_stroke(private_stroke_plugin_t *this,
+ plugin_feature_t *feature, bool reg, void *data)
+{
+ if (reg)
+ {
+ this->socket = stroke_socket_create();
+ }
+ else
+ {
+ DESTROY_IF(this->socket);
+ }
+ return TRUE;
+}
+
+METHOD(plugin_t, get_features, int,
+ private_stroke_plugin_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[] = {
+ PLUGIN_CALLBACK((plugin_feature_callback_t)register_stroke, NULL),
+ PLUGIN_PROVIDE(CUSTOM, "stroke"),
+ PLUGIN_SDEPEND(PRIVKEY, KEY_RSA),
+ PLUGIN_SDEPEND(PRIVKEY, KEY_ECDSA),
+ PLUGIN_SDEPEND(PRIVKEY, KEY_DSA),
+ PLUGIN_SDEPEND(CERT_DECODE, CERT_ANY),
+ PLUGIN_SDEPEND(CERT_DECODE, CERT_X509),
+ PLUGIN_SDEPEND(CERT_DECODE, CERT_X509_CRL),
+ PLUGIN_SDEPEND(CERT_DECODE, CERT_X509_AC),
+ PLUGIN_SDEPEND(CERT_DECODE, CERT_TRUSTED_PUBKEY),
+ };
+ *features = f;
+ return countof(f);
+}
+
+METHOD(plugin_t, destroy, void,
+ private_stroke_plugin_t *this)
{
- this->socket->destroy(this->socket);
free(this);
}
*/
plugin_t *stroke_plugin_create()
{
- private_stroke_plugin_t *this = malloc_thing(private_stroke_plugin_t);
+ private_stroke_plugin_t *this;
- this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
- this->socket = stroke_socket_create();
- if (this->socket == NULL)
- {
- free(this);
+ if (!lib->caps->keep(lib->caps, CAP_CHOWN))
+ { /* required to chown(2) stroke socket */
+ DBG1(DBG_CFG, "stroke plugin requires CAP_CHOWN capability");
return NULL;
}
+
+ INIT(this,
+ .public = {
+ .plugin = {
+ .get_name = _get_name,
+ .reload = (void*)return_false,
+ .get_features = _get_features,
+ .destroy = _destroy,
+ },
+ },
+ );
+
return &this->public.plugin;
}