-/*
- *
- * Bacula Director -- authorize.c -- handles authorization of
- * Storage and File daemons.
- *
- * Kern Sibbald, May MMI
- *
- * This routine runs as a thread and must be thread reentrant.
- *
- * Version $Id$
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Director -- authorize.c -- handles authorization of
+ * Storage and File daemons.
+ *
+ * Kern Sibbald, May MMI
+ *
+ * This routine runs as a thread and must be thread reentrant.
+ *
+ * Version $Id$
+ *
+ */
#include "bacula.h"
#include "dird.h"
bash_spaces(dirname);
/* Timeout Hello after 1 min */
btimer_t *tid = start_bsock_timer(sd, AUTH_TIMEOUT);
- if (!bnet_fsend(sd, hello, dirname)) {
+ if (!sd->fsend(hello, dirname)) {
stop_bsock_timer(tid);
Dmsg1(50, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd));
Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd));
stop_bsock_timer(tid);
Dmsg0(50, _("Director and Storage daemon passwords or names not the same.\n"));
Jmsg2(jcr, M_FATAL, 0,
- _("Director unable to authenticate with Storage daemon on \"%s:%d\". Possible causes:\n"
+ _("Director unable to authenticate with Storage daemon at \"%s:%d\". Possible causes:\n"
"Passwords or names not the same or\n"
"Maximum Concurrent Jobs exceeded on the SD or\n"
"SD networking messed up (restart daemon).\n"
/* Engage TLS! Full Speed Ahead! */
if (!bnet_tls_client(store->tls_ctx, sd, NULL)) {
stop_bsock_timer(tid);
- Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed with SD on \"%s:%d\"\n"),
+ Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed with SD at \"%s:%d\"\n"),
sd->host(), sd->port());
return 0;
}
}
Dmsg1(116, ">stored: %s", sd->msg);
- if (bnet_recv(sd) <= 0) {
+ if (sd->recv() <= 0) {
stop_bsock_timer(tid);
Jmsg3(jcr, M_FATAL, 0, _("bdird<stored: \"%s:%s\" bad response to Hello command: ERR=%s\n"),
- sd->who(), sd->host(), bnet_strerror(sd));
+ sd->who(), sd->host(), sd->bstrerror());
return 0;
}
Dmsg1(110, "<stored: %s", sd->msg);
stop_bsock_timer(tid);
if (strncmp(sd->msg, OKhello, sizeof(OKhello)) != 0) {
Dmsg0(50, _("Storage daemon rejected Hello command\n"));
- Jmsg2(jcr, M_FATAL, 0, _("Storage daemon on \"%s:%d\" rejected Hello command\n"),
+ Jmsg2(jcr, M_FATAL, 0, _("Storage daemon at \"%s:%d\" rejected Hello command\n"),
sd->host(), sd->port());
return 0;
}
*/
bstrncpy(dirname, director->hdr.name, sizeof(dirname));
bash_spaces(dirname);
- /* Timeout Hello after 10 mins */
+ /* Timeout Hello after 1 min */
btimer_t *tid = start_bsock_timer(fd, AUTH_TIMEOUT);
- if (!bnet_fsend(fd, hello, dirname)) {
+ if (!fd->fsend(hello, dirname)) {
stop_bsock_timer(tid);
- Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon on \"%s:%d\". ERR=%s\n"),
- fd->host(), fd->port(), bnet_strerror(fd));
+ Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon at \"%s:%d\". ERR=%s\n"),
+ fd->host(), fd->port(), fd->bstrerror());
return 0;
}
Dmsg1(50, "Sent: %s", fd->msg);
stop_bsock_timer(tid);
Dmsg0(50, _("Director and File daemon passwords or names not the same.\n"));
Jmsg(jcr, M_FATAL, 0,
- _("Unable to authenticate with File daemon on \"%s:%d\". Possible causes:\n"
+ _("Unable to authenticate with File daemon at \"%s:%d\". Possible causes:\n"
"Passwords or names not the same or\n"
"Maximum Concurrent Jobs exceeded on the FD or\n"
"FD networking messed up (restart daemon).\n"
/* Verify that we are willing to meet the remote host's requirements */
if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
stop_bsock_timer(tid);
- Jmsg(jcr, M_FATAL, 0, _("Authorization problem: FD on \"%s:%d\" requires TLS.\n"),
+ Jmsg(jcr, M_FATAL, 0, _("Authorization problem: FD at \"%s:%d\" requires TLS.\n"),
fd->host(), fd->port());
return 0;
}
if (!bnet_tls_client(client->tls_ctx, fd, client->tls_allowed_cns)) {
stop_bsock_timer(tid);
- Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed with FD on \"%s:%d\".\n"),
+ Jmsg(jcr, M_FATAL, 0, _("TLS negotiation failed with FD at \"%s:%d\".\n"),
fd->host(), fd->port());
return 0;
}
}
Dmsg1(116, ">filed: %s", fd->msg);
- if (bnet_recv(fd) <= 0) {
+ if (fd->recv() <= 0) {
stop_bsock_timer(tid);
Dmsg1(50, _("Bad response from File daemon to Hello command: ERR=%s\n"),
bnet_strerror(fd));
- Jmsg(jcr, M_FATAL, 0, _("Bad response from File daemon on \"%s:%d\" to Hello command: ERR=%s\n"),
- fd->host(), fd->port(), bnet_strerror(fd));
+ Jmsg(jcr, M_FATAL, 0, _("Bad response from File daemon at \"%s:%d\" to Hello command: ERR=%s\n"),
+ fd->host(), fd->port(), fd->bstrerror());
return 0;
}
Dmsg1(110, "<stored: %s", fd->msg);
stop_bsock_timer(tid);
if (strncmp(fd->msg, FDOKhello, sizeof(FDOKhello)) != 0) {
Dmsg0(50, _("File daemon rejected Hello command\n"));
- Jmsg(jcr, M_FATAL, 0, _("File daemon on \"%s:%d\" rejected Hello command\n"),
+ Jmsg(jcr, M_FATAL, 0, _("File daemon at \"%s:%d\" rejected Hello command\n"),
fd->host(), fd->port());
return 0;
}
TLS_CONTEXT *tls_ctx = NULL;
alist *verify_list = NULL;
-
-// Emsg4(M_INFO, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who(),
-// ua->host(), ua->port(), ua->msglen);
if (ua->msglen < 16 || ua->msglen >= MAX_NAME_LENGTH + 15) {
Emsg4(M_ERROR, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who(),
ua->host(), ua->port(), ua->msglen);
/* Authorization Completed */
auth_done:
if (!auth_success) {
- bnet_fsend(ua, "%s", _(Dir_sorry));
+ ua->fsend("%s", _(Dir_sorry));
Emsg4(M_ERROR, 0, _("Unable to authenticate console \"%s\" at %s:%s:%d.\n"),
name, ua->who(), ua->host(), ua->port());
sleep(5);
return 0;
}
- bnet_fsend(ua, _("1000 OK: %s Version: %s (%s)\n"), my_name, VERSION, BDATE);
+ ua->fsend(_("1000 OK: %s Version: %s (%s)\n"), my_name, VERSION, BDATE);
return 1;
}
return 1;
}
LockRes();
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->cons->name());
+ client = GetClientResWithName(ua->cons->name());
if (!client) {
ua->error_msg(_("Client \"%s\" not found.\n"), ua->cons->name());
}
} else {
LockRes();
- job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ job = GetJobResWithName(ua->argv[i]);
UnlockRes();
}
if (!job) {
strcasecmp(ua->argk[i], "fd") == 0) {
client = NULL;
if (ua->argv[i]) {
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ client = GetClientResWithName(ua->argv[i]);
if (client) {
do_client_setdebug(ua, client, level, trace_flag);
return 1;
strcasecmp(ua->argk[i], NT_("sd")) == 0) {
store = NULL;
if (ua->argv[i]) {
- store = (STORE *)GetResWithName(R_STORAGE, ua->argv[i]);
+ store = GetStoreResWithName(ua->argv[i]);
if (store) {
do_storage_setdebug(ua, store, level, trace_flag);
return 1;
if (strcasecmp(ua->argk[i], NT_("client")) == 0 ||
strcasecmp(ua->argk[i], NT_("fd")) == 0) {
if (ua->argv[i]) {
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ client = GetClientResWithName(ua->argv[i]);
continue;
}
}
if (strcasecmp(ua->argk[i], NT_("job")) == 0) {
if (ua->argv[i]) {
- job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ job = GetJobResWithName(ua->argv[i]);
if (job && !acl_access_ok(ua, Job_ACL, job->name())) {
ua->error_msg(_("No authorization for Job \"%s\"\n"), job->name());
return 1;
}
if (strcasecmp(ua->argk[i], NT_("fileset")) == 0) {
if (ua->argv[i]) {
- fileset = (FILESET *)GetResWithName(R_FILESET, ua->argv[i]);
+ fileset = GetFileSetResWithName(ua->argv[i]);
if (fileset && !acl_access_ok(ua, FileSet_ACL, fileset->name())) {
ua->error_msg(_("No authorization for FileSet \"%s\"\n"), fileset->name());
return 1;
}
}
if (!job) {
- job = (JOB *)GetResWithName(R_JOB, ua->argk[1]);
+ job = GetJobResWithName(ua->argk[1]);
if (!job) {
ua->error_msg(_("No job specified.\n"));
return 1;
ua->error_msg(_("No authorization for Catalog \"%s\"\n"), ua->argv[i]);
return false;
}
- catalog = (CAT *)GetResWithName(R_CATALOG, ua->argv[i]);
+ catalog = GetCatalogResWithName(ua->argv[i]);
if (catalog) {
if (ua->catalog && ua->catalog != catalog) {
close_db(ua);
ua->error_msg(_("No authorization for Client \"%s\"\n"), ua->argv[i]);
return false;
}
- client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
+ client = GetClientResWithName(ua->argv[i]);
if (client) {
catalog = client->catalog;
if (ua->catalog && ua->catalog != catalog) {
ua->error_msg(_("No authorization for Job \"%s\"\n"), ua->argv[i]);
return false;
}
- job = (JOB *)GetResWithName(R_JOB, ua->argv[i]);
+ job = GetJobResWithName(ua->argv[i]);
if (job) {
catalog = job->client->catalog;
if (ua->catalog && ua->catalog != catalog) {
if (nbytes != (size_t) msglen) {
berrno be;
Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, msglen);
- Qmsg1(jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
+ Qmsg1(get_jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
be.bstrerror());
update_attr_spool_size(tsize - last);
return false;
update_attr_spool_size(tsize - last);
if (ferror(m_spool_fd)) {
berrno be;
- Qmsg1(jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
+ Qmsg1(get_jcr(), M_FATAL, 0, _("fread attr spool error. ERR=%s\n"),
be.bstrerror());
return false;
}
}
start_size = dbuf_size;
if ((msg = realloc_pool_memory(msg, dbuf_size + 100)) == NULL) {
- Qmsg0(jcr(), M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
+ Qmsg0(get_jcr(), M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
return false;
}
if (rw & BNET_SETBUF_READ) {
while ((dbuf_size > TAPE_BSIZE) && (setsockopt(m_fd, SOL_SOCKET,
SO_RCVBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) {
berrno be;
- Qmsg1(jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror());
+ Qmsg1(get_jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror());
dbuf_size -= TAPE_BSIZE;
}
Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
if (dbuf_size != start_size) {
- Qmsg1(jcr(), M_WARNING, 0,
+ Qmsg1(get_jcr(), M_WARNING, 0,
_("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
}
if (dbuf_size % TAPE_BSIZE != 0) {
- Qmsg1(jcr(), M_ABORT, 0,
+ Qmsg1(get_jcr(), M_ABORT, 0,
_("Network buffer size %d not multiple of tape block size.\n"),
dbuf_size);
}
while ((dbuf_size > TAPE_BSIZE) && (setsockopt(m_fd, SOL_SOCKET,
SO_SNDBUF, (sockopt_val_t) & dbuf_size, sizeof(dbuf_size)) < 0)) {
berrno be;
- Qmsg1(jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror());
+ Qmsg1(get_jcr(), M_ERROR, 0, _("sockopt error: %s\n"), be.bstrerror());
dbuf_size -= TAPE_BSIZE;
}
Dmsg1(900, "set network buffer size=%d\n", dbuf_size);
if (dbuf_size != start_size) {
- Qmsg1(jcr(), M_WARNING, 0,
+ Qmsg1(get_jcr(), M_WARNING, 0,
_("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
}
if (dbuf_size % TAPE_BSIZE != 0) {
- Qmsg1(jcr(), M_ABORT, 0,
+ Qmsg1(get_jcr(), M_ABORT, 0,
_("Network buffer size %d not multiple of tape block size.\n"),
dbuf_size);
}
/* Get current flags */
if ((oflags = fcntl(m_fd, F_GETFL, 0)) < 0) {
berrno be;
- Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
+ Jmsg1(get_jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
}
/* Set O_NONBLOCK flag */
if ((fcntl(m_fd, F_SETFL, oflags|O_NONBLOCK)) < 0) {
berrno be;
- Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
+ Jmsg1(get_jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
}
m_blocking = 0;
/* Get current flags */
if ((oflags = fcntl(m_fd, F_GETFL, 0)) < 0) {
berrno be;
- Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
+ Jmsg1(get_jcr(), M_ABORT, 0, _("fcntl F_GETFL error. ERR=%s\n"), be.bstrerror());
}
/* Set O_NONBLOCK flag */
if ((fcntl(m_fd, F_SETFL, oflags & ~O_NONBLOCK)) < 0) {
berrno be;
- Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
+ Jmsg1(get_jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
}
m_blocking = 1;
#ifndef HAVE_WIN32
if ((fcntl(m_fd, F_SETFL, flags)) < 0) {
berrno be;
- Jmsg1(jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
+ Jmsg1(get_jcr(), M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.bstrerror());
}
m_blocking = (flags & O_NONBLOCK) ? true : false;
char *host() { return m_host; };
int port() { return m_port; };
JCR *jcr() { return m_jcr; };
+ JCR *get_jcr() { return m_jcr; };
bool is_terminated() { return m_terminated; };
bool is_timed_out() { return m_timed_out; };
void set_terminated() { m_terminated = true; };
{"name", store_name, ITEM(con_font.hdr.name), 0, ITEM_REQUIRED, 0},
{"description", store_str, ITEM(con_font.hdr.desc), 0, 0, 0},
{"font", store_str, ITEM(con_font.fontface), 0, 0, 0},
- {"requiressl", store_bit, ITEM(con_font.require_ssl), 1, ITEM_DEFAULT, 0},
{NULL, NULL, {0}, 0, 0, 0}
};
/* Definition of the contents of each Resource */
-struct DIRRES {
+class DIRRES {
+public:
RES hdr;
int DIRport; /* UA server port */
char *address; /* UA server address */
inline char *DIRRES::name() const { return hdr.name; }
+
struct CONFONTRES {
RES hdr;
char *fontface; /* Console Font specification */
- int require_ssl; /* Require SSL on all connections */
};
-struct CONRES {
+class CONRES {
+public:
RES hdr;
char *password; /* UA server password */
int tls_enable; /* Enable TLS on all connections */
char *tls_ca_certdir; /* TLS CA Certificate Directory */
char *tls_certfile; /* TLS Client Certificate File */
char *tls_keyfile; /* TLS Client Key File */
- utime_t heartbeat_interval; /* Dir heartbeat interval */
+ utime_t heartbeat_interval; /* Cons heartbeat interval */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
+
+ /* Methods */
+ char *name() const;
};
+inline char *CONRES::name() const { return hdr.name; }
+
/* Define the Union of all the above
* resource structure definitions.
typedef union u_res URES;
+#define GetConsoleResWithName(x) ((CONRES *)GetResWithName(R_CONSOLE, (x)))
+#define GetDirResWithName(x) ((DIRRES *)GetResWithName(R_DIRECTOR, (x)))
+
+
#endif /* _BAT_CONF_H_ */
if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) ||
/* Now challenge dir */
!cram_md5_challenge(dir, password, tls_local_need, compatible)) {
- printf(_("%s: Director authorization problem.\n"), my_name);
- display_text(_("Director authorization problem.\n"));
+ display_textf(_("Director authorization problem at \"%s:%d\"\n"),
+ dir->host(), dir->port());
goto bail_out;
}
/* Verify that the remote host is willing to meet our TLS requirements */
if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
- display_text(_("Authorization problem:"
- " Remote server did not advertise required TLS support.\n"));
+ display_textf(_("Authorization problem:"
+ " Remote server at \"%s:%d\" did not advertise required TLS support.\n"),
+ dir->host(), dir->port());
goto bail_out;
}
/* Verify that we are willing to meet the remote host's requirements */
if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK && tls_remote_need != BNET_TLS_OK) {
- display_text(_("Authorization problem:"
- " Remote server requires TLS.\n"));
+ display_textf(_("Authorization problem with Director at \"%s:%d\":"
+ " Remote server requires TLS.\n"),
+ dir->host(), dir->port());
+
goto bail_out;
}
if (tls_local_need >= BNET_TLS_OK && tls_remote_need >= BNET_TLS_OK) {
/* Engage TLS! Full Speed Ahead! */
if (!bnet_tls_client(tls_ctx, dir, NULL)) {
- display_text(_("TLS negotiation failed\n"));
+ display_textf(_("TLS negotiation failed with Director at \"%s:%d\"\n"),
+ dir->host(), dir->port());
goto bail_out;
}
}
Dmsg1(6, ">dird: %s", dir->msg);
if (dir->recv() <= 0) {
stop_bsock_timer(tid);
- display_textf(_("Bad response to Hello command: ERR=%s\n"),
- dir->bstrerror());
- printf(_("%s: Bad response to Hello command: ERR=%s\n"),
- my_name, dir->bstrerror());
- display_text(_("The Director is probably not running.\n"));
+ display_textf(_("Bad response to Hello command: ERR=%s\n"
+ "The Director at \"%s:%d\" is probably not running.\n"),
+ dir->bstrerror(), dir->host(), dir->port());
return false;
}
stop_bsock_timer(tid);
Dmsg1(10, "<dird: %s", dir->msg);
if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) {
- display_text(_("Director rejected Hello command\n"));
+ display_textf(_("Director at \"%s:%d\" rejected Hello command\n"),
+ dir->host(), dir->port());
return false;
} else {
display_text(dir->msg);
bail_out:
stop_bsock_timer(tid);
- display_text(_("Director authorization problem.\n"
+ display_textf(_("Authorization problem with Director at \"%s:%d\"\n"
"Most likely the passwords do not agree.\n"
"If you are using TLS, there may have been a certificate validation error during the TLS handshake.\n"
- "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"));
+ "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"),
+ dir->host(), dir->port());
return false;
}
LockRes();
/* If cons==NULL, default console will be used */
- CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL);
+ CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, NULL);
UnlockRes();
char buf[1024];
/* Initialize Console TLS context */
if (cons && (cons->tls_enable || cons->tls_require)) {
/* Generate passphrase prompt */
- bsnprintf(buf, sizeof(buf), "Passphrase for Console \"%s\" TLS private key: ", cons->hdr.name);
+ bsnprintf(buf, sizeof(buf), "Passphrase for Console \"%s\" TLS private key: ",
+ cons->name());
/* Initialize TLS context:
* Args: CA certfile, CA certdir, Certfile, Keyfile,
if (!cons->tls_ctx) {
display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"),
- m_dir->hdr.name);
+ m_dir->name());
return;
}
}
if (m_dir->tls_enable || m_dir->tls_require) {
/* Generate passphrase prompt */
bsnprintf(buf, sizeof(buf), "Passphrase for Director \"%s\" TLS private key: ",
- m_dir->hdr.name);
+ m_dir->name());
/* Initialize TLS context:
* Args: CA certfile, CA certdir, Certfile, Keyfile,
if (!m_dir->tls_ctx) {
display_textf(_("Failed to initialize TLS context for Director \"%s\".\n"),
- m_dir->hdr.name);
+ m_dir->name());
mainWin->set_status("Connection failed");
return;
}
-/*
- *
- * Bacula authentication. Provides authentication with
- * File and Storage daemons.
- *
- * Nicolas Boichat, August MMIV
- *
- * This routine runs as a thread and must be thread reentrant.
- *
- * Basic tasks done here:
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula authentication. Provides authentication with
+ * File and Storage daemons.
+ *
+ * Nicolas Boichat, August MMIV
+ *
+ * This routine runs as a thread and must be thread reentrant.
+ *
+ * Basic tasks done here:
+ *
+ */
#include "bacula.h"
#include "tray-monitor.h"
/* Timeout Hello after 5 mins */
btimer_t *tid = start_bsock_timer(dir, 60 * 5);
- bnet_fsend(dir, DIRhello, bashed_name);
+ dir->fsend(DIRhello, bashed_name);
if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) ||
!cram_md5_challenge(dir, password, tls_local_need, compatible)) {
}
Dmsg1(6, ">dird: %s", dir->msg);
- if (bnet_recv(dir) <= 0) {
+ if (dir->recv() <= 0) {
stop_bsock_timer(tid);
Jmsg1(jcr, M_FATAL, 0, _("Bad response to Hello command: ERR=%s\n"),
- bnet_strerror(dir));
+ dir->bstrerror());
return 0;
}
Dmsg1(10, "<dird: %s", dir->msg);
Jmsg0(jcr, M_FATAL, 0, _("Director rejected Hello command\n"));
return 0;
} else {
- Jmsg0(jcr, M_FATAL, 0, dir->msg);
+ Jmsg0(jcr, M_INFO, 0, dir->msg);
}
return 1;
}
bash_spaces(dirname);
/* Timeout Hello after 5 mins */
btimer_t *tid = start_bsock_timer(sd, 60 * 5);
- if (!bnet_fsend(sd, SDFDhello, dirname)) {
+ if (!sd->fsend(SDFDhello, dirname)) {
stop_bsock_timer(tid);
Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd));
return 0;
return 0;
}
Dmsg1(116, ">stored: %s", sd->msg);
- if (bnet_recv(sd) <= 0) {
+ if (sd->recv() <= 0) {
stop_bsock_timer(tid);
Jmsg1(jcr, M_FATAL, 0, _("bdird<stored: bad response to Hello command: ERR=%s\n"),
- bnet_strerror(sd));
+ sd->bstrerror());
return 0;
}
Dmsg1(110, "<stored: %s", sd->msg);
bash_spaces(dirname);
/* Timeout Hello after 5 mins */
btimer_t *tid = start_bsock_timer(fd, 60 * 5);
- if (!bnet_fsend(fd, SDFDhello, dirname)) {
+ if (!fd->fsend(SDFDhello, dirname)) {
stop_bsock_timer(tid);
Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon. ERR=%s\n"), bnet_strerror(fd));
return 0;
return 0;
}
Dmsg1(116, ">filed: %s", fd->msg);
- if (bnet_recv(fd) <= 0) {
+ if (fd->recv() <= 0) {
stop_bsock_timer(tid);
Jmsg(jcr, M_FATAL, 0, _("Bad response from File daemon to Hello command: ERR=%s\n"),
- bnet_strerror(fd));
+ fd->bstrerror());
return 0;
}
Dmsg1(110, "<stored: %s", fd->msg);