mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
log file: if the path is not absolute make it relative to config dir
Also refuse to join invalid file name such as "." Fixes #85
This commit is contained in:
@@ -4,6 +4,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/drakkan/sftpgo/config"
|
||||
@@ -140,6 +141,7 @@ func addServeFlags(cmd *cobra.Command) {
|
||||
func getCustomServeFlags() []string {
|
||||
result := []string{}
|
||||
if configDir != defaultConfigDir {
|
||||
configDir = filepath.Clean(configDir)
|
||||
result = append(result, "--"+configDirFlag)
|
||||
result = append(result, configDir)
|
||||
}
|
||||
@@ -147,7 +149,10 @@ func getCustomServeFlags() []string {
|
||||
result = append(result, "--"+configFileFlag)
|
||||
result = append(result, configFile)
|
||||
}
|
||||
if logFilePath != defaultLogFile {
|
||||
if logFilePath != defaultLogFile && len(logFilePath) > 0 && logFilePath != "." {
|
||||
if !filepath.IsAbs(logFilePath) {
|
||||
logFilePath = filepath.Join(configDir, logFilePath)
|
||||
}
|
||||
result = append(result, "--"+logFilePathFlag)
|
||||
result = append(result, logFilePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user