diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go index 5f9b0be80f2e82b670c7b8a5f5655fe37f5bd9a2..c8c60241d41d230d89a60147a09af9cb917615d1 100644 --- a/pkg/vpn/openvpn.go +++ b/pkg/vpn/openvpn.go @@ -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() }