]> git.sur5r.net Git - bacula/bacula/commitdiff
Send M_ERROR_TERM and M_ABORT messages to stdout on Windows.
authorRobert Nelson <robertn@the-nelsons.org>
Wed, 11 Oct 2006 22:40:53 +0000 (22:40 +0000)
committerRobert Nelson <robertn@the-nelsons.org>
Wed, 11 Oct 2006 22:40:53 +0000 (22:40 +0000)
Fix cleanup of spool files on Windows.

Fix Windows 9x compatibility.

Remove /silent option from daemons on Windows.  The new default is the same as the old /silent.  To enable the message boxes that previously were suppressed by /silent you must add /debug instead.

Add new /debug option. This option enables the message boxes that previously were suppressed by the /silent option.  In addition the daemons will open a console window if this option is used.

Fix bug with service not being removed on migrated installs.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3548 91ce42f0-d328-0410-95d8-f526ca767f89

18 files changed:
bacula/src/lib/message.c
bacula/src/stored/stored.c
bacula/src/win32/compat/winapi.c
bacula/src/win32/dird/winbacula.h
bacula/src/win32/dird/winmain.cpp
bacula/src/win32/dird/winservice.cpp
bacula/src/win32/filed/vss_generic.cpp
bacula/src/win32/filed/winmain.cpp
bacula/src/win32/filed/winservice.cpp
bacula/src/win32/installer/winbacula.nsi
bacula/src/win32/libbac/libbac.vcproj
bacula/src/win32/libwin32/winbacula.h
bacula/src/win32/stored/baculasd/winbacula.h
bacula/src/win32/stored/baculasd/winmain.cpp
bacula/src/win32/stored/baculasd/winservice.cpp
bacula/src/win32/winapi.h
bacula/src/wx-console/console_thread.cpp
bacula/technotes-1.39

index 15a939590e8423aab2ad89ed8ef058f9b4e88b5c..7b411d5b3c6ad0ec914bff2fa33197b57af3be9b 100755 (executable)
@@ -596,11 +596,9 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
     }
 
     if (type == M_ABORT || type == M_ERROR_TERM) {
-#if !defined(HAVE_WIN32)
        fputs(dt, stdout);
        fputs(msg, stdout);         /* print this here to INSURE that it is printed */
        fflush(stdout);
-#endif
     }
 
     /* Now figure out where to send the message */
index 26205e20249063ffde8725c0e12f213a169626e9..aa6c47ad07c7f319bb329f92920507264bdb531f 100644 (file)
@@ -418,16 +418,24 @@ static void cleanup_old_files()
 {
    POOLMEM *cleanup = get_pool_memory(PM_MESSAGE);
    int len = strlen(me->working_directory);
+#if defined(HAVE_WIN32)
+   pm_strcpy(cleanup, "del /q ");
+#else
    pm_strcpy(cleanup, "/bin/rm -f ");
+#endif
    pm_strcat(cleanup, me->working_directory);
-   if (len > 0 && me->working_directory[len-1] != '/') {
+   if (len > 0 && me->working_directory[len-1] != '/'
+#if defined(HAVE_WIN32)
+       && me->working_directory[len-1] != '\\'
+#endif
+       ) {
       pm_strcat(cleanup, "/");
    }
    pm_strcat(cleanup, my_name);
    pm_strcat(cleanup, "*.spool");
    run_program(cleanup, 0, NULL);
    free_pool_memory(cleanup);
-}      
+}
 
 
 /*
index f08cf623dd73ce94f7b9607cd95c97315bff8587..0681c6c6dc643687434ca0b34d27d5c095c64966 100644 (file)
@@ -34,13 +34,13 @@ t_LookupPrivilegeValue  p_LookupPrivilegeValue = NULL;
 
 t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL;
 
-t_CreateFileA   p_CreateFileA = NULL;
-t_CreateFileW   p_CreateFileW = NULL;
-t_CreateDirectoryA   p_CreateDirectoryA;
-t_CreateDirectoryW   p_CreateDirectoryW;
+t_CreateFileA           p_CreateFileA = NULL;
+t_CreateFileW           p_CreateFileW = NULL;
+t_CreateDirectoryA      p_CreateDirectoryA;
+t_CreateDirectoryW      p_CreateDirectoryW;
 
-t_wunlink p_wunlink = NULL;
-t_wmkdir p_wmkdir = NULL;
+t_wunlink               p_wunlink = NULL;
+t_wmkdir                p_wmkdir = NULL;
 
 t_GetFileAttributesA    p_GetFileAttributesA = NULL;
 t_GetFileAttributesW    p_GetFileAttributesW = NULL;
@@ -52,22 +52,24 @@ t_SetFileAttributesA    p_SetFileAttributesA = NULL;
 t_SetFileAttributesW    p_SetFileAttributesW = NULL;
 t_BackupRead            p_BackupRead = NULL;
 t_BackupWrite           p_BackupWrite = NULL;
-t_WideCharToMultiByte p_WideCharToMultiByte = NULL;
-t_MultiByteToWideChar p_MultiByteToWideChar = NULL;
+t_WideCharToMultiByte   p_WideCharToMultiByte = NULL;
+t_MultiByteToWideChar   p_MultiByteToWideChar = NULL;
 
-t_FindFirstFileA p_FindFirstFileA = NULL;
-t_FindFirstFileW p_FindFirstFileW = NULL;
+t_AttachConsole         p_AttachConsole = NULL;
 
-t_FindNextFileA p_FindNextFileA = NULL;
-t_FindNextFileW p_FindNextFileW = NULL;
+t_FindFirstFileA        p_FindFirstFileA = NULL;
+t_FindFirstFileW        p_FindFirstFileW = NULL;
 
-t_SetCurrentDirectoryA p_SetCurrentDirectoryA = NULL;
-t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL;
+t_FindNextFileA         p_FindNextFileA = NULL;
+t_FindNextFileW         p_FindNextFileW = NULL;
 
-t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL;
-t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL;
+t_SetCurrentDirectoryA  p_SetCurrentDirectoryA = NULL;
+t_SetCurrentDirectoryW  p_SetCurrentDirectoryW = NULL;
 
-t_GetVolumePathNameW p_GetVolumePathNameW = NULL;
+t_GetCurrentDirectoryA  p_GetCurrentDirectoryA = NULL;
+t_GetCurrentDirectoryW  p_GetCurrentDirectoryW = NULL;
+
+t_GetVolumePathNameW    p_GetVolumePathNameW = NULL;
 t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL;
 
 void 
@@ -124,9 +126,9 @@ InitWinAPIWrapper()
 
       if (g_platform_id != VER_PLATFORM_WIN32_WINDOWS) {
          p_CreateFileW = (t_CreateFileW)
-             GetProcAddress(hLib, "CreateFileW");      
+             GetProcAddress(hLib, "CreateFileW");
          p_CreateDirectoryW = (t_CreateDirectoryW)
-             GetProcAddress(hLib, "CreateDirectoryW");      
+             GetProcAddress(hLib, "CreateDirectoryW");
 
          /* backup calls */
          p_BackupRead = (t_BackupRead)
