9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] rx: add ssh
@ 2024-07-04 16:46 mkf9
  2024-07-09 22:36 ` cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: mkf9 @ 2024-07-04 16:46 UTC (permalink / raw)
  To: 9front

Hello.
This patch adds ssh support to rx, and taken from 9legacy code with 
minor changes.
Allows us to use sam -r to unix systems if they have sam installed. 
(tested with OpenBSD and p9p's sam)

heads/rx_ssh: 10b583949b50d8d39e99fc3658b81c831bbc04f5
term% git/export
From: mkf <mkf@cloud9p.org>
Date: Thu, 04 Jul 2024 20:26:20 +0000
Subject: [PATCH] rx: add ssh

---
diff f628dc850db46a7b81b04dba3eb63ba2258c6fda 
10b583949b50d8d39e99fc3658b81c831bbc04f5
--- a/sys/src/cmd/rx.c
+++ b/sys/src/cmd/rx.c
@@ -13,6 +13,7 @@
  void	rex(int, char*);
  void	rcpu(int, char*);
  void	tcpexec(int, char*, char*);
+void	sshexec(char*, char*);
  int	call(char *, char*, char*, char**);
  char	*buildargs(char*[]);
  int	send(int);
@@ -70,6 +71,14 @@
  		rex(fd, args);
  	close(fd);

+	/* if there's an ssh port, try that */
+	fd = call("tcp", host, "ssh", &addr);
+	if(fd >= 0){
+		close(fd);
+		sshexec(host, args);
+		/* falls through if no ssh */
+	}
+
  	/* specific attempts */
  	fd = call("tcp", host, "shell", &addr);
  	if(fd >= 0)
@@ -203,8 +212,28 @@
  			error("write error", 0);
  	}
  	sleep(250);
-	postnote(PNPROC, kid, note);/**/
+	postnote(PNPROC, kid, note);
  	exits(0);
+}
+
+void
+sshexec(char *host, char *cmd)
+{
+	char *argv[10];
+	int n;
+
+	n = 0;
+	argv[n++] = "ssh";
+	if(!returns)
+		argv[n++] = "-r";
+	if(ruser){
+		argv[n++] = "-u";
+		argv[n++] = ruser;
+	}
+	argv[n++] = host;
+	argv[n++] = cmd;
+	argv[n] = 0;
+	exec("/bin/ssh", argv);
  }

  int

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-09 22:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-04 16:46 [9front] [PATCH] rx: add ssh mkf9
2024-07-09 22:36 ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).