Use KPasswordDialog to open LUKS containers.
This commit is contained in:
parent
f1210d0aa7
commit
a1026d20be
|
@ -57,6 +57,7 @@ find_package(KF5 REQUIRED
|
||||||
IconThemes
|
IconThemes
|
||||||
KIO
|
KIO
|
||||||
Service
|
Service
|
||||||
|
WidgetsAddons
|
||||||
)
|
)
|
||||||
|
|
||||||
# use sane compile flags
|
# use sane compile flags
|
||||||
|
|
|
@ -45,6 +45,7 @@ target_link_libraries( kpmcore
|
||||||
KF5::IconThemes
|
KF5::IconThemes
|
||||||
KF5::KIOCore
|
KF5::KIOCore
|
||||||
KF5::Service
|
KF5::Service
|
||||||
|
KF5::WidgetsAddons
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS kpmcore EXPORT KPMcoreTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
install(TARGETS kpmcore EXPORT KPMcoreTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
#include "fs/filesystemfactory.h"
|
#include "fs/filesystemfactory.h"
|
||||||
|
|
||||||
#include "gui/decryptluksdialog.h"
|
|
||||||
|
|
||||||
#include "util/capacity.h"
|
#include "util/capacity.h"
|
||||||
#include "util/externalcommand.h"
|
#include "util/externalcommand.h"
|
||||||
#include "util/report.h"
|
#include "util/report.h"
|
||||||
|
@ -34,6 +32,7 @@
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <KPasswordDialog>
|
||||||
|
|
||||||
namespace FS
|
namespace FS
|
||||||
{
|
{
|
||||||
|
@ -246,15 +245,12 @@ bool luks::cryptOpen(QWidget* parent, const QString& deviceNode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<DecryptLuksDialog> dlg = new DecryptLuksDialog(parent, deviceNode);
|
KPasswordDialog dlg( parent );
|
||||||
|
dlg.setPrompt(i18n("Enter passphrase for %1:", deviceNode));
|
||||||
if (dlg->exec() != QDialog::Accepted)
|
if( !dlg.exec() )
|
||||||
{
|
|
||||||
delete dlg;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
QString passphrase = dlg->luksPassphrase().text();
|
QString passphrase = dlg.password();
|
||||||
std::vector<QString> commands;
|
std::vector<QString> commands;
|
||||||
commands.push_back(QStringLiteral("echo"));
|
commands.push_back(QStringLiteral("echo"));
|
||||||
commands.push_back(QStringLiteral("cryptsetup"));
|
commands.push_back(QStringLiteral("cryptsetup"));
|
||||||
|
@ -263,7 +259,6 @@ bool luks::cryptOpen(QWidget* parent, const QString& deviceNode)
|
||||||
args.push_back({ QStringLiteral("open"),
|
args.push_back({ QStringLiteral("open"),
|
||||||
deviceNode,
|
deviceNode,
|
||||||
suggestedMapperName(deviceNode) });
|
suggestedMapperName(deviceNode) });
|
||||||
delete dlg;
|
|
||||||
|
|
||||||
ExternalCommand cmd(commands, args);
|
ExternalCommand cmd(commands, args);
|
||||||
if (!(cmd.run(-1) && cmd.exitCode() == 0))
|
if (!(cmd.run(-1) && cmd.exitCode() == 0))
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
set(GUI_SRC
|
set(GUI_SRC
|
||||||
gui/decryptluksdialog.cpp
|
|
||||||
gui/decryptluksdialogwidget.cpp
|
|
||||||
gui/partresizerwidget.cpp
|
gui/partresizerwidget.cpp
|
||||||
gui/partwidget.cpp
|
gui/partwidget.cpp
|
||||||
gui/partwidgetbase.cpp
|
gui/partwidgetbase.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GUI_LIB_HDRS
|
set(GUI_LIB_HDRS
|
||||||
gui/decryptluksdialog.h
|
|
||||||
gui/decryptluksdialogwidget.h
|
|
||||||
gui/partresizerwidget.h
|
gui/partresizerwidget.h
|
||||||
gui/partwidget.h
|
gui/partwidget.h
|
||||||
gui/partwidgetbase.h
|
gui/partwidgetbase.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(gui_UIFILES
|
|
||||||
gui/decryptluksdialogwidgetbase.ui
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*************************************************************************
|
|
||||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or *
|
|
||||||
* modify it under the terms of the GNU General Public License as *
|
|
||||||
* published by the Free Software Foundation; either version 3 of *
|
|
||||||
* the License, or (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#include "gui/decryptluksdialog.h"
|
|
||||||
#include "gui/decryptluksdialogwidget.h"
|
|
||||||
|
|
||||||
#include "core/device.h"
|
|
||||||
#include "core/partitiontable.h"
|
|
||||||
|
|
||||||
#include <KLocalizedString>
|
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
DecryptLuksDialog::DecryptLuksDialog(QWidget* parent, const QString& deviceNode) :
|
|
||||||
QDialog(parent),
|
|
||||||
m_DialogWidget(new DecryptLuksDialogWidget(this)),
|
|
||||||
m_DeviceNode(deviceNode)
|
|
||||||
{
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
|
||||||
setLayout(mainLayout);
|
|
||||||
mainLayout->addWidget(&widget());
|
|
||||||
setWindowTitle(xi18nc("@title:window", "Decrypt LUKS partition on <filename>%1</filename>", this->deviceNode()));
|
|
||||||
|
|
||||||
QDialogButtonBox* dialogButtonBox = new QDialogButtonBox;
|
|
||||||
QPushButton* decryptButton = new QPushButton;
|
|
||||||
decryptButton->setText(i18nc("@action:button", "&Decrypt"));
|
|
||||||
decryptButton->setIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
|
|
||||||
dialogButtonBox->addButton(decryptButton, QDialogButtonBox::AcceptRole);
|
|
||||||
mainLayout->addWidget(dialogButtonBox);
|
|
||||||
connect(dialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*************************************************************************
|
|
||||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or *
|
|
||||||
* modify it under the terms of the GNU General Public License as *
|
|
||||||
* published by the Free Software Foundation; either version 3 of *
|
|
||||||
* the License, or (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#if !defined(DECRYPTLUKSDIALOG__H)
|
|
||||||
|
|
||||||
#define DECRYPTLUKSDIALOG__H
|
|
||||||
|
|
||||||
#include "gui/decryptluksdialogwidget.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class Device;
|
|
||||||
|
|
||||||
class DecryptLuksDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DecryptLuksDialog(QWidget* parent, const QString& deviceNode);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DecryptLuksDialogWidget& widget() { return *m_DialogWidget; }
|
|
||||||
const DecryptLuksDialogWidget& widget() const { return *m_DialogWidget; }
|
|
||||||
const QString& deviceNode() const { return m_DeviceNode; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
DecryptLuksDialogWidget* m_DialogWidget;
|
|
||||||
const QString& m_DeviceNode;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QLineEdit& luksPassphrase() { return widget().luksPassphrase(); }
|
|
||||||
const QLineEdit& luksPassphrase() const { return widget().luksPassphrase(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*************************************************************************
|
|
||||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or *
|
|
||||||
* modify it under the terms of the GNU General Public License as *
|
|
||||||
* published by the Free Software Foundation; either version 3 of *
|
|
||||||
* the License, or (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#include "gui/decryptluksdialogwidget.h"
|
|
||||||
|
|
||||||
DecryptLuksDialogWidget::DecryptLuksDialogWidget(QWidget* parent) :
|
|
||||||
QWidget(parent)
|
|
||||||
{
|
|
||||||
setupUi(this);
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*************************************************************************
|
|
||||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or *
|
|
||||||
* modify it under the terms of the GNU General Public License as *
|
|
||||||
* published by the Free Software Foundation; either version 3 of *
|
|
||||||
* the License, or (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
* This program is distributed in the hope that it will be useful, *
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
||||||
* GNU General Public License for more details. *
|
|
||||||
* *
|
|
||||||
* You should have received a copy of the GNU General Public License *
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
#if !defined(DECRYPTLUKSDIALOGWIDGET__H)
|
|
||||||
|
|
||||||
#define DECRYPTLUKSDIALOGWIDGET__H
|
|
||||||
|
|
||||||
#include "ui_decryptluksdialogwidgetbase.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
|
|
||||||
class DecryptLuksDialogWidget : public QWidget, public Ui::DecryptLuksDialogWidgetBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DecryptLuksDialogWidget(QWidget* parent);
|
|
||||||
|
|
||||||
QLineEdit& luksPassphrase() { return *m_LineEditPassphrase; }
|
|
||||||
const QLineEdit& luksPassphrase() const { return *m_LineEditPassphrase; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DecryptLuksDialogWidgetBase</class>
|
|
||||||
<widget class="QWidget" name="DecryptLuksDialogWidgetBase">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>377</width>
|
|
||||||
<height>122</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_Pass">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Passphrase:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>m_LineEditPassphrase</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="m_LineEditPassphrase">
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
Loading…
Reference in New Issue