From 0bf4993071fb8a2c260e50cd424a539ca9727b67 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Tue, 17 Nov 2015 21:19:59 -0800 Subject: [PATCH] [server] minor update to replace a string compare for command cycle close exclusions --- server/access.c | 12 ++++++++++-- server/cmd_cycle.c | 4 +--- server/fwknopd_common.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server/access.c b/server/access.c index 075ee069..8b5a4a27 100644 --- a/server/access.c +++ b/server/access.c @@ -1292,8 +1292,13 @@ acc_data_is_valid(fko_srv_options_t *opts, ); return(0); } - if(acc->cmd_cycle_timer == 0 - && strncmp(acc->cmd_cycle_close, "NONE", 4) != 0) + + /* Allow the string "NONE" to short-circuit close command execution. + */ + if(strncmp(acc->cmd_cycle_close, "NONE", 4) == 0) + acc->cmd_cycle_do_close = 0; + + if(acc->cmd_cycle_timer == 0 && acc->cmd_cycle_do_close) { log_msg(LOG_ERR, "[*] Must set the CMD_CYCLE_TIMER for command cycle functionality: '%s'", @@ -1614,7 +1619,10 @@ parse_access_file(fko_srv_options_t *opts) &(curr_acc->cmd_exec_gid), val, "CMD_EXEC_GROUP", file_ptr, opts); else if(CONF_VAR_IS(var, "CMD_CYCLE_OPEN")) + { add_acc_string(&(curr_acc->cmd_cycle_open), val, file_ptr, opts); + curr_acc->cmd_cycle_do_close = 1; /* default, will be validated */ + } else if(CONF_VAR_IS(var, "CMD_CYCLE_CLOSE")) add_acc_string(&(curr_acc->cmd_cycle_close), val, file_ptr, opts); else if(CONF_VAR_IS(var, "CMD_CYCLE_TIMER")) diff --git a/server/cmd_cycle.c b/server/cmd_cycle.c index 88e91b81..c69b2bbf 100644 --- a/server/cmd_cycle.c +++ b/server/cmd_cycle.c @@ -296,9 +296,7 @@ cmd_cycle_open(fko_srv_options_t *opts, acc_stanza_t *acc, if(! cmd_open(opts, acc, spadat, stanza_num)) return 0; - /* Allow the string "NONE" to short-circuit close command execution. - */ - if(strncmp(acc->cmd_cycle_close, "NONE", 4) != 0) + if(acc->cmd_cycle_do_close) if(! add_cmd_close(opts, acc, spadat, stanza_num)) return 0; diff --git a/server/fwknopd_common.h b/server/fwknopd_common.h index 1e4e2052..926ee92d 100644 --- a/server/fwknopd_common.h +++ b/server/fwknopd_common.h @@ -388,6 +388,7 @@ typedef struct acc_stanza char *cmd_exec_group; char *cmd_cycle_open; char *cmd_cycle_close; + unsigned char cmd_cycle_do_close; int cmd_cycle_timer; uid_t cmd_exec_uid; gid_t cmd_exec_gid;