From e5dc3c1823a1ff704b6d05bd2b888001c1d7ec2c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 27 Sep 2007 08:10:23 +0000 Subject: [PATCH] Add const char where needed (more to do). Remove temp debug code. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5670 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/job.c | 2 +- bacula/src/dird/protos.h | 8 ++++---- bacula/src/dird/ua_acl.c | 22 +++++++++++----------- bacula/src/dird/ua_run.c | 6 +++--- bacula/src/dird/ua_select.c | 4 ++-- bacula/src/filed/authenticate.c | 11 +---------- bacula/src/stored/authenticate.c | 5 +---- bacula/src/stored/dev.c | 2 +- bacula/src/stored/job.c | 13 ------------- bacula/technotes-2.3 | 2 ++ 10 files changed, 26 insertions(+), 49 deletions(-) diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 68a0f0c09e..3b90108b35 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -1212,7 +1212,7 @@ bool create_restore_bootstrap_file(JCR *jcr) UAContext *ua; memset(&rx, 0, sizeof(rx)); rx.bsr = new_bsr(); - rx.JobIds = ""; + rx.JobIds = (char *)""; rx.bsr->JobId = jcr->previous_jr.JobId; ua = new_ua_context(jcr); complete_bsr(ua, rx.bsr); diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index c0ad0d5e46..30e627448d 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -169,8 +169,8 @@ extern void restore_cleanup(JCR *jcr, int TermCode); /* ua_acl.c */ -bool acl_access_ok(UAContext *ua, int acl, char *item); -bool acl_access_ok(UAContext *ua, int acl, char *item, int len); +bool acl_access_ok(UAContext *ua, int acl, const char *item); +bool acl_access_ok(UAContext *ua, int acl, const char *item, int len); /* ua_cmds.c */ int do_a_command(UAContext *ua, const char *cmd); @@ -231,7 +231,7 @@ CLIENT *select_client_resource(UAContext *ua); FILESET *select_fileset_resource(UAContext *ua); int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); -bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk="pool"); +bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk="pool"); bool select_client_dbr(UAContext *ua, CLIENT_DBR *cr); void start_prompt(UAContext *ua, const char *msg); @@ -242,7 +242,7 @@ STORE *get_storage_resource(UAContext *ua, bool use_default); int get_storage_drive(UAContext *ua, STORE *store); int get_storage_slot(UAContext *ua, STORE *store); int get_media_type(UAContext *ua, char *MediaType, int max_media); -bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk="pool"); +bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk="pool"); bool get_client_dbr(UAContext *ua, CLIENT_DBR *cr); POOL *get_pool_resource(UAContext *ua); POOL *select_pool_resource(UAContext *ua); diff --git a/bacula/src/dird/ua_acl.c b/bacula/src/dird/ua_acl.c index 4d4b37faaf..a8873123a2 100644 --- a/bacula/src/dird/ua_acl.c +++ b/bacula/src/dird/ua_acl.c @@ -1,15 +1,7 @@ -/* - * - * Bacula Director -- User Agent Access Control List (ACL) handling - * - * Kern Sibbald, January MMIV - * - * Version $Id$ - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2004-2006 Free Software Foundation Europe e.V. + Copyright (C) 2004-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -33,6 +25,14 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * + * Bacula Director -- User Agent Access Control List (ACL) handling + * + * Kern Sibbald, January MMIV + * + * Version $Id$ + */ #include "bacula.h" #include "dird.h" @@ -40,14 +40,14 @@ /* * Check if access is permitted to item in acl */ -bool acl_access_ok(UAContext *ua, int acl, char *item) +bool acl_access_ok(UAContext *ua, int acl, const char *item) { return acl_access_ok(ua, acl, item, strlen(item)); } /* This version expects the length of the item which we must check. */ -bool acl_access_ok(UAContext *ua, int acl, char *item, int len) +bool acl_access_ok(UAContext *ua, int acl, const char *item, int len) { /* If no console resource => default console and all is permitted */ diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index ece3e36cb7..b6ebac7121 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -46,7 +46,7 @@ public: char *when, *verify_job_name, *catalog_name; char *previous_job_name; char *since; - char *verify_list; + const char *verify_list; JOB *job; JOB *verify_job; JOB *previous_job; @@ -69,7 +69,7 @@ public: /* Forward referenced subroutines */ static void select_job_level(UAContext *ua, JCR *jcr); static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, - char *verify_list, char *jid, const char *replace, + const char *verify_list, char *jid, const char *replace, char *client_name); static void select_where_regexp(UAContext *ua, JCR *jcr); static bool scan_command_line_arguments(UAContext *ua, run_ctx &rc); @@ -659,7 +659,7 @@ static void select_job_level(UAContext *ua, JCR *jcr) return; } -static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, char *verify_list, +static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char *verify_list, char *jid, const char *replace, char *client_name) { Dmsg1(800, "JobType=%c\n", jcr->JobType); diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 416073a5c2..5a684eb40a 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -443,7 +443,7 @@ bool select_client_dbr(UAContext *ua, CLIENT_DBR *cr) * returns: false on error * true on success and fills in POOL_DBR */ -bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) +bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk) { if (pr->Name[0]) { /* If name already supplied */ if (db_get_pool_record(ua->jcr, ua->db, pr) && @@ -462,7 +462,7 @@ bool get_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) * Select a Pool record from catalog * argk can be pool, recyclepool, scratchpool etc.. */ -bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, char *argk) +bool select_pool_dbr(UAContext *ua, POOL_DBR *pr, const char *argk) { POOL_DBR opr; char name[MAX_NAME_LENGTH]; diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index 6d12c6cca3..12de1816ce 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -37,7 +37,7 @@ #include "bacula.h" #include "filed.h" -const int dbglvl = 3; +const int dbglvl = 50; static char OK_hello[] = "2000 OK Hello\n"; static char Dir_sorry[] = "2999 No go\n"; @@ -227,9 +227,6 @@ int authenticate_storagedaemon(JCR *jcr) } /* Respond to SD challenge */ - if (debug_level == 3) { - Dmsg1(000, "sd_auth_key=%s\n", jcr->sd_auth_key); - } auth_success = cram_md5_respond(sd, jcr->sd_auth_key, &tls_remote_need, &compatible); if (job_canceled(jcr)) { auth_success = false; /* force quick exit */ @@ -274,16 +271,10 @@ int authenticate_storagedaemon(JCR *jcr) goto auth_fatal; } } - if (debug_level == 3) { - Dmsg0(000, "FD->SD Auth OK\n"); - } auth_fatal: /* Destroy session key */ memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); - if (debug_level == 3) { - Dmsg0(000, "zap sd_auth_key\n"); - } stop_bsock_timer(tid); /* Single thread all failures to avoid DOS */ if (!auth_success) { diff --git a/bacula/src/stored/authenticate.c b/bacula/src/stored/authenticate.c index 0b6ad505a1..49f6551fc5 100644 --- a/bacula/src/stored/authenticate.c +++ b/bacula/src/stored/authenticate.c @@ -38,7 +38,7 @@ #include "bacula.h" #include "stored.h" -const int dbglvl = 3; +const int dbglvl = 50; static char Dir_sorry[] = "3999 No go\n"; static char OK_hello[] = "3000 OK Hello\n"; @@ -211,9 +211,6 @@ int authenticate_filed(JCR *jcr) /* Timeout Hello after 5 mins */ btimer_t *tid = start_bsock_timer(fd, AUTH_TIMEOUT); /* Challenge FD */ - if (debug_level == 3) { - Pmsg1(000, "sd_auth_key=%s\n", jcr->sd_auth_key); - } auth_success = cram_md5_challenge(fd, jcr->sd_auth_key, tls_local_need, compatible); if (auth_success) { /* Respond to his challenge */ diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index 50b4dd4a63..3b2ff04006 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -2468,7 +2468,7 @@ static bool dev_get_os_pos(DEVICE *dev, struct mtget *mt_stat) mt_stat->mt_fileno >= 0; } -static char *modes[] = { +static const char *modes[] = { "CREATE_READ_WRITE", "OPEN_READ_WRITE", "OPEN_READ_ONLY", diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 3da8c386d5..a95b072a75 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -138,9 +138,6 @@ bool job_cmd(JCR *jcr) bsnprintf(seed, sizeof(seed), "%p%d", jcr, JobId); make_session_key(auth_key, seed, 1); dir->fsend(OKjob, jcr->VolSessionId, jcr->VolSessionTime, auth_key); - if (debug_level == 3) { - Dmsg2(000, ">dird jid=%u: %s", (uint32_t)jcr->JobId, dir->msg); - } Dmsg2(100, ">dird jid=%u: %s", (uint32_t)jcr->JobId, dir->msg); jcr->sd_auth_key = bstrdup(auth_key); memset(auth_key, 0, sizeof(auth_key)); @@ -196,9 +193,6 @@ bool run_cmd(JCR *jcr) } V(mutex); - if (debug_level == 3) { - Dmsg0(000, "Zap sd_auth_key\n"); - } memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); if (jcr->authenticated && !job_canceled(jcr)) { @@ -238,16 +232,9 @@ void handle_filed_connection(BSOCK *fd, char *job_name) /* * Authenticate the File daemon */ - if (debug_level == 3) { - Dmsg2(000, "jid=%u sd_auth_key=%s\n", (uint32_t)jcr->JobId, jcr->sd_auth_key); - } if (jcr->authenticated || !authenticate_filed(jcr)) { Dmsg1(100, "Authentication failed Job %s\n", jcr->Job); Jmsg(jcr, M_FATAL, 0, _("Unable to authenticate File daemon\n")); - if (debug_level == 3) { - Dmsg2(000, "**** Authentication failed jid=%u key=%s\n", - (uint32_t)jcr->JobId, jcr->sd_auth_key); - } } else { jcr->authenticated = true; Dmsg2(110, "OK Authentication jid=%u Job %s\n", (uint32_t)jcr->JobId, jcr->Job); diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 2aec7b22c4..c82b284a76 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,8 @@ Technical notes on version 2.3 General: +27Sep07 +kes Add const char where needed (more to do). Remove temp debug code. 26Sep07 kes Setup SQLite busy handler before doing queries. kes Don't overwrite error message in check_tables_version. -- 2.39.5