Skip to content

Commit 2c1e058

Browse files
Explicitly set file permissions for admin-cluster-{bucket,iam}-export… (minio#5194)
Explicitly set file permissions for admin-cluster-{bucket,iam}-export.go to 600 regardless of umask
1 parent 0a686cf commit 2c1e058

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cmd/admin-cluster-bucket-export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func mainClusterBucketExport(ctx *cli.Context) error {
119119
}
120120
fatalIf(probe.NewError(moveFile(tmpFile.Name(), downloadPath)), "Unable to rename downloaded data, file exists at %s", tmpFile.Name())
121121

122+
// Explicitly set permissions to 0o600 and override umask
123+
// to ensure that the file is not world-readable.
124+
e = os.Chmod(downloadPath, 0o600)
125+
fatalIf(probe.NewError(e), "Unable to set file permissions for "+downloadPath)
126+
122127
if !globalJSON {
123128
console.Infof("Bucket metadata successfully downloaded as %s\n", downloadPath)
124129
return nil

cmd/admin-cluster-iam-export.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ func mainClusterIAMExport(ctx *cli.Context) error {
125125

126126
fatalIf(probe.NewError(moveFile(tmpFile.Name(), downloadPath)), "Unable to rename downloaded data, file exists at %s", tmpFile.Name())
127127

128+
// Explicitly set permissions to 0o600 and override umask
129+
// to ensure that the file is not world-readable.
130+
e = os.Chmod(downloadPath, 0o600)
131+
fatalIf(probe.NewError(e), "Unable to set file permissions for "+downloadPath)
132+
128133
if !globalJSON {
129134
console.Infof("IAM info successfully downloaded as %s\n", downloadPath)
130135
return nil

0 commit comments

Comments
 (0)