1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

fix(greeter): Allow empty password submits to reach PAM

This commit is contained in:
purian23
2026-03-11 16:13:26 -04:00
committed by bbedward
parent 3ff9564c9b
commit 78357d45bb

View File

@@ -363,21 +363,21 @@ Item {
} }
function submitBufferedPassword() { function submitBufferedPassword() {
if (!GreeterState.passwordBuffer || GreeterState.passwordBuffer.length === 0)
return false;
pendingPasswordResponse = false; pendingPasswordResponse = false;
resetPasswordSessionTransition(true); resetPasswordSessionTransition(true);
awaitingExternalAuth = false; awaitingExternalAuth = false;
authTimeout.interval = defaultAuthTimeoutMs; authTimeout.interval = defaultAuthTimeoutMs;
authTimeout.restart(); authTimeout.restart();
Greetd.respond(GreeterState.passwordBuffer); // Some PAM stacks expect an explicit empty response to advance U2F/fprint or fail normally.
Greetd.respond(GreeterState.passwordBuffer || "");
GreeterState.passwordBuffer = ""; GreeterState.passwordBuffer = "";
inputField.text = ""; inputField.text = "";
return true; return true;
} }
function requestPasswordSessionTransition() { function requestPasswordSessionTransition() {
if (!GreeterState.passwordBuffer || GreeterState.passwordBuffer.length === 0) const hasPasswordBuffer = GreeterState.passwordBuffer && GreeterState.passwordBuffer.length > 0;
if (!passwordSubmitRequested && !hasPasswordBuffer)
return; return;
if (cancelingExternalAuthForPassword) if (cancelingExternalAuthForPassword)
return; return;
@@ -402,32 +402,33 @@ Item {
Greetd.cancelSession(); Greetd.cancelSession();
} }
function startAuthSession() { function startAuthSession(submitPassword) {
submitPassword = submitPassword === true;
if (!GreeterState.showPasswordInput || !GreeterState.username) if (!GreeterState.showPasswordInput || !GreeterState.username)
return; return;
if (GreeterState.unlocking) if (GreeterState.unlocking)
return; return;
const hasPasswordBuffer = GreeterState.passwordBuffer && GreeterState.passwordBuffer.length > 0; const hasPasswordBuffer = GreeterState.passwordBuffer && GreeterState.passwordBuffer.length > 0;
if (Greetd.state !== GreetdState.Inactive) { if (Greetd.state !== GreetdState.Inactive) {
if (pendingPasswordResponse && hasPasswordBuffer) if (pendingPasswordResponse && submitPassword)
submitBufferedPassword(); submitBufferedPassword();
else if (hasPasswordBuffer) else if (submitPassword)
passwordSubmitRequested = true; passwordSubmitRequested = true;
return; return;
} }
if (cancelingExternalAuthForPassword) { if (cancelingExternalAuthForPassword) {
if (hasPasswordBuffer) if (submitPassword)
passwordSubmitRequested = true; passwordSubmitRequested = true;
return; return;
} }
if (!hasPasswordBuffer && !root.greeterExternalAuthAvailable) if (!submitPassword && !hasPasswordBuffer && !root.greeterExternalAuthAvailable)
return; return;
pendingPasswordResponse = false; pendingPasswordResponse = false;
passwordSubmitRequested = hasPasswordBuffer; passwordSubmitRequested = submitPassword;
awaitingExternalAuth = !hasPasswordBuffer && root.greeterExternalAuthAvailable; awaitingExternalAuth = !submitPassword && !hasPasswordBuffer && root.greeterExternalAuthAvailable;
// Included PAM stacks (system-auth/common-auth/password-auth) may still run // Included PAM stacks (system-auth/common-auth/password-auth) may still run
// biometric/U2F modules before password even when DMS toggles are off. // biometric/U2F modules before password even when DMS toggles are off.
const waitingOnPamExternalBeforePassword = hasPasswordBuffer && root.greeterPamHasExternalAuth; const waitingOnPamExternalBeforePassword = submitPassword && root.greeterPamHasExternalAuth;
authTimeout.interval = (awaitingExternalAuth || waitingOnPamExternalBeforePassword) ? externalAuthTimeoutMs : defaultAuthTimeoutMs; authTimeout.interval = (awaitingExternalAuth || waitingOnPamExternalBeforePassword) ? externalAuthTimeoutMs : defaultAuthTimeoutMs;
authTimeout.restart(); authTimeout.restart();
Greetd.createSession(GreeterState.username); Greetd.createSession(GreeterState.username);
@@ -448,7 +449,7 @@ Item {
return; return;
externalAuthAutoStartedForUser = GreeterState.username; externalAuthAutoStartedForUser = GreeterState.username;
startAuthSession(); startAuthSession(false);
} }
function isExternalAuthPrompt(message, responseRequired) { function isExternalAuthPrompt(message, responseRequired) {
@@ -838,7 +839,7 @@ Item {
} }
onAccepted: { onAccepted: {
if (GreeterState.showPasswordInput) { if (GreeterState.showPasswordInput) {
root.startAuthSession(); root.startAuthSession(true);
} else { } else {
if (text.trim()) { if (text.trim()) {
root.submitUsername(text); root.submitUsername(text);
@@ -959,7 +960,7 @@ Item {
buttonSize: 32 buttonSize: 32
visible: GreeterState.showPasswordInput && root.greeterExternalAuthAvailable && GreeterState.passwordBuffer.length === 0 && (Greetd.state === GreetdState.Inactive || awaitingExternalAuth || pendingPasswordResponse) && !GreeterState.unlocking visible: GreeterState.showPasswordInput && root.greeterExternalAuthAvailable && GreeterState.passwordBuffer.length === 0 && (Greetd.state === GreetdState.Inactive || awaitingExternalAuth || pendingPasswordResponse) && !GreeterState.unlocking
enabled: visible enabled: visible
onClicked: root.startAuthSession() onClicked: root.startAuthSession(false)
} }
DankActionButton { DankActionButton {
id: virtualKeyboardButton id: virtualKeyboardButton
@@ -992,7 +993,7 @@ Item {
enabled: true enabled: true
onClicked: { onClicked: {
if (GreeterState.showPasswordInput) { if (GreeterState.showPasswordInput) {
root.startAuthSession(); root.startAuthSession(true);
} else { } else {
if (inputField.text.trim()) { if (inputField.text.trim()) {
root.submitUsername(inputField.text); root.submitUsername(inputField.text);
@@ -1613,14 +1614,16 @@ Item {
function onStateChanged() { function onStateChanged() {
if (Greetd.state === GreetdState.Inactive) { if (Greetd.state === GreetdState.Inactive) {
const resumePasswordSubmit = cancelingExternalAuthForPassword && passwordSubmitRequested && GreeterState.passwordBuffer && GreeterState.passwordBuffer.length > 0; const resumePasswordSubmit = cancelingExternalAuthForPassword && passwordSubmitRequested;
awaitingExternalAuth = false; awaitingExternalAuth = false;
pendingPasswordResponse = false; pendingPasswordResponse = false;
cancelingExternalAuthForPassword = false; cancelingExternalAuthForPassword = false;
authTimeout.interval = defaultAuthTimeoutMs; authTimeout.interval = defaultAuthTimeoutMs;
authTimeout.stop(); authTimeout.stop();
if (resumePasswordSubmit) { if (resumePasswordSubmit) {
Qt.callLater(root.startAuthSession); Qt.callLater(function() {
root.startAuthSession(true);
});
return; return;
} }
resetPasswordSessionTransition(true); resetPasswordSessionTransition(true);