mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2025-04-12 01:00:48 +00:00
Show a more friendly message when requesting elevation under Linux
Under Linux we have control over how the process requesting elevation describes itself - use this to refer to the updater as 'Mendeley Updater' rather than 'updater'.
This commit is contained in:
parent
1768e4525f
commit
aa3282b582
3 changed files with 20 additions and 7 deletions
|
@ -63,14 +63,17 @@ void ProcessUtils::runAsync(const std::string& executable,
|
|||
}
|
||||
|
||||
int ProcessUtils::runElevated(const std::string& executable,
|
||||
const std::list<std::string>& args)
|
||||
const std::list<std::string>& args,
|
||||
const std::string& task)
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
(void)task;
|
||||
return runElevatedWindows(executable,args);
|
||||
#elif defined(PLATFORM_MAC)
|
||||
(void)task;
|
||||
return runElevatedMac(executable,args);
|
||||
#elif defined(PLATFORM_LINUX)
|
||||
return runElevatedLinux(executable,args);
|
||||
return runElevatedLinux(executable,args,task);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -106,9 +109,16 @@ bool ProcessUtils::waitForProcess(PLATFORM_PID pid)
|
|||
|
||||
#ifdef PLATFORM_LINUX
|
||||
int ProcessUtils::runElevatedLinux(const std::string& executable,
|
||||
const std::list<std::string>& args)
|
||||
const std::list<std::string>& args,
|
||||
const std::string& _task)
|
||||
{
|
||||
std::string sudoMessage = FileUtils::fileName(executable.c_str()) + " needs administrative privileges. Please enter your password.";
|
||||
std::string task(_task);
|
||||
if (task.empty())
|
||||
{
|
||||
task = FileUtils::fileName(executable.c_str());
|
||||
}
|
||||
|
||||
std::string sudoMessage = task + " needs administrative privileges. Please enter your password.";
|
||||
|
||||
std::vector<std::string> sudos;
|
||||
sudos.push_back("kdesudo");
|
||||
|
|
|
@ -47,7 +47,8 @@ class ProcessUtils
|
|||
* not be started.
|
||||
*/
|
||||
static int runElevated(const std::string& executable,
|
||||
const std::list<std::string>& args);
|
||||
const std::list<std::string>& args,
|
||||
const std::string& task);
|
||||
|
||||
/** Wait for a process to exit.
|
||||
* Returns true if the process was found and has exited or false
|
||||
|
@ -70,7 +71,8 @@ class ProcessUtils
|
|||
RunAsync
|
||||
};
|
||||
static int runElevatedLinux(const std::string& executable,
|
||||
const std::list<std::string>& args);
|
||||
const std::list<std::string>& args,
|
||||
const std::string& task);
|
||||
static int runElevatedMac(const std::string& executable,
|
||||
const std::list<std::string>& args);
|
||||
static int runElevatedWindows(const std::string& executable,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "UpdateInstaller.h"
|
||||
|
||||
#include "AppInfo.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Log.h"
|
||||
#include "ProcessUtils.h"
|
||||
|
@ -115,7 +116,7 @@ void UpdateInstaller::run() throw ()
|
|||
LOG(Info,"Insufficient rights to install app to " + m_installDir + " requesting elevation");
|
||||
|
||||
// start a copy of the updater with admin rights
|
||||
installStatus = ProcessUtils::runElevated(updaterPath,args);
|
||||
installStatus = ProcessUtils::runElevated(updaterPath,args,AppInfo::name());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue