Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
deepin-boot-maker (6.0.16) unstable; urgency=medium

* fix(disk): use temp file instead of shell pipe for fdisk input
* refactor(auth): remove unnecessary Polkit authorization checks

-- wangrong <wangrong@uniontech.com> Thu, 14 May 2026 19:33:59 +0800

deepin-boot-maker (6.0.15) unstable; urgency=medium

* Revert "deps: migrate from p7zip-full to 7zip package"
Expand Down
41 changes: 0 additions & 41 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,14 @@
#include <util/utils.h>
#include <QDebug>
#include <DLog>
#include <DApplication>

Check warning on line 14 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DWidgetUtil>

Check warning on line 15 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DWidgetUtil> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 15 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DWidgetUtil> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DGuiApplicationHelper>

Check warning on line 16 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 16 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <DApplicationSettings>
#endif

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if defined (Q_OS_LINUX)
#include <polkit-qt5-1/PolkitQt1/Authority>
#include <polkit-qt5-1/PolkitQt1/Subject>
#endif
#else
#if defined (Q_OS_LINUX)
#include <polkit-qt6-1/PolkitQt1/Authority>
#include <polkit-qt6-1/PolkitQt1/Subject>
#endif
#endif

const QString s_PolkitActionCreate = "com.deepin.bootmaker.create";


DCORE_USE_NAMESPACE
DWIDGET_USE_NAMESPACE
Expand Down Expand Up @@ -68,27 +53,6 @@

#endif

// 在前端中预先进行身份验证, 便于流程控制
bool checkAuthorization()
{
#if defined (Q_OS_LINUX)
QString busName = QDBusConnection::systemBus().baseService();
auto authority = PolkitQt1::Authority::instance();
if (!authority) {
qWarning() << "Failed to get Polkit authority instance";
return false;
}
PolkitQt1::Authority::Result ret = authority->checkAuthorizationSync(
s_PolkitActionCreate,
PolkitQt1::SystemBusNameSubject(busName),
PolkitQt1::Authority::AllowUserInteraction);

return PolkitQt1::Authority::Yes == ret;
#else
return true;
#endif
}

int main(int argc, char **argv)
{
qInfo() << "Starting Boot Maker application";
Expand All @@ -114,11 +78,6 @@
// app.setApplicationVersion(DApplication::buildVersion(VERSION));
// app.setTheme("light");

if (!checkAuthorization()) {
qInfo() << "Authorization failed, exiting";
return 1;
}

#ifdef Q_OS_MAC
qDebug() << "Checking root privileges on macOS";
if (switchToRoot(app)) {
Expand Down
22 changes: 4 additions & 18 deletions src/service/bootmakerservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,14 @@ void BootMakerService::Reboot()

void BootMakerService::Start()
{
Q_D(BootMakerService);
qInfo() << "Start requested";
if (!d->checkAuthorization(s_PolkitActionCreate)) {
qWarning() << "Start request denied - Authorization failed";
return;
}

// 启动服务, 不会修改系统, 不需要鉴权
qDebug() << "Starting Boot Maker";
emit s_StartBootMarker();
}

void BootMakerService::Stop()
{
Q_D(BootMakerService);
qInfo() << "Stop requested";
if (!d->checkAuthorization(s_PolkitActionCreate)) {
qWarning() << "Stop request denied - Authorization failed";
return;
}

// 停止服务, 不会修改系统, 不需要鉴权
qDebug() << "Stopping Boot Maker Service";
qApp->exit(0);
}
Expand All @@ -158,12 +146,9 @@ void BootMakerService::Stop()
//! return json of devicelist
QString BootMakerService::DeviceList()
{
// BootMaker::deviceList() 是只读操作, 不需要鉴权
Q_D(BootMakerService);
qDebug() << "Device list requested";
if (!d->checkAuthorization(s_PolkitActionCreate)) {
qWarning() << "Device list request denied - Authorization failed";
return "";
}
return deviceListToJson(d->bm->deviceList());
}

Expand All @@ -184,6 +169,7 @@ bool BootMakerService::Install(const QString &image, const QString &device, cons

bool BootMakerService::CheckFile(const QString &filepath)
{
// BootMaker::checkfile() 是只读操作, 不需要鉴权
Q_D(BootMakerService);
qDebug() << "File check requested:" << filepath;
return d->bm->checkfile(filepath);
Expand Down
16 changes: 13 additions & 3 deletions src/vendor/src/libxsys/DiskUtil/DiskUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

Expand Down Expand Up @@ -642,8 +642,18 @@ bool CreatePartition(const QString& diskDev)

qDebug() << "Creating partition for disk" << diskDev;

QString cmd = QString("echo -e 'o\\nn\\np\\n1\\n\\n\\nw' | fdisk ") + diskDev;
XSys::Result result = XSys::SynExec("bash", "-c \"" + cmd + "\"");
QTemporaryFile tmpFile;
if (!tmpFile.open()) {
qWarning() << "Failed to create fdisk input file:" << tmpFile.errorString();
return false;
}
QTextStream out(&tmpFile);
out << "o\nn\np\n1\n\n\nw\n";
tmpFile.close();

XSys::Result result = XSys::SynExec(XSys::FS::SearchBin("fdisk"),
diskDev,
tmpFile.fileName());

if (!result.isSuccess()) {
qWarning() << "Failed to create partition table with fdisk for" << diskDev;
Expand Down
Loading