]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix Win32 crash
authorKern Sibbald <kern@sibbald.com>
Mon, 5 May 2003 16:07:06 +0000 (16:07 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 5 May 2003 16:07:06 +0000 (16:07 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@493 91ce42f0-d328-0410-95d8-f526ca767f89

18 files changed:
bacula/src/filed/backup.c
bacula/src/filed/heartbeat.c
bacula/src/filed/job.c
bacula/src/filed/status.c
bacula/src/filed/win32/winbacula.h
bacula/src/filed/win32/winmain.cpp
bacula/src/filed/win32/winservice.cpp
bacula/src/findlib/Makefile.in
bacula/src/findlib/attribs.c
bacula/src/findlib/find.h
bacula/src/findlib/find_one.c
bacula/src/findlib/protos.h
bacula/src/lib/bnet.c
bacula/src/lib/jcr.c
bacula/src/lib/message.c
bacula/src/lib/message.h
bacula/src/lib/watchdog.c
bacula/src/version.h

index 8403b8331a624afa6e740ead2352e2e658723629..637418524d321311fe9d016739b15fbe00d09244 100644 (file)
@@ -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;
 }         
 
index 409b4013af667ce67a0cf228823a93d023c73b8e..2cc907f7abb0923789f01927e8f29a6adeb0a42e 100644 (file)
@@ -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);
    }
 }
index 37e0d4b0982f5bc9f94f2dedfc6e3109f35fd48d..398feede195efa6e47c2e666b1ae400607a93ccd 100644 (file)
@@ -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);
index 6bc287862b521818e094979e0bf11658cd94ed39..e0c1054de6c9fcac7ac43234d70d7bd978d954ea 100755 (executable)
@@ -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;
 }
index df804f5aeb716d2bfe0d729b1c5c2d062ed67b6b..a9a83dfbb3a0d0985b98536ed0b580205739831f 100755 (executable)
@@ -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__)
index 4faaaea6d33d5a1b8143f59b4f2e923db8ef0dda..78eb3db3d5a8ae7c8d700eb60b8188df313348bd 100755 (executable)
@@ -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);
    }
 
index 91e30b234606176cef10c1c472b40857e2e81d2f..2315e3ab9530c09cf6fc95245e405142e9a156a4 100755 (executable)
 #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;
index 9a8386b96f066b188cde897163c1f0db081a29e3..034dacf9e32dba596065f09ef48886d5069d7c78 100644 (file)
@@ -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:
index 287653981a0bf440d04d95758d5c5baf6b8e5d82..3a39b02dac7fe37fb5a4ba4a905aee571f22e09e 100755 (executable)
@@ -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 */
index 4bd86c0f53c8c8ff82fe953cdc2a84fad6b35405..f7edc771b9fca50f7114405a806bf6cbad88c79c 100755 (executable)
@@ -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 <windows.h>
 
 #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;
 
 
index f08548ec7842d463810a06cb048345ad491a622e..8d3bf5e3b4d160962c3a0a4af062aff2384df862 100755 (executable)
@@ -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 || 
index 49f7b889d0b06b16abccab7ee4797aadd81d19e6..0d17d1342ed7b0733ba746f96e9a5728b623859c 100644 (file)
  */
 
 /* 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);
index 73d1ab3a19519697443e3fa6bf006f0b817ba86c..f1d850ff1a72730f151e52d3426d973da6356656 100644 (file)
@@ -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);
index caa59b4f5a1c640b61e58ad9df23b2c824267742..5c77afbd7491f6b117d5ce850752fbb3c52c968f 100755 (executable)
@@ -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;
 }
index 60d24de7d38c3c26eb244b983f8cc8279a7733b3..94eb9425588d4c7260690f664a5ed4f2a4e313b0 100755 (executable)
@@ -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;
index 4e722f0e0c90c9078e226d0203f89e52f5d1ef58..890594d6c2198bd91da8a427e20f88f620b791e4 100644 (file)
 
 #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. 
  * 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,...);
index 6814e1fceeebacef95b9f8acec1b18df1142df14..002207641faeb1d5418bb614f1b204c16c6943ff 100755 (executable)
@@ -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);
 
index 2e2802ec2fea0200b19260b44117d7f1e674e332..2f9d2315a07142f60fcceec8473466fb430c9dfe 100644 (file)
 #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