Skip to content

Commit

Permalink
polkit: do not shadow dbus errors, avoid panic in case of errors
Browse files Browse the repository at this point in the history
With the current code, when the dbus call fails with an error we will shadow it
with our own error. In the process of doing so, we try to access a map in
authResult that is uninitialized, accessing a key will cause a panic.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
  • Loading branch information
bboozzoo committed Mar 8, 2018
1 parent 1b05ab9 commit fd048f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion polkit/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ func checkAuthorization(subject authSubject, actionId string, details map[string
err = authority.Call(
"org.freedesktop.PolicyKit1.Authority.CheckAuthorization", 0,
subject, actionId, details, flags, "").Store(&result)
if err != nil || !result.IsAuthorized {
if err != nil {
return false, err
}
if !result.IsAuthorized {
if result.IsChallenge {
err = ErrInteraction
} else if result.Details["polkit.dismissed"] != "" {
Expand Down

0 comments on commit fd048f8

Please sign in to comment.