agent: guard against empty keyring files

This commit is contained in:
Ryan Uber 2014-10-02 17:14:52 -07:00
parent db0084ccd0
commit daebf39946
1 changed files with 5 additions and 0 deletions

View File

@ -50,6 +50,11 @@ func loadKeyringFile(c *serf.Config) error {
keysDecoded[i] = keyBytes
}
// Guard against empty keyring
if len(keysDecoded) == 0 {
return fmt.Errorf("no keys present in keyring file: %s", c.KeyringFile)
}
// Create the keyring
keyring, err := memberlist.NewKeyring(keysDecoded, keysDecoded[0])
if err != nil {