29
29
#include < polkit-qt5-1/PolkitQt1/Subject>
30
30
#endif
31
31
32
- const QString s_PolkitAction = " com.deepin.bootmaker" ;
32
+ const QString s_PolkitActionCreate = " com.deepin.bootmaker.create" ;
33
+ const QString s_PolkitActionReboot = " com.deepin.bootmaker.reboot" ;
33
34
34
35
/* *
35
36
@brief Polkit action authorization check.
@@ -38,11 +39,14 @@ const QString s_PolkitAction = "com.deepin.bootmaker";
38
39
@note Available on linux/unix/macos platform.
39
40
@return check passed.
40
41
*/
41
- bool checkAuthorization (qint64 pid)
42
+ bool checkAuthorization (qint64 pid, const QString &action )
42
43
{
43
44
#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC)
44
45
PolkitQt1::Authority::Result ret = PolkitQt1::Authority::instance ()->checkAuthorizationSync (
45
- s_PolkitAction, PolkitQt1::UnixProcessSubject (pid), PolkitQt1::Authority::AllowUserInteraction);
46
+ action,
47
+ PolkitQt1::UnixProcessSubject (pid),
48
+ PolkitQt1::Authority::AllowUserInteraction);
49
+
46
50
if (PolkitQt1::Authority::Yes == ret) {
47
51
return true ;
48
52
} else {
@@ -141,10 +145,8 @@ BootMakerService::~BootMakerService()
141
145
void BootMakerService::Reboot ()
142
146
{
143
147
Q_D (BootMakerService);
144
- if (!d->checkCaller ()) {
145
- return ;
146
- }
147
- d->bm ->reboot ();
148
+ if (checkAuthorization (d->dbusCallerPid (), s_PolkitActionReboot))
149
+ d->bm ->reboot ();
148
150
}
149
151
150
152
void BootMakerService::Start ()
@@ -189,7 +191,7 @@ bool BootMakerService::Install(const QString &image, const QString &device, cons
189
191
return false ;
190
192
}
191
193
192
- if (!d->disableCheck && !checkAuthorization (d->dbusCallerPid ())) {
194
+ if (!d->disableCheck && !checkAuthorization (d->dbusCallerPid (), s_PolkitActionCreate )) {
193
195
return false ;
194
196
}
195
197
0 commit comments