From 4fda59f18c75cafff2f8886069c12bccf2103aaf Mon Sep 17 00:00:00 2001 From: renbin Date: Wed, 20 Dec 2023 13:08:46 +0800 Subject: [PATCH] feat: Adapt dbus security standard. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配DBus接口安全规范 * 新增systemd服务管理DBus服务 * 新增polkit鉴权配置 * DBus接口将判断调用者 * 调整UT以测试新版接口 * 调整界面以适配鉴权失败分支 Log: 更新DBus接口规范 Task: https://pms.uniontech.com/task-view-310479.html Influence: DBus systemd polkit UI UT --- debian/control | 3 +- src/app/bmwindow.cpp | 25 +++++ src/app/view/usbselectview.cpp | 33 +++--- src/app/view/usbselectview.h | 4 + src/libdbm/backend/bmdbushandler.h | 20 ++-- src/libdbm/backend/bmhandler.h | 4 +- src/libdbm/backend/bootmaker.h | 28 ++--- src/libdbm/bminterface.cpp | 2 + src/libdbm/bminterface.h | 3 +- src/service/LogManager.cpp | 8 +- src/service/bootmakerservice.cpp | 106 +++++++++++++----- src/service/bootmakerservice_p.h | 30 +++++ src/service/data/com.deepin.bootmaker.policy | 21 ++++ src/service/data/com.deepin.bootmaker.service | 5 +- src/service/data/deepin-boot-maker.service | 15 +++ src/service/service.pro | 11 +- src/service/vendor.pri | 2 +- src/tests/bootmakerservicetest.cpp | 3 + src/tests/main.cpp | 3 + src/tests/tests.pro | 6 +- 20 files changed, 251 insertions(+), 81 deletions(-) create mode 100644 src/service/bootmakerservice_p.h create mode 100644 src/service/data/com.deepin.bootmaker.policy create mode 100644 src/service/data/deepin-boot-maker.service diff --git a/debian/control b/debian/control index 5f586567..b1112901 100644 --- a/debian/control +++ b/debian/control @@ -17,7 +17,8 @@ Build-Depends: debhelper-compat (=11), libegl1-mesa-dev, libstartup-notification0-dev, libdtkwidget-dev, - libgtest-dev + libgtest-dev, + libpolkit-qt5-1-dev Standards-Version: 4.5.1 Homepage: https://github.com/linuxdeepin/deepin-boot-maker Vcs-Git: https://salsa.debian.org/pkg-deepin-team/deepin-boot-maker.git diff --git a/src/app/bmwindow.cpp b/src/app/bmwindow.cpp index 28d86826..40bb0da5 100644 --- a/src/app/bmwindow.cpp +++ b/src/app/bmwindow.cpp @@ -160,14 +160,39 @@ BMWindow::BMWindow(QWidget *parent) closeflags = false; this->setVisible(true); #endif + DWindowManagerHelper::instance()->setMotifFunctions(windowHandle(), DWindowManagerHelper::FUNC_CLOSE, false); titlebar()->setQuitMenuDisabled(true); + d->usbWidget->setEnabled(false); + +#ifdef Q_OS_WIN slideWidget(d->usbWidget, d->progressWidget); d->wsib->setCurrentPage(2); +#endif + auto isoFilePath = property("bmISOFilePath").toString(); qDebug() << "call interface install" << partition << format; emit d->interface->startInstall(isoFilePath, "", partition, format); + // Linux: wait for startInstallRet() polkit authorization check result, then animate the widget. }); + +#ifndef Q_OS_WIN + // Check polkit authorization success, not availiable on windows. + connect(d->interface, &BMInterface::startInstallRet, this, [ = ](bool success) { + if (success) { + slideWidget(d->usbWidget, d->progressWidget); + d->wsib->setCurrentPage(2); + } else { + qWarning() << "call interface install return failed"; + + d->usbWidget->resetStartInstall(); + d->usbWidget->setEnabled(true); + titlebar()->setQuitMenuDisabled(false); + DWindowManagerHelper::instance()->setMotifFunctions(windowHandle(), DWindowManagerHelper::FUNC_CLOSE, true); + } + }); +#endif + connect(d->progressWidget, &ProgressView::testCancel, this, [ = ] { setWindowFlags(windowFlags() | Qt::WindowCloseButtonHint); d->resultWidget->updateResult(BMHandler::SyscExecFailed, "title", "description"); diff --git a/src/app/view/usbselectview.cpp b/src/app/view/usbselectview.cpp index 3ac5bf76..8337f0f8 100644 --- a/src/app/view/usbselectview.cpp +++ b/src/app/view/usbselectview.cpp @@ -146,25 +146,25 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) usbPanelLayout->addSpacing(15); usbPanelLayout->addLayout(checkBoxLayout); - DSuggestButton *start = new DSuggestButton; - start->setAccessibleName("usbSelectWidget_startButton"); - start->setFocusPolicy(Qt::NoFocus); - start->setObjectName("StartMake"); - start->setText(tr("Start")); - DFontSizeManager::instance()->bind(start, DFontSizeManager::T6); - start->setDisabled(true); - start->setFixedHeight(36); + m_start = new DSuggestButton; + m_start->setAccessibleName("usbSelectWidget_startButton"); + m_start->setFocusPolicy(Qt::NoFocus); + m_start->setObjectName("StartMake"); + m_start->setText(tr("Start")); + DFontSizeManager::instance()->bind(m_start, DFontSizeManager::T6); + m_start->setDisabled(true); + m_start->setFixedHeight(36); DPushButton* pBackBtn = new DPushButton(tr("Back", "button")); pBackBtn->setAccessibleName("usbSelectWidget_backBuuton"); pBackBtn->setFocusPolicy(Qt::NoFocus); - DFontSizeManager::instance()->bind(start, DFontSizeManager::T6); + DFontSizeManager::instance()->bind(m_start, DFontSizeManager::T6); pBackBtn->setDisabled(false); pBackBtn->setFixedHeight(36); QHBoxLayout* pHlayout = new QHBoxLayout; pHlayout->setContentsMargins(20, 0, 20, 0); pHlayout->setSpacing(10); pHlayout->addWidget(pBackBtn); - pHlayout->addWidget(start); + pHlayout->addWidget(m_start); mainLayout->addWidget(m_title, 0, Qt::AlignHCenter); mainLayout->addStretch(); @@ -282,7 +282,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) } } - start->setDisabled(!hasPartitionSelected); + m_start->setDisabled(!hasPartitionSelected); if (!hasPartitionSelected) { this->setProperty("last_path", ""); @@ -332,13 +332,13 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) infoItem->setCheck(true); this->setProperty("last_path", infoItem->property("path").toString()); this->setProperty("last_fstype", infoItem->property("fstype").toString()); - start->setDisabled(false); + m_start->setDisabled(false); } m_previous = current; }); - connect(start, &DPushButton::clicked, this, [ = ] { + connect(m_start, &DPushButton::clicked, this, [ = ] { auto format = m_formatDiskCheck->isChecked(); QString usbMountPoint = XSys::DiskUtil::MountPoint(this->property("last_path").toString()); @@ -368,7 +368,7 @@ UsbSelectView::UsbSelectView(DWidget *parent) : DWidget(parent) return; } - start->setEnabled(false); + m_start->setEnabled(false); #ifdef Q_OS_LINUX if (!m_formatDiskCheck->isChecked() && "vfat" != this->property("last_fstype").toString()) { @@ -390,3 +390,8 @@ void UsbSelectView::getIsoFileSelectedPath(QString isoPath) { this->setProperty("isoFilePath",isoPath); } + +void UsbSelectView::resetStartInstall() +{ + m_start->setEnabled(true); +} diff --git a/src/app/view/usbselectview.h b/src/app/view/usbselectview.h index 32f28736..c067e6db 100644 --- a/src/app/view/usbselectview.h +++ b/src/app/view/usbselectview.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -24,11 +25,14 @@ class UsbSelectView : public DWidget void deviceSelected(const QString &partition, bool format); void finish(quint32 error, const QString &title, const QString &description); void backToPrevUI(); + public slots: void getIsoFileSelectedPath(QString isoPath); + void resetStartInstall(); private: QList m_mountDevs; QListWidgetItem *m_previous = nullptr; + DSuggestButton *m_start = nullptr; }; diff --git a/src/libdbm/backend/bmdbushandler.h b/src/libdbm/backend/bmdbushandler.h index 98afc490..1f92e839 100644 --- a/src/libdbm/backend/bmdbushandler.h +++ b/src/libdbm/backend/bmdbushandler.h @@ -26,6 +26,10 @@ class BMDbusHandler : public BMHandler if (!m_dbus->isValid()) { qDebug() << "m_dbus isValid false error:" << m_dbus->lastError(); } + + // Not default timeout (~25s), waiting for polkit authorization to complete. + m_dbus->setTimeout(INT_MAX); + qDebug() << "m_dbus isValid true"; connect(m_dbus, &BMDBusInterface::DeviceListChanged, this, [ = ](const QString & addlistJson, const QString& dellistJson) { @@ -43,24 +47,24 @@ class BMDbusHandler : public BMHandler } public slots: - void reboot() + void reboot() override { m_dbus->Reboot(); } - void start() + void start() override { qDebug() << "start"; m_dbus->Start(); qDebug() << "m_dbus Start error:" << m_dbus->lastError(); } - void stop() + void stop() override { m_dbus->Stop(); } - const QList deviceList() const + const QList deviceList() const override { qDebug() << "deviceList"; return deviceListFromJson(m_dbus->DeviceList()); @@ -69,13 +73,15 @@ public slots: bool install(const QString &image, const QString &device, const QString &partition, - bool formatDevice) + bool formatDevice) override { qDebug() << "install"; - return m_dbus->Install(image, device, partition, formatDevice); + bool ret = m_dbus->Install(image, device, partition, formatDevice); + Q_EMIT startInstallRet(ret); + return ret; } - bool checkfile(const QString &filepath) + bool checkfile(const QString &filepath) override { qDebug() << "checkfile"; return m_dbus->CheckFile(filepath); diff --git a/src/libdbm/backend/bmhandler.h b/src/libdbm/backend/bmhandler.h index 4eb23cf9..54d7ede1 100644 --- a/src/libdbm/backend/bmhandler.h +++ b/src/libdbm/backend/bmhandler.h @@ -45,8 +45,8 @@ class BMHandler : public QObject void removablePartitionsChanged(const QList &addlist, const QList& reducelist); void finished(int errcode, const QString &description); void reportProgress(int current, int error, const QString &title, const QString &description); - void reportProgress1(int current, int error, const QString &title, const QString &description); - // void checkFileResult(bool result); + void reportProgress1(int current, int error, const QString &title, const QString &description); + void startInstallRet(bool success); public slots: virtual void reboot() = 0; diff --git a/src/libdbm/backend/bootmaker.h b/src/libdbm/backend/bootmaker.h index 1840c711..ef474346 100644 --- a/src/libdbm/backend/bootmaker.h +++ b/src/libdbm/backend/bootmaker.h @@ -15,8 +15,8 @@ class BootMaker : public BMHandler Q_OBJECT public: explicit BootMaker(QObject *parent = nullptr); - virtual ~BootMaker() { - + virtual ~BootMaker() override + { if (m_pInstaller != nullptr) { delete m_pInstaller; m_pInstaller = nullptr; @@ -27,22 +27,18 @@ class BootMaker : public BMHandler m_monitorWork->wait(); m_monitorWork->deleteLater(); } - } + public slots: - void reboot(); - void start(); - void stop(); - const QList deviceList() const; - bool install(const QString &image, - const QString &device, - const QString &partition, - bool formatDevice); - bool checkfile(const QString &filepath); + void reboot() override; + void start() override; + void stop() override; + const QList deviceList() const override; + bool install(const QString &image, const QString &device, const QString &partition, bool formatDevice) override; + bool checkfile(const QString &filepath) override; private: - DeviceMonitor* m_usbDeviceMonitor = nullptr; - QtBaseInstaller* m_pInstaller; - QThread* m_monitorWork; + DeviceMonitor *m_usbDeviceMonitor = nullptr; + QtBaseInstaller *m_pInstaller = nullptr; + QThread *m_monitorWork = nullptr; }; - diff --git a/src/libdbm/bminterface.cpp b/src/libdbm/bminterface.cpp index 8eee4a92..f5838071 100644 --- a/src/libdbm/bminterface.cpp +++ b/src/libdbm/bminterface.cpp @@ -55,6 +55,8 @@ BMInterface::BMInterface(QObject *parent) : this,&BMInterface::reportProgress1); connect(this, &BMInterface::startInstall, d->handler, &BMHandler::startInstall ); + connect(d->handler, &BMHandler::startInstallRet, + this, &BMInterface::startInstallRet); } BMInterface::~BMInterface() diff --git a/src/libdbm/bminterface.h b/src/libdbm/bminterface.h index 17f88fe0..40e316e7 100644 --- a/src/libdbm/bminterface.h +++ b/src/libdbm/bminterface.h @@ -34,7 +34,8 @@ class BMInterface : public QObject, public Dtk::Core::DSingleton const QString &device, const QString &partition, bool formatDevice); -// void checkFileResult(bool result); + void startInstallRet(bool success); + public slots: void start(); void stop(); diff --git a/src/service/LogManager.cpp b/src/service/LogManager.cpp index c58bb933..52e60ec2 100644 --- a/src/service/LogManager.cpp +++ b/src/service/LogManager.cpp @@ -15,7 +15,7 @@ void DBMLogManager::initConsoleAppender() { m_consoleAppender = new ConsoleAppender; m_consoleAppender->setFormat(m_format); - logger->registerAppender(m_consoleAppender); + loggerInstance()->registerAppender(m_consoleAppender); } void DBMLogManager::initRollingFileAppender() @@ -25,7 +25,9 @@ void DBMLogManager::initRollingFileAppender() cachePath = QString("/var/log/%1").arg(qApp->organizationName()); } if (!QDir(cachePath).exists()) { - QDir(cachePath).mkpath(cachePath); + if (!QDir(cachePath).mkpath(cachePath)) { + return; + } } m_logPath = joinPath(cachePath, QString("%1.log").arg(qApp->applicationName())); @@ -33,7 +35,7 @@ void DBMLogManager::initRollingFileAppender() m_rollingFileAppender->setFormat(m_format); m_rollingFileAppender->setLogFilesLimit(5); m_rollingFileAppender->setDatePattern(RollingFileAppender::DailyRollover); - logger->registerAppender(m_rollingFileAppender); + loggerInstance()->registerAppender(m_rollingFileAppender); } //! Registers the appender to write the log records to the Console diff --git a/src/service/bootmakerservice.cpp b/src/service/bootmakerservice.cpp index 92ef3019..96476763 100644 --- a/src/service/bootmakerservice.cpp +++ b/src/service/bootmakerservice.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-only #include "bootmakerservice.h" +#include "bootmakerservice_p.h" #include #include @@ -10,6 +11,7 @@ #include #include #include +#include #include #include @@ -22,6 +24,37 @@ #include +#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC) +#include +#include +#endif + +const QString s_PolkitAction = "com.deepin.bootmaker"; + +/** + @brief Polkit action authorization check. + Use com.deepin.bootmaker.policy config file. + Default action id: "com.deepin.bootmaker" + @note Available on linux/unix/macos platform. + @return check passed. + */ +bool checkAuthorization(qint64 pid) +{ +#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) || defined (Q_OS_MAC) + PolkitQt1::Authority::Result ret = PolkitQt1::Authority::instance()->checkAuthorizationSync( + s_PolkitAction, PolkitQt1::UnixProcessSubject(pid), PolkitQt1::Authority::AllowUserInteraction); + if (PolkitQt1::Authority::Yes == ret) { + return true; + } else { + qWarning() << qPrintable("Policy authorization check failed!"); + return false; + } +#else + return true; +#endif +} + +#if 0 // Not use now int getProcIdByExeName(std::string execName) { int pid = -1; @@ -52,37 +85,20 @@ int getProcIdByExeName(std::string execName) return pid; } +#endif -static std::string getProcIdExe(int id) +static QString getProcIdExe(qint64 id) { - std::string execName; + QString execName; if (id > 0) { // Read contents of virtual /proc/{pid}/cmdline file - auto exeSymlinkPath = std::string("/proc/") + QString("%1").arg(id).toStdString() + "/exe"; - char *actualpath = realpath(exeSymlinkPath.c_str(), NULL); - execName = std::string(actualpath); + QString exeSymlinkPath = QString("/proc/%1/exe").arg(id); + char *actualpath = realpath(exeSymlinkPath.toStdString().c_str(), NULL); + execName = QString(actualpath); } return execName; } -class BootMakerServicePrivate -{ -public: - BootMakerServicePrivate(BootMakerService *parent) : q_ptr(parent) {} - ~BootMakerServicePrivate() { -// if (bm != nullptr) { -// delete bm; -// bm = nullptr; -// } - } - bool checkCaller(); - - BootMaker *bm; - - BootMakerService *q_ptr; - Q_DECLARE_PUBLIC(BootMakerService) -}; - BootMakerService::BootMakerService(QObject *parent) : QObject(parent), d_ptr(new BootMakerServicePrivate(this)) { @@ -172,6 +188,11 @@ bool BootMakerService::Install(const QString &image, const QString &device, cons if (!d->checkCaller()) { return false; } + + if (!d->disableCheck && !checkAuthorization(d->dbusCallerPid())) { + return false; + } + qDebug() << "install image:" << image << " device:" << device << " partition:" << partition; emit d->bm->startInstall(image, device, partition, formatDevice); return true; @@ -191,20 +212,45 @@ bool BootMakerService::CheckFile(const QString &filepath) bool BootMakerServicePrivate::checkCaller() { -/* + if (disableCheck) { + return true; + } + Q_Q(BootMakerService); - auto callerPid = static_cast(q->connection().interface()->servicePid(q->message().service()).value()); - auto callerExe = getProcIdExe(callerPid); - auto dbmExe = "/usr/bin/deepin-boot-maker"; -// auto dbmPid = getProcIdByExeName(); + if (!q->calledFromDBus()) { + return false; + } - qDebug() << "callerPid is: " << callerPid << "callerExe is:" << callerExe.c_str() ; + qint64 callerPid = dbusCallerPid(); + QString callerExe = getProcIdExe(callerPid); + QString dbmExe = QStandardPaths::findExecutable("deepin-boot-maker", {"/usr/bin"}); + + qDebug() << "callerPid is: " << callerPid << "callerExe is:" << callerExe; if (callerExe != dbmExe) { qDebug() << QString("caller not authorized") ; return false; } - qDebug() << QString("caller authorized");*/ + qDebug() << QString("caller authorized"); + return true; +} + +/** + @return DBus interface caller pid + If the call is not from dbus (from UT), return 0 + */ +qint64 BootMakerServicePrivate::dbusCallerPid() +{ + Q_Q(BootMakerService); + if (!q->calledFromDBus()) { + return 0; + } + + auto interface = q->connection().interface(); + if (interface) { + return static_cast(interface->servicePid(q->message().service()).value()); + } + return 0; } diff --git a/src/service/bootmakerservice_p.h b/src/service/bootmakerservice_p.h new file mode 100644 index 00000000..e097091f --- /dev/null +++ b/src/service/bootmakerservice_p.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-only + +#ifndef BOOTMAKERSERVICE_P_H +#define BOOTMAKERSERVICE_P_H + +#include "bootmakerservice.h" + +#include + +class BootMakerServicePrivate +{ +public: + explicit BootMakerServicePrivate(BootMakerService *parent) + : q_ptr(parent) + { + } + ~BootMakerServicePrivate() {} + bool checkCaller(); + qint64 dbusCallerPid(); + + bool disableCheck = false; + BootMaker *bm = nullptr; + + BootMakerService *q_ptr; + Q_DECLARE_PUBLIC(BootMakerService) +}; + +#endif // BOOTMAKERSERVICE_P_H diff --git a/src/service/data/com.deepin.bootmaker.policy b/src/service/data/com.deepin.bootmaker.policy new file mode 100644 index 00000000..6b0254c1 --- /dev/null +++ b/src/service/data/com.deepin.bootmaker.policy @@ -0,0 +1,21 @@ + + + + LinuxDeepin + https://www.deepin.com/ + + To create a bootable USB drive you need to authenticate. + 创建启动盘需要您进行认证。 + 創建啓動盤需要您進行認證。 + 創建啟動盤需要您進行認證。 + + no + no + auth_admin_keep + + /usr/lib/deepin-daemon/deepin-boot-maker-service + true + + diff --git a/src/service/data/com.deepin.bootmaker.service b/src/service/data/com.deepin.bootmaker.service index 190d8efb..2009a249 100644 --- a/src/service/data/com.deepin.bootmaker.service +++ b/src/service/data/com.deepin.bootmaker.service @@ -1,4 +1,5 @@ [D-BUS Service] Name=com.deepin.bootmaker -Exec=/usr/lib/deepin-daemon/deepin-boot-maker-service -User=root +Exec=/usr/bin/false +# Activate by sysmtemd service. +SystemdService=deepin-boot-maker.service diff --git a/src/service/data/deepin-boot-maker.service b/src/service/data/deepin-boot-maker.service new file mode 100644 index 00000000..78239ff2 --- /dev/null +++ b/src/service/data/deepin-boot-maker.service @@ -0,0 +1,15 @@ +[Unit] +Description=Deepin Boot Maker + +[Service] +Type=dbus +BusName=com.deepin.bootmaker +ExecStart=/usr/lib/deepin-daemon/deepin-boot-maker-service +StandardOutput=syslog +# Needs CAP_SYS_ADMIN umount u-disk. +CapabilityBoundingSet=~CAP_SYS_BPF CAP_NET_ADMIN +MemoryLimit=10G +IOWeight=200 + +[Install] +WantedBy=multi-user.target diff --git a/src/service/service.pro b/src/service/service.pro index a2a5b795..39528548 100644 --- a/src/service/service.pro +++ b/src/service/service.pro @@ -25,7 +25,8 @@ SOURCES += main.cpp \ HEADERS += \ bootmakerservice.h \ - LogManager.h + LogManager.h \ + bootmakerservice_p.h unix{ binary.path = $${PREFIX}/lib/deepin-daemon/ @@ -37,5 +38,11 @@ service.files = $$PWD/data/com.deepin.bootmaker.service dbus.path = $${PREFIX}/share/dbus-1/system.d/ dbus.files = $$PWD/data/com.deepin.bootmaker.conf -INSTALLS += service dbus binary +systemd.path = $${PREFIX}/lib/systemd/system +systemd.files = $$PWD/data/deepin-boot-maker.service + +policy.path = $${PREFIX}/share/polkit-1/actions +policy.files = $$PWD/data/com.deepin.bootmaker.policy + +INSTALLS += service dbus binary systemd policy } diff --git a/src/service/vendor.pri b/src/service/vendor.pri index 25435e3a..f6e34098 100644 --- a/src/service/vendor.pri +++ b/src/service/vendor.pri @@ -3,7 +3,7 @@ include($$PWD/../vendor/env.pri) unix{ QT += dbus CONFIG += link_pkgconfig - PKGCONFIG += dtkcore + PKGCONFIG += dtkcore polkit-qt5-1 } win32{ diff --git a/src/tests/bootmakerservicetest.cpp b/src/tests/bootmakerservicetest.cpp index 573cba69..b5265a40 100644 --- a/src/tests/bootmakerservicetest.cpp +++ b/src/tests/bootmakerservicetest.cpp @@ -3,11 +3,14 @@ // SPDX-License-Identifier: GPL-3.0-only #include "bootmakerservicetest.h" +#include "../service/bootmakerservice_p.h" #include + // Sets up the test fixture. void BootMakerServiceTest::SetUp() { m_bootMakerService = new BootMakerService; + m_bootMakerService->d_ptr->disableCheck = true; } // Tears down the test fixture. diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 0f6ca877..2cd5a4a1 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -11,6 +11,9 @@ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); + a.setOrganizationName("deepin"); + a.setApplicationName("deepin-boot-maker"); + ::testing::InitGoogleTest(&argc,argv); int ret = RUN_ALL_TESTS(); #ifdef QT_DEBUG diff --git a/src/tests/tests.pro b/src/tests/tests.pro index b4f395f0..c42126d5 100644 --- a/src/tests/tests.pro +++ b/src/tests/tests.pro @@ -10,7 +10,7 @@ CONFIG(debug, debug|release) { #添加安全编译参数 QMAKE_LFLAGS += -z noexecstack -pie -fPIC -z relro -z now QMAKE_CFLAGS += -fstack-protector-all -QMAKE_CXXFLAGS += -fstack-protector-all +QMAKE_CXXFLAGS += -fstack-protector-all -fno-access-control QT += core gui widgets testlib @@ -22,6 +22,7 @@ CONFIG += testcase no_testcase_installs CONFIG += resources_big PKGCONFIG += dtkwidget PKGCONFIG += dtkcore +PKGCONFIG += polkit-qt5-1 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings @@ -108,7 +109,8 @@ HEADERS += \ ../vendor/src/libxsys/FileSystem/FileSystem.h \ ../vendor/src/libxsys/DiskUtil/Syslinux.h \ ../service/bootmakerservice.h \ - ../service/LogManager.h + ../service/LogManager.h \ + ../service/bootmakerservice_p.h