summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Windows: Fix crashes in elevated installation"Katja Marttila2016-05-205-80/+4
| | | | | | | | This reverts commit 95ae661cba931a982d12cd68d8b4da392d74bdd0. As we now require at least Qt5.5.0 we don't need this workaround Change-Id: I6ab930886bc9af0716a61a8e21b12db83018b0c2 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Make usage of authorization fallback optionalSlobodan Vrkacevic2016-05-187-1/+35
| | | | | | | | | | | | | | | | | | | | Asking users to use the authorization fallback in case of authorization errors might be a bit problematic in some cases. If the users are not familiar with the concept, running: "<installer_exe> --startserver PRODUCTION,{GUID},{GUID}" from command line might be confusing or difficult. Also it might not help at all. So let's make this optional. If the config variable DisableAuthorizationFallback is set to true the installer will not ask users to run the authorization fallback but instead it will abort the installation immediately. In RemoteClient this is implemented by adding a new function called setAuthorizationFallbackDisabled. The init function could be also extend for this but the config settings are not loaded at the time when the function is called. Change-Id: I4baf1dea34c5cc0016e98df47a9492ee1418c5ee Reviewed-by: Katja Marttila <katja.marttila@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add the Predefined Variables in Component Scripting.Takayuki ORITO2016-05-031-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | Add variables - ApplicationsDirX86 - ApplicationsDirX64 Change that the application directory can be selected on Windows, don't depend on the architecture(32bit or 64bit) of QtIFW. For example: When on Windows(64bit version). - QtIFW(32bit version) - ApplicationsDir -> C:\Program Files (x86) - ApplicationsDirX86 -> C:\Program Files (x86) - ApplicationsDirX64 -> C:\Program Files - QtIFW(64bit version) - ApplicationsDir -> C:\Program Files - ApplicationsDirX86 -> C:\Program Files (x86) - ApplicationsDirX64 -> C:\Program Files Change-Id: Idbc41d6f1ba9d7b0b9a9ff5590d05077662345cb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Niels Weber <niels.weber@qt.io> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Fixed detecting problems while launching sudoFrerich Raabe2016-05-031-2/+4
| | | | | | | | | | | | | | The installer would always consider the exit status of the sudo process, but if executing sudo itself fails (e.g. because the file does not exist, or because of insufficient permissions), a success exit status (zero) was returned. Fix this by rather returning the (negative) errno value in case anything goes wrong with execve. Change-Id: Iac5051e998982c6a31fa49cb6f4290cf66050c44 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fixed handling of Destroy command in server processFrerich Raabe2016-04-071-2/+2
| | | | | | | | | Destroying QProcess or QAbstractFileEngine objects never worked, since the code for deciding what type of object is to be destroyed confused the 'type' with the 'command'. Change-Id: I8d6c6bf2f11ff82cfbd744c43fcc91d234967b69 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Add a logging category and debug for http downloadKatja Marttila2016-04-073-2/+21
| | | | | | | | | | | Sometimes installing fails due to a problem in server. Since downloading can happen from mirror, it is hard to detect where the problem is. Print the IP address where the download actually happens to ease the problem solving. Change-Id: I31e15c2b1926745c251093cd1663d1ca1c65bff6 Task-number: QTIFW-813 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
* Make communication via installer.execute() Unicode safeKarsten Heimrich2016-03-302-4/+24
| | | | | | | | | | | | | | | | | It was impossible to pass Unicode data safely to a process started via installer.execute(), or to read Unicode data printed by that process safely back in. The reason for this is that the code hardcoded the latin1 codec for converting between strings used in the script interpreter and bytes used by the QProcessWrapper API. Fix this by adding two new optional arguments to installer.execute() which can be used to define the codec to be used for writing to stdin resp. reading from stdout. This defaults to latin1 for backwards compatibility. Change-Id: I290d8d9617b286ef90b2f0a05c6e7a47f6df317f Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Frerich Raabe <raabe@froglogic.com>
* Fix warning introduced with commit 175ffec58f9.Karsten Heimrich2016-03-231-8/+9
| | | | | | Change-Id: I922e572e246abfbd0647216a0134df615d36b484 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Fixed file handle leak when sudo'ingFrerich Raabe2016-03-041-1/+1
| | | | | | | | The write handle of the stderr pipe was closed in the parent process further up already. What's left to close is the read handle. Change-Id: I988c5334edb2df002cb29b1f2d47fb34eb284185 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Allow specifying the installer size in 'em' or 'ex' unitsSlobodan Vrkacevic2016-02-291-2/+21
| | | | | | | | | | | | | | | | | | | | | | | The WizardDefaultWidth and WizardDefaultHeight configuration settings always expected pixel values. This made the installer look somewhat awkward on high DPI displays, in which case the ratio between the font size and the installer window size was such that the fonts looked very big. Let's fix this by allowing to specify the width/height of the installer using units which are defined in terms of the font size, namely 'em' ("The width of the letter M") and 'ex' ("The width of the letter x"). 'px' is supported as well and means the same thing as not specifying any unit at all: the given size is defined in pixels. We choose to *not* use the font width for 'em' and 'ex' to be consistent with what the Qt CSS parser does (see src/gui/text/qcssparser.cpp), which adheres to what the W3C document at https://www.w3.org/WAI/GL/css2em.htm describes. Change-Id: Iaeb5a29c79d437ef4b956cb318158181f6289ec9 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
* Fixed deleting files when uninstalling on OS XFrerich Raabe2016-02-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Uninstalling packages on OS X didn't seem to work very reliably, it often (always?) seemed to not remove a couple of files. When clicking the 'Show Progress' button while uninstalling, it became apparent that the paths to all the files to remove were computed wrongly: instead of deleting e.g. the file /tmp/installdir/foo.txt The uninstaller attempted to remove /tmp/installdir/Uninstall.app/foo.txt What happens is when uninstalling, the ExtractArchiveOperation class (which performs deletion of installed files in its 'undoOperation' reimplementation) reads the files which were installed from the XML markup embedded in the maintenance tool binary (this happens in UpdateOperation::fromXml()). The paths to the files which were installed make use of a special '@RELOCATABLE_PATH@' placeholder which denotes the effective installation directory. This placeholder is meant to be replaced with the actual installation directory, which is assumed to be the directory where the maintenance tool resides, i.e. what QCoreApplication::applicationDirPath();. On OS X however, the maintenance tool is an app bundle, i.e. the actual binary is not in /tmp/installdir/Uninstall but rather /tmp/installdir/Uninstall.app/Contents/MacOS/Uninstall The code already called the QInstaller:isInBundle() utility function to handle this case, but did so wrongly: isInBundle() returns the directory to the app bundle, i.e. /tmp/installdir/Uninstall.app What we want though is just '/tmp/installdir'. Hence, let's go one directory up. Change-Id: I927a453d7fbdd1048ff3d2172bd3cfec3a563b4a Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* fix banner sizeKatja Marttila2016-02-291-2/+9
| | | | | | | | | | If WizardDefaultSize was not set, banner size was zero. In this commit default banner size to page size if WizardDefaultSize is not set. Also resize banner only when it is found to avoid warning messages in console. Change-Id: If47f947b134714ae935d80bc3074226763ca8ea7 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix arguments in RegisterFileTypeKatja Marttila2016-02-292-22/+39
| | | | | | | | | | When using RegisterFileType, argumens include progId. Removed it from arguments and saved as member variable. This way progId won't interfere argument check count and it can be used also in undo operation. Change-Id: Ic80a54a28b5e171a5d4e3023b58eb1636a16fa49 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fixed reading stderr output of sudoFrerich Raabe2016-02-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | After the sudo process finished, we need to make sure to read any buffered bytes from the stderr pipe. Without this, the stderr data which was shown in the message box often ended up being incomplete. For instance, three failures to enter the correct root password would show a message box saying Sorry, try again. Sorry, try again. Instead of Sorry, try again. Sorry, try again. Sorry, try again. sudo: 3 incorrect password attempts Change-Id: Ib1e7aa40d95f9bf140ba1978fdb9be92cad926b6 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Don't print error messages in case correct sudo password is enteredFrerich Raabe2016-02-191-3/+5
| | | | | | | | | | | | | | Any stderr data printed by 'sudo' was always printed as part of an error message box, even if sudo succeeded. This issue is triggered very easily by entering a wrong root password first, and then the correct password on the second try. Let's just print stderr data in case we have some *and* in case 'sudo' returns a non-zero return code. Change-Id: Icbb2d31cdf5c4d5d20ed4200553e9bf7e2b5bedd Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Fixed checking exit status when calling 'sudo'Frerich Raabe2016-02-191-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were a few closely related issues in how the code tried to decide whether running 'sudo' succeeded: The first issue I noticed was that in some cases, the wait() call would fail with ECHILD. What happened was that the waitpid() call noticed that the sudo process terminated and reaped the zombie. Then, the loop was left and wait() was called on the PID again -- at this point, there was no child with that PID anymore though. The user-visible consequence of this was that the authentication was incorrectly considered to have failed, and a "Cannot get authorization" dialog was shown even though the correct root password was entered. No matter whether wait() failed or not, the code would try to use the WIFEXITED() and WEXITSTATUS() macros to interpret the last status. This caused some reading of uninitialized memory (as Valgrind pointed out), since WIFEXITED() may only be called in case wait() succeeded. Furthermore, as wait(2) explains: WEXITSTATUS(status) returns the exit status of the child. [..] This macro should be employed only if WIFEXITED returned true. This patch fixes all these problems by a) not calling wait() again but rather using the status which was fetched by waitpid() and b) only using the W* macros if it's legal to do so (i.e. waitpid() succeeded). Change-Id: I81741898dc686bb2d2128fceb9e71535fab43417 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* Fix setValue saving in restartKatja Marttila2016-02-153-3/+13
| | | | | | | | | | | | | When running maintenancetool and installing a component that sets a value in installscript with setValue, the value is cleared when pressing 'Restart'. Task-number:QTIFW-504 Change-Id: Ie588b6f1011d7b50b771ea8ee0dea99350f65878 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Fixed out of bounds access when calling su/sudoFrerich Raabe2016-02-151-1/+1
| | | | | | | | The memory block allocated for the execv() arguments was too small, causing subsequent code to invoke undefined behavior. Change-Id: Ic0b1e03ddc07e3147ef0d920f18d86276b21e222 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Don't use 'lockmyApp' prefix for lock filesFrerich Raabe2016-02-152-2/+8
| | | | | | | | | | | | | | | The 'lockmyApp' part of the lock file names looked like some generic default value which just was not customized to fit the installer. Let's use the Qt application name instead as returned by QApplication::applicationName(). We maintain the strong random filename generation algorithm by sticking to the proven constants which presumably are perfectly random since they were generated by a fair die roll. Change-Id: Ief18942ca4e967f7016e7c471a7b44e3b8ab8c95 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Allow calling installer.setValue() with an empty string as the valueFrerich Raabe2016-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calls like installer.setValue("RunProgram", ""); would fail if there was no previous setValue() call which set the variable to a non-empty string. In PackageManagerCoreData, the variables of the installer which are accessible via installer.setValue and installer.value are managed in two data structures: * m_variables contains all variables which were set at runtime, via installer.setValue * m_settings contains all variables as defined in the XML configuration file. When calling installer.value(), it would first consider m_variables and if the given variable name is not in that structure, it falls back to m_settings. What happened for calls like 'installer.setValue("RunProgram", "");' was that the code tries to detect whether the variable already has the specified value -- and only if it doesn't, the variable is set. To test if the variable has the specified value, it would simply check m_variables.value(key) and compare it with the given new value. However, if the key was never set, 'value()' returns an empty string -- which is equal to the new value, and hence PackageManagerCoreData::setValue() returned false. Fix this by first verifying that the given key exists in the m_variables object at all before bothering to check what m_variables.value() returns. Change-Id: I8a2bcb74e52e05f1454945628bcf372445c91a17 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Fixed writing log on Windows if target dir requires admin rightsFrerich Raabe2016-02-151-0/+46
| | | | | | | | | | | | | | Writing the installation log would fail on Windows in case writing to the target directory requires admin privileges. Instead of relying on the VerboseWriter destructor, let the PackageManagerCore destructor explicitly write the installation log. In case using the PlainVerboseWriterOutput does not work, try to use a newly introduced VerboseWriterAdminOutput which first tries to acquire admin privileges before writing a file via RemoteFileEngine. Change-Id: I13f203afa67175012409bc1eed95f05e51cdcb81 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Factored QFile usage out of VerboseWriter::flush()Frerich Raabe2016-02-152-13/+46
| | | | | | | | | | | This introduces a new 'VerboseWriterOutput' interface which can be reimplemented to perform writing the installation log file by different means. For now, there's just a standard QFile-based implementation. The plan is to use this facility for implementing log writing via RemoteFileEngine. Change-Id: I89d91a4c7a146401ca96f27b25c49558099c5bb7 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Factored flushing of VerboseWriter into dedicated methodFrerich Raabe2016-02-152-3/+16
| | | | | | | | | | | | | | This patch introduces a (yet unused) VerboseWriter::flush() method which can be used to explicitly trigger flushing the installation log. This permits clients to decide when to do the flushing instead of having to rely on the destructor being called. The destructor will call flush() if needed - whether flushing is needed is defined in terms of the 'perFileBuffer': if it's open, flushing is needed - otherwise, no flushing is needed. Change-Id: I17f1df96e5ddf3b6f613d647c28b90b6973c9393 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Fixed final 'Finish' message on OS XFrerich Raabe2016-02-151-6/+4
| | | | | | | | | | | | | | | | | | | | | | | On OS X, the final page of the installer would say something like Click Done to exit the %1 wizard. However, the final "commit" button is only actually labelled "Done" when using the natie OS X style. When specifying a different style in the config.xml file, e.g. 'Modern', the commit button is labelled the same as on other operating systems: "Finish". Hence, in such cases the final message would be wrong. Fix this by not hardcoding any particular label in the message but rather querying the default button text - this works with all styles. This also required setting the text a little later (when entering the page) because only then we can safely access the pointer returned by the gui() method. Change-Id: I285c6e376c8450457fcce20941240f9e29350de7 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Resize banner image to fit default installer widthSlobodan Vrkacevic2016-02-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | When the Modern wizard style is used, the size of the banner picture limits the width of the installer and that's a problem on high DPI displays. Scaling and resizing of the UI does not work correctly in that case. Also the WizardDefaultWidth option from config.xml is ignored completely. Let's try to solve this by resizing the banner image to fit the installers default width. This is technically not backwards compatible (existing installers may suddenly appear to be much more narrow or wide than before) but makes the installer work much better on high DPI displays in which case the fonts tends to be very big (in terms of pixels) and the banner image looks very small. If the old behavior is needed, setting the 'WizardDefaultWidth' value to be equal to the width of the banner image will do the job. Change-Id: Ib311df3bbc277c328e015c1095ae4d35663c42e1 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* Doc: added namespace statement for lib7zNico Vertriest2016-01-281-1/+7
| | | | | | Change-Id: I0783917628f0f2608f20b00f90b6a68db7a86253 Task-number: QTBUG-43810 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
* Doc: removed qdoc var declaration pixmapNico Vertriest2016-01-211-4/+0
| | | | | | | | Variable had previously been removed from localpackagehub.h Change-Id: I9673de6bbc1f5fedd6957b53a059e654930f77c2 Task-number: QTBUG-50557 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
* Compilation fix for QV4 usageIikka Eklund2016-01-211-2/+2
| | | | | | | | asObject() is deprecated so use as<QV4::Object>() instead. Change-Id: Ib0ea08a69e1c806a6c76d10a92c0280cb0bed153 Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/2.0'Iikka Eklund2016-01-20230-930/+711
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: installerfw.pri src/libs/kdtools/kdgenericfactory.cpp src/libs/kdtools/kdgenericfactory.h src/libs/kdtools/kdupdaterapplication.cpp src/libs/kdtools/kdupdaterapplication.h src/libs/kdtools/kdupdaterupdatesourcesinfo.cpp src/libs/kdtools/kdupdaterupdatesourcesinfo.h sync.profile Change-Id: Ifdc8b065f89b7e241bd3788ed79768e21888161f
| * Doc: Remove dubious sentence from installer.calculateComponentsToUninstall()Kai Koehne2016-01-151-2/+2
| | | | | | | | | | | | | | | | The auto-dependencies seems already to be handled correctly in UninstallerCalculator. Change-Id: I30074036aa030399cd49a6bfe2e380ffa1e92c58 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
| * Update license headersIikka Eklund2015-12-29235-899/+664
| | | | | | | | | | | | | | | | | | Update existing license headers. LGPL -> LGPLv21. Update copyright year as well. Change-Id: Ie1d71f8c68186b8f625f409ddf94691f178093c9 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com> Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
| * Fix target directory check for reserved words on WindowsAndy Shaw2015-12-071-1/+1
| | | | | | | | | | | | | | | | | | If the directory starts with "Con" etc then it is still ok to use, it is only if it is /Con or /Con/ that it is not allowed. So the extra check to be sure has anything after the reserved part is included. Change-Id: I72e0e0f98167f29da54cb627e75cd1814c3f9706 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
| * Use QQmlV4Function to correctly get empty parameters from script.Karsten Heimrich2015-11-263-46/+56
| | | | | | | | | | | | | | | | | | By using QQmlV4Function to get the parameters, empty strings passed are correctly kept as empty and not null. Task-number: QTIFW-724 Change-Id: I592e2230e574ba82e765bd0079964db29452b2e9 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Allow defining non-checkable itemsKatja Marttila2016-01-185-4/+21
| | | | | | | | | | | | | | | | | | | | | | This change will introduce new element 'Checkable' for package. Setting checkable to false will hide checkbox. Useful if use case is to install one sub item instead of all sub items. Change-Id: I8c731e77353b6da539dddcecdc8495b28ef5f7ea Task-number: QTIFW-773 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* | Added support for setting descriptions of Windows shortcutsFrerich Raabe2016-01-182-3/+9
| | | | | | | | | | | | | | | | | | This patch extends the CreateShortcut operation on Windows such that it recognizes a new optional 'description' argument - if specified, it's used to set the description (AKA "comment") of the Windows shortcut. Change-Id: Ib0ab48bd30e83d9cc89b1bad7d2b88e9109bdcea Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* | Fix timezone issue, simply keep the UTC time.Karsten Heimrich2016-01-042-28/+6
| | | | | | | | | | | | | | | | | | | | Since we're the only user of the list archive function, do not convert from UTC. Though once we document the function it should be mentioned that the user needs to convert it (e.g. for display purposes etc...). Change-Id: Icbf8372ddff4f34e3c5a426b983ff25a117d74eb Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* | Optimized checking validity of target directory value on WindowsFrerich Raabe2015-12-092-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDir::drives() was called on every key press to check whether the specified drive letter is valid. Alas, this function is quite expensive on Windows in case there are network drives. In my local tests, a single call to QDir::drives() would take about 300ms per call (i.e. 0.3s per key press). This made typing text feel very sluggish. I first considered fetching the list of drives up front (e.g. when starting the installer) but this won't handle cases nicely where drives are added/removed while the installer is running - e.g. USB devices. Instead, let's use a cooldown timer: only bother checking the entered path if there was no keypress for some specific time (right now: 200ms, a value which is based on highly scientific experiments). In addition to that, also make sure to check the validity when trying to navigate to the next page -- this takes care of people typing and hitting Return quickly. Change-Id: I35e83fff2fd095765ab1b00b44ac1b8bf495af98 Task-number: QTIFW-673 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Remove implicit expanding vertical spacer from dynamic pagesFrerich Raabe2015-12-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | This change is backwards incompatible in that it may have a negative impact on the layouting of dynamic pages, but it permits creating dynamic pages which allocate the entire vertical space of the page, e.g. custom license text viewers. Change-Id: I5981450366a1d58f01315192bb29f6ae29b7dbd4 Task-number: QTIFW-779 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Fixed compiling lib7z_facade.cpp with Visual Studio 2013Frerich Raabe2015-12-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit c43f3f0c683841f7b2bd62ce8c1556f2e5412d4d introduced a usage of localtime_s for non-MinGW Windows builds. Visual Studio 2013 complained about this, saying ..\..\..\..\source\src\libs\installer\lib7z_facade.cpp(331) : error C3861: 'localtime_s': identifier not found The MSDN explains that <time.h> should be included, so let's do that to make the build succeed. Change-Id: I8447ed0c97480485e4219f6e413b05d80be6ef63 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Fixed reading error output from sudo'ed processFrerich Raabe2015-12-091-1/+1
| | | | | | | | | | | | | | The 'errBuf' buffer was never actually used for anything. Change-Id: Ia28b3ee3308ecff451afb518e0da8cf7125362d4 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* | Fixed bug in making stderr pipe read-handle non-blockingFrerich Raabe2015-12-091-1/+1
| | | | | | | | | | | | | | Use F_GETFL to set the flags, and S_SETFL to set them. Change-Id: Ia32d020f320e819db5f0976972e38981d22eaa26 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* | When running sudo'ed process, make reading from child non-blockingFrerich Raabe2015-12-091-1/+11
| | | | | | | | | | | | | | | | | | | | | | For some reason, using a blocking read would sometimes(!) not cause the sudo process to finish. In fact, it didn't even seem to start running, even though it showed up in the process list. Maybe a deadlock? Using non-blocking reads fixes this. Change-Id: Ic8a94b38e4be426abcc08bbd0dd887a3cffda5d5 Task-number: QTIFW-771 Reviewed-by: Katja Marttila <katja.marttila@theqtcompany.com>
* | Let ElevatedExecuteOperation delete its RemoteObject earlierFrerich Raabe2015-12-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After running the process, ElevatedExecuteOperation would delete the QProcessWrapper object via deleteLater(). However, this would cause lingering remote connections: Operations are executed threaded via QtConcurrent::run(). The QtConcurrent threads don't run an event loop, so calling QProcessWrapper::deleteLater() would cause the object to get deleted once the thread finished. However, QtConcurrent uses a thread pool, so it may happen that the remote object is never deleted at all. Let's fix this by deleting the object right away. It should be safe no matter which thread runs the operation: 1. If it's the UI thread, the nested event loop will synchronize, i.e. the QEventLoop:exec() call only returns once the process finished. 2. If it's a non-UI thread, the code synchronizes via QProcessWrapper::waitForFinished(). In either case, the process will be finished by the time we get to the end of the function, so I think it's safe to just delete the object right away (and hence close the remote connection). Let's also add an assert to document our assumption. Change-Id: Ieb9970ff6452d404924824ece2a0a6e79552b0b3 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Removed unused variableFrerich Raabe2015-12-081-1/+0
| | | | | | | | | | | | | | I see no need to do anything with the file descriptor flags in here. Change-Id: Ib4d8dfd3d18ed90028138b0def7c5da15f434fd7 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Fixed running binarycreator if the temporary directory name contains spacesFrerich Raabe2015-12-081-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The binarycreator program fails to generate an archive if the temporary directory name contains spaces. This is not uncommon on Windows since the temporary directory is beneath the home directory, e.g. C:\Users\<username>\AppData\Local\Temp. If the user name contains spaces (as it does in my case, the user name is "Frerich Raabe") binarycreator fails with [64] Warning: QFile::remove: Empty or null file name (C:\Qt\MSVC12\5.5.0-src\qtbase\src\corelib\io\qfile.cpp:498, bool __thiscall QFile::remove(void)) Caught exception: Cannot create archive "C:\Users\Frerich": internal code: E_FAIL This was caused by createArchive() assembling a command line without escaping either the 'target' or any of the 'sources' values. Instead of adding escaping only to split the command line again, let's drop the approach of constructing a command and then splitting it completely. Instead, let's build an array of arguments right away. Change-Id: I284c1b5a27e9edd3717243ea7979149ab2033d64 Task-number: QTIFW-787 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Fix violated assertion in error handling of binarycreatorFrerich Raabe2015-12-081-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The errorMessageFrom7zResult() function asserts (via a qFatal) that the given status code is indeed an error, i.e. not S_OK. However, the condition 'res != S_OK || !tempFile.exists()' permitted that the function is called with S_OK (in case !tempFile.exists() is true), violating an assertion. This patch adjusts the error handling such that the details of the error returned by errorMessageFrom7zResult() are only included in the exception message if the status code is not S_OK. Change-Id: I15d686cd35c918093ec90c56a7bcc3f0e6638cfb Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Automatically chose to perform uninstall if appropriateFrerich Raabe2015-12-082-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the maintenance tool automatically chose (but not start) deinstallation if there are no valid repositories available. Without this, all three options are available but the first two will show an error message if there is not even one repository available. This simplifies the maintenance tool for purely offline installers which use no repositories whatsoever. Change-Id: If496ac6858191c758a7bae6ec4a9434f88ddaac0 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Implemented installer.readFile()Frerich Raabe2015-12-082-0/+29
| | | | | | | | | | | | | | | | | | | | | | For reading an external file using a specific encoding. This is convenient for having installers show the current configuration (e.g. effective license key) in case the configuration is stored in plain files as opposed to using e.g. the Windows registry. Change-Id: I87f8583b4cb192c4bd8b62a03f292a5cbefd52d8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Implemented support for creating URL shortcuts on WindowsFrerich Raabe2015-12-081-21/+43
| | | | | | | | | | | | | | | | | | | | | | | | This makes it possible to use the CreateShortcut operation for creating http: and ftp: links, too. This is useful for adding links to online resources to the start menu. The detection of hyperlinks is very simplistic at this point, but good enough many purposes. Change-Id: I80b5eea466a37891cb378eb5c603c08f065bd843 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
* | Fixed occasional crash on Windows when terminating installerFrerich Raabe2015-12-083-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The static RemoteClient object (defined in RemoteClient::instance()) which gets destroyed at the very end of the process lifetime would -- as part of its constructor -- execute the RemoteClientPrivate destructor. The RemoteClientPrivate destructor did non-trivial work though, trying to shut down the connection which involves accessing the LocalServer instance. Executing this code at the very end of the process lifetime would sometimes cause a crash on Windows with a back trace into the QMutex guts. Let's fix this by getting more control over the destruction order; the RemoteClient instance is no longer a static object but allocated dynamically. Callers can explicitly call 'destroy' to dispose of the instance as part of their shutdown routine. Change-Id: Ie6773ccc0276ad6285919e57e9ed190bab02be3f Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>