From: Kern Sibbald Date: Tue, 11 Nov 2003 21:55:36 +0000 (+0000) Subject: Fix segfault from double free or RestoreBootstrap; add L_NONE for restore and admin... X-Git-Tag: Release-7.0.0~9916 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9d8607727598a4ece6597153c42c11d9e4483033;p=bacula%2Fbacula Fix segfault from double free or RestoreBootstrap; add L_NONE for restore and admin jobs git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@805 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 6459cf9e2d..61ac538623 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -47,6 +47,15 @@ For 1.33 Testing/Documentation: For 1.33 +- Implement Console mtx commands. +- Look at 2Gb limit for SQLite. +- Implement 3 Pools for a Job: + Job { +   Name = ... +   Full Backup Pool = xxx +   Incremental Backup Pool = yyy +   Differential Backup Pool = zzz + } - Add a default DB password to MySQL. GRANT all privileges ON bacula.* TO bacula@localhost IDENTIFIED BY 'bacula_password'; diff --git a/bacula/scripts/btraceback.in b/bacula/scripts/btraceback.in index bc9d87c67b..79df59979d 100755 --- a/bacula/scripts/btraceback.in +++ b/bacula/scripts/btraceback.in @@ -9,7 +9,7 @@ # $2 = main pid of running program to be traced back. # gdb -quiet -batch -x @sbindir@/btraceback.gdb $1 $2 2>&1 \ - | @sbindir@/smtp -h @smtp_host@ -s "Bacula traceback" @dump_email@ + | @sbindir@/bsmtp -h @smtp_host@ -s "Bacula traceback" @dump_email@ # Below is some old code that did the traceback from a core # dump. However, for some odd reason, core dumps are not diff --git a/bacula/src/console/Makefile.in b/bacula/src/console/Makefile.in index 83958a8410..93661945dc 100644 --- a/bacula/src/console/Makefile.in +++ b/bacula/src/console/Makefile.in @@ -38,7 +38,7 @@ CONS_LDFLAGS=@CONS_LDFLAGS@ .c.o: $(CXX) $(DEFS) $(DEBUG) -c $(CPPFLAGS) $(CONS_INC) -I$(srcdir) -I$(basedir) $(DINCLUDE) $(CFLAGS) $< #------------------------------------------------------------------------- -all: Makefile console @STATIC_CONS@ +all: Makefile bconsole @STATIC_CONS@ @echo "==== Make of console is good ====" @echo " " @@ -58,19 +58,19 @@ Makefile: $(srcdir)/Makefile.in $(topdir)/config.status && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status clean: - @$(RMF) console core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3 - @$(RMF) static-console gmon.out + @$(RMF) console bconsole core core.* a.out *.o *.bak *~ *.intpro *.extpro 1 2 3 + @$(RMF) static-console static-bconsole gmon.out realclean: clean - @$(RMF) tags console.conf + @$(RMF) tags console.conf bconsole.conf distclean: realclean if test $(srcdir) = .; then $(MAKE) realclean; fi (cd $(srcdir); $(RMF) Makefile; $(RMF) -r CVS) install: all - $(INSTALL_SCRIPT) console $(DESTDIR)$(sbindir)/console - @srcconf=console.conf; \ + $(INSTALL_SCRIPT) bconsole $(DESTDIR)$(sbindir)/bconsole + @srcconf=bconsole.conf; \ if test -f ${DESTDIR}${sysconfdir}/$$srcconf; then \ destconf=$$srcconf.new; \ echo " ==> Found existing $$srcconf, installing new conf file as $$destconf"; \ @@ -81,8 +81,8 @@ install: all ${INSTALL_CONFIG} $$srcconf ${DESTDIR}${sysconfdir}/$$destconf uninstall: - (cd $(DESTDIR)$(sbindir); $(RMF) console) - (cd $(DESTDIR)$(sysconfdir); $(RMF) console.conf console.conf.new) + (cd $(DESTDIR)$(sbindir); $(RMF) bconsole) + (cd $(DESTDIR)$(sysconfdir); $(RMF) bconsole.conf bconsole.conf.new) diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index e29e192fa6..d98f8b9cd7 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -349,6 +349,8 @@ struct s_jl joblevels[] = { {"VolumeToCatalog", L_VERIFY_VOLUME_TO_CATALOG, JT_VERIFY}, {"DiskToCatalog", L_VERIFY_DISK_TO_CATALOG, JT_VERIFY}, {"Data", L_VERIFY_DATA, JT_VERIFY}, + {" ", L_NONE, JT_ADMIN}, + {" ", L_NONE, JT_RESTORE}, {NULL, 0} }; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index db7064e716..e84a6422cc 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -407,7 +407,15 @@ void set_jcr_defaults(JCR *jcr, JOB *job) { jcr->job = job; jcr->JobType = job->JobType; - jcr->JobLevel = job->level; + switch (jcr->JobType) { + case JT_ADMIN: + case JT_RESTORE: + jcr->JobLevel = L_NONE; + break; + default: + jcr->JobLevel = job->level; + break; + } jcr->JobPriority = job->Priority; jcr->store = job->storage; jcr->client = job->client; @@ -421,6 +429,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) jcr->messages = job->messages; if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); + jcr->RestoreBootstrap = NULL; } /* This can be overridden by Console program */ if (job->RestoreBootstrap) { @@ -437,7 +446,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) break; case JT_RESTORE: case JT_ADMIN: - jcr->JobLevel = L_FULL; + jcr->JobLevel = L_NONE; break; default: break; diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 73e5c6b8e8..6dfb15ef14 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -73,7 +73,7 @@ int do_restore(JCR *jcr) } memset(&rjr, 0, sizeof(rjr)); - jcr->jr.Level = 'F'; /* Full restore */ + jcr->jr.Level = L_FULL; /* Full restore */ jcr->jr.StartTime = jcr->start_time; if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db)); diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 9a041a5ab7..c9aaede5ba 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -406,6 +406,7 @@ static void prt_runhdr(UAContext *ua) static void prt_runtime(UAContext *ua, JOB *job, int level, time_t runtime, POOL *pool) { char dt[MAX_TIME_LENGTH]; + char *level_ptr; bool ok = false; bool close_db = false; JCR *jcr = ua->jcr; @@ -425,9 +426,17 @@ static void prt_runtime(UAContext *ua, JOB *job, int level, time_t runtime, POOL } } bstrftime(dt, sizeof(dt), runtime); + switch (job->JobType) { + case JT_ADMIN: + case JT_RESTORE: + level_ptr = " "; + break; + default: + level_ptr = level_to_str(level); + break; + } bsendmsg(ua, _("%-14s %-8s %-18s %-18s %s\n"), - level_to_str(level), job_type_to_str(job->JobType), dt, job->hdr.name, - mr.VolumeName); + level_ptr, job_type_to_str(job->JobType), dt, job->hdr.name, mr.VolumeName); if (close_db) { db_close_database(jcr, jcr->db); } diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 88217eeb26..0d6a981882 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -43,6 +43,7 @@ #define L_VERIFY_DISK_TO_CATALOG 'd' /* verify Disk attributes to catalog */ #define L_VERIFY_DATA 'A' /* verify data on volume */ #define L_BASE 'B' /* Base level job */ +#define L_NONE ' ' /* None, for Restore and Admin */ /* Job Types. These are stored in the DB */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index ece158bd71..ad80a10cef 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -111,23 +111,24 @@ static void free_common_jcr(JCR *jcr) { /* Keep some statistics */ switch (jcr->JobType) { - case JT_BACKUP: - case JT_VERIFY: - case JT_RESTORE: - last_job.NumJobs++; - last_job.JobType = jcr->JobType; - last_job.JobId = jcr->JobId; - last_job.VolSessionId = jcr->VolSessionId; - last_job.VolSessionTime = jcr->VolSessionTime; - strcpy(last_job.Job, jcr->Job); - last_job.JobFiles = jcr->JobFiles; - last_job.JobBytes = jcr->JobBytes; - last_job.JobStatus = jcr->JobStatus; - last_job.start_time = jcr->start_time; - last_job.end_time = time(NULL); - break; - default: - break; + case JT_BACKUP: + case JT_VERIFY: + case JT_RESTORE: + case JT_ADMIN: + last_job.NumJobs++; + last_job.JobType = jcr->JobType; + last_job.JobId = jcr->JobId; + last_job.VolSessionId = jcr->VolSessionId; + last_job.VolSessionTime = jcr->VolSessionTime; + bstrncpy(last_job.Job, jcr->Job, sizeof(last_job.Job)); + last_job.JobFiles = jcr->JobFiles; + last_job.JobBytes = jcr->JobBytes; + last_job.JobStatus = jcr->JobStatus; + last_job.start_time = jcr->start_time; + last_job.end_time = time(NULL); + break; + default: + break; } pthread_mutex_destroy(&jcr->mutex); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 0f03113fec..8f91db6c67 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -315,6 +315,9 @@ char *job_level_to_str(int level) case L_VERIFY_DATA: str = _("Verify Data"); break; + case L_NONE: + str = " "; + break; default: str = _("Unknown Job Level"); break;