From 91ad3461f4b7117927cd4df0020e93dd34e8e570 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Mon, 29 Sep 2014 13:44:51 -0700 Subject: [PATCH] command: fix panic when client RPC is asked for a keyring operation --- command/agent/rpc.go | 5 +++++ command/keyring.go | 14 -------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/command/agent/rpc.go b/command/agent/rpc.go index e64084d177..c4fe71f70a 100644 --- a/command/agent/rpc.go +++ b/command/agent/rpc.go @@ -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) } diff --git a/command/keyring.go b/command/keyring.go index e06248d42b..cc6d211a83 100644 --- a/command/keyring.go +++ b/command/keyring.go @@ -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()