Escape hashes in password for config file
The hash is the comment character in the config file, even if it occurs in the middle of the password. This can be worked around however by escaping it. This fixes #16.
This commit is contained in:
parent
ab356b2890
commit
11f380924f
|
@ -185,7 +185,7 @@ func freeipmiConfig(config IPMIConfig) string {
|
||||||
fmt.Fprintf(&b, "username %s\n", config.User)
|
fmt.Fprintf(&b, "username %s\n", config.User)
|
||||||
}
|
}
|
||||||
if config.Password != "" {
|
if config.Password != "" {
|
||||||
fmt.Fprintf(&b, "password %s\n", config.Password)
|
fmt.Fprintf(&b, "password %s\n", escapePassword(config.Password))
|
||||||
}
|
}
|
||||||
if config.Timeout != 0 {
|
if config.Timeout != 0 {
|
||||||
fmt.Fprintf(&b, "session-timeout %d\n", config.Timeout)
|
fmt.Fprintf(&b, "session-timeout %d\n", config.Timeout)
|
||||||
|
@ -515,6 +515,10 @@ func contains(s []int64, elm int64) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func escapePassword(password string) string {
|
||||||
|
return strings.Replace(password, "#", "\\#", -1)
|
||||||
|
}
|
||||||
|
|
||||||
func targetName(target string) string {
|
func targetName(target string) string {
|
||||||
if targetIsLocal(target) {
|
if targetIsLocal(target) {
|
||||||
return "[local]"
|
return "[local]"
|
||||||
|
|
Loading…
Reference in New Issue