mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Fixes a serialisation bug - encoding/gob does not directly support serializing `map[string]interface{}`, so we serialise to JSON and send a byte array in the RPC call, and deserialize and update on the receiver.
This commit is contained in:
parent
070d3610ff
commit
17eeec6895
@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"sync"
|
||||
@ -213,7 +214,12 @@ func S3PeersUpdateBucketListener(bucket string, lcfg []listenerConfig) {
|
||||
// S3PeersUpdateBucketPolicy - Sends update bucket policy request to
|
||||
// all peers. Currently we log an error and continue.
|
||||
func S3PeersUpdateBucketPolicy(bucket string, pCh policyChange) {
|
||||
setBPPArgs := &SetBPPArgs{Bucket: bucket, PCh: pCh}
|
||||
byts, err := json.Marshal(pCh)
|
||||
if err != nil {
|
||||
errorIf(err, "Failed to marshal policyChange - this is a BUG!")
|
||||
return
|
||||
}
|
||||
setBPPArgs := &SetBPPArgs{Bucket: bucket, PChBytes: byts}
|
||||
peers := globalS3Peers.GetPeers()
|
||||
errsMap := globalS3Peers.SendRPC(peers, "S3.SetBucketPolicyPeer", setBPPArgs)
|
||||
for peer, err := range errsMap {
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
package cmd
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s3 *s3PeerAPIHandlers) LoginHandler(args *RPCLoginArgs, reply *RPCLoginReply) error {
|
||||
jwt, err := newJWT(defaultInterNodeJWTExpiry)
|
||||
@ -128,8 +131,8 @@ type SetBPPArgs struct {
|
||||
|
||||
Bucket string
|
||||
|
||||
// policy config
|
||||
PCh policyChange
|
||||
// Policy change (serialized to JSON)
|
||||
PChBytes []byte
|
||||
}
|
||||
|
||||
// tell receiving server to update a bucket policy
|
||||
@ -145,5 +148,10 @@ func (s3 *s3PeerAPIHandlers) SetBucketPolicyPeer(args SetBPPArgs, reply *Generic
|
||||
return errServerNotInitialized
|
||||
}
|
||||
|
||||
return globalBucketPolicies.SetBucketPolicy(args.Bucket, args.PCh)
|
||||
var pCh policyChange
|
||||
if err := json.Unmarshal(args.PChBytes, &pCh); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return globalBucketPolicies.SetBucketPolicy(args.Bucket, pCh)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user