mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-02 10:17:10 +01:00
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:
1 parent
57086977ee
commit
a898fe8e28
2 files changed
+6
-2
No files matched your search
@@ -156,7 +156,11 @@ func (c *commandS3UserProvision) Do(args []string, commandEnv *CommandEnv, write
|
||||
}
|
||||
_, err = client.CreateUser(ctx, &iam_pb.CreateUserRequest{Identity: identity})
|
||||
if err != nil {
|
||||
return fmt.Errorf("create user: %v", err)
|
||||
// Rollback: remove the policy we just created
|
||||
if _, delErr := client.DeletePolicy(ctx, &iam_pb.DeletePolicyRequest{Name: policyName}); delErr != nil {
|
||||
fmt.Fprintf(writer, "Warning: failed to rollback policy %q: %v\n", policyName, delErr)
|
||||
}
|
||||
return fmt.Errorf("create user: %w", err)
|
||||
}
|
||||
fmt.Fprintf(writer, "Created user %q with policy %q attached\n", *name, policyName)
|
||||
|
||||
|
||||
Reference in new issue
Block a user