X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fdadf2969c54edc7314ca50a629f3912998087b4..84c753c29346450bae7efd8f8bcd11aa7ea71109:/lib/dispatchcloud/worker/verify.go diff --git a/lib/dispatchcloud/worker/verify.go b/lib/dispatchcloud/worker/verify.go index 3300719514..c718702101 100644 --- a/lib/dispatchcloud/worker/verify.go +++ b/lib/dispatchcloud/worker/verify.go @@ -21,13 +21,17 @@ var ( instanceSecretLength = 40 // hex digits ) -type tagVerifier struct { +type TagVerifier struct { cloud.Instance - secret string + Secret string } -func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) error { - if err := tv.Instance.VerifyHostKey(pubKey, client); err != cloud.ErrNotImplemented || tv.secret == "" { +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 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 +53,7 @@ func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) er if err != nil { return err } - if stdout.String() != tv.secret { + if stdout.String() != tv.Secret { return errBadInstanceSecret } return nil