LibreOffice Module onlineupdate (master) 1
|
#include "bspatch.h"
#include "progressui.h"
#include "archivereader.h"
#include "readstrings.h"
#include "errors.h"
#include "bzlib.h"
#include <thread>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>
#include <algorithm>
#include <memory>
#include <config_version.h>
#include "updatelogging.h"
#include <onlineupdate/mozilla/Compiler.h>
#include <onlineupdate/mozilla/Types.h>
Go to the source code of this file.
Classes | |
class | AutoFile |
struct | MARChannelStringTable |
struct | copy_recursive_skiplist< N > |
class | Action |
class | RemoveFile |
class | RemoveDir |
class | AddFile |
class | PatchFile |
class | AddIfFile |
class | AddIfNotFile |
class | PatchIfFile |
class | ActionList |
Macros | |
#define | PROGRESS_PREPARE_SIZE 20.0f |
#define | PROGRESS_EXECUTE_SIZE 75.0f |
#define | PROGRESS_FINISH_SIZE 5.0f |
#define | SSIZE_MAX LONG_MAX |
#define | USE_EXECV |
#define | SKIPLIST_COUNT 3 |
Functions | |
static unsigned int | crc32 (const unsigned char *buf, unsigned int len) |
static NS_tchar * | mstrtok (const NS_tchar *delims, NS_tchar **str) |
static NS_tchar * | new_absolute_path (const NS_tchar *relpath) |
Converts a relative update path to an absolute path related to the working or install directory. More... | |
static const NS_tchar * | get_relative_offset (const NS_tchar *abs_path) |
Get a pointer in the absolute path, relative to the working or install directory. More... | |
static NS_tchar * | get_valid_path (NS_tchar **line, bool isdir=false) |
Gets the platform specific path and performs simple checks to the path. More... | |
static NS_tchar * | get_quoted_path (const NS_tchar *path) |
static void | ensure_write_permissions (const NS_tchar *path) |
static int | ensure_remove (const NS_tchar *path) |
static int | ensure_remove_recursive (const NS_tchar *path, bool continueEnumOnFailure=false) |
static bool | is_read_only (const NS_tchar *flags) |
static FILE * | ensure_open (const NS_tchar *path, const NS_tchar *flags, unsigned int options) |
static int | ensure_parent_dir (const NS_tchar *path) |
static int | ensure_copy_symlink (const NS_tchar *path, const NS_tchar *dest) |
static int | ensure_copy (const NS_tchar *path, const NS_tchar *dest) |
template<unsigned N> | |
static int | ensure_copy_recursive (const NS_tchar *path, const NS_tchar *dest, copy_recursive_skiplist< N > &skiplist) |
static int | rename_file (const NS_tchar *spath, const NS_tchar *dpath, bool allowDirs=false) |
static int | backup_create (const NS_tchar *path) |
static int | backup_restore (const NS_tchar *path, const NS_tchar *relPath) |
static int | backup_discard (const NS_tchar *path, const NS_tchar *relPath) |
static void | backup_finish (const NS_tchar *path, const NS_tchar *relPath, int status) |
static int | DoUpdate (ArchiveReader &ArchiveReader) |
static void | LaunchCallbackApp (const NS_tchar *workingDir, int argc, NS_tchar **argv, bool usingService) |
static bool | WriteStatusFile (const char *aStatus) |
static void | WriteStatusFile (int status) |
static int | CopyInstallDirToDestDir () |
static int | ProcessReplaceRequest () |
static int | GetUpdateFileNames (std::vector< tstring > &fileNames) |
static int | CheckSignature (ArchiveReader &archiveReader) |
static void | UpdateThreadFunc (void *) |
int | LaunchCallbackAndPostProcessApps (int argc, NS_tchar **argv, int callbackIndex) |
int | NS_main (int argc, NS_tchar **argv) |
int | add_dir_entries (const NS_tchar *dirpath, ActionList *list) |
static NS_tchar * | GetManifestContents (const NS_tchar *manifest) |
int | AddPreCompleteActions (ActionList *list) |
Variables | |
unsigned int | BZ2_crc32Table [256] |
static NS_tchar * | gPatchDirPath |
static NS_tchar | gInstallDirPath [MAXPATHLEN] |
static NS_tchar | gWorkingDirPath [MAXPATHLEN] |
static bool | gSucceeded = false |
static bool | sStagedUpdate = false |
static bool | sReplaceRequest = false |
static bool | sUsingService = false |
static const NS_tchar | kWhitespace [] = NS_T(" \t") |
static const NS_tchar | kNL [] = NS_T("\r\n") |
static const NS_tchar | kQuote [] = NS_T("\"") |
#define PROGRESS_EXECUTE_SIZE 75.0f |
Definition at line 81 of file updater.cxx.
#define PROGRESS_FINISH_SIZE 5.0f |
Definition at line 82 of file updater.cxx.
#define PROGRESS_PREPARE_SIZE 20.0f |
contents = 1*( line ) line = method LWS *( param LWS ) CRLF CRLF = "\r\n" LWS = 1*( " " | "\t" )
Available methods for the manifest file:
method = "add" | "add-if" | "patch" | "patch-if" | "remove" | "rmdir" | "rmrfdir" | type
'type' is the update type (e.g. complete or partial) and when present MUST be the first entry in the update manifest. The type is used to support downgrades by causing the actions defined in precomplete to be performed.
method = "add" | "add-if" | "add-if-not" | "patch" | "patch-if" | "remove" | "rmdir" | "rmrfdir" | type
'add-if-not' adds a file if it doesn't exist.
method = "remove" | "rmdir"
Definition at line 80 of file updater.cxx.
#define SKIPLIST_COUNT 3 |
#define SSIZE_MAX LONG_MAX |
Definition at line 107 of file updater.cxx.
#define USE_EXECV |
Definition at line 113 of file updater.cxx.
int add_dir_entries | ( | const NS_tchar * | dirpath, |
ActionList * | list | ||
) |
Definition at line 4213 of file updater.cxx.
References action, ActionList::Append(), get_quoted_path(), get_relative_offset(), LOG, LOG_S, MAXPATHLEN, new_absolute_path(), NS_T, NS_tsnprintf, NS_tstrlen, OK, UNEXPECTED_FILE_OPERATION_ERROR, and UPDATER_QUOTED_PATH_MEM_ERROR.
Referenced by DoUpdate().
int AddPreCompleteActions | ( | ActionList * | list | ) |
Definition at line 4393 of file updater.cxx.
References action, ActionList::Append(), BAD_ACTION_ERROR, GetManifestContents(), kNL, kWhitespace, line, LOG, LOG_S, mstrtok(), new_absolute_path(), NS_T, NS_tstrcmp, OK, and PARSE_ERROR.
Referenced by DoUpdate().
Definition at line 987 of file updater.cxx.
References BACKUP_EXT, MAXPATHLEN, NS_T, NS_tsnprintf, and rename_file().
Referenced by RemoveFile::Execute(), AddFile::Execute(), and PatchFile::Execute().
Definition at line 1018 of file updater.cxx.
References BACKUP_EXT, ensure_remove(), LOG, LOG_S, MAXPATHLEN, NS_T, NS_taccess, NS_tsnprintf, OK, rename_file(), sReplaceRequest, sStagedUpdate, and WRITE_ERROR_DELETE_BACKUP.
Referenced by backup_finish().
Definition at line 1072 of file updater.cxx.
References backup_discard(), backup_restore(), and OK.
Referenced by RemoveFile::Finish(), AddFile::Finish(), and PatchFile::Finish().
Definition at line 998 of file updater.cxx.
References BACKUP_EXT, LOG, LOG_S, MAXPATHLEN, NS_T, NS_taccess, NS_tsnprintf, OK, and rename_file().
Referenced by backup_finish().
|
static |
Definition at line 2623 of file updater.cxx.
References gWorkingDirPath, MARChannelStringTable::MARChannelID, MAX_PATH, MAX_TEXT_LEN, NS_T, NS_tsnprintf, OK, size, type, ArchiveReader::VerifyProductInformation(), and ArchiveReader::VerifySignature().
Referenced by UpdateThreadFunc().
|
static |
Definition at line 2317 of file updater.cxx.
References copy_recursive_skiplist< N >::append(), ensure_copy_recursive(), gInstallDirPath, gPatchDirPath, gWorkingDirPath, LOG, LOG_S, MAXPATHLEN, NS_T, NS_tstrcpy, and NS_tstrrchr.
Referenced by UpdateThreadFunc().
Definition at line 159 of file updater.cxx.
References BZ2_crc32Table, and end.
Referenced by PatchFile::LoadSourceFile().
|
static |
Definition at line 4460 of file updater.cxx.
References action, add_dir_entries(), AddPreCompleteActions(), ActionList::Append(), BAD_ACTION_ERROR, ensure_parent_dir(), ActionList::Execute(), ArchiveReader::ExtractFile(), ActionList::Finish(), GetManifestContents(), gWorkingDirPath, kNL, kQuote, kWhitespace, line, LOG, LOG_S, MAXPATHLEN, mstrtok(), NS_T, NS_tremove, NS_tsnprintf, NS_tstrcmp, NS_tstrlen, PARSE_ERROR, ActionList::Prepare(), READ_ERROR, and type.
Referenced by UpdateThreadFunc().
Definition at line 667 of file updater.cxx.
References ensure_copy_symlink(), ensure_open(), infile, LOG, LOG_S, nCount, NS_T, NS_tchmod, NS_tlstat, NS_tstat_t, OK, outfile, READ_ERROR, result, UPDATER_MEM_ERROR, WRITE_ERROR, and WRITE_ERROR_FILE_COPY.
Referenced by ensure_copy_recursive().
|
static |
Definition at line 786 of file updater.cxx.
References ensure_copy(), ensure_copy_recursive(), ensure_copy_symlink(), copy_recursive_skiplist< N >::find(), LOG, LOG_S, MAXPATHLEN, NS_T, NS_tclosedir, NS_tDIR, NS_tdirent, NS_tlstat, NS_tmkdir, NS_topendir, NS_treaddir, NS_tsnprintf, NS_tstat_t, NS_tstrcmp, READ_ERROR, and WRITE_ERROR.
Referenced by CopyInstallDirToDestDir(), ensure_copy_recursive(), and ProcessReplaceRequest().
Definition at line 644 of file updater.cxx.
References LOG, LOG_S, MAXPATHLEN, NS_T, and READ_ERROR.
Referenced by ensure_copy(), and ensure_copy_recursive().
|
static |
Definition at line 582 of file updater.cxx.
References ensure_write_permissions(), FILE, is_read_only(), NS_tchmod, NS_tfopen, NS_tstat, and NS_tstat_t.
Referenced by ensure_copy(), and PatchFile::Execute().
Definition at line 613 of file updater.cxx.
References ensure_parent_dir(), LOG, LOG_S, NS_T, NS_tmkdir, NS_tstrrchr, OK, and WRITE_ERROR.
Referenced by DoUpdate(), ensure_parent_dir(), AddFile::Execute(), rename_file(), and WriteStatusFile().
Definition at line 491 of file updater.cxx.
References ensure_write_permissions(), LOG, LOG_S, and NS_tremove.
Referenced by backup_discard(), ensure_remove_recursive(), and rename_file().
|
static |
Definition at line 502 of file updater.cxx.
References ensure_remove(), ensure_remove_recursive(), ensure_write_permissions(), LOG, LOG_S, MAXPATHLEN, NS_T, NS_tclosedir, NS_tDIR, NS_tdirent, NS_tlstat, NS_topendir, NS_treaddir, NS_trmdir, NS_tsnprintf, NS_tstat_t, NS_tstrcmp, and OK.
Referenced by ensure_remove_recursive(), NS_main(), ProcessReplaceRequest(), and UpdateThreadFunc().
|
static |
Definition at line 478 of file updater.cxx.
Referenced by ensure_open(), ensure_remove(), and ensure_remove_recursive().
Definition at line 456 of file updater.cxx.
References kQuote, NS_T, NS_tstrcat, NS_tstrcpy, and NS_tstrlen.
Referenced by add_dir_entries().
Get a pointer in the absolute path, relative to the working or install directory.
Returns itself, if not absolute or outside of the directory.
abs_path | An absolute path. return pointer to the location within fullpath where the relative path starts or fullpath itself if it already looks relative. |
Definition at line 371 of file updater.cxx.
References gInstallDirPath, gWorkingDirPath, NS_tstrlen, prefix, and sStagedUpdate.
Referenced by add_dir_entries().
Gets the platform specific path and performs simple checks to the path.
If the path checks don't pass nullptr will be returned.
line | The line from the manifest that contains the path. |
isdir | Whether the path is a directory path. Defaults to false. |
Definition at line 405 of file updater.cxx.
References kQuote, line, LOG, LOG_S, mstrtok(), NS_T, NS_tstrlen, and NS_tstrstr.
Referenced by RemoveFile::Parse(), RemoveDir::Parse(), AddFile::Parse(), PatchFile::Parse(), AddIfFile::Parse(), AddIfNotFile::Parse(), and PatchIfFile::Parse().
Definition at line 4329 of file updater.cxx.
References count, FILE, LOG, LOG_S, NS_T, NS_tfopen, and SSIZE_MAX.
Referenced by AddPreCompleteActions(), and DoUpdate().
Definition at line 2582 of file updater.cxx.
References gPatchDirPath, LOG, LOG_S, MAXPATHLEN, NS_T, NS_tDIR, NS_tdirent, NS_topendir, NS_treaddir, NS_tsnprintf, NS_tstrcmp, NS_tstrncmp, NS_tstrrchr, OK, and READ_ERROR.
Referenced by UpdateThreadFunc().
|
static |
Definition at line 561 of file updater.cxx.
References length, NS_T, NS_tstrcmp, and NS_tstrlen.
Referenced by ensure_open().
Definition at line 2842 of file updater.cxx.
References gInstallDirPath, gPatchDirPath, gSucceeded, LaunchCallbackApp(), LaunchMacPostProcess(), LaunchWinPostProcess(), StartServiceUpdate(), and sUsingService.
Referenced by NS_main().
|
static |
Definition at line 2140 of file updater.cxx.
References LaunchChild(), LOG, NS_tchdir, and WinLaunchChild().
Referenced by LaunchCallbackAndPostProcessApps(), and NS_main().
Definition at line 244 of file updater.cxx.
Referenced by AddPreCompleteActions(), DoUpdate(), get_valid_path(), PatchFile::Parse(), AddIfFile::Parse(), AddIfNotFile::Parse(), and PatchIfFile::Parse().
Converts a relative update path to an absolute path related to the working or install directory.
Allocates a new NS_tchar[] based path!
relpath | The relative path to convert to a full path. |
Definition at line 312 of file updater.cxx.
References gInstallDirPath, gWorkingDirPath, NS_T, NS_tstrcat, NS_tstrcpy, NS_tstrlen, and sStagedUpdate.
Referenced by add_dir_entries(), AddPreCompleteActions(), RemoveFile::Parse(), RemoveDir::Parse(), AddFile::Parse(), PatchFile::Parse(), AddIfFile::Parse(), AddIfNotFile::Parse(), and PatchIfFile::Parse().
Definition at line 2895 of file updater.cxx.
References CalculateRegistryPathFromFilePath(), d, DELETE, UACHelper::DisablePrivileges(), DoesFallbackKeyExist(), ELEVATION_CANCELED, ensure_remove_recursive(), FALLBACKKEY_LAUNCH_ERROR, FALLBACKKEY_NOKEY_ERROR, FALLBACKKEY_REGPATH_ERROR, FALLBACKKEY_SERVICE_NO_STOP_ERROR, FALLBACKKEY_UNKNOWN_ERROR, FALSE, gInstallDirPath, gPatchDirPath, gSucceeded, gWorkingDirPath, InitProgressUI(), IsLocalFile(), IsUnpromptedElevation(), LaunchCallbackAndPostProcessApps(), LaunchCallbackApp(), LaunchServiceSoftwareUpdateCommand(), LaunchWinPostProcess(), LOG, LOG_S, LogFinish, LogInit, MakeCommandLine(), MAX_PATH, MAXPATHLEN, NS_SLASH, NS_T, NS_taccess, NS_tmkdir, NS_tremove, NS_tsnprintf, NS_tstrcat, NS_tstrcpy, NS_tstrlen, NS_tstrncpy, NS_tstrrchr, NS_tstrstr, NULL, OK, p, rename_file(), result, ShowProgressUI(), sReplaceRequest, sStagedUpdate, sUsingService, SVC_NAME, t, UpdateThreadFunc(), WaitForServiceStop(), WRITE_ERROR_ACCESS_DENIED, WRITE_ERROR_APPLY_DIR_PATH, WRITE_ERROR_CALLBACK_APP, WRITE_ERROR_CALLBACK_PATH, and WriteStatusFile().
|
static |
Definition at line 2356 of file updater.cxx.
References ensure_copy_recursive(), ensure_remove_recursive(), gInstallDirPath, gPatchDirPath, gSucceeded, gWorkingDirPath, LOG, LOG_S, LogFlush, MAXPATHLEN, NO_INSTALLDIR_ERROR, NS_T, NS_taccess, NS_tmkdir, NS_tremove, NS_trename, NS_tsnprintf, NS_tstrcat, NS_tstrcpy, NS_tstrlen, NS_tstrrchr, rename_file(), and WRITE_ERROR.
Referenced by UpdateThreadFunc().
|
static |
Definition at line 857 of file updater.cxx.
References ensure_parent_dir(), ensure_remove(), LOG, LOG_S, NS_taccess, NS_trename, NS_tstat, NS_tstat_t, OK, READ_ERROR, RENAME_ERROR_EXPECTED_FILE, WRITE_ERROR, and WRITE_ERROR_DELETE_FILE.
Referenced by backup_create(), backup_discard(), backup_restore(), NS_main(), and ProcessReplaceRequest().
|
static |
Definition at line 2705 of file updater.cxx.
References CheckSignature(), CopyInstallDirToDestDir(), DoUpdate(), ensure_remove_recursive(), GetUpdateFileNames(), gInstallDirPath, gWorkingDirPath, LOG, LOG_S, MAX_PATH, MAXPATHLEN, NS_T, NS_tchdir, NS_tsnprintf, OK, ArchiveReader::Open(), ProcessReplaceRequest(), QuitProgressUI(), sReplaceRequest, sStagedUpdate, sUsingService, and WriteStatusFile().
Referenced by NS_main().
|
static |
Definition at line 2175 of file updater.cxx.
References ensure_parent_dir(), gPatchDirPath, MAXPATHLEN, NS_T, NS_tfopen, and NS_tsnprintf.
Referenced by NS_main(), UpdateThreadFunc(), and WriteStatusFile().
|
static |
Definition at line 2220 of file updater.cxx.
References OK, sStagedUpdate, text(), and WriteStatusFile().
unsigned int BZ2_crc32Table[256] |
Definition at line 155 of file updater.cxx.
Referenced by crc32().
|
static |
Definition at line 224 of file updater.cxx.
Referenced by CopyInstallDirToDestDir(), get_relative_offset(), LaunchCallbackAndPostProcessApps(), new_absolute_path(), NS_main(), ProcessReplaceRequest(), and UpdateThreadFunc().
|
static |
Definition at line 223 of file updater.cxx.
Referenced by CopyInstallDirToDestDir(), GetUpdateFileNames(), LaunchCallbackAndPostProcessApps(), NS_main(), ProcessReplaceRequest(), and WriteStatusFile().
|
static |
Definition at line 226 of file updater.cxx.
Referenced by ActionList::Finish(), LaunchCallbackAndPostProcessApps(), NS_main(), and ProcessReplaceRequest().
|
static |
Definition at line 225 of file updater.cxx.
Referenced by CheckSignature(), CopyInstallDirToDestDir(), DoUpdate(), get_relative_offset(), new_absolute_path(), NS_main(), PatchFile::Prepare(), ProcessReplaceRequest(), and UpdateThreadFunc().
Definition at line 240 of file updater.cxx.
Referenced by AddPreCompleteActions(), and DoUpdate().
Definition at line 241 of file updater.cxx.
Referenced by DoUpdate(), get_quoted_path(), get_valid_path(), PatchFile::Parse(), AddIfFile::Parse(), AddIfNotFile::Parse(), and PatchIfFile::Parse().
Definition at line 239 of file updater.cxx.
Referenced by AddPreCompleteActions(), and DoUpdate().
|
static |
Definition at line 228 of file updater.cxx.
Referenced by backup_discard(), NS_main(), and UpdateThreadFunc().
|
static |
Definition at line 227 of file updater.cxx.
Referenced by backup_discard(), get_relative_offset(), new_absolute_path(), NS_main(), UpdateThreadFunc(), and WriteStatusFile().
|
static |
Definition at line 229 of file updater.cxx.
Referenced by LaunchCallbackAndPostProcessApps(), NS_main(), and UpdateThreadFunc().