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

chore: [security] add polkit with setSingleInstance #363

Merged
merged 1 commit into from
Oct 10, 2024
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
17 changes: 10 additions & 7 deletions deepin-devicemanager/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ int main(int argc, char *argv[])
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
SingleDeviceManager app(argc, argv);
app.setAutoActivateWindows(true);
DBusDriverInterface::getInstance();

Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication",
UnixProcessSubject(getpid()),
Authority::AllowUserInteraction);
if (result != Authority::Yes)
return 0;

// 保证进程唯一性
qputenv("DTK_USE_SEMAPHORE_SINGLEINSTANCE", "1");
Expand All @@ -92,6 +85,16 @@ int main(int argc, char *argv[])
app.setApplicationDescription(QObject::tr("Device Manager is a handy tool for viewing hardware information and managing the devices.") + "\n");
const QString acknowledgementLink = "https://www.deepin.org/original/device-manager/";
app.setApplicationAcknowledgementPage(acknowledgementLink);

if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) {
exit(0);
}
Authority::Result result = Authority::instance()->checkAuthorizationSync("com.deepin.deepin-devicemanager.checkAuthentication",
UnixProcessSubject(getpid()),
Authority::AllowUserInteraction);
if (result != Authority::Yes)
return 0;

DApplicationSettings settinAgs;
Dtk::Core::DLogManager::registerFileAppender();

Expand Down
Loading