ref: a093dbb53911954c664b4ebfa0457f5f46011cda
dir: /newuser/
#!/bin/rc run_newuser=t args=() fn usage { echo 'usage: newuser [-n] [-d dept] [-e email] [-i postid] [-s sponsormail] user [pass]' >[1=2] exit 'usage' } fn newu { u=$1 p=$2 auth/keyfs if(test -w /srv/cwfs.cmd){ echo newuser $u >> /srv/cwfs.cmd wm/chusr $args -p $p $u if(~ $run_newuser t) { # auth/as $u /sys/lib/newuser # messes up with namespace if(! test -f /env/authdom) authdom=`{ndb/query sys $sysname authdom} if(! test -f /env/authdom) { echo 'newuser: no authdom variable or entry in ndb' >[1=2] exit 'no authdom' } echo 'key user='$u' proto=dp9ik dom='$authdom' role=client !password='$p >/mnt/factotum/ctl rcpu -u $u -c /sys/lib/newuser } auth/enable $u } if not { echo 'no cwfs.cmd or access to it'>[2=1] exit 'no cwfs.cmd or access to it' } } while (~ $1 -*) { switch ($1) { case -[sdier] if(~ $#x 0) args=$args $1 $2 shift case -n run_newuser=f case -* usage } shift } if (~ $#* 1) { pass=`{fortune /lib/dict/pgwindex | awk '{ print $1 }'} pass=($pass^`{fortune /lib/dict/pgwindex | awk '{ print $1 }'}) echo password: $"pass newu $1 $pass } if (~ $#* 2) newu $1 $2 if not usage