Fail if authentication modules are changed on reload

This commit is contained in:
Nikos Mavrogiannopoulos
2015-02-19 11:47:20 +01:00
parent bfeab4b015
commit c0ceeba0f8
+15 -6
View File
@@ -1157,7 +1157,6 @@ void reload_cfg_file(void *pool, struct cfg_st* config)
/* authentication methods can't change on reload */ /* authentication methods can't change on reload */
memcpy(bak, config->auth, sizeof(config->auth)); memcpy(bak, config->auth, sizeof(config->auth));
memset(config->auth, 0, sizeof(config->auth));
bak_size = config->auth_methods; bak_size = config->auth_methods;
clear_cfg_file(config); clear_cfg_file(config);
@@ -1166,17 +1165,27 @@ void reload_cfg_file(void *pool, struct cfg_st* config)
parse_cfg_file(cfg_file, config, 1); parse_cfg_file(cfg_file, config, 1);
/* reset the auth methods */ /* check if the authentication methods remained the same */
if (config->auth_methods != bak_size) {
goto auth_fail;
}
for (i=0;i<config->auth_methods;i++) { for (i=0;i<config->auth_methods;i++) {
if (config->auth[i].enabled) if (config->auth[i].enabled != bak[i].enabled) {
DEL(config->auth[i].additional); goto auth_fail;
}
if (config->auth[i].type != bak[i].type) {
goto auth_fail;
}
} }
memcpy(config->auth, bak, sizeof(config->auth));
config->auth_methods = bak_size;
check_cfg(config); check_cfg(config);
return; return;
auth_fail:
syslog(LOG_ERR, "you cannot switch authentication methods on reload");
exit(1);
} }
void write_pid_file(void) void write_pid_file(void)