From 50d74002068ec5d9470c246412c004125bfb2e05 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 31 Mar 2003 18:49:56 +0000 Subject: [PATCH] Add verbose, Uname info, better Device error msg git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@406 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/platforms/redhat/.cvsignore | 5 ++++ bacula/scripts/bacula.png | Bin 2972 -> 2983 bytes bacula/src/cats/protos.h | 1 + bacula/src/cats/sql.c | 15 +++++++++-- bacula/src/cats/sql_update.c | 26 ++++++++++++++++++ bacula/src/console/console.c | 19 +++++++------ bacula/src/dird/backup.c | 6 ++--- bacula/src/dird/dird.c | 7 ++++- bacula/src/dird/fd_cmds.c | 27 ++++++++++++++----- bacula/src/dird/getmsg.c | 10 ++++--- bacula/src/dird/job.c | 7 +++-- bacula/src/dird/msgchan.c | 10 +++++-- bacula/src/dird/protos.h | 2 +- bacula/src/dird/restore.c | 8 +++--- bacula/src/dird/verify.c | 6 ++--- bacula/src/filed/filed.c | 7 ++++- bacula/src/filed/job.c | 42 ++++++++++++++++++----------- bacula/src/lib/message.c | 3 ++- bacula/src/lib/message.h | 1 + bacula/src/stored/bcopy.c | 1 - bacula/src/stored/bls.c | 1 - bacula/src/stored/bscan.c | 1 - bacula/src/stored/btape.c | 1 - bacula/src/stored/job.c | 13 +++++++-- bacula/src/stored/read_record.c | 1 - bacula/src/stored/stored.c | 7 ++++- bacula/src/tools/dbcheck.c | 1 - 27 files changed, 165 insertions(+), 63 deletions(-) diff --git a/bacula/platforms/redhat/.cvsignore b/bacula/platforms/redhat/.cvsignore index d79558d1ed..adc959fa0f 100644 --- a/bacula/platforms/redhat/.cvsignore +++ b/bacula/platforms/redhat/.cvsignore @@ -6,3 +6,8 @@ bacula.spec bacula.sqlite.rh8.spec bacula.client.rh8.spec bacula.mysql.rh8.spec +bacula.sqlite.rh7.spec +bacula.client.rh7.spec +bacula.mysql.rh7.spec + + diff --git a/bacula/scrip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aj8o(6ZDqEF%z^X-_;V&L&w@OvnWRB_TL}{ycZ?+&OV-7>Ea4Tw225C@YNfxeJ6rfZl4c zv$I31)xz^UEPu;S@bK{2_XK;TmlYm2D3MYU_&$!~ z;5g0^8k|5CO*eo)!joob3}jq0_(BkjjF8kcQmGVC6n~LO{PL4MFaQouih9YAMu!P< zlo4i7Ebt2OCQw4L!QmcdH&v-nTV17^ zNRSeOaeq|T=O!?VVu2&5bk}?KJ-WtMfoeL9^ZM(A$t14p;yBKU^&A)gEA{$;K?!u( zV8Qo!?ZE@4(rI1|Lq?;B^Bgoh9)StEPm9De#5z#RX3^h%8+U#l&v7se1M?INabN(z z@pA%!+STDGB4OLi(5>*YbjMx^4jQimHBDnLmw!W_o1?wFj5j%n>-+3Co7AdR%H{Ie z_5=@00|kJGGAg1w60=a}IYpQDLYG6tG&n@L{GO(oj$pMx(*)+qe1r^Uq%#E)dHe-5qxTT?lp;7iqln4&LY}zV8z{ z4xVX}uT~L>1e@2dW6#bKeEl^OySqqWKapVn(j@{-!|3dIrBdP6ty|o?ckjic!?84l zK$ntXR3_NDdKLZJH3Ch;YPZpwO51Uxj8)7 zWq*I4^7b~5*Vg*-l-NK4*oh+XS0UsOY8cXd;|;ZotrmNoVTP{jv@A4pEI*nzTG#U;5`OP4w32y)GVW8k@}~)oPVmt;VOHe%e?42JQj>_~|EcXL(s>M@Gm5 z0iNsP*!Hp4E|f}aZ*AfEKINSq0e`SvE{nOjIho01u-ffYNBgHqU!D~Gf3lFt$nzI2 zFj*>L**2@ItDL5LGYA>D2LNn3j+ieNCG|SK@AJ_|AN?AC_7};o;sLSD&Cbf)=qM{I zD=)errmsg, _("query %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg); + if (verbose) { + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + } return 0; } mdb->result = sql_store_result(mdb); @@ -106,6 +109,9 @@ InsertDB(char *file, int line, void *jcr, B_DB *mdb, char *cmd) if (sql_query(mdb, cmd)) { m_msg(file, line, &mdb->errmsg, _("insert %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_FATAL, 0, "%s", mdb->errmsg); + if (verbose) { + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + } return 0; } if (mdb->have_insert_id) { @@ -115,7 +121,7 @@ InsertDB(char *file, int line, void *jcr, B_DB *mdb, char *cmd) } if (mdb->num_rows != 1) { char ed1[30]; - m_msg(file, line, &mdb->errmsg, _("Insertion problem: affect_rows=%s\n"), + m_msg(file, line, &mdb->errmsg, _("Insertion problem: affected_rows=%s\n"), edit_uint64(mdb->num_rows, ed1)); return 0; } @@ -134,7 +140,9 @@ UpdateDB(char *file, int line, void *jcr, B_DB *mdb, char *cmd) if (sql_query(mdb, cmd)) { m_msg(file, line, &mdb->errmsg, _("update %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg); - j_msg(file, line, jcr, M_ERROR, 0, "%s\n", cmd); + if (verbose) { + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + } return 0; } mdb->num_rows = sql_affected_rows(mdb); @@ -160,6 +168,9 @@ DeleteDB(char *file, int line, void *jcr, B_DB *mdb, char *cmd) if (sql_query(mdb, cmd)) { m_msg(file, line, &mdb->errmsg, _("delete %s failed:\n%s\n"), cmd, sql_strerror(mdb)); j_msg(file, line, jcr, M_ERROR, 0, "%s", mdb->errmsg); + if (verbose) { + j_msg(file, line, jcr, M_INFO, 0, "%s\n", cmd); + } return -1; } mdb->changes++; diff --git a/bacula/src/cats/sql_update.c b/bacula/src/cats/sql_update.c index ff31234a5a..eea89901cc 100644 --- a/bacula/src/cats/sql_update.c +++ b/bacula/src/cats/sql_update.c @@ -150,6 +150,32 @@ VolSessionTime=%u, PoolId=%u, FileSetId=%u, JobTDate=%s WHERE JobId=%u", } +int +db_update_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr) +{ + int stat; + char ed1[50], ed2[50]; + + db_lock(mdb); + if (!db_create_client_record(jcr, mdb, cr)) { + db_unlock(mdb); + return 0; + } + + Mmsg(&mdb->cmd, +"UPDATE Client SET AutoPrune=%d,FileRetention=%s,JobRetention=%s," +"Uname='%s' WHERE Name='%s'", + cr->AutoPrune, + edit_uint64(cr->FileRetention, ed1), + edit_uint64(cr->JobRetention, ed2), + cr->Uname, cr->Name); + + stat = UPDATE_DB(jcr, mdb, mdb->cmd); + db_unlock(mdb); + return stat; +} + + int db_update_pool_record(void *jcr, B_DB *mdb, POOL_DBR *pr) { diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index c3341f71b8..1c6cf1d956 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -136,12 +136,12 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) while ((stat = bnet_recv(UA_sock)) >= 0) { if (at_prompt) { if (!stop) { - fprintf(output, "\n"); + putc('\n', output); } at_prompt = FALSE; } if (!stop) { - fprintf(output, "%s", UA_sock->msg); + fputs(UA_sock->msg, output); } } if (!stop) { @@ -179,15 +179,17 @@ int main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) { switch (ch) { case 'c': /* configuration file */ - if (configfile != NULL) + if (configfile != NULL) { free(configfile); + } configfile = bstrdup(optarg); break; case 'd': debug_level = atoi(optarg); - if (debug_level <= 0) + if (debug_level <= 0) { debug_level = 1; + } break; case 's': /* turn off signals */ @@ -233,7 +235,7 @@ int main(int argc, char *argv[]) } UnlockRes(); if (ndir == 0) { - Emsg1(M_ABORT, 0, "No Director resource defined in %s\n\ + Emsg1(M_ERROR_TERM, 0, "No Director resource defined in %s\n\ Without that I don't how to speak to the Director :-(\n", configfile); } @@ -286,7 +288,7 @@ try_again: } jcr.dir_bsock = UA_sock; if (!authenticate_director(&jcr, dir)) { - fprintf(stderr, "ERR: %s", UA_sock->msg); + fprintf(stderr, "ERR=%s", UA_sock->msg); terminate_console(0); return 1; } @@ -310,8 +312,9 @@ static void terminate_console(int sig) { static int already_here = FALSE; - if (already_here) /* avoid recursive temination problems */ + if (already_here) { /* avoid recursive temination problems */ exit(1); + } already_here = TRUE; exit(0); } @@ -387,7 +390,7 @@ get_cmd(FILE *input, char *prompt, BSOCK *sock, int sec) { int len; if (!stop) { - fprintf(output, prompt); + puts(prompt, output); fflush(output); } again: diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 937efbe6a7..b854ecd511 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -210,7 +210,7 @@ int do_backup(JCR *jcr) jcr->store->SDDport = jcr->store->SDport; } bnet_fsend(fd, storaddr, jcr->store->address, jcr->store->SDDport); - if (!response(fd, OKstore, "Storage")) { + if (!response(fd, OKstore, "Storage", 1)) { goto bail_out; } @@ -234,13 +234,13 @@ int do_backup(JCR *jcr) goto bail_out; } Dmsg1(120, ">filed: %s", fd->msg); - if (!response(fd, OKlevel, "Level")) { + if (!response(fd, OKlevel, "Level", 1)) { goto bail_out; } /* Send backup command */ bnet_fsend(fd, backupcmd); - if (!response(fd, OKbackup, "backup")) { + if (!response(fd, OKbackup, "backup", 1)) { goto bail_out; } diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 0bb4db06f3..a8ced2eae9 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -71,6 +71,7 @@ static void usage() " -s no signals\n" " -t test - read configuration and exit\n" " -u userid\n" +" -v verbose user messages\n" " -? print this message.\n" "\n")); @@ -98,7 +99,7 @@ int main (int argc, char *argv[]) daemon_start_time = time(NULL); memset(&last_job, 0, sizeof(last_job)); - while ((ch = getopt(argc, argv, "c:d:fg:r:stu:?")) != -1) { + while ((ch = getopt(argc, argv, "c:d:fg:r:stu:v?")) != -1) { switch (ch) { case 'c': /* specify config file */ if (configfile != NULL) { @@ -144,6 +145,10 @@ int main (int argc, char *argv[]) uid = optarg; break; + case 'v': /* verbose */ + verbose++; + break; + case '?': default: usage(); diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index f565c1360e..fed2e5ae56 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -100,10 +100,20 @@ int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } else { - /***** ***FIXME***** update Client Uname */ + CLIENT_DBR cr; + memset(&cr, 0, sizeof(cr)); + bstrncpy(cr.Name, jcr->client->hdr.name, sizeof(cr.Name)); + cr.AutoPrune = jcr->client->AutoPrune; + cr.FileRetention = jcr->client->FileRetention; + cr.JobRetention = jcr->client->JobRetention; + bstrncpy(cr.Uname, fd->msg+strlen(OKjob)+1, sizeof(cr.Uname)); + if (!db_update_client_record(jcr, jcr->db, &cr)) { + Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"), + db_strerror(jcr->db)); + } } } else { - Jmsg(jcr, M_FATAL, 0, _("num_names; j++) { p = ie->name_list[j]; - switch (*p++) { + switch (*p) { case '|': fd->msg = edit_job_codes(jcr, fd->msg, p, ""); bpipe = open_bpipe(fd->msg, 0, "r"); @@ -199,6 +209,9 @@ static int send_list(JCR *jcr, int list) } fclose(ffd); break; + case '\\': + p++; /* skip over \ */ + /* Note, fall through wanted */ default: if (ie->num_opts) { pm_strcpy(&fd->msg, ie->opts_list[0]->opts); @@ -206,7 +219,7 @@ static int send_list(JCR *jcr, int list) } else { pm_strcpy(&fd->msg, "0 "); } - pm_strcat(&fd->msg, ie->name_list[j]); + pm_strcat(&fd->msg, p); Dmsg1(100, "Inc/Exc name=%s\n", fd->msg); fd->msglen = strlen(fd->msg); if (!bnet_send(fd)) { @@ -219,10 +232,10 @@ static int send_list(JCR *jcr, int list) } bnet_sig(fd, BNET_EOD); /* end of data */ if (list == INC_LIST) { - if (!response(fd, OKinc, "Include")) { + if (!response(fd, OKinc, "Include", 1)) { goto bail_out; } - } else if (!response(fd, OKexc, "Exclude")) { + } else if (!response(fd, OKexc, "Exclude", 1)) { goto bail_out; } return 1; diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index 68b6a4a3df..0676e1d092 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -207,7 +207,7 @@ static char *find_msg_start(char *msg) * Returns: 0 on failure * 1 on success */ -int response(BSOCK *fd, char *resp, char *cmd) +int response(BSOCK *fd, char *resp, char *cmd, int prtmsg) { int n; @@ -219,11 +219,13 @@ int response(BSOCK *fd, char *resp, char *cmd) if (strcmp(fd->msg, resp) == 0) { return 1; } - Emsg3(M_FATAL, 0, _("msg); + if (prtmsg) { + Emsg3(M_FATAL, 0, _("FD gave bad response to %s command: wanted %s got: %s\n"), + cmd, resp, fd->msg); + } return 0; } - Emsg2(M_FATAL, 0, _("client->hdr.name); + bstrncpy(cr.Name, jcr->client->hdr.name, sizeof(cr.Name)); cr.AutoPrune = jcr->client->AutoPrune; cr.FileRetention = jcr->client->FileRetention; cr.JobRetention = jcr->client->JobRetention; @@ -395,7 +395,7 @@ int get_or_create_client_record(JCR *jcr) jcr->client_name = get_memory(strlen(jcr->client->hdr.name) + 1); strcpy(jcr->client_name, jcr->client->hdr.name); if (!db_create_client_record(jcr, jcr->db, &cr)) { - Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s"), + Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), db_strerror(jcr->db)); return 0; } @@ -514,6 +514,9 @@ void dird_free_jcr(JCR *jcr) if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); } + if (jcr->client_uname) { + free_pool_memory(jcr->client_uname); + } Dmsg0(200, "End dird free_jcr\n"); } diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 4b3c8f012d..cdaad12cff 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -156,8 +156,14 @@ int start_storage_daemon_job(JCR *jcr) device_name_len + media_type_len + pool_type_len + pool_name_len); bnet_fsend(sd, use_device, device_name, media_type, pool_name, pool_type); Dmsg1(110, ">stored: %s", sd->msg); - status = response(sd, OK_device, "Use Device"); - + status = response(sd, OK_device, "Use Device", 0); + if (!status) { + pm_strcpy(&pool_type, sd->msg); /* save message */ + Jmsg(jcr, M_FATAL, 0, _("\n" + " Storage daemon didn't accept Device \"%s\" because:\n %s"), + device_name, pool_type/* sd->msg */); + } + free_memory(device_name); free_memory(media_type); free_memory(pool_name); diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index ef70fcbe18..d4178c1cf8 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -71,7 +71,7 @@ extern int connect_to_storage_daemon(JCR *jcr, int retry_interval, extern int start_storage_daemon_job(JCR *jcr); extern int start_storage_daemon_message_thread(JCR *jcr); extern int32_t bget_msg(BSOCK *bs, int type); -extern int response(BSOCK *fd, char *resp, char *cmd); +extern int response(BSOCK *fd, char *resp, char *cmd, int prtmsg); extern void wait_for_storage_daemon_termination(JCR *jcr); /* newvol.c */ diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index a3a9dd686c..5ec84e2c1e 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -192,7 +192,7 @@ int do_restore(JCR *jcr) } bnet_fsend(fd, storaddr, jcr->store->address, jcr->store->SDDport); Dmsg1(6, "dird>filed: %s\n", fd->msg); - if (!response(fd, OKstore, "Storage")) { + if (!response(fd, OKstore, "Storage", 1)) { restore_cleanup(jcr, JS_ErrorTerminated); return 0; } @@ -219,7 +219,7 @@ int do_restore(JCR *jcr) rjr.VolSessionId, rjr.VolSessionTime, rjr.StartFile, rjr.EndFile, rjr.StartBlock, rjr.EndBlock); - if (!response(fd, OKsession, "Session")) { + if (!response(fd, OKsession, "Session", 1)) { restore_cleanup(jcr, JS_ErrorTerminated); return 0; } @@ -246,7 +246,7 @@ int do_restore(JCR *jcr) bnet_fsend(fd, restorecmd, replace, where); unbash_spaces(where); - if (!response(fd, OKrestore, "Restore")) { + if (!response(fd, OKrestore, "Restore", 1)) { restore_cleanup(jcr, JS_ErrorTerminated); return 0; } @@ -379,7 +379,7 @@ static int send_bootstrap_file(JCR *jcr) } bnet_sig(fd, BNET_EOD); fclose(bs); - if (!response(fd, OKbootstrap, "Bootstrap")) { + if (!response(fd, OKbootstrap, "Bootstrap", 1)) { set_jcr_job_status(jcr, JS_ErrorTerminated); return 0; } diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index f365a2796d..d42d91bfc9 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -214,7 +214,7 @@ int do_verify(JCR *jcr) jcr->store->SDDport = jcr->store->SDport; } bnet_fsend(fd, storaddr, jcr->store->address, jcr->store->SDDport); - if (!response(fd, OKstore, "Storage")) { + if (!response(fd, OKstore, "Storage", 1)) { goto bail_out; } /* @@ -226,7 +226,7 @@ int do_verify(JCR *jcr) jr.VolSessionId, jr.VolSessionTime, jr.StartFile, jr.EndFile, jr.StartBlock, jr.EndBlock); - if (!response(fd, OKsession, "Session")) { + if (!response(fd, OKsession, "Session", 1)) { goto bail_out; } level = "volume"; @@ -243,7 +243,7 @@ int do_verify(JCR *jcr) * Send verify command/level to File daemon */ bnet_fsend(fd, verifycmd, level); - if (!response(fd, OKverify, "Verify")) { + if (!response(fd, OKverify, "Verify", 1)) { goto bail_out; } diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index df71130740..7091cf40cb 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -67,6 +67,7 @@ static void usage() " -s no signals (for debugging)\n" " -t test configuration file and exit\n" " -u userid\n" +" -v verbose user messages\n" " -? print this message.\n" "\n")); exit(1); @@ -97,7 +98,7 @@ int main (int argc, char *argv[]) memset(&last_job, 0, sizeof(last_job)); - while ((ch = getopt(argc, argv, "c:d:fg:istu:?")) != -1) { + while ((ch = getopt(argc, argv, "c:d:fg:istu:v?")) != -1) { switch (ch) { case 'c': /* configuration file */ if (configfile != NULL) { @@ -136,6 +137,10 @@ int main (int argc, char *argv[]) uid = optarg; break; + case 'v': /* verbose */ + verbose++; + break; + case '?': default: usage(); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index a451120d30..99947a7f00 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -293,6 +293,25 @@ static int job_cmd(JCR *jcr) return bnet_fsend(dir, OKjob); } +#define INC_LIST 0 +#define EXC_LIST 1 + +static void add_fname_to_list(JCR *jcr, char *fname, int list) +{ + char *p; + if (list == INC_LIST) { + add_fname_to_include_list((FF_PKT *)jcr->ff, 1, fname); + } else { + /* Skip leading options -- currently ignored */ + for (p=fname; *p && *p != ' '; p++) + { } + /* Skip spaces */ + for ( ; *p && *p == ' '; p++) + { } + add_fname_to_exclude_list((FF_PKT *)jcr->ff, p); + } +} + /* * * Get list of files/directories to include from Director @@ -303,10 +322,10 @@ static int include_cmd(JCR *jcr) BSOCK *dir = jcr->dir_bsock; while (bnet_recv(dir) >= 0) { - dir->msg[dir->msglen] = 0; - strip_trailing_junk(dir->msg); - Dmsg1(010, "include file: %s\n", dir->msg); - add_fname_to_include_list((FF_PKT *)jcr->ff, 1, dir->msg); + dir->msg[dir->msglen] = 0; + strip_trailing_junk(dir->msg); + Dmsg1(010, "include file: %s\n", dir->msg); + add_fname_to_list(jcr, dir->msg, INC_LIST); } return bnet_fsend(dir, OKinc); @@ -319,19 +338,12 @@ static int include_cmd(JCR *jcr) static int exclude_cmd(JCR *jcr) { BSOCK *dir = jcr->dir_bsock; - char *p; while (bnet_recv(dir) >= 0) { - dir->msg[dir->msglen] = 0; - strip_trailing_junk(dir->msg); - /* Skip leading options -- currently ignored */ - for (p=dir->msg; *p && *p != ' '; p++) - { } - /* Skip spaces */ - for ( ; *p && *p == ' '; p++) - { } - add_fname_to_exclude_list((FF_PKT *)jcr->ff, p); - Dmsg1(110, "msg); + dir->msg[dir->msglen] = 0; + strip_trailing_junk(dir->msg); + add_fname_to_list(jcr, dir->msg, EXC_LIST); + Dmsg1(110, "msg); } return bnet_fsend(dir, OKexc); diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index d4caf14e03..762bdc255d 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -34,7 +34,8 @@ #define FULL_LOCATION 1 /* set for file:line in Debug messages */ char *working_directory = NULL; /* working directory path stored here */ -int debug_level = 5; /* debug level */ +int verbose = 0; /* increase User messages */ +int debug_level = 0; /* debug level */ time_t daemon_start_time = 0; /* Daemon start time */ char my_name[20]; /* daemon name is stored here */ diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index 4f8200e0b3..2d4ae0bef9 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -106,6 +106,7 @@ void e_msg(char *file, int line, int type, int level, char *fmt,...); void Jmsg(void *vjcr, int type, int level, char *fmt,...); extern int debug_level; +extern int verbose; extern char my_name[]; extern char *working_directory; extern time_t daemon_start_time; diff --git a/bacula/src/stored/bcopy.c b/bacula/src/stored/bcopy.c index 69dc4ee1f5..11b5521532 100644 --- a/bacula/src/stored/bcopy.c +++ b/bacula/src/stored/bcopy.c @@ -41,7 +41,6 @@ static JCR *in_jcr; /* input jcr */ static JCR *out_jcr; /* output jcr */ static BSR *bsr = NULL; static char *wd = "/tmp"; -static int verbose = 0; static int list_records = 0; static uint32_t records = 0; static uint32_t jobs = 0; diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index dfbd6fed5c..e0c8cfa929 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -39,7 +39,6 @@ static DEVICE *dev; static int dump_label = FALSE; static int list_blocks = FALSE; static int list_jobs = FALSE; -static int verbose = 0; static DEV_RECORD *rec; static DEV_BLOCK *block; static JCR *jcr; diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index c185e03cca..44b28490e4 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -81,7 +81,6 @@ static char *db_name = "bacula"; static char *db_user = "bacula"; static char *db_password = ""; static char *wd = NULL; -static int verbose = 0; static int update_db = 0; static int update_vol_info = 0; static int list_records = 0; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index ecb16f2506..bd1b27a04f 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -82,7 +82,6 @@ static uint64_t VolBytes; static time_t now; static double kbs; static long file_index; -static int verbose = 0; static int end_of_tape = 0; static uint32_t LastBlock = 0; static uint32_t eot_block; diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 432238ee7b..0481e25866 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -44,7 +44,7 @@ static char use_device[] = "use device=%s media_type=%s pool_name=%s pool_type=% /* Responses sent to Director daemon */ static char OKjob[] = "3000 OK Job SDid=%u SDtime=%u Authorization=%s\n"; static char OK_device[] = "3000 OK use device\n"; -static char NO_device[] = "3914 Device %s does not exist\n"; +static char NO_device[] = "3914 Device \"%s\" not in SD Device resources.\n"; static char BAD_use[] = "3913 Bad use command: %s\n"; static char BAD_job[] = "3915 Bad Job command: %s\n"; @@ -297,10 +297,19 @@ static int use_device_cmd(JCR *jcr) } } UnlockRes(); - Jmsg(jcr, M_FATAL, 0, _("Requested device %s not found. Cannot continue.\n"), + if (verbose) { + unbash_spaces(dir->msg); + Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), dir->msg); + } + Jmsg(jcr, M_FATAL, 0, _("\n" + " Device \"%s\" requested by Dir not found in SD Device resources.\n"), dev_name); bnet_fsend(dir, NO_device, dev_name); } else { + if (verbose) { + unbash_spaces(dir->msg); + Jmsg(jcr, M_INFO, 0, _("Failed command: %s\n"), dir->msg); + } Jmsg(jcr, M_FATAL, 0, _("storemsg); bnet_fsend(dir, BAD_use, dir->msg); } diff --git a/bacula/src/stored/read_record.c b/bacula/src/stored/read_record.c index 625e6b736e..7658784174 100644 --- a/bacula/src/stored/read_record.c +++ b/bacula/src/stored/read_record.c @@ -43,7 +43,6 @@ int read_records(JCR *jcr, DEVICE *dev, DEV_BLOCK *block; DEV_RECORD *rec; uint32_t record, num_files = 0; - int verbose = FALSE; int ok = TRUE; int done = FALSE; SESSION_LABEL sessrec; diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 3b253ca93c..615d941962 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -71,6 +71,7 @@ static void usage() " -s no signals (for debugging)\n" " -t test - read config and exit\n" " -u userid\n" +" -v verbose user messages\n" " -? print this message.\n" "\n")); exit(1); @@ -105,7 +106,7 @@ int main (int argc, char *argv[]) Emsg1(M_ABORT, 0, "Tape block size (%d) is not a power of 2\n", TAPE_BSIZE); } - while ((ch = getopt(argc, argv, "c:d:fg:stu:?")) != -1) { + while ((ch = getopt(argc, argv, "c:d:fg:stu:v?")) != -1) { switch (ch) { case 'c': /* configuration file */ if (configfile != NULL) { @@ -141,6 +142,10 @@ int main (int argc, char *argv[]) uid = optarg; break; + case 'v': /* verbose */ + verbose++; + break; + case '?': default: usage(); diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 923bc5a0cc..35c06a9ad2 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -52,7 +52,6 @@ typedef struct s_name_ctx { /* Global variables */ static int fix = FALSE; static int batch = FALSE; -static int verbose = FALSE; static B_DB *db; static ID_LIST id_list; static NAME_LIST name_list; -- 2.39.5