Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On macOS, replaces use of cocoasudo for elevating privileges #11

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions TrayIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,19 @@ void find_sudo_app()
else if(system("type gksu")==0) sudo_app="gksu";
else if(system("type kdesu")==0) sudo_app="kdesu";
else sudo_app="sudo";
#else
sudo_app="\"" BINDIR "/UrBackup Client Administration\"";
#endif
}

void runCommand(std::string cmd, std::string arg1)
{
#ifdef __APPLE__

wxString clientexecutable = wxStandardPaths::Get().GetExecutablePath();
wxString sudoedcommand = "/usr/bin/osascript -e 'do shell script (quoted form of \""+ clientexecutable +"\" & \" "+cmd+"\""+(arg1.empty()?std::string():(" & \" "+arg1+"\""))+") with prompt \"UrBackup Client wants to make changes\" with administrator privileges'";
wxExecute(sudoedcommand, wxEXEC_ASYNC, NULL, NULL);

#else

std::string sudo_prefix = "";

if (Connector::getPasswordData(true, false).empty())
Expand All @@ -143,10 +149,7 @@ void runCommand(std::string cmd, std::string arg1)
}
sudo_prefix = sudo_app + " ";
}
#ifdef __APPLE__
wxString clientexecutable = wxStandardPaths::Get().GetExecutablePath();
wxExecute(sudo_prefix +"\""+ clientexecutable +"\" "+cmd+(arg1.empty()?std::string():(" "+arg1)), wxEXEC_ASYNC, NULL, NULL);
#else

wxExecute(sudo_prefix + BINDIR "/urbackupclientgui "+cmd+(arg1.empty()?std::string():(" "+arg1)), wxEXEC_ASYNC, NULL, NULL);
#endif
}
Expand Down