X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/16f704326f44fd1e5e5e60b936c9b5895d6a6ff8..9aae71fdbdf2c923f792a2fb064c11091b19f3dd:/lib/dispatchcloud/worker/verify.go diff --git a/lib/dispatchcloud/worker/verify.go b/lib/dispatchcloud/worker/verify.go index e22c85d009..559bb28973 100644 --- a/lib/dispatchcloud/worker/verify.go +++ b/lib/dispatchcloud/worker/verify.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" - "git.curoverse.com/arvados.git/lib/cloud" + "git.arvados.org/arvados.git/lib/cloud" "golang.org/x/crypto/ssh" ) @@ -21,13 +21,21 @@ var ( instanceSecretLength = 40 // hex digits ) -type tagVerifier struct { +type TagVerifier struct { cloud.Instance + Secret string + ReportVerified func(cloud.Instance) } -func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) error { - expectSecret := tv.Instance.Tags()[tagKeyInstanceSecret] - if err := tv.Instance.VerifyHostKey(pubKey, client); err != cloud.ErrNotImplemented || expectSecret == "" { +func (tv TagVerifier) InitCommand() cloud.InitCommand { + return cloud.InitCommand(fmt.Sprintf("umask 0177 && echo -n %q >%s", tv.Secret, instanceSecretFilename)) +} + +func (tv TagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) error { + if tv.ReportVerified != nil { + tv.ReportVerified(tv.Instance) + } + if err := tv.Instance.VerifyHostKey(pubKey, client); err != cloud.ErrNotImplemented || tv.Secret == "" { // If the wrapped instance indicates it has a way to // verify the key, return that decision. return err @@ -49,7 +57,7 @@ func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) er if err != nil { return err } - if stdout.String() != expectSecret { + if stdout.String() != tv.Secret { return errBadInstanceSecret } return nil