summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-06-17 11:48:15 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-06-17 13:14:51 +0200
commit76ed00f8db34490d5e21c72d142e11da510ac605 (patch)
tree85f380adc536a08a4bc06ca20507f452b9781254 /desktop
parent44f75d653b972a581bb888868a0cb9f08f625974 (diff)
updater: detect when user can not write to installation directory
In this case we can not update right now. Change-Id: I19cda5ddef448ff81e1ca457774b2db036038c88
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/updater.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 949ec186d1fe..468c94b4e74c 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -211,6 +211,35 @@ struct update_info
std::vector<language_file> aLanguageFiles;
};
+bool isUserWritable(const OUString& rFileURL)
+{
+ osl::FileStatus aStatus(osl_FileStatus_Mask_Attributes);
+ osl::DirectoryItem aDirectoryItem;
+
+ osl::FileBase::RC eRes = osl::DirectoryItem::get(rFileURL, aDirectoryItem);
+ if (eRes != osl::FileBase::E_None)
+ {
+ Updater::log("Could not get the directory item for: " + rFileURL);
+ return false;
+ }
+
+ osl::FileBase::RC eResult = aDirectoryItem.getFileStatus(aStatus);
+ if (eResult != osl::FileBase::E_None)
+ {
+ Updater::log("Could not get the file status for: " + rFileURL);
+ return false;
+ }
+
+ bool bReadOnly = (aStatus.getAttributes() & static_cast<sal_uInt64>(osl_File_Attribute_ReadOnly)) != 0;
+ if (bReadOnly)
+ {
+ Updater::log("Update location as determined by: " + rFileURL + " is read-only.");
+ return false;
+ }
+
+ return true;
+}
+
}
void update()
@@ -602,6 +631,15 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash
void update_checker()
{
+ OUString aBrandBaseDir("${BRAND_BASE_DIR}");
+ rtl::Bootstrap::expandMacros(aBrandBaseDir);
+ bool bUserWritable = isUserWritable(aBrandBaseDir);
+ if (!bUserWritable)
+ {
+ Updater::log("Can't update as the update location is not user writable");
+ return;
+ }
+
OUString aDownloadCheckBaseURL = officecfg::Office::Update::Update::URL::get();
static const char* pDownloadCheckBaseURLEnv = std::getenv("LIBO_UPDATER_URL");
if (pDownloadCheckBaseURLEnv)