2020-11-16 12:57:03 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
2020-11-16 13:07:25 +00:00
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
2020-11-16 13:08:33 +00:00
|
|
|
#include <Security/Security.h>
|
2020-11-16 12:57:03 +00:00
|
|
|
|
|
|
|
int uninstall();
|
|
|
|
|
|
|
|
int main(int argc, char * argv[])
|
|
|
|
{
|
|
|
|
QApplication app{argc, argv};
|
|
|
|
if(QMessageBox::question(nullptr, "Lokinet Uninstaller", "Do You want to uninstall Lokinet?",
|
|
|
|
QMessageBox::Yes|QMessageBox::No)
|
|
|
|
== QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
QMessageBox msgBox;
|
|
|
|
const auto retcode = uninstall();
|
|
|
|
if(retcode == 0)
|
|
|
|
{
|
|
|
|
msgBox.setText("Lokinet has been successfully uninstalled, you may now remove the uninstaller if you wish.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-16 13:07:25 +00:00
|
|
|
msgBox.setText("Failed to uninstall lokinet");
|
2020-11-16 12:57:03 +00:00
|
|
|
}
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int uninstall()
|
|
|
|
{
|
|
|
|
AuthorizationRef authorizationRef;
|
|
|
|
OSStatus status;
|
|
|
|
|
2020-11-18 22:06:48 +00:00
|
|
|
status = AuthorizationCreate(nullptr, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &authorizationRef);
|
|
|
|
if(status != 0)
|
|
|
|
return status;
|
|
|
|
char* tool = "/bin/sh";
|
|
|
|
char* args[] = {"/opt/lokinet/bin/lokinet_uninstall.sh", nullptr};
|
|
|
|
FILE* pipe = stdout;
|
2020-11-16 12:57:03 +00:00
|
|
|
|
2020-11-16 13:07:25 +00:00
|
|
|
return AuthorizationExecuteWithPrivileges(authorizationRef, tool, kAuthorizationFlagDefaults, args, &pipe);
|
2020-11-16 12:57:03 +00:00
|
|
|
}
|
|
|
|
|