From: Benjamin Cama Date: Sun, 29 Jan 2012 23:16:41 +0000 (+0100) Subject: Fix binding of the cli to the configured address X-Git-Tag: 2.2.1-2fdn3.1~19^2~1 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/bceebb9a9db4a3cb096827b45f3a771f1f0d466f?ds=inline Fix binding of the cli to the configured address We used to read the configuration file /after/ binding the cli. Fix that. Signed-off-by: Benjamin Cama --- diff --git a/cli.c b/cli.c index 32c82a9..25ba34f 100644 --- a/cli.c +++ b/cli.c @@ -139,8 +139,6 @@ void init_cli() char buf[4096]; struct cli_command *c; struct cli_command *c2; - int on = 1; - struct sockaddr_in addr; cli = cli_init(); @@ -268,6 +266,17 @@ void init_cli() } fclose(f); } +} + +void cli_init_complete(char *hostname) +{ + int on = 1; + struct sockaddr_in addr; + + if (hostname && *hostname) + cli_set_hostname(cli, hostname); + else + cli_set_hostname(cli, "l2tpns"); memset(&addr, 0, sizeof(addr)); clifd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -297,14 +306,6 @@ void init_cli() } } -void cli_init_hostname(char *hostname) -{ - if (hostname && *hostname) - cli_set_hostname(cli, hostname); - else - cli_set_hostname(cli, "l2tpns"); -} - void cli_do(int sockfd) { int require_auth = 1; diff --git a/l2tpns.c b/l2tpns.c index 2d53ea2..3488002 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -4717,7 +4717,7 @@ int main(int argc, char *argv[]) /* set hostname /after/ having read the config file */ if (*config->hostname) strcpy(hostname, config->hostname); - cli_init_hostname(hostname); + cli_init_complete(hostname); update_config(); init_tbf(config->num_tbfs); diff --git a/l2tpns.h b/l2tpns.h index f38e9f3..5ef6253 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -911,7 +911,7 @@ void become_master(void); // We're the master; kick off any required master init // cli.c void init_cli(); -void cli_init_hostname(char *hostname); +void cli_init_complete(char *hostname); void cli_do_file(FILE *fh); void cli_do(int sockfd); int cli_arg_help(struct cli_def *cli, int cr_ok, char *entry, ...);