Fix: only use and write auth file if user is set

- Apply to custom openvpn configuration without username
This commit is contained in:
Quentin McGaw (desktop)
2021-06-14 14:25:37 +00:00
parent c63ae3f3af
commit 582c6d1c43
2 changed files with 9 additions and 5 deletions

View File

@@ -80,7 +80,9 @@ func modifyCustomConfig(lines []string, username string,
modified = append(modified, "pull-filter ignore \"auth-token\"") // prevent auth failed loop
modified = append(modified, "auth-retry nointeract")
modified = append(modified, "suppress-timestamps")
modified = append(modified, "auth-user-pass "+constants.OpenVPNAuthConf)
if settings.User != "" {
modified = append(modified, "auth-user-pass "+constants.OpenVPNAuthConf)
}
modified = append(modified, "verb "+strconv.Itoa(settings.Verbosity))
if len(settings.Cipher) > 0 {
modified = append(modified, utils.CipherLines(settings.Cipher, settings.Version)...)

View File

@@ -143,10 +143,12 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) { //nolint:gocog
continue
}
if err := l.conf.WriteAuthFile(settings.User, settings.Password, l.puid, l.pgid); err != nil {
l.signalCrashedStatus()
l.logAndWait(ctx, err)
continue
if settings.User != "" {
if err := l.conf.WriteAuthFile(settings.User, settings.Password, l.puid, l.pgid); err != nil {
l.signalCrashedStatus()
l.logAndWait(ctx, err)
continue
}
}
if err := l.fw.SetVPNConnection(ctx, connection); err != nil {