mirror of
https://github.com/minio/minio.git
synced 2025-01-23 20:53:18 -05:00
api: Upon bucket delete remove in-memory state properly. (#4716)
This PR fixes the issue of cleaning up in-memory state properly. Without this PR we can lead to security situations where new bucket would inherit wrong permissions on bucket and expose objects erroneously. Fixes #4714
This commit is contained in:
parent
b918a6592f
commit
4785555d34
@ -653,12 +653,21 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http.
|
|||||||
// Delete bucket access policy, if present - ignore any errors.
|
// Delete bucket access policy, if present - ignore any errors.
|
||||||
_ = removeBucketPolicy(bucket, objectAPI)
|
_ = removeBucketPolicy(bucket, objectAPI)
|
||||||
|
|
||||||
|
// Notify all peers (including self) to update in-memory state
|
||||||
|
S3PeersUpdateBucketPolicy(bucket, policyChange{true, nil})
|
||||||
|
|
||||||
// Delete notification config, if present - ignore any errors.
|
// Delete notification config, if present - ignore any errors.
|
||||||
_ = removeNotificationConfig(bucket, objectAPI)
|
_ = removeNotificationConfig(bucket, objectAPI)
|
||||||
|
|
||||||
|
// Notify all peers (including self) to update in-memory state
|
||||||
|
S3PeersUpdateBucketNotification(bucket, nil)
|
||||||
|
|
||||||
// Delete listener config, if present - ignore any errors.
|
// Delete listener config, if present - ignore any errors.
|
||||||
_ = removeListenerConfig(bucket, objectAPI)
|
_ = removeListenerConfig(bucket, objectAPI)
|
||||||
|
|
||||||
|
// Notify all peers (including self) to update in-memory state
|
||||||
|
S3PeersUpdateBucketListener(bucket, []listenerConfig{})
|
||||||
|
|
||||||
// Write success response.
|
// Write success response.
|
||||||
writeSuccessNoContent(w)
|
writeSuccessNoContent(w)
|
||||||
}
|
}
|
||||||
|
@ -503,9 +503,8 @@ func removeNotificationConfig(bucket string, objAPI ObjectLayer) error {
|
|||||||
// Acquire a write lock on notification config before modifying.
|
// Acquire a write lock on notification config before modifying.
|
||||||
objLock := globalNSMutex.NewNSLock(minioMetaBucket, ncPath)
|
objLock := globalNSMutex.NewNSLock(minioMetaBucket, ncPath)
|
||||||
objLock.Lock()
|
objLock.Lock()
|
||||||
err := objAPI.DeleteObject(minioMetaBucket, ncPath)
|
defer objLock.Unlock()
|
||||||
objLock.Unlock()
|
return objAPI.DeleteObject(minioMetaBucket, ncPath)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove listener configuration from storage layer. Used when a bucket is deleted.
|
// Remove listener configuration from storage layer. Used when a bucket is deleted.
|
||||||
@ -516,9 +515,8 @@ func removeListenerConfig(bucket string, objAPI ObjectLayer) error {
|
|||||||
// Acquire a write lock on notification config before modifying.
|
// Acquire a write lock on notification config before modifying.
|
||||||
objLock := globalNSMutex.NewNSLock(minioMetaBucket, lcPath)
|
objLock := globalNSMutex.NewNSLock(minioMetaBucket, lcPath)
|
||||||
objLock.Lock()
|
objLock.Lock()
|
||||||
err := objAPI.DeleteObject(minioMetaBucket, lcPath)
|
defer objLock.Unlock()
|
||||||
objLock.Unlock()
|
return objAPI.DeleteObject(minioMetaBucket, lcPath)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads both notification and listener config.
|
// Loads both notification and listener config.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user