Skip to content

Commit

Permalink
Don't crash when ua->UA_sock == NULL in prtit()
Browse files Browse the repository at this point in the history
Some admin jobs have an UA context but not a ua->UA_sock and when you
then blind use ua->UA_sock->fsend() you crash in the worst possible way.
We now call ua->send_msg() which has some fallback logic when
ua->UA_sock is NULL and then uses Jmsg with M_INFO to redirect the info
to the Job.

Its might not fully fix #418 as its seems the admin Job want to have
interaction with the user which ain't going to work in an admin Job but
crashing is about the worse what can happen.

Fixes #418: traceback runnning after job
  • Loading branch information
Marco van Wieringen authored and pstorz committed Mar 27, 2015
1 parent a150cd1 commit 0a34bd6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dird/ua_output.c
Expand Up @@ -908,12 +908,14 @@ void prtit(void *ctx, const char *msg)
{
UAContext *ua = (UAContext *)ctx;

ua->UA_sock->fsend("%s", msg);
if (ua) {
ua->send_msg("%s", msg);
}
}

/*
* Format message and send to other end.
*
* If the UA_sock is NULL, it means that there is no user
* agent, so we are being called from BAREOS core. In
* that case direct the messages to the Job.
Expand Down

0 comments on commit 0a34bd6

Please sign in to comment.