Go to the documentation of this file.
85 get_env(
const char *name,
const char *envp[])
90 const int namelen = strlen(name);
91 for (i = 0; envp[i]; ++i)
93 if (!strncmp(envp[i], name, namelen))
95 const char *cp = envp[i] + namelen;
127 const char **envp = args->
envp;
132 fprintf(stderr,
"sample-client-connect: this plugin is incompatible with the running version of OpenVPN\n");
213 FILE *fp = fopen(name,
"w");
221 const char *p =
get_env(
"plugin_cc_config", envp);
224 fprintf(fp,
"%s\n", p);
228 fprintf(fp,
"push \"echo sample-cc plugin 1 called\"\n");
231 if (
get_env(
"UV_WANT_CC_DISABLE", envp))
234 fprintf(fp,
"disable\n");
244 const char *ccd_file =
get_env(
"client_connect_deferred_file", envp);
248 "'client_connect_deferred_file' not set -> fail", seconds);
259 int fd = open(ccd_file, O_WRONLY);
266 if (
write(fd,
"2", 1) != 1)
288 waitpid(p1, NULL, 0);
318 const char *p =
get_env(
"UV_WANT_CC_FAIL", envp);
326 fd = open(ccd_file, O_WRONLY);
355 for (
int i = 0;
argv[i]; i++)
359 for (
int i = 0; envp[i]; i++)
366 const char *p =
get_env(
"UV_WANT_CC_ASYNC", envp);
379 p =
get_env(
"UV_WANT_CC_FAIL", envp);
399 const char *want_async =
get_env(
"UV_WANT_CC2_ASYNC", envp);
400 const char *want_fail =
get_env(
"UV_WANT_CC2_FAIL", envp);
401 const char *want_disable =
get_env(
"UV_WANT_CC2_DISABLE", envp);
408 const char *client_config =
get_env(
"plugin_cc2_config", envp);
412 client_config =
"push \"setenv CC2 MOOH\"\n";
443 rl->
name = strdup(
"config");
447 rl->
value = strdup(
"disable\n");
451 rl->
value = strdup(client_config);
501 rl->
name = strdup(
"config");
505 rl->
value = strdup(
"disable\n");
531 void *per_client_context,
598 printf(
"FUNC: openvpn_plugin_client_constructor_v1\n");
605 printf(
"FUNC: openvpn_plugin_client_destructor_v1\n");
606 free(per_client_context);
613 printf(
"FUNC: openvpn_plugin_close_v1\n");
OPENVPN_EXPORT void * openvpn_plugin_client_constructor_v1(openvpn_plugin_handle_t handle)
plugin_base64_decode_t plugin_base64_decode
#define OPENVPN_PLUGIN_CLIENT_CONNECT_V2
int openvpn_plugin_client_connect(struct plugin_context *context, const char **argv, const char **envp)
OPENVPN_EXPORT int openvpn_plugin_func_v2(openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[], void *per_client_context, struct openvpn_plugin_string_list **return_list)
#define OPENVPN_PLUGIN_LEARN_ADDRESS
#define OPENVPN_PLUGIN_UP
#define OPENVPN_PLUGIN_DOWN
plugin_secure_memzero_t plugin_secure_memzero
static const char * get_env(const char *name, const char *envp[])
Arguments used to transport variables to the plug-in.
Contains all state information for one tunnel.
static plugin_base64_decode_t plugin_base64_decode
void(* plugin_log_t)(openvpn_plugin_log_flags_t flags, const char *plugin_name, const char *format,...) _ovpn_chk_fmt(3
int write_cc_options_file(const char *name, const char **envp)
#define OPENVPN_PLUGIN_MASK(x)
int openvpn_plugin_client_connect_v2(struct plugin_context *context, struct plugin_per_client_context *pcc, const char **envp, struct openvpn_plugin_string_list **return_list)
OPENVPN_EXPORT void openvpn_plugin_close_v1(openvpn_plugin_handle_t handle)
int openvpn_plugin_client_connect_defer_v2(struct plugin_context *context, struct plugin_per_client_context *pcc, struct openvpn_plugin_string_list **return_list)
static plugin_log_t plugin_log
OPENVPN_EXPORT int openvpn_plugin_open_v3(const int v3structver, struct openvpn_plugin_args_open_in const *args, struct openvpn_plugin_args_open_return *ret)
#define OPENVPN_PLUGIN_FUNC_ERROR
static plugin_secure_memzero_t plugin_secure_memzero
int(* plugin_base64_decode_t)(const char *str, void *data, int size)
Export of openvpn_base64_decode() to be used inside plug-ins.
#define OPENVPN_PLUGIN_IPCHANGE
#define OPENVPN_PLUGIN_FUNC_DEFERRED
#define OPENVPN_PLUGIN_ROUTE_UP
OPENVPN_EXPORT void openvpn_plugin_client_destructor_v1(openvpn_plugin_handle_t handle, void *per_client_context)
static int atoi_null0(const char *str)
#define OPENVPN_PLUGIN_TLS_VERIFY
void(*) typedef void(*) typedef void(* plugin_secure_memzero_t)(void *data, size_t len)
Export of secure_memzero() to be used inside plug-ins.
#define OPENVPN_PLUGIN_CLIENT_DISCONNECT
Arguments used to transport variables from the plug-in back to the OpenVPN process.
openvpn_plugin_handle_t handle
#define OPENVPN_PLUGIN_FUNC_SUCCESS
#define OPENVPN_PLUGIN_TLS_FINAL
const char * client_config
void * openvpn_plugin_handle_t
int cc_handle_deferred_v1(int seconds, const char *name, const char **envp)
#define OPENVPN_PLUGIN_CLIENT_CONNECT
struct openvpn_plugin_callbacks * callbacks
#define OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2