shell: restrict export file permissions, rollback policy on user create failure

- s3.iam.export: use os.OpenFile with mode 0600 instead of os.Create
  to protect exported credentials from other users
- s3.user.provision: rollback the created policy if CreateUser fails,
  with a warning if the rollback itself fails
This commit is contained in:
Chris Lu committed 2026-04-07 12:34:41 -07:00
1 parent 57086977ee
commit a898fe8e28
2 files changed
+6 -2

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ func (c *commandS3IAMExport) Do(args []string, commandEnv *CommandEnv, writer io
var out io.Writer = writer
if *file != "" {
fp, err := os.Create(*file)
fp, err := os.OpenFile(*file, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return fmt.Errorf("create file: %v", err)
}