-
Couldn't load subscription status.
- Fork 29
Avoid polling token endpoint after login request cancelled #903
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
base: main
Are you sure you want to change the base?
Changes from all commits
c5beec4
a461f10
9615413
26a86d4
791edc2
c576d00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| data: | ||
| err: invalid access authentication key: invalid | ||
| err: invalid authentication reply: invalid |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FIRST CALL: | ||
| access: | ||
| msg: | ||
| err: can't check authentication: invalid access authentication key: invalid | ||
| err: can't check authentication: invalid authentication reply: invalid |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,13 @@ import ( | |
| "fmt" | ||
| "os" | ||
| "runtime" | ||
| "syscall" | ||
| "time" | ||
|
|
||
| "github.com/msteinert/pam/v2" | ||
| "github.com/ubuntu/authd/log" | ||
| "github.com/ubuntu/authd/pam/internal/dbusmodule" | ||
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -25,6 +27,19 @@ func init() { | |
| // calling the dbus services from the process and so that the module PID | ||
| // check won't fail. | ||
| runtime.LockOSThread() | ||
|
|
||
| // Ask the kernel to send SIGTERM if the parent dies | ||
| if err := unix.Prctl(unix.PR_SET_PDEATHSIG, uintptr(syscall.SIGTERM), 0, 0, 0); err != nil { | ||
| log.Errorf(context.Background(), "failed to set PDEATHSIG: %v", err) | ||
| os.Exit(1) | ||
|
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I was wondering to use the same too... But maybe we can handle it also client-side, on the dbus side... Let me check that too. However this is fine. The changes on broker instead I'd hold since I had some refactoring there for another branch, and that side is quite delicate sadly (as we may cancel too early). |
||
| } | ||
|
|
||
| // Check if parent is still alive | ||
| ppid := unix.Getppid() | ||
| if ppid == 1 { | ||
| log.Error(context.Background(), "parent is already gone; exiting") | ||
| os.Exit(1) | ||
| } | ||
| } | ||
|
|
||
| func mainFunc() error { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this create a race?
CancelIsAuthenticatedis not a blocking call, so (also considering that the "wait" was removed on theIsAuthenticatedfunction) we can end up returning to PAM without the broker being "ready" to handle a new call, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? It also uses
BusObject.CallWithContextfrom thedbuspackage, which according to the documentation waits for a reply.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the dbus call returns, but if you look at the
CancelIsAuthenticatedfunc on the broker side, it's not waiting for the cancellation to be done, it just requests a cancel and then theIsAuthenticatedfunc that returns whether it was cancelled or not. Did it make sense? It's not easy to explain