Skip to content

Commit 055e74f

Browse files
authored
fix: [247629/reboot] no auth aquired on reboot (#61)
as title. Log: fix security issue. Bug: https://pms.uniontech.com/bug-view-247629.html
1 parent fcf4445 commit 055e74f

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/service/bootmakerservice.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
#include <polkit-qt5-1/PolkitQt1/Subject>
3030
#endif
3131

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";
3334

3435
/**
3536
@brief Polkit action authorization check.
@@ -38,11 +39,14 @@ const QString s_PolkitAction = "com.deepin.bootmaker";
3839
@note Available on linux/unix/macos platform.
3940
@return check passed.
4041
*/
41-
bool checkAuthorization(qint64 pid)
42+
bool checkAuthorization(qint64 pid, const QString &action)
4243
{
4344
#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC)
4445
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+
4650
if (PolkitQt1::Authority::Yes == ret) {
4751
return true;
4852
} else {
@@ -141,10 +145,8 @@ BootMakerService::~BootMakerService()
141145
void BootMakerService::Reboot()
142146
{
143147
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();
148150
}
149151

150152
void BootMakerService::Start()
@@ -189,7 +191,7 @@ bool BootMakerService::Install(const QString &image, const QString &device, cons
189191
return false;
190192
}
191193

192-
if (!d->disableCheck && !checkAuthorization(d->dbusCallerPid())) {
194+
if (!d->disableCheck && !checkAuthorization(d->dbusCallerPid(), s_PolkitActionCreate)) {
193195
return false;
194196
}
195197

src/service/data/com.deepin.bootmaker.policy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<policyconfig>
66
<vendor>LinuxDeepin</vendor>
77
<vendor_url>https://www.deepin.com/</vendor_url>
8-
<action id="com.deepin.bootmaker">
8+
<action id="com.deepin.bootmaker.create">
99
<message>To create a bootable USB drive you need to authenticate.</message>
1010
<message xml:lang="zh_CN">创建启动盘需要您进行认证。</message>
1111
<message xml:lang="zh_HK">創建啓動盤需要您進行認證。</message>
@@ -18,4 +18,17 @@
1818
<annotate key="org.freedesktop.policykit.exec.path">/usr/lib/deepin-daemon/deepin-boot-maker-service</annotate>
1919
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
2020
</action>
21+
<action id="com.deepin.bootmaker.reboot">
22+
<message>Authentication is required to reboot the operating system.</message>
23+
<message xml:lang="zh_CN">重启操作系统需要认证。</message>
24+
<message xml:lang="zh_HK">重啓作業系統需要認證。</message>
25+
<message xml:lang="zh_TW">重啟作業系統需要認證。</message>
26+
<defaults>
27+
<allow_any>no</allow_any>
28+
<allow_inactive>no</allow_inactive>
29+
<allow_active>auth_admin_keep</allow_active>
30+
</defaults>
31+
<annotate key="org.freedesktop.policykit.exec.path">/usr/lib/deepin-daemon/deepin-boot-maker-service</annotate>
32+
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
33+
</action>
2134
</policyconfig>

0 commit comments

Comments
 (0)