From eed718dc04cfc8da8d691cf1185d444df5d0a9c3 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 29 Oct 2003 15:08:41 +0000 Subject: [PATCH] Final changes git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@789 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ChangeLog | 6 +- bacula/kernstodo | 35 +++++++++++ bacula/src/dird/backup.c | 8 ++- bacula/src/dird/bacula-dir.conf.in | 2 +- bacula/src/filed/filed.c | 88 +++++++++++++-------------- bacula/src/filed/win32/bin/README.txt | 5 +- bacula/src/lib/cram-md5.c | 1 + bacula/src/lib/daemon.c | 11 +--- bacula/src/lib/message.c | 19 +++++- bacula/src/stored/acquire.c | 12 +++- bacula/src/version.h | 4 +- 11 files changed, 125 insertions(+), 66 deletions(-) diff --git a/bacula/ChangeLog b/bacula/ChangeLog index 98bb658ab8..9b85652fdd 100644 --- a/bacula/ChangeLog +++ b/bacula/ChangeLog @@ -1,5 +1,9 @@ -2003-10-26 Version 1.32c 26Oct03 +2003-10-29 Version 1.32c 29Oct03 +29Oct03 +- Add code to ensure that fds 0,1, and 2 are defined by dup'ing them + to /dev/null if necessary. Mostly for Windows that does not have them. +- Error check dir_create_jobmedia_record() 2 places in acquire.c 26Oct03 - More doc fixes. - Make message buffer longer for a status message that was diff --git a/bacula/kernstodo b/bacula/kernstodo index f161f4a27c..ae98c6cda2 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -36,8 +36,43 @@ For 1.33 Testing/Documentation: - Add an item to the FAQ about running jobs in different timezones. For 1.32c +- Add Volume name to "I cannot write on this volume because" For 1.33 +- Write your PID file and chwon root:wheel before drop. +- Make sure there is no symlink in a file before creating a + file (attack). +- Look at mktemp or mkstemp(3). + mktemp and mkstemp create files with predictable names too. That's + not the vulnerability. The vulnerability is in creating files without + using the O_EXCL flag, which means "only create this file if it doesn't + exist, including if the file is a dangling symlink." + + It is *NOT* enough to do the equivalent of + + if doesn't exist $filename + then create $filename + + because between the test and the create another process could have + gotten the CPU and created the file. You must use atomic functions + (those that don't get interrupted by other processes) and O_EXCL is + the only way for this particular example. +- Keep last 5 or 10 completed jobs and show them in a similar + list. +- Make a Running Jobs: output similar to current Scheduled Jobs: +- Use ioctl() fsf if it exists. Figure out where we are from + the mt_status command. Use slow fsf only if other does + not work. +- Add flag to write only one EOF mark on the tape. +- Mount a tape that is not right for the job (wrong # files on tape) + Bacula asks for another tape, fix problems with first tape and + say "mount". All works OK, but status shows: + Device /dev/nst0 open but no Bacula volume is mounted. + Total Bytes=1,153,820,213 Blocks=17,888 Bytes/block=64,502 + Positioned at File=9 Block=3,951 + Full Backup job Rufus.2003-10-26_16.45.31 using Volume "DLT-24Oct03" on device /dev/nst0 + Files=21,003 Bytes=253,954,408 Bytes/sec=2,919,016 + FDReadSeqNo=192,134 in_msg=129830 out_msg=5 fd=7 - Automatically create pools, but instead of looking for what in in Job records, walk through the pool resources. - Check and double check tree code, why does it take so long? diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 2f32d18ce7..6fe03e8550 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -338,8 +338,12 @@ static void backup_cleanup(JCR *jcr, int TermCode, char *since, FILESET_DBR *fsr VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, &VolParams); if (VolCount == 0) { - Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters. ERR=%s\n"), - db_strerror(jcr->db)); + Jmsg(jcr, M_ERROR, 0, _("Could not get Job Volume Parameters to " + "update Bootstrap file. ERR=%s\n"), db_strerror(jcr->db)); + if (jcr->SDJobFiles != 0) { + set_jcr_job_status(jcr, JS_ErrorTerminated); + } + } for (int i=0; i < VolCount; i++) { /* Write the record */ diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index be3f7e3626..9c00dfbdb4 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -185,7 +185,7 @@ Messages { # # WARNING! the following will create a file that you must cycle from # time to time as it will grow indefinitely. However, it will -# also keep all your messages if the scroll off the console. +# also keep all your messages if they scroll off the console. # append = "@working_dir@/log" = all, !skipped } diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 4ad2c704d2..1c321e7d7b 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -103,50 +103,50 @@ int main (int argc, char *argv[]) while ((ch = getopt(argc, argv, "c:d:fg:istu:v?")) != -1) { switch (ch) { - case 'c': /* configuration file */ - if (configfile != NULL) { - free(configfile); - } - configfile = bstrdup(optarg); - break; - - case 'd': /* debug level */ - debug_level = atoi(optarg); - if (debug_level <= 0) { - debug_level = 1; - } - break; - - case 'f': /* run in foreground */ - foreground = TRUE; - break; - - case 'g': /* set group */ - gid = optarg; - break; - - case 'i': - inetd_request = TRUE; - break; - case 's': - no_signals = TRUE; - break; - - case 't': - test_config = TRUE; - break; - - case 'u': /* set userid */ - uid = optarg; - break; - - case 'v': /* verbose */ - verbose++; - break; - - case '?': - default: - usage(); + case 'c': /* configuration file */ + if (configfile != NULL) { + free(configfile); + } + configfile = bstrdup(optarg); + break; + + case 'd': /* debug level */ + debug_level = atoi(optarg); + if (debug_level <= 0) { + debug_level = 1; + } + break; + + case 'f': /* run in foreground */ + foreground = TRUE; + break; + + case 'g': /* set group */ + gid = optarg; + break; + + case 'i': + inetd_request = TRUE; + break; + case 's': + no_signals = TRUE; + break; + + case 't': + test_config = TRUE; + break; + + case 'u': /* set userid */ + uid = optarg; + break; + + case 'v': /* verbose */ + verbose++; + break; + + case '?': + default: + usage(); } } diff --git a/bacula/src/filed/win32/bin/README.txt b/bacula/src/filed/win32/bin/README.txt index 08ab12edd8..cefbf6b158 100644 --- a/bacula/src/filed/win32/bin/README.txt +++ b/bacula/src/filed/win32/bin/README.txt @@ -3,7 +3,7 @@ This is the binary distribution of Bacula for Win32 -systems (Win95, Win98, WinMe, WinNT, and Win2000). +systems (Win95, Win98, WinMe, WinXP, WinNT, and Win2000). INSTALLATION @@ -13,7 +13,7 @@ To install it, please UnZip (or detar) the distribution file into your root directory on drive c:\ then follow the instructions in the online manual viewable by any Internet Browser (Netscape, Microsoft Internet Explorer). -See http://www.bacula.net/htm-manual +See http://www.bacula.org/rel-manual/index.html or get the source release Bacula (tm) is released under the GPL license (given below). @@ -41,4 +41,3 @@ cygwin can be found at http://www.cygwin.com MA 02111-1307, USA. */ - diff --git a/bacula/src/lib/cram-md5.c b/bacula/src/lib/cram-md5.c index 948892dc24..be1ed8db4c 100644 --- a/bacula/src/lib/cram-md5.c +++ b/bacula/src/lib/cram-md5.c @@ -96,6 +96,7 @@ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need) if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s ssl=%d\n", chal, &ssl_has) != 2) { ssl_has = BNET_SSL_NONE; if (sscanf(mp_chr(bs->msg), "auth cram-md5 %s\n", chal) != 1) { + bnet_fsend(bs, "1999 Authorization failed.\n"); Dmsg1(100, "Cannot scan challenge: %s\n", bs->msg); bmicrosleep(5, 0); return 0; diff --git a/bacula/src/lib/daemon.c b/bacula/src/lib/daemon.c index b5ced0cb79..d56287bdbd 100644 --- a/bacula/src/lib/daemon.c +++ b/bacula/src/lib/daemon.c @@ -57,17 +57,10 @@ daemon_start() setsid(); /* In the PRODUCTION system, we close ALL - * file descriptors. It is useful - * for debugging to leave the STDOUT ane STDERR open. + * file descriptors except stdin, stdout, and stderr. */ - for (i=sysconf(_SC_OPEN_MAX)-1; i >=0; i--) { -#ifdef DEBUG - if (i != STDOUT_FILENO && i != STDERR_FILENO) { - close(i); - } -#else + for (i=sysconf(_SC_OPEN_MAX)-1; i >= 3; i--) { close(i); -#endif } /* Move to root directory. For debug we stay diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index dc7c4723ff..98c03a86b5 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -158,12 +158,29 @@ void init_msg(JCR *jcr, MSGS *msg) { DEST *d, *dnew, *temp_chain = NULL; + int i, fd; + + /* + * Make sure we have fd's 0, 1, 2 open + * If we don't do this one of our sockets may open + * there and if we then use stdout, it could + * send total garbage to our socket. + * + */ + fd = open("/dev/null", O_RDONLY, 0644); + if (fd > 2) { + close(fd); + } else { + for(i=1; fd + i <= 2; i++) { + dup2(fd, fd+i); + } + } + /* * If msg is NULL, initialize global chain for STDOUT and syslog */ if (msg == NULL) { - int i; daemon_msgs = (MSGS *)malloc(sizeof(MSGS)); memset(daemon_msgs, 0, sizeof(MSGS)); for (i=1; i<=M_MAX; i++) { diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 940b0171f2..44e00b6bd7 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -294,7 +294,10 @@ int release_device(JCR *jcr, DEVICE *dev) /* If we are the only writer, write EOF after job */ if (dev->state & ST_LABEL) { Dmsg0(100, "dir_create_jobmedia_record. Release\n"); - dir_create_jobmedia_record(jcr); + if (!dir_create_jobmedia_record(jcr)) { + Jmsg(jcr, M_ERROR, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + jcr->VolCatInfo.VolCatName, jcr->Job); + } if (dev_can_write(dev)) { weof_dev(dev, 1); } @@ -311,14 +314,17 @@ int release_device(JCR *jcr, DEVICE *dev) } } else if (dev->state & ST_LABEL) { Dmsg0(100, "dir_create_jobmedia_record. Release\n"); - dir_create_jobmedia_record(jcr); + if (!dir_create_jobmedia_record(jcr)) { + Jmsg(jcr, M_ERROR, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"), + jcr->VolCatInfo.VolCatName, jcr->Job); + } Dmsg0(200, "dir_update_vol_info. Release1\n"); dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */ dev->VolCatInfo.VolCatJobs++; /* increment number of jobs */ dir_update_volume_info(jcr, &dev->VolCatInfo, 0); /* send Volume info to Director */ } } else { - Jmsg2(jcr, M_ERROR, 0, _("BAD ERROR: release_device %s, Volume %s not in use.\n"), + Jmsg2(jcr, M_ERROR, 0, _("BAD ERROR: release_device %s, Volume \"%s\" not in use.\n"), dev_name(dev), NPRT(jcr->VolumeName)); } detach_jcr_from_device(dev, jcr); diff --git a/bacula/src/version.h b/bacula/src/version.h index c4109aae2c..c138161f4a 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.32c" #define VSTRING "1" -#define BDATE "26 Oct 2003" -#define LSMDATE "26Oct03" +#define BDATE "29 Oct 2003" +#define LSMDATE "20Oct03" /* Debug flags */ #undef DEBUG -- 2.39.5