From 1538e546b0c94c3003b1934a1adb513a6e409a6c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 14 Nov 2005 20:20:19 +0000 Subject: [PATCH] Apply SunOS patch for ACLs submitted by David Duchscher. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2588 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/examples/bacula_mail_summary.sh | 47 ++++++++++++++++++++++++++ bacula/kes-1.38 | 9 +++++ bacula/src/filed/acl.c | 15 ++++---- bacula/src/stored/askdir.c | 8 ++--- bacula/src/stored/dev.c | 11 +++--- bacula/src/stored/dircmd.c | 5 +++ 6 files changed, 78 insertions(+), 17 deletions(-) create mode 100755 bacula/examples/bacula_mail_summary.sh diff --git a/bacula/examples/bacula_mail_summary.sh b/bacula/examples/bacula_mail_summary.sh new file mode 100755 index 0000000000..266bfd1e5a --- /dev/null +++ b/bacula/examples/bacula_mail_summary.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# This script is to create a summary of the job notifications from bacula +# and send it to people who care. +# +# For it to work, you need to have all Bacula job report +# mails cc'd to a unix mailbox called 'bacula', but of course you can edit +# as appropriate. This should be run after all backup jobs have finished. +# Tested with bacula-1.38.0 + +# Contributed by Andrew J. Millar + +# Use awk to create the report, pass to column to be +# formatted nicely, then on to mail to be sent to +# people who care. +EMAIL_LIST="peoplewhocare@company.com" +awk -F\:\ 'BEGIN { + print "Client Status Type StartTime EndTime Files Bytes" + } + /Client/ { + CLIENT=$2; sub(/"/, "", CLIENT) ; sub(/".*$/, "", CLIENT) + } + /Backup Level/ { + TYPE=$2 ; sub(/,.*$/, "", TYPE) + } + /Start time/ { + STARTTIME=$2; sub(/.*-.*-.* /, "", STARTTIME) + } + /End time/ { + ENDTIME=$2; sub(/.*-.*-.* /, "", ENDTIME) + } + /SD Files Written/ { + SDFILES=$2 + } + /SD Bytes Written/ { + SDBYTES=$2 + } + /Termination/ { + TERMINATION=$2 ; + sub(/Backup/, "", TERMINATION) ; + printf "%s %s %s %s %s %s %s \n", CLIENT,TERMINATION,TYPE,STARTTIME,ENDTIME,SDFILES,SDBYTES}' /var/spool/mail/bacula | \ + column -t | \ + mail -s "Bacula Summary for `date -d yesterday +%a,\ %D`" ${EMAIL_LIST} +# +# Empty the mailbox +cat /dev/null > /var/spool/mail/bacula +# +# That's all folks diff --git a/bacula/kes-1.38 b/bacula/kes-1.38 index 2b34409539..e5b0f313e2 100644 --- a/bacula/kes-1.38 +++ b/bacula/kes-1.38 @@ -4,7 +4,16 @@ General: Changes to 1.38.1: +14Oct05 +- Apply SunOS patch for ACLs submitted by David Duchscher. +- Make sure to set storage before trying to set drive. +- Add bacula_mail_summary.sh to examples directory. It makes + a single email summary of any number of jobs. Submitted + by Adrew J. Millar. +- Make sure when we do a mount to unblock the device even + if the drive could not be opened. 13Oct05 +- Merge Scott's new spec files. - Add doc on setting up Win32 environment variable supplied by Kees van den Broek. - Turn off API debug output unless debug set to avoid confusing diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 46a98ce252..b8f98bcb45 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -47,10 +47,6 @@ #include "bacula.h" #include "filed.h" -/* So we can free system allocated memory */ -#undef free -#undef malloc -#define malloc &* dont use malloc in this routine #else /* @@ -117,6 +113,9 @@ JCR jcr; || !( defined(HAVE_LINUX_OS) \ || defined(HAVE_FREEBSD_OS) \ || defined(HAVE_DARWIN_OS) \ + || defined(HAVE_IRIX_OS) \ + || defined(HAVE_OSF1_OS) \ + || defined(HAVE_SUN_OS) \ ) /* bacl_get() returns the lenght of the string, or -1 on error. */ @@ -318,7 +317,7 @@ int bacl_get(JCR *jcr, int acltype) if (acl(jcr->last_fname, GETACL, n, acls) == n) { if ((acl_text = acltotext(acls, n)) != NULL) { len = pm_strcpy(jcr->acl_text, acl_text); - free(acl_text); + actuallyfree(acl_text); free(acls); return len; } @@ -336,11 +335,11 @@ int bacl_set(JCR *jcr, int acltype) if (!acls) { return -1; } - if (acl(jcr->last_fname, SETACL, n, acls) != 0) { - free(acls); + if (acl(jcr->last_fname, SETACL, n, acls) == -1) { + actuallyfree(acls); return -1; } - free(acls); + actuallyfree(acls); return 0; } diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 08176ce3a9..b9f4340b6c 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -477,7 +477,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) stat = wait_for_sysop(dcr); if (dev->poll) { - Dmsg1(400, "Poll timeout in create append vol on device %s\n", dev->print_name()); + Dmsg1(000, "Poll timeout in create append vol on device %s\n", dev->print_name()); continue; } @@ -486,7 +486,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device %s for Job %s\n"), dev->print_name(), jcr->Job); Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg); - Dmsg1(400, "Gave up waiting on device %s\n", dev->print_name()); + Dmsg1(000, "Gave up waiting on device %s\n", dev->print_name()); return false; /* exceeded maximum waits */ } continue; @@ -503,7 +503,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) Jmsg(jcr, M_WARNING, 0, _("pthread error in mount_next_volume stat=%d ERR=%s\n"), stat, be.strerror(stat)); } - Dmsg1(400, "Someone woke me for device %s\n", dev->print_name()); + Dmsg1(000, "Someone woke me for device %s\n", dev->print_name()); /* If no VolumeName, and cannot get one, try again */ P(dev->mutex); @@ -531,7 +531,7 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) } set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); - Dmsg0(400, "leave dir_ask_sysop_to_mount_create_appendable_volume\n"); + Dmsg0(000, "leave dir_ask_sysop_to_mount_create_appendable_volume\n"); return true; } diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index b01c670383..7dc108cab7 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -359,24 +359,25 @@ void DEVICE::open_tape_device(DCR *dcr, int omode) /* Use system open() */ while ((fd = ::open(dev_name, mode+nonblocking, MODE_RW)) < 0) { berrno be; - Dmsg2(100, "Open error errno=%d ERR=%s\n", errno, be.strerror()); - if (errno == EINTR || errno == EAGAIN) { + dev_errno = errno; + Dmsg5(050, "Open omode=%d mode=%x nonblock=%d error errno=%d ERR=%s\n", + omode, mode, nonblocking, errno, be.strerror()); + if (dev_errno == EINTR || dev_errno == EAGAIN) { Dmsg0(100, "Continue open\n"); continue; } /* Busy wait for specified time (default = 5 mins) */ - if (errno == EBUSY && timeout-- > 0) { + if (dev_errno == EBUSY && timeout-- > 0) { Dmsg2(100, "Device %s busy. ERR=%s\n", print_name(), be.strerror()); bmicrosleep(1, 0); continue; } /* IO error (no volume) try 10 times every 6 seconds */ - if (errno == EIO && ioerrcnt-- > 0) { + if (dev_errno == EIO && ioerrcnt-- > 0) { bmicrosleep(5, 0); Dmsg0(100, "Continue open\n"); continue; } - dev_errno = errno; Mmsg2(errmsg, _("Unable to open device %s: ERR=%s\n"), print_name(), be.strerror(dev_errno)); /* Stop any open timer we set */ diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index f3fa17f209..5a06eeba48 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -581,6 +581,11 @@ static bool mount_cmd(JCR *jcr) bnet_fsend(dir, _("3901 open device failed: ERR=%s\n"), strerror_dev(dev)); dev->open_nowait = false; + if (dev->dev_blocked == BST_UNMOUNTED) { + /* We blocked the device, so unblock it */ + Dmsg0(100, "Unmounted. Unblocking device\n"); + unblock_device(dev); + } break; } dev->open_nowait = false; -- 2.39.5