diff options
author | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-12-27 15:25:38 +0300 |
commit | 2b34d862111f1fd84cdb9d744ac34c1c933f34da (patch) | |
tree | 1e758ddc96689793e1c4c1b55cf3671bb05f2884 /accel-pptpd/radius | |
parent | ccaeb500e38d82c37568292d7850b66691793626 (diff) | |
download | accel-ppp-2b34d862111f1fd84cdb9d744ac34c1c933f34da.tar.gz accel-ppp-2b34d862111f1fd84cdb9d744ac34c1c933f34da.zip |
implemented partial config reload via SIGUSR1 signal or cli
Diffstat (limited to 'accel-pptpd/radius')
-rw-r--r-- | accel-pptpd/radius/dm_coa.c | 2 | ||||
-rw-r--r-- | accel-pptpd/radius/radius.c | 71 | ||||
-rw-r--r-- | accel-pptpd/radius/radius_p.h | 8 | ||||
-rw-r--r-- | accel-pptpd/radius/req.c | 8 |
4 files changed, 55 insertions, 34 deletions
diff --git a/accel-pptpd/radius/dm_coa.c b/accel-pptpd/radius/dm_coa.c index d78f91a..baf51b5 100644 --- a/accel-pptpd/radius/dm_coa.c +++ b/accel-pptpd/radius/dm_coa.c @@ -273,7 +273,7 @@ static void __init init(void) addr.sin_family = AF_INET; addr.sin_port = htons (conf_dm_coa_port); if (conf_dm_coa_server) - addr.sin_addr.s_addr = inet_addr(conf_dm_coa_server); + addr.sin_addr.s_addr = conf_dm_coa_server; else addr.sin_addr.s_addr = htonl (INADDR_ANY); if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) { diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c index 11b2717..8d0c887 100644 --- a/accel-pptpd/radius/radius.c +++ b/accel-pptpd/radius/radius.c @@ -25,21 +25,22 @@ int conf_max_try = 3; int conf_timeout = 3; int conf_acct_timeout = 600; -char *conf_nas_identifier = "accel-pptpd"; +char *conf_nas_identifier; in_addr_t conf_nas_ip_address; in_addr_t conf_gw_ip_address; in_addr_t conf_bind; int conf_verbose; int conf_interim_verbose; -char *conf_auth_server; +in_addr_t conf_auth_server; int conf_auth_server_port = 1812; char *conf_auth_secret; -char *conf_acct_server; +in_addr_t conf_acct_server; int conf_acct_server_port = 1813; char *conf_acct_secret; -char *conf_dm_coa_server; + +in_addr_t conf_dm_coa_server; int conf_dm_coa_port = 3799; char *conf_dm_coa_secret; @@ -344,7 +345,7 @@ static struct pwdb_t pwdb = { .check = check, }; -static int parse_server(const char *opt, char **name, int *port, char **secret) +static int parse_server(const char *opt, in_addr_t *addr, int *port, char **secret) { char *str = _strdup(opt); char *p1, *p2; @@ -359,23 +360,28 @@ static int parse_server(const char *opt, char **name, int *port, char **secret) else return -1; - *name = str; + *addr = inet_addr(str); + if (p1) { *port = atoi(p1 + 1); if (*port <=0 ) return -1; } - *secret = p2 + 1; + + p1 = _strdup(p2 + 1); + p2 = *secret; + *secret = p1; + if (p2) + _free(p2); + + _free(str); return 0; } -static void __init radius_init(void) +static int load_config(void) { char *opt; - char *dict = DICTIONARY; - - rpd_pool = mempool_create(sizeof(struct radius_pd_t)); opt = conf_get_opt("radius", "max-try"); if (opt && atoi(opt) > 0) @@ -401,9 +407,13 @@ static void __init radius_init(void) if (opt) conf_nas_ip_address = inet_addr(opt); + if (conf_nas_identifier) + _free(conf_nas_identifier); opt = conf_get_opt("radius", "nas-identifier"); if (opt) - conf_nas_identifier = opt; + conf_nas_identifier = _strdup(opt); + else + conf_nas_identifier = NULL; opt = conf_get_opt("radius", "gw-ip-address"); if (opt) @@ -420,10 +430,10 @@ static void __init radius_init(void) opt = conf_get_opt("radius", "auth_server"); if (!opt) { log_emerg("radius: auth-server not specified\n"); - _exit(EXIT_FAILURE); + return -1; } else if (parse_server(opt, &conf_auth_server, &conf_auth_server_port, &conf_auth_secret)) { log_emerg("radius: failed to parse auth_server\n"); - _exit(EXIT_FAILURE); + return -1; } opt = conf_get_opt("radius", "acct-server"); @@ -433,23 +443,15 @@ static void __init radius_init(void) log_emerg("radius: acct-server not specified\n"); if (opt && parse_server(opt, &conf_acct_server, &conf_acct_server_port, &conf_acct_secret)) { log_emerg("radius: failed to parse acct_server\n"); - _exit(EXIT_FAILURE); + return -1; } opt = conf_get_opt("radius", "dae-server"); if (opt && parse_server(opt, &conf_dm_coa_server, &conf_dm_coa_port, &conf_dm_coa_secret)) { log_emerg("radius: failed to parse dae-server\n"); - _exit(EXIT_FAILURE); - } else { - opt = conf_get_opt("radius", "dm_coa_secret"); - if (opt) - conf_dm_coa_secret = opt; + return -1; } - opt = conf_get_opt("radius", "dictionary"); - if (opt) - dict = opt; - opt = conf_get_opt("radius", "sid_in_auth"); if (opt && atoi(opt) > 0) conf_sid_in_auth = 1; @@ -461,7 +463,24 @@ static void __init radius_init(void) opt = conf_get_opt("radius", "acct-interim-interval"); if (opt && atoi(opt) > 0) conf_acct_interim_interval = atoi(opt); - + + return 0; +} + +static void __init radius_init(void) +{ + char *opt; + char *dict = DICTIONARY; + + rpd_pool = mempool_create(sizeof(struct radius_pd_t)); + + if (load_config()) + _exit(EXIT_FAILURE); + + opt = conf_get_opt("radius", "dictionary"); + if (opt) + dict = opt; + if (rad_dict_load(dict)) _exit(EXIT_FAILURE); @@ -472,4 +491,6 @@ static void __init radius_init(void) triton_event_register_handler(EV_PPP_ACCT_START, (triton_event_func)ppp_acct_start); triton_event_register_handler(EV_PPP_FINISHING, (triton_event_func)ppp_finishing); triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ppp_finished); + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); + } diff --git a/accel-pptpd/radius/radius_p.h b/accel-pptpd/radius/radius_p.h index 570c496..2bd3ff8 100644 --- a/accel-pptpd/radius/radius_p.h +++ b/accel-pptpd/radius/radius_p.h @@ -48,7 +48,7 @@ struct rad_req_t uint8_t RA[16]; struct rad_packet_t *pack; struct rad_packet_t *reply; - const char *server_name; + in_addr_t server_addr; int server_port; struct radius_pd_t *rpd; @@ -63,16 +63,16 @@ extern char *conf_nas_identifier; extern in_addr_t conf_nas_ip_address; extern in_addr_t conf_bind; extern in_addr_t conf_gw_ip_address; -extern char *conf_auth_server; +extern in_addr_t conf_auth_server; extern char *conf_auth_secret; extern int conf_auth_server_port; -extern char *conf_acct_server; +extern in_addr_t conf_acct_server; extern char *conf_acct_secret; extern int conf_acct_server_port; extern char *conf_dm_coa_secret; extern int conf_sid_in_auth; extern int conf_require_nas_ident; -extern char *conf_dm_coa_server; +extern in_addr_t conf_dm_coa_server; extern int conf_dm_coa_port; extern int conf_acct_interim_interval; diff --git a/accel-pptpd/radius/req.c b/accel-pptpd/radius/req.c index 818ceb4..94c10c3 100644 --- a/accel-pptpd/radius/req.c +++ b/accel-pptpd/radius/req.c @@ -31,7 +31,7 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u req->hnd.fd = -1; req->ctx.before_switch = log_switch; - req->server_name = conf_auth_server; + req->server_addr = conf_auth_server; req->server_port = conf_auth_server_port; while (1) { @@ -83,7 +83,7 @@ out_err: int rad_req_acct_fill(struct rad_req_t *req) { - req->server_name = conf_acct_server; + req->server_addr = conf_acct_server; req->server_port = conf_acct_server_port; memset(req->RA, 0, sizeof(req->RA)); @@ -148,7 +148,7 @@ static int make_socket(struct rad_req_t *req) } } - addr.sin_addr.s_addr = inet_addr(req->server_name); + addr.sin_addr.s_addr = req->server_addr; addr.sin_port = htons(req->server_port); if (connect(req->hnd.fd, (struct sockaddr *) &addr, sizeof(addr))) { @@ -244,7 +244,7 @@ int rad_req_wait(struct rad_req_t *req, int timeout) triton_context_wakeup(&req->ctx); - triton_context_schedule(req->rpd->ppp->ctrl->ctx); + triton_context_schedule(); if (conf_verbose && req->reply) { log_ppp_info1("recv "); |