diff options
Diffstat (limited to 'plugin/eurephia.c')
-rw-r--r-- | plugin/eurephia.c | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/plugin/eurephia.c b/plugin/eurephia.c index f06c684..74b4785 100644 --- a/plugin/eurephia.c +++ b/plugin/eurephia.c @@ -49,66 +49,9 @@ #include <certinfo.h> #include <randstr.h> #include <passwd.h> +#include <environment.h> -#define MAX_ARGUMENTS 64 /**< Maximum arguments we will parse from the openvpn plug-in configuration */ - - -/** - * get_env() retrieve values from the openvpn environment table - * - * @param ctx eurephiaCTX context - * @param logmasking If 1, the value will be masked in the log files (eg. to hide password) - * @param len How many bytes to copy out of the environment variable - * @param envp the environment table - * @param fmt The key to look for (stdarg) - * - * @return Returns a const char * with the value, or NULL if not found - */ -char *get_env(eurephiaCTX *ctx, int logmasking, size_t len, - const char *envp[], const char *fmt, ... ) -{ - if (envp) { - va_list ap; - char key[384]; - int keylen = 0; - int i; - - // Build up the key we are looking for - memset(&key, 0, 384); - va_start(ap, fmt); - vsnprintf(key, 382, fmt, ap); - - // Find the key - keylen = strlen (key); - for (i = 0; envp[i]; ++i) { - if (!strncmp (envp[i], key, keylen)) { - const char *cp = envp[i] + keylen; - char *ret = NULL; - if (*cp == '=') { -#ifdef ENABLE_DEBUG - int do_mask = 0; -#ifndef SHOW_SECRETS - do_mask = logmasking; -#endif - if( ctx != NULL ) { - DEBUG(ctx, 30, "Function call: get_env(envp, '%s') == '%s'", - key, (do_mask == 0 ? cp + 1 : "xxxxxxxxxxxxxx")); - } -#endif - ret = malloc_nullsafe(ctx, len+2); - strncpy(ret, cp+1, len); - return ret; - } - } - } - if( ctx != NULL ) { - DEBUG(ctx, 15, "Function call: get_env(envp, '%s') -- environment variable not found", - key); - } - va_end(ap); - } - return NULL; -} +#define MAX_ARGUMENTS 64 /**< Maximum arguments we will parse from the openvpn plug-in configuration */ /** |