From 7d4f5a1a1443fac1bd99c109268e171108fd232e Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 5 May 2003 16:07:06 +0000 Subject: [PATCH] Fix Win32 crash git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@493 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/filed/backup.c | 3 + bacula/src/filed/heartbeat.c | 5 +- bacula/src/filed/job.c | 4 +- bacula/src/filed/status.c | 4 + bacula/src/filed/win32/winbacula.h | 3 + bacula/src/filed/win32/winmain.cpp | 2 +- bacula/src/filed/win32/winservice.cpp | 99 +++---------------- bacula/src/findlib/Makefile.in | 4 +- bacula/src/findlib/attribs.c | 104 -------------------- bacula/src/findlib/find.h | 136 +++++++++++++------------- bacula/src/findlib/find_one.c | 4 +- bacula/src/findlib/protos.h | 39 ++++---- bacula/src/lib/bnet.c | 44 ++++----- bacula/src/lib/jcr.c | 14 +-- bacula/src/lib/message.c | 48 +++++---- bacula/src/lib/message.h | 102 +++++++++---------- bacula/src/lib/watchdog.c | 3 +- bacula/src/version.h | 5 + 18 files changed, 243 insertions(+), 380 deletions(-) diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 8403b8331a..637418524d 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -51,6 +51,8 @@ int blast_data_to_storage_daemon(JCR *jcr, char *addr) sd = jcr->store_bsock; + get_backup_privileges(jcr, 0); + set_jcr_job_status(jcr, JS_Running); Dmsg1(110, "bfiled: opened data connection %d to stored\n", sd->fd); @@ -94,6 +96,7 @@ int blast_data_to_storage_daemon(JCR *jcr, char *addr) free_pool_memory(jcr->compress_buf); jcr->compress_buf = NULL; } + Dmsg1(110, "end blast_data stat=%d\n", stat); return stat; } diff --git a/bacula/src/filed/heartbeat.c b/bacula/src/filed/heartbeat.c index 409b4013af..2cc907f7ab 100644 --- a/bacula/src/filed/heartbeat.c +++ b/bacula/src/filed/heartbeat.c @@ -67,7 +67,7 @@ static void *sd_heartbeat_thread(void *arg) } if (n == 1) { /* input waiting */ bnet_recv(sd); /* read it -- probably heartbeat from sd */ -/* Dmsg1(000, "Got %d from SD\n", sd->msglen); */ + Dmsg1(100, "Got %d from SD\n", sd->msglen); } } bnet_close(sd); @@ -95,7 +95,10 @@ void stop_heartbeat_monitor(JCR *jcr) /* Wait for heartbeat thread to stop */ while (jcr->hb_bsock) { +#ifndef HAVE_CYGWIN + /* Naturally, Cygwin 1.3.20 craps out on the following */ pthread_kill(jcr->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ +#endif bmicrosleep(0, 500); } } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 37e0d4b098..398feede19 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -185,7 +185,7 @@ void *handle_client_request(void *dirp) found = TRUE; /* indicate command found */ if (!cmds[i].func(jcr)) { /* do command */ quit = TRUE; /* error or fully terminated, get out */ - Pmsg0(20, "Command error\n"); + Pmsg0(20, "Command error or Job done.\n"); } break; } @@ -290,7 +290,7 @@ static int job_cmd(JCR *jcr) jcr->sd_auth_key = bstrdup(sd_auth_key); free_pool_memory(sd_auth_key); if (jcr->use_win_backup_api) { - SetServicePrivileges(jcr); + get_backup_privileges(jcr, 1 /* ignore_errors */); } Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key); return bnet_fsend(dir, OKjob); diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 6bc287862b..e0c1054de6 100755 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -66,6 +66,7 @@ static void do_status(void sendit(char *msg, int len, void *sarg), void *arg) termstat); sendit(msg, len, arg); } + Dmsg0(200, "Begin status jcr loop.\n"); lock_jcr_chain(); for (njcr=NULL; (njcr=get_next_jcr(njcr)); ) { bstrftime(dt, sizeof(dt), njcr->start_time); @@ -115,6 +116,7 @@ static void do_status(void sendit(char *msg, int len, void *sarg), void *arg) free_locked_jcr(njcr); } unlock_jcr_chain(); + Dmsg0(200, "Begin status jcr loop.\n"); if (!found) { len = Mmsg(&msg, _("No jobs running.\n")); sendit(msg, len, arg); @@ -204,6 +206,7 @@ char *bac_status(int stat) break; } } + Dmsg0(200, "Begin bac_status jcr loop.\n"); lock_jcr_chain(); for (njcr=NULL; (njcr=get_next_jcr(njcr)); ) { if (njcr->JobId != 0) { @@ -215,6 +218,7 @@ char *bac_status(int stat) free_locked_jcr(njcr); } unlock_jcr_chain(); + Dmsg0(200, "End bac_status jcr loop.\n"); strcpy(buf, termstat); return buf; } diff --git a/bacula/src/filed/win32/winbacula.h b/bacula/src/filed/win32/winbacula.h index df804f5aeb..a9a83dfbb3 100755 --- a/bacula/src/filed/win32/winbacula.h +++ b/bacula/src/filed/win32/winbacula.h @@ -74,3 +74,6 @@ const char BaculaShowHelp[] = "/help"; // Usage string const char BaculaUsageText[] = "Bacula [/run] [/kill] [/install] [/remove] [/about] [/status] [/events]\n"; + +void LogErrorMsg(char *msg, char *fname, int lineno); +#define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__) diff --git a/bacula/src/filed/win32/winmain.cpp b/bacula/src/filed/win32/winmain.cpp index 4faaaea6d3..78eb3db3d5 100755 --- a/bacula/src/filed/win32/winmain.cpp +++ b/bacula/src/filed/win32/winmain.cpp @@ -270,7 +270,7 @@ void *Main_Msg_Loop(LPVOID lpwThreadParam) // Create tray icon & menu if we're running as an app bacMenu *menu = new bacMenu(); if (menu == NULL) { -// LogErrorMsg("Could not create sys tray menu"); +// log_error_message("Could not create sys tray menu"); PostQuitMessage(0); } diff --git a/bacula/src/filed/win32/winservice.cpp b/bacula/src/filed/win32/winservice.cpp index 91e30b2346..2315e3ab95 100755 --- a/bacula/src/filed/win32/winservice.cpp +++ b/bacula/src/filed/win32/winservice.cpp @@ -42,11 +42,6 @@ #include "winservice.h" #include "wintray.h" -// Error message logging -void LogErrorMsg(char *message); -#ifdef needed -void SetServicePrivileges(); -#endif // OS-SPECIFIC ROUTINES @@ -348,7 +343,7 @@ bacService::BaculaServiceMain() if (RegisterService == NULL) { MessageBox(NULL, "Registry service not found: Bacula service not started", "Bacula Service", MB_OK); - LogErrorMsg("Registry service not found"); + log_error_message("Registry service not found"); break; } @@ -378,7 +373,7 @@ bacService::BaculaServiceMain() // Call the service control dispatcher with our entry table if (!StartServiceCtrlDispatcher(dispatchTable)) { - LogErrorMsg("StartServiceCtrlDispatcher failed."); + log_error_message("StartServiceCtrlDispatcher failed."); } break; } /* end case */ @@ -396,7 +391,7 @@ void WINAPI ServiceMain(DWORD argc, char **argv) g_hstatus = RegisterServiceCtrlHandler(BAC_SERVICENAME, ServiceCtrl); if (g_hstatus == 0) { - LogErrorMsg("RegisterServiceCtlHandler failed"); + log_error_message("RegisterServiceCtlHandler failed"); MessageBox(NULL, "Contact Register Service Handler failure", "Bacula service", MB_OK); return; @@ -413,7 +408,7 @@ void WINAPI ServiceMain(DWORD argc, char **argv) 45000)) { // Hint as to how long Bacula should have hung before you assume error ReportStatus(SERVICE_STOPPED, g_error, 0); - LogErrorMsg("ReportStatus failed 1"); + log_error_message("ReportStatus STOPPED failed 1"); return; } @@ -437,7 +432,7 @@ DWORD WINAPI ServiceWorkThread(LPVOID lpwThreadParam) NO_ERROR, // exit code 0)) { // wait hint MessageBox(NULL, "Report Service failure", "Bacula Service", MB_OK); - LogErrorMsg("ReportStatus failed 2"); + log_error_message("ReportStatus RUNNING failed"); return 0; } @@ -452,71 +447,6 @@ DWORD WINAPI ServiceWorkThread(LPVOID lpwThreadParam) return 0; } -#ifdef needed -/* - * Setup privileges we think we will need. We probably do not need - * the SE_SECURITY_NAME, but since nothing seems to be working, - * we get it hoping to fix the problems. - */ -void SetServicePrivileges() -{ - HANDLE hToken; - TOKEN_PRIVILEGES tkp; - // Get a token for this process. - if (!OpenProcessToken(GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { - /* Forge on anyway */ - } - - // Get the LUID for the security privilege. - LookupPrivilegeValue(NULL, SE_SECURITY_NAME, &tkp.Privileges[0].Luid); - - tkp.PrivilegeCount = 1; // one privilege to set - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - // Get the security privilege for this process. - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)0); - - // Cannot test the return value of AdjustTokenPrivileges. - if (GetLastError() != ERROR_SUCCESS) { -// MessageBox(NULL, "Get security priv failed: AdjustTokePrivileges", "backup", MB_OK); - } - - // Get the LUID for the backup privilege. - LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tkp.Privileges[0].Luid); - - tkp.PrivilegeCount = 1; // one privilege to set - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - // Get the backup privilege for this process. - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)0); - - // Cannot test the return value of AdjustTokenPrivileges. - if (GetLastError() != ERROR_SUCCESS) { -// MessageBox(NULL, "Get backup priv failed: AdjustTokePrivileges", "backup", MB_OK); - } - - // Get the LUID for the restore privilege. - LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tkp.Privileges[0].Luid); - - tkp.PrivilegeCount = 1; // one privilege to set - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - // Get the restore privilege for this process. - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)0); - - // Cannot test the return value of AdjustTokenPrivileges. - if (GetLastError() != ERROR_SUCCESS) { -// MessageBox(NULL, "Get restore priv failed: AdjustTokePrivileges", "restore", MB_OK); - } - - CloseHandle(hToken); -} - -#endif // SERVICE STOP ROUTINE - post a quit message to the relevant thread void ServiceStop() @@ -556,7 +486,7 @@ bacService::InstallService() strcat(servicecmd, "\\bacula-fd.conf"); } else { - LogErrorMsg("Service commend length too long"); + log_error_message("Service command length too long"); MessageBox(NULL, "Service command length too long. Service not registered.", szAppName, MB_ICONEXCLAMATION | MB_OK); return 0; @@ -572,7 +502,7 @@ bacService::InstallService() if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices", &runservices) != ERROR_SUCCESS) { - LogErrorMsg("Cannot write System Registry"); + log_error_message("Cannot write System Registry"); MessageBox(NULL, "The System Registry could not be updated - the Bacula service was not installed", szAppName, MB_ICONEXCLAMATION | MB_OK); break; } @@ -580,7 +510,7 @@ bacService::InstallService() // Attempt to add a Bacula key if (RegSetValueEx(runservices, szAppName, 0, REG_SZ, (unsigned char *)servicecmd, strlen(servicecmd)+1) != ERROR_SUCCESS) { RegCloseKey(runservices); - LogErrorMsg("Cannot add Bacula key to System Registry"); + log_error_message("Cannot add Bacula key to System Registry"); MessageBox(NULL, "The Bacula service could not be installed", szAppName, MB_ICONEXCLAMATION | MB_OK); break; } @@ -629,7 +559,7 @@ bacService::InstallService() // Open the default, local Service Control Manager database hsrvmanager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hsrvmanager == NULL) { - LogErrorMsg("OpenSCManager failed"); + log_error_message("OpenSCManager failed"); MessageBox(NULL, "The Service Control Manager could not be contacted - the Bacula service was not installed", szAppName, MB_ICONEXCLAMATION | MB_OK); @@ -654,7 +584,7 @@ bacService::InstallService() NULL); // no password if (hservice == NULL) { CloseServiceHandle(hsrvmanager); - LogErrorMsg("CreateService failed"); + log_error_message("CreateService failed"); MessageBox(NULL, "The Bacula service could not be installed", szAppName, MB_ICONEXCLAMATION | MB_OK); @@ -699,7 +629,7 @@ bacService::InstallService() MB_ICONINFORMATION | MB_OK); break; default: - LogErrorMsg("Unknow Windows OP Sys"); + log_error_message("Unknown Windows System version"); MessageBox(NULL, "Unknown Windows operating system.\n" "Cannot install Bacula service.\n", @@ -871,14 +801,14 @@ BOOL ReportStatus(DWORD state, // Tell the SCM our new status if (!(result = SetServiceStatus(g_hstatus, &g_srvstatus))) { - LogErrorMsg("SetServiceStatus failed"); + log_error_message("SetServiceStatus failed"); } return result; } // Error reporting -void LogErrorMsg(char *message) +void LogErrorMsg(char *message, char *fname, int lineno) { char msgbuff[256]; HANDLE heventsrc; @@ -899,7 +829,8 @@ void LogErrorMsg(char *message) // Use event logging to log the error heventsrc = RegisterEventSource(NULL, BAC_SERVICENAME); - sprintf(msgbuff, "%s error: %ld", BAC_SERVICENAME, g_error); + sprintf(msgbuff, "\n\n%s error: %ld at %s:%d", + BAC_SERVICENAME, g_error, fname, lineno); strings[0] = msgbuff; strings[1] = message; strings[2] = msg; diff --git a/bacula/src/findlib/Makefile.in b/bacula/src/findlib/Makefile.in index 9a8386b96f..034dacf9e3 100644 --- a/bacula/src/findlib/Makefile.in +++ b/bacula/src/findlib/Makefile.in @@ -21,9 +21,9 @@ dummy: # LIBSRCS = find.c match.c find_one.c attibs.c create_file.c \ - bfile.c makepath.c save-cwd.c + bfile.c get_priv.c makepath.c save-cwd.c LIBOBJS = find.o match.o find_one.o attribs.o create_file.o \ - bfile.o makepath.o save-cwd.o + bfile.o get_priv.o makepath.o save-cwd.o .SUFFIXES: .c .o .PHONY: diff --git a/bacula/src/findlib/attribs.c b/bacula/src/findlib/attribs.c index 287653981a..3a39b02dac 100755 --- a/bacula/src/findlib/attribs.c +++ b/bacula/src/findlib/attribs.c @@ -273,10 +273,6 @@ int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt) return STREAM_UNIX_ATTRIBUTES; } -void SetServicePrivileges(void *jcr) - { } - - #endif @@ -481,104 +477,4 @@ void unix_name_to_win32(POOLMEM **win32_name, char *name) cygwin_conv_to_win32_path(name, *win32_name); } -/* - * Setup privileges we think we will need. We probably do not need - * the SE_SECURITY_NAME, but since nothing seems to be working, - * we get it hoping to fix the problems. - */ -void SetServicePrivileges(void *jcr) -{ - HANDLE hToken; - TOKEN_PRIVILEGES tkp, tkpPrevious; - DWORD cbPrevious = sizeof(TOKEN_PRIVILEGES); - DWORD lerror; - // Get a token for this process. - if (!OpenProcessToken(GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { - win_error(jcr, "OpenProcessToken", GetLastError()); - /* Forge on anyway */ - } - - // Get the LUID for the security privilege. - if (!LookupPrivilegeValue(NULL, SE_SECURITY_NAME, &tkp.Privileges[0].Luid)) { - win_error(jcr, "LookupPrivilegeValue", GetLastError()); - } - - tkp.PrivilegeCount = 1; - tkp.Privileges[0].Attributes = 0; - /* Get the privilege */ - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - &tkpPrevious, &cbPrevious); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges get SECURITY_NAME", lerror); - } - - tkpPrevious.PrivilegeCount = 1; - tkpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED); - - /* Set the security privilege for this process. */ - AdjustTokenPrivileges(hToken, FALSE, &tkpPrevious, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges set SECURITY_NAME", lerror); - } - - // Get the LUID for the backup privilege. - if (!LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &tkp.Privileges[0].Luid)) { - win_error(jcr, "LookupPrivilegeValue", GetLastError()); - } - - tkp.PrivilegeCount = 1; - tkp.Privileges[0].Attributes = 0; - /* Get the current privilege */ - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - &tkpPrevious, &cbPrevious); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges get BACKUP_NAME", lerror); - } - - tkpPrevious.PrivilegeCount = 1; - tkpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED); - - /* Set the backup privilege for this process. */ - AdjustTokenPrivileges(hToken, FALSE, &tkpPrevious, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges set BACKUP_NAME", lerror); - } - - // Get the LUID for the restore privilege. - if (!LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &tkp.Privileges[0].Luid)) { - win_error(jcr, "LookupPrivilegeValue", GetLastError()); - } - - tkp.PrivilegeCount = 1; - tkp.Privileges[0].Attributes = 0; - /* Get the privilege */ - AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(TOKEN_PRIVILEGES), - &tkpPrevious, &cbPrevious); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges get RESTORE_NAME", lerror); - } - - tkpPrevious.PrivilegeCount = 1; - tkpPrevious.Privileges[0].Attributes |= (SE_PRIVILEGE_ENABLED); - - /* Set the security privilege for this process. */ - AdjustTokenPrivileges(hToken, FALSE, &tkpPrevious, sizeof(TOKEN_PRIVILEGES), - (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL); - lerror = GetLastError(); - if (lerror != ERROR_SUCCESS) { - win_error(jcr, "AdjustTokenPrivileges set RESTORE_NAME", lerror); - } - CloseHandle(hToken); -} - -// MessageBox(NULL, "Get restore priv failed: AdjustTokePrivileges", "restore", MB_OK); - #endif /* HAVE_CYGWIN */ diff --git a/bacula/src/findlib/find.h b/bacula/src/findlib/find.h index 4bd86c0f53..f7edc771b9 100755 --- a/bacula/src/findlib/find.h +++ b/bacula/src/findlib/find.h @@ -61,43 +61,43 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); /* * Status codes returned by create_file() */ -#define CF_SKIP 1 /* skip file (not newer or something) */ -#define CF_ERROR 2 /* error creating file */ -#define CF_EXTRACT 3 /* file created, data to extract */ -#define CF_CREATED 4 /* file created, no data to extract */ +#define CF_SKIP 1 /* skip file (not newer or something) */ +#define CF_ERROR 2 /* error creating file */ +#define CF_EXTRACT 3 /* file created, data to extract */ +#define CF_CREATED 4 /* file created, no data to extract */ /* * NOTE!!! These go on the tape, so don't change them. If * need be, add to them. */ -#define FT_LNKSAVED 1 /* hard link to file already saved */ -#define FT_REGE 2 /* Regular file but empty */ -#define FT_REG 3 /* Regular file */ -#define FT_LNK 4 /* Soft Link */ -#define FT_DIR 5 /* Directory */ -#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ -#define FT_NOACCESS 7 /* Not able to access */ -#define FT_NOFOLLOW 8 /* Could not follow link */ -#define FT_NOSTAT 9 /* Could not stat file */ -#define FT_NOCHG 10 /* Incremental option, file not changed */ -#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ -#define FT_ISARCH 12 /* Trying to save archive file */ -#define FT_NORECURSE 13 /* No recursion into directory */ -#define FT_NOFSCHG 14 /* Different file system, prohibited */ -#define FT_NOOPEN 15 /* Could not open directory */ -#define FT_RAW 16 /* Raw block device */ -#define FT_FIFO 17 /* Raw fifo device */ +#define FT_LNKSAVED 1 /* hard link to file already saved */ +#define FT_REGE 2 /* Regular file but empty */ +#define FT_REG 3 /* Regular file */ +#define FT_LNK 4 /* Soft Link */ +#define FT_DIR 5 /* Directory */ +#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */ +#define FT_NOACCESS 7 /* Not able to access */ +#define FT_NOFOLLOW 8 /* Could not follow link */ +#define FT_NOSTAT 9 /* Could not stat file */ +#define FT_NOCHG 10 /* Incremental option, file not changed */ +#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */ +#define FT_ISARCH 12 /* Trying to save archive file */ +#define FT_NORECURSE 13 /* No recursion into directory */ +#define FT_NOFSCHG 14 /* Different file system, prohibited */ +#define FT_NOOPEN 15 /* Could not open directory */ +#define FT_RAW 16 /* Raw block device */ +#define FT_FIFO 17 /* Raw fifo device */ /* Options saved in "flag" of ff packet */ -#define FO_MD5 0x001 /* Do MD5 checksum */ -#define FO_GZIP 0x002 /* Do Zlib compression */ -#define FO_NO_RECURSION 0x004 /* no recursion in directories */ -#define FO_MULTIFS 0x008 /* multiple file systems */ -#define FO_SPARSE 0x010 /* do sparse file checking */ -#define FO_IF_NEWER 0x020 /* replace if newer */ -#define FO_NOREPLACE 0x040 /* never replace */ -#define FO_READFIFO 0x080 /* read data from fifo */ -#define FO_SHA1 0x100 /* Do SHA1 checksum */ +#define FO_MD5 0x001 /* Do MD5 checksum */ +#define FO_GZIP 0x002 /* Do Zlib compression */ +#define FO_NO_RECURSION 0x004 /* no recursion in directories */ +#define FO_MULTIFS 0x008 /* multiple file systems */ +#define FO_SPARSE 0x010 /* do sparse file checking */ +#define FO_IF_NEWER 0x020 /* replace if newer */ +#define FO_NOREPLACE 0x040 /* never replace */ +#define FO_READFIFO 0x080 /* read data from fifo */ +#define FO_SHA1 0x100 /* Do SHA1 checksum */ /* * Options saved in "options" of include list @@ -109,21 +109,21 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); #define OPT_compute_MD5 0x01 /* compute MD5 of file's data */ #define OPT_GZIP_compression 0x02 /* use GZIP compression */ #define OPT_no_recursion 0x04 /* no recursion in directories */ -#define OPT_multifs 0x08 /* multiple file systems */ -#define OPT_sparse 0x10 /* do sparse file checking */ +#define OPT_multifs 0x08 /* multiple file systems */ +#define OPT_sparse 0x10 /* do sparse file checking */ #define OPT_replace_if_newer 0x20 /* replace file if newer */ #define OPT_never_replace 0x40 /* never replace */ -#define OPT_read_fifo 0x80 /* read data from fifo (named pipe) */ +#define OPT_read_fifo 0x80 /* read data from fifo (named pipe) */ #define OPT_compute_SHA1 0x100 /* compute SHA1 of file's data */ struct s_included_file { struct s_included_file *next; - int options; /* backup options */ - int level; /* compression level */ - int len; /* length of fname */ - int pattern; /* set if pattern */ - char VerifyOpts[20]; /* Options for verify */ + int options; /* backup options */ + int level; /* compression level */ + int len; /* length of fname */ + int pattern; /* set if pattern */ + char VerifyOpts[20]; /* Options for verify */ char fname[1]; }; @@ -138,26 +138,26 @@ struct s_excluded_file { #include #define BF_CLOSED 0 -#define BF_READ 1 /* BackupRead */ -#define BF_WRITE 2 /* BackupWrite */ +#define BF_READ 1 /* BackupRead */ +#define BF_WRITE 2 /* BackupWrite */ /* Basic low level I/O file packet */ typedef struct s_bfile { - int use_win_api; /* set if using WinAPI */ - int mode; /* set if file is open */ - HANDLE fh; /* Win32 file handle */ - int fid; /* fd if doing Unix style */ - LPVOID lpContext; /* BackupRead/Write context */ - POOLMEM *errmsg; /* error message buffer */ - DWORD rw_bytes; /* Bytes read or written */ - DWORD lerror; /* Last error code */ + int use_win_api; /* set if using WinAPI */ + int mode; /* set if file is open */ + HANDLE fh; /* Win32 file handle */ + int fid; /* fd if doing Unix style */ + LPVOID lpContext; /* BackupRead/Write context */ + POOLMEM *errmsg; /* error message buffer */ + DWORD rw_bytes; /* Bytes read or written */ + DWORD lerror; /* Last error code */ } BFILE; #else /* Basic low level I/O file packet */ typedef struct s_bfile { - int fid; /* file id on Unix */ + int fid; /* file id on Unix */ } BFILE; #endif @@ -168,30 +168,30 @@ typedef struct s_bfile { * first argument to the find_files callback subroutine. */ typedef struct s_ff { - char *fname; /* filename */ - char *link; /* link if file linked */ - POOLMEM *sys_fname; /* system filename */ - struct stat statp; /* stat packet */ - uint32_t FileIndex; /* FileIndex of this file */ - uint32_t LinkFI; /* FileIndex of main hard linked file */ - struct f_link *linked; /* Set if we are hard linked */ - int type; /* FT_ type from above */ - int flags; /* control flags */ - int ff_errno; /* errno */ - int incremental; /* do incremental save */ - BFILE bfd; /* Bacula file descriptor */ - time_t save_time; /* start of incremental time */ - int mtime_only; /* incremental on mtime_only */ - int dereference; /* follow links */ - int GZIP_level; /* compression level */ - int atime_preserve; /* preserve access times */ - int null_output_device; /* using null output device */ + char *fname; /* filename */ + char *link; /* link if file linked */ + POOLMEM *sys_fname; /* system filename */ + struct stat statp; /* stat packet */ + uint32_t FileIndex; /* FileIndex of this file */ + uint32_t LinkFI; /* FileIndex of main hard linked file */ + struct f_link *linked; /* Set if we are hard linked */ + int type; /* FT_ type from above */ + int flags; /* control flags */ + int ff_errno; /* errno */ + int incremental; /* do incremental save */ + BFILE bfd; /* Bacula file descriptor */ + time_t save_time; /* start of incremental time */ + int mtime_only; /* incremental on mtime_only */ + int dereference; /* follow links */ + int GZIP_level; /* compression level */ + int atime_preserve; /* preserve access times */ + int null_output_device; /* using null output device */ char VerifyOpts[20]; struct s_included_file *included_files_list; struct s_excluded_file *excluded_files_list; struct s_excluded_file *excluded_paths_list; - struct f_link *linklist; /* hard linked files */ + struct f_link *linklist; /* hard linked files */ } FF_PKT; diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index f08548ec78..8d3bf5e3b4 100755 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -71,7 +71,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), return handle_file(ff_pkt, pkt); } - Dmsg1(60, "File ----: %s\n", fname); + Dmsg1(300, "File ----: %s\n", fname); /* Save current times of this directory in case we need to * reset them because the user doesn't want them changed. @@ -86,7 +86,7 @@ find_one_file(JCR *jcr, FF_PKT *ff_pkt, int handle_file(FF_PKT *ff, void *hpkt), * or Incremental. */ if (ff_pkt->incremental && !S_ISDIR(ff_pkt->statp.st_mode)) { - Dmsg1(100, "Non-directory incremental: %s\n", ff_pkt->fname); + Dmsg1(300, "Non-directory incremental: %s\n", ff_pkt->fname); /* Not a directory */ if (ff_pkt->statp.st_mtime < ff_pkt->save_time && (ff_pkt->mtime_only || diff --git a/bacula/src/findlib/protos.h b/bacula/src/findlib/protos.h index 49f7b889d0..0d17d1342e 100644 --- a/bacula/src/findlib/protos.h +++ b/bacula/src/findlib/protos.h @@ -24,18 +24,17 @@ */ /* from attribs.c */ -void encode_stat (char *buf, struct stat *statp, uint32_t LinkFI); -void decode_stat (char *buf, struct stat *statp, uint32_t *LinkFI); -int encode_attribsEx (void *jcr, char *attribsEx, FF_PKT *ff_pkt); +void encode_stat (char *buf, struct stat *statp, uint32_t LinkFI); +void decode_stat (char *buf, struct stat *statp, uint32_t *LinkFI); +int encode_attribsEx (void *jcr, char *attribsEx, FF_PKT *ff_pkt); int set_attributes(void *jcr, char *fname, char *ofile, char *lname, - int type, int stream, struct stat *statp, - char *attribsEx, BFILE *ofd); -void SetServicePrivileges(void *jcr); + int type, int stream, struct stat *statp, + char *attribsEx, BFILE *ofd); /* from create_file.c */ int create_file(void *jcr, char *fname, char *ofile, char *lname, - int type, int stream, struct stat *statp, - char *attribsEx, BFILE *ofd, int replace, int win_io); + int type, int stream, struct stat *statp, + char *attribsEx, BFILE *ofd, int replace, int win_io); /* From find.c */ FF_PKT *init_find_files(); @@ -51,26 +50,30 @@ void add_fname_to_exclude_list(FF_PKT *ff, char *fname); int file_is_excluded(FF_PKT *ff, char *file); int file_is_included(FF_PKT *ff, char *file); struct s_included_file *get_next_included_file(FF_PKT *ff, - struct s_included_file *inc); + struct s_included_file *inc); /* From find_one.c */ int find_one_file(JCR *jcr, FF_PKT *ff, int handle_file(FF_PKT *ff_pkt, void *hpkt), - void *pkt, char *p, dev_t parent_device, int top_level); + void *pkt, char *p, dev_t parent_device, int top_level); int term_find_one(FF_PKT *ff); +/* From get_priv.c */ +void get_backup_privileges(void *jcr, int ignore_errors); + + /* from makepath.c */ int make_path(void *jcr, const char *argpath, int mode, - int parent_mode, uid_t owner, gid_t group, - int preserve_existing, char *verbose_fmt_string); + int parent_mode, uid_t owner, gid_t group, + int preserve_existing, char *verbose_fmt_string); /* from file_io.c */ ssize_t bread(BFILE *bfd, void *buf, size_t count); -int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); -int bclose(BFILE *bfd); +int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode); +int bclose(BFILE *bfd); ssize_t bread(BFILE *bfd, void *buf, size_t count); ssize_t bwrite(BFILE *bfd, void *buf, size_t count); -off_t blseek(BFILE *bfd, off_t offset, int whence); -int is_bopen(BFILE *bfd); -void binit(BFILE *bfd, int use_win_api); -char *berror(BFILE *bfd); +off_t blseek(BFILE *bfd, off_t offset, int whence); +int is_bopen(BFILE *bfd); +void binit(BFILE *bfd, int use_win_api); +char *berror(BFILE *bfd); diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 73d1ab3a19..f1d850ff1a 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -393,18 +393,18 @@ bnet_wait_data(BSOCK *bsock, int sec) tv.tv_usec = 0; for ( ;; ) { switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) { - case 0: /* timeout */ - bsock->b_errno = 0; - return 0; - case -1: - bsock->b_errno = errno; - if (errno == EINTR || errno == EAGAIN) { - continue; - } - return -1; /* error return */ - default: - bsock->b_errno = 0; - return 1; + case 0: /* timeout */ + bsock->b_errno = 0; + return 0; + case -1: + bsock->b_errno = errno; + if (errno == EINTR || errno == EAGAIN) { + continue; + } + return -1; /* error return */ + default: + bsock->b_errno = 0; + return 1; } } } @@ -424,15 +424,15 @@ bnet_wait_data_intr(BSOCK *bsock, int sec) tv.tv_usec = 0; for ( ;; ) { switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) { - case 0: /* timeout */ - bsock->b_errno = 0; - return 0; - case -1: - bsock->b_errno = errno; - return -1; /* error return */ - default: - bsock->b_errno = 0; - return 1; + case 0: /* timeout */ + bsock->b_errno = 0; + return 0; + case -1: + bsock->b_errno = errno; + return -1; /* error return */ + default: + bsock->b_errno = 0; + return 1; } } } @@ -747,7 +747,7 @@ init_bsock(void *jcr, int sockfd, char *who, char *host, int port) BSOCK * dup_bsock(BSOCK *osock) { - BSOCK *bsock = (BSOCK *) malloc(sizeof(BSOCK)); + BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK)); memcpy(bsock, osock, sizeof(BSOCK)); bsock->msg = get_pool_memory(PM_MESSAGE); bsock->errmsg = get_pool_memory(PM_MESSAGE); diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index caa59b4f5a..5c77afbd74 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -176,7 +176,7 @@ void free_jcr(JCR *jcr) P(mutex); jcr->use_count--; /* decrement use count */ - Dmsg2(200, "Decrement jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Dec jcr 0x%x use_count=%d\n", jcr, jcr->use_count); if (jcr->use_count > 0) { /* if in use */ V(mutex); Dmsg2(200, "jcr 0x%x use_count=%d\n", jcr, jcr->use_count); @@ -204,7 +204,7 @@ void free_jcr(JCR *jcr) void free_locked_jcr(JCR *jcr) { jcr->use_count--; /* decrement use count */ - Dmsg2(200, "Decrement jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Dec jcr 0x%x use_count=%d\n", jcr, jcr->use_count); if (jcr->use_count > 0) { /* if in use */ return; } @@ -229,7 +229,7 @@ JCR *get_jcr_by_id(uint32_t JobId) for (jcr = jobs; jcr; jcr=jcr->next) { if (jcr->JobId == JobId) { jcr->use_count++; - Dmsg2(200, "Increment jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Inc jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -251,7 +251,7 @@ JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime) if (jcr->VolSessionId == SessionId && jcr->VolSessionTime == SessionTime) { jcr->use_count++; - Dmsg2(200, "Increment jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Inc jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -277,7 +277,7 @@ JCR *get_jcr_by_partial_name(char *Job) for (jcr = jobs; jcr; jcr=jcr->next) { if (strncmp(Job, jcr->Job, len) == 0) { jcr->use_count++; - Dmsg2(200, "Increment jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Inc jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -300,7 +300,7 @@ JCR *get_jcr_by_full_name(char *Job) for (jcr = jobs; jcr; jcr=jcr->next) { if (strcmp(jcr->Job, Job) == 0) { jcr->use_count++; - Dmsg2(200, "Increment jcr 0x%x use_count=%d\n", jcr, jcr->use_count); + Dmsg2(200, "Inc jcr 0x%x use_count=%d\n", jcr, jcr->use_count); break; } } @@ -354,7 +354,7 @@ JCR *get_next_jcr(JCR *jcr) } if (rjcr) { rjcr->use_count++; - Dmsg1(200, "Increment jcr use_count=%d\n", rjcr->use_count); + Dmsg1(200, "Inc jcr use_count=%d\n", rjcr->use_count); } return rjcr; } diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 60d24de7d3..94eb942558 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -46,9 +46,7 @@ char con_fname[500]; /* Console filename */ FILE *con_fd = NULL; /* Console file descriptor */ brwlock_t con_lock; /* Console lock structure */ -#ifdef TRACE_FILE FILE *trace_fd = NULL; -#endif /* Forward referenced functions */ @@ -539,7 +537,7 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) MSGS *msgs; BPIPE *bpipe; - Dmsg2(200, "Enter dispatch_msg type=%d msg=%s\n", type, msg); + Dmsg2(800, "Enter dispatch_msg type=%d msg=%s\n", type, msg); if (type == M_ABORT || type == M_ERROR_TERM) { fputs(msg, stdout); /* print this here to INSURE that it is printed */ @@ -557,10 +555,10 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) if (bit_is_set(type, d->msg_types)) { switch (d->dest_code) { case MD_CONSOLE: - Dmsg1(400, "CONSOLE for following msg: %s", msg); + Dmsg1(800, "CONSOLE for following msg: %s", msg); if (!con_fd) { con_fd = fopen(con_fname, "a+"); - Dmsg0(200, "Console file not open.\n"); + Dmsg0(800, "Console file not open.\n"); } if (con_fd) { Pw(con_lock); /* get write lock on console message file */ @@ -584,14 +582,14 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) } break; case MD_SYSLOG: - Dmsg1(400, "SYSLOG for collowing msg: %s\n", msg); + Dmsg1(800, "SYSLOG for collowing msg: %s\n", msg); /* * We really should do an openlog() here. */ syslog(LOG_DAEMON|LOG_ERR, "%s", msg); break; case MD_OPERATOR: - Dmsg1(400, "OPERATOR for collowing msg: %s\n", msg); + Dmsg1(800, "OPERATOR for collowing msg: %s\n", msg); mcmd = get_pool_memory(PM_MESSAGE); if ((bpipe=open_mail_pipe(jcr, &mcmd, d))) { int stat; @@ -607,7 +605,7 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) break; case MD_MAIL: case MD_MAIL_ON_ERROR: - Dmsg1(400, "MAIL for following msg: %s", msg); + Dmsg1(800, "MAIL for following msg: %s", msg); if (!d->fd) { POOLMEM *name = get_pool_memory(PM_MESSAGE); make_unique_mail_filename(jcr, &name, d); @@ -628,7 +626,7 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) fputs(msg, d->fd); break; case MD_FILE: - Dmsg1(400, "FILE for following msg: %s", msg); + Dmsg1(800, "FILE for following msg: %s", msg); if (!d->fd) { d->fd = fopen(d->where, "w+"); if (!d->fd) { @@ -641,7 +639,7 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) fputs(msg, d->fd); break; case MD_APPEND: - Dmsg1(400, "APPEND for following msg: %s", msg); + Dmsg1(800, "APPEND for following msg: %s", msg); if (!d->fd) { d->fd = fopen(d->where, "a"); if (!d->fd) { @@ -654,7 +652,7 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) fputs(msg, d->fd); break; case MD_DIRECTOR: - Dmsg1(400, "DIRECTOR for following msg: %s", msg); + Dmsg1(800, "DIRECTOR for following msg: %s", msg); if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) { jcr->dir_bsock->msglen = Mmsg(&(jcr->dir_bsock->msg), @@ -664,13 +662,13 @@ void dispatch_message(void *vjcr, int type, int level, char *msg) } break; case MD_STDOUT: - Dmsg1(400, "STDOUT for following msg: %s", msg); + Dmsg1(800, "STDOUT for following msg: %s", msg); if (type != M_ABORT && type != M_ERROR_TERM) { /* already printed */ fputs(msg, stdout); } break; case MD_STDERR: - Dmsg1(400, "STDERR for following msg: %s", msg); + Dmsg1(800, "STDERR for following msg: %s", msg); fputs(msg, stderr); break; default: @@ -706,6 +704,16 @@ d_msg(char *file, int line, int level, char *fmt,...) } if (level <= debug_level) { +#ifdef SEND_DMSG_TO_FILE + if (!trace_fd) { + bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); + trace_fd = fopen(buf, "a+"); + if (!trace_fd) { + Emsg2(M_ABORT, 0, _("Cannot open %s: ERR=%s\n"), + buf, strerror(errno)); + } + } +#endif #ifdef FULL_LOCATION if (details) { len= sprintf(buf, "%s: %s:%d ", my_name, file, line); @@ -719,7 +727,12 @@ d_msg(char *file, int line, int level, char *fmt,...) bvsnprintf(buf+len, sizeof(buf)-len, (char *)fmt, arg_ptr); va_end(arg_ptr); +#ifdef SEND_DMSG_TO_FILE + fputs(buf, trace_fd); + fflush(trace_fd); +#else fputs(buf, stdout); +#endif } } @@ -751,10 +764,11 @@ t_msg(char *file, int line, int level, char *fmt,...) if (level <= debug_level) { if (!trace_fd) { - trace_fd = fopen("bacula.trace", "a+"); + bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory); + trace_fd = fopen(buf, "a+"); if (!trace_fd) { - Emsg1(M_ABORT, 0, _("Cannot open bacula.trace: ERR=%s\n"), - strerror(errno)); + Emsg2(M_ABORT, 0, _("Cannot open %s: ERR=%s\n"), + buf, strerror(errno)); } } @@ -858,7 +872,7 @@ Jmsg(void *vjcr, int type, int level, char *fmt,...) char *job; - Dmsg1(200, "Enter Jmsg type=%d\n", type); + Dmsg1(800, "Enter Jmsg type=%d\n", type); msgs = NULL; job = NULL; diff --git a/bacula/src/lib/message.h b/bacula/src/lib/message.h index 4e722f0e0c..890594d6c2 100644 --- a/bacula/src/lib/message.h +++ b/bacula/src/lib/message.h @@ -26,16 +26,16 @@ #include "bits.h" -#undef M_DEBUG -#undef M_ABORT -#undef M_FATAL -#undef M_ERROR -#undef M_WARNING -#undef M_INFO -#undef M_MOUNT -#undef M_ERROR_TERM -#undef M_TERM -#undef M_RESTORED +#undef M_DEBUG +#undef M_ABORT +#undef M_FATAL +#undef M_ERROR +#undef M_WARNING +#undef M_INFO +#undef M_MOUNT +#undef M_ERROR_TERM +#undef M_TERM +#undef M_RESTORED /* * Most of these message levels are more or less obvious. @@ -43,66 +43,66 @@ * and here are some of the details of where I am trying to * head (in the process of changing the code) as of 15 June 2002. * - * M_ABORT Bacula immediately aborts and tries to produce a traceback - * This is for really serious errors like segmentation fault. + * M_ABORT Bacula immediately aborts and tries to produce a traceback + * This is for really serious errors like segmentation fault. * M_ERROR_TERM Bacula immediately terminates but no dump. This is for * "obvious" serious errors like daemon already running or - * cannot open critical file, ... where a dump is not wanted. - * M_TERM Bacula daemon shutting down because of request (SIGTERM). + * cannot open critical file, ... where a dump is not wanted. + * M_TERM Bacula daemon shutting down because of request (SIGTERM). * * The remaining apply to Jobs rather than the daemon. * - * M_FATAL Bacula detected a fatal Job error. The Job will be killed, - * but Bacula continues running. - * M_ERROR Bacula detected a Job error. The Job will continue running - * but the termination status will be error. - * M_WARNING Job warning message. - * M_INFO Job information message. + * M_FATAL Bacula detected a fatal Job error. The Job will be killed, + * but Bacula continues running. + * M_ERROR Bacula detected a Job error. The Job will continue running + * but the termination status will be error. + * M_WARNING Job warning message. + * M_INFO Job information message. * - * M_RESTORED An ls -l of each restored file. + * M_RESTORED An ls -l of each restored file. * */ -#define M_DEBUG 1 /* debug message */ -#define M_ABORT 2 /* MUST abort immediately */ -#define M_FATAL 3 /* Fatal error, stopping job */ -#define M_ERROR 4 /* Error, but recoverable */ -#define M_WARNING 5 /* Warning message */ -#define M_INFO 6 /* Informational message */ -#define M_SAVED 7 /* Info on saved file */ -#define M_NOTSAVED 8 /* Info on notsaved file */ -#define M_SKIPPED 9 /* File skipped by option setting */ -#define M_MOUNT 10 /* Mount requests */ -#define M_ERROR_TERM 11 /* Error termination request (no dump) */ -#define M_TERM 12 /* Terminating daemon */ -#define M_RESTORED 13 /* ls -l of restored files */ +#define M_DEBUG 1 /* debug message */ +#define M_ABORT 2 /* MUST abort immediately */ +#define M_FATAL 3 /* Fatal error, stopping job */ +#define M_ERROR 4 /* Error, but recoverable */ +#define M_WARNING 5 /* Warning message */ +#define M_INFO 6 /* Informational message */ +#define M_SAVED 7 /* Info on saved file */ +#define M_NOTSAVED 8 /* Info on notsaved file */ +#define M_SKIPPED 9 /* File skipped by option setting */ +#define M_MOUNT 10 /* Mount requests */ +#define M_ERROR_TERM 11 /* Error termination request (no dump) */ +#define M_TERM 12 /* Terminating daemon */ +#define M_RESTORED 13 /* ls -l of restored files */ -#define M_MAX M_RESTORED /* keep this updated ! */ +#define M_MAX M_RESTORED /* keep this updated ! */ /* Define message destination structure */ /* *** FIXME **** where should be extended to handle multiple values */ typedef struct s_dest { struct s_dest *next; - int dest_code; /* destination (one of the MD_ codes) */ - int max_len; /* max mail line length */ - FILE *fd; /* file descriptor */ + int dest_code; /* destination (one of the MD_ codes) */ + int max_len; /* max mail line length */ + FILE *fd; /* file descriptor */ char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */ - char *where; /* filename/program name */ - char *mail_cmd; /* mail command */ - POOLMEM *mail_filename; /* unique mail filename */ + char *where; /* filename/program name */ + char *mail_cmd; /* mail command */ + POOLMEM *mail_filename; /* unique mail filename */ } DEST; /* Message Destination values for dest field of DEST */ -#define MD_SYSLOG 1 /* send msg to syslog */ -#define MD_MAIL 2 /* email group of messages */ -#define MD_FILE 3 /* write messages to a file */ -#define MD_APPEND 4 /* append messages to a file */ -#define MD_STDOUT 5 /* print messages */ -#define MD_STDERR 6 /* print messages to stderr */ -#define MD_DIRECTOR 7 /* send message to the Director */ -#define MD_OPERATOR 8 /* email a single message to the operator */ -#define MD_CONSOLE 9 /* send msg to UserAgent or console */ -#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */ +#define MD_SYSLOG 1 /* send msg to syslog */ +#define MD_MAIL 2 /* email group of messages */ +#define MD_FILE 3 /* write messages to a file */ +#define MD_APPEND 4 /* append messages to a file */ +#define MD_STDOUT 5 /* print messages */ +#define MD_STDERR 6 /* print messages to stderr */ +#define MD_DIRECTOR 7 /* send message to the Director */ +#define MD_OPERATOR 8 /* email a single message to the operator */ +#define MD_CONSOLE 9 /* send msg to UserAgent or console */ +#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */ void d_msg(char *file, int line, int level, char *fmt,...); diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 6814e1fcee..002207641f 100755 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -118,7 +118,7 @@ static void *btimer_thread(void *arg) for ( ;!quit; ) { time_t timer_start, now; - Dmsg0(200, "Top of for loop\n"); + Dmsg0(200, "Top of watchdog loop\n"); watchdog_time = time(NULL); /* update timer */ @@ -168,6 +168,7 @@ static void *btimer_thread(void *arg) } unlock_jcr_chain(); + Dmsg0(200, "Watchdog sleep.\n"); bmicrosleep(SLEEP_TIME, 0); now = time(NULL); diff --git a/bacula/src/version.h b/bacula/src/version.h index 2e2802ec2f..2f9d2315a0 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -10,6 +10,11 @@ #define SMCHECK #define TRACE_FILE 1 +/* Turn this on ONLY if you want all Dmsg() to append to the + * trace file. Implemented mainly for Win32 ... + */ +/* #define SEND_DMSG_TO_FILE 1 */ + /* Turn this on if you want to try the new Job semaphore code */ #define USE_SEMAPHORE -- 2.39.5