mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-06 17:08:53 +00:00
Register temp file cleanup before close in ssh config writer
This commit is contained in:
@@ -234,14 +234,14 @@ func (m *Manager) writeSSHConfig(sshConfig string) error {
|
||||
return fmt.Errorf("create temp SSH config: %w", err)
|
||||
}
|
||||
tmpPath := tmp.Name()
|
||||
if err := tmp.Close(); err != nil {
|
||||
return fmt.Errorf("close temp SSH config %s: %w", tmpPath, err)
|
||||
}
|
||||
defer func() {
|
||||
if err := os.Remove(tmpPath); err != nil && !os.IsNotExist(err) {
|
||||
log.Debugf("remove temp SSH config %s: %v", tmpPath, err)
|
||||
}
|
||||
}()
|
||||
if err := tmp.Close(); err != nil {
|
||||
return fmt.Errorf("close temp SSH config %s: %w", tmpPath, err)
|
||||
}
|
||||
|
||||
if err := writeFileWithTimeout(tmpPath, []byte(sshConfig), 0644); err != nil {
|
||||
return fmt.Errorf("write SSH config file %s: %w", tmpPath, err)
|
||||
|
||||
Reference in New Issue
Block a user