#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 */
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;
}
/* 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;
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));
}
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;
/* 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;
}
/* 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) {
{
BFILE bfd;
+ Dmsg0(50, "=== digest_file\n");
binit(&bfd);
if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW
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;
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;
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++;
-/*
- * 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.
(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"
extern int execvp_errors[];
#endif
-const char *berrno::strerror()
+const char *berrno::bstrerror()
{
#ifdef HAVE_WIN32
if (berrno_ & b_errno_win32) {
}
#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_;
-/*
- * 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.
(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 */
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); }
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();
}
if (!connected) {
free_addresses(addr_list);
- errno = save_errno;
+ errno = save_errno | b_errno_win32;
return NULL;
}
/*
#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;
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);
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;
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 {
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 {
sig->sigData = SignatureData_new();
sig->jcr = jcr;
+ Dmsg1(50, "crypto_sign_new jcr=%p\n", jcr);
if (!sig->sigData) {
/* Allocation failed in OpenSSL */
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);
*/
-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)
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;
}
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 */
{
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;
(void)fwrite("\n", 2, 1, con_fd);
}
fflush(con_fd);
- console_msg_pending = TRUE;
+ console_msg_pending = true;
Vw(con_lock);
}
break;
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);
}
}
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 */
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);
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);
#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 */
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.