fix leading space

This commit is contained in:
Adem Baccara
2025-09-10 23:02:44 +01:00
parent 5ac3ebeabe
commit 2589076020
2 changed files with 5 additions and 6 deletions
@@ -108,14 +108,13 @@ func (r *Repository) createTempFile(dir string) (string, error) {
tempFileName := fmt.Sprintf("config%s%s", timestamp, TempSuffix) tempFileName := fmt.Sprintf("config%s%s", timestamp, TempSuffix)
tempFilePath := filepath.Join(dir, tempFileName) tempFilePath := filepath.Join(dir, tempFileName)
// Create the temp file // Create the temp file with explicit 0600 permissions
file, err := r.fileSystem.Create(tempFilePath) f, err := r.fileSystem.OpenFile(tempFilePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, SSHConfigPerms)
if err != nil { if err != nil {
return "", err return "", err
} }
if cerr := f.Close(); cerr != nil {
if err := file.Close(); err != nil { r.logger.Warnf("failed to close temporary file %s: %v", tempFilePath, cerr)
r.logger.Warnf("failed to close temporary file %s: %v", tempFilePath, err)
} }
return tempFilePath, nil return tempFilePath, nil
@@ -97,7 +97,7 @@ func (r *Repository) createHostFromServer(server domain.Server) *ssh_config.Host
{Str: server.Alias}, {Str: server.Alias},
}, },
Nodes: make([]ssh_config.Node, 0), Nodes: make([]ssh_config.Node, 0),
LeadingSpace: 1, LeadingSpace: 4,
EOLComment: "Added by lazyssh", EOLComment: "Added by lazyssh",
SpaceBeforeComment: strings.Repeat(" ", 4), SpaceBeforeComment: strings.Repeat(" ", 4),
} }