From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=DATE_IN_PAST_03_06, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI autolearn=no autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id 1729323395 for ; Thu, 4 Jul 2024 22:31:44 +0200 (CEST) Received: from mx1.riseup.net ([198.252.153.129]) by 9front; Thu Jul 4 16:30:35 -0400 2024 Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx1.riseup.net (Postfix) with ESMTPS id 4WFSvS2xlfzDqwt for <9front@9front.org>; Thu, 4 Jul 2024 20:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1720125028; bh=saCFAvG3BYhiFrxNghPW92nnGFTe+Bu9RLIYlQgrqRE=; h=To:From:Subject:Date:From; b=p4FOEZP48zeZNcNcfq/hcZ9/Bb2iInv+/I58MB9/7mDZhl+jKz0yoR4kCm/l4sWcV 5wQu+TuMi1TSjZiW7zny6raRcrlXYgCtQmzlchcdNmf7D6Q/p1wgna3NGPsbo+p/7y TjExBe3yUp+WtlXtpIyTcUILfNc8J+WGeJlp3HCs= X-Riseup-User-ID: CA11A115DA600B6D75862FCE3C9898154DC812B421CC647FF02B2315F13F3C6F Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4WFSvR4tVBzJrw2 for <9front@9front.org>; Thu, 4 Jul 2024 20:30:27 +0000 (UTC) To: 9front@9front.org From: mkf9 Message-ID: <69e17437-a256-5c8a-8acd-90227e2a908a@riseup.net> Date: Thu, 4 Jul 2024 20:16:42 +0330 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: shared encrypted realtime ActivityPub scripting configuration persistence controller Subject: [9front] [PATCH] rx: add ssh Reply-To: 9front@9front.org Precedence: bulk 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 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