From 3fbde5d1ad3b15f53a7da32cc77a7d64b6d839d6 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 24 Aug 2006 09:48:11 +0000 Subject: [PATCH] kes Add Media.Enabled flag to client backups for dotcmds.c kes Enforce Media.Enabled=1 for a current restore to work. kes Require restore case 3 to have sqlquery permission to work. kes Remove obsolete del_MAC sql command. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3359 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/ReleaseNotes | 2 +- bacula/kernstodo | 4 ++++ bacula/scripts/bacula-ctl-fd.in | 2 +- bacula/src/cats/sql_cmds.c | 9 ++++++--- bacula/src/dird/ua_dotcmds.c | 4 ++-- bacula/src/dird/ua_restore.c | 4 ++++ bacula/src/dird/ua_update.c | 10 +++++----- bacula/src/dird/verify.c | 10 +++++----- bacula/src/stored/bscan.c | 1 + bacula/src/version.h | 6 +++--- bacula/src/win32/README.mingw32 | 8 ++++++++ bacula/src/win32/cats/bacula_cats.def | 1 - bacula/technotes-1.39 | 7 +++++++ 13 files changed, 47 insertions(+), 21 deletions(-) diff --git a/bacula/ReleaseNotes b/bacula/ReleaseNotes index dc41a78054..de6d1fa628 100644 --- a/bacula/ReleaseNotes +++ b/bacula/ReleaseNotes @@ -18,7 +18,7 @@ New Features in 1.39.20: - Implement mount command for autochanger Fixes for 1.39.20: -- Writing DVDs should work much better thans to Richard Mortimer. +- Writing DVDs should work much better thanks to Richard Mortimer. - Fix bug #462 incorrect error message printed when client script called from File= was not found. - Fix bug #558 (waiting for feedback) where Bacula needs too much time to diff --git a/bacula/kernstodo b/bacula/kernstodo index 4c5af74dd0..948d44122d 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -33,6 +33,10 @@ Document: Priority: For 1.39: +- Restricted consoles start in the Default catalog even if it + is not permitted. +- Make sure that the restore options don't permit "seeing" other + Client's job data. - Implement Python event for backing up/restoring a file. - Fix wx-console scanning problem with commas in names. - Change dbcheck to tell users to use native tools for fixing diff --git a/bacula/scripts/bacula-ctl-fd.in b/bacula/scripts/bacula-ctl-fd.in index f3552c32d1..539a04da3a 100644 --- a/bacula/scripts/bacula-ctl-fd.in +++ b/bacula/scripts/bacula-ctl-fd.in @@ -226,7 +226,7 @@ case "$1" in ;; status) - [ -x ${BACFDBIN}/bacula-fd ] && status ${BACFDBIN}/bacula-fd ${FD_PORT} + [ -x ${BACFDBIN}/bacula-fd ] && status ${BACFDBIN}/bacula-fd ${FD_PORT} ;; *) diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index e4e273025a..c90ae3ac28 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -24,13 +24,13 @@ #include "bacula.h" #include "cats.h" -/* For ua_cmds.c */ +/* For ua_update.c */ const char *list_pool = "SELECT * FROM Pool WHERE PoolId=%s"; /* For ua_dotcmds.c */ const char *client_backups = "SELECT DISTINCT Job.JobId,Client.Name as Client,Level,StartTime," - "JobFiles,JobBytes,VolumeName,MediaType,FileSet" + "JobFiles,JobBytes,VolumeName,MediaType,FileSet,Media.Enabled as Enabled" " FROM Client,Job,JobMedia,Media,FileSet" " WHERE Client.Name='%s'" " AND FileSet='%s'" @@ -47,7 +47,6 @@ const char *del_File = "DELETE FROM File WHERE JobId=%s"; const char *upd_Purged = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%s"; const char *cnt_DelCand = "SELECT count(*) FROM DelCandidates"; const char *del_Job = "DELETE FROM Job WHERE JobId=%s"; -const char *del_MAC = "DELETE FROM MAC WHERE JobId=%s"; const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%s"; const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%s"; const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%s"; @@ -261,6 +260,7 @@ const char *uar_last_full = "AND Job.StartTime<'%s' " "AND Level='F' AND JobStatus='T' AND Type='B' " "AND JobMedia.JobId=Job.JobId " + "AND Media.Enabled=1 " "AND JobMedia.MediaId=Media.MediaId " "AND Job.FileSetId=FileSet.FileSetId " "AND FileSet.FileSet='%s' " @@ -273,6 +273,7 @@ const char *uar_full = "StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime " "FROM temp1,Job,JobMedia,Media WHERE temp1.JobId=Job.JobId " "AND Level='F' AND JobStatus='T' AND Type='B' " + "AND Media.Enabled=1 " "AND JobMedia.JobId=Job.JobId " "AND JobMedia.MediaId=Media.MediaId"; @@ -285,6 +286,7 @@ const char *uar_dif = "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' " "AND Job.ClientId=%s " "AND JobMedia.JobId=Job.JobId " + "AND Media.Enabled=1 " "AND JobMedia.MediaId=Media.MediaId " "AND Job.Level='D' AND JobStatus='T' AND Type='B' " "AND Job.FileSetId=FileSet.FileSetId " @@ -300,6 +302,7 @@ const char *uar_inc = "FROM Job,JobMedia,Media,FileSet " "WHERE Job.JobTDate>%s AND Job.StartTime<'%s' " "AND Job.ClientId=%s " + "AND Media.Enabled=1 " "AND JobMedia.JobId=Job.JobId " "AND JobMedia.MediaId=Media.MediaId " "AND Job.Level='I' AND JobStatus='T' AND Type='B' " diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 4200031817..b172e679e4 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -220,8 +220,8 @@ static int typescmd(UAContext *ua, const char *cmd) static int client_backups_handler(void *ctx, int num_field, char **row) { UAContext *ua = (UAContext *)ctx; - bsendmsg(ua, "| %s | %s | %s | %s | %s | %s | %s |\n", - row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]); + bsendmsg(ua, "| %s | %s | %s | %s | %s | %s | %s | %s |\n", + row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]); return 0; } diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 0ada4cf794..07f00a0c3d 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -414,6 +414,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) case -1: /* error or cancel */ return 0; case 0: /* list last 20 Jobs run */ + /* ***FIXME*** restrict clients on restricted console */ gui_save = ua->jcr->gui; ua->jcr->gui = true; db_list_sql_query(ua->jcr, ua->db, uar_list_jobs, prtit, ua, 1, HORZ_LIST); @@ -445,6 +446,9 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx) pm_strcpy(rx->JobIds, ua->cmd); break; case 3: /* Enter an SQL list command */ + if (!acl_access_ok(ua, Command_ACL, NT_("sqlquery"), 8)) { + return 0; + } if (!get_cmd(ua, _("Enter SQL list command: "))) { return 0; } diff --git a/bacula/src/dird/ua_update.c b/bacula/src/dird/ua_update.c index c3191e377f..aa5d80b598 100644 --- a/bacula/src/dird/ua_update.c +++ b/bacula/src/dird/ua_update.c @@ -32,7 +32,7 @@ void update_slots(UAContext *ua); /* Forward referenced functions */ static int update_volume(UAContext *ua); -static int update_pool(UAContext *ua); +static bool update_pool(UAContext *ua); /* * Update a Pool Record in the database. @@ -676,7 +676,7 @@ static int update_volume(UAContext *ua) /* * Update pool record -- pull info from current POOL resource */ -static int update_pool(UAContext *ua) +static bool update_pool(UAContext *ua) { POOL_DBR pr; int id; @@ -686,13 +686,13 @@ static int update_pool(UAContext *ua) pool = get_pool_resource(ua); if (!pool) { - return 0; + return false; } memset(&pr, 0, sizeof(pr)); bstrncpy(pr.Name, pool->hdr.name, sizeof(pr.Name)); if (!get_pool_dbr(ua, &pr)) { - return 0; + return false; } set_pooldbr_from_poolres(&pr, pool, POOL_OP_UPDATE); /* update */ @@ -707,5 +707,5 @@ static int update_pool(UAContext *ua) db_list_sql_query(ua->jcr, ua->db, query, prtit, ua, 1, HORZ_LIST); free_pool_memory(query); bsendmsg(ua, _("Pool DB record updated from resource.\n")); - return 1; + return true; } diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index a83c1b1cba..a407547446 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -711,11 +711,11 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId) */ jcr->fn_printed = false; bsnprintf(buf, sizeof(buf), -"SELECT Path.Path,Filename.Name FROM File,Path,Filename " -"WHERE File.JobId=%d " -"AND File.MarkId!=%d AND File.PathId=Path.PathId " -"AND File.FilenameId=Filename.FilenameId", - JobId, jcr->JobId); + "SELECT Path.Path,Filename.Name FROM File,Path,Filename " + "WHERE File.JobId=%d " + "AND File.MarkId!=%d AND File.PathId=Path.PathId " + "AND File.FilenameId=Filename.FilenameId", + JobId, jcr->JobId); /* missing_handler is called for each file found */ db_sql_query(jcr->db, buf, missing_handler, (void *)jcr); if (jcr->fn_printed) { diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index eb7856fdcc..48602c216e 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -844,6 +844,7 @@ static int create_media_record(B_DB *db, MEDIA_DBR *mr, VOLUME_LABEL *vl) /* We mark Vols as Archive to keep them from being re-written */ bstrncpy(mr->VolStatus, "Archive", sizeof(mr->VolStatus)); mr->VolRetention = 365 * 3600 * 24; /* 1 year */ + mr->Enabled = 1; if (vl->VerNum >= 11) { mr->FirstWritten = btime_to_utime(vl->write_btime); mr->LabelDate = btime_to_utime(vl->label_btime); diff --git a/bacula/src/version.h b/bacula/src/version.h index 971a25709d..99683cf5a6 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "1.39.20" -#define BDATE "22 August 2006" -#define LSMDATE "22Aug06" +#define VERSION "1.39.21" +#define BDATE "23 August 2006" +#define LSMDATE "23Aug06" #define BYEAR "2006" /* year for copyright messages in progs */ /* Debug flags */ diff --git a/bacula/src/win32/README.mingw32 b/bacula/src/win32/README.mingw32 index f444e4b7e6..2c1ded4d8f 100644 --- a/bacula/src/win32/README.mingw32 +++ b/bacula/src/win32/README.mingw32 @@ -127,6 +127,14 @@ in question is for openssl): NOTE: The -C means clobber. Any local changes to the source code in the depkgs-mingw32/src directory will be lost. The source will be reextracted from the archive and the current patches will be applied. + +If you add a new subroutine or global symbol in the CATS library +================================================================= +Edit src/win32/cats/bacula_cats.def and update it appropriately. +The output of a link will tell you the C++ mangled subroutine name +to add, and for global symbols, it is rather easy. See the file. + + Structure of the new Win32 build environment ============================================ diff --git a/bacula/src/win32/cats/bacula_cats.def b/bacula/src/win32/cats/bacula_cats.def index b3a1a57a4f..c7b741026d 100644 --- a/bacula/src/win32/cats/bacula_cats.def +++ b/bacula/src/win32/cats/bacula_cats.def @@ -114,7 +114,6 @@ del_File DATA ;cnt_File DATA cnt_DelCand DATA del_Job DATA -del_MAC DATA del_JobMedia DATA cnt_JobMedia DATA sel_JobMedia DATA diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index a5284c28ae..550fdb24fa 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,13 @@ Technical notes on version 1.39 General: +24Aug06 +kes Add Media.Enabled flag to client backups for dotcmds.c +kes Enforce Media.Enabled=1 for a current restore to work. +kes Require restore case 3 to have sqlquery permission to work. +kes Remove obsolete del_MAC sql command. + +Version 1.39.20 beta released: 22Aug06 kes Correct missing Client table reference in SQL pointed out by Marc. -- 2.39.5