"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "util/radiusutils.c" between
gvm-libs-1.0-beta2.tar.gz and gvm-libs-1.0.0.tar.gz

About: GVM Libraries for the Greenbone Vulnerability Management (GVM-10) framework (derived from the former openvas-libraries).

radiusutils.c  (gvm-libs-1.0-beta2):radiusutils.c  (gvm-libs-1.0.0)
/* Copyright (C) 2015-2018 Greenbone Networks GmbH /* Copyright (C) 2015-2019 Greenbone Networks GmbH
* *
* SPDX-License-Identifier: GPL-2.0-or-later * SPDX-License-Identifier: GPL-2.0-or-later
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/** /**
* @file * @file
* @brief Implementation of an API for Radius authentication. * @brief Implementation of an API for Radius authentication.
*/ */
#ifdef ENABLE_RADIUS_AUTH #ifdef ENABLE_RADIUS_AUTH
#include <arpa/inet.h> /* for inet_pton */ #include <arpa/inet.h> /* for inet_pton */
#if defined(RADIUS_AUTH_FREERADIUS) #if defined(RADIUS_AUTH_FREERADIUS)
#include <freeradius-client.h> #include <freeradius-client.h>
#ifndef RC_CONFIG_FILE #ifndef RC_CONFIG_FILE
#define RC_DICTIONARY_FILE "/etc/radiusclient/dictionary" #define RC_DICTIONARY_FILE "/etc/radiusclient/dictionary"
#endif #endif
#elif defined(RADIUS_AUTH_RADCLI) #elif defined(RADIUS_AUTH_RADCLI)
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include <stdlib.h> /* for mkstemp */
#include <string.h> /* for strerror */
#include <radcli/radcli.h> #include <radcli/radcli.h>
#include <stdlib.h> /* for mkstemp */
#include <string.h> /* for strerror */
#include <unistd.h>
#ifndef RC_CONFIG_FILE #ifndef RC_CONFIG_FILE
#define RC_DICTIONARY_FILE "/etc/radcli/dictionary" #define RC_DICTIONARY_FILE "/etc/radcli/dictionary"
#endif #endif
#endif #endif
#include <glib.h> /* for g_warning */
#include "../base/networking.h" /* for gvm_resolve */ #include "../base/networking.h" /* for gvm_resolve */
#include <glib.h> /* for g_warning */
#ifndef PW_MAX_MSG_SIZE #ifndef PW_MAX_MSG_SIZE
#define PW_MAX_MSG_SIZE 4096 #define PW_MAX_MSG_SIZE 4096
#endif #endif
/** /**
* Initialize the Radius client configuration. * Initialize the Radius client configuration.
* *
* @param[in] hostname Server hostname. * @param[in] hostname Server hostname.
* @param[in] secret Radius secret key. * @param[in] secret Radius secret key.
* *
skipping to change at line 106 skipping to change at line 107
if (fprintf (config_file, if (fprintf (config_file,
"auth_order radius\n" "auth_order radius\n"
"login_tries 4\n" "login_tries 4\n"
"dictionary %s\n" "dictionary %s\n"
"seqfile /var/run/radius.seq\n" "seqfile /var/run/radius.seq\n"
"radius_retries 3\n" "radius_retries 3\n"
"radius_timeout 5\n" "radius_timeout 5\n"
"radius_deadtime 0\n" "radius_deadtime 0\n"
"authserver %s\n" "authserver %s\n"
"acctserver %s\n", "acctserver %s\n",
RC_DICTIONARY_FILE, RC_DICTIONARY_FILE, authserver, authserver)
authserver, < 0)
authserver) < 0)
{ {
fclose (config_file); fclose (config_file);
g_warning ("%s: Couldn't write to temp radius config file %s:%s\n", g_warning ("%s: Couldn't write to temp radius config file %s:%s\n",
__FUNCTION__, config_filename, strerror (errno)); __FUNCTION__, config_filename, strerror (errno));
unlink (config_filename); unlink (config_filename);
goto radius_init_fail; goto radius_init_fail;
} }
fclose (config_file); fclose (config_file);
rh = rc_read_config (config_filename); rh = rc_read_config (config_filename);
if (rh == NULL) if (rh == NULL)
{ {
g_warning ("%s: Couldn't read temp radius config file %s\n", g_warning ("%s: Couldn't read temp radius config file %s\n", __FUNCTION__,
__FUNCTION__, config_filename); config_filename);
unlink (config_filename); unlink (config_filename);
goto radius_init_fail; goto radius_init_fail;
} }
unlink (config_filename); unlink (config_filename);
#else // defined(RADIUS_AUTH_RADCLI) #else // defined(RADIUS_AUTH_RADCLI)
if ((rh = rc_new ()) == NULL) if ((rh = rc_new ()) == NULL)
{ {
g_warning ("radius_init: Couldn't allocate memory"); g_warning ("radius_init: Couldn't allocate memory");
return NULL; return NULL;
} }
if (!rc_config_init (rh)) if (!rc_config_init (rh))
{ {
g_warning("radius_init: Couldn't initialize the config"); g_warning ("radius_init: Couldn't initialize the config");
return NULL; return NULL;
} }
/* Set the basic configuration options. */ /* Set the basic configuration options. */
if (rc_add_config (rh, "auth_order", "radius", "config", 0)) if (rc_add_config (rh, "auth_order", "radius", "config", 0))
{ {
g_warning("radius_init: Couldn't set auth_order"); g_warning ("radius_init: Couldn't set auth_order");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "login_tries", "4", "config", 0)) if (rc_add_config (rh, "login_tries", "4", "config", 0))
{ {
g_warning("radius_init: Couldn't set login_tries"); g_warning ("radius_init: Couldn't set login_tries");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "dictionary", RC_DICTIONARY_FILE, "config", 0)) if (rc_add_config (rh, "dictionary", RC_DICTIONARY_FILE, "config", 0))
{ {
g_warning("radius_init: Couldn't set dictionary"); g_warning ("radius_init: Couldn't set dictionary");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "seqfile", "/var/run/radius.seq", "config", 0)) if (rc_add_config (rh, "seqfile", "/var/run/radius.seq", "config", 0))
{ {
g_warning("radius_init: Couldn't set seqfile"); g_warning ("radius_init: Couldn't set seqfile");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "radius_retries", "3", "config", 0)) if (rc_add_config (rh, "radius_retries", "3", "config", 0))
{ {
g_warning("radius_init: Couldn't set radius_retries"); g_warning ("radius_init: Couldn't set radius_retries");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "radius_timeout", "5", "config", 0)) if (rc_add_config (rh, "radius_timeout", "5", "config", 0))
{ {
g_warning("radius_init: Couldn't set radius_timeout"); g_warning ("radius_init: Couldn't set radius_timeout");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "radius_deadtime", "0", "config", 0)) if (rc_add_config (rh, "radius_deadtime", "0", "config", 0))
{ {
g_warning("radius_init: Couldn't set radius_deadtime"); g_warning ("radius_init: Couldn't set radius_deadtime");
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_add_config (rh, "authserver", authserver, "config", 0) != 0) if (rc_add_config (rh, "authserver", authserver, "config", 0) != 0)
{ {
g_warning ("radius_init: Couldn't set authserver %s", authserver); g_warning ("radius_init: Couldn't set authserver %s", authserver);
goto radius_init_fail; goto radius_init_fail;
} }
if (rc_read_dictionary (rh, RC_DICTIONARY_FILE) != 0) if (rc_read_dictionary (rh, RC_DICTIONARY_FILE) != 0)
{ {
g_warning ("radius_init: Couldn't read the dictionary file %s", g_warning ("radius_init: Couldn't read the dictionary file %s",
skipping to change at line 256 skipping to change at line 256
authenticate_leave: authenticate_leave:
rc_destroy (rh); rc_destroy (rh);
if (send) if (send)
rc_avpair_free (send); rc_avpair_free (send);
if (received) if (received)
rc_avpair_free (received); rc_avpair_free (received);
return rc; return rc;
} }
#else /* ENABLE_RADIUS_AUTH */ #else /* ENABLE_RADIUS_AUTH */
/** /**
* @brief Dummy function for manager. * @brief Dummy function for manager.
* *
* @param[in] hostname Server hostname. * @param[in] hostname Server hostname.
* @param[in] secret Radius secret key. * @param[in] secret Radius secret key.
* @param[in] username Username to authenticate. * @param[in] username Username to authenticate.
* @param[in] password Password to use with username. * @param[in] password Password to use with username.
* *
* @return -1. * @return -1.
 End of changes. 18 change blocks. 
21 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)