Skip to content

Commit

Permalink
Merge pull request #32 from cybozu-go/hide-password
Browse files Browse the repository at this point in the history
setup-hw: hide raw password shown in console
  • Loading branch information
kfyharukz authored Aug 27, 2019
2 parents ed6b88f + 0f56c50 commit 2d40467
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.6.8] - 2019-08-27

### Added
- monitor-hw: skip iDRAC reset if `no-reset` file exists (#31)

### Changed
- setup-hw: hide raw passwords (#32)

## [1.6.7] - 2019-08-19

### Changed
Expand Down Expand Up @@ -64,7 +72,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Support Redfish version 1.2.0 and 1.4.0 (#12)

[Unreleased]: https://github.com/cybozu-go/setup-hw/compare/v1.6.7...HEAD
[Unreleased]: https://github.com/cybozu-go/setup-hw/compare/v1.6.8...HEAD
[1.6.8]: https://github.com/cybozu-go/setup-hw/compare/v1.6.7...v1.6.8
[1.6.7]: https://github.com/cybozu-go/setup-hw/compare/v1.6.6...v1.6.7
[1.6.6]: https://github.com/cybozu-go/setup-hw/compare/v1.6.5...v1.6.6
[1.6.5]: https://github.com/cybozu-go/setup-hw/compare/v1.6.4...v1.6.5
Expand Down
30 changes: 29 additions & 1 deletion pkg/setup-hw/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"os"
"os/exec"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -52,6 +53,33 @@ RETRY:
goto RETRY
}

func racadmRetrySilent(ctx context.Context, args ...string) error {
retries := 0
RETRY:
cmd := exec.CommandContext(ctx, racadmPath, args...)
out, err := cmd.CombinedOutput()
if err == nil {
time.Sleep(1 * time.Second)
return nil
}

retries++
if retries == retryCount {
log.Error("idracadm7 failed", map[string]interface{}{
log.FnError: err,
"output": string(out),
})
return err
}

select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(10 * time.Second):
}
goto RETRY
}

// racadmGetConfig returns a string corresponding to the given key.
// In many cases 'idracadm7 get KEY' returns INI format output,
// but in some cases it returns the value not conforming to INI format.
Expand Down Expand Up @@ -358,7 +386,7 @@ func (dc *dellConfigurator) configUser(ctx context.Context, idx, name, priv, ipm
return err
}
if cred.Password.Raw != "" {
if err := racadmRetry(ctx, "set", prefix+"Password", cred.Password.Raw); err != nil {
if err := racadmRetrySilent(ctx, "set", prefix+"Password", cred.Password.Raw); err != nil {
return err
}
} else {
Expand Down

0 comments on commit 2d40467

Please sign in to comment.