Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
7eca4fa0
Kaydet (Commit)
7eca4fa0
authored
Ara 27, 2016
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
get the update service working
Change-Id: I25921090083f20c4bb416f9cfdd5ec6400a27a21
üst
19066caf
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
222 additions
and
66 deletions
+222
-66
Repository.mk
Repository.mk
+3
-0
Executable_update_service.mk
onlineupdate/Executable_update_service.mk
+28
-0
Module_onlineupdate.mk
onlineupdate/Module_onlineupdate.mk
+1
-0
certificatecheck.cxx
onlineupdate/source/service/certificatecheck.cxx
+0
-0
maintenanceservice.cxx
onlineupdate/source/service/maintenanceservice.cxx
+7
-3
registrycertificates.cxx
onlineupdate/source/service/registrycertificates.cxx
+43
-10
servicebase.cxx
onlineupdate/source/service/servicebase.cxx
+11
-12
servicebase.hxx
onlineupdate/source/service/servicebase.hxx
+1
-1
serviceinstall.cxx
onlineupdate/source/service/serviceinstall.cxx
+67
-27
windowsHelper.hxx
onlineupdate/source/service/windowsHelper.hxx
+48
-0
workmonitor.cxx
onlineupdate/source/service/workmonitor.cxx
+13
-13
No files found.
Repository.mk
Dosyayı görüntüle @
7eca4fa0
...
@@ -93,6 +93,9 @@ $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \
...
@@ -93,6 +93,9 @@ $(eval $(call gb_Helper_register_executables_for_install,SDK,sdk, \
$(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
$(eval $(call gb_Helper_register_executables_for_install,OOO,brand, \
$(if $(ENABLE_ONLINE_UPDATE_MAR),\
$(if $(ENABLE_ONLINE_UPDATE_MAR),\
mar \
mar \
$(if $(filter WNT,$(OS)), \
update_service \
) \
updater )\
updater )\
$(call gb_Helper_optional,BREAKPAD,minidump_upload) \
$(call gb_Helper_optional,BREAKPAD,minidump_upload) \
$(call gb_Helper_optional,FUZZERS,wmffuzzer) \
$(call gb_Helper_optional,FUZZERS,wmffuzzer) \
...
...
onlineupdate/Executable_update_service.mk
Dosyayı görüntüle @
7eca4fa0
...
@@ -9,16 +9,44 @@
...
@@ -9,16 +9,44 @@
$(eval $(call gb_Executable_Executable,update_service))
$(eval $(call gb_Executable_Executable,update_service))
$(eval $(call gb_Executable_set_targettype_gui,update_service,YES))
$(eval $(call gb_Executable_set_include,update_service,\
$(eval $(call gb_Executable_set_include,update_service,\
-I$(SRCDIR)/onlineupdate/source/libmar/src/ \
-I$(SRCDIR)/onlineupdate/source/libmar/src/ \
-I$(SRCDIR)/onlineupdate/source/libmar/verify/ \
-I$(SRCDIR)/onlineupdate/source/libmar/verify/ \
-I$(SRCDIR)/onlineupdate/source/libmar/sign/ \
-I$(SRCDIR)/onlineupdate/source/libmar/sign/ \
-I$(SRCDIR)/onlineupdate/source/update/common/ \
$$(INCLUDE) \
$$(INCLUDE) \
))
))
$(eval $(call gb_Executable_use_static_libraries,update_service,\
updatehelper \
winhelper \
))
$(eval $(call gb_Executable_add_libs,update_service,\
$(eval $(call gb_Executable_add_libs,update_service,\
ws2_32.lib \
ws2_32.lib \
Crypt32.lib \
Crypt32.lib \
shell32.lib \
wintrust.lib \
version.lib \
wtsapi32.lib \
userenv.lib \
shlwapi.lib \
ole32.lib \
rpcrt4.lib \
comctl32.lib \
shlwapi.lib \
kernel32.lib \
advapi32.lib \
))
$(eval $(call gb_Executable_add_defs,update_service,\
-DUNICODE \
))
$(eval $(call gb_Executable_add_ldflags,update_service,\
/ENTRY:wmainCRTStartup \
))
))
$(eval $(call gb_Executable_add_cxxobjects,update_service,\
$(eval $(call gb_Executable_add_cxxobjects,update_service,\
...
...
onlineupdate/Module_onlineupdate.mk
Dosyayı görüntüle @
7eca4fa0
...
@@ -18,6 +18,7 @@ $(eval $(call gb_Module_add_targets,onlineupdate,\
...
@@ -18,6 +18,7 @@ $(eval $(call gb_Module_add_targets,onlineupdate,\
StaticLibrary_winhelper )\
StaticLibrary_winhelper )\
Executable_mar \
Executable_mar \
Executable_updater \
Executable_updater \
Executable_update_service \
))
))
endif
endif
...
...
onlineupdate/source/service/certificatecheck.cxx
Dosyayı görüntüle @
7eca4fa0
onlineupdate/source/service/maintenanceservice.cxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -12,8 +12,8 @@
...
@@ -12,8 +12,8 @@
#include "maintenanceservice.hxx"
#include "maintenanceservice.hxx"
#include "servicebase.hxx"
#include "servicebase.hxx"
#include "workmonitor.hxx"
#include "workmonitor.hxx"
#include "uachelper.h
xx
"
#include "uachelper.h"
#include "updatehelper.h
xx
"
#include "updatehelper.h"
// Link w/ subsystem window so we don't get a console when executing
// Link w/ subsystem window so we don't get a console when executing
// this binary through the installer.
// this binary through the installer.
...
@@ -33,6 +33,11 @@ BOOL GetLogDirectoryPath(WCHAR *path);
...
@@ -33,6 +33,11 @@ BOOL GetLogDirectoryPath(WCHAR *path);
int
int
wmain
(
int
argc
,
WCHAR
**
argv
)
wmain
(
int
argc
,
WCHAR
**
argv
)
{
{
if
(
argc
<
2
)
{
LOG_WARN
((
"missing mandatory command line argument"
));
return
1
;
}
// If command-line parameter is "install", install the service
// If command-line parameter is "install", install the service
// or upgrade if already installed
// or upgrade if already installed
// If command line parameter is "forceinstall", install the service
// If command line parameter is "forceinstall", install the service
...
@@ -218,7 +223,6 @@ EnsureProcessTerminatedThread(LPVOID)
...
@@ -218,7 +223,6 @@ EnsureProcessTerminatedThread(LPVOID)
{
{
Sleep
(
5000
);
Sleep
(
5000
);
exit
(
0
);
exit
(
0
);
return
0
;
}
}
void
void
...
...
onlineupdate/source/service/registrycertificates.cxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -6,13 +6,46 @@
...
@@ -6,13 +6,46 @@
#include <stdlib.h>
#include <stdlib.h>
#include <windows.h>
#include <windows.h>
#include <memory>
#include "registrycertificates.hxx"
#include "registrycertificates.hxx"
#include "pathhash.hxx"
#include "pathhash.h"
#include "nsWindowsHelpers.hxx"
#include "servicebase.hxx"
#include "servicebase.hxx"
#include "updatehelper.h
xx
"
#include "updatehelper.h"
#define MAX_KEY_LENGTH 255
#define MAX_KEY_LENGTH 255
namespace
{
struct
AutoRegKey
{
AutoRegKey
(
HKEY
key
)
:
mKey
(
key
)
{
}
~
AutoRegKey
()
{
releaseKey
(
mKey
);
}
void
releaseKey
(
HKEY
key
)
{
if
(
key
!=
nullptr
)
{
RegCloseKey
(
key
);
}
}
HKEY
mKey
;
HKEY
get
()
{
return
mKey
;
}
};
}
/**
/**
* Verifies if the file path matches any certificate stored in the registry.
* Verifies if the file path matches any certificate stored in the registry.
*
*
...
@@ -51,11 +84,11 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
...
@@ -51,11 +84,11 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
return
FALSE
;
return
FALSE
;
}
}
}
}
ns
AutoRegKey
baseKey
(
baseKeyRaw
);
AutoRegKey
baseKey
(
baseKeyRaw
);
// Get the number of subkeys.
// Get the number of subkeys.
DWORD
subkeyCount
=
0
;
DWORD
subkeyCount
=
0
;
retCode
=
RegQueryInfoKeyW
(
baseKey
,
nullptr
,
nullptr
,
nullptr
,
&
subkeyCount
,
retCode
=
RegQueryInfoKeyW
(
baseKey
.
get
()
,
nullptr
,
nullptr
,
nullptr
,
&
subkeyCount
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
);
nullptr
,
nullptr
);
if
(
retCode
!=
ERROR_SUCCESS
)
{
if
(
retCode
!=
ERROR_SUCCESS
)
{
...
@@ -67,7 +100,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
...
@@ -67,7 +100,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
for
(
DWORD
i
=
0
;
i
<
subkeyCount
;
i
++
)
{
for
(
DWORD
i
=
0
;
i
<
subkeyCount
;
i
++
)
{
WCHAR
subkeyBuffer
[
MAX_KEY_LENGTH
];
WCHAR
subkeyBuffer
[
MAX_KEY_LENGTH
];
DWORD
subkeyBufferCount
=
MAX_KEY_LENGTH
;
DWORD
subkeyBufferCount
=
MAX_KEY_LENGTH
;
retCode
=
RegEnumKeyExW
(
baseKey
,
i
,
subkeyBuffer
,
retCode
=
RegEnumKeyExW
(
baseKey
.
get
(),
i
,
subkeyBuffer
,
&
subkeyBufferCount
,
nullptr
,
&
subkeyBufferCount
,
nullptr
,
nullptr
,
nullptr
,
nullptr
);
nullptr
,
nullptr
,
nullptr
);
if
(
retCode
!=
ERROR_SUCCESS
)
{
if
(
retCode
!=
ERROR_SUCCESS
)
{
...
@@ -77,12 +110,12 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
...
@@ -77,12 +110,12 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
// Open the subkey for the current certificate
// Open the subkey for the current certificate
HKEY
subKeyRaw
;
HKEY
subKeyRaw
;
retCode
=
RegOpenKeyExW
(
baseKey
,
retCode
=
RegOpenKeyExW
(
baseKey
.
get
(),
subkeyBuffer
,
subkeyBuffer
,
0
,
0
,
KEY_READ
|
KEY_WOW64_64KEY
,
KEY_READ
|
KEY_WOW64_64KEY
,
&
subKeyRaw
);
&
subKeyRaw
);
ns
AutoRegKey
subKey
(
subKeyRaw
);
AutoRegKey
subKey
(
subKeyRaw
);
if
(
retCode
!=
ERROR_SUCCESS
)
{
if
(
retCode
!=
ERROR_SUCCESS
)
{
LOG_WARN
((
"Could not open subkey. (%d)"
,
retCode
));
LOG_WARN
((
"Could not open subkey. (%d)"
,
retCode
));
continue
;
// Try the next subkey
continue
;
// Try the next subkey
...
@@ -94,7 +127,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
...
@@ -94,7 +127,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
WCHAR
issuer
[
MAX_CHAR_COUNT
]
=
{
L'\0'
};
WCHAR
issuer
[
MAX_CHAR_COUNT
]
=
{
L'\0'
};
// Get the name from the registry
// Get the name from the registry
retCode
=
RegQueryValueExW
(
subKey
,
L"name"
,
0
,
nullptr
,
retCode
=
RegQueryValueExW
(
subKey
.
get
(),
L"name"
,
0
,
nullptr
,
(
LPBYTE
)
name
,
&
valueBufSize
);
(
LPBYTE
)
name
,
&
valueBufSize
);
if
(
retCode
!=
ERROR_SUCCESS
)
{
if
(
retCode
!=
ERROR_SUCCESS
)
{
LOG_WARN
((
"Could not obtain name from registry. (%d)"
,
retCode
));
LOG_WARN
((
"Could not obtain name from registry. (%d)"
,
retCode
));
...
@@ -103,7 +136,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
...
@@ -103,7 +136,7 @@ DoesBinaryMatchAllowedCertificates(LPCWSTR basePathForUpdate, LPCWSTR filePath)
// Get the issuer from the registry
// Get the issuer from the registry
valueBufSize
=
MAX_CHAR_COUNT
*
sizeof
(
WCHAR
);
valueBufSize
=
MAX_CHAR_COUNT
*
sizeof
(
WCHAR
);
retCode
=
RegQueryValueExW
(
subKey
,
L"issuer"
,
0
,
nullptr
,
retCode
=
RegQueryValueExW
(
subKey
.
get
(),
L"issuer"
,
0
,
nullptr
,
(
LPBYTE
)
issuer
,
&
valueBufSize
);
(
LPBYTE
)
issuer
,
&
valueBufSize
);
if
(
retCode
!=
ERROR_SUCCESS
)
{
if
(
retCode
!=
ERROR_SUCCESS
)
{
LOG_WARN
((
"Could not obtain issuer from registry. (%d)"
,
retCode
));
LOG_WARN
((
"Could not obtain issuer from registry. (%d)"
,
retCode
));
...
...
onlineupdate/source/service/servicebase.cxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -3,10 +3,9 @@
...
@@ -3,10 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "servicebase.hxx"
#include "servicebase.hxx"
#include "
nsWindowsHelpers
.hxx"
#include "
windowsHelper
.hxx"
// Shared code between applications and updater.exe
// Shared code between applications and updater.exe
#include "nsWindowsRestart.cpp"
/**
/**
* Verifies if 2 files are byte for byte equivalent.
* Verifies if 2 files are byte for byte equivalent.
...
@@ -20,19 +19,19 @@ BOOL
...
@@ -20,19 +19,19 @@ BOOL
VerifySameFiles
(
LPCWSTR
file1Path
,
LPCWSTR
file2Path
,
BOOL
&
sameContent
)
VerifySameFiles
(
LPCWSTR
file1Path
,
LPCWSTR
file2Path
,
BOOL
&
sameContent
)
{
{
sameContent
=
FALSE
;
sameContent
=
FALSE
;
nsAutoHandle
file1
(
CreateFileW
(
file1Path
,
GENERIC_READ
,
FILE_SHARE_READ
,
AutoHandle
file1
(
CreateFileW
(
file1Path
,
GENERIC_READ
,
FILE_SHARE_READ
,
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
if
(
INVALID_HANDLE_VALUE
==
file1
)
{
if
(
file1
==
INVALID_HANDLE_VALUE
)
{
return
FALSE
;
return
FALSE
;
}
}
nsAutoHandle
file2
(
CreateFileW
(
file2Path
,
GENERIC_READ
,
FILE_SHARE_READ
,
AutoHandle
file2
(
CreateFileW
(
file2Path
,
GENERIC_READ
,
FILE_SHARE_READ
,
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
if
(
INVALID_HANDLE_VALUE
==
file2
)
{
if
(
file2
==
INVALID_HANDLE_VALUE
)
{
return
FALSE
;
return
FALSE
;
}
}
DWORD
fileSize1
=
GetFileSize
(
file1
,
nullptr
);
DWORD
fileSize1
=
GetFileSize
(
file1
.
get
()
,
nullptr
);
DWORD
fileSize2
=
GetFileSize
(
file2
,
nullptr
);
DWORD
fileSize2
=
GetFileSize
(
file2
.
get
()
,
nullptr
);
if
(
INVALID_FILE_SIZE
==
fileSize1
||
INVALID_FILE_SIZE
==
fileSize2
)
{
if
(
INVALID_FILE_SIZE
==
fileSize1
||
INVALID_FILE_SIZE
==
fileSize2
)
{
return
FALSE
;
return
FALSE
;
}
}
...
@@ -48,12 +47,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
...
@@ -48,12 +47,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
DWORD
leftOver
=
fileSize1
%
COMPARE_BLOCKSIZE
;
DWORD
leftOver
=
fileSize1
%
COMPARE_BLOCKSIZE
;
DWORD
readAmount
;
DWORD
readAmount
;
for
(
DWORD
i
=
0
;
i
<
numBlocks
;
i
++
)
{
for
(
DWORD
i
=
0
;
i
<
numBlocks
;
i
++
)
{
if
(
!
ReadFile
(
file1
,
buf1
,
COMPARE_BLOCKSIZE
,
&
readAmount
,
nullptr
)
||
if
(
!
ReadFile
(
file1
.
get
()
,
buf1
,
COMPARE_BLOCKSIZE
,
&
readAmount
,
nullptr
)
||
readAmount
!=
COMPARE_BLOCKSIZE
)
{
readAmount
!=
COMPARE_BLOCKSIZE
)
{
return
FALSE
;
return
FALSE
;
}
}
if
(
!
ReadFile
(
file2
,
buf2
,
COMPARE_BLOCKSIZE
,
&
readAmount
,
nullptr
)
||
if
(
!
ReadFile
(
file2
.
get
()
,
buf2
,
COMPARE_BLOCKSIZE
,
&
readAmount
,
nullptr
)
||
readAmount
!=
COMPARE_BLOCKSIZE
)
{
readAmount
!=
COMPARE_BLOCKSIZE
)
{
return
FALSE
;
return
FALSE
;
}
}
...
@@ -65,12 +64,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
...
@@ -65,12 +64,12 @@ VerifySameFiles(LPCWSTR file1Path, LPCWSTR file2Path, BOOL &sameContent)
}
}
if
(
leftOver
)
{
if
(
leftOver
)
{
if
(
!
ReadFile
(
file1
,
buf1
,
leftOver
,
&
readAmount
,
nullptr
)
||
if
(
!
ReadFile
(
file1
.
get
()
,
buf1
,
leftOver
,
&
readAmount
,
nullptr
)
||
readAmount
!=
leftOver
)
{
readAmount
!=
leftOver
)
{
return
FALSE
;
return
FALSE
;
}
}
if
(
!
ReadFile
(
file2
,
buf2
,
leftOver
,
&
readAmount
,
nullptr
)
||
if
(
!
ReadFile
(
file2
.
get
()
,
buf2
,
leftOver
,
&
readAmount
,
nullptr
)
||
readAmount
!=
leftOver
)
{
readAmount
!=
leftOver
)
{
return
FALSE
;
return
FALSE
;
}
}
...
...
onlineupdate/source/service/servicebase.hxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <windows.h>
#include <windows.h>
#include "updatelogging.h
xx
"
#include "updatelogging.h"
BOOL
PathAppendSafe
(
LPWSTR
base
,
LPCWSTR
extra
);
BOOL
PathAppendSafe
(
LPWSTR
base
,
LPCWSTR
extra
);
BOOL
VerifySameFiles
(
LPCWSTR
file1Path
,
LPCWSTR
file2Path
,
BOOL
&
sameContent
);
BOOL
VerifySameFiles
(
LPCWSTR
file1Path
,
LPCWSTR
file2Path
,
BOOL
&
sameContent
);
...
...
onlineupdate/source/service/serviceinstall.cxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -10,18 +10,58 @@
...
@@ -10,18 +10,58 @@
// Used for DNLEN and UNLEN
// Used for DNLEN and UNLEN
#include <lm.h>
#include <lm.h>
#include <nsWindowsHelpers.h>
#include "mozilla/UniquePtr.h"
#include "serviceinstall.hxx"
#include "serviceinstall.hxx"
#include "servicebase.hxx"
#include "servicebase.hxx"
#include "updatehelper.hxx"
#include "updatehelper.h"
#include "shellapi.hxx"
#include "shellapi.h"
#include "readstrings.hxx"
#include "readstrings.h"
#include "errors.hxx"
#include "errors.h"
#include <memory>
#pragma comment(lib, "version.lib")
#pragma comment(lib, "version.lib")
namespace
{
struct
AutoServiceHandle
{
AutoServiceHandle
(
SC_HANDLE
handle
)
:
mHandle
(
handle
)
{
}
~
AutoServiceHandle
()
{
releaseHandle
(
mHandle
);
}
void
releaseHandle
(
SC_HANDLE
handle
)
{
if
(
handle
!=
nullptr
)
CloseServiceHandle
(
handle
);
}
SC_HANDLE
get
()
const
{
return
mHandle
;
}
operator
bool
()
const
{
return
mHandle
!=
nullptr
;
}
void
reset
(
SC_HANDLE
handle
=
nullptr
)
{
releaseHandle
(
mHandle
);
mHandle
=
handle
;
}
SC_HANDLE
mHandle
;
};
}
/**
/**
* A wrapper function to read strings for the maintenance service.
* A wrapper function to read strings for the maintenance service.
*
*
...
@@ -64,7 +104,7 @@ GetVersionNumberFromPath(LPWSTR path, DWORD &A, DWORD &B,
...
@@ -64,7 +104,7 @@ GetVersionNumberFromPath(LPWSTR path, DWORD &A, DWORD &B,
DWORD
&
C
,
DWORD
&
D
)
DWORD
&
C
,
DWORD
&
D
)
{
{
DWORD
fileVersionInfoSize
=
GetFileVersionInfoSizeW
(
path
,
0
);
DWORD
fileVersionInfoSize
=
GetFileVersionInfoSizeW
(
path
,
0
);
mozilla
::
UniqueP
tr
<
char
[]
>
fileVersionInfo
(
new
char
[
fileVersionInfoSize
]);
std
::
unique_p
tr
<
char
[]
>
fileVersionInfo
(
new
char
[
fileVersionInfoSize
]);
if
(
!
GetFileVersionInfoW
(
path
,
0
,
fileVersionInfoSize
,
if
(
!
GetFileVersionInfoW
(
path
,
0
,
fileVersionInfoSize
,
fileVersionInfo
.
get
()))
{
fileVersionInfo
.
get
()))
{
LOG_WARN
((
"Could not obtain file info of old service. (%d)"
,
LOG_WARN
((
"Could not obtain file info of old service. (%d)"
,
...
@@ -235,7 +275,7 @@ BOOL
...
@@ -235,7 +275,7 @@ BOOL
SvcInstall
(
SvcInstallAction
action
)
SvcInstall
(
SvcInstallAction
action
)
{
{
// Get a handle to the local computer SCM database with full access rights.
// Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
AutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
SC_MANAGER_ALL_ACCESS
));
SC_MANAGER_ALL_ACCESS
));
if
(
!
schSCManager
)
{
if
(
!
schSCManager
)
{
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
...
@@ -253,7 +293,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -253,7 +293,7 @@ SvcInstall(SvcInstallAction action)
}
}
// Check if we already have the service installed.
// Check if we already have the service installed.
nsAutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
,
AutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
.
get
(),
SVC_NAME
,
SVC_NAME
,
SERVICE_ALL_ACCESS
));
SERVICE_ALL_ACCESS
));
DWORD
lastError
=
GetLastError
();
DWORD
lastError
=
GetLastError
();
...
@@ -268,7 +308,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -268,7 +308,7 @@ SvcInstall(SvcInstallAction action)
// This could happen if the permissions were not set correctly originally
// This could happen if the permissions were not set correctly originally
// or have been changed after the installation. This will reset the
// or have been changed after the installation. This will reset the
// permissions back to allow limited user accounts.
// permissions back to allow limited user accounts.
if
(
!
SetUserAccessServiceDACL
(
schService
))
{
if
(
!
SetUserAccessServiceDACL
(
schService
.
get
()
))
{
LOG_WARN
((
"Could not reset security ACE on service handle. It might not be "
LOG_WARN
((
"Could not reset security ACE on service handle. It might not be "
"possible to start the service. This error should never "
"possible to start the service. This error should never "
"happen. (%d)"
,
GetLastError
()));
"happen. (%d)"
,
GetLastError
()));
...
@@ -276,7 +316,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -276,7 +316,7 @@ SvcInstall(SvcInstallAction action)
// The service exists and we opened it
// The service exists and we opened it
DWORD
bytesNeeded
;
DWORD
bytesNeeded
;
if
(
!
QueryServiceConfigW
(
schService
,
nullptr
,
0
,
&
bytesNeeded
)
&&
if
(
!
QueryServiceConfigW
(
schService
.
get
(),
nullptr
,
0
,
&
bytesNeeded
)
&&
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
{
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
)
{
LOG_WARN
((
"Could not determine buffer size for query service config. (%d)"
,
LOG_WARN
((
"Could not determine buffer size for query service config. (%d)"
,
GetLastError
()));
GetLastError
()));
...
@@ -285,8 +325,8 @@ SvcInstall(SvcInstallAction action)
...
@@ -285,8 +325,8 @@ SvcInstall(SvcInstallAction action)
// Get the service config information, in particular we want the binary
// Get the service config information, in particular we want the binary
// path of the service.
// path of the service.
mozilla
::
UniqueP
tr
<
char
[]
>
serviceConfigBuffer
(
new
char
[
bytesNeeded
]);
std
::
unique_p
tr
<
char
[]
>
serviceConfigBuffer
(
new
char
[
bytesNeeded
]);
if
(
!
QueryServiceConfigW
(
schService
,
if
(
!
QueryServiceConfigW
(
schService
.
get
(),
reinterpret_cast
<
QUERY_SERVICE_CONFIGW
*>
(
serviceConfigBuffer
.
get
()),
reinterpret_cast
<
QUERY_SERVICE_CONFIGW
*>
(
serviceConfigBuffer
.
get
()),
bytesNeeded
,
&
bytesNeeded
))
{
bytesNeeded
,
&
bytesNeeded
))
{
LOG_WARN
((
"Could open service but could not query service config. (%d)"
,
LOG_WARN
((
"Could open service but could not query service config. (%d)"
,
...
@@ -300,7 +340,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -300,7 +340,7 @@ SvcInstall(SvcInstallAction action)
BOOL
servicePathWasWrong
;
BOOL
servicePathWasWrong
;
static
BOOL
alreadyCheckedFixServicePath
=
FALSE
;
static
BOOL
alreadyCheckedFixServicePath
=
FALSE
;
if
(
!
alreadyCheckedFixServicePath
)
{
if
(
!
alreadyCheckedFixServicePath
)
{
if
(
!
FixServicePath
(
schService
,
serviceConfig
.
lpBinaryPathName
,
if
(
!
FixServicePath
(
schService
.
get
()
,
serviceConfig
.
lpBinaryPathName
,
servicePathWasWrong
))
{
servicePathWasWrong
))
{
LOG_WARN
((
"Could not fix service path. This should never happen. (%d)"
,
LOG_WARN
((
"Could not fix service path. This should never happen. (%d)"
,
GetLastError
()));
GetLastError
()));
...
@@ -353,7 +393,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -353,7 +393,7 @@ SvcInstall(SvcInstallAction action)
existingC
==
newC
&&
existingD
<
newD
))
{
existingC
==
newC
&&
existingD
<
newD
))
{
// We have a newer updater, so update the description from the INI file.
// We have a newer updater, so update the description from the INI file.
UpdateServiceDescription
(
schService
);
UpdateServiceDescription
(
schService
.
get
()
);
schService
.
reset
();
schService
.
reset
();
if
(
!
StopService
())
{
if
(
!
StopService
())
{
...
@@ -469,7 +509,7 @@ SvcInstall(SvcInstallAction action)
...
@@ -469,7 +509,7 @@ SvcInstall(SvcInstallAction action)
// Quote the path only if it contains spaces.
// Quote the path only if it contains spaces.
PathQuoteSpacesW
(
newServiceBinaryPath
);
PathQuoteSpacesW
(
newServiceBinaryPath
);
// The service does not already exist so create the service as on demand
// The service does not already exist so create the service as on demand
schService
.
own
(
CreateServiceW
(
schSCManager
,
SVC_NAME
,
SVC_DISPLAY_NAME
,
schService
.
reset
(
CreateServiceW
(
schSCManager
.
get
()
,
SVC_NAME
,
SVC_DISPLAY_NAME
,
SERVICE_ALL_ACCESS
,
SERVICE_WIN32_OWN_PROCESS
,
SERVICE_ALL_ACCESS
,
SERVICE_WIN32_OWN_PROCESS
,
SERVICE_DEMAND_START
,
SERVICE_ERROR_NORMAL
,
SERVICE_DEMAND_START
,
SERVICE_ERROR_NORMAL
,
newServiceBinaryPath
,
nullptr
,
nullptr
,
newServiceBinaryPath
,
nullptr
,
nullptr
,
...
@@ -481,14 +521,14 @@ SvcInstall(SvcInstallAction action)
...
@@ -481,14 +521,14 @@ SvcInstall(SvcInstallAction action)
return
FALSE
;
return
FALSE
;
}
}
if
(
!
SetUserAccessServiceDACL
(
schService
))
{
if
(
!
SetUserAccessServiceDACL
(
schService
.
get
()
))
{
LOG_WARN
((
"Could not set security ACE on service handle, the service will not "
LOG_WARN
((
"Could not set security ACE on service handle, the service will not "
"be able to be started from unelevated processes. "
"be able to be started from unelevated processes. "
"This error should never happen. (%d)"
,
"This error should never happen. (%d)"
,
GetLastError
()));
GetLastError
()));
}
}
UpdateServiceDescription
(
schService
);
UpdateServiceDescription
(
schService
.
get
()
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -502,7 +542,7 @@ BOOL
...
@@ -502,7 +542,7 @@ BOOL
StopService
()
StopService
()
{
{
// Get a handle to the local computer SCM database with full access rights.
// Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
AutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
SC_MANAGER_ALL_ACCESS
));
SC_MANAGER_ALL_ACCESS
));
if
(
!
schSCManager
)
{
if
(
!
schSCManager
)
{
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
...
@@ -510,7 +550,7 @@ StopService()
...
@@ -510,7 +550,7 @@ StopService()
}
}
// Open the service
// Open the service
nsAutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
,
SVC_NAME
,
AutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
.
get
(),
SVC_NAME
,
SERVICE_ALL_ACCESS
));
SERVICE_ALL_ACCESS
));
if
(
!
schService
)
{
if
(
!
schService
)
{
LOG_WARN
((
"Could not open service. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Could not open service. (%d)"
,
GetLastError
()));
...
@@ -520,7 +560,7 @@ StopService()
...
@@ -520,7 +560,7 @@ StopService()
LOG
((
"Sending stop request..."
));
LOG
((
"Sending stop request..."
));
SERVICE_STATUS
status
;
SERVICE_STATUS
status
;
SetLastError
(
ERROR_SUCCESS
);
SetLastError
(
ERROR_SUCCESS
);
if
(
!
ControlService
(
schService
,
SERVICE_CONTROL_STOP
,
&
status
)
&&
if
(
!
ControlService
(
schService
.
get
()
,
SERVICE_CONTROL_STOP
,
&
status
)
&&
GetLastError
()
!=
ERROR_SERVICE_NOT_ACTIVE
)
{
GetLastError
()
!=
ERROR_SERVICE_NOT_ACTIVE
)
{
LOG_WARN
((
"Error sending stop request. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Error sending stop request. (%d)"
,
GetLastError
()));
}
}
...
@@ -548,7 +588,7 @@ BOOL
...
@@ -548,7 +588,7 @@ BOOL
SvcUninstall
()
SvcUninstall
()
{
{
// Get a handle to the local computer SCM database with full access rights.
// Get a handle to the local computer SCM database with full access rights.
nsAutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
AutoServiceHandle
schSCManager
(
OpenSCManager
(
nullptr
,
nullptr
,
SC_MANAGER_ALL_ACCESS
));
SC_MANAGER_ALL_ACCESS
));
if
(
!
schSCManager
)
{
if
(
!
schSCManager
)
{
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Could not open service manager. (%d)"
,
GetLastError
()));
...
@@ -556,7 +596,7 @@ SvcUninstall()
...
@@ -556,7 +596,7 @@ SvcUninstall()
}
}
// Open the service
// Open the service
nsAutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
,
SVC_NAME
,
AutoServiceHandle
schService
(
OpenServiceW
(
schSCManager
.
get
(),
SVC_NAME
,
SERVICE_ALL_ACCESS
));
SERVICE_ALL_ACCESS
));
if
(
!
schService
)
{
if
(
!
schService
)
{
LOG_WARN
((
"Could not open service. (%d)"
,
GetLastError
()));
LOG_WARN
((
"Could not open service. (%d)"
,
GetLastError
()));
...
@@ -568,7 +608,7 @@ SvcUninstall()
...
@@ -568,7 +608,7 @@ SvcUninstall()
DWORD
totalWaitTime
=
0
;
DWORD
totalWaitTime
=
0
;
SERVICE_STATUS
status
;
SERVICE_STATUS
status
;
static
const
int
maxWaitTime
=
1000
*
60
;
// Never wait more than a minute
static
const
int
maxWaitTime
=
1000
*
60
;
// Never wait more than a minute
if
(
ControlService
(
schService
,
SERVICE_CONTROL_STOP
,
&
status
))
{
if
(
ControlService
(
schService
.
get
()
,
SERVICE_CONTROL_STOP
,
&
status
))
{
do
{
do
{
Sleep
(
status
.
dwWaitHint
);
Sleep
(
status
.
dwWaitHint
);
totalWaitTime
+=
(
status
.
dwWaitHint
+
10
);
totalWaitTime
+=
(
status
.
dwWaitHint
+
10
);
...
@@ -577,11 +617,11 @@ SvcUninstall()
...
@@ -577,11 +617,11 @@ SvcUninstall()
}
else
if
(
totalWaitTime
>
maxWaitTime
)
{
}
else
if
(
totalWaitTime
>
maxWaitTime
)
{
break
;
break
;
}
}
}
while
(
QueryServiceStatus
(
schService
,
&
status
));
}
while
(
QueryServiceStatus
(
schService
.
get
()
,
&
status
));
}
}
// Delete the service or mark it for deletion
// Delete the service or mark it for deletion
BOOL
deleted
=
DeleteService
(
schService
);
BOOL
deleted
=
DeleteService
(
schService
.
get
()
);
if
(
!
deleted
)
{
if
(
!
deleted
)
{
deleted
=
(
GetLastError
()
==
ERROR_SERVICE_MARKED_FOR_DELETE
);
deleted
=
(
GetLastError
()
==
ERROR_SERVICE_MARKED_FOR_DELETE
);
}
}
...
...
onlineupdate/source/service/windowsHelper.hxx
0 → 100644
Dosyayı görüntüle @
7eca4fa0
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_ONLINEUPDATE_SERVICE_WINDOWSHELPER_HXX
#define INCLUDED_ONLINEUPDATE_SERVICE_WINDOWSHELPER_HXX
struct
AutoHandle
{
AutoHandle
(
HANDLE
handle
)
:
mHandle
(
handle
)
{
}
~
AutoHandle
()
{
release
(
mHandle
);
}
void
release
(
HANDLE
handle
)
{
if
(
handle
&&
handle
!=
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
handle
);
}
}
HANDLE
get
()
const
{
return
mHandle
;
}
bool
operator
==
(
const
AutoHandle
&
rhs
)
{
return
mHandle
==
rhs
.
mHandle
;
}
HANDLE
mHandle
;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
onlineupdate/source/service/workmonitor.cxx
Dosyayı görüntüle @
7eca4fa0
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <wtsapi32.h>
#include <wtsapi32.h>
#include <userenv.h>
#include <userenv.h>
#include <shellapi.h>
#include <shellapi.h>
#include <cstddef>
#pragma comment(lib, "wtsapi32.lib")
#pragma comment(lib, "wtsapi32.lib")
#pragma comment(lib, "userenv.lib")
#pragma comment(lib, "userenv.lib")
...
@@ -14,21 +15,20 @@
...
@@ -14,21 +15,20 @@
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "rpcrt4.lib")
#pragma comment(lib, "rpcrt4.lib")
#include "nsWindowsHelpers.h"
#include "workmonitor.hxx"
#include "serviceinstall.hxx"
#include "workmonitor.h"
#include "servicebase.hxx"
#include "serviceinstall.h"
#include "registrycertificates.hxx"
#include "servicebase.h"
#include "registrycertificates.h"
#include "uachelper.h"
#include "uachelper.h"
#include "updatehelper.h"
#include "updatehelper.h"
#include "errors.h"
#include "errors.h"
#include "windowsHelper.hxx"
// Wait 15 minutes for an update operation to run at most.
// Wait 15 minutes for an update operation to run at most.
// Updates usually take less than a minute so this seems like a
// Updates usually take less than a minute so this seems like a
// significantly large and safe amount of time to wait.
// significantly large and safe amount of time to wait.
static
const
int
TIME_TO_WAIT_ON_UPDATER
=
15
*
60
*
1000
;
static
const
int
TIME_TO_WAIT_ON_UPDATER
=
15
*
60
*
1000
;
char16_t
*
MakeCommandLine
(
int
argc
,
char16
_t
**
argv
);
wchar_t
*
MakeCommandLine
(
int
argc
,
wchar
_t
**
argv
);
BOOL
WriteStatusFailure
(
LPCWSTR
updateDirPath
,
int
errorCode
);
BOOL
WriteStatusFailure
(
LPCWSTR
updateDirPath
,
int
errorCode
);
BOOL
PathGetSiblingFilePath
(
LPWSTR
destinationBuffer
,
LPCWSTR
siblingFilePath
,
BOOL
PathGetSiblingFilePath
(
LPWSTR
destinationBuffer
,
LPCWSTR
siblingFilePath
,
LPCWSTR
newFileName
);
LPCWSTR
newFileName
);
...
@@ -53,20 +53,20 @@ IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying)
...
@@ -53,20 +53,20 @@ IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying)
return
FALSE
;
return
FALSE
;
}
}
ns
AutoHandle
statusFile
(
CreateFileW
(
updateStatusFilePath
,
GENERIC_READ
,
AutoHandle
statusFile
(
CreateFileW
(
updateStatusFilePath
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
FILE_SHARE_DELETE
,
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
if
(
INVALID_HANDLE_VALUE
==
statusFile
)
{
if
(
statusFile
==
INVALID_HANDLE_VALUE
)
{
LOG_WARN
((
"Could not open update.status file"
));
LOG_WARN
((
"Could not open update.status file"
));
return
FALSE
;
return
FALSE
;
}
}
char
buf
[
32
]
=
{
0
};
char
buf
[
32
]
=
{
0
};
DWORD
read
;
DWORD
read
;
if
(
!
ReadFile
(
statusFile
,
buf
,
sizeof
(
buf
),
&
read
,
nullptr
))
{
if
(
!
ReadFile
(
statusFile
.
get
()
,
buf
,
sizeof
(
buf
),
&
read
,
nullptr
))
{
LOG_WARN
((
"Could not read from update.status file"
));
LOG_WARN
((
"Could not read from update.status file"
));
return
FALSE
;
return
FALSE
;
}
}
...
@@ -378,9 +378,9 @@ ProcessSoftwareUpdateCommand(DWORD argc, LPWSTR *argv)
...
@@ -378,9 +378,9 @@ ProcessSoftwareUpdateCommand(DWORD argc, LPWSTR *argv)
return
FALSE
;
return
FALSE
;
}
}
ns
AutoHandle
noWriteLock
(
CreateFileW
(
argv
[
0
],
GENERIC_READ
,
FILE_SHARE_READ
,
AutoHandle
noWriteLock
(
CreateFileW
(
argv
[
0
],
GENERIC_READ
,
FILE_SHARE_READ
,
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
nullptr
,
OPEN_EXISTING
,
0
,
nullptr
));
if
(
INVALID_HANDLE_VALUE
==
noWriteLock
)
{
if
(
noWriteLock
==
INVALID_HANDLE_VALUE
)
{
LOG_WARN
((
"Could not set no write sharing access on file. (%d)"
,
LOG_WARN
((
"Could not set no write sharing access on file. (%d)"
,
GetLastError
()));
GetLastError
()));
if
(
!
WriteStatusFailure
(
argv
[
1
],
if
(
!
WriteStatusFailure
(
argv
[
1
],
...
@@ -401,7 +401,7 @@ ProcessSoftwareUpdateCommand(DWORD argc, LPWSTR *argv)
...
@@ -401,7 +401,7 @@ ProcessSoftwareUpdateCommand(DWORD argc, LPWSTR *argv)
result
=
FALSE
;
result
=
FALSE
;
}
}
BOOL
updaterIsCorrect
;
BOOL
updaterIsCorrect
=
FALSE
;
if
(
result
&&
!
VerifySameFiles
(
argv
[
0
],
installDirUpdater
,
if
(
result
&&
!
VerifySameFiles
(
argv
[
0
],
installDirUpdater
,
updaterIsCorrect
))
{
updaterIsCorrect
))
{
LOG_WARN
((
"Error checking if the updaters are the same.
\n
"
LOG_WARN
((
"Error checking if the updaters are the same.
\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment