ref: 53c3169386da4cffee65e3dfe94723c299e98d05
dir: /select-handler/
#!/bin/rc rfork skel=$rc_nntpd_dir^/skel bind /bin $skel^/bin bind /rc $skel^/rc bind -c '#e' $skel^/env bind -c '#c' $skel^/dev bind -c /nntp/storage $skel^/storage # Connection state directory rc_nntpd_statedir=/nntp/tmp # ramfs -m $rc_nntp_statedir # if (! test -r '#s'/nntp.ramfs) # ramfs -s nntp.ramfs -m $rc_nntpd_statedir # if not # mount '#s'/nntp.ramfs $rc_nntp_statedir bind -c $rc_nntpd_statedir $skel^/tmp cat /adm/timezone/local >$skel^/env/timezone bind $skel / news=/storage # bootstrapping cr= . log.rc connid=`{cat /dev/random | tr -dc '0-9a-zA-Z' | read -c8} cmd=() lockfile=/tmp/lock current_group=/tmp/$connid/group current_article=/tmp/$connid/article current_group_ac=/tmp/$connid/group_ac current_group_low=/tmp/$connid/group_low current_group_high=/tmp/$connid/group_high touch $current_group touch $current_article touch $current_group_ac touch $current_group_low touch $current_group_high # exit handler fn sigexit { rm -rf /tmp/$connid } # server entrypoint if (! test -r $news && ! ~ `{ns | grep storage} '') { log 'no working storage found; quitting' exit } log 'client connection established, id' $connid response 200 'NNTP Service Ready, posting prohibited' touch $lockfile while(test -f $lockfile) { cmdline=`{read >[2]/dev/null} if (! ~ $status '') { log 'client connection hungup, bye?' exit } cmd=`{echo $cmdline | sed 's/'^$cr^'//g'} handle-nntp sleep 1 } log 'client connection' $connid 'closing, bye' response 205 'NNTP Service exits normally' exit