@@ -141,13 +143,13 @@ InitWinAPIWrapper()
          p_SetFileAttributesW = (t_SetFileAttributesW)
              GetProcAddress(hLib, "SetFileAttributesW");
          p_FindFirstFileW = (t_FindFirstFileW)
-             GetProcAddress(hLib, "FindFirstFileW");       
+             GetProcAddress(hLib, "FindFirstFileW");
          p_FindNextFileW = (t_FindNextFileW)
              GetProcAddress(hLib, "FindNextFileW");
          p_GetCurrentDirectoryW = (t_GetCurrentDirectoryW)
-             GetProcAddress(hLib, "GetCurrentDirectoryW");      
+             GetProcAddress(hLib, "GetCurrentDirectoryW");
          p_SetCurrentDirectoryW = (t_SetCurrentDirectoryW)
-             GetProcAddress(hLib, "SetCurrentDirectoryW");       
+             GetProcAddress(hLib, "SetCurrentDirectoryW");
 
          /* some special stuff we need for VSS
             but statically linkage doesn't work on Win 9x */
@@ -155,6 +157,9 @@ InitWinAPIWrapper()
              GetProcAddress(hLib, "GetVolumePathNameW");
          p_GetVolumeNameForVolumeMountPointW = (t_GetVolumeNameForVolumeMountPointW)
              GetProcAddress(hLib, "GetVolumeNameForVolumeMountPointW");
+
+         p_AttachConsole = (t_AttachConsole)
+             GetProcAddress(hLib, "AttachConsole");
       }
 
       FreeLibrary(hLib);
index 0e6960284862c650b71108402439f64c1e413fa6..6a0a4e9a5747af3e5ba935b3e374750d78358e01 100644 (file)
@@ -49,7 +49,7 @@ extern int BaculaAppMain();
 extern void LogErrorMsg(char *msg);
 
 // Standard command-line flag definitions
-const char BaculaSilent[]                = "/silent";
+const char BaculaOptDebug[]              = "/debug";
 
 const char BaculaRunService[]            = "/service";
 const char BaculaRunAsUserApp[]          = "/run";
@@ -61,7 +61,7 @@ const char BaculaRemoveService[]         = "/remove";
 const char BaculaShowHelp[]              = "/help";
 
 // Usage string
-const char BaculaUsageText[] = "Bacula [/silent] [/service] [/run] [/kill] [/install] [/remove] [/help]\n";
+const char BaculaUsageText[] = "Bacula [/debug] [/service] [/run] [/kill] [/install] [/remove] [/help]\n";
 
 void LogErrorMsg(char *msg, char *fname, int lineno);
 #define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__)
