Skip to content

Commit 361944e

Browse files
Merge branch 'master' into mc_share_contentlengthrange
2 parents c831fe1 + 2676e50 commit 361944e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+978
-382
lines changed

Dockerfile.release.fips

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmd/admin-accesskey-info.go

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
package cmd
1919

2020
import (
21+
"strings"
22+
"time"
23+
24+
"github.com/charmbracelet/lipgloss"
25+
humanize "github.com/dustin/go-humanize"
2126
"github.com/minio/cli"
27+
json "github.com/minio/colorjson"
28+
"github.com/minio/madmin-go/v3"
29+
"github.com/minio/mc/pkg/probe"
2230
)
2331

2432
var adminAccesskeyInfoCmd = cli.Command{
@@ -45,6 +53,150 @@ EXAMPLES:
4553
`,
4654
}
4755

56+
type accesskeyMessage struct {
57+
op string
58+
Status string `json:"status"`
59+
AccessKey string `json:"accessKey"`
60+
SecretKey string `json:"secretKey,omitempty"`
61+
STS bool `json:"sts,omitempty"`
62+
ParentUser string `json:"parentUser,omitempty"`
63+
AccountStatus string `json:"accountStatus,omitempty"`
64+
ImpliedPolicy bool `json:"impliedPolicy,omitempty"`
65+
Policy json.RawMessage `json:"policy,omitempty"`
66+
Name string `json:"name,omitempty"`
67+
Description string `json:"description,omitempty"`
68+
Expiration *time.Time `json:"expiration,omitempty"`
69+
Provider string `json:"provider,omitempty"`
70+
ProviderInfo providerInfo `json:"providerInfo,omitempty"`
71+
}
72+
73+
func (m accesskeyMessage) String() string {
74+
labelStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#04B575")) // green
75+
o := strings.Builder{}
76+
switch m.op {
77+
case "info":
78+
expirationStr := "NONE"
79+
if m.Expiration != nil && !m.Expiration.IsZero() && !m.Expiration.Equal(timeSentinel) {
80+
expirationStr = humanize.Time(*m.Expiration)
81+
}
82+
policyStr := "embedded"
83+
if m.ImpliedPolicy {
84+
policyStr = "implied"
85+
}
86+
statusStr := "enabled"
87+
if m.AccountStatus == "off" {
88+
statusStr = "disabled"
89+
}
90+
stsStr := "false"
91+
if m.STS {
92+
stsStr = "true"
93+
}
94+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Access Key:"), m.AccessKey))
95+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Parent User:"), m.ParentUser))
96+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Status:"), statusStr))
97+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Policy:"), policyStr))
98+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Name:"), m.Name))
99+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Description:"), m.Description))
100+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Expiration:"), expirationStr))
101+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("STS:"), stsStr))
102+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Provider:"), m.Provider))
103+
if m.ProviderInfo != nil {
104+
o.WriteString(iFmt(0, "%s\n", labelStyle.Render("Provider Specific Info:")))
105+
o.WriteString(m.ProviderInfo.String())
106+
}
107+
case "create":
108+
expirationStr := "NONE"
109+
if m.Expiration != nil && !m.Expiration.IsZero() && !m.Expiration.Equal(timeSentinel) {
110+
expirationStr = m.Expiration.String()
111+
}
112+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Access Key:"), m.AccessKey))
113+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Secret Key:"), m.SecretKey))
114+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Expiration:"), expirationStr))
115+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Name:"), m.Name))
116+
o.WriteString(iFmt(0, "%s %s\n", labelStyle.Render("Description:"), m.Description))
117+
case "remove":
118+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully removed access key `%s`.", m.AccessKey)))
119+
case "edit":
120+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully edited access key `%s`.", m.AccessKey)))
121+
case "enable":
122+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully enabled access key `%s`.", m.AccessKey)))
123+
case "disable":
124+
o.WriteString(labelStyle.Render(iFmt(0, "Successfully disabled access key `%s`.", m.AccessKey)))
125+
}
126+
return o.String()
127+
}
128+
129+
func (m accesskeyMessage) JSON() string {
130+
m.Status = "success"
131+
jsonMessageBytes, e := json.MarshalIndent(m, "", " ")
132+
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
133+
134+
return string(jsonMessageBytes)
135+
}
136+
137+
type providerInfo interface {
138+
String() string
139+
}
140+
48141
func mainAdminAccesskeyInfo(ctx *cli.Context) error {
49142
return commonAccesskeyInfo(ctx)
50143
}
144+
145+
func commonAccesskeyInfo(ctx *cli.Context) error {
146+
if len(ctx.Args()) < 2 {
147+
showCommandHelpAndExit(ctx, 1) // last argument is exit code
148+
}
149+
150+
args := ctx.Args()
151+
aliasedURL := args.Get(0)
152+
accessKeys := args.Tail()
153+
154+
// Create a new MinIO Admin Client
155+
client, err := newAdminClient(aliasedURL)
156+
fatalIf(err, "Unable to initialize admin connection.")
157+
158+
for _, accessKey := range accessKeys {
159+
// Assume service account by default
160+
res, e := client.InfoAccessKey(globalContext, accessKey)
161+
fatalIf(probe.NewError(e), "Unable to get info for access key.")
162+
m := accesskeyMessage{
163+
op: "info",
164+
AccessKey: accessKey,
165+
ParentUser: res.ParentUser,
166+
AccountStatus: res.AccountStatus,
167+
ImpliedPolicy: res.ImpliedPolicy,
168+
Policy: json.RawMessage(res.Policy),
169+
Name: res.Name,
170+
Description: res.Description,
171+
Expiration: nilExpiry(res.Expiration),
172+
Provider: res.UserProvider,
173+
}
174+
175+
switch res.UserProvider {
176+
case madmin.LDAPProvider:
177+
info := res.LDAPSpecificInfo
178+
m.ProviderInfo = ldapAccessKeyInfo{
179+
Username: info.Username,
180+
}
181+
case madmin.OpenIDProvider:
182+
info := res.OpenIDSpecificInfo
183+
m.ProviderInfo = openIDAccessKeyInfo{
184+
ConfigName: info.ConfigName,
185+
UserID: info.UserID,
186+
UserIDClaim: info.UserIDClaim,
187+
DisplayName: info.DisplayName,
188+
DisplayNameClaim: info.DisplayNameClaim,
189+
}
190+
}
191+
printMsg(m)
192+
}
193+
194+
return nil
195+
}
196+
197+
func nilExpiry(expiry *time.Time) *time.Time {
198+
if expiry != nil && expiry.Equal(timeSentinel) {
199+
return nil
200+
}
201+
return expiry
202+
}

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

cmd/admin-logs.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ func (l logMessage) String() string {
107107
if l.NodeName != "" {
108108
hostStr = fmt.Sprintf("%s ", colorizedNodeName(l.NodeName))
109109
}
110-
log := l.LogInfo
111-
if log.ConsoleMsg != "" {
112-
if strings.HasPrefix(log.ConsoleMsg, "\n") {
113-
fmt.Fprintf(b, "%s\n", hostStr)
114-
log.ConsoleMsg = strings.TrimPrefix(log.ConsoleMsg, "\n")
115-
}
116-
fmt.Fprintf(b, "%s %s", hostStr, log.ConsoleMsg)
117-
return b.String()
118-
}
119110
if l.API != nil {
120111
apiString := "API: " + l.API.Name + "("
121112
if l.API.Args != nil && l.API.Args.Bucket != "" {
@@ -142,6 +133,9 @@ func (l logMessage) String() string {
142133
if l.UserAgent != "" {
143134
fmt.Fprintf(b, "\n%s UserAgent: %s", hostStr, l.UserAgent)
144135
}
136+
if l.Message != "" {
137+
fmt.Fprintf(b, "\n%s Message: %s", hostStr, l.Message)
138+
}
145139
if l.Trace != nil {
146140
if l.Trace.Message != "" {
147141
fmt.Fprintf(b, "\n%s Error: %s", hostStr, console.Colorize("LogMessage", l.Trace.Message))

cmd/admin-replicate-resync-cancel.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,12 @@ func (m resyncCancelMessage) String() string {
7474
}
7575

7676
func mainAdminReplicateResyncCancel(ctx *cli.Context) error {
77-
{
78-
// Check argument count
79-
argsNr := len(ctx.Args())
80-
if argsNr != 2 {
81-
cli.ShowCommandHelpAndExit(ctx, "cancel", 1) // last argument is exit code
82-
}
77+
// Check argument count
78+
argsNr := len(ctx.Args())
79+
if argsNr != 2 {
80+
showCommandHelpAndExit(ctx, 1) // last argument is exit code
8381
}
82+
8483
console.SetColor("ResyncMessage", color.New(color.FgGreen))
8584

8685
// Get the alias parameter from cli

cmd/admin-replicate-resync-start.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"fmt"
2222
"strings"
2323

24+
"github.com/minio/madmin-go/v3"
25+
2426
"github.com/fatih/color"
2527
"github.com/minio/cli"
2628
json "github.com/minio/colorjson"
27-
"github.com/minio/madmin-go/v3"
2829
"github.com/minio/mc/pkg/probe"
2930
"github.com/minio/pkg/v3/console"
3031
)
@@ -74,12 +75,10 @@ func (m resyncMessage) String() string {
7475
}
7576

7677
func mainAdminReplicateResyncStart(ctx *cli.Context) error {
77-
{
78-
// Check argument count
79-
argsNr := len(ctx.Args())
80-
if argsNr != 2 {
81-
cli.ShowCommandHelpAndExit(ctx, "start", 1) // last argument is exit code
82-
}
78+
// Check argument count
79+
argsNr := len(ctx.Args())
80+
if argsNr != 2 {
81+
showCommandHelpAndExit(ctx, 1) // last argument is exit code
8382
}
8483

8584
console.SetColor("ResyncMessage", color.New(color.FgGreen))

cmd/admin-replicate-resync-status.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ EXAMPLES:
6060
}
6161

6262
func mainAdminReplicationResyncStatus(ctx *cli.Context) error {
63-
{
64-
// Check argument count
65-
argsNr := len(ctx.Args())
66-
if argsNr != 2 {
67-
cli.ShowCommandHelpAndExit(ctx, "status", 1) // last argument is exit code
68-
}
63+
// Check argument count
64+
argsNr := len(ctx.Args())
65+
if argsNr != 2 {
66+
showCommandHelpAndExit(ctx, 1) // last argument is exit code
6967
}
7068

7169
console.SetColor("ResyncMessage", color.New(color.FgGreen))

cmd/admin-trace.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,10 @@ func (opts matchOpts) matches(traceInfo madmin.ServiceTraceInfo) bool {
411411
}
412412
}
413413

414-
if opts.requestSize > 0 && traceInfo.Trace.HTTP.CallStats.InputBytes < int(opts.requestSize) {
415-
return false
416-
}
417-
418-
if opts.responseSize > 0 && traceInfo.Trace.HTTP.CallStats.OutputBytes < int(opts.responseSize) {
419-
return false
414+
if traceInfo.Trace.HTTP != nil {
415+
if (opts.requestSize > 0 && traceInfo.Trace.HTTP.CallStats.InputBytes < int(opts.requestSize)) || (opts.responseSize > 0 && traceInfo.Trace.HTTP.CallStats.OutputBytes < int(opts.responseSize)) {
416+
return false
417+
}
420418
}
421419

422420
return true

cmd/alias-set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func checkAliasSetSyntax(ctx *cli.Context, accessKey, secretKey string, deprecat
148148
}
149149
} else {
150150
if !isValidPath(path) {
151-
fatalIf(errInvalidArgument().Trace(bucketLookup),
151+
fatalIf(errInvalidArgument().Trace(path),
152152
"Unrecognized path value. Valid options are `[auto, on, off]`.")
153153
}
154154
}

0 commit comments

Comments
 (0)