command: fix panic when client RPC is asked for a keyring operation

This commit is contained in:
Ryan Uber 2014-09-29 13:44:51 -07:00
parent 9d01174521
commit 91ad3461f4
2 changed files with 5 additions and 14 deletions

View File

@ -655,6 +655,10 @@ func (i *AgentRPC) handleKeyring(client *rpcClient, seq uint64, cmd string) erro
Error: errToString(err),
}
if queryResp == nil {
goto SEND
}
for _, kr := range queryResp.Responses {
var pool string
if kr.WAN {
@ -689,6 +693,7 @@ func (i *AgentRPC) handleKeyring(client *rpcClient, seq uint64, cmd string) erro
r.Info = append(r.Info, info)
}
SEND:
return client.Send(&header, r)
}

View File

@ -96,20 +96,6 @@ func (c *KeyringCommand) Run(args []string) int {
}
defer client.Close()
// For all key-related operations, we must be querying a server node. It is
// probably better to enforce this even for LAN pool changes, because other-
// wise, the same exact command syntax will have different results depending
// on where it was run.
s, err := client.Stats()
if err != nil {
c.Ui.Error(fmt.Sprintf("Error: %s", err))
return 1
}
if s["consul"]["server"] != "true" {
c.Ui.Error("Error: Key modification can only be handled by a server")
return 1
}
if listKeys {
c.Ui.Info("Asking all members for installed keys...")
r, err := client.ListKeys()