From 6c1f88a09042e4f0d9f6fb79424f3260ffabfb99 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 14 Mar 2015 18:46:17 +0100 Subject: [PATCH] sec-mod: only exit on ERR_BAD_COMMAND errors from main msg handler --- src/sec-mod-auth.c | 13 +++++++------ src/sec-mod.c | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sec-mod-auth.c b/src/sec-mod-auth.c index fa792de8..aafe1d04 100644 --- a/src/sec-mod-auth.c +++ b/src/sec-mod-auth.c @@ -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 */ diff --git a/src/sec-mod.c b/src/sec-mod.c index 1975bb11..d8b4658f 100644 --- a/src/sec-mod.c +++ b/src/sec-mod.c @@ -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); }