ref: 44f2bd70a5a90701151ad61b437dfd49aed13099
parent: a4925d9443172211f3ecc348a51d5e46d9be756f
author: Yaroslav K <yarikos@gmail.com>
date: Fri Mar 13 21:22:11 EDT 2026
Add plan9port support Enables `mk o.thread` and `mk test` under plan9port. The program itself still doesn't run well (yet?) but this is good enough for CI.
--- a/mkfile
+++ b/mkfile
@@ -1,10 +1,6 @@
-</$objtype/mkfile
-<|opt.rc
+<|rc ./opt.rc
-#<$PLAN9/src/mkhdr
-
TARG=rd
-BIN=/$objtype/bin
HFILES=fns.h dat.h
OFILES=\
@@ -44,8 +40,7 @@
rle_test.$O \
utf16_test.$O \
-</sys/src/cmd/mkone
-#<$PLAN9/src/mkone
+<$MKONE
$TARG: mkfile
@@ -53,7 +48,7 @@
all:V: $O.thread
test:V: runtest
runtest:V: $O.test
- $O.test
+ ./$O.test
$O.thread: $THREADOFILES $LIB
$LD $LDFLAGS -o $target $prereq
--- a/opt.rc
+++ b/opt.rc
@@ -1,7 +1,20 @@
#!/bin/rc
-# 9front differs in initThumbprints signature/usage
-if(~ `{grep initThumbprints /sys/include/libsec.h | wc -w} 7)- echo 'TLSFILE=tls9f'
-if not
- echo 'TLSFILE=tls'
+if(! ~ $#PLAN9 0) {+ # plan9port
+ echo '<$PLAN9/src/mkhdr'
+ echo 'MKONE=$PLAN9/src/mkone'
+ echo 'TLSFILE=tlsp9p'
+ echo 'BIN=$PLAN9/bin'
+}
+if not {+ echo '</$objtype/mkfile'
+ echo 'MKONE=/sys/src/cmd/mkone'
+ echo 'BIN=/$objtype/bin'
+
+ # 9front differs in initThumbprints signature/usage
+ if(~ `{grep initThumbprints /sys/include/libsec.h | wc -w} 7)+ echo 'TLSFILE=tls9f'
+ if not
+ echo 'TLSFILE=tls'
+}
--- a/rd-thread.c
+++ b/rd-thread.c
@@ -88,7 +88,7 @@
if(c->user == nil)
sysfatal("set $user"); if(doauth){- creds = auth_getuserpasswd(auth_getkey, "proto=pass service=rdp %s", keyspec);
+ creds = auth_getuserpasswd(auth_getkey, "proto=pass role=client service=rdp %s", keyspec);
if(creds == nil)
fprint(2, "factotum: %r\n");
else {--- /dev/null
+++ b/tlsp9p.c
@@ -1,0 +1,38 @@
+#include <u.h>
+#include <libc.h>
+#include <mp.h>
+#include <libsec.h>
+#include "dat.h"
+#include "fns.h"
+
+int
+istrusted(uchar* cert, int certlen)
+{+ return 1;
+}
+
+/* lifted from /sys/src/cmd/upas/fs/imap4.c:/^starttls */
+int
+starttls(Rdp* r)
+{+ TLSconn c;
+ int fd, sfd;
+
+ fd = r->fd;
+
+ memset(&c, 0, sizeof c);
+ sfd = tlsClient(fd, &c);
+ if(sfd < 0){+ werrstr("tlsClient: %r");+ return -1;
+ }
+ if(!istrusted(c.cert, c.certlen)){+ close(sfd);
+ return -1;
+ }
+ /* BUG: free c.cert? */
+
+ close(r->fd);
+ r->fd = sfd;
+ return sfd;
+}
--
⑨