From 90d6e7df2484fdf7bbe7e614c7683906c77bd98e Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 1 Jul 2020 17:22:22 +0100 Subject: [PATCH] policy: Recalculate permission mode after setting a new one (#3280) `mc policy set` can confuse users by showing that a bucket has 'none' policy mode although issuing `mc policy get` will show it is `custom` when the bucket already other policy statements for some sub-resources. For better UX, mc will issue another request to get the real policy mode. --- cmd/policy-main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/policy-main.go b/cmd/policy-main.go index 3bb02df9..4a88ecc3 100644 --- a/cmd/policy-main.go +++ b/cmd/policy-main.go @@ -437,8 +437,11 @@ func runPolicyCmd(args cli.Args) { perms := accessPerms(args.Get(1)) targetURL := args.Get(2) if perms.isValidAccessPERM() { - probeErr = doSetAccess(ctx, targetURL, perms) operation = "set" + probeErr = doSetAccess(ctx, targetURL, perms) + if probeErr == nil { + perms, _, probeErr = doGetAccess(ctx, targetURL) + } } else if perms.isValidAccessFile() { probeErr = doSetAccessJSON(ctx, targetURL, perms) operation = "set-json"