This commit is contained in:
parent
4fa5efa5b6
commit
417088c32b
@ -1,3 +1,3 @@
|
||||
kind: Fixed
|
||||
body: Local command's `dir` config key resolved to full path
|
||||
body: Local command's `dir` full path is now found with home directory
|
||||
time: 2025-02-20T14:48:43.475300515-06:00
|
||||
|
@ -569,7 +569,7 @@ func processCmds(opts *ConfigOpts) error {
|
||||
|
||||
if cmd.Dir != nil {
|
||||
|
||||
cmdDir, err := resolveDir(*cmd.Dir)
|
||||
cmdDir, err := getFullPathWithHomeDir(*cmd.Dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -643,7 +643,7 @@ func processCmds(opts *ConfigOpts) error {
|
||||
}
|
||||
if cmd.OutputFile != "" {
|
||||
var err error
|
||||
cmd.OutputFile, err = resolveDir(cmd.OutputFile)
|
||||
cmd.OutputFile, err = getFullPathWithHomeDir(cmd.OutputFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func (remoteConfig *Host) ConnectToHost(opts *ConfigOpts) error {
|
||||
|
||||
if !remoteConfig.useDefaultConfig {
|
||||
var err error
|
||||
remoteConfig.ConfigFilePath, err = resolveDir(remoteConfig.ConfigFilePath)
|
||||
remoteConfig.ConfigFilePath, err = getFullPathWithHomeDir(remoteConfig.ConfigFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -63,7 +63,7 @@ func (remoteConfig *Host) ConnectToHost(opts *ConfigOpts) error {
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
} else {
|
||||
defaultConfig, _ := resolveDir("~/.ssh/config")
|
||||
defaultConfig, _ := getFullPathWithHomeDir("~/.ssh/config")
|
||||
configFile, sshConfigFileOpenErr = os.Open(defaultConfig)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
@ -242,7 +242,7 @@ func (remoteHost *Host) GetPrivateKeyFileFromConfig() {
|
||||
identityFile = remoteHost.PrivateKeyPath
|
||||
}
|
||||
|
||||
remoteHost.PrivateKeyPath, _ = resolveDir(identityFile)
|
||||
remoteHost.PrivateKeyPath, _ = getFullPathWithHomeDir(identityFile)
|
||||
}
|
||||
|
||||
// GetPort checks if the port from the config file is 0
|
||||
@ -324,10 +324,10 @@ func (remoteHost *Host) ConnectThroughBastion(log zerolog.Logger) (*ssh.Client,
|
||||
func (remotehHost *Host) GetKnownHosts() error {
|
||||
var knownHostsFileErr error
|
||||
if TS(remotehHost.KnownHostsFile) != "" {
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = resolveDir(remotehHost.KnownHostsFile)
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = getFullPathWithHomeDir(remotehHost.KnownHostsFile)
|
||||
return knownHostsFileErr
|
||||
}
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = resolveDir("~/.ssh/known_hosts")
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = getFullPathWithHomeDir("~/.ssh/known_hosts")
|
||||
return knownHostsFileErr
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ func GetPrivateKeyPassword(key string, opts *ConfigOpts, log zerolog.Logger) (st
|
||||
var prKeyPassword string
|
||||
if strings.HasPrefix(key, "file:") {
|
||||
privKeyPassFilePath := strings.TrimPrefix(key, "file:")
|
||||
privKeyPassFilePath, _ = resolveDir(privKeyPassFilePath)
|
||||
privKeyPassFilePath, _ = getFullPathWithHomeDir(privKeyPassFilePath)
|
||||
keyFile, keyFileErr := os.Open(privKeyPassFilePath)
|
||||
if keyFileErr != nil {
|
||||
return "", errors.Errorf("Private key password file %s failed to open. \n Make sure it is accessible and correct.", privKeyPassFilePath)
|
||||
@ -368,7 +368,7 @@ func GetPassword(pass string, opts *ConfigOpts, log zerolog.Logger) (string, err
|
||||
var password string
|
||||
if strings.HasPrefix(pass, "file:") {
|
||||
passFilePath := strings.TrimPrefix(pass, "file:")
|
||||
passFilePath, _ = resolveDir(passFilePath)
|
||||
passFilePath, _ = getFullPathWithHomeDir(passFilePath)
|
||||
keyFile, keyFileErr := os.Open(passFilePath)
|
||||
if keyFileErr != nil {
|
||||
return "", errors.New("Password file failed to open")
|
||||
@ -440,7 +440,7 @@ func (remoteConfig *Host) GetProxyJumpConfig(hosts map[string]*Host, opts *Confi
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
} else {
|
||||
defaultConfig, _ := resolveDir("~/.ssh/config")
|
||||
defaultConfig, _ := getFullPathWithHomeDir("~/.ssh/config")
|
||||
configFile, sshConfigFileOpenErr = os.Open(defaultConfig)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
@ -706,7 +706,7 @@ func (command *Command) runRemoteScript(session *ssh.Session, cmdCtxLogger zerol
|
||||
|
||||
// readFileToBuffer reads a file into a buffer.
|
||||
func readFileToBuffer(filePath string) (*bytes.Buffer, error) {
|
||||
resolvedPath, err := resolveDir(filePath)
|
||||
resolvedPath, err := getFullPathWithHomeDir(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func NewOpts(configFilePath string, opts ...BackyOptionFunc) *ConfigOpts {
|
||||
|
||||
func injectEnvIntoSSH(envVarsToInject environmentVars, process *ssh.Session, opts *ConfigOpts, log zerolog.Logger) {
|
||||
if envVarsToInject.file != "" {
|
||||
envPath, envPathErr := resolveDir(envVarsToInject.file)
|
||||
envPath, envPathErr := getFullPathWithHomeDir(envVarsToInject.file)
|
||||
if envPathErr != nil {
|
||||
log.Fatal().Str("envFile", envPath).Err(envPathErr).Send()
|
||||
}
|
||||
@ -125,7 +125,7 @@ errEnvFile:
|
||||
|
||||
func injectEnvIntoLocalCMD(envVarsToInject environmentVars, process *exec.Cmd, log zerolog.Logger) {
|
||||
if envVarsToInject.file != "" {
|
||||
envPath, _ := resolveDir(envVarsToInject.file)
|
||||
envPath, _ := getFullPathWithHomeDir(envVarsToInject.file)
|
||||
|
||||
file, fileErr := os.Open(envPath)
|
||||
if fileErr != nil {
|
||||
@ -192,7 +192,7 @@ func IsCmdStdOutEnabled() bool {
|
||||
return os.Getenv("BACKY_CMDSTDOUT") == "enabled"
|
||||
}
|
||||
|
||||
func resolveDir(path string) (string, error) {
|
||||
func getFullPathWithHomeDir(path string) (string, error) {
|
||||
path = strings.TrimSpace(path)
|
||||
|
||||
if path == "~" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user