kryptco / kr

DEPRECATED A dev tool for SSH auth + Git commit/tag signing using a key stored in Krypton.
https://krypt.co/developers/
Other
1.59k stars 109 forks source link

PREFIX not being honored for `kr sshconfig` ? #194

Closed ghost closed 6 years ago

ghost commented 6 years ago

When using a custom PREFIX as in the install process for FreeBSD, the sshconfig values are not updated to honor the PREFIX. It is unclear why this does not work, so I am patching the source directly in our FreeBSD package builds. The issue is somewhere around here:

https://github.com/kryptco/kr/blob/master/kr/kr_unix.go#L15-L21

Somehow the PREFIX is being lost before this point, so regardless of the build environment the ssh config is always populated with

        PKCS11Provider /usr/lib/kr-pkcs11.so
        ProxyCommand /usr/bin/krssh %h %p

when you run kr sshconfig

I expect if the PREFIX=/usr/local that these point to /usr/local/lib and /usr/local/bin

kcking commented 6 years ago

One reason might be that sshconfig is modified at runtime. Is the PREFIX env var still set at runtime? Perhaps a better way would be to see where kr is on the path and derive PREFIX from that.

ghost commented 6 years ago

No, PREFIX is not set at runtime. You are 100% correct and I have just reproduced this. I did not think to try with PREFIX at runtime. This is definitely a bug because PREFIX is something that generally only exists in build environments to modify software for the OS at compile time.

ghost commented 6 years ago

Would it be enough to patch it like this?

const DEFAULT_PREFIX = os.Getenv("PREFIX")

edit: Not all build environments may set a PREFIX, though... I don't know go well enough to know if you can express something like

const DEFAULT_PREFIX = os.Getenv("PREFIX") ? "/usr"
kcking commented 6 years ago

I don't think so, that Getenv is only run at runtime so I don't think it will change anything. The best option I can think of is to infer it from which kr

kcking commented 6 years ago

This was fixed with https://github.com/kryptco/kr/commit/a51b73256ef435ed64a8518367b02821d0169326