diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-05-24 23:26:11 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-05-24 23:26:11 +0000 |
commit | 344ee9181734dcd5a922b8b2a7ebea4ce818a0b0 (patch) | |
tree | 8a4c3724971a0c81debc97d3bba62138aab3a247 /plugin.c | |
parent | Did: (diff) | |
download | openvpn-344ee9181734dcd5a922b8b2a7ebea4ce818a0b0.tar.xz |
Support asynchronous/deferred authentication in
OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY plugin handler.
See documentation in openvpn-plugin.h and example
usage in plugin/defer/simple.c.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2969 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'plugin.c')
-rw-r--r-- | plugin.c | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -347,7 +347,7 @@ plugin_call_item (const struct plugin *p, plugin_type_name (type), status); - if (status != OPENVPN_PLUGIN_FUNC_SUCCESS) + if (status == OPENVPN_PLUGIN_FUNC_ERROR) msg (M_WARN, "PLUGIN_CALL: plugin function %s failed with status %d: %s", plugin_type_name (type), status, @@ -541,7 +541,8 @@ plugin_call (const struct plugin_list *pl, int i; const char **envp; const int n = plugin_n (pl); - int count = 0; + bool error = false; + bool deferred = false; mutex_lock_static (L_PLUGIN); @@ -550,13 +551,16 @@ plugin_call (const struct plugin_list *pl, for (i = 0; i < n; ++i) { - if (!plugin_call_item (&pl->common->plugins[i], - pl->per_client.per_client_context[i], - type, - args, - pr ? &pr->list[i] : NULL, - envp)) - ++count; + const int status = plugin_call_item (&pl->common->plugins[i], + pl->per_client.per_client_context[i], + type, + args, + pr ? &pr->list[i] : NULL, + envp); + if (status == OPENVPN_PLUGIN_FUNC_ERROR) + error = true; + else if (status == OPENVPN_PLUGIN_FUNC_DEFERRED) + deferred = true; } if (pr) @@ -566,12 +570,13 @@ plugin_call (const struct plugin_list *pl, gc_free (&gc); - return count == n ? 0 : 1; /* if any one plugin in the chain failed, return failure (1) */ - } - else - { - return 0; + if (error) + return OPENVPN_PLUGIN_FUNC_ERROR; + else if (deferred) + return OPENVPN_PLUGIN_FUNC_DEFERRED; } + + return OPENVPN_PLUGIN_FUNC_SUCCESS; } void |