VirtualBox

Changeset 96967 in vbox


Ignore:
Timestamp:
Oct 3, 2022 1:17:31 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153888
Message:

FE/Qt: bugref:10293: Machine settings / System page: A possibility to manually reset secure boot keys to default.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r96430 r96967  
    858858}
    859859
    860 bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent /* = 0*/) const
     860bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent /* = 0 */) const
    861861{
    862862    return questionBinary(pParent, MessageType_Question,
    863863                          tr("<p>There are unsaved changes in the port forwarding configuration.</p>"
    864864                             "<p>If you proceed your changes will be discarded.</p>"),
     865                          0 /* auto-confirm id */,
     866                          QString() /* ok button text */,
     867                          QString() /* cancel button text */,
     868                          false /* ok button by default? */);
     869}
     870
     871bool UIMessageCenter::confirmRestoringDefaultKeys(QWidget *pParent /* = 0 */) const
     872{
     873    return questionBinary(pParent, MessageType_Question,
     874                          tr("<p>Are you going to restore default secure boot keys.</p>"
     875                             "<p>If you proceed your current keys will be rewritten. "
     876                             "You may not be able to boot affected VM anymore.</p>"),
    865877                          0 /* auto-confirm id */,
    866878                          QString() /* ok button text */,
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r96407 r96967  
    317317        bool warnAboutRulesConflict(QWidget *pParent = 0) const;
    318318        bool confirmCancelingPortForwardingDialog(QWidget *pParent = 0) const;
     319        bool confirmRestoringDefaultKeys(QWidget *pParent = 0) const;
    319320    /** @} */
    320321
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMotherboardFeaturesEditor.cpp

    r96877 r96967  
    3030#include <QGridLayout>
    3131#include <QLabel>
     32#include <QPushButton>
    3233
    3334/* GUI includes: */
     35#include "UIIconPool.h"
     36#include "UIMessageCenter.h"
    3437#include "UIMotherboardFeaturesEditor.h"
    3538
     
    4649    , m_pCheckBoxEnableEfi(0)
    4750    , m_pCheckBoxEnableSecureBoot(0)
     51    , m_pPushButtonResetSecureBoot(0)
    4852{
    4953    prepare();
     
    124128           ? m_pCheckBoxEnableSecureBoot->checkState() == Qt::Checked
    125129           : m_fEnableSecureBoot;
     130}
     131
     132bool UIMotherboardFeaturesEditor::isResetSecureBoot() const
     133{
     134    return   m_pPushButtonResetSecureBoot
     135           ? m_pPushButtonResetSecureBoot->property("clicked_once").toBool()
     136           : false;
    126137}
    127138
     
    166177        m_pCheckBoxEnableSecureBoot->setToolTip(tr("When checked, the secure boot emulation will be enabled."));
    167178    }
     179    if (m_pPushButtonResetSecureBoot)
     180    {
     181        m_pPushButtonResetSecureBoot->setText(tr("&Reset Keys to Default"));
     182        m_pPushButtonResetSecureBoot->setToolTip(tr("Resets secure boot keys to default."));
     183    }
    168184}
    169185
     
    171187{
    172188    /* Acquire actual feature state: */
    173     const bool fOn = m_pCheckBoxEnableEfi ? m_pCheckBoxEnableEfi->isChecked() : false;
     189    const bool fOn = m_pCheckBoxEnableEfi
     190                   ? m_pCheckBoxEnableEfi->isChecked()
     191                   : false;
    174192
    175193    /* Update corresponding controls: */
     
    179197    /* Notify listeners: */
    180198    emit sigChangedEfi();
     199    sltHandleEnableSecureBootToggling();
     200}
     201
     202void UIMotherboardFeaturesEditor::sltHandleEnableSecureBootToggling()
     203{
     204    /* Acquire actual feature state: */
     205    const bool fOn =    m_pCheckBoxEnableEfi
     206                     && m_pCheckBoxEnableSecureBoot
     207                     && m_pPushButtonResetSecureBoot
     208                   ?    m_pCheckBoxEnableEfi->isChecked()
     209                     && m_pCheckBoxEnableSecureBoot->isChecked()
     210                     && !m_pPushButtonResetSecureBoot->property("clicked_once").toBool()
     211                   : false;
     212
     213    /* Update corresponding controls: */
     214    if (m_pPushButtonResetSecureBoot)
     215        m_pPushButtonResetSecureBoot->setEnabled(fOn);
     216
     217    /* Notify listeners: */
     218    emit sigChangedSecureBoot();
     219}
     220
     221void UIMotherboardFeaturesEditor::sltResetSecureBoot()
     222{
     223    if (!m_pPushButtonResetSecureBoot->property("clicked_once").toBool())
     224    {
     225        if (msgCenter().confirmRestoringDefaultKeys())
     226        {
     227            m_pPushButtonResetSecureBoot->setProperty("clicked_once", true);
     228            sltHandleEnableSecureBootToggling();
     229        }
     230    }
    181231}
    182232
     
    226276        {
    227277            connect(m_pCheckBoxEnableSecureBoot, &QCheckBox::stateChanged,
    228                     this, &UIMotherboardFeaturesEditor::sigChangedSecureBoot);
     278                    this, &UIMotherboardFeaturesEditor::sltHandleEnableSecureBootToggling);
    229279            m_pLayout->addWidget(m_pCheckBoxEnableSecureBoot, 3, 1);
     280        }
     281        /* Prepare 'reset secure boot' tool-button: */
     282        m_pPushButtonResetSecureBoot = new QPushButton(this);
     283        if (m_pPushButtonResetSecureBoot)
     284        {
     285            m_pPushButtonResetSecureBoot->setIcon(UIIconPool::iconSet(":/refresh_16px"));
     286            connect(m_pPushButtonResetSecureBoot, &QPushButton::clicked,
     287                    this, &UIMotherboardFeaturesEditor::sltResetSecureBoot);
     288            m_pLayout->addWidget(m_pPushButtonResetSecureBoot, 4, 1);
    230289        }
    231290    }
     
    233292    /* Fetch states: */
    234293    sltHandleEnableEfiToggling();
     294    sltHandleEnableSecureBootToggling();
    235295
    236296    /* Apply language settings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMotherboardFeaturesEditor.h

    r96877 r96967  
    3939class QGridLayout;
    4040class QLabel;
     41class QPushButton;
    4142
    4243/** QWidget subclass used as motherboard features editor. */
     
    8182    bool isEnabledSecureBoot() const;
    8283
     84    /** Returns 'reset to default secure boot keys' feature value. */
     85    bool isResetSecureBoot() const;
     86
    8387    /** Returns minimum layout hint. */
    8488    int minimumLabelHorizontalHint() const;
     
    9599    /** Handles 'enable EFI' feature being toggled. */
    96100    void sltHandleEnableEfiToggling();
     101    /** Handles 'enable secure boot' feature being toggled. */
     102    void sltHandleEnableSecureBootToggling();
     103
     104    /** Marks corresponding push button activated. */
     105    void sltResetSecureBoot();
    97106
    98107private:
     
    116125     * @{ */
    117126        /** Holds the main layout instance. */
    118         QGridLayout *m_pLayout;
     127        QGridLayout  *m_pLayout;
    119128        /** Holds the label instance. */
    120         QLabel      *m_pLabel;
     129        QLabel       *m_pLabel;
    121130        /** Holds the 'enable IO APIC' check-box instance. */
    122         QCheckBox   *m_pCheckBoxEnableIoApic;
     131        QCheckBox    *m_pCheckBoxEnableIoApic;
    123132        /** Holds the 'enable UTC time' check-box instance. */
    124         QCheckBox   *m_pCheckBoxEnableUtcTime;
     133        QCheckBox    *m_pCheckBoxEnableUtcTime;
    125134        /** Holds the 'enable EFI' check-box instance. */
    126         QCheckBox   *m_pCheckBoxEnableEfi;
    127         /** Holds the 'enable secure boot' check-box instance. */
    128         QCheckBox   *m_pCheckBoxEnableSecureBoot;
     135        QCheckBox    *m_pCheckBoxEnableEfi;
     136        /** Holds the 'secure boot' check-box instance. */
     137        QCheckBox    *m_pCheckBoxEnableSecureBoot;
     138        /** Holds the 'secure boot' tool-button instance. */
     139        QPushButton  *m_pPushButtonResetSecureBoot;
    129140    /** @} */
    130141};
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r96804 r96967  
    7575        , m_fAvailableSecureBoot(false)
    7676        , m_fEnabledSecureBoot(false)
     77        , m_fResetSecureBoot(false)
    7778        /* CPU data: */
    7879        , m_cCPUCount(-1)
     
    106107               && (m_fAvailableSecureBoot == other.m_fAvailableSecureBoot)
    107108               && (m_fEnabledSecureBoot == other.m_fEnabledSecureBoot)
     109               && (m_fResetSecureBoot == other.m_fResetSecureBoot)
    108110               /* CPU data: */
    109111               && (m_cCPUCount == other.m_cCPUCount)
     
    152154    /** Holds whether the secure boot is enabled. */
    153155    bool                m_fEnabledSecureBoot;
     156    /** Holds whether the secure boot is reseted. */
     157    bool                m_fResetSecureBoot;
    154158
    155159    /** Holds the CPU count. */
     
    295299                                       ? comStoreLvl2.GetSecureBootEnabled()
    296300                                       : false;
     301    oldSystemData.m_fResetSecureBoot = false;
    297302
    298303    /* Gather old 'Processor' data: */
     
    409414        newSystemData.m_fAvailableSecureBoot = m_pCache->base().m_fAvailableSecureBoot;
    410415        newSystemData.m_fEnabledSecureBoot = m_pEditorMotherboardFeatures->isEnabledSecureBoot();
     416        newSystemData.m_fResetSecureBoot = m_pEditorMotherboardFeatures->isResetSecureBoot();
    411417    }
    412418
     
    9981004        }
    9991005        /* Save whether secure boot is enabled: */
    1000         if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledSecureBoot != oldSystemData.m_fEnabledSecureBoot)
     1006        if (   fSuccess && isMachineOffline()
     1007            && (   newSystemData.m_fEnabledSecureBoot != oldSystemData.m_fEnabledSecureBoot
     1008                || newSystemData.m_fResetSecureBoot != oldSystemData.m_fResetSecureBoot))
    10011009        {
    10021010            CNvramStore comStoreLvl1 = m_machine.GetNonVolatileStore();
     
    10071015                && newSystemData.m_fEnabledEFI)
    10081016            {
    1009                 /* Secure boot was NOT available? */
    1010                 if (!newSystemData.m_fAvailableSecureBoot)
     1017                /* Secure boot was NOT available
     1018                 * or requested to be reseted: */
     1019                if (   !newSystemData.m_fAvailableSecureBoot
     1020                    || newSystemData.m_fResetSecureBoot)
    10111021                {
    1012                     /* Init and enroll everything: */
    1013                     comStoreLvl1.InitUefiVariableStore(0);
     1022                    /* Init if required: */
     1023                    if (!newSystemData.m_fAvailableSecureBoot)
     1024                        comStoreLvl1.InitUefiVariableStore(0);
     1025                    /* Enroll everything: */
    10141026                    comStoreLvl2 = comStoreLvl1.GetUefiVariableStore();
    10151027                    comStoreLvl2.EnrollOraclePlatformKey();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette