From 4dfcc69c5bdbdd7e9881acc6ff7dd805f8f64484 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 22 May 2007 10:35:29 +0000 Subject: [PATCH] kes Implement message callback so that GUI is sure to get all daemon messages. Currently displayed in a dialog in bat. kes Ignore SIGUSR2 (Bacula timer) in bat. kes Apply regress patch from bug #859 to allow regress to work with Solaris compiler. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4873 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 2 ++ bacula/kernstodo | 1 + bacula/src/lib/message.c | 14 +++++++++++++- bacula/src/lib/openssl.c | 18 ++++++++++++------ bacula/src/lib/protos.h | 1 + bacula/src/lib/tls.c | 21 +++++++++++---------- bacula/src/qt-console/bat.h | 2 ++ bacula/src/qt-console/console/console.cpp | 3 +-- bacula/src/qt-console/main.cpp | 2 ++ bacula/src/qt-console/mainwin.cpp | 9 +++++++++ bacula/src/version.h | 4 ++-- bacula/technotes-2.1 | 6 ++++++ 12 files changed, 62 insertions(+), 21 deletions(-) diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index 6cfb26fa4e..d41a605fb6 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -23,6 +23,8 @@ Areas requiring caution or testing: to what we do with sockets). - Solaris is untested - Win32 servers are untested, and very likely not to work. +- SQLite is no longer supported for Solaris -- it fails too often with + bus errors. The major new features are: - Much faster insertion of attributes (somewhere around 10 times), diff --git a/bacula/kernstodo b/bacula/kernstodo index a4d1f74bd9..9fef4e1e0f 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -52,6 +52,7 @@ Professional Needs: - Novell NSS backup http://www.novell.com/coolsolutions/tools/18952.html Priority: +- Look at mincore: http://insights.oetiker.ch/linux/fadvise.html - Unicode input http://en.wikipedia.org/wiki/Byte_Order_Mark - How does restore JobId=nnn work? (Dirk) - What does: restore select fileset="TestSet" client="workplay-fd" pool="Default" diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index d846f42614..2c3cd90cd9 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -61,6 +61,7 @@ FILE *con_fd = NULL; /* Console file descriptor */ brwlock_t con_lock; /* Console lock structure */ static char *catalog_db = NULL; /* database type */ +static void (*message_callback)(int type, char *msg) = NULL; const char *host_os = HOST_OS; const char *distname = DISTNAME; @@ -83,6 +84,11 @@ static bool trace = false; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static MSGS *daemon_msgs; /* global messages */ +void register_message_callback(void msg_callback(int type, char *msg)) +{ + message_callback = msg_callback; +} + /* * Set daemon name. Also, find canonical execution @@ -94,7 +100,6 @@ static MSGS *daemon_msgs; /* global messages */ * Resource record. On the second call, generally, * argv is NULL to avoid doing the path code twice. */ -#define BTRACE_EXTRA 20 void my_name_is(int argc, char *argv[], const char *name) { char *l, *p, *q; @@ -618,12 +623,19 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) dt[dtlen] = 0; } + /* If the program registered a callback, send it there */ + if (message_callback) { + message_callback(type, msg); + return; + } + if (type == M_ABORT || type == M_ERROR_TERM) { fputs(dt, stdout); fputs(msg, stdout); /* print this here to INSURE that it is printed */ fflush(stdout); } + /* Now figure out where to send the message */ msgs = NULL; if (jcr) { diff --git a/bacula/src/lib/openssl.c b/bacula/src/lib/openssl.c index beacf41bbd..96ffcb52bf 100644 --- a/bacula/src/lib/openssl.c +++ b/bacula/src/lib/openssl.c @@ -58,6 +58,12 @@ struct CRYPTO_dynlock_value { pthread_mutex_t mutex; }; +/* + * ***FIXME*** this is a sort of dummy to avoid having to + * change all the existing code to pass either a jcr or + * a NULL. Passing a NULL causes the messages to be + * printed by the daemon -- not very good :-( + */ void openssl_post_errors(int code, const char *errstring) { openssl_post_errors(NULL, code, errstring); @@ -75,7 +81,7 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring) /* Pop errors off of the per-thread queue */ while((sslerr = ERR_get_error()) != 0) { /* Acquire the human readable string */ - ERR_error_string_n(sslerr, (char *) &buf, sizeof(buf)); + ERR_error_string_n(sslerr, buf, sizeof(buf)); Dmsg3(100, "jcr=%p %s: ERR=%s\n", jcr, errstring, buf); Jmsg2(jcr, M_ERROR, 0, "%s: ERR=%s\n", errstring, buf); } @@ -86,10 +92,10 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring) * Returns: thread ID * */ -static unsigned long get_openssl_thread_id (void) +static unsigned long get_openssl_thread_id(void) { /* Comparison without use of pthread_equal() is mandated by the OpenSSL API */ - return ((unsigned long) pthread_self()); + return ((unsigned long)pthread_self()); } /* @@ -100,7 +106,7 @@ static struct CRYPTO_dynlock_value *openssl_create_dynamic_mutex (const char *fi struct CRYPTO_dynlock_value *dynlock; int stat; - dynlock = (struct CRYPTO_dynlock_value *) malloc(sizeof(struct CRYPTO_dynlock_value)); + dynlock = (struct CRYPTO_dynlock_value *)malloc(sizeof(struct CRYPTO_dynlock_value)); if ((stat = pthread_mutex_init(&dynlock->mutex, NULL)) != 0) { berrno be; @@ -110,7 +116,7 @@ static struct CRYPTO_dynlock_value *openssl_create_dynamic_mutex (const char *fi return dynlock; } -static void openssl_update_dynamic_mutex (int mode, struct CRYPTO_dynlock_value *dynlock, const char *file, int line) +static void openssl_update_dynamic_mutex(int mode, struct CRYPTO_dynlock_value *dynlock, const char *file, int line) { if (mode & CRYPTO_LOCK) { P(dynlock->mutex); @@ -119,7 +125,7 @@ static void openssl_update_dynamic_mutex (int mode, struct CRYPTO_dynlock_value } } -static void openssl_destroy_dynamic_mutex (struct CRYPTO_dynlock_value *dynlock, const char *file, int line) +static void openssl_destroy_dynamic_mutex(struct CRYPTO_dynlock_value *dynlock, const char *file, int line) { int stat; diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index da3aa4d350..cbfd34ba4b 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -224,6 +224,7 @@ void free_msgs_res (MSGS *msgs); void dequeue_messages (JCR *jcr); void set_trace (int trace_flag); void set_db_type (const char *name); +void register_message_callback(void msg_callback(int type, char *msg)); /* bnet_server.c */ void bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq, diff --git a/bacula/src/lib/tls.c b/bacula/src/lib/tls.c index df4e78e6c0..141771d76a 100644 --- a/bacula/src/lib/tls.c +++ b/bacula/src/lib/tls.c @@ -65,6 +65,8 @@ struct TLS_Context { SSL_CTX *openssl; CRYPTO_PEM_PASSWD_CB *pem_callback; const void *pem_userdata; + bool tls_enable; + bool tls_require; }; struct TLS_Connection { @@ -78,7 +80,6 @@ struct TLS_Connection { */ static int openssl_verify_peer(int ok, X509_STORE_CTX *store) { - if (!ok) { X509 *cert = X509_STORE_CTX_get_current_cert(store); int depth = X509_STORE_CTX_get_error_depth(store); @@ -120,7 +121,7 @@ TLS_CONTEXT *new_tls_context(const char *ca_certfile, const char *ca_certdir, BIO *bio; DH *dh; - ctx = (TLS_CONTEXT *) malloc(sizeof(TLS_CONTEXT)); + ctx = (TLS_CONTEXT *)malloc(sizeof(TLS_CONTEXT)); /* Allocate our OpenSSL TLSv1 Context */ ctx->openssl = SSL_CTX_new(TLSv1_method()); @@ -204,10 +205,10 @@ TLS_CONTEXT *new_tls_context(const char *ca_certfile, const char *ca_certdir, /* Verify Peer Certificate */ if (verify_peer) { - /* SSL_VERIFY_FAIL_IF_NO_PEER_CERT has no effect in client mode */ - SSL_CTX_set_verify(ctx->openssl, - SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, - openssl_verify_peer); + /* SSL_VERIFY_FAIL_IF_NO_PEER_CERT has no effect in client mode */ + SSL_CTX_set_verify(ctx->openssl, + SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT, + openssl_verify_peer); } return ctx; @@ -380,7 +381,7 @@ success: * Returns: Pointer to TLS_CONNECTION instance on success * NULL on failure; */ -TLS_CONNECTION *new_tls_connection (TLS_CONTEXT *ctx, int fd) +TLS_CONNECTION *new_tls_connection(TLS_CONTEXT *ctx, int fd) { BIO *bio; @@ -397,7 +398,7 @@ TLS_CONNECTION *new_tls_connection (TLS_CONTEXT *ctx, int fd) BIO_set_fd(bio, fd, BIO_NOCLOSE); /* Allocate our new tls connection */ - TLS_CONNECTION *tls = (TLS_CONNECTION *) malloc(sizeof(TLS_CONNECTION)); + TLS_CONNECTION *tls = (TLS_CONNECTION *)malloc(sizeof(TLS_CONNECTION)); /* Create the SSL object and attach the socket BIO */ if ((tls->openssl = SSL_new(ctx->openssl)) == NULL) { @@ -425,7 +426,7 @@ err: /* * Free TLS_CONNECTION instance */ -void free_tls_connection (TLS_CONNECTION *tls) +void free_tls_connection(TLS_CONNECTION *tls) { SSL_free(tls->openssl); free(tls); @@ -533,7 +534,7 @@ bool tls_bsock_accept(BSOCK *bsock) /* * Shutdown TLS_CONNECTION instance */ -void tls_bsock_shutdown (BSOCK *bsock) +void tls_bsock_shutdown(BSOCK *bsock) { /* * SSL_shutdown must be called twice to fully complete the process - diff --git a/bacula/src/qt-console/bat.h b/bacula/src/qt-console/bat.h index 606077e658..bab6c48b84 100644 --- a/bacula/src/qt-console/bat.h +++ b/bacula/src/qt-console/bat.h @@ -34,6 +34,8 @@ * Kern Sibbald, January 2007 */ +#include +#include #include "mainwin.h" #include "config.h" #include "bacula.h" diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 3d3937d160..29f3476a0f 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -34,7 +34,7 @@ * */ -#include +//#include #include "bat.h" #include "console.h" #include "restore.h" @@ -50,7 +50,6 @@ Console::Console(QStackedWidget *parent) m_parent = parent; m_closeable = false; m_console = this; - (void)parent; setupUi(this); m_sock = NULL; diff --git a/bacula/src/qt-console/main.cpp b/bacula/src/qt-console/main.cpp index e5d8145726..bebafdaa0e 100644 --- a/bacula/src/qt-console/main.cpp +++ b/bacula/src/qt-console/main.cpp @@ -78,6 +78,8 @@ int main(int argc, char *argv[]) sigignore.sa_handler = SIG_IGN; sigfillset(&sigignore.sa_mask); sigaction(SIGPIPE, &sigignore, NULL); + sigaction(SIGUSR2, &sigignore, NULL); + while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) { switch (ch) { diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index d2201fb86e..5382346a31 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -47,11 +47,20 @@ #include "joblist/joblist.h" #include "clients/clients.h" +/* + * Daemon message callback + */ +void message_callback(int /* type */, char *msg) +{ + QMessageBox::warning(mainWin, "Bat", msg, QMessageBox::Ok); +} + MainWin::MainWin(QWidget *parent) : QMainWindow(parent) { m_dtformat = "yyyy-MM-dd HH:mm:ss"; mainWin = this; setupUi(this); /* Setup UI defined by main.ui (designer) */ + register_message_callback(message_callback); readPreferences(); treeWidget->clear(); treeWidget->setColumnCount(1); diff --git a/bacula/src/version.h b/bacula/src/version.h index 3dd249fe89..8d0d9d607a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.11" -#define BDATE "21 May 2007" -#define LSMDATE "21May07" +#define BDATE "22 May 2007" +#define LSMDATE "22May07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 2fe5018630..010fc51cf9 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,12 @@ Technical notes on version 2.1 General: +22May07 +kes Implement message callback so that GUI is sure to get all + daemon messages. Currently displayed in a dialog in bat. +kes Ignore SIGUSR2 (Bacula timer) in bat. +kes Apply regress patch from bug #859 to allow regress to work + with Solaris compiler. 21May07 kes Begin adding TLS support to bat. kes Apply UTF-8/16 patch from Yves Orton to -- 2.39.5