mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
reorganized to avoid compiler warnings
This commit is contained in:
+40
-36
@@ -149,7 +149,42 @@ static struct cfg_options available_options[] = {
|
|||||||
|
|
||||||
#define get_brackets_string get_brackets_string1
|
#define get_brackets_string get_brackets_string1
|
||||||
static char *get_brackets_string1(void *pool, const char *str);
|
static char *get_brackets_string1(void *pool, const char *str);
|
||||||
static char *get_brackets_string2(void *pool, const char *str);
|
|
||||||
|
#ifdef HAVE_RADIUS
|
||||||
|
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;
|
||||||
|
|
||||||
|
return talloc_strndup(pool, p, len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const tOptionValue* get_option(const char* name, unsigned * mand)
|
static const tOptionValue* get_option(const char* name, unsigned * mand)
|
||||||
{
|
{
|
||||||
@@ -333,39 +368,6 @@ static char *get_brackets_string1(void *pool, const char *str)
|
|||||||
return talloc_strndup(pool, p, len);
|
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;
|
|
||||||
|
|
||||||
return talloc_strndup(pool, p, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parses the string ::1/prefix, to return prefix
|
/* Parses the string ::1/prefix, to return prefix
|
||||||
* and modify the string to contain the network only.
|
* and modify the string to contain the network only.
|
||||||
@@ -461,13 +463,14 @@ unsigned force_cert_auth;
|
|||||||
amod = &plain_auth_funcs;
|
amod = &plain_auth_funcs;
|
||||||
config->auth_types |= amod->type;
|
config->auth_types |= amod->type;
|
||||||
} else if (strncasecmp(auth[j], "radius", 6) == 0) {
|
} else if (strncasecmp(auth[j], "radius", 6) == 0) {
|
||||||
const char *p;
|
|
||||||
if ((config->auth_types & AUTH_TYPE_USERNAME_PASS) != 0) {
|
if ((config->auth_types & AUTH_TYPE_USERNAME_PASS) != 0) {
|
||||||
fprintf(stderr, "You cannot mix multiple username/password authentication methods\n");
|
fprintf(stderr, "You cannot mix multiple username/password authentication methods\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
#ifdef HAVE_RADIUS
|
#ifdef HAVE_RADIUS
|
||||||
|
const char *p;
|
||||||
|
|
||||||
config->auth_additional = get_brackets_string1(config, auth[j]+6);
|
config->auth_additional = get_brackets_string1(config, auth[j]+6);
|
||||||
if (config->auth_additional == NULL) {
|
if (config->auth_additional == NULL) {
|
||||||
fprintf(stderr, "No configuration specified; error in %s\n", auth[j]);
|
fprintf(stderr, "No configuration specified; error in %s\n", auth[j]);
|
||||||
@@ -488,6 +491,7 @@ unsigned force_cert_auth;
|
|||||||
fprintf(stderr, "Radius support is disabled\n");
|
fprintf(stderr, "Radius support is disabled\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
} else if (c_strcasecmp(auth[j], "certificate") == 0) {
|
} else if (c_strcasecmp(auth[j], "certificate") == 0) {
|
||||||
config->auth_types |= AUTH_TYPE_CERTIFICATE;
|
config->auth_types |= AUTH_TYPE_CERTIFICATE;
|
||||||
} else if (c_strcasecmp(auth[j], "certificate[optional]") == 0) {
|
} else if (c_strcasecmp(auth[j], "certificate[optional]") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user