From: Kern Sibbald Date: Sun, 14 Oct 2018 14:09:11 +0000 (+0200) Subject: Make detection of duplicate M_SECURITY messages work X-Git-Tag: Release-9.4.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb5f7ba8bb97665a5f5e32f7b88467067b093cd5;p=thirdparty%2Fbacula.git Make detection of duplicate M_SECURITY messages work --- diff --git a/bacula/src/dird/authenticate.c b/bacula/src/dird/authenticate.c index 0be30b7a36..89a6c76ee0 100644 --- a/bacula/src/dird/authenticate.c +++ b/bacula/src/dird/authenticate.c @@ -326,8 +326,8 @@ int authenticate_user_agent(UAContext *uac) int ua_version = 0; if (ua->msglen < 16 || ua->msglen >= MAX_NAME_LENGTH + 15) { - Jmsg4(NULL, M_SECURITY, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who(), - ua->host(), ua->port(), ua->msglen); + Qmsg3(NULL, M_SECURITY, 0, _("UA Hello from %s:%s is invalid. Len=%d\n"), ua->who(), + ua->host(), ua->msglen); sleep(5); return 0; } @@ -335,8 +335,8 @@ int authenticate_user_agent(UAContext *uac) if (sscanf(ua->msg, "Hello %127s calling %d", name, &ua_version) != 2 && sscanf(ua->msg, "Hello %127s calling", name) != 1) { ua->msg[100] = 0; /* terminate string */ - Jmsg4(NULL, M_SECURITY, 0, _("UA Hello from %s:%s:%d is invalid. Got: %s\n"), ua->who(), - ua->host(), ua->port(), ua->msg); + Qmsg3(NULL, M_SECURITY, 0, _("UA Hello from %s:%s is invalid. Got: %s\n"), ua->who(), + ua->host(), ua->msg); sleep(5); return 0; } diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index 9269e5206d..cca2652412 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -512,17 +512,12 @@ int32_t BSOCK::recv() /* If signal or packet size too big */ if (pktsiz < 0 || pktsiz > 1000000) { if (pktsiz > 0) { /* if packet too big */ - int m_type = M_FATAL; - if (!m_jcr) { - m_type = M_SECURITY; - } - Qmsg4(m_jcr, m_type, 0, + if (m_jcr) { + Qmsg4(m_jcr, M_FATAL, 0, _("Packet size=%d too big from \"%s:%s:%d\". Maximum permitted 1000000. Terminating connection.\n"), pktsiz, m_who, m_host, m_port); - pktsiz = BNET_TERMINATE; /* hang up */ - if (m_type == M_SECURITY) { - sleep(5); } + pktsiz = BNET_TERMINATE; /* hang up */ } if (pktsiz == BNET_TERMINATE) { set_terminated(); diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index a1ca4467cf..ba9bf0d1b0 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -543,8 +543,10 @@ void free_jcr(JCR *jcr) remove_jcr(jcr); /* remove Jcr from chain */ unlock_jcr_chain(); - dequeue_messages(jcr); - dequeue_daemon_messages(jcr); + if (jcr->JobId > 0) { + dequeue_messages(jcr); + dequeue_daemon_messages(jcr); + } close_msg(jcr); /* close messages for this job */ job_end_pop(jcr); /* pop and call hooked routines */