Panic when calling Set() on Ubuntu 20.04 on WSL
Piccirello opened this issue · comments
Calling keyring.Set()
on Ubuntu 20.04 on WSL results in the following panic: panic: runtime error: slice bounds out of range
. On Ubuntu 18.04 on the same machine, keyring.Set()
fails more gracefully, returning the error exec: "dbus-launch": executable file not found in $PATH
. I've included a minimal PoC to reproduce.
OS: Microsoft Windows Server Version 1809
package main
import (
"fmt"
"github.com/zalando/go-keyring"
)
func main() {
if err := keyring.Set("my-service", "foo", "bar"); err != nil {
fmt.Printf("Error: %s", err)
} else {
fmt.Printf("Success!")
}
}
Ubuntu 20.04 on WSL:
thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
panic: runtime error: slice bounds out of range [308:282]
goroutine 1 [running]:
github.com/godbus/dbus.getSessionBusPlatformAddress(0x59090f, 0x18, 0x0, 0x0)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn_other.go:30 +0x295
github.com/godbus/dbus.getSessionBusAddress(0x0, 0x0, 0x0, 0x0)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:96 +0xf8
github.com/godbus/dbus.SessionBusPrivate(0x7f85a58ece20, 0xc00008cd18, 0x40d430)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:101 +0x25
github.com/godbus/dbus.SessionBus(0x0, 0x0, 0x0)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/godbus/dbus@v4.1.0+incompatible/conn.go:73 +0xb5
github.com/zalando/go-keyring/secret_service.NewSecretService(0x40d430, 0xc00008cd80, 0x44bfa5)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/secret_service/secret_service.go:50 +0x26
github.com/zalando/go-keyring.secretServiceProvider.Set(0x58d634, 0xa, 0x58c369, 0x3, 0x58c357, 0x3, 0x0, 0x0)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/keyring_linux.go:14 +0x5d
github.com/zalando/go-keyring.Set(...)
/Users/thomas/Documents/projects/go/pkg/mod/github.com/zalando/go-keyring@v0.1.0/keyring.go:27
main.main()
/Users/thomas/Documents/projects/go/src/github.com/DopplerHQ/cli/keyring-poc.go:10 +0x78
Ubuntu 18.04 on WSL:
thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
Error: exec: "dbus-launch": executable file not found in $PATH
Thanks for reporting this. Since this panic happens deep inside the godbus library it may have to be reported there if there is a way to replicate it outside of go-keyring
. As a first step we could try to update the library version and see if it has already been addressed.
Aha! That update seems to have fixed the panic:
Build:
thomas $ go get github.com/zalando/go-keyring@4d37811583adde6f2c303662712b318405f279ff
go: github.com/zalando/go-keyring 4d37811583adde6f2c303662712b318405f279ff => v0.1.1-0.20210112083600-4d37811583ad
go: downloading github.com/zalando/go-keyring v0.1.1-0.20210112083600-4d37811583ad
go: downloading github.com/godbus/dbus/v5 v5.0.3
thomas $ GOOS=linux go build -o keyring keyring-poc.go
Execution:
thomas@windows-server-2019:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
thomas@windows-server-2019:~$ /mnt/c/Users/thomas/Desktop/keyring
Error: dbus: couldn't determine address of session bus
Cool! Thanks for testing it!
Thanks for putting up a fix! Will there be a new release for these changes, or should I remain pinned to the specific commit?
@Piccirello We have made a new release now: https://github.com/zalando/go-keyring/releases/tag/v0.1.1