浏览代码

judge manager before unlocking

Signed-off-by: allencloud <allen.sun@daocloud.io>
(cherry picked from commit 972a246c671b52786a5e57743babfcf7b5b5ae99)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
allencloud 8 年之前
父节点
当前提交
cd587419d0
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      daemon/cluster/cluster.go

+ 9 - 0
daemon/cluster/cluster.go

@@ -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