shithub: 9bbs

Download patch

ref: c0aa29099d9d1e09c812c2438868ec2091c81ec7
author: sl <sl@gaff>
date: Sat Aug 24 23:25:14 EDT 2024

mercurial -> git: initial import (sans commit history)

diff: cannot open b/9bbs/.git//null: file does not exist: 'b/9bbs/.git//null' diff: cannot open b/9bbs//null: file does not exist: 'b/9bbs//null' diff: cannot open b/bin//null: file does not exist: 'b/bin//null' diff: cannot open b/etc/users/sl//null: file does not exist: 'b/etc/users/sl//null' diff: cannot open b/etc/users//null: file does not exist: 'b/etc/users//null' diff: cannot open b/etc//null: file does not exist: 'b/etc//null' diff: cannot open b/img//null: file does not exist: 'b/img//null' diff: cannot open b/rooms/lobby//null: file does not exist: 'b/rooms/lobby//null' diff: cannot open b/rooms//null: file does not exist: 'b/rooms//null' diff: cannot open b/src//null: file does not exist: 'b/src//null'
--- /dev/null
+++ b/9bbs/.git/HEAD
@@ -1,0 +1,1 @@
+ref: refs/heads/front
--- /dev/null
+++ b/9bbs/.git/config
@@ -1,0 +1,4 @@
+[core]
+	repositoryformatversion = p9.0
+[branch "front"]
+	remote = origin
binary files /dev/null b/bin/9bbs differ
--- /dev/null
+++ b/bin/9bbs2nostromo
@@ -1,0 +1,36 @@
+#!/bin/rc
+# convert old message format to new message format.
+rfork e
+fn checkdir{
+	if(! test -d $1){
+		echo $1 does not exist >[1=2]
+		exit checkdir
+	}
+}
+fn seconds2rfc822{ date `{cat} | awk '{print $1 ", " $3 " " $2 " " $6 " " $4 " " $5}' }
+fn usage{
+	echo usage: 9bbs2nostromo src dst post >[1=2]
+	exit usage
+}
+if(~ $#2 0 || ~ $#4 1)
+	usage
+src=$1
+dst=$2
+post=$3
+checkdir $src
+checkdir $dst
+builtin cd $src
+if(~ $#post 0 || ! ~ $post [0-9]*)
+	post=1
+for(i in `{ls | grep -e '^[0-9]'}){
+	{
+		echo From: `{cat $i/from}
+		echo X-Room: `{cat name}
+		echo Date: `{echo $i | seconds2rfc822}
+		echo X-Date-N: $i
+		echo
+		cat $i/body
+	} >$dst/$post
+	echo $i '->' $post
+	post=`{echo $post^+1 | bc}
+}
--- /dev/null
+++ b/bin/mkperms
@@ -1,0 +1,42 @@
+#!/bin/rc
+# fix file permissions for etc/ and rooms/ when running as user other than none.
+# run from 9bbs install directory.
+rfork e
+argv0=$0
+fn usage {
+	echo usage: $argv0 '[ -g group ] [ -m mode]' >[1=2]
+	exit usage
+}
+ngroup=()
+nmode=()
+if(~ $#* 0)
+	usage
+while(~ $1 -*){
+	switch($1){
+	case -g
+		ngroup=$2
+		shift
+	case -m
+		nmode=$2
+		shift
+	case *
+		usage
+	}
+	shift
+}
+if(! ~ $#* 0)
+	usage
+if(! grep -s -e ':'^$ngroup^':' /adm/users){
+	echo group does not exist.
+	exit nogroup
+}
+for(i in `{walk etc/users}){
+	chgrp $ngroup $i
+	chmod $nmode $i
+	chmod g-w etc
+}
+for(i in `{walk etc/rooms rooms}){
+	chgrp $ngroup $i
+	chmod 775 $i
+	chmod g-w rooms
+}
--- /dev/null
+++ b/bin/mkroom
@@ -1,0 +1,16 @@
+#!/bin/rc
+# create a room.
+# run from 9bbs install directory.
+rfork e
+if(grep -s -e '^'$"1'$' etc/roomlist){
+	echo !room already exists &&
+	exit
+}
+mkdir -p rooms/$1 &&
+cp rooms/lobby/1 rooms/$1/ &&	# hope you didn't edit this file!
+echo $1 >>etc/roomlist &&
+echo $1/1 >>etc/rooms &&
+for(i in `{ls etc/users})
+	echo $1/1 >>$i/rooms	# what if the user is logged in?
+for(i in `{walk rooms/$1})
+	chgrp none $i
--- /dev/null
+++ b/etc/goodbye
@@ -1,0 +1,9 @@
+
+----------------------------------------------------------------------------
+"Quis custodiet ipsos custodes."
+         --Juvenal, _Satires_, VI, 347
+          Quoted as the epigraph of
+          the Tower Commission Report,
+          1987
+----------------------------------------------------------------------------
+
--- /dev/null
+++ b/etc/motd
@@ -1,0 +1,41 @@
+ +---------------------------------------------------+
+ |  Intellectual Property Policy for OSUNY U.K. BBS  |
+ +---------------------------------------------------+
+
+In accordance with Title 17 U.S.C. Section 107, the material within is
+distributed without profit to those who have expressed a prior interest
+in receiving the included information for research and educational
+purposes.  Use of this system constitutes the expression of prior
+interest.
+
+
+.+===============================================+.
+|                                                 |     
+|     _  ,^.  _                                   |
+|   ,'/ -' '- \`.                                 |
+|  / |   \ /   | \                                |
+| |  |   | |   |  |                               |
+| |   \_,' `._/   |  __   __ __  __  __  _  _     |    
+| |               | (( \  || ||  ||\ ||  \\//     |
+|  \             /   \\   || ||  ||\\||   )/      |
+|   `.         .'   \_))  \\_//  || \||  //       |
+|     `--._.--'                                   |
+|                                  u.k.           |
+|                                                 |     
+|                                                 |
+`+===============================================+' 
+
+
+---------------------------------------------------------------------------
+            Someday they won't let you, so now you must agree
+        The times they are a-telling, and the changing isn't free
+        You've read it in the tea leaves, and the tracks are on TV
+                          Beware the savage jaw
+                                 Of 1984
+---------------------------------------------------------------------------
+===========================================================================
+  ssh osuny.bell-labs.co port 999	# any username, no password
+	RSA SHA256:lf2khQcO6kib2dN/eXYaemzV/sBSt+Yaou/E4PKYxUQ
+  telnet osuny.bell-labs.co port 666
+===========================================================================
+
--- /dev/null
+++ b/etc/roomlist
@@ -1,0 +1,1 @@
+lobby
--- /dev/null
+++ b/etc/rooms
@@ -1,0 +1,1 @@
+lobby/1
--- /dev/null
+++ b/etc/users/sl/created
@@ -1,0 +1,1 @@
+Tue Feb  7 16:47:55 GMT 2012
--- /dev/null
+++ b/etc/users/sl/editor
@@ -1,0 +1,1 @@
+sam -d
--- /dev/null
+++ b/etc/users/sl/password
@@ -1,0 +1,1 @@
+CHANGEME
--- /dev/null
+++ b/etc/users/sl/plines
@@ -1,0 +1,1 @@
+22
--- /dev/null
+++ b/etc/users/sl/room
@@ -1,0 +1,1 @@
+lobby
--- /dev/null
+++ b/etc/users/sl/rooms
@@ -1,0 +1,1 @@
+lobby/1
--- /dev/null
+++ b/etc/users/sl/sig
@@ -1,0 +1,1 @@
+sl
--- /dev/null
+++ b/etc/users/sl/wrap
@@ -1,0 +1,1 @@
+72
--- /dev/null
+++ b/etc/welcome
@@ -1,0 +1,20 @@
+
+----------------------------------------------------------------------------
+
+  W E L C O M E  T O  O S U N Y  U . K .
+
+----------------------------------------------------------------------------
+
+  The default editor is sam -d.  (http://sam.cat-v.org)
+
+  The following is an example of how to enter a simple message:
+
+	e
+	i
+	[your text here]
+	.
+	w
+	q
+
+  type 'h' for general help with the system.
+
binary files /dev/null b/img/9til.de.png differ
--- /dev/null
+++ b/index.md
@@ -1,0 +1,143 @@
+9bbs
+====
+
+citadel style bbs for plan 9, written in rc
+
+download
+--------
+
+[9bbs.tgz](http://plan9.stanleylieber.com/src/9bbs.tgz)
+
+	hg clone https://code.9front.org/hg/9bbs
+
+install
+-------
+
+9bbs is started by a [listen(8)](http://man.9front.org/8/listen)
+script that runs on an arbitrary port.  The example files included
+with this distribution are setup to run on port 666, but may be
+modified to suit.  The following instructions assume that a listener
+is already scanning the directory `/rc/bin/service` (true by default
+for cpu servers).  In this scenario, the 9bbs script will be run as
+user `none`, which has special properties limiting its access to
+system resources.  Run 9bbs as any user other than `none` at
+your own risk.  WARNING: Because user `none` can only read and
+write files that are world-accessible, anyone with access to the
+file system will be able to read and write files under `etc/`.
+
+First, edit `src/tcp666` to reflect the location of the 9bbs files on
+your system, and set any desired options.  Edit `etc/motd` and
+`etc/welcome` according to taste.
+
+Next, build and install the programs:
+
+	cd 9bbs/src
+	mk install
+	cd ..
+	mk log
+	mk perms	# user who runs this must be a member of group none
+
+Note: 9bbs uses a modified copy of the Plan 9 pager,
+[p(1)](http://man.9front.org/1/p).  It is identical in all ways to the
+original except that the `!` command for issuing shell commands has been
+removed.  The resulting np binary is copied to `$objtype/bin/`, the
+tcp666 script is copied to `/rc/bin/service/`, and a log file is created
+in `/sys/log/9bbs`.  All other 9bbs files remain within the 9bbs
+directory.
+
+All of that completed, 9bbs will now answer telnet connections on port
+666.
+
+Suggested: Read the source.
+
+use
+---
+
+The following commands have been implemented:
+
+	[0-9]+	print specified message
+	b		back
+	B		toggle biff
+	C		change password
+	d [...]		delete message
+	D [...]		view, set message delimiter
+	>D		truncate message delimiter
+	e		enter message
+	E [...]		view, set editor (choices: sam, simple)
+	f		jump to first message
+	g [...]		list rooms with unread messages, go to specified room
+	gr		list ten most recently active rooms
+	grep [...]	grep messages in current room for regexp
+	h, help		print this help message
+	k [...]		print roomlist or grep for specified regexp
+	l		jump to last message
+	L [...]		view, set number of lines to print before engaging pager (enter to continue, q to quit)
+	n		next
+	p, re [...]		print message with minimal headers
+	P [...]		print message with full headers
+	r [...]		reply to message
+	q		quit
+	S [...]		view, set signature
+	>S		truncate signature
+	t		print current date and time
+	u		list users
+	w		who is online
+	wr		list ten most recently active users
+	W [...]		view, set line wrap width
+	y		synchronize message list for current room
+	z		mark all messages (on the entire bbs) as read
+	" [...]		print message in quoted form, suitable for reply
+	?		print debug information
+
+rooms
+-----
+
+A room is a directory somewhere under `rooms/` that contains at least
+one numbered message file.  An example room has been included in the
+distribution: `rooms/lobby/`.
+
+To create a room:
+
+	cd 9bbs
+	./bin/mkroom roomname
+
+Note: Rooms may be nested.
+
+messages
+---------
+
+The message format is as follows:
+
+	To: lobby
+	Date: Wed, 31 Dec 1969 19:00:01 EST
+	X-Date-N: 1
+	
+	This is a placeholder message created to bootstrap the system.
+
+todo
+----
+
+• `g [room]/[n]` to print message `[n]` in `[room]`.
+
+mailing list
+------------
+
+Mainly for announcements.
+
+To subscribe:
+
+	echo subscribe | mail [email protected]
+
+After you're subscribed, messages will arrive from, and may be sent
+to, [email protected].
+
+To unsubscribe:
+
+	echo unsubscribe | mail [email protected]
+
+powered
+-------
+
+<http://osuny.bell-labs.co> - telnet port 666, ssh port 999
+
+<http://9til.de> - telnet port 999
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,23 @@
+log:V:
+	>/sys/log/9bbs
+	chmod +aw /sys/log/9bbs
+	cp src/tcp666 /rc/bin/service
+
+perms:V:
+	for(i in `{walk etc/users}){
+		chgrp none $i
+		chmod 777 $i	# see bin/mkperms for users other than none
+	}
+	for(i in `{walk etc/rooms rooms}){
+		chgrp none $i
+		chmod 777 $i	# gross
+	}
+
+web:V:
+	if(test -f 9bbs.tgz)
+		rm 9bbs.tgz
+	cd ..
+	tar zcvf /tmp/9bbs.tgz 9bbs
+	cd 9bbs
+	cp /tmp/9bbs.tgz ../src/
+	rm /tmp/9bbs.tgz
--- /dev/null
+++ b/rooms/lobby/1
@@ -1,0 +1,5 @@
+To: lobby
+Date: Wed, 31 Dec 1969 19:00:01 EST
+X-Date-N: 1
+
+This is a placeholder message created to bootstrap the system.
--- /dev/null
+++ b/src/mkfile
@@ -1,0 +1,7 @@
+</$objtype/mkfile
+BIN=/$objtype/bin
+TARG=np
+
+OFILES=np.$O
+
+</sys/src/cmd/mkone
--- /dev/null
+++ b/src/np.c
@@ -1,0 +1,84 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+#define	DEF	22	/* lines in chunk: 3*DEF == 66, #lines per nroff page */
+
+Biobuf *cons;
+Biobuf bout;
+
+int pglen = DEF;
+
+void printfile(int);
+
+void
+main(int argc, char *argv[])
+{
+	int n;
+	int f;
+
+	if((cons = Bopen("/dev/cons", OREAD)) == 0) {
+		fprint(2, "np: can't open /dev/cons\n");
+		exits("missing /dev/cons");
+	}
+	Blethal(cons, nil);
+	Binit(&bout, 1, OWRITE);
+	Blethal(&bout, nil);
+	n = 0;
+	while(argc > 1) {
+		--argc; argv++;
+		if(*argv[0] == '-'){
+			pglen = atoi(&argv[0][1]);
+			if(pglen <= 0)
+				pglen = DEF;
+		} else {
+			n++;
+			f = open(argv[0], OREAD);
+			if(f < 0){
+				fprint(2, "np: can't open %s - %r\n", argv[0]);
+				continue;
+			}
+			printfile(f);
+			close(f);
+		}
+	}
+	if(n == 0)
+		printfile(0);
+	exits(0);
+}
+
+void
+printfile(int f)
+{
+	int i, j, n;
+	char *s, *cmd;
+	Biobuf *b;
+
+	b = malloc(sizeof(Biobuf));
+	Binit(b, f, OREAD);
+	Blethal(b, nil);
+	for(;;){
+		for(i=1; i <= pglen; i++) {
+			s = Brdline(b, '\n');
+			if(s == 0){
+				n = Blinelen(b);
+				if(n > 0)	/* line too long for Brdline */
+					for(j=0; j<n; j++)
+						Bputc(&bout, Bgetc(b));
+				else{		/* true EOF */
+					free(b);
+					return;
+				}
+			}else{
+				Bwrite(&bout, s, Blinelen(b)-1);
+				if(i < pglen)
+					Bwrite(&bout, "\n", 1);
+			}
+		}
+		Bflush(&bout);
+		cmd = Brdline(cons, '\n');
+		if(cmd == 0 || *cmd == 'q')
+			exits(0);
+		cmd[Blinelen(cons)-1] = 0;
+	}
+}
--- /dev/null
+++ b/src/tcp666
@@ -1,0 +1,2 @@
+#!/bin/rc
[email protected] /usr/sl/osuny/bin/9bbs -f lobby -m /usr/sl/osuny -p 9000 >>[2]/sys/log/9bbs