sec-mod: only exit on ERR_BAD_COMMAND errors from main msg handler

This commit is contained in:
Nikos Mavrogiannopoulos
2015-03-14 18:46:17 +01:00
parent 00e775dac6
commit 6c1f88a090
2 changed files with 8 additions and 8 deletions
+7 -6
View File
@@ -396,7 +396,7 @@ int send_failed_session_open_reply(int cfd, sec_mod_st *sec)
lpool = talloc_new(sec);
if (lpool == NULL) {
return ERR_MEM;
return ERR_BAD_COMMAND;
}
ret = send_msg(lpool, cfd, SM_CMD_AUTH_SESSION_REPLY, &rep,
@@ -404,10 +404,11 @@ int send_failed_session_open_reply(int cfd, sec_mod_st *sec)
(pack_func) sec_auth_session_reply_msg__pack);
if (ret < 0) {
seclog(sec, LOG_WARNING, "error in sending session reply");
ret = ERR_BAD_COMMAND; /* we desynced */
}
talloc_free(lpool);
return -1;
return ret;
}
static
@@ -463,7 +464,7 @@ int handle_sec_auth_session_open(int cfd, sec_mod_st *sec, const SecAuthSessionM
lpool = talloc_new(e);
if (lpool == NULL) {
return ERR_MEM;
return ERR_BAD_COMMAND; /* we desync */
}
if (sec->config_module && sec->config_module->get_sup_config) {
@@ -480,7 +481,7 @@ int handle_sec_auth_session_open(int cfd, sec_mod_st *sec, const SecAuthSessionM
(pack_func) sec_auth_session_reply_msg__pack);
if (ret < 0) {
seclog(sec, LOG_ERR, "error in sending session reply");
exit(1); /* we cannot recover */
return ERR_BAD_COMMAND; /* we desync */
}
talloc_free(lpool);
@@ -501,7 +502,7 @@ int handle_sec_auth_session_close(int cfd, sec_mod_st *sec, const SecAuthSession
if (req->sid.len != SID_SIZE) {
seclog(sec, LOG_ERR, "auth session close but with illegal sid size (%d)!",
(int)req->sid.len);
return -1;
return ERR_BAD_COMMAND;
}
e = find_client_entry(sec, req->sid.data);
@@ -536,7 +537,7 @@ int handle_sec_auth_session_close(int cfd, sec_mod_st *sec, const SecAuthSession
(pack_func) cli_stats_msg__pack);
if (ret < 0) {
seclog(sec, LOG_ERR, "error in sending session stats");
exit(1); /* we cannot recover */
return ERR_BAD_COMMAND;
}
/* save total stats */
+1 -2
View File
@@ -256,7 +256,6 @@ int process_packet(void *pool, int cfd, sec_mod_st * sec, cmd_request_t cmd,
tmsg = cli_stats_msg__unpack(&pa, data.size, data.data);
if (tmsg == NULL) {
seclog(sec, LOG_ERR, "error unpacking data");
ret = ERR_BAD_COMMAND;
return -1;
}
@@ -663,7 +662,7 @@ void sec_mod_server(void *main_pool, struct perm_cfg_st *perm_config, const char
seclog(sec, LOG_ERR, "error in memory allocation");
} else {
ret = serve_request(sec, cmd_fd, 1, buffer, buffer_size);
if (ret < 0) {
if (ret < 0 && ret == ERR_BAD_COMMAND) {
seclog(sec, LOG_ERR, "error processing command from main");
exit(1);
}