index a3f680eaf2f64a9a4301aa850ef8fb41f59cbb66..fbd1cabd7f9cee8b90257da3c9b0ea4da05c0c84 100644 (file)
@@ -31,10 +31,10 @@ extern BOOL ReportStatus(DWORD state, DWORD exitcode, DWORD waithint);
 extern void d_msg(const char *, int, int, const char *, ...);
 
 /* Globals */
-HINSTANCE       hAppInstance;
-const char      *szAppName = "Bacula-dir";
-DWORD           mainthreadId;
-bool            silent = false;
+HINSTANCE      hAppInstance;
+const char     *szAppName = "Bacula-dir";
+DWORD          mainthreadId;
+bool           opt_debug = false;
 
 /* Imported variables */
 extern DWORD    g_servicethread;
@@ -55,7 +55,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    char *szCmdLine = CmdLine;
    char *wordPtr, *tempPtr;
    int i, quote;
-   DWORD dwCharsWritten;
 
    /* Save the application instance and main thread id */
    hAppInstance = hInstance;
@@ -144,10 +143,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
       /* Now check for command-line arguments */
 
-      /* /silent install quietly -- no prompts */
-      if (strnicmp(&szCmdLine[i], BaculaSilent, sizeof(BaculaSilent) - 1) == 0) {
-         silent = true;
-         i += sizeof(BaculaSilent) - 1;
+      /* /debug install quietly -- no prompts */
+      if (strnicmp(&szCmdLine[i], BaculaOptDebug, sizeof(BaculaOptDebug) - 1) == 0) {
+         opt_debug = true;
+         i += sizeof(BaculaOptDebug) - 1;
          continue;
       }
 
@@ -159,11 +158,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       /* /run  (this is the default if no command line arguments) */
       if (strnicmp(&szCmdLine[i], BaculaRunAsUserApp, sizeof(BaculaRunAsUserApp) - 1) == 0) {
          /* Bacula is being run as a user-level program */
-         if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-            AllocConsole();
-         }
-         WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
          return BaculaAppMain();
       }
       /* /install */
@@ -196,12 +190,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       return 1;
    }
 
-   /* If no arguments were given then just run */
-   if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-      AllocConsole();
-   }
-   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
    return BaculaAppMain();
 }
 
