Téléverser les fichiers vers "workstation-setup/src"
This commit is contained in:
@@ -213,6 +213,70 @@ void ProvisioningBackend::setBusy(bool busy)
|
||||
emit busyChanged();
|
||||
}
|
||||
|
||||
|
||||
void ProvisioningBackend::resetFidoInteraction()
|
||||
{
|
||||
const bool changed = m_fidoTouchRequired
|
||||
|| m_fidoTouchRequestCount != 0
|
||||
|| !m_fidoStatus.isEmpty();
|
||||
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoTouchRequestCount = 0;
|
||||
m_fidoStatus.clear();
|
||||
m_helperStdoutBuffer.clear();
|
||||
|
||||
if (changed) {
|
||||
emit fidoInteractionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void ProvisioningBackend::handleHelperStdout(Operation operation, const QByteArray &data)
|
||||
{
|
||||
if (operation != Operation::Fido || data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_helperStdoutBuffer += data;
|
||||
|
||||
qsizetype newlineIndex = -1;
|
||||
while ((newlineIndex = m_helperStdoutBuffer.indexOf('\n')) >= 0) {
|
||||
QByteArray line = m_helperStdoutBuffer.left(newlineIndex);
|
||||
m_helperStdoutBuffer.remove(0, newlineIndex + 1);
|
||||
if (!line.isEmpty() && line.endsWith('\r')) {
|
||||
line.chop(1);
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
if (line == QByteArrayLiteral("EVENT_FIDO_INITIALIZING")) {
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoStatus = QStringLiteral("Initialisation de l'association FIDO2…");
|
||||
changed = true;
|
||||
} else if (line == QByteArrayLiteral("EVENT_FIDO_GENERATING")) {
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoStatus = QStringLiteral("Génération du secret FIDO2…");
|
||||
changed = true;
|
||||
} else if (line == QByteArrayLiteral("EVENT_FIDO_UPDATING_HOME")) {
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoStatus = QStringLiteral("Mise à jour du home chiffré…");
|
||||
changed = true;
|
||||
} else if (line == QByteArrayLiteral("EVENT_FIDO_SYNCHRONIZING")) {
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoStatus = QStringLiteral("Synchronisation des clés de chiffrement…");
|
||||
changed = true;
|
||||
} else if (line == QByteArrayLiteral("EVENT_FIDO_TOUCH_REQUIRED")) {
|
||||
m_fidoTouchRequired = true;
|
||||
++m_fidoTouchRequestCount;
|
||||
m_fidoStatus = QStringLiteral("Touchez la YubiKey maintenant — demande %1. Il peut y avoir plusieurs touchers pendant cette étape.")
|
||||
.arg(m_fidoTouchRequestCount);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
emit fidoInteractionChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProvisioningBackend::secureClear(QByteArray &data)
|
||||
{
|
||||
if (!data.isEmpty()) {
|
||||
@@ -359,6 +423,10 @@ void ProvisioningBackend::enrollFido(const QString ¤tPassword,
|
||||
return;
|
||||
}
|
||||
|
||||
resetFidoInteraction();
|
||||
m_fidoStatus = QStringLiteral("Préparation de l'association FIDO2…");
|
||||
emit fidoInteractionChanged();
|
||||
|
||||
startHelper(Operation::Fido,
|
||||
QString::fromUtf8(NIXOS_WORKSTATIONS_FIDO_HELPER_PATH),
|
||||
currentPassword,
|
||||
@@ -396,6 +464,7 @@ void ProvisioningBackend::startHelper(Operation operation,
|
||||
secureClear(third);
|
||||
|
||||
m_helperTimedOut = false;
|
||||
m_helperStdoutBuffer.clear();
|
||||
setBusy(true);
|
||||
|
||||
auto *process = new QProcess(this);
|
||||
@@ -432,6 +501,14 @@ void ProvisioningBackend::startHelper(Operation operation,
|
||||
timer->start();
|
||||
});
|
||||
|
||||
connect(process, &QProcess::readyReadStandardOutput, this,
|
||||
[this, process, operation]() {
|
||||
if (m_process != process) {
|
||||
return;
|
||||
}
|
||||
handleHelperStdout(operation, process->readAllStandardOutput());
|
||||
});
|
||||
|
||||
connect(process, &QProcess::errorOccurred, this,
|
||||
[this, process, timer, operation](QProcess::ProcessError error) {
|
||||
if (m_process != process || error != QProcess::FailedToStart) {
|
||||
@@ -443,6 +520,9 @@ void ProvisioningBackend::startHelper(Operation operation,
|
||||
process->deleteLater();
|
||||
setBusy(false);
|
||||
appendLog(operationName(operation) + QStringLiteral(" failed to start"));
|
||||
if (operation == Operation::Fido) {
|
||||
resetFidoInteraction();
|
||||
}
|
||||
emitResult(operation, false, QStringLiteral("Impossible de démarrer le composant de configuration."));
|
||||
});
|
||||
|
||||
@@ -459,6 +539,10 @@ void ProvisioningBackend::startHelper(Operation operation,
|
||||
|
||||
QByteArray stderrData = process->readAllStandardError();
|
||||
QByteArray stdoutData = process->readAllStandardOutput();
|
||||
if (operation == Operation::Fido && !stdoutData.isEmpty()) {
|
||||
handleHelperStdout(operation, stdoutData);
|
||||
stdoutData.clear();
|
||||
}
|
||||
QByteArray combined = stderrData + '\n' + stdoutData;
|
||||
|
||||
const bool timedOut = m_helperTimedOut;
|
||||
@@ -515,6 +599,14 @@ void ProvisioningBackend::startHelper(Operation operation,
|
||||
setBusy(false);
|
||||
refreshState();
|
||||
|
||||
if (operation == Operation::Fido) {
|
||||
m_fidoTouchRequired = false;
|
||||
m_fidoStatus = helperSucceeded && markerCreated
|
||||
? QStringLiteral("Association FIDO2 terminée.")
|
||||
: QStringLiteral("Association FIDO2 interrompue.");
|
||||
emit fidoInteractionChanged();
|
||||
}
|
||||
|
||||
emitResult(operation, helperSucceeded && markerCreated, message);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user