Skip to content
Snippets Groups Projects
Commit 08f1ae74 authored by Pea Nut's avatar Pea Nut Committed by jkito
Browse files

Improve logging and error handling in generateManagementPassword

parent c994d4bb
No related branches found
No related tags found
1 merge request!198v5 implementation with a single Bitmask struct
......@@ -179,16 +179,24 @@ func maybeGetPrivateGateway() (bonafide.Gateway, bool) {
return gw, true
}
// generates a password and returns the path for a temporary file where this password is written
// Generates a password and returns the path for a temporary file where the password is written
func (b *Bitmask) generateManagementPassword() string {
pass := getRandomPass(12)
tmpFile, err := ioutil.TempFile(b.tempdir, "leap-vpn-")
if err != nil {
log.Fatal().
Err(err).
Msg("Could not create temporary file")
Msg("Could not create temporary file to save management password")
}
_, err = tmpFile.Write([]byte(pass))
if err != nil {
log.Fatal().
Str("tmpFile", tmpFile.Name()).
Err(err).
Msg("Could not write management password to file")
}
tmpFile.Write([]byte(pass))
b.launch.MngPass = pass
return tmpFile.Name()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment