From 0417c8a15820abf02974bc2927f9377f3f87ed85 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Wed, 31 Jan 2024 12:17:33 -0800 Subject: [PATCH] fix: set shellpref default settings for backend The shell preference is a new feature that was never integrated into ssh config importing. This makes the backend changes to allow that to happen. --- wavesrv/pkg/cmdrunner/cmdrunner.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index 6f681177f..46f8a921f 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -1542,6 +1542,7 @@ type HostInfoType struct { SshKeyFile string ConnectMode string Ignore bool + ShellPref string } func createSshImportSummary(changeList map[string][]string) string { @@ -1637,6 +1638,13 @@ func NewHostInfo(hostName string) (*HostInfoType, error) { connectMode = sstore.ConnectModeManual } + shellPref := sstore.ShellTypePref_Detect + if cfgWaveOptions["shellpref"] == "bash" { + shellPref = "bash" + } else if cfgWaveOptions["shellpref"] == "zsh" { + shellPref = "zsh" + } + outHostInfo := new(HostInfoType) outHostInfo.Host = hostName outHostInfo.User = userName @@ -1645,6 +1653,7 @@ func NewHostInfo(hostName string) (*HostInfoType, error) { outHostInfo.SshKeyFile = sshKeyFile outHostInfo.ConnectMode = connectMode outHostInfo.Ignore = shouldIgnore + outHostInfo.ShellPref = shellPref return outHostInfo, nil } @@ -1709,6 +1718,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT if hostInfo.SshKeyFile != "" { editMap[sstore.RemoteField_SSHKey] = hostInfo.SshKeyFile } + editMap[sstore.RemoteField_ShellPref] = hostInfo.ShellPref msh := remote.GetRemoteById(previouslyImportedRemote.RemoteId) if msh == nil { remoteChangeList["updateErr"] = append(remoteChangeList["updateErr"], hostInfo.CanonicalName) @@ -1716,7 +1726,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT continue } - if msh.Remote.ConnectMode == hostInfo.ConnectMode && msh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && msh.Remote.RemoteAlias == hostInfo.Host { + if msh.Remote.ConnectMode == hostInfo.ConnectMode && msh.Remote.SSHOpts.SSHIdentity == hostInfo.SshKeyFile && msh.Remote.RemoteAlias == hostInfo.Host && msh.Remote.ShellPref == hostInfo.ShellPref { // silently skip this one. it didn't fail, but no changes were needed continue } @@ -1753,6 +1763,7 @@ func RemoteConfigParseCommand(ctx context.Context, pk *scpacket.FeCommandPacketT AutoInstall: true, SSHOpts: sshOpts, SSHConfigSrc: sstore.SSHConfigSrcTypeImport, + ShellPref: sstore.ShellTypePref_Detect, } err := remote.AddRemote(ctx, r, false) if err != nil {