~moody/rc

f396e3ee1b1a183cd6b755d1b0a20d2abebc2985 — Moody 1 year, 1 month ago master
Initial commit
Add firewall and np scripts
2 files changed, 69 insertions(+), 0 deletions(-)

A firewall
A np
A  => firewall +24 -0
@@ 1,24 @@
#!/bin/rc
# Designed to be used with aux/listen1
# EX: aux/listen1 firewall /lib/blacklist aux/trampoline ...

while(~ $1 -*){
	switch($1){
	case -l
		shift
		sed 's/!.*//' $net/remote >> $1
	}

	shift
}

if(test $#* -lt 2){
	echo 'usage: firewall [-l logfile] blacklist command args...' >> /fd/2
	exit
}

if(grep -s `{sed 's/!.*//' $net/remote} $1)
	exit 'blocked by firewall'

shift
exec $*

A  => np +45 -0
@@ 1,45 @@
#!/bin/rc
rfork e
if(test $#* -lt 1){
	echo 'Usage: np name' >[1=2]
	exit
}

prog=$1
dir=$home/src/^$prog
shift

if(test -d $dir){
	exit 'dir already exists'
}
mkdir $dir
sed 's/PROG/'^$prog^'/g' >$dir^'/mkfile' <<.
</$$objtype/mkfile
BIN=$home/bin/$objtype

TARG=PROG
OFILES=PROG.$$O

</sys/src/cmd/mkone
.

includes=`{
	{
		echo #include <u.h>
		echo #include <lib.h>
		for(i in $*){
			man 2 $i 
		} | grep '#include'
	} | awk '{ a[$0] = 1 } END{for(x in a) print x}' | sed 's/^[ 	]+//g;/^$/d'
}


sed '/^$/i\
'^$"includes <{
echo
echo 'void'
echo 'main(int argc, char *argv[])'
echo '{'
echo '}'
} | sed 's/> ?/>\n/g' | sed '/^$/d' | sed '/void/i\
' | sed 's/{/{\n/' > $dir^'/'^$prog^'.c'