1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

judge manager before unlocking

Signed-off-by: allencloud <allen.sun@daocloud.io>
(cherry picked from commit 972a246c67)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
allencloud 2016-11-17 11:12:21 +08:00 committed by Victor Vieux
parent 10ce88227d
commit cd587419d0

View file

@ -587,6 +587,15 @@ func (c *Cluster) GetUnlockKey() (string, error) {
// UnlockSwarm provides a key to decrypt data that is encrypted at rest.
func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error {
c.RLock()
if !c.isActiveManager() {
if err := c.errNoManager(); err != ErrSwarmLocked {
c.RUnlock()
return err
}
}
c.RUnlock()
key, err := encryption.ParseHumanReadableKey(req.UnlockKey)
if err != nil {
return err