OK, turing.

<- leave blank

Thu Jan 21 15:32:39 EST 2021

; cd /net/udp
; echo connect 172.24.172.227!8888 > clone
; cat clone
0
; cd /net/udp/0
; echo connect 172.24.172.227!8888 > ctl
; cat remote
172.24.172.227!8888
; cat local
172.24.172.227!58449
; echo hello world > data
echo: write error: Destination address required


Thu Jan 21 03:57:30 EST 2021
$ gdb ./emu-g
(gdb) run
0xf7f8937d in tss_get () from /lib/ld-musl-i386.so.1
(gdb) bt
#0 0xf7f8937d in tss_get () from /lib/ld-musl-i386.so.1
#1 0x5662e280 in getup () at ../port/kproc-pthreads.c:39
#2 0x5662da5e in cleanexit (x=0) at os.c:136
#3 0x566548ab in panic (fmt=0x5669b49a "can't save startup args") at
../port/main.c:409
#4 0x56654975 in savestartup (argv=0xfffac374, argc=1) at ../port/main.c:198
#5 main (argc=1, argv=0xfffac374) at ../port/main.c:245

Wed Jan 20 23:58:55 EST 2021
package main

import (
	"io"
	"io/ioutil"
	"log"
	"os"
	"os/exec"

	"github.com/gliderlabs/ssh"
	gossh "golang.org/x/crypto/ssh"
)

func transfer(dst io.Writer, src io.Reader) {
	buf := make([]byte, 4096)
	for {
		n, err := src.Read(buf)
		switch {
		case n == 0:
			continue
		case err == io.EOF:
			return
		case err != nil:
			log.Println("transfer read:", err)
		}
		out, err := dst.Write(buf[:n])
		switch {
		case out != n:
			log.Println("transfer write: short write")
		case err != nil:
			log.Println("transfer write:", err)
		}
	}
}

func shellHandler(s ssh.Session) {
	cmd := exec.Command("/bin/rc")
	stdin, err := cmd.StdinPipe()
	if err != nil {
		log.Fatal(err)
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		log.Fatal(err)
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		log.Fatal(err)
	}
	err = cmd.Start()
	if err != nil {
		log.Fatal(err)
	}
	//go io.Copy(stdin, s)
	go transfer(stdin, s)
	//go io.Copy(s, stderr)
	go transfer(s, stderr)
	//io.Copy(s, stdout)
	transfer(s, stdout)
}

func main() {
	priv, err := ioutil.ReadFile("./id_rsa")
	if err != nil {
		log.Fatal(err)
	}
	signer, err := gossh.ParsePrivateKey(priv)
	if err != nil {
		log.Fatal(err)
	}
	s := &ssh.Server{
		Addr: ":2222",
		Handler: shellHandler,
	}
	s.AddHostKey(signer)
	err = s.SetOption(ssh.NoPty())
	if err != nil {
		log.Fatal(err)
	}
	if len(os.Args) > 1 {
		pubAuth := ssh.PublicKeyAuth(func(ctx ssh.Context, key
		ssh.PublicKey) bool {
			data, err := ioutil.ReadFile(os.Args[1])
			if err != nil {
				log.Fatal(err)
			}
			allowed, _, _, _, _ := ssh.ParseAuthorizedKey(data)
			return ssh.KeysEqual(key, allowed)
		})
		err = s.SetOption(pubAuth)
		if err != nil {
			log.Fatal(err)
		}
	}

	log.Println("starting ssh server on port 2222...")
	log.Fatal(s.ListenAndServe())
}


Wed Jan 20 20:46:59 EST 2021
--- /mnt/git/object/22f34a315b71fdeb2ac90b79f134e11b3052f07a/tree/./castor.c
+++ ./castor.c
@@ -409,7 +409,6 @@
			}

			Bflush(&body);
- close(fd);

			h->p = hist;
			h->n = nil;
@@ -417,14 +416,14 @@
			hist = h;

			show(c);
- }

+ }
		break;
	case 30:
