Skip to content

Commit fb28669

Browse files
minio disable ListBucket (#729)
Co-authored-by: nallux-dozryl <nallux-dozryl@protonmail.com>
1 parent c96a53e commit fb28669

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

goseg/docker/minio.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"groundseg/config"
88
"groundseg/structs"
9+
"io/ioutil"
910
"os"
1011
"path/filepath"
1112
"strings"
@@ -227,14 +228,25 @@ mcRunning:
227228
if _, err := ExecDockerCommand(containerName, createCommand); err != nil {
228229
return err
229230
}
230-
publicCommand := []string{
231+
232+
// write the script
233+
scriptContent := fmt.Sprintf(
234+
`{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":"*","Action":["s3:GetObject"],"Resource":["arn:aws:s3:::%s/*"]}]}`,
235+
"bucket",
236+
)
237+
scriptPath := filepath.Join(config.DockerDir, containerName, "_data", "policy.json")
238+
err = ioutil.WriteFile(scriptPath, []byte(scriptContent), 0755) // make the script executable
239+
if err != nil {
240+
return err
241+
}
242+
policyCommand := []string{
231243
"mc",
232244
"anonymous",
233-
"set",
234-
"download",
245+
"set-json",
246+
"/data/policy.json",
235247
fmt.Sprintf("patp_%s/bucket", patp),
236248
}
237-
if _, err := ExecDockerCommand(containerName, publicCommand); err != nil {
249+
if _, err := ExecDockerCommand(containerName, policyCommand); err != nil {
238250
return err
239251
}
240252
return nil

0 commit comments

Comments
 (0)