@@ -258,11 +246,20 @@ int BaculaAppMain()
 {
  /* DWORD dwThreadID; */
    pthread_t tid;
+   DWORD dwCharsWritten;
 
    InitWinAPIWrapper();
 
    WSA_Init();
 
+   /* If no arguments were given then just run */
+   if (p_AttachConsole == NULL || !p_AttachConsole(ATTACH_PARENT_PROCESS)) {
+      if (opt_debug) {
+         AllocConsole();
+      }
+   }
+   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
+
    /* Set this process to be the last application to be shut down. */
    if (p_SetProcessShutdownParameters) {
       p_SetProcessShutdownParameters(0x100, 0);
index e9169b72fe9e502bd05e7e0c4c1cc143c7b89181..1b71b617b55c38470b74f060a2e53ef080f76298 100644 (file)
@@ -51,7 +51,7 @@ void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
 
 bacService init;
 
-extern bool    silent;
+extern bool    opt_debug;
 
 // SERVICE-MODE ROUTINES
 
@@ -267,7 +267,7 @@ _("Provides director services. Bacula -- the network backup solution."));
    CloseServiceHandle(hservice);
 
    // Everything went fine
-   if (!silent) {
+   if (opt_debug) {
       MessageBox(NULL,
               _("The Bacula Director service was successfully installed.\n"
               "The service may be started from the Control Panel and will\n"
@@ -314,7 +314,7 @@ bacService::RemoveService()
 
          // Now remove the service from the SCM
          if(DeleteService(hservice)) {
-            if (!silent) {
+            if (opt_debug) {
                MessageBox(NULL, _("The Bacula Director service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
             }
          } else {
index f87c6d57c781aa5a26cdd162c3cd55e541ba5ac8..328fc9d86ef73ff76971b6182f201b49892edd2a 100644 (file)
@@ -198,14 +198,17 @@ VSSClientGeneric::~VSSClientGeneric()
 BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore)
 {
    if (!(p_CreateVssBackupComponents && p_VssFreeSnapshotProperties)) {
+      Dmsg2(0, "VSSClientGeneric::Initialize: p_CreateVssBackupComponents = 0x%08X, p_VssFreeSnapshotProperties = 0x%08X\n", p_CreateVssBackupComponents, p_VssFreeSnapshotProperties);
       errno = ENOSYS;
       return FALSE;
    }
 
    HRESULT hr;
-   // Initialize COM 
-   if (!m_bCoInitializeCalled)  {
-      if (FAILED(CoInitialize(NULL))) {
+   // Initialize COM
+   if (!m_bCoInitializeCalled) {
+      hr = CoInitialize(NULL);
+      if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: CoInitialize returned 0x%08X\n", hr);
          errno = b_errno_win32;
          return FALSE;
       }
@@ -227,13 +230,14 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore)
          NULL                            //  Reserved parameter
          );
 
-      if (FAILED(hr)) {         
+      if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: CoInitializeSecurity returned 0x%08X\n", hr);
          errno = b_errno_win32;
          return FALSE;
       }
-      m_bCoInitializeSecurityCalled = true;      
+      m_bCoInitializeSecurityCalled = true;
    }
-   
+
    // Release the IVssBackupComponents interface 
    if (m_pVssObject) {
       m_pVssObject->Release();
@@ -242,7 +246,8 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore)
 
    // Create the internal backup components object
    hr = p_CreateVssBackupComponents((IVssBackupComponents**) &m_pVssObject);
-   if (FAILED(hr)) {      
+   if (FAILED(hr)) {
+      Dmsg1(0, "VSSClientGeneric::Initialize: CreateVssBackupComponents returned 0x%08X\n", hr);
       errno = b_errno_win32;
       return FALSE;
    }
@@ -251,6 +256,7 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore)
    if (dwContext != VSS_CTX_BACKUP) {
       hr = ((IVssBackupComponents*) m_pVssObject)->SetContext(dwContext);
       if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetContext returned 0x%08X\n", hr);
          errno = b_errno_win32;
          return FALSE;
       }
@@ -258,31 +264,33 @@ BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL bDuringRestore)
 #endif
 
    if (!bDuringRestore) {
-       // 1. InitializeForBackup
-       hr = ((IVssBackupComponents*) m_pVssObject)->InitializeForBackup();
-       if (FAILED(hr)) {
-           errno = b_errno_win32; 
-           return FALSE;
-       }
+      // 1. InitializeForBackup
+      hr = ((IVssBackupComponents*) m_pVssObject)->InitializeForBackup();
+      if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->InitializeForBackup returned 0x%08X\n", hr);
+         errno = b_errno_win32; 
+         return FALSE;
+      }
  
-       // 2. SetBackupState
-       hr = ((IVssBackupComponents*) m_pVssObject)->SetBackupState(true, true, VSS_BT_FULL, false);
-       if (FAILED(hr)) {
-           errno = b_errno_win32;
-           return FALSE;
-       }
-       
-       CComPtr<IVssAsync>  pAsync1;       
-       // 3. GatherWriterMetaData
-       hr = ((IVssBackupComponents*) m_pVssObject)->GatherWriterMetadata(&pAsync1.p);
-       if (FAILED(hr)) {
-           errno = b_errno_win32;
-           return FALSE;
-       }
-        // Waits for the async operation to finish and checks the result
-       WaitAndCheckForAsyncOperation(pAsync1.p);
-   }
+      // 2. SetBackupState
+      hr = ((IVssBackupComponents*) m_pVssObject)->SetBackupState(true, true, VSS_BT_FULL, false);
+      if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->SetBackupState returned 0x%08X\n", hr);
+         errno = b_errno_win32;
+         return FALSE;
+      }
 
+      CComPtr<IVssAsync>  pAsync1;
+      // 3. GatherWriterMetaData
+      hr = ((IVssBackupComponents*) m_pVssObject)->GatherWriterMetadata(&pAsync1.p);
+      if (FAILED(hr)) {
+         Dmsg1(0, "VSSClientGeneric::Initialize: IVssBackupComponents->GatherWriterMetadata returned 0x%08X\n", hr);
+         errno = b_errno_win32;
+         return FALSE;
+      }
+      // Waits for the async operation to finish and checks the result
+      WaitAndCheckForAsyncOperation(pAsync1.p);
+   }
 
    // We are during restore now?
    m_bDuringRestore = bDuringRestore;
@@ -610,7 +618,7 @@ BOOL VSSClientGeneric::CheckWriterStatus()
         bstrncpy(str, "\"", sizeof(str));
         wchar_2_UTF8(szBuf, bstrWriterName.p, sizeof(szBuf));
         bstrncat(str, szBuf, sizeof(str));
-        bstrncat(str, "\", State: 0x",sizeof(str));
+        bstrncat(str, "\", State: 0x", sizeof(str));
         itoa(eWriterStatus, szBuf, sizeof(szBuf));
         bstrncat(str, szBuf, sizeof(str));
         bstrncat(str, " (", sizeof(str));
index 85b941cc94b52e23b419a0a354ac10598f57a95f..5b540af89c8ecf714b5f1e4a7d37a175bd018a66 100644 (file)
@@ -36,7 +36,7 @@ extern void VSSInit();
 HINSTANCE       hAppInstance;
 const char      *szAppName = "Bacula-fd";
 DWORD           mainthreadId;
-bool            silent = false;
+bool            opt_debug = false;
 
 /* Imported variables */
 extern DWORD    g_servicethread;
@@ -57,7 +57,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    char *szCmdLine = CmdLine;
    char *wordPtr, *tempPtr;
    int i, quote;
-   DWORD dwCharsWritten;
 
    /* Save the application instance and main thread id */
    hAppInstance = hInstance;
@@ -86,7 +85,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    if (*szCmdLine != '"' && *wordPtr == '"') {
       szCmdLine = wordPtr + 1;
    }
-// MessageBox(NULL, szCmdLine, "Cmdline", MB_OK);
 
    /* Build Unix style argc *argv[] */      
 
@@ -147,10 +145,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
       /* Now check for command-line arguments */
 
-      /* /silent install quietly -- no prompts */
-      if (strnicmp(&szCmdLine[i], BaculaSilent, sizeof(BaculaSilent) - 1) == 0) {
-         silent = true;
-         i += sizeof(BaculaSilent) - 1;
+      /* /debug - enable debugging facilities such as console message window */
+      if (strnicmp(&szCmdLine[i], BaculaOptDebug, sizeof(BaculaOptDebug) - 1) == 0) {
+         opt_debug = true;
+         i += sizeof(BaculaOptDebug) - 1;
          continue;
       }
 
@@ -162,11 +160,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       /* /run  (this is the default if no command line arguments) */
       if (strnicmp(&szCmdLine[i], BaculaRunAsUserApp, sizeof(BaculaRunAsUserApp) - 1) == 0) {
          /* Bacula is being run as a user-level program */
-         if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-            AllocConsole();
-         }
-         WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
          return BaculaAppMain();
       }
       /* /install */
@@ -212,12 +205,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       return 1;
    }
 
-   /* If no arguments were given then just run */
-   if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-      AllocConsole();
-   }
-   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
    return BaculaAppMain();
 }
 
@@ -231,7 +218,6 @@ void *Main_Msg_Loop(LPVOID lpwThreadParam)
 {
    DWORD old_servicethread = g_servicethread;
 
-
    pthread_detach(pthread_self());
 
    /* Since we are the only thread with a message loop
@@ -286,8 +272,18 @@ int BaculaAppMain()
 {
  /* DWORD dwThreadID; */
    pthread_t tid;
+   DWORD dwCharsWritten;
 
    InitWinAPIWrapper();
+
+   /* If no arguments were given then just run */
+   if (p_AttachConsole == NULL || !p_AttachConsole(ATTACH_PARENT_PROCESS)) {
+      if (opt_debug) {
+         AllocConsole();
+      }
+   }
+   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
+
    VSSInit();
 
    WSA_Init();
index ed5054f4f3f5d812f556865ce19b1f3161a49388..f6ec888c97711d071836979f45ab055c0973182f 100644 (file)
@@ -52,7 +52,7 @@ void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
 
 bacService init;
 
-extern bool    silent;
+extern bool    opt_debug;
 
 bacService::bacService()
 {
@@ -369,7 +369,7 @@ bacService::InstallService(const char *pszCmdLine)
       RegCloseKey(runservices);
 
       // We have successfully installed the service!
-      if (!silent) {
+      if (opt_debug) {
          MessageBox(NULL,
               _("The Bacula File service was successfully installed.\n"
               "The service may be started by double clicking on the\n"
@@ -427,7 +427,7 @@ _("Provides file backup and restore services. Bacula -- the network backup solut
       CloseServiceHandle(hservice);
 
       // Everything went fine
-      if (!silent) {
+      if (opt_debug) {
          MessageBox(NULL,
               _("The Bacula File service was successfully installed.\n"
               "The service may be started from the Control Panel and will\n"
@@ -485,7 +485,7 @@ bacService::RemoveService()
       }
 
       // We have successfully removed the service!
-      if (!silent) {
+      if (opt_debug) {
          MessageBox(NULL, _("The Bacula service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
       }
       break;
@@ -523,7 +523,7 @@ bacService::RemoveService()
 
             // Now remove the service from the SCM
             if (DeleteService(hservice)) {
-               if (!silent) {
+               if (opt_debug) {
                   MessageBox(NULL, _("The Bacula file service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
                }
             } else {
index 8de4b90976096c553f2b5e7674fbe4f43e489240..5a80af1e01116493b742ec694248c326f5092e9f 100644 (file)
@@ -533,27 +533,21 @@ Section "-Initialize"
   ${EndIf}
 
   ${If} ${FileExists} "$OldInstallDir\bin\bacula-fd.exe"
-    ${If} $InstallType <> ${MigrateInstall}
-      nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /silent /kill'     ; Shutdown any bacula that could be running
-      Sleep 3000
-      nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /silent /remove'   ; Remove existing service
-    ${Else}
-      nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /kill'     ; Shutdown any bacula that could be running
-      Sleep 3000
-      nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /remove'   ; Remove existing service
-    ${EndIf}
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /kill'     ; Shutdown any bacula that could be running
+    Sleep 3000
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-fd.exe" /remove'   ; Remove existing service
   ${EndIf}
 
   ${If} ${FileExists} "$OldInstallDir\bin\bacula-sd.exe"
-    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /silent /kill'     ; Shutdown any bacula that could be running
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /kill'     ; Shutdown any bacula that could be running
     Sleep 3000
-    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /silent /remove'   ; Remove existing service
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-sd.exe" /remove'   ; Remove existing service
   ${EndIf}
 
   ${If} ${FileExists} "$OldInstallDir\bin\bacula-dir.exe"
-    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /silent /kill'     ; Shutdown any bacula that could be running
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /kill'     ; Shutdown any bacula that could be running
     Sleep 3000
-    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /silent /remove'   ; Remove existing service
+    nsExec::ExecToLog '"$OldInstallDir\bin\bacula-dir.exe" /remove'   ; Remove existing service
   ${EndIf}
 
 SectionEnd
@@ -865,27 +859,27 @@ UninstallText "This will uninstall Bacula. Hit next to continue."
 
 Section "Uninstall"
   ; Shutdown any baculum that could be running
-  nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /silent /kill'
-  nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /silent /kill'
-  nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /silent /kill'
+  nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /kill'
+  nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /kill'
+  nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /kill'
   Sleep 3000
 
   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-fd"
   ${If} $R0 = 1
     ; Remove bacula service
-    nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /silent /remove'
+    nsExec::ExecToLog '"$INSTDIR\bin\bacula-fd.exe" /remove'
   ${EndIf}
   
   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-sd"
   ${If} $R0 = 1
     ; Remove bacula service
-    nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /silent /remove'
+    nsExec::ExecToLog '"$INSTDIR\bin\bacula-sd.exe" /remove'
   ${EndIf}
   
   ReadRegDWORD $R0 HKLM "Software\Bacula" "Service_Bacula-dir"
   ${If} $R0 = 1
     ; Remove bacula service
-    nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /silent /remove'
+    nsExec::ExecToLog '"$INSTDIR\bin\bacula-dir.exe" /remove'
   ${EndIf}
   
   ; remove registry keys
@@ -930,14 +924,14 @@ Function InstallDaemon
   WriteRegDWORD HKLM "Software\Bacula" "Service_$0" $2
   
   ${If} $2 = 1
-    nsExec::ExecToLog '"$INSTDIR\bin\$0.exe" /silent /install -c "$APPDATA\Bacula\$0.conf"'
+    nsExec::ExecToLog '"$INSTDIR\bin\$0.exe" /install -c "$APPDATA\Bacula\$0.conf"'
 
     ${If} $OsIsNT <> 1
       File "Start.bat"
       File "Stop.bat"
     ${EndIf}
 
-    ; Start the service? (default skipped if silent, use /start to force starting)
+    ; Start the service?
 
     ${If} $3 = 1  
       ${If} $OsIsNT = 1
index 75b52997a16949b30708ea4b897f6f55ad49c6c4..e9d00418a424c9c620fc73a5184a0658dd0cce52 100644 (file)
@@ -47,8 +47,8 @@
                                RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
                                SuppressStartupBanner="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="4"\r
                        />\r
                        <Tool\r
                                SuppressStartupBanner="true"\r
                                AdditionalLibraryDirectories="..\..\..\..\depkgs-msvc\lib"\r
                                ModuleDefinitionFile="msvc\bacula.def"\r
-                               ImportLibrary="$(TargetDir)libbac.lib"\r
                                GenerateDebugInformation="true"\r
+                               ImportLibrary="$(TargetDir)libbac.lib"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\lib\protos.h"\r
+                               RelativePath="..\..\findlib\protos.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\findlib\protos.h"\r
+                               RelativePath="..\..\lib\protos.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\lib\watchdog.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\winapi.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\compat\winconfig.h"\r
                                >\r
index 7968b1da6af86396bf78fd6b7cbe7c466316f824..b1674cc662ab60f42843e244c0edc541f7a304c6 100644 (file)
@@ -49,7 +49,7 @@ extern int BaculaAppMain();
 extern void LogErrorMsg(char *msg);
 
 // Standard command-line flag definitions
-const char BaculaSilent[]                = "/silent";
+const char BaculaOptDebug[]              = "/debug";
 
 const char BaculaRunService[]            = "/service";
 const char BaculaRunAsUserApp[]          = "/run";
@@ -64,7 +64,7 @@ const char BaculaShowStatus[]            = "/status";
 const char BaculaShowHelp[]              = "/help";
 
 // Usage string
-const char BaculaUsageText[] = "Bacula [/silent] [/service] [/run] [/kill] [/install] [/remove] [/about] [/status] [/help]\n";
+const char BaculaUsageText[] = "Bacula [/debug] [/service] [/run] [/kill] [/install] [/remove] [/about] [/status] [/help]\n";
 
 void LogErrorMsg(char *msg, char *fname, int lineno);
 #define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__)
index 7968b1da6af86396bf78fd6b7cbe7c466316f824..b1674cc662ab60f42843e244c0edc541f7a304c6 100644 (file)
@@ -49,7 +49,7 @@ extern int BaculaAppMain();
 extern void LogErrorMsg(char *msg);
 
 // Standard command-line flag definitions
-const char BaculaSilent[]                = "/silent";
+const char BaculaOptDebug[]              = "/debug";
 
 const char BaculaRunService[]            = "/service";
 const char BaculaRunAsUserApp[]          = "/run";
@@ -64,7 +64,7 @@ const char BaculaShowStatus[]            = "/status";
 const char BaculaShowHelp[]              = "/help";
 
 // Usage string
-const char BaculaUsageText[] = "Bacula [/silent] [/service] [/run] [/kill] [/install] [/remove] [/about] [/status] [/help]\n";
+const char BaculaUsageText[] = "Bacula [/debug] [/service] [/run] [/kill] [/install] [/remove] [/about] [/status] [/help]\n";
 
 void LogErrorMsg(char *msg, char *fname, int lineno);
 #define log_error_message(msg) LogErrorMsg((msg), __FILE__, __LINE__)
index a42e02922052469923fb8ffcb5ef351fd4919f6e..b665df7934f6130b47247f38e8b28cc33d1f77ce 100644 (file)
@@ -35,7 +35,7 @@ extern void d_msg(const char *, int, int, const char *, ...);
 HINSTANCE       hAppInstance;
 const char      *szAppName = "Bacula-sd";
 DWORD           mainthreadId;
-bool            silent = false;
+bool            opt_debug = false;
 
 /* Imported variables */
 extern DWORD    g_servicethread;
@@ -56,7 +56,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    char *szCmdLine = CmdLine;
    char *wordPtr, *tempPtr;
    int i, quote;
-   DWORD dwCharsWritten;
 
    /* Save the application instance and main thread id */
    hAppInstance = hInstance;
@@ -145,10 +144,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
       /* Now check for command-line arguments */
 
-      /* /silent install quietly -- no prompts */
-      if (strnicmp(&szCmdLine[i], BaculaSilent, sizeof(BaculaSilent) - 1) == 0) {
-         silent = true;
-         i += sizeof(BaculaSilent) - 1;
+      /* /debug install quietly -- no prompts */
+      if (strnicmp(&szCmdLine[i], BaculaOptDebug, sizeof(BaculaOptDebug) - 1) == 0) {
+         opt_debug = true;
+         i += sizeof(BaculaOptDebug) - 1;
          continue;
       }
 
@@ -160,11 +159,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       /* /run  (this is the default if no command line arguments) */
       if (strnicmp(&szCmdLine[i], BaculaRunAsUserApp, sizeof(BaculaRunAsUserApp) - 1) == 0) {
          /* Bacula is being run as a user-level program */
-         if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-            AllocConsole();
-         }
-         WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
          return BaculaAppMain();
       }
       /* /install */
@@ -209,12 +203,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       return 1;
    }
 
-   /* If no arguments were given then just run */
-   if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
-      AllocConsole();
-   }
-   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
-
    return BaculaAppMain();
 }
 
@@ -283,11 +271,20 @@ int BaculaAppMain()
 {
  /* DWORD dwThreadID; */
    pthread_t tid;
+   DWORD dwCharsWritten;
 
    InitWinAPIWrapper();
 
    WSA_Init();
 
+   /* If no arguments were given then just run */
+   if (p_AttachConsole == NULL || !p_AttachConsole(ATTACH_PARENT_PROCESS)) {
+      if (opt_debug) {
+         AllocConsole();
+      }
+   }
+   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &dwCharsWritten, NULL);
+
    /* Set this process to be the last application to be shut down. */
    if (p_SetProcessShutdownParameters) {
       p_SetProcessShutdownParameters(0x100, 0);
index 7f3f0cbf57dc3ee5e26f34af7b731d71e22d1672..5e23337fcb65f80377f9f455c9b8e653165df099 100644 (file)
@@ -52,7 +52,7 @@ void set_service_description(SC_HANDLE hSCManager, SC_HANDLE hService,
 
 bacService init;
 
-extern bool    silent;
+extern bool    opt_debug;
 
 bacService::bacService()
 {
@@ -317,7 +317,7 @@ _("Provides storage services. Bacula -- the network backup solution."));
    CloseServiceHandle(hservice);
 
    // Everything went fine
-   if (!silent) {
+   if (opt_debug) {
       MessageBox(NULL,
               _("The Bacula Storage service was successfully installed.\n"
               "The service may be started from the Control Panel and will\n"
@@ -364,7 +364,7 @@ bacService::RemoveService()
 
          // Now remove the service from the SCM
          if(DeleteService(hservice)) {
-            if (!silent) {
+            if (opt_debug) {
                MessageBox(NULL, _("The Bacula Storage service has been removed"), szAppName, MB_ICONINFORMATION | MB_OK);
             }
          } else {
index fb79e55c4d29af5c3c99e09f22e561a8bd259cdf..5ccc2edba77b0c9b8f243238a9b191070d7be245 100644 (file)
@@ -121,7 +121,9 @@ typedef DWORD (WINAPI * t_GetCurrentDirectoryW) (DWORD, LPWSTR);
 
 typedef BOOL (WINAPI * t_GetVolumePathNameW) (LPCWSTR, LPWSTR, DWORD);
 typedef BOOL (WINAPI * t_GetVolumeNameForVolumeMountPointW) (LPCWSTR, LPWSTR, DWORD);
-  
+
+typedef BOOL (WINAPI * t_AttachConsole) (DWORD);
+
 extern t_GetFileAttributesA   DLL_IMP_EXP p_GetFileAttributesA;
 extern t_GetFileAttributesW   DLL_IMP_EXP p_GetFileAttributesW;
 
@@ -159,6 +161,8 @@ extern t_GetCurrentDirectoryW DLL_IMP_EXP p_GetCurrentDirectoryW;
 extern t_GetVolumePathNameW DLL_IMP_EXP p_GetVolumePathNameW;
 extern t_GetVolumeNameForVolumeMountPointW DLL_IMP_EXP p_GetVolumeNameForVolumeMountPointW;
 
+extern t_AttachConsole DLL_IMP_EXP p_AttachConsole;
+
 void InitWinAPIWrapper();
 #endif
 
index 6adce12512807b7f4e4dae9a72af6d21752eb525..9d00ef4aa7db96a49f5392655249015d85c30ce7 100644 (file)
@@ -216,9 +216,7 @@ wxString console_thread::LoadConfig(wxString configfile)
    MSGS* msgs = (MSGS *)bmalloc(sizeof(MSGS));
    memset(msgs, 0, sizeof(MSGS));
    for (int i=1; i<=M_MAX; i++) {
-#ifndef HAVE_WIN32
       add_msg_dest(msgs, MD_STDOUT, i, NULL, NULL);
-#endif
 //    add_msg_dest(msgs, MD_SYSLOG, i, NULL, NULL);
       add_msg_dest(msgs, MD_CONSOLE, i, NULL, NULL);
    }
index 17fdda22a02d2b1ecbc2cd8cb6e954375f025819..f17f9edbf3b31e24db6a635a21e71dc146669cf4 100644 (file)
@@ -4,6 +4,36 @@ General:
 11Oct06
 kes  Correct mtx-changer bug that I introduced in a recent commit, and
      pointed out by Robert Nelson -- thanks.
+rbn  Fix Windows' daemons so that messages print to stdout if not 
+     running as a service.
+rbn  Add daemon name to trace file name (eg bacula-dir.trace).
+rbn  Fix environment variable expansion in directory names on Windows.
+rbn  Fix autochanger support in fill command.
+rbn  Update SQL scripts to match Unix versions.
+rbn  Fix daemon usage displays.
+rbn  Cleanup bacula-dir.conf template.
+rbn  Install openssl.cnf so that the openssl.exe installed in the
+     Bacula\bin directory can be used to generate keys and 
+     certificates for TLS and encryption.
+rbn  Fix cleanup of spool files on Windows.
+rbn  Remove /silent option from daemons on Windows.  The new default 
+     is the same as the old /silent.  To enable the message boxes that 
+     previously were suppressed by /silent you must add /debug instead.
+     NOTE: As a result of this change, the first time you upgrade from 
+           a previous version of 1.39.x you will receive the message 
+           boxes when the remove of the old services succeeds.  This 
+           is the same behaviour as when migrating from a version prior 
+           to 1.39.0.
+     However, going forward, these message boxes will not appear on 
+     upgrades or new installs.
+rbn  Add new /debug option. This option enables the message boxes that 
+     previously were suppressed by the /silent option.  In addition the 
+     daemons running as services will open a console window if this 
+     option is used.
+rbn  Fix bug with service not being removed on migrated installs.  This 
+     should correct those cases where the file daemon install was failing
+     when upgrading from versions prior to 1.39.x.
+
 08Oct06
 kes  Turn on heap reporting in Dir with zero debug level.
 kes  Send a message to the sys log when Bacula forces a SEG FAULT, and
@@ -24,6 +54,12 @@ kes  Modify the autochanger loaded?, load, and unload commands to print
 kes  Correct a few Win32 errno returns in the VSS code so that hopefully
      a resonable Win32 error message will be printed.
 kes  Convert a few strcat()... to bstrncat() in the Win32 code.
+06Oct06
+rbn  Added Windows version of bsmtp.
+rbn  Fixed path search for Windows so that Bacula\bin is automatically 
+     searched for programs and scripts.
+rbn  Fixed bugs in mtx-changer.cmd and made template bacula-sd.conf
+     Windows specific.
 
 Version 1.39.24 released:
 02Oct06