Skip to content

Commit 2d40467

Browse files
authored
Merge pull request #32 from cybozu-go/hide-password
setup-hw: hide raw password shown in console
2 parents ed6b88f + 0f56c50 commit 2d40467

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [1.6.8] - 2019-08-27
9+
10+
### Added
11+
- monitor-hw: skip iDRAC reset if `no-reset` file exists (#31)
12+
13+
### Changed
14+
- setup-hw: hide raw passwords (#32)
15+
816
## [1.6.7] - 2019-08-19
917

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

67-
[Unreleased]: https://github.com/cybozu-go/setup-hw/compare/v1.6.7...HEAD
75+
[Unreleased]: https://github.com/cybozu-go/setup-hw/compare/v1.6.8...HEAD
76+
[1.6.8]: https://github.com/cybozu-go/setup-hw/compare/v1.6.7...v1.6.8
6877
[1.6.7]: https://github.com/cybozu-go/setup-hw/compare/v1.6.6...v1.6.7
6978
[1.6.6]: https://github.com/cybozu-go/setup-hw/compare/v1.6.5...v1.6.6
7079
[1.6.5]: https://github.com/cybozu-go/setup-hw/compare/v1.6.4...v1.6.5

pkg/setup-hw/dell.go

+29-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"os"
7+
"os/exec"
78
"strconv"
89
"strings"
910
"time"
@@ -52,6 +53,33 @@ RETRY:
5253
goto RETRY
5354
}
5455

56+
func racadmRetrySilent(ctx context.Context, args ...string) error {
57+
retries := 0
58+
RETRY:
59+
cmd := exec.CommandContext(ctx, racadmPath, args...)
60+
out, err := cmd.CombinedOutput()
61+
if err == nil {
62+
time.Sleep(1 * time.Second)
63+
return nil
64+
}
65+
66+
retries++
67+
if retries == retryCount {
68+
log.Error("idracadm7 failed", map[string]interface{}{
69+
log.FnError: err,
70+
"output": string(out),
71+
})
72+
return err
73+
}
74+
75+
select {
76+
case <-ctx.Done():
77+
return ctx.Err()
78+
case <-time.After(10 * time.Second):
79+
}
80+
goto RETRY
81+
}
82+
5583
// racadmGetConfig returns a string corresponding to the given key.
5684
// In many cases 'idracadm7 get KEY' returns INI format output,
5785
// but in some cases it returns the value not conforming to INI format.
@@ -358,7 +386,7 @@ func (dc *dellConfigurator) configUser(ctx context.Context, idx, name, priv, ipm
358386
return err
359387
}
360388
if cred.Password.Raw != "" {
361-
if err := racadmRetry(ctx, "set", prefix+"Password", cred.Password.Raw); err != nil {
389+
if err := racadmRetrySilent(ctx, "set", prefix+"Password", cred.Password.Raw); err != nil {
362390
return err
363391
}
364392
} else {

0 commit comments

Comments
 (0)