From: Kern Sibbald Date: Fri, 4 May 2007 15:15:59 +0000 (+0000) Subject: kes Change console Job name from *Console* to -Console- to eliminate X-Git-Tag: Release-7.0.0~6438 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ef5e6d3586cb406724f5f866b589a4422634ebb7;p=bacula%2Fbacula kes Change console Job name from *Console* to -Console- to eliminate Win32 filename problems. Put Win32 path separator when creating Console file. This fixes bug #846. kes Change berrno::strerror() to berrno::bstrerror(). Not yet full implemented. kes Pass jcr to crypt_sign_decode because it creates a new SIGNATURE structure. kes Define b_errno_win32 on Linux to be zero so that it can be or'ed in to force Win32 error message. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4693 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index b5d5afb48d..68a3df8663 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -635,12 +635,14 @@ extern "C" int mknod ( const char *path, int mode, dev_t device ); #if defined(HAVE_WIN32) #define DEFAULT_CONFIGDIR "C:\\Documents and Settings\\All Users\\Application Data\\Bacula" +#define PathSeparator '\\' inline bool IsPathSeparator(int ch) { return ch == '/' || ch == '\\'; } inline char *first_path_separator(char *path) { return strpbrk(path, "/\\"); } inline const char *first_path_separator(const char *path) { return strpbrk(path, "/\\"); } #else +#define PathSeparator '/' /* Define Winsock functions if we aren't on Windows */ #define WSA_Init() 0 /* 0 = success */ diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index b29b7e11db..5d50184b1a 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -125,7 +125,7 @@ static void *handle_UA_client_request(void *arg) pthread_detach(pthread_self()); - jcr = new_control_jcr("*Console*", JT_CONSOLE); + jcr = new_control_jcr("-Console-", JT_CONSOLE); ua = new_ua_context(jcr); ua->UA_sock = user; diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index a85cbec6ad..8a81fe6c4d 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -604,7 +604,7 @@ void do_restore(JCR *jcr) } /* Save signature. */ - if (extract && (sig = crypto_sign_decode((uint8_t *)sd->msg, (uint32_t)sd->msglen)) == NULL) { + if (extract && (sig = crypto_sign_decode(jcr, (uint8_t *)sd->msg, (uint32_t)sd->msglen)) == NULL) { Jmsg1(jcr, M_ERROR, 0, _("Failed to decode message signature for %s\n"), jcr->last_fname); } break; @@ -786,6 +786,7 @@ static const char *zlib_strerror(int stat) static int do_file_digest(FF_PKT *ff_pkt, void *pkt, bool top_level) { JCR *jcr = (JCR *)pkt; + Dmsg1(50, "do_file_digest jcr=%p\n", jcr); return (digest_file(jcr, ff_pkt, jcr->digest)); } @@ -816,6 +817,7 @@ static bool verify_signature(JCR *jcr, SIGNATURE *sig) err = crypto_sign_get_digest(sig, jcr->pki_keypair, &digest); switch (err) { case CRYPTO_ERROR_NONE: + Dmsg0(50, "== Got digest\n"); /* Signature found, digest allocated */ jcr->digest = digest; @@ -832,14 +834,14 @@ static bool verify_signature(JCR *jcr, SIGNATURE *sig) /* Verify the signature */ if ((err = crypto_sign_verify(sig, keypair, digest)) != CRYPTO_ERROR_NONE) { - Dmsg1(100, "Bad signature on %s\n", jcr->last_fname); + Dmsg1(50, "Bad signature on %s\n", jcr->last_fname); Jmsg2(jcr, M_ERROR, 0, _("Signature validation failed for file %s: ERR=%s\n"), jcr->last_fname, crypto_strerror(err)); goto bail_out; } /* Valid signature */ - Dmsg1(100, "Signature good on %s\n", jcr->last_fname); + Dmsg1(50, "Signature good on %s\n", jcr->last_fname); crypto_digest_free(digest); jcr->digest = NULL; return true; @@ -859,7 +861,7 @@ static bool verify_signature(JCR *jcr, SIGNATURE *sig) } /* No signer */ - Dmsg1(100, "Could not find a valid public key for signature on %s\n", jcr->last_fname); + Dmsg1(50, "Could not find a valid public key for signature on %s\n", jcr->last_fname); bail_out: if (digest) { diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index 4456e42675..126ef80fed 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -285,6 +285,7 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) { BFILE bfd; + Dmsg0(50, "=== digest_file\n"); binit(&bfd); if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW @@ -294,6 +295,7 @@ int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest) ff_pkt->ff_errno = errno; berrno be; be.set_errno(bfd.berrno); + Dmsg2(100, "Cannot open %s: ERR=%s\n", ff_pkt->fname, be.strerror()); Jmsg(jcr, M_ERROR, 1, _(" Cannot open %s: ERR=%s.\n"), ff_pkt->fname, be.strerror()); return 1; @@ -336,6 +338,7 @@ int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr) char buf[DEFAULT_NETWORK_BUFFER_SIZE]; int64_t n; + Dmsg0(50, "=== read_digest\n"); while ((n=bread(bfd, buf, sizeof(buf))) > 0) { crypto_digest_update(digest, (uint8_t *)buf, n); jcr->JobBytes += n; @@ -344,6 +347,7 @@ int read_digest(BFILE *bfd, DIGEST *digest, JCR *jcr) if (n < 0) { berrno be; be.set_errno(bfd->berrno); + Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, be.strerror()); Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), jcr->last_fname, be.strerror()); jcr->Errors++; diff --git a/bacula/src/lib/berrno.c b/bacula/src/lib/berrno.c index 4f673635bf..47c1ad82d4 100644 --- a/bacula/src/lib/berrno.c +++ b/bacula/src/lib/berrno.c @@ -1,20 +1,7 @@ -/* - * Bacula errno handler - * - * berrno is a simplistic errno handler that works for - * Unix, Win32, and Bacula bpipes. - * - * See berrno.h for how to use berrno. - * - * Kern Sibbald, July MMIV - * - * Version $Id$ - * - */ /* 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. @@ -38,6 +25,19 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Bacula errno handler + * + * berrno is a simplistic errno handler that works for + * Unix, Win32, and Bacula bpipes. + * + * See berrno.h for how to use berrno. + * + * Kern Sibbald, July MMIV + * + * Version $Id$ + * + */ #include "bacula.h" @@ -47,7 +47,7 @@ extern int num_execvp_errors; extern int execvp_errors[]; #endif -const char *berrno::strerror() +const char *berrno::bstrerror() { #ifdef HAVE_WIN32 if (berrno_ & b_errno_win32) { @@ -82,7 +82,7 @@ const char *berrno::strerror() } #endif /* Normal errno */ - if (bstrerror(berrno_, buf_, 1024) < 0) { + if (b_strerror(berrno_, buf_, 1024) < 0) { return _("Invalid errno. No error message possible."); } return buf_; diff --git a/bacula/src/lib/berrno.h b/bacula/src/lib/berrno.h index 28408a8089..13750cdd35 100644 --- a/bacula/src/lib/berrno.h +++ b/bacula/src/lib/berrno.h @@ -1,13 +1,7 @@ -/* - * Version $Id$ - * - * Kern Sibbald, July MMIV - * - */ /* 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. @@ -31,12 +25,20 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * Version $Id$ + * + * Kern Sibbald, July MMIV + * + */ /* * Extra bits set to interpret errno value differently from errno */ #ifdef HAVE_WIN32 #define b_errno_win32 (1<<29) /* user reserved bit */ +#else +#define b_errno_win32 0 /* On Unix/Linix system */ #endif #define b_errno_exit (1<<28) /* child exited, exit code returned */ #define b_errno_signal (1<<27) /* child died, signal code returned */ @@ -61,8 +63,10 @@ class berrno : public SMARTALLOC { public: berrno(int pool=PM_EMSG); ~berrno(); - const char *strerror(); - const char *strerror(int errnum); + const char *strerror() { return bstrerror(); }; + const char *bstrerror(); + const char *strerror(int errnum) { return bstrerror(errnum); }; + const char *bstrerror(int errnum); void set_errno(int errnum); int code() { return berrno_ & ~(b_errno_exit|b_errno_signal); } int code(int stat) { return stat & ~(b_errno_exit|b_errno_signal); } @@ -83,10 +87,10 @@ inline berrno::~berrno() free_pool_memory(buf_); } -inline const char *berrno::strerror(int errnum) +inline const char *berrno::bstrerror(int errnum) { berrno_ = errnum; - return berrno::strerror(); + return berrno::bstrerror(); } diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 6c2c6a00d5..43b71c8136 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -628,7 +628,7 @@ static BSOCK *bnet_open(JCR *jcr, const char *name, char *host, char *service, if (!connected) { free_addresses(addr_list); - errno = save_errno; + errno = save_errno | b_errno_win32; return NULL; } /* diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index b869d51d1c..3a7899d581 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -348,7 +348,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) #endif /* HAVE_READDIR_R */ -int bstrerror(int errnum, char *buf, size_t bufsiz) +int b_strerror(int errnum, char *buf, size_t bufsiz) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; int stat = 0; diff --git a/bacula/src/lib/crypto.c b/bacula/src/lib/crypto.c index b5cd07c12a..77aa7bcff5 100644 --- a/bacula/src/lib/crypto.c +++ b/bacula/src/lib/crypto.c @@ -597,6 +597,7 @@ DIGEST *crypto_digest_new(JCR *jcr, crypto_digest_t type) digest = (DIGEST *)malloc(sizeof(DIGEST)); digest->type = type; digest->jcr = jcr; + Dmsg1(50, "crypto_digest_new jcr=%p\n", jcr); /* Initialize the OpenSSL message digest context */ EVP_MD_CTX_init(&digest->ctx); @@ -631,6 +632,7 @@ DIGEST *crypto_digest_new(JCR *jcr, crypto_digest_t type) err: /* This should not happen, but never say never ... */ + Dmsg0(50, "Digest init failed.\n"); openssl_post_errors(jcr, M_ERROR, _("OpenSSL digest initialization failed")); crypto_digest_free(digest); return NULL; @@ -644,6 +646,7 @@ err: bool crypto_digest_update(DIGEST *digest, const uint8_t *data, uint32_t length) { if (EVP_DigestUpdate(&digest->ctx, data, length) == 0) { + Dmsg0(50, "digest update failed\n"); openssl_post_errors(digest->jcr, M_ERROR, _("OpenSSL digest update failed")); return false; } else { @@ -661,6 +664,7 @@ bool crypto_digest_update(DIGEST *digest, const uint8_t *data, uint32_t length) bool crypto_digest_finalize(DIGEST *digest, uint8_t *dest, uint32_t *length) { if (!EVP_DigestFinal(&digest->ctx, dest, (unsigned int *)length)) { + Dmsg0(50, "digest finalize failed\n"); openssl_post_errors(digest->jcr, M_ERROR, _("OpenSSL digest finalize failed")); return false; } else { @@ -693,6 +697,7 @@ SIGNATURE *crypto_sign_new(JCR *jcr) sig->sigData = SignatureData_new(); sig->jcr = jcr; + Dmsg1(50, "crypto_sign_new jcr=%p\n", jcr); if (!sig->sigData) { /* Allocation failed in OpenSSL */ @@ -724,6 +729,7 @@ crypto_error_t crypto_sign_get_digest(SIGNATURE *sig, X509_KEYPAIR *keypair, DIG si = sk_SignerInfo_value(signers, i); if (M_ASN1_OCTET_STRING_cmp(keypair->keyid, si->subjectKeyIdentifier) == 0) { /* Get the digest algorithm and allocate a digest context */ + Dmsg1(50, "crypto_sign_get_digest jcr=%p\n", sig->jcr); switch (OBJ_obj2nid(si->digestAlgorithm)) { case NID_md5: *digest = crypto_digest_new(sig->jcr, CRYPTO_DIGEST_MD5); @@ -919,7 +925,7 @@ int crypto_sign_encode(SIGNATURE *sig, uint8_t *dest, uint32_t *length) */ -SIGNATURE *crypto_sign_decode(const uint8_t *sigData, uint32_t length) +SIGNATURE *crypto_sign_decode(JCR *jcr, const uint8_t *sigData, uint32_t length) { SIGNATURE *sig; #if (OPENSSL_VERSION_NUMBER >= 0x0090800FL) @@ -932,13 +938,14 @@ SIGNATURE *crypto_sign_decode(const uint8_t *sigData, uint32_t length) if (!sig) { return NULL; } + sig->jcr = jcr; /* d2i_SignatureData modifies the supplied pointer */ sig->sigData = d2i_SignatureData(NULL, &p, length); if (!sig->sigData) { /* Allocation / Decoding failed in OpenSSL */ - openssl_post_errors(M_ERROR, _("Signature decoding failed")); + openssl_post_errors(jcr, M_ERROR, _("Signature decoding failed")); free(sig); return NULL; } diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 9b161a798e..da28cee39f 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -55,7 +55,7 @@ const char *version = VERSION " (" BDATE ")"; char my_name[30]; /* daemon name is stored here */ char *exepath = (char *)NULL; char *exename = (char *)NULL; -int console_msg_pending = 0; +int console_msg_pending = false; char con_fname[500]; /* Console filename */ FILE *con_fd = NULL; /* Console file descriptor */ brwlock_t con_lock; /* Console lock structure */ @@ -256,7 +256,7 @@ void init_console_msg(const char *wd) { int fd; - bsnprintf(con_fname, sizeof(con_fname), "%s/%s.conmsg", wd, my_name); + bsnprintf(con_fname, sizeof(con_fname), "%s%c%s.conmsg", wd, PathSeparator, my_name); fd = open(con_fname, O_CREAT|O_RDWR|O_BINARY, 0600); if (fd == -1) { berrno be; @@ -679,7 +679,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg) (void)fwrite("\n", 2, 1, con_fd); } fflush(con_fd); - console_msg_pending = TRUE; + console_msg_pending = true; Vw(con_lock); } break; diff --git a/bacula/src/lib/openssl.c b/bacula/src/lib/openssl.c index 8650ca8956..3626d6bc1f 100644 --- a/bacula/src/lib/openssl.c +++ b/bacula/src/lib/openssl.c @@ -76,6 +76,7 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring) while((sslerr = ERR_get_error()) != 0) { /* Acquire the human readable string */ ERR_error_string_n(sslerr, (char *) &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); } } diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 14d202f225..da3aa4d350 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -74,7 +74,7 @@ void make_unique_filename (POOLMEM **name, int Id, char *what); long long int strtoll (const char *ptr, char **endptr, int base); #endif void read_state_file(char *dir, const char *progname, int port); -int bstrerror(int errnum, char *buf, size_t bufsiz); +int b_strerror(int errnum, char *buf, size_t bufsiz); char *escape_filename(const char *file_path); /* bnet.c */ @@ -143,7 +143,7 @@ crypto_error_t crypto_sign_get_digest (SIGNATURE *sig, X509_KEYPAIR *ke crypto_error_t crypto_sign_verify (SIGNATURE *sig, X509_KEYPAIR *keypair, DIGEST *digest); int crypto_sign_add_signer (SIGNATURE *sig, DIGEST *digest, X509_KEYPAIR *keypair); int crypto_sign_encode (SIGNATURE *sig, uint8_t *dest, uint32_t *length); -SIGNATURE * crypto_sign_decode (const uint8_t *sigData, uint32_t length); +SIGNATURE * crypto_sign_decode (JCR *jcr, const uint8_t *sigData, uint32_t length); void crypto_sign_free (SIGNATURE *sig); CRYPTO_SESSION * crypto_session_new (crypto_cipher_t cipher, alist *pubkeys); void crypto_session_free (CRYPTO_SESSION *cs); diff --git a/bacula/src/qt-console/run/runcmd.cpp b/bacula/src/qt-console/run/runcmd.cpp index 4eb8680b1c..b867695390 100644 --- a/bacula/src/qt-console/run/runcmd.cpp +++ b/bacula/src/qt-console/run/runcmd.cpp @@ -64,13 +64,13 @@ void runCmdDialog::fillRunDialog() item = m_console->msg(); items = item.split("\n"); label->setText(items[0]); - Dmsg1(000, "Title=%s\n", items[0].toUtf8().data()); + Dmsg1(200, "Title=%s\n", items[0].toUtf8().data()); items.removeFirst(); /* remove title */ foreach(item, items) { rx.indexIn(item); val = rx.cap(1); - Dmsg1(000, "Item=%s\n", item.toUtf8().data()); - Dmsg1(000, "Value=%s\n", val.toUtf8().data()); + Dmsg1(200, "Item=%s\n", item.toUtf8().data()); + Dmsg1(200, "Value=%s\n", val.toUtf8().data()); if (item.startsWith("JobName:")) { jobCombo->addItem(val); diff --git a/bacula/src/version.h b/bacula/src/version.h index 3a891316bf..67a2ebe9e6 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.1.8" -#define BDATE "03 May 2007" -#define LSMDATE "03May07" +#define BDATE "04 May 2007" +#define LSMDATE "04May07" #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 696d548a04..715e62e304 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,16 @@ Technical notes on version 2.1 General: +04May07 +kes Change console Job name from *Console* to -Console- to eliminate + Win32 filename problems. Put Win32 path separator when creating + Console file. This fixes bug #846. +kes Change berrno::strerror() to berrno::bstrerror(). Not yet full + implemented. +kes Pass jcr to crypt_sign_decode because it creates a new SIGNATURE + structure. +kes Define b_errno_win32 on Linux to be zero so that it can be or'ed in + to force Win32 error message. 03May07 kes First cut strip path. The data should be passed to the FD, but nothing is done with it yet.