- gemini_get(urlparse(nil, r->meta));
+ gemini_get(urlparse(url, r->meta));
		break;
	case 31:
- gemini_get(urlparse(nil, r->meta));
+ gemini_get(urlparse(url, r->meta));
		break;
	case 40:
		message("Temporary failure, please try again later!");
@@ -469,6 +468,7 @@
	// message("Unknown status code %d!", status);
	// break;
	}
+ close(fd);
 }

 void
--- /mnt/git/object/22f34a315b71fdeb2ac90b79f134e11b3052f07a/tree/./url.c
+++ ./url.c
@@ -223,13 +223,12 @@
 static Url *
 saneurl(Url *u)
 {
- if(strcmp(u->scheme, "mailto") == 0 && Upath(u) != nil)
- return u;
-
	if(u == nil || u->scheme == nil || u->host == nil || Upath(u) ==
	nil){
		freeurl(u);
		return nil;
	}
+ if(strcmp(u->scheme, "mailto") == 0 && Upath(u) != nil)
+ return u;
	if(u->port){
		/* remove default ports */
		switch(atoi(u->port)){


Wed Jan 20 20:18:24 EST 2021
--- /mnt/git/object/22f34a315b71fdeb2ac90b79f134e11b3052f07a/tree/./url.c
+++ ./url.c
@@ -223,13 +223,12 @@
 static Url *
 saneurl(Url *u)
 {
- if(strcmp(u->scheme, "mailto") == 0 && Upath(u) != nil)
- return u;
-
	if(u == nil || u->scheme == nil || u->host == nil || Upath(u) ==
	nil){
		freeurl(u);
		return nil;
	}
+ if(strcmp(u->scheme, "mailto") == 0 && Upath(u) != nil)
+ return u;
	if(u->port){
		/* remove default ports */
		switch(atoi(u->port)){


Wed Jan 20 20:17:07 EST 2021
cpu% mk castor.acid
6c -FTVw -Ilibpanel -a castor.c >castor.acid
cpu% acid -l castor.acid 19120
/proc/19120/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
strcmp(s2=0x40c047)+0x12 /sys/src/libc/port/strcmp.c:10
saneurl(u=0x414a48)+0x1c /usr/ori/src/castor9/url.c:226
urlparse(s=0x0,b=0x0)+0x354 /usr/ori/src/castor9/url.c:377
	t=0x414b08
	p=0x414a08
	u=0x414a48
	x=0x4149c8
gemini_get(url=0x40e6f8)+0x34c /usr/ori/src/castor9/castor.c:427
	c=0x4146e8
	r=0x414728
	h=0x414768
	fd=0x2033b300000010
	body=0x0
	line=0x414328
main(argv=0x7fffffffef88)+0xc3 /usr/ori/src/castor9/castor.c:816
	url=0x40e6f8
	e=0x0
_main+0x40 /sys/src/libc/amd64/main9.s:15
acid: Url(0x414a48)
	raw 0x0000000000414ac8
	full 0x0000000000000000
	scheme 0x0000000000000000
	user 0x0000000000000000
	pass 0x0000000000000000
	host 0x0000000000000000
	port 0x0000000000000000
	path 0x0000000000414b48
	query 0x0000000000000000
	fragment 0x0000000000000000
	free 0
acid: *(0x0000000000414b48\s)
/


Wed Jan 20 10:49:15 EST 2021
diff -r 01125acb5565 sys/src/cmd/5l/asm.c
--- a/sys/src/cmd/5l/asm.c Tue Jan 19 19:56:38 2021 -0800
+++ b/sys/src/cmd/5l/asm.c Wed Jan 20 07:48:56 2021 -0800
@@ -789,6 +789,12 @@
		r = p->reg;
		if(r == NREG)
			r = p->to.reg;
+ /*
+ * R>>32 is encoded as R>>0, so flip to the
+ * equivalent R<<0.
+ */
+ if(instoffset == 0)
+ o1 &= ~(3<<5);
		o1 |= r;
		o1 |= (instoffset&31) << 7;
		o1 |= p->to.reg << 12;


Wed Jan 20 10:42:45 EST 2021
178c178
< background = allocimage(display, Rect(0,0,1,1), RGB24, 1, 0x777777FF);
---
> background = readimage(display, 0, 0);


Tue Jan 19 22:31:19 EST 2021
diff -r fda0775c4195 sys/src/cmd/hjfs/auth.c
--- a/sys/src/cmd/hjfs/auth.c Tue Jan 19 18:14:53 2021 -0800
+++ b/sys/src/cmd/hjfs/auth.c Tue Jan 19 19:31:18 2021 -0800
@@ -301,10 +301,13 @@
	if((fs->flags & FSNOPERM) != 0)
		return 1;
	perm = d->mode & 0777;
- if(d->uid == uid)
- perm >>= 6;
- else if(ingroup(fs, uid, d->gid, 0))
- perm >>= 3;
+ /* uid none gets only other permissions */
+ if(d->uid != 0) {
+ if(d->uid == uid)
+ perm >>= 6;
+ else if(ingroup(fs, uid, d->gid, 0))
+ perm >>= 3;
+ }
	switch(mode & 3){
	case OREAD:
		return (perm & 4) != 0;


Tue Jan 19 21:58:33 EST 2021
#!/bin/rc
window 0,0,161,117 stats -lm
window 161,0,560,117 faces -i
window -miny 130

# run a system shell on the serial console
~ $#console 0 || window -scroll console


Tue Jan 19 21:57:09 EST 2021
#!/bin/rc
# Warning, parts of this script have been STOLEN!

# TODO:
# fs usage
# kernel

fn storage {
	disks = `{ls -d /dev/sd* | uniq}
	anydisk = 'false'
	for(i in $disks){
		if(test -f $i/data){
			full = `{ls -l $i/data}
			disk = `{echo $full | awk -F '/' '{print $3}'}
			size = `{echo $full | awk '{print $6}'}
			echo $disk^': '^`{echo $size^' / 1024 / 1024 /1024' |
			bc}^GB
			anydisk = 'true'
		}
	}
	if(~ $anydisk -c 'false')
		echo Running in the diskless
}

fn fs {
	if(ls /srv | grep -s '*.cmd')
		ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g'
	if(test -f /srv/fscons)
		echo fossil
	# Logic from storage to scrape for venti arenas
	v='false'
	disks = `{ls -d /dev/sd* | uniq}
	for(i in $disks){
		if(ls $i | grep -s arena)
			v='true'
	}
	if(~ $v -c 'true')
		echo venti
}

fn cpuid {
	if(test -f /bin/aux/cpuid)
		aux/cpuid >[2]/dev/null | grep procname | sed 's/.*procname//'
}

os=`{
	if(grep -s 'zrv' /dev/drivers)
		echo 9ants
	if not if(grep -s 'vmx' /dev/drivers)
		echo 9front
	if not
		echo Bell Labs
}

# fs and storage require #S bound on /dev
bind -b '#S' /dev

arch=`{echo $cputype}
shell=/bin/rc
uptime=`{uptime| sed 's/.*up//; s/..........$//'}
scr=`{dd -count 1 < /dev/screen|[2];}
scr=($scr(4) x $scr(5))
ram=(`{tr / ' '</dev/swap})
free=`{echo $ram(1)'/1024^2'|bc}
used=`{echo '('$ram(3)'*('$ram(7)^+$ram(5)^'))/1024^2'|bc}
cpu=`{cpuid}
files=`{fs}
strg=`{storage}

cat <<EOF
	     $user@$sysname
    (\(\ -----------
   j".  ..  os: Plan 9 from $os/$arch
   ( . .) shell: $shell
   | ° ¡ uptime: $uptime
   ¿ ; ram: $used/$free MiB
   c?".UJ cpu: $cputype $cpu
	     resolution: $scr
	     fs: $files
	     $strg
EOF


prev | next