Kaydet (Commit) 35ec8253 authored tarafından Armin Le Grand's avatar Armin Le Grand

profilesafe: Add values for SecureUserConfig

Added default values for SecureUserConfig values
to soffice.ini/rc which enable the mechanism,
enable by default and set a maximum of three backups
file in packed form. Added more handy flag for easy
decision to add compressed/uncompressed.

Change-Id: I5a624c09fec4e4278314e13fc5f693ac085d5e61
üst 2da3bb5c
......@@ -103,7 +103,7 @@ namespace
{
sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt64 nBytesTransfer(0);
sal_uInt64 nSize(getFullFileSize());
sal_uInt64 nSize(getPackFileSize());
// set offset in source file - when this is zero, a new file is to be added
if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
......@@ -140,7 +140,7 @@ namespace
sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
sal_uInt64 nBytesTransfer(0);
sal_uInt64 nSize(getFullFileSize());
sal_uInt64 nSize(getPackFileSize());
std::unique_ptr< z_stream > zstream(new z_stream);
memset(zstream.get(), 0, sizeof(*zstream));
......@@ -294,21 +294,22 @@ namespace
public:
// create new, uncompressed entry
PackedFileEntry(
sal_uInt32 nFullFileSize,
sal_uInt32 nOffset,
sal_uInt32 nCrc32,
FileSharedPtr& rFile,
bool bDoCompress)
: mnFullFileSize(nFullFileSize),
mnPackFileSize(nFullFileSize),
mnOffset(nOffset),
mnOffset(0),
mnCrc32(nCrc32),
maFile(rFile),
mbDoCompress(bDoCompress)
{
}
// create entry to be loaded as header (read_header)
PackedFileEntry()
: mnFullFileSize(0),
mnPackFileSize(0),
......@@ -669,7 +670,7 @@ namespace
return bRetval;
}
bool tryPush(FileSharedPtr& rFileCandidate)
bool tryPush(FileSharedPtr& rFileCandidate, bool bCompress)
{
sal_uInt64 nFileSize(0);
......@@ -724,19 +725,14 @@ namespace
nCrc32 = createCrc32(rFileCandidate, 0);
}
// create a file entry for a new file. Offset is set to 0 to mark
// the entry as new file entry
// the compress flag decides if entries should be compressed when
// they get written to the target package
static bool bUseCompression(true);
// create a file entry for a new file. Offset is set automatically
// to 0 to mark the entry as new file entry
maPackedFileEntryVector.push_back(
PackedFileEntry(
static_cast< sal_uInt32 >(nFileSize),
0,
nCrc32,
rFileCandidate,
bUseCompression));
bCompress));
mbChanged = true;
}
......@@ -837,14 +833,14 @@ namespace comphelper
return OUString(maBase + "/." + maName + ".pack");
}
bool BackupFileHelper::tryPush()
bool BackupFileHelper::tryPush(bool bCompress)
{
if (splitBaseURL() && baseFileExists())
{
PackedFile aPackedFile(getName());
FileSharedPtr aBaseFile(new osl::File(mrBaseURL));
if (aPackedFile.tryPush(aBaseFile))
if (aPackedFile.tryPush(aBaseFile, bCompress))
{
// reduce to allowed number and flush
aPackedFile.tryReduceToNumBackups(mnNumBackups);
......
......@@ -613,8 +613,6 @@ Components::Components(
Components::~Components()
{
SAL_WARN("configmgr", "################# Components::~Components() #####################");
// get flag if _exit was already called which is a sign to not to secure user config
const bool bExitWasCalled(comphelper::BackupFileHelper::getExitWasCalled());
......
......@@ -569,11 +569,14 @@ void Desktop::Init()
SetBootstrapError( BE_OFFICECONFIG_BROKEN, e.Message );
}
// test code for ProfileSafeMode to allow testing the fail
// of loading the office configuration initially. To use,
// either set to true and compile, or set a breakpoint
// in debugger and change the local bool
static bool bTryHardOfficeconfigBroken(false);
if (bTryHardOfficeconfigBroken)
{
SAL_WARN("configmgr", "################# Desktop::Init() #####################");
SetBootstrapError(BE_OFFICECONFIG_BROKEN, OUString());
}
}
......
......@@ -20,11 +20,24 @@
namespace comphelper
{
/** Helper class to backup/restore a single file
*
* This is a general class to manage backups/restore of the file
* given by the URL. The container holding the backups is created
* aside the original file, e.g for 'test.txt' a container
* called '.test.pack' will be used. If it was not yet backed-up
* this container file will be created at the 1st backup and deleted
* when the last gets removed. The container holds a stack with a
* maximum given number (in the constructor) of copies, these are by
* default compressed, but don't have to be (see tryPush).
*
* Due to being on a low system level here, no UNO API and not much
* other tooling can be used, as a consequence for the container a
* own simple format is used and e.g. the zip lib directly.
*
* You need to hand over the URL of the file to look at and
* a maximum number of allowed copies. That number is internally
* limited to a max of 10 (see implementation). The number of
* allowed copies is limited to [1..max].
* limited to a absolute max of 10 (see implementation). The number
* of allowed copies is limited to [1..max].
*
* Calling tryPush() will check if there is no backup yet or if
* there is one that the file has changed. If yes, a new copy is
......@@ -102,10 +115,14 @@ namespace comphelper
* Also may cleanup older backups when NumBackups given in the
* constructor has changed.
*
* @param bCompress
* Defines if the new backup will be compressed when
* added. Default is true
*
* @return bool
* returns true if a new backup was actually created
*/
bool tryPush();
bool tryPush(bool bCompress = true);
/** finds out if a restore is possible
*
......
......@@ -104,6 +104,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
) > $@
# for release-builds (building installers) adjust values in openoffice.lst.in
# Added 'SecureUserConfig' flags to enable and safe three registrymodifications.xcu versions
$(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_rcfile,soffice) :
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ECH,1)
( \
......@@ -118,6 +119,8 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
&& echo 'ProgressTextBaseline=145' \
&& echo 'ProgressTextColor=255,255,255' \
&& echo 'URE_BOOTSTRAP=$${ORIGIN}/$(call gb_Helper_get_rcfile,fundamental)' \
&& echo 'SecureUserConfig=true' \
&& echo 'SecureUserConfigNumCopies=3' \
) > $@
$(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_rcfile,uno) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment