use batchmode for non-manual connections. don't allow duplicate aliases for remotes

This commit is contained in:
sawka
2022-09-30 16:05:48 -07:00
parent 534ef04cca
commit 62c3390d31
3 changed files with 9 additions and 1 deletions
+4 -1
View File
@@ -770,6 +770,9 @@ func (msh *MShellProc) Launch() {
msh.WriteToPtyBuffer("connecting to %s...\n", remoteCopy.RemoteCanonicalName)
sshOpts := convertSSHOpts(remoteCopy.SSHOpts)
sshOpts.SSHErrorsToTty = true
if remoteCopy.ConnectMode != sstore.ConnectModeManual {
sshOpts.BatchMode = true
}
cmdStr := MakeServerCommandStr()
ecmd := sshOpts.MakeSSHExecCmd(cmdStr)
cmdPty, err := msh.addControllingTty(ecmd)
@@ -820,7 +823,7 @@ func (msh *MShellProc) Launch() {
}
if err != nil {
msh.setErrorStatus(err)
msh.WriteToPtyBuffer("*error connecting to remote (uname=%q): %v\n", msh.UName, err)
msh.WriteToPtyBuffer("*error connecting to remote: %v\n", err)
return
}
msh.WriteToPtyBuffer("connected\n")
+4
View File
@@ -123,6 +123,10 @@ func UpsertRemote(ctx context.Context, r *RemoteType) error {
if tx.Exists(query, r.RemoteCanonicalName) {
return fmt.Errorf("remote has duplicate canonicalname '%s', cannot create", r.RemoteCanonicalName)
}
query = `SELECT remoteid FROM remote WHERE alias = ?`
if r.RemoteAlias != "" && tx.Exists(query, r.RemoteAlias) {
return fmt.Errorf("remote has duplicate alias '%s', cannot create", r.RemoteAlias)
}
query = `SELECT COALESCE(max(remoteidx), 0) FROM remote`
maxRemoteIdx := tx.GetInt(query)
r.RemoteIdx = int64(maxRemoteIdx + 1)
+1
View File
@@ -83,6 +83,7 @@ type RemoteEditType struct {
RemoteEdit bool `json:"remoteedit"`
RemoteId string `json:"remoteid,omitempty"`
ErrorStr string `json:"errorstr,omitempty"`
InfoStr string `json:"infostr,omitempty"`
}
type InfoMsgType struct {