lunixbochs / go-keychain

Simple OS keychain bindings for password storage in Go (Golang)
MIT License
26 stars 9 forks source link

Does not compile under Linux? #4

Open marians opened 7 years ago

marians commented 7 years ago

I'm wondering whether go-keychain can be built on Linux.

I am currently testing the use of go-keychain for our CLI. The entire code and PR is here: https://github.com/giantswarm/gsctl/pull/18

The CLI is cross platform and built in a Linux container, where we cross-compile for Linux, Mac, and Windows. However I'm getting this error when attempting a build this way:

go build github.com/giantswarm/gsctl/vendor/github.com/lunixbochs/go-keychain: no buildable Go source files in /go/src/github.com/giantswarm/gsctl/vendor/github.com/lunixbochs/go-keychain

Building on Mac OS using go build directly works fine.

For details on our build command, see here: https://github.com/giantswarm/gsctl/blob/use-mac-keychain/Makefile#L35-L41

If you can answer this easily, I'd appreciate it. Otherwise I can do a more isolated test under Linux on my own.

lunixbochs commented 7 years ago

From the README:

Currently only supports OS X.

I still need to write a Linux backend. Some ideas are here: https://github.com/lunixbochs/go-keychain/pull/3#issuecomment-216379606

I could also write a stub backend for unsupported platforms (throws registered passwords away) if you just want builds to work.

marians commented 7 years ago

I'm aware that the keychain is OS X specific. In code, I am using runtime.GOOS == "darwin" to only enable the function for Mac users.

But does that mean the code cannot be built on Linux?

lunixbochs commented 7 years ago

It needs to link against libsecurity. Can your cross compiler build cgo for OS X? You might be able to make a shim (fake libsecurity that exposes the right symbols), though I'm not sure about linking frameworks from cross-linux.

lunixbochs commented 7 years ago

https://github.com/karalabe/xgo might help

marians commented 7 years ago

Thanks so far, I'll check out if that is usable for us!

lunixbochs commented 7 years ago

I also just found https://github.com/tmc/keyring which has a native Linux SecretService interface, but shells out to access the OS X keychain