86get_env(
const char *name,
const char *envp[])
90 const size_t namelen = strlen(name);
91 for (
int i = 0; envp[
i]; ++
i)
93 if (!strncmp(envp[
i], name, namelen))
95 const char *cp = envp[
i] + namelen;
126 const char **envp = args->
envp;
132 "sample-client-connect: this plugin is incompatible with the running version of OpenVPN\n");
212 FILE *fp = fopen(name,
"w");
220 const char *p =
get_env(
"plugin_cc_config", envp);
223 fprintf(fp,
"%s\n", p);
227 fprintf(fp,
"push \"echo sample-cc plugin 1 called\"\n");
230 if (
get_env(
"UV_WANT_CC_DISABLE", envp))
233 fprintf(fp,
"disable\n");
243 const char *ccd_file =
get_env(
"client_connect_deferred_file", envp);
247 "env has UV_WANT_CC_ASYNC=%d, but "
248 "'client_connect_deferred_file' not set -> fail",
260 int fd = open(ccd_file, O_WRONLY);
267 if (
write(fd,
"2", 1) != 1)
289 waitpid(p1, NULL, 0);
313 sleep((
unsigned int)seconds);
319 const char *p =
get_env(
"UV_WANT_CC_FAIL", envp);
327 fd = open(ccd_file, O_WRONLY);
358 for (
int i = 0; envp[
i];
i++)
365 const char *p =
get_env(
"UV_WANT_CC_ASYNC", envp);
378 p =
get_env(
"UV_WANT_CC_FAIL", envp);
397 const char *want_async =
get_env(
"UV_WANT_CC2_ASYNC", envp);
398 const char *want_fail =
get_env(
"UV_WANT_CC2_FAIL", envp);
399 const char *want_disable =
get_env(
"UV_WANT_CC2_DISABLE", envp);
406 const char *client_config =
get_env(
"plugin_cc2_config", envp);
410 client_config =
"push \"setenv CC2 MOOH\"\n";
441 rl->
name = strdup(
"config");
445 rl->
value = strdup(
"disable\n");
449 rl->
value = strdup(client_config);
496 rl->
name = strdup(
"config");
500 rl->
value = strdup(
"disable\n");
523 const char *envp[],
void *per_client_context,
588 printf(
"FUNC: openvpn_plugin_client_constructor_v1\n");
595 printf(
"FUNC: openvpn_plugin_client_destructor_v1\n");
596 free(per_client_context);
603 printf(
"FUNC: openvpn_plugin_close_v1\n");
#define OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2
#define OPENVPN_PLUGIN_CLIENT_CONNECT_V2
#define OPENVPN_PLUGIN_LEARN_ADDRESS
#define OPENVPN_PLUGIN_CLIENT_CONNECT
#define OPENVPN_PLUGIN_DOWN
void * openvpn_plugin_handle_t
#define OPENVPN_PLUGIN_MASK(x)
#define OPENVPN_PLUGIN_TLS_FINAL
#define OPENVPN_PLUGIN_TLS_VERIFY
void(* plugin_log_t)(openvpn_plugin_log_flags_t flags, const char *plugin_name, const char *format,...) _ovpn_chk_fmt(3
#define OPENVPN_PLUGIN_IPCHANGE
#define OPENVPN_PLUGIN_FUNC_DEFERRED
#define OPENVPN_PLUGIN_FUNC_SUCCESS
#define OPENVPN_PLUGIN_UP
#define OPENVPN_PLUGIN_CLIENT_DISCONNECT
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_ROUTE_UP
#define OPENVPN_PLUGIN_FUNC_ERROR
int(* plugin_base64_decode_t)(const char *str, void *data, int size)
Export of openvpn_base64_decode() to be used inside plug-ins.
OPENVPN_EXPORT void openvpn_plugin_close_v1(openvpn_plugin_handle_t handle)
static plugin_log_t plugin_log
int openvpn_plugin_client_connect_defer_v2(struct plugin_context *context, struct plugin_per_client_context *pcc, struct openvpn_plugin_string_list **return_list)
int cc_handle_deferred_v1(int seconds, const char *name, const char **envp)
OPENVPN_EXPORT void openvpn_plugin_client_destructor_v1(openvpn_plugin_handle_t handle, void *per_client_context)
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)
static plugin_secure_memzero_t plugin_secure_memzero
int write_cc_options_file(const char *name, const char **envp)
static const char * get_env(const char *name, const char *envp[])
static plugin_base64_decode_t plugin_base64_decode
OPENVPN_EXPORT void * openvpn_plugin_client_constructor_v1(openvpn_plugin_handle_t handle)
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)
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)
int openvpn_plugin_client_connect(struct plugin_context *context, const char **argv, const char **envp)
static int atoi_null0(const char *str)
Contains all state information for one tunnel.
Arguments used to transport variables to the plug-in.
struct openvpn_plugin_callbacks * callbacks
Arguments used to transport variables from the plug-in back to the OpenVPN process.
openvpn_plugin_handle_t handle
plugin_base64_decode_t plugin_base64_decode
plugin_secure_memzero_t plugin_secure_memzero
const char * client_config