mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
update: Add permission check before starting to update (#13291)
This commit is contained in:
parent
a984c55cf9
commit
db65ec4674
@ -149,9 +149,13 @@ func (a adminAPIHandlers) ServerUpdateHandler(w http.ResponseWriter, r *http.Req
|
|||||||
|
|
||||||
for _, nerr := range globalNotificationSys.ServerUpdate(ctx, u, sha256Sum, lrTime, releaseInfo) {
|
for _, nerr := range globalNotificationSys.ServerUpdate(ctx, u, sha256Sum, lrTime, releaseInfo) {
|
||||||
if nerr.Err != nil {
|
if nerr.Err != nil {
|
||||||
|
err := AdminError{
|
||||||
|
Code: AdminUpdateApplyFailure,
|
||||||
|
Message: nerr.Err.Error(),
|
||||||
|
StatusCode: http.StatusInternalServerError,
|
||||||
|
}
|
||||||
logger.GetReqInfo(ctx).SetTags("peerAddress", nerr.Host.String())
|
logger.GetReqInfo(ctx).SetTags("peerAddress", nerr.Host.String())
|
||||||
logger.LogIf(ctx, nerr.Err)
|
logger.LogIf(ctx, fmt.Errorf("server update failed with %w", err))
|
||||||
err = fmt.Errorf("Server update failed, please do not restart the servers yet: failed with %w", nerr.Err)
|
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -159,7 +163,7 @@ func (a adminAPIHandlers) ServerUpdateHandler(w http.ResponseWriter, r *http.Req
|
|||||||
|
|
||||||
updateStatus, err := updateServer(u, sha256Sum, lrTime, releaseInfo, mode)
|
updateStatus, err := updateServer(u, sha256Sum, lrTime, releaseInfo, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Server update failed, please do not restart the servers yet: failed with %w", err)
|
logger.LogIf(ctx, fmt.Errorf("server update failed with %w", err))
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -537,6 +537,14 @@ func doUpdate(u *url.URL, lrTime time.Time, sha256Sum []byte, releaseInfo string
|
|||||||
Checksum: sha256Sum,
|
Checksum: sha256Sum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := opts.CheckPermissions(); err != nil {
|
||||||
|
return AdminError{
|
||||||
|
Code: AdminUpdateApplyFailure,
|
||||||
|
Message: fmt.Sprintf("server update failed with: %s, do not restart the servers yet", err),
|
||||||
|
StatusCode: http.StatusInternalServerError,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minisignPubkey := env.Get(envMinisignPubKey, "")
|
minisignPubkey := env.Get(envMinisignPubKey, "")
|
||||||
if minisignPubkey != "" {
|
if minisignPubkey != "" {
|
||||||
v := selfupdate.NewVerifier()
|
v := selfupdate.NewVerifier()
|
||||||
|
Loading…
Reference in New Issue
Block a user