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);
+ sleep(5);
return 0;
}
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);
+ sleep(5);
return 0;
}
char addr[64];
char *who = bs->get_peer(addr, sizeof(addr)) ? bs->who() : addr;
Qmsg2(NULL, M_SECURITY, 0, _("FD expecting Hello got bad command from %s. Len=%d.\n"), who, bs->msglen);
+ sleep(5);
bs->destroy();
return NULL;
}
/* If signal or packet size too big */
if (pktsiz < 0 || pktsiz > 1000000) {
if (pktsiz > 0) { /* if packet too big */
- Qmsg4(m_jcr, M_FATAL, 0,
+ int m_type = M_FATAL;
+ if (!m_jcr) {
+ m_type = M_SECURITY;
+ }
+ Qmsg4(m_jcr, m_type, 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);
+ }
}
if (pktsiz == BNET_TERMINATE) {
set_terminated();
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
- This notice must be preserved when any source code is
+ This notice must be preserved when any source code is
conveyed and/or propagated.
Bacula(R) is a registered trademark of Kern Sibbald.
va_list arg_ptr;
int len, maxlen;
POOLMEM *pool_buf;
- MQUEUE_ITEM *item;
+ MQUEUE_ITEM *item, *last_item;
pool_buf = get_pool_memory(PM_EMSG);
}
item = (MQUEUE_ITEM *)malloc(sizeof(MQUEUE_ITEM) + strlen(pool_buf) + 1);
item->type = type;
+ item->repeat = 0;
item->mtime = time(NULL);
strcpy(item->msg, pool_buf);
if (!jcr) {
syslog(LOG_DAEMON|LOG_ERR, "%s", item->msg);
P(daemon_msg_queue_mutex);
if (daemon_msg_queue) {
- daemon_msg_queue->append(item);
+ if (item->type == M_SECURITY) { /* can be repeated */
+ /* Keep repeat count of identical messages */
+ last_item = (MQUEUE_ITEM *)daemon_msg_queue->last();
+ if (last_item) {
+ if (strcmp(last_item->msg, item->msg) == 0) {
+ last_item->repeat++;
+ free(item);
+ item = NULL;
+ }
+ }
+ }
+ if (item) {
+ daemon_msg_queue->append(item);
+ }
}
V(daemon_msg_queue_mutex);
} else {
if (item->type == M_FATAL || item->type == M_ERROR) {
item->type = M_SECURITY;
}
- Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
+ if (item->repeat == 0) {
+ Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
+ } else {
+ Jmsg(jcr, item->type, item->mtime, "Message repeated %d times: %s",
+ item->repeat, item->msg);
+ }
}
if (jcr->dir_bsock) jcr->dir_bsock->suppress_error_messages(false);
/* Remove messages just sent */
/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2017 Kern Sibbald
+ Copyright (C) 2000-2018 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
- This notice must be preserved when any source code is
+ This notice must be preserved when any source code is
conveyed and/or propagated.
Bacula(R) is a registered trademark of Kern Sibbald.
*
* M_RESTORED An ls -l of each restored file.
*
- * M_SECURITY For security viloations. This is equivalent to FATAL.
- * (note, this is currently being implemented in 1.33).
+ * M_SECURITY For security alerts. This is equivalent to FATAL, but
+ * generally occurs in a daemon with no JCR.
*
* M_ALERT For Tape Alert messages.
*
/* Queued message item */
struct MQUEUE_ITEM {
dlink link;
- int type;
- utime_t mtime;
- char msg[1];
+ int type; /* message M_ type */
+ int repeat; /* count of identical messages */
+ utime_t mtime; /* time stamp message queued */
+ char msg[1]; /* message text */
};
/* Debug options */
dir->who(), dir->msglen);
Qmsg2(jcr, M_SECURITY, 0, _("Bad Hello command from Director at %s. Len=%d.\n"),
dir->who(), dir->msglen);
+ sleep(5);
return false;
}
dirname = get_pool_memory(PM_MESSAGE);
Qmsg2(jcr, M_SECURITY, 0, _("Bad Hello command from Director at %s: %s\n"),
dir->who(), dir->msg);
free_pool_memory(dirname);
+ sleep(5);
return false;
}
"Please see " MANUAL_AUTH_URL " for help.\n"),
dirname, dir->who());
free_pool_memory(dirname);
+ sleep(5);
return false;
}
jcr->director = director;
sscanf(fd->msg, "Hello FD: Bacula Storage calling Start Job %127s %d", job_name, &sd_version) != 2 &&
sscanf(fd->msg, "Hello Start Job %127s", job_name) != 1) {
Qmsg2(NULL, M_SECURITY, 0, _("Invalid Hello from %s. Len=%d\n"), fd->who(), fd->msglen);
+ sleep(5);
fd->destroy();
return;
}
if (!(jcr=get_jcr_by_full_name(job_name))) {
Qmsg1(NULL, M_SECURITY, 0, _("Client connect failed: Job name not found: %s\n"), job_name);
Dmsg1(3, "**** Job \"%s\" not found.\n", job_name);
+ sleep(5);
fd->destroy();
return;
}
}
pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */
free_jcr(jcr);
+ if (!jcr->authenticated) {
+ sleep(5);
+ }
return;
}