Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Using back command 'r' in native UI can be racy #719

Open
2 tasks done
3v1n0 opened this issue Jan 9, 2025 · 0 comments · May be fixed by #818
Open
2 tasks done

Issue: Using back command 'r' in native UI can be racy #719

3v1n0 opened this issue Jan 9, 2025 · 0 comments · May be fixed by #818
Assignees
Labels
bug Something isn't working jira

Comments

@3v1n0
Copy link
Collaborator

3v1n0 commented Jan 9, 2025

@3v1n0 3v1n0 added the bug Something isn't working label Jan 9, 2025
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 27, 2025
@3v1n0 3v1n0 self-assigned this Feb 27, 2025
@3v1n0 3v1n0 added the jira label Feb 27, 2025
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 27, 2025
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 27, 2025
…oking it

In some cases (when the "goback" request via the 'r' cancel key was
performed very quickly) on the UI we might have ended in calling the
nativeAuthSelection request when we were still technically performing
the stage change from challenge to auth-mode selection.

This was particularly a problem in the "Wait" cases, given that these
events could have been arriving without a proper order, because the
cancellation of the previous event could lead to a delayed stage-change
request that we didn't handle, but it could happen also in non-wait
cases, for example

  authd-pam-exec-DEBUG: 23:46:32.560: authenticate: called method
    Prompt((1, 'Gimme your password:\n> '))
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:3}
  *adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset"
  *adapter.authModeSelectionModel: Focus"
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
  	(tea.Cmd)(0xc96b00), (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

or:

  authenticate: called method Prompt((2, 'Choose action:\n> '))
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1496660)}
  adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset
  *adapter.authModeSelectionModel: Focus
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1483980), (tea.Cmd)(0x1496660)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

As visible, the nativeStageChangeRequest (which triggered the selection
via nativeAuthSelection{}) was arriving *before* that the request of
changing the internal stage value (via nativeChangeStage{}) was actually
delivered. And this prevented nativeAuthSelection{} to actually do
anything (or any other stage-change request in general).

So basically we need to ensure that the request is happening only after
the internal stage is changed, and this is now fixed by relying on the
main StageChange event request that eventually will update the internal
state, after we're triggering again nativeStageChangeRequest{}.

Closes: ubuntu#719
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 27, 2025
In some cases (when the "goback" request via the 'r' cancel key was
performed very quickly) on the UI we might have ended in calling the
nativeAuthSelection request when we were still technically performing
the stage change from challenge to auth-mode selection.

This was particularly a problem in the "Wait" cases, given that these
events could have been arriving without a proper order, because the
cancellation of the previous event could lead to a delayed stage-change
request that we didn't handle, but it could happen also in non-wait
cases, for example

  authd-pam-exec-DEBUG: 23:46:32.560: authenticate: called method
    Prompt((1, 'Gimme your password:\n> '))
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:3}
  *adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset"
  *adapter.authModeSelectionModel: Focus"
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
  	(tea.Cmd)(0xc96b00), (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

or:

  authenticate: called method Prompt((2, 'Choose action:\n> '))
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1496660)}
  adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset
  *adapter.authModeSelectionModel: Focus
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1483980), (tea.Cmd)(0x1496660)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

As visible, the nativeStageChangeRequest (which triggered the selection
via nativeAuthSelection{}) was arriving *before* that the request of
changing the internal stage value (via nativeChangeStage{}) was actually
delivered. And this prevented nativeAuthSelection{} to actually do
anything (or any other stage-change request in general).

So basically we need to ensure that the request is happening only after
the internal stage is changed, and this is now fixed by relying on the
main StageChange event request that eventually will update the internal
state, after we're triggering again nativeStageChangeRequest{}.

Closes: ubuntu#719
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 28, 2025
3v1n0 added a commit to 3v1n0/authd that referenced this issue Feb 28, 2025
In some cases (when the "goback" request via the 'r' cancel key was
performed very quickly) on the UI we might have ended in calling the
nativeAuthSelection request when we were still technically performing
the stage change from challenge to auth-mode selection.

This was particularly a problem in the "Wait" cases, given that these
events could have been arriving without a proper order, because the
cancellation of the previous event could lead to a delayed stage-change
request that we didn't handle, but it could happen also in non-wait
cases, for example

  authd-pam-exec-DEBUG: 23:46:32.560: authenticate: called method
    Prompt((1, 'Gimme your password:\n> '))
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:3}
  *adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset"
  *adapter.authModeSelectionModel: Focus"
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
  	(tea.Cmd)(0xc96b00), (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

or:

  authenticate: called method Prompt((2, 'Choose action:\n> '))
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1496660)}
  adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset
  *adapter.authModeSelectionModel: Focus
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1483980), (tea.Cmd)(0x1496660)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

As visible, the nativeStageChangeRequest (which triggered the selection
via nativeAuthSelection{}) was arriving *before* that the request of
changing the internal stage value (via nativeChangeStage{}) was actually
delivered. And this prevented nativeAuthSelection{} to actually do
anything (or any other stage-change request in general).

So basically we need to ensure that the request is happening only after
the internal stage is changed, and this is now fixed by relying on the
main StageChange event request that eventually will update the internal
state, after we're triggering again nativeStageChangeRequest{}.

Closes: ubuntu#719
3v1n0 added a commit to 3v1n0/authd that referenced this issue Mar 3, 2025
In some cases (when the "goBack{}" request via the 'r' cancel key is
performed very quickly on the UI) we might end up doing a
nativeAuthSelection{} request when we are still technically performing
the stage change from the challenge stage to auth-mode selection.

This was particularly a problem in the "Wait" cases, given that these
events could have been arriving without a proper order, because the
cancellation of the previous event could lead to a delayed stage-change
request that we didn't handle, but it could happen also in non-wait
cases, for example

  authd-pam-exec-DEBUG: 23:46:32.560: authenticate: called method
    Prompt((1, 'Gimme your password:\n> '))
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
    (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:3}
  *adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset"
  *adapter.authModeSelectionModel: Focus"
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0xca47c0),
        (tea.Cmd)(0xc96b00), (tea.Cmd)(0xca47c0)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

or:

  authenticate: called method Prompt((2, 'Choose action:\n> '))
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(nil)}
  Native model update: adapter.nativeGoBack{}
  adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.isAuthenticatedCancelled{msg:""}
  Native model update: adapter.nativeStageChangeRequest{Stage:2}
  Native model update: adapter.nativeChangeStage{Stage:3}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1496660)}
  adapter.ChangeStage{Stage:2}
  *adapter.authenticationModel: Reset
  *adapter.authModeSelectionModel: Focus
  Native model update: adapter.nativeAuthSelection{}
  Native model update: tea.sequenceMsg{(tea.Cmd)(0x1496660),
    (tea.Cmd)(0x1483980), (tea.Cmd)(0x1496660)}
  Native model update: adapter.nativeChangeStage{Stage:2}
  adapter.authModeSelectionModel: adapter.authModeSelectionFocused{}
  Native model update: adapter.authModeSelectionFocused{}

As visible, the nativeStageChangeRequest (which triggered the selection
via nativeAuthSelection{}) was arriving *before* that the request of
changing the internal stage value (via nativeChangeStage{}) was actually
delivered. And this prevented nativeAuthSelection{} to anything (or any
other stage-change request in general).

So, basically we need to ensure that the request is happening only after
the internal stage is changed, and this is now fixed by relying on the
main StageChange event request that eventually will update the internal
state, after we're triggering again nativeStageChangeRequest{}.

Closes: ubuntu#719
3v1n0 added a commit to 3v1n0/authd that referenced this issue Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jira
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant