ref: dda857a4d67fa12ee4cb222e672f5e989d7f26de
parent: 32fe6dfac597a31f823cb0fc069fc29794b87b95
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Aug 4 07:22:53 EDT 2025
sshnet: pass cs query operations to original /net/cs The cs file served by sshnet was only handling dial string resolution, and was refusing ndb queries with "can't translate". This change forwards queries to the original /net/cs. This is needed for rcpu/factotum which needs to resolve authdom using csquery.
--- a/sys/man/4/sshnet
+++ b/sys/man/4/sshnet
@@ -32,6 +32,19 @@
All other arguments are passed to
.IR ssh (1)
as is.
+.PP
+For
+.IR dial (2)
+operations, name resolution happens on the remote side as
+.I sshnet
+serves a
+.IR mtpt /cs
+file that passes the hostname to the
+.B connect
+dial string.
+Other query operations are passed verbatim to the
+original connection service at
+.IR mtpt /cs.
.SH SOURCE
.B /sys/src/cmd/sshnet.c
.SH "SEE ALSO"
--- a/sys/src/cmd/sshnet.c
+++ b/sys/src/cmd/sshnet.c
@@ -696,6 +696,7 @@
{
char *resp;
int isnew;
+ int fd; /* real /net/cs file-descriptor */
};
static int
@@ -725,7 +726,7 @@
free(port);
return n;
-}
+}
static void
csread(Req *r)
@@ -733,6 +734,17 @@
Cs *cs;
cs = r->fid->aux;
+ if(cs->fd >= 0){
+ int n;
+
+ if((n = read(cs->fd, r->ofcall.data, r->ifcall.count)) < 0)
+ responderror(r);
+ else {
+ r->ofcall.count = n;
+ respond(r, nil);
+ }
+ return;
+ }
if(cs->resp==nil){
respond(r, "cs read without write");
return;
@@ -757,6 +769,24 @@
Cs *cs;
cs = r->fid->aux;
+
+ if(r->ifcall.count > 0 && ((char*)r->ifcall.data)[0] == '!'){
+ int n;
+
+ s = smprint("%s/cs", mtpt);
+ if(cs->fd >= 0)
+ close(cs->fd);
+ cs->fd = open(s, ORDWR);
+ if(cs->fd < 0 || (n = write(cs->fd, r->ifcall.data, r->ifcall.count)) < 0)
+ responderror(r);
+ else {
+ r->ofcall.count = n;
+ respond(r, nil);
+ }
+ free(s);
+ return;
+ }
+
s = emalloc9p(r->ifcall.count+1);
memmove(s, r->ifcall.data, r->ifcall.count);
s[r->ifcall.count] = '\0';
@@ -1049,6 +1079,7 @@
switch(TYPE(path)){
case Qcs:
cs = emalloc9p(sizeof(Cs));
+ cs->fd = -1;
r->fid->aux = cs;
respond(r, nil);
break;
@@ -1257,6 +1288,8 @@
case Qcs:
cs = fid->aux;
if(cs){
+ if(cs->fd >= 0)
+ close(cs->fd);
free(cs->resp);
free(cs);
}
--
⑨