Skip to content

Commit

Permalink
Merge pull request #65 from kambala-decapitator/macos-pass-cli-params
Browse files Browse the repository at this point in the history
[macOS] pass all CLI params when relaunching with sudo
  • Loading branch information
chewitt authored Feb 27, 2024
2 parents 171b1b6 + 2bcf622 commit 7025e86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ int main(int argc, char *argv[])
{
const auto sudoPrompt = QLatin1String{"%1 requires admin permissions."}.arg(app.applicationDisplayName());
const QLatin1String appleScript{R"(do shell script "sudo '%1' %2" with prompt "%3" with administrator privileges)"};
const auto cliParams = QStringList{elevatedParam} + cmdArgs.mid(1);

QProcess myProcess;
myProcess.setProgram(QLatin1String{"osascript"});
myProcess.setArguments({"-e", appleScript.arg(QCoreApplication::applicationFilePath(), elevatedParam, sudoPrompt)});
myProcess.setArguments({"-e", appleScript.arg(QCoreApplication::applicationFilePath(), cliParams.join(' '), sudoPrompt)});

if (myProcess.startDetached())
{
Expand Down

0 comments on commit 7025e86

Please sign in to comment.