From c360f10f67c3eba0bdab606fd20f35360bcce729 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 9 Jan 2015 03:07:22 +0100 Subject: plugin: Remove usage of not really useful environment variable, ifconfig_pool_netmask This isn't always present, and only triggers some warnings. As it's not used for anything critical, get rid of it. Signed-off-by: David Sommerseth --- plugin/environment.h | 12 ------------ plugin/eurephia.c | 34 +++++++++++----------------------- plugin/eurephiadb_session.c | 15 +++++++-------- plugin/eurephiadb_session.h | 6 +++--- 4 files changed, 21 insertions(+), 46 deletions(-) (limited to 'plugin') diff --git a/plugin/environment.h b/plugin/environment.h index ef480d8..66d55ca 100644 --- a/plugin/environment.h +++ b/plugin/environment.h @@ -175,18 +175,6 @@ char *get_env(eurephiaCTX *ctx, int logmasking, size_t len, const char *envp[], */ #define GETENV_TIMEDURATION(ctx, env) get_env(ctx, 0, MAXLEN_TIMEDURATION, env, "time_duration"); -#define MAXLEN_POOLNETMASK 34 /**< Maximum allowed length of the clients VPN netmask*/ -/** - * Macro for retrieving the network mask of the tunnelled VPN network for the current session. - * - * @param ctx eurephiaCTX - * @param env Char array pointer to the environment table where the value resides - * - * @return Returns a pointer to a new memory region with the value. This region must be freed after use. - * @see get_env() - */ -#define GETENV_POOLNETMASK(ctx, env) get_env(ctx, 0, MAXLEN_POOLNETMASK, env, "ifconfig_pool_netmask"); - #define MAXLEN_POOLIPADDR 34 /**< Maximum allowed length of the clients VPN IP address*/ /** * Macro for retrieving the the IP address of the tunnelled VPN network for the current session. diff --git a/plugin/eurephia.c b/plugin/eurephia.c index c419c78..fadce39 100644 --- a/plugin/eurephia.c +++ b/plugin/eurephia.c @@ -1,7 +1,7 @@ /* eurephia.c -- Main functions for the eurephia authentication module * - * GPLv2 only - Copyright (C) 2008 - 2013 - * David Sommerseth + * GPLv2 only - Copyright (C) 2008 - 2015 + * David Sommerseth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -155,7 +155,7 @@ eurephiaCTX *eurephiaInit(const char const **argv, const char const **envp, eurephia_log_init(ctx, "eurephia-auth", logfile, loglvl, NULL); } eurephia_log(ctx, LOG_INFO, 0, "Initialising eurephia v" EUREPHIAVERSION - " (David Sommerseth (C) 2008-2012 GPLv2)"); + " (David Sommerseth (C) 2008-2015 GPLv2)"); // Load the database driver if( (error == 0) && eDBlink_init(ctx, dbi, 4) ) { @@ -438,8 +438,7 @@ int eurephia_userauth(eurephiaCTX *ctx, const char **env, certinfo *ci) // an authentication session do not use assigned VPN address authsess = eDBopen_session_seed(ctx, ci->digest, ci->common_name, username, - NULL, NULL, - ipaddr, remport); + NULL, ipaddr, remport); if( authsess == NULL ) { // No session found goto chk_pwd; @@ -613,7 +612,7 @@ int eurephia_userauth(eurephiaCTX *ctx, const char **env, certinfo *ci) */ int eurephia_connect(eurephiaCTX *ctx, const char **env, certinfo *ci) { eurephiaSESSION *session = NULL; - char *uname, *vpnipaddr, *vpnipmask, *remipaddr, *remport, *proto; + char *uname, *vpnipaddr, *remipaddr, *remport, *proto; int certid = 0, uid = 0, accprofile = -1, ret = 0; DEBUG(ctx, 10, "** Function call: eurephia_connect(...)"); @@ -621,21 +620,18 @@ int eurephia_connect(eurephiaCTX *ctx, const char **env, certinfo *ci) { // Fetch needed info uname = GETENV_USERNAME(ctx, env); vpnipaddr = GETENV_POOLIPADDR(ctx, env); - vpnipmask = GETENV_POOLNETMASK(ctx, env); remipaddr = GETENV_TRUSTEDIP(ctx, env); remport = GETENV_TRUSTEDPORT(ctx, env); proto = GETENV_PROTO1(ctx, env); // Get a session ticket session = eDBopen_session_seed(ctx, ci->digest, ci->common_name, - uname, vpnipaddr, vpnipmask, - remipaddr, remport); + uname, vpnipaddr, remipaddr, remport); if( session == NULL ) { free_nullsafe(ctx, proto); free_nullsafe(ctx, remport); free_nullsafe(ctx, remipaddr); free_nullsafe(ctx, vpnipaddr); - free_nullsafe(ctx, vpnipmask); free_nullsafe(ctx, uname); return 0; } @@ -659,7 +655,6 @@ int eurephia_connect(eurephiaCTX *ctx, const char **env, certinfo *ci) { free_nullsafe(ctx, remport); free_nullsafe(ctx, remipaddr); free_nullsafe(ctx, vpnipaddr); - free_nullsafe(ctx, vpnipmask); free_nullsafe(ctx, uname); DEBUG(ctx, 10, "** Function result: eurephia_connect(...) = %i", ret); @@ -676,7 +671,7 @@ int eurephia_connect(eurephiaCTX *ctx, const char **env, certinfo *ci) { */ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { eurephiaSESSION *session = NULL; - char *uname, *vpnipaddr, *vpnipmask, *remipaddr, *remport; + char *uname, *vpnipaddr, *remipaddr, *remport; char *bytes_sent, *bytes_rec, *duration; int ret = 0; @@ -685,7 +680,6 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { // Fetch needed info uname = GETENV_USERNAME(ctx, env); vpnipaddr = GETENV_POOLIPADDR(ctx, env); - vpnipmask = GETENV_POOLNETMASK(ctx, env); remipaddr = GETENV_TRUSTEDIP(ctx, env); remport = GETENV_TRUSTEDPORT(ctx, env); bytes_sent= GETENV_BYTESSENT(ctx, env); @@ -694,8 +688,7 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { // Get a session ticket session = eDBopen_session_seed(ctx, ci->digest, ci->common_name, uname, - vpnipaddr, vpnipmask, - remipaddr, remport); + vpnipaddr, remipaddr, remport); if( session == NULL ) { free_nullsafe(ctx, duration); free_nullsafe(ctx, bytes_rec); @@ -703,7 +696,6 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { free_nullsafe(ctx, remport); free_nullsafe(ctx, remipaddr); free_nullsafe(ctx, vpnipaddr); - free_nullsafe(ctx, vpnipmask); free_nullsafe(ctx, uname); return 0; } @@ -720,7 +712,7 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { // Get the authentication session and destroy it session = eDBopen_session_seed(ctx, ci->digest, ci->common_name, uname, - NULL, NULL, remipaddr, remport); + NULL, remipaddr, remport); if( !eDBdestroy_session(ctx, session) ) { eurephia_log(ctx, LOG_WARNING, 0, "Could not destroy authentication session (%s/%s/%s)", @@ -733,7 +725,6 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { free_nullsafe(ctx, remport); free_nullsafe(ctx, remipaddr); free_nullsafe(ctx, vpnipaddr); - free_nullsafe(ctx, vpnipmask); free_nullsafe(ctx, uname); DEBUG(ctx, 10, "** Function result: eurephia_disconnect(...) = %i", ret); @@ -756,7 +747,7 @@ int eurephia_disconnect(eurephiaCTX *ctx, const char **env, certinfo *ci) { int eurephia_learn_address(eurephiaCTX *ctx, const char *mode, const char *clientaddr, const char **env, certinfo *ci) { eurephiaSESSION *session = NULL; - char *uname = NULL, *vpnipaddr = NULL, *vpnipmask = NULL, + char *uname = NULL, *vpnipaddr = NULL, *remipaddr = NULL, *remport = NULL; char *fwprofile = NULL, *fwdest = NULL; int ret = 0, fw_enabled = 0; @@ -787,14 +778,12 @@ int eurephia_learn_address(eurephiaCTX *ctx, const char *mode, const char *clien // Fetch needed info uname = GETENV_USERNAME(ctx, env); vpnipaddr = GETENV_POOLIPADDR(ctx, env); - vpnipmask = GETENV_POOLNETMASK(ctx, env); remipaddr = GETENV_TRUSTEDIP(ctx, env); remport = GETENV_TRUSTEDPORT(ctx, env); // Get a session ticket session = eDBopen_session_seed(ctx, ci->digest, ci->common_name, uname, - vpnipaddr, vpnipmask, - remipaddr, remport); + vpnipaddr, remipaddr, remport); if( session == NULL ) { ret = 0; goto exit; @@ -871,7 +860,6 @@ int eurephia_learn_address(eurephiaCTX *ctx, const char *mode, const char *clien free_nullsafe(ctx, remport); free_nullsafe(ctx, remipaddr); free_nullsafe(ctx, vpnipaddr); - free_nullsafe(ctx, vpnipmask); free_nullsafe(ctx, uname); DEBUG(ctx, 10, "** Function result: eurephia_learn_address(ctx, '%s', '%.18s', ...) = %i", mode, clientaddr, ret); diff --git a/plugin/eurephiadb_session.c b/plugin/eurephiadb_session.c index 0cbf1e5..be43bcc 100644 --- a/plugin/eurephiadb_session.c +++ b/plugin/eurephiadb_session.c @@ -1,7 +1,7 @@ /* eurephiadb_session.c -- Functions for handling sessions from eurephia-auth * - * GPLv2 only - Copyright (C) 2008 - 2012 - * David Sommerseth + * GPLv2 only - Copyright (C) 2008 - 2015 + * David Sommerseth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -65,7 +65,6 @@ extern eurephiaVALUES *(*eDBload_sessiondata) (eurephiaCTX *ctx, const char *ses * @param cname Contains the clients X.509 Common Name field * @param username The user name of the client * @param vpnipaddr The IP address of the VPN connection of the client - * @param vpnipmask The IP address' network mask * @param remipaddr The public IP address the client is connecting from * @param remport The remote port of the client connection * @@ -73,7 +72,7 @@ extern eurephiaVALUES *(*eDBload_sessiondata) (eurephiaCTX *ctx, const char *ses */ eurephiaSESSION *eDBopen_session_seed(eurephiaCTX *ctx, const char *digest, const char *cname, const char *username, - const char *vpnipaddr, const char *vpnipmask, + const char *vpnipaddr, const char *remipaddr, const char *remport) { eurephiaSESSION *new_session = NULL; @@ -82,16 +81,16 @@ eurephiaSESSION *eDBopen_session_seed(eurephiaCTX *ctx, const char *digest, uint8_t sha_res[SHA512_HASH_SIZE]; size_t totlen = 0, i = 0; - DEBUG(ctx, 12, "Function call: eDBopen_session_seed(ctx, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", - digest, cname, username, vpnipaddr, vpnipmask, remipaddr, remport); + DEBUG(ctx, 12, "Function call: eDBopen_session_seed(ctx, '%s', '%s', '%s', '%s', '%s', '%s')", + digest, cname, username, vpnipaddr, remipaddr, remport); new_session = (eurephiaSESSION *) malloc_nullsafe(ctx, sizeof(eurephiaSESSION) + 2); if( new_session == NULL ) { return NULL; } - // Session type is stSESSION if we do have VPN address and/or netmask - new_session->type = ((vpnipaddr == NULL) && (vpnipmask == NULL) ? stAUTHENTICATION : stSESSION); + // Session type is stSESSION if we do have VPN IP address + new_session->type = (vpnipaddr == NULL ? stAUTHENTICATION : stSESSION); // Build up a string containing all elements for the session seed totlen = MAXLEN_TLSDIGEST + MAXLEN_CNAME + MAXLEN_USERNAME + MAXLEN_POOLIPADDR diff --git a/plugin/eurephiadb_session.h b/plugin/eurephiadb_session.h index 50682ae..c43dc92 100644 --- a/plugin/eurephiadb_session.h +++ b/plugin/eurephiadb_session.h @@ -1,7 +1,7 @@ /* eurephia_session.h -- Internal API to provide storing of variables connected to a session * - * GPLv2 only - Copyright (C) 2008 - 2012 - * David Sommerseth + * GPLv2 only - Copyright (C) 2008 - 2015 + * David Sommerseth * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,7 +35,7 @@ eurephiaSESSION *eDBopen_session_seed(eurephiaCTX *ctx, const char *digest, const char *cname, const char *username, - const char *vpnipaddr, const char *vpnipmask, + const char *vpnipaddr, const char *remipaddr, const char *remport); eurephiaSESSION *eDBsession_load(eurephiaCTX *ctx, const char *sesskey, sessionType sesstype); -- cgit