Added support for reading user configuration from radius.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-12-09 15:38:27 +01:00
parent 2194e11b39
commit 766afb591a
11 changed files with 258 additions and 25 deletions
+58 -6
View File
@@ -34,6 +34,7 @@
#include <auth/pam.h>
#include <auth/radius.h>
#include <auth/plain.h>
#include <sec-mod-sup-config.h>
#include <vpn.h>
#include <cookies.h>
@@ -145,7 +146,9 @@ static struct cfg_options available_options[] = {
{ .name = "default-group-config", .type = OPTION_STRING, .mandatory = 0 },
};
static char *get_brackets_string(void *pool, const char *str);
#define get_brackets_string get_brackets_string1
static char *get_brackets_string1(void *pool, const char *str);
static char *get_brackets_string2(void *pool, const char *str);
static const tOptionValue* get_option(const char* name, unsigned * mand)
{
@@ -302,7 +305,7 @@ unsigned j;
}
}
static char *get_brackets_string(void *pool, const char *str)
static char *get_brackets_string1(void *pool, const char *str)
{
char *p, *p2;
unsigned len;
@@ -315,10 +318,47 @@ static char *get_brackets_string(void *pool, const char *str)
while (c_isspace(*p))
p++;
p2 = strchr(p, ']');
p2 = strchr(p, ',');
if (p2 == NULL) {
fprintf(stderr, "error parsing %s\n", str);
exit(1);
p2 = strchr(p, ']');
if (p2 == NULL) {
fprintf(stderr, "error parsing %s\n", str);
exit(1);
}
}
len = p2 - p;
return talloc_strndup(pool, p, len);
}
static char *get_brackets_string2(void *pool, const char *str)
{
char *p, *p2;
unsigned len;
p = strchr(str, '[');
if (p == NULL) {
return NULL;
}
p++;
p = strchr(p, ',');
if (p == NULL) {
return NULL;
}
p++;
while (c_isspace(*p))
p++;
p2 = strchr(p, ',');
if (p2 == NULL) {
p2 = strchr(p, ']');
if (p2 == NULL) {
fprintf(stderr, "error parsing %s\n", str);
exit(1);
}
}
len = p2 - p;
@@ -366,6 +406,8 @@ unsigned force_cert_auth;
prev = val;
} while((val = optionNextValue(pov, prev)) != NULL);
config->sup_config_type = SUP_CONFIG_FILE;
READ_MULTI_LINE("auth", auth, auth_size);
for (j=0;j<auth_size;j++) {
if (c_strncasecmp(auth[j], "pam", 3) == 0) {
@@ -395,17 +437,27 @@ unsigned force_cert_auth;
amod = &plain_auth_funcs;
config->auth_types |= amod->type;
} else if (strncasecmp(auth[j], "radius", 6) == 0) {
const char *p;
if ((config->auth_types & AUTH_TYPE_USERNAME_PASS) != 0) {
fprintf(stderr, "You cannot mix multiple username/password authentication methods\n");
exit(1);
}
#ifdef HAVE_RADIUS
config->auth_additional = get_brackets_string(config, auth[j]+6);
config->auth_additional = get_brackets_string1(config, auth[j]+6);
if (config->auth_additional == NULL) {
fprintf(stderr, "No configuration specified; error in %s\n", auth[j]);
exit(1);
}
p = get_brackets_string2(config, auth[j]+6);
if (p != NULL) {
if (strcasecmp(p, "groupconfig") != 0) {
fprintf(stderr, "No known configuration option: %s\n", p);
exit(1);
}
config->sup_config_type = SUP_CONFIG_RADIUS;
}
amod = &radius_auth_funcs;
config->auth_types |= amod->type;
#else