Allow the UI to set a passphrase before creation instead of asking.
This commit is contained in:
parent
46c3536a4c
commit
7edc601a36
|
@ -78,19 +78,13 @@ void luks::init()
|
||||||
bool luks::create(Report& report, const QString& deviceNode) const
|
bool luks::create(Report& report, const QString& deviceNode) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_innerFs);
|
Q_ASSERT(m_innerFs);
|
||||||
QPointer<DecryptLuksDialog> dlg = new DecryptLuksDialog(0, deviceNode); //TODO: parent widget instead of 0
|
Q_ASSERT(!m_passphrase.isEmpty());
|
||||||
|
|
||||||
if (dlg->exec() != QDialog::Accepted)
|
|
||||||
{
|
|
||||||
delete dlg;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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"));
|
||||||
std::vector<QStringList> args;
|
std::vector<QStringList> args;
|
||||||
args.push_back({ dlg->luksPassphrase().text() });
|
args.push_back({ m_passphrase });
|
||||||
args.push_back({ QStringLiteral("-s"),
|
args.push_back({ QStringLiteral("-s"),
|
||||||
QStringLiteral("512"),
|
QStringLiteral("512"),
|
||||||
QStringLiteral("luksFormat"),
|
QStringLiteral("luksFormat"),
|
||||||
|
@ -104,11 +98,10 @@ bool luks::create(Report& report, const QString& deviceNode) const
|
||||||
commands.push_back(QStringLiteral("echo"));
|
commands.push_back(QStringLiteral("echo"));
|
||||||
commands.push_back(QStringLiteral("cryptsetup"));
|
commands.push_back(QStringLiteral("cryptsetup"));
|
||||||
args.clear();
|
args.clear();
|
||||||
args.push_back({ dlg->luksPassphrase().text() });
|
args.push_back({ m_passphrase });
|
||||||
args.push_back({ QStringLiteral("luksOpen"),
|
args.push_back({ QStringLiteral("luksOpen"),
|
||||||
deviceNode,
|
deviceNode,
|
||||||
dlg->luksName().text() });
|
QStringLiteral("luks-") + readUUID(deviceNode) });
|
||||||
delete dlg;
|
|
||||||
|
|
||||||
ExternalCommand openCmd(commands, args);
|
ExternalCommand openCmd(commands, args);
|
||||||
if (!(openCmd.run(-1) && openCmd.exitCode() == 0))
|
if (!(openCmd.run(-1) && openCmd.exitCode() == 0))
|
||||||
|
@ -175,6 +168,11 @@ QString luks::cryptCloseTitle() const
|
||||||
return i18nc("@title:menu", "Deactivate");
|
return i18nc("@title:menu", "Deactivate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void luks::setPassphrase(const QString& passphrase)
|
||||||
|
{
|
||||||
|
m_passphrase = passphrase;
|
||||||
|
}
|
||||||
|
|
||||||
bool luks::canMount(const QString& deviceNode) const
|
bool luks::canMount(const QString& deviceNode) const
|
||||||
{
|
{
|
||||||
return m_isCryptOpen &&
|
return m_isCryptOpen &&
|
||||||
|
|
|
@ -95,6 +95,8 @@ public:
|
||||||
QString cryptOpenTitle() const;
|
QString cryptOpenTitle() const;
|
||||||
QString cryptCloseTitle() const;
|
QString cryptCloseTitle() const;
|
||||||
|
|
||||||
|
void setPassphrase(const QString&);
|
||||||
|
|
||||||
virtual bool canMount(const QString&) const;
|
virtual bool canMount(const QString&) const;
|
||||||
virtual bool canUnmount(const QString&) const;
|
virtual bool canUnmount(const QString&) const;
|
||||||
bool isMounted() const;
|
bool isMounted() const;
|
||||||
|
@ -143,6 +145,7 @@ private:
|
||||||
mutable FileSystem* m_innerFs;
|
mutable FileSystem* m_innerFs;
|
||||||
|
|
||||||
mutable bool m_isCryptOpen;
|
mutable bool m_isCryptOpen;
|
||||||
|
QString m_passphrase;
|
||||||
bool m_isMounted;
|
bool m_isMounted;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue