From: Kern Sibbald Date: Wed, 7 Dec 2005 10:10:30 +0000 (+0000) Subject: - Remove warning message about multiple saves of hardlinked files X-Git-Tag: Release-7.0.0~8232 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bf8c83dba953374f736a5f73b4191de1b5dc9acd;hp=1232bbff04c2fb23a4c0756fdf1232099f113574;p=bacula%2Fbacula - Remove warning message about multiple saves of hardlinked files from find_one.c as it can generate too many warning messages. 06Dec05 - Reset timeout values before select() per patch from Frank Sweetser for problems with non-blocking sockets. - Unlink the state file if either reading or writing it gets errors. Hopefully this will fix Win32 exit problems. - Add sanity check in append.c to ensure that dcr is not NULL. This can happen if multiple drive autochanger SCSI control channel and drive indicies do not correspond. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2649 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 1093efbd17..39432750a7 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -14,6 +14,7 @@ Document: - Document the multiple-drive-changer.txt script. - Pruning with Admin job. - Does WildFile match against full name? Doc. +- %d and %v only valid on Director, not for ClientRunBefore/After. For 1.39: - Queue warning/error messages during restore so that they diff --git a/bacula/kes-1.39 b/bacula/kes-1.39 index cc4b51f1c7..1195f3cf6a 100644 --- a/bacula/kes-1.39 +++ b/bacula/kes-1.39 @@ -4,6 +4,17 @@ General: Changes to 1.39.2: +07Dec05 +- Remove warning message about multiple saves of hardlinked files + from find_one.c as it can generate too many warning messages. +06Dec05 +- Reset timeout values before select() per patch from + Frank Sweetser for problems with non-blocking sockets. +- Unlink the state file if either reading or writing it gets + errors. Hopefully this will fix Win32 exit problems. +- Add sanity check in append.c to ensure that dcr is not NULL. + This can happen if multiple drive autochanger SCSI control + channel and drive indicies do not correspond. 05Dec05 - Get next volume from Scratch pool before creating a volume. - Set new Pool defaults in Vol when moved from Scratch Pool. diff --git a/bacula/platforms/redhat/bacula.spec.in b/bacula/platforms/redhat/bacula.spec.in index 7e82118e74..9743d8c8e1 100644 --- a/bacula/platforms/redhat/bacula.spec.in +++ b/bacula/platforms/redhat/bacula.spec.in @@ -1,5 +1,5 @@ # Bacula RPM spec file -# Copyright (C) 2004 Kern Sibbald +# Copyright (C) 2000-2005 Kern Sibbald # Platform Build Configuration @@ -27,6 +27,8 @@ %{?build_fc1:%define fc1 1} %define fc3 0 %{?build_fc3:%define fc3 1} +%define fc4 0 +%{?build_fc4:%define fc4 1} # Whitebox Enterprise build %define wb3 0 %{?build_wb3:%define wb3 1} @@ -36,11 +38,11 @@ %{?build_rhel3:%define wb3 1} %define rhel4 0 %{?build_rhel4:%define rhel4 1} -%{?build_rhel4:%define fc3 1} +%{?build_rhel4:%define fc4 1} # CentOS build %define centos4 0 %{?build_centos4:%define centos4 1} -%{?build_centos4:%define fc3 1} +%{?build_centos4:%define fc4 1} # SuSE build %define su9 0 %{?build_su9:%define su9 1} @@ -49,7 +51,7 @@ %{?build_mdk:%define mdk 1} # test for a platform definition -%if ! %{rh7} && ! %{rh8} && ! %{rh9} && ! %{fc1} && ! %{fc3} && ! %{wb3} && ! %{su9} && ! %{mdk} +%if ! %{rh7} && ! %{rh8} && ! %{rh9} && ! %{fc1} && ! %{fc3} && ! %{fc4} && ! %{wb3} && ! %{su9} && ! %{mdk} %{error: You must specify a platform. Please examine the spec file.} exit 1 %endif @@ -87,7 +89,7 @@ exit 1 %if %{centos4} %define _dist %(grep CentOS /etc/redhat-release) %endif -%if %{fc3} && ! %{rhel4} && ! %{centos4} +%if %{fc3} || %{fc4} && ! %{rhel4} && ! %{centos4} %define _dist %(grep Fedora /etc/redhat-release) %endif %if %{wb3} && ! %{rhel3} @@ -162,7 +164,7 @@ BuildRequires: libstdc++-static-devel BuildRequires: glibc-static-devel BuildRequires: freetype2-devel %endif -%if %{fc3} +%if %{fc3} || %{fc4} BuildRequires: libtermcap-devel BuildRequires: gtk2-devel >= 2.4 BuildRequires: libgnomeui-devel >= 2.8 @@ -175,7 +177,7 @@ BuildRequires: bonobo-activation-devel BuildRequires: GConf2-devel BuildRequires: freetype-devel %endif -%if ! %{rh7} && ! %{su9} && ! %{mdk} && ! %{fc3} +%if ! %{rh7} && ! %{su9} && ! %{mdk} && ! %{fc3} && !%{fc4} BuildRequires: libtermcap-devel BuildRequires: gtk2-devel >= 2.0 BuildRequires: libgnomeui-devel >= 2.0 @@ -405,7 +407,7 @@ Requires: libbonoboui >= 2.0 Requires: GConf2 Requires: freetype2 %endif -%if %{fc3} +%if %{fc3} || %{fc4} Requires: gtk2 >= 2.4 Requires: libgnomeui >= 2.8 Requires: glibc >= 2.3 @@ -417,7 +419,7 @@ Requires: bonobo-activation Requires: GConf2 Requires: freetype %endif -%if ! %{rh7} && ! %{su9} && ! %{mdk} && ! %{fc3} +%if ! %{rh7} && ! %{su9} && ! %{mdk} && ! %{fc3} && ! %{fc4} Requires: gtk2 >= 2.0 Requires: libgnomeui >= 2.0 Requires: glibc >= 2.3 @@ -509,7 +511,7 @@ export LDFLAGS=-L/usr/lib64/mysql --enable-smartalloc \ --enable-gnome \ %if ! %{rh7} && ! %{rh8} - --enable-tray-monitor \ + --enable-tray-monitor \ %endif %if %{mysql} --with-mysql \ @@ -523,12 +525,12 @@ export LDFLAGS=-L/usr/lib64/mysql --with-working-dir=%{working_dir} \ --with-pid-dir=/var/run \ --with-subsys-dir=/var/lock/subsys \ - --with-dir-user=%{daemon_user} \ - --with-dir-group=%{daemon_group} \ - --with-sd-user=%{daemon_user} \ - --with-sd-group=%{daemon_group} \ - --with-fd-user=%{daemon_user} \ - --with-fd-group=%{daemon_group} + --with-dir-user=%{daemon_user} \ + --with-dir-group=%{daemon_group} \ + --with-sd-user=%{daemon_user} \ + --with-sd-group=%{daemon_group} \ + --with-fd-user=%{daemon_user} \ + --with-fd-group=%{daemon_group} make %install @@ -620,7 +622,7 @@ cp -p scripts/gnome-console.console_apps $RPM_BUILD_ROOT/etc/security/console.ap cp -p scripts/gnome-console.pamd $RPM_BUILD_ROOT/etc/pam.d/gnome-console ln -sf consolehelper $RPM_BUILD_ROOT/usr/bin/gnome-console %endif -%if %{rh8} || %{rh9} || %{wb3} || %{fc1} || %{fc3} || %{mdk} +%if %{rh8} || %{rh9} || %{wb3} || %{fc1} || %{fc3} || %{fc4} || %{mdk} cp -p scripts/bacula.png $RPM_BUILD_ROOT/usr/share/pixmaps/bacula.png cp -p scripts/bacula.desktop.gnome2.consolehelper $RPM_BUILD_ROOT/usr/share/applications/bacula.desktop cp -p scripts/gnome-console.console_apps $RPM_BUILD_ROOT/etc/security/console.apps/gnome-console @@ -745,17 +747,17 @@ chmod 644 $RPM_BUILD_ROOT/etc/bacula/tray-monitor.conf DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1` if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "8" ]; then - echo "This bacula upgrade will update a bacula database from version 8 to 9." - echo "You appear to be running database version $DB_VER. You must first update" - echo "your database to version 8 and then install this upgrade. The alternative" - echo "is to use /etc/bacula/drop_mysql_tables to delete all your your current" - echo "catalog information, then do the upgrade. Information on updating a" - echo "database older than version 8 can be found in the release notes." - exit 1 + echo "This bacula upgrade will update a bacula database from version 8 to 9." + echo "You appear to be running database version $DB_VER. You must first update" + echo "your database to version 8 and then install this upgrade. The alternative" + echo "is to use /etc/bacula/drop_mysql_tables to delete all your your current" + echo "catalog information, then do the upgrade. Information on updating a" + echo "database older than version 8 can be found in the release notes." + exit 1 fi # check for and copy /etc/bacula/console.conf to bconsole.conf if [ -s /etc/bacula/console.conf ];then - cp -p /etc/bacula/console.conf /etc/bacula/bconsole.conf + cp -p /etc/bacula/console.conf /etc/bacula/bconsole.conf fi %post mysql @@ -773,31 +775,31 @@ DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1` # grant privileges and create tables if they do not exist if [ -z "$DB_VER" ]; then - echo "Hmm, doesn't look like you have an existing database." - echo "Granting privileges for MySQL user bacula..." - /etc/bacula/grant_mysql_privileges - echo "Creating MySQL bacula database..." - /etc/bacula/create_mysql_database - echo "Creating bacula tables..." - /etc/bacula/make_mysql_tables + echo "Hmm, doesn't look like you have an existing database." + echo "Granting privileges for MySQL user bacula..." + /etc/bacula/grant_mysql_privileges + echo "Creating MySQL bacula database..." + /etc/bacula/create_mysql_database + echo "Creating bacula tables..." + /etc/bacula/make_mysql_tables # check to see if we need to upgrade a 1.36 or lower database elif [ "$DB_VER" -lt "9" ]; then - echo "This release requires an upgrade to your bacula database." - echo "Backing up your current database..." - mysqldump -f --opt bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2 - echo "Upgrading bacula database ..." - /etc/bacula/update_mysql_tables - echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" + echo "This release requires an upgrade to your bacula database." + echo "Backing up your current database..." + mysqldump -f --opt bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2 + echo "Upgrading bacula database ..." + /etc/bacula/update_mysql_tables + echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" fi # create the daemon group HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null` if [ -z $HAVE_BACULA ]; then - %{groupadd} -r %{daemon_group} > /dev/null 2>&1 - echo "The group %{daemon_group} has been added to %{group_file}." - echo "See the manual chapter Running Bacula for details." + %{groupadd} -r %{daemon_group} > /dev/null 2>&1 + echo "The group %{daemon_group} has been added to %{group_file}." + echo "See the manual chapter Running Bacula for details." fi %preun mysql @@ -881,20 +883,20 @@ fi %pre sqlite # test for bacula database older than version 8 if [ -s %{working_dir}/bacula.db ] && [ -s %{sqlite_bindir}/sqlite ];then - DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1` - if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "8" ]; then - echo "This bacula upgrade will update a bacula database from version 8 to 9." - echo "You appear to be running database version $DB_VER. You must first update" - echo "your database to version 8 and then install this upgrade. The alternative" - echo "is to use /etc/bacula/drop_sqlite_tables to delete all your your current" - echo "catalog information, then do the upgrade. Information on updating a" - echo "database older than version 8 can be found in the release notes." - exit 1 - fi + DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1` + if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "8" ]; then + echo "This bacula upgrade will update a bacula database from version 8 to 9." + echo "You appear to be running database version $DB_VER. You must first update" + echo "your database to version 8 and then install this upgrade. The alternative" + echo "is to use /etc/bacula/drop_sqlite_tables to delete all your your current" + echo "catalog information, then do the upgrade. Information on updating a" + echo "database older than version 8 can be found in the release notes." + exit 1 + fi fi # check for and copy /etc/bacula/console.conf to bconsole.conf if [ -s /etc/bacula/console.conf ];then - cp -p /etc/bacula/console.conf /etc/bacula/bconsole.conf + cp -p /etc/bacula/console.conf /etc/bacula/bconsole.conf fi %post sqlite @@ -907,40 +909,40 @@ fi # test for an existing database if [ -s %{working_dir}/bacula.db ]; then - DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1` - # check to see if we need to upgrade a 1.36 or lower database - if [ "$DB_VER" -lt "8" ]; then - echo "This bacula upgrade requires a database update to version 9. You appear to" - echo "be running database version $DB_VER. You must update your database using the" - echo "upgrade scripts in the bacula-updatedb package. The alternative" - echo "is to use /etc/bacula/drop_sqlite_tables to delete all your your current" - echo "catalog information, then /etc/bacula/make_sqlite_tables. Information on updating a" - echo "database older than version 8 can be found in the release notes." - fi - - if [ "$DB_VER" -lt "9" ] && [ "$DB_VER" -ge "8" ]; then - echo "This release requires an upgrade to your bacula database." - echo "Backing up your current database..." - echo ".dump" | %{sqlite_bindir}/sqlite %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2 - echo "Upgrading bacula database ..." - /etc/bacula/update_sqlite_tables - echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" - fi + DB_VER=`echo "select * from Version;" | %{sqlite_bindir}/sqlite 2>/dev/null %{working_dir}/bacula.db | tail -n 1` + # check to see if we need to upgrade a 1.36 or lower database + if [ "$DB_VER" -lt "8" ]; then + echo "This bacula upgrade requires a database update to version 9. You appear to" + echo "be running database version $DB_VER. You must update your database using the" + echo "upgrade scripts in the bacula-updatedb package. The alternative" + echo "is to use /etc/bacula/drop_sqlite_tables to delete all your your current" + echo "catalog information, then /etc/bacula/make_sqlite_tables. Information on updating a" + echo "database older than version 8 can be found in the release notes." + fi + + if [ "$DB_VER" -lt "9" ] && [ "$DB_VER" -ge "8" ]; then + echo "This release requires an upgrade to your bacula database." + echo "Backing up your current database..." + echo ".dump" | %{sqlite_bindir}/sqlite %{working_dir}/bacula.db | bzip2 > %{working_dir}/bacula_backup.sql.bz2 + echo "Upgrading bacula database ..." + /etc/bacula/update_sqlite_tables + echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" + fi else - # create the database and tables - echo "Hmm, doesn't look like you have an existing database." - echo "Creating SQLite database..." - /etc/bacula/create_sqlite_database - echo "Creating the SQLite tables..." - /etc/bacula/make_sqlite_tables + # create the database and tables + echo "Hmm, doesn't look like you have an existing database." + echo "Creating SQLite database..." + /etc/bacula/create_sqlite_database + echo "Creating the SQLite tables..." + /etc/bacula/make_sqlite_tables fi # create the daemon group HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null` if [ -z $HAVE_BACULA ]; then - %{groupadd} -r %{daemon_group} > /dev/null 2>&1 - echo "The group %{daemon_group} has been added to %{group_file}." - echo "See the manual chapter Running Bacula for details." + %{groupadd} -r %{daemon_group} > /dev/null 2>&1 + echo "The group %{daemon_group} has been added to %{group_file}." + echo "See the manual chapter Running Bacula for details." fi %preun sqlite @@ -1023,13 +1025,13 @@ fi DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1` if [ -n "$DB_VER" ] && [ "$DB_VER" -lt "8" ]; then - echo "This bacula upgrade will update a bacula database from version 8 to 9." - echo "You appear to be running database version $DB_VER. You must first update" - echo "your database to version 8 and then install this upgrade. The alternative" - echo "is to use /etc/bacula/drop_postgresql_tables to delete all your your current" - echo "catalog information, then do the upgrade. Information on updating a" - echo "database older than version 8 can be found in the release notes." - exit 1 + echo "This bacula upgrade will update a bacula database from version 8 to 9." + echo "You appear to be running database version $DB_VER. You must first update" + echo "your database to version 8 and then install this upgrade. The alternative" + echo "is to use /etc/bacula/drop_postgresql_tables to delete all your your current" + echo "catalog information, then do the upgrade. Information on updating a" + echo "database older than version 8 can be found in the release notes." + exit 1 fi %post postgresql @@ -1046,33 +1048,33 @@ DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head # grant privileges and create tables if they do not exist if [ -z "$DB_VER" ]; then - echo "Hmm, doesn't look like you have an existing database." - echo "Creating PostgreSQL bacula database..." - /etc/bacula/create_postgresql_database - echo "Creating bacula tables..." - /etc/bacula/make_postgresql_tables - echo "Granting privileges for PostgreSQL user bacula..." - /etc/bacula/grant_postgresql_privileges + echo "Hmm, doesn't look like you have an existing database." + echo "Creating PostgreSQL bacula database..." + /etc/bacula/create_postgresql_database + echo "Creating bacula tables..." + /etc/bacula/make_postgresql_tables + echo "Granting privileges for PostgreSQL user bacula..." + /etc/bacula/grant_postgresql_privileges # check to see if we need to upgrade a 1.36 or lower database elif [ "$DB_VER" -lt "9" ]; then - echo "This release requires an upgrade to your bacula database." - echo "Backing up your current database..." - pg_dump bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2 - echo "Upgrading bacula database ..." - /etc/bacula/update_postgresql_tables - echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" - + echo "This release requires an upgrade to your bacula database." + echo "Backing up your current database..." + pg_dump bacula | bzip2 > %{working_dir}/bacula_backup.sql.bz2 + echo "Upgrading bacula database ..." + /etc/bacula/update_postgresql_tables + echo "If bacula works correctly you can remove the backup file %{working_dir}/bacula_backup.sql.bz2" + fi # create the daemon group HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null` if [ -z $HAVE_BACULA ]; then - %{groupadd} -r %{daemon_group} > /dev/null 2>&1 - echo "The group %{daemon_group} has been added to %{groupfile}." - echo "See the manual chapter Running Bacula for details." + %{groupadd} -r %{daemon_group} > /dev/null 2>&1 + echo "The group %{daemon_group} has been added to %{groupfile}." + echo "See the manual chapter Running Bacula for details." fi - + %preun postgresql # delete our links @@ -1117,9 +1119,9 @@ fi # create the daemon group HAVE_BACULA=`cat %{group_file} | grep %{daemon_group} 2>/dev/null` if [ -z $HAVE_BACULA ]; then - %{groupadd} -r %{daemon_group} > /dev/null 2>&1 - echo "The group %{daemon_group} has been added to %{group_file}." - echo "See the manual chapter Running Bacula for details." + %{groupadd} -r %{daemon_group} > /dev/null 2>&1 + echo "The group %{daemon_group} has been added to %{group_file}." + echo "See the manual chapter Running Bacula for details." fi %preun client diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 91ac80890b..1f497687c0 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -238,8 +238,6 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, lp->dev == (dev_t)ff_pkt->statp.st_dev) { /* If we have already backed up the hard linked file don't do it again */ if (strcmp(lp->name, fname) == 0) { - Jmsg1(jcr, M_WARNING, 0, _("Attempt to backup hard linked file %s twice ignored.\n"), - fname); return 1; /* ignore */ } ff_pkt->link = lp->name; diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 74e198220d..d94112490a 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -538,9 +538,9 @@ int bnet_wait_data(BSOCK * bsock, int sec) FD_ZERO(&fdset); FD_SET((unsigned)bsock->fd, &fdset); - tv.tv_sec = sec; - tv.tv_usec = 0; for (;;) { + tv.tv_sec = sec; + tv.tv_usec = 0; switch (select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) { case 0: /* timeout */ bsock->b_errno = 0; diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 67c163242b..e15dcee1dc 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -489,6 +489,7 @@ void read_state_file(char *dir, const char *progname, int port) { int sfd; ssize_t stat; + bool ok = false; POOLMEM *fname = get_pool_memory(PM_FNAME); struct s_state_hdr hdr; int hdr_size = sizeof(hdr); @@ -499,7 +500,7 @@ void read_state_file(char *dir, const char *progname, int port) if ((sfd = open(fname, O_RDONLY|O_BINARY, 0)) < 0) { Dmsg3(010, "Could not open state file. sfd=%d size=%d: ERR=%s\n", sfd, sizeof(hdr), strerror(errno)); - goto bail_out; + goto bail_out; } if ((stat=read(sfd, &hdr, hdr_size)) != hdr_size) { Dmsg4(010, "Could not read state file. sfd=%d stat=%d size=%d: ERR=%s\n", @@ -516,11 +517,17 @@ void read_state_file(char *dir, const char *progname, int port) goto bail_out; } // Dmsg1(010, "Read header of %d bytes.\n", sizeof(hdr)); - read_last_jobs_list(sfd, hdr.last_jobs_addr); + if (!read_last_jobs_list(sfd, hdr.last_jobs_addr)) { + goto bail_out; + } + ok = true; bail_out: if (sfd >= 0) { close(sfd); } + if (!ok) { + unlink(fname); + } free_pool_memory(fname); } @@ -530,17 +537,20 @@ bail_out: void write_state_file(char *dir, const char *progname, int port) { int sfd; + bool ok = false; POOLMEM *fname = get_pool_memory(PM_FNAME); Mmsg(&fname, "%s/%s.%d.state", dir, progname, port); /* Create new state file */ if ((sfd = open(fname, O_CREAT|O_WRONLY|O_BINARY, 0640)) < 0) { - Dmsg2(000, "Could not create state file. %s ERR=%s\n", fname, strerror(errno)); - Emsg2(M_ERROR, 0, _("Could not create state file. %s ERR=%s\n"), fname, strerror(errno)); + berrno be; + Dmsg2(000, "Could not create state file. %s ERR=%s\n", fname, be.strerror()); + Emsg2(M_ERROR, 0, _("Could not create state file. %s ERR=%s\n"), fname, be.strerror()); goto bail_out; } if (write(sfd, &state_hdr, sizeof(state_hdr)) != sizeof(state_hdr)) { - Dmsg1(000, "Write hdr error: ERR=%s\n", strerror(errno)); + berrno be; + Dmsg1(000, "Write hdr error: ERR=%s\n", be.strerror()); goto bail_out; } // Dmsg1(010, "Wrote header of %d bytes\n", sizeof(state_hdr)); @@ -548,17 +558,24 @@ void write_state_file(char *dir, const char *progname, int port) state_hdr.reserved[0] = write_last_jobs_list(sfd, state_hdr.last_jobs_addr); // Dmsg1(010, "write last job end = %d\n", (int)state_hdr.reserved[0]); if (lseek(sfd, 0, SEEK_SET) < 0) { - Dmsg1(000, "lseek error: ERR=%s\n", strerror(errno)); + berrno be; + Dmsg1(000, "lseek error: ERR=%s\n", be.strerror()); goto bail_out; } if (write(sfd, &state_hdr, sizeof(state_hdr)) != sizeof(state_hdr)) { - Pmsg1(000, _("Write final hdr error: ERR=%s\n"), strerror(errno)); + berrno be; + Pmsg1(000, _("Write final hdr error: ERR=%s\n"), be.strerror()); + goto bail_out; } + ok = true; // Dmsg1(010, "rewrote header = %d\n", sizeof(state_hdr)); bail_out: if (sfd >= 0) { close(sfd); } + if (!ok) { + unlink(fname); + } free_pool_memory(fname); } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 747ebc7fc9..3db430beab 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -105,26 +105,26 @@ void term_last_jobs_list() } } -void read_last_jobs_list(int fd, uint64_t addr) +bool read_last_jobs_list(int fd, uint64_t addr) { struct s_last_job *je, job; uint32_t num; Dmsg1(100, "read_last_jobs seek to %d\n", (int)addr); if (addr == 0 || lseek(fd, (off_t)addr, SEEK_SET) < 0) { - return; + return false; } if (read(fd, &num, sizeof(num)) != sizeof(num)) { - return; + return false; } Dmsg1(100, "Read num_items=%d\n", num); if (num > 4 * max_last_jobs) { /* sanity check */ - return; + return false; } for ( ; num; num--) { if (read(fd, &job, sizeof(job)) != sizeof(job)) { Dmsg1(000, "Read job entry. ERR=%s\n", strerror(errno)); - return; + return false; } if (job.JobId > 0) { je = (struct s_last_job *)malloc(sizeof(struct s_last_job)); @@ -140,6 +140,7 @@ void read_last_jobs_list(int fd, uint64_t addr) } } } + return true; } uint64_t write_last_jobs_list(int fd, uint64_t addr) diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 244f1ca49c..c03a52bb88 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -158,7 +158,7 @@ void init_last_jobs_list(); void term_last_jobs_list(); void lock_last_jobs_list(); void unlock_last_jobs_list(); -void read_last_jobs_list(int fd, uint64_t addr); +bool read_last_jobs_list(int fd, uint64_t addr); uint64_t write_last_jobs_list(int fd, uint64_t addr); void write_state_file(char *dir, const char *progname, int port); void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx); diff --git a/bacula/src/lib/tls.c b/bacula/src/lib/tls.c index d9d3b51002..978e1aede9 100644 --- a/bacula/src/lib/tls.c +++ b/bacula/src/lib/tls.c @@ -432,8 +432,6 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) /* Zero the fdset, we'll set our fd prior to each invocation of select() */ FD_ZERO(&fdset); - tv.tv_sec = 10; - tv.tv_usec = 0; fdmax = bsock->fd + 1; /* Ensure that socket is non-blocking */ @@ -452,31 +450,37 @@ static inline bool openssl_bsock_session_start(BSOCK *bsock, bool server) /* Handle errors */ switch (SSL_get_error(tls->openssl, err)) { - case SSL_ERROR_NONE: - stat = true; - goto cleanup; - case SSL_ERROR_ZERO_RETURN: - /* TLS connection was cleanly shut down */ - openssl_post_errors(M_ERROR, _("Connect failure")); - stat = false; - goto cleanup; - case SSL_ERROR_WANT_READ: - /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); - /* Block until we can read */ - select(fdmax, &fdset, NULL, &fdset, &tv); - break; - case SSL_ERROR_WANT_WRITE: - /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); - /* Block until we can write */ - select(fdmax, NULL, &fdset, &fdset, &tv); - break; - default: - /* Socket Error Occured */ - openssl_post_errors(M_ERROR, _("Connect failure")); - stat = false; - goto cleanup; + case SSL_ERROR_NONE: + stat = true; + goto cleanup; + case SSL_ERROR_ZERO_RETURN: + /* TLS connection was cleanly shut down */ + openssl_post_errors(M_ERROR, _("Connect failure")); + stat = false; + goto cleanup; + case SSL_ERROR_WANT_READ: + /* If we timeout of a select, this will be unset */ + FD_SET((unsigned) bsock->fd, &fdset); + /* Set our timeout */ + tv.tv_sec = 10; + tv.tv_usec = 0; + /* Block until we can read */ + select(fdmax, &fdset, NULL, &fdset, &tv); + break; + case SSL_ERROR_WANT_WRITE: + /* If we timeout of a select, this will be unset */ + FD_SET((unsigned) bsock->fd, &fdset); + /* Set our timeout */ + tv.tv_sec = 10; + tv.tv_usec = 0; + /* Block until we can write */ + select(fdmax, NULL, &fdset, &fdset, &tv); + break; + default: + /* Socket Error Occured */ + openssl_post_errors(M_ERROR, _("Connect failure")); + stat = false; + goto cleanup; } if (bsock->timed_out) { @@ -575,8 +579,6 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b /* Zero the fdset, we'll set our fd prior to each invocation of select() */ FD_ZERO(&fdset); - tv.tv_sec = 10; - tv.tv_usec = 0; fdmax = bsock->fd + 1; /* Ensure that socket is non-blocking */ @@ -598,32 +600,36 @@ static inline int openssl_bsock_readwrite(BSOCK *bsock, char *ptr, int nbytes, b /* Handle errors */ switch (SSL_get_error(tls->openssl, nwritten)) { - case SSL_ERROR_NONE: - nleft -= nwritten; - if (nleft) { - ptr += nwritten; - } - break; - case SSL_ERROR_ZERO_RETURN: - /* TLS connection was cleanly shut down */ - openssl_post_errors(M_ERROR, _("TLS read/write failure.")); - goto cleanup; - case SSL_ERROR_WANT_READ: - /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); - /* Block until we can read */ - select(fdmax, &fdset, NULL, &fdset, &tv); - break; - case SSL_ERROR_WANT_WRITE: - /* If we timeout of a select, this will be unset */ - FD_SET((unsigned) bsock->fd, &fdset); - /* Block until we can write */ - select(fdmax, NULL, &fdset, &fdset, &tv); - break; - default: - /* Socket Error Occured */ - openssl_post_errors(M_ERROR, _("TLS read/write failure.")); - goto cleanup; + case SSL_ERROR_NONE: + nleft -= nwritten; + if (nleft) { + ptr += nwritten; + } + break; + case SSL_ERROR_ZERO_RETURN: + /* TLS connection was cleanly shut down */ + openssl_post_errors(M_ERROR, _("TLS read/write failure.")); + goto cleanup; + case SSL_ERROR_WANT_READ: + /* If we timeout of a select, this will be unset */ + FD_SET((unsigned) bsock->fd, &fdset); + tv.tv_sec = 10; + tv.tv_usec = 0; + /* Block until we can read */ + select(fdmax, &fdset, NULL, &fdset, &tv); + break; + case SSL_ERROR_WANT_WRITE: + /* If we timeout of a select, this will be unset */ + FD_SET((unsigned) bsock->fd, &fdset); + tv.tv_sec = 10; + tv.tv_usec = 0; + /* Block until we can write */ + select(fdmax, NULL, &fdset, &fdset, &tv); + break; + default: + /* Socket Error Occured */ + openssl_post_errors(M_ERROR, _("TLS read/write failure.")); + goto cleanup; } /* Everything done? */ diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 539f63ead5..fb9bc58f79 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -40,10 +40,20 @@ bool do_append_data(JCR *jcr) BSOCK *fd_sock = jcr->file_bsock; bool ok = true; DEV_RECORD rec; - DCR *dcr = jcr->dcr; - DEVICE *dev = dcr->dev; char buf1[100], buf2[100]; + DCR *dcr = jcr->dcr; + DEVICE *dev; + + if (!dcr) { + Jmsg0(jcr, M_FATAL, 0, _("DCR is NULL!!!\n")); + return false; + } + dev = dcr->dev; + if (!dev) { + Jmsg0(jcr, M_FATAL, 0, _("DEVICE is NULL!!!\n")); + return false; + } Dmsg1(100, "Start append data. res=%d\n", dev->reserved_device); @@ -53,7 +63,7 @@ bool do_append_data(JCR *jcr) if (!bnet_set_buffer_size(ds, dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) { set_jcr_job_status(jcr, JS_ErrorTerminated); - Jmsg(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n")); + Jmsg0(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n")); return false; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 78d0faa2ac..11206d2373 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.2" -#define BDATE "05 December 2005" -#define LSMDATE "05Dec05" +#define BDATE "06 December 2005" +#define LSMDATE "06Dec05" /* Debug flags */ #undef DEBUG