home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-18 | 35.7 KB | 1,246 lines |
- Newsgroups: comp.sources.misc
- From: dave@elxr.jpl.Nasa.Gov (Dave Hayes)
- Subject: v30i061: netvote - USENET Newsgroup Voting Software, Part01/01
- Message-ID: <1992Jun17.221834.5991@sparky.imd.sterling.com>
- X-Md4-Signature: 0a120b1a4b8d6f0067656740aef806f8
- Date: Wed, 17 Jun 1992 22:18:34 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: dave@elxr.jpl.Nasa.Gov (Dave Hayes)
- Posting-number: Volume 30, Issue 61
- Archive-name: netvote/part01
- Environment: Perl
-
- This is the voting software I used on soc.personals.ads.*
- I make no guarantees or warranties...but it worked for
- me. It is written in PERL...if you don't have that then
- you're on your own to get it.
-
- This software is designed to sit at the end of an alias pipe
- from some mailer. It recieves mail messages and attempts to
- parse a reasonable vote out of them. Whether it finds a vote
- or not it sends a reply back to the voter informing him/her
- of what (if anything) it was able to do.
-
- I left it tailored for the last vote so you could see what I did
- more clearly.
-
- Dave Hayes - Network & Communications Engineering - JPL / NASA - Pasadena CA
- dave@elxr.jpl.nasa.gov dave@jato.jpl.nasa.gov ...usc!elroy!dxh
- -------------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: README multi multi/README multi/acknowledge
- # multi/cfv.config multi/cfv_handler.pl multi/makeme multi/official
- # multi/perlsu.c multi/refused single single/README
- # single/acknowledge single/cfv_handler.pl single/makeme
- # single/official single/perlsu.c single/refused
- # Wrapped by kent@sparky on Wed Jun 17 17:11:30 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 1 (of 1)."'
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(161 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis contains two packages:
- X
- X single - contains software designed for a vote on a SINGLE newsgroup
- X
- X multi - This will run a single vote on MULTIPLE newsgroups
- END_OF_FILE
- if test 161 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test ! -d 'multi' ; then
- echo shar: Creating directory \"'multi'\"
- mkdir 'multi'
- fi
- if test -f 'multi/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/README'\"
- else
- echo shar: Extracting \"'multi/README'\" \(2343 characters\)
- sed "s/^X//" >'multi/README' <<'END_OF_FILE'
- XThis is the voting software I used on soc.personals.ads.*
- XI make no guarantees or warranties...but it worked for
- Xme. It is written in PERL...if you don't have that then
- Xyou're on your own to get it.
- X
- X[*] OVERVIEW
- X
- XThis software is designed to sit at the end of an alias pipe
- Xfrom some mailer. It recieves mail messages and attempts to
- Xparse a reasonable vote out of them. Whether it finds a vote
- Xor not it sends a reply back to the voter informing him/her
- Xof what (if anything) it was able to do.
- X
- X[*] WHAT'S HERE
- X
- XI left it tailored for the last vote so you could see what I did
- Xmore clearly. Here are the files in this distribution:
- X
- Xacknowledge - The automatic acknowledgement that is sent
- X a voter via email.
- X
- Xcfv.config - Most all the configuration data is in here
- X
- Xcfv_handler.pl - This is the handler for incoming mail. Look
- X inside it to configure it for the path name of the
- X above file.
- X
- Xofficial - Used to do an official tally of votes.
- X
- Xrefused - Sent to voter when a vote is refused for some reason
- X
- X[*] CONFIGURATION
- X
- XEdit the cfv_handler.pl file to tell it where the cfv.config file
- Xis.
- X
- XEdit the cfv.config file to suit your needs. Everything should be
- Xself explanatory. You'll probably find that the current patterns
- Xare ok, feel free to add more according to your needs.
- X
- X[*] INSTALLATION
- X
- XSince (for some reason - if you find out please let ME know)
- Xsendmail aliases can be almost any uid, a setuid program is needed
- Xto avoid making the vote data world writable. The "makeme" script
- X(I *really* didn't want to use 'make') will do this in two
- Xways:
- X
- X"makeme static" will only work if you have a statically linked
- XPERL binary in this directory AND an "undump" for your system
- Xsomewhere in your path. This is the "preferred" way to make a
- Xsetuid perl program.
- X
- X"makeme" will make a C wrapper around the program. Make sure that
- Xif you do it this way that you don't decide to move this directory
- Xto somewhere else without rerunning "makeme".
- X
- XOnce that is done, a binary called "cfv_handler" should be resident
- Xin this directory. Next decide upon an alias for your vote and do
- Xthis in your /etc/aliases file:
- X
- Xvote_address: "| <your directory>/cfv_handler"
- X
- X[*] TRIVIA
- X
- XAny problems, bugs, or enhancements should be sent to dave@elxr.jpl.nasa.gov...
- Xas this is pretty trivial code I have no problem supporting it.
- X
- X
- X
- END_OF_FILE
- if test 2343 -ne `wc -c <'multi/README'`; then
- echo shar: \"'multi/README'\" unpacked with wrong size!
- fi
- # end of 'multi/README'
- fi
- if test -f 'multi/acknowledge' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/acknowledge'\"
- else
- echo shar: Extracting \"'multi/acknowledge'\" \(140 characters\)
- sed "s/^X//" >'multi/acknowledge' <<'END_OF_FILE'
- X[This is a recording...]
- X
- XYour vote on soc.personals.ads.{groups} has been received by my
- Xautomatic voting software. Thank you for voting!
- END_OF_FILE
- if test 140 -ne `wc -c <'multi/acknowledge'`; then
- echo shar: \"'multi/acknowledge'\" unpacked with wrong size!
- fi
- # end of 'multi/acknowledge'
- fi
- if test -f 'multi/cfv.config' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/cfv.config'\"
- else
- echo shar: Extracting \"'multi/cfv.config'\" \(1510 characters\)
- sed "s/^X//" >'multi/cfv.config' <<'END_OF_FILE'
- X#######################CONFIGURE THESE CONSTANTS
- X#
- X# Pathname of working directory (all files relative to here)
- X$cfv_dir="/home/dave/news/cfv/ads";
- X#
- X# Groups you are running a vote for
- X@groups = ("soc.personals.ads.male.seeking-male",
- X "soc.personals.ads.male.seeking-female",
- X "soc.personals.ads.female.seeking-male",
- X "soc.personals.ads.female.seeking-female");
- X#
- X# Pathnames of some files (probably won't need to change these)
- X$mass_ack = "$cfv_dir/mass_acknowledge"; # Where the currently voted people go
- X$votes = "$cfv_dir/votes"; # Where the votes go
- X$single_ack = "$cfv_dir/acknowledge"; # Canned vote acknowledgement
- X$refused = "$cfv_dir/refused"; # Canned vote refusal
- X#
- X# Other parameters
- X$start_date = "4/16/92 06:00"; # Votes start at this time
- X$end_date = "5/18/92 18:00"; # Votes end at this time.
- X$moderator = "dave@elxr"; # Who to send errors to
- X$backup_err = "$cfv_dir/errors"; # Where to send errors to if above fails
- X#
- X# Regexp definitions.
- X# The software looks for a match such that one of the below regexps
- Xpreceeds one of the
- X# above newsgroups. Note the "\\" used to denote a "\", thus a PERL token of "\n"
- X# should be written as "\\n" below.
- X#
- X# Valid YES vote substring regexps.
- X@yesvotes = (
- X "\\sy\\s",
- X "yes",
- X "in.*favo[ur].*"
- X);
- X#
- X# Valid NO vote substring regexps
- X@novotes = (
- X "\\sn\\s",
- X "no",
- X "against.*"
- X);
- X#
- X# Why'd Larry make us do this junk?
- X1;
- X
- X
- X
- END_OF_FILE
- if test 1510 -ne `wc -c <'multi/cfv.config'`; then
- echo shar: \"'multi/cfv.config'\" unpacked with wrong size!
- fi
- # end of 'multi/cfv.config'
- fi
- if test -f 'multi/cfv_handler.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/cfv_handler.pl'\"
- else
- echo shar: Extracting \"'multi/cfv_handler.pl'\" \(5308 characters\)
- sed "s/^X//" >'multi/cfv_handler.pl' <<'END_OF_FILE'
- X#!/usr/bin/perl
- X#
- X# CFV_HANDLER - Handle a CFV from usenet. Expects candidate messages on STDIN.
- X#
- X# Copyright (c) 1991 by Dave Hayes - dave@elxr.jpl.nasa.gov
- X#
- X# All rights reserved.
- X#
- X# Permission is given to distribute these sources, as long as the
- X# copyright messages are not removed, and no monies are exchanged.
- X#
- X# Rev 2 - Handles multiple newsgroup votes
- X#
- X#####################CONFIGURE THIS STUFF!
- X#
- Xrequire '/home/dave/news/cfv/ads/cfv.config';
- X#
- X#####################END OF CONFIGURATION STUFF!
- X#
- X$debug = 0; # Use this if you want verbosity on ERRLOG
- X#
- X# This may be a faster way to read messages. With MailMan I didn't
- X# care if the message was in an array. Here I do cause I'm searching the
- X# body.
- X# Thanks to goehring@mentor.cc.purdue.edu (Scott Goehring)
- X$* = 1;
- X$save = $/; undef $/; $message = <STDIN>; $/ = $save;
- Xstudy $message;
- X($from) = $message =~ /^From: (.+)$/;
- X($subject) = $message =~ /^Subject: (.+)$/;
- X$subject =~ tr/A-Z/a-z/;
- X&maildebug("Message from '$from' with subject '$subject'");
- X#
- X# Check the date now. Must be within bounds
- X($smon,$sday,$syr,$shr,$smin) = split(/[\s\:\/]/,$start_date);
- X($emon,$eday,$eyr,$ehr,$emin) = split(/[\s\:\/]/,$end_date);
- X($x1,$cmin,$chr,$cday,$cmon,$cyr,$x2,$x3,$x4) = (localtime);
- X$s = &numdate($syr,$smon,$sday,$shr,$smin);
- X$e = &numdate($eyr,$emon,$eday,$ehr,$emin);
- X$c = &numdate($cyr,$cmon+1,$cday,$chr,$cmin);
- Xif ($s > $c || $c > $e) {
- X &mailwarn("Invalid date to vote. Message follows:");
- X print ERRLOG $message;
- X open(ACK,"<$refused") || &mailwarn("Couldn't open '$refused': out
- Xof date vote from '$from': $!");
- X open(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe to
- Xmail: out of date vote from '$from'");
- X print MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Error in your vote
- XEOT
- X print MAIL <ACK>;
- X print MAIL "\nYour vote is not with in the date bounds
- X'$start_date' and '$end_date'.\n";
- X close(MAIL);
- X &maildie("EOT.",0);
- X}
- X
- X#
- X# Now check for a valid vote.
- Xforeach $group (@groups) {
- X $got = 0;
- X foreach $yv (@yesvotes) {
- X if (($message =~ /$yv[^\n]*$group/i) || ($message =~ /$group[^\n]*$yv/i)) {
- X #
- X # A YES vote
- X #
- X &mass_ack;
- X open(VOTES,">>$votes") || &mailwarn("Couldn't open
- X'$votes': YES vote from '$from' : ($<,$>) $!");
- X print VOTES "[Y] $group $from\n"; close(VOTES);
- X $got = 1;
- X $vote{$group} = "Y";
- X }
- X }
- X foreach $nv (@novotes) {
- X if (($message =~ /$nv[^\n]*$group/i) || ($message =~ /$group[^\n]*$nv/i)) {
- X #
- X # A NO vote
- X #
- X &mass_ack;
- X open(VOTES,">>$votes") || &mailwarn("Couldn't open
- X'$votes': NO vote from '$from' : $! ");
- X print VOTES "[N] $group $from\n";
- X close(VOTES);
- X $vote{$group} = "N";
- X $got = 1;
- X }
- X }
- X if (!$got) {
- X open(VOTES,">>$votes") || &mailwarn("Couldn't open '$votes': NO
- Xvote from '$from' : $! ");
- X print VOTES "[A] $group $from\n";
- X close(VOTES);
- X $vote{$group} = "A";
- X }
- X}
- X
- Xopen(ACK,"<$single_ack") || &mailwarn("Couldn't open '$single_ack':
- XYES vote from '$from': $!");
- Xopen(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe to
- Xmail: out of date vote from '$from'");
- Xprint MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Your vote
- XEOT
- X
- Xprint MAIL <ACK>;
- Xprint MAIL "\nYour vote was recorded like so:\n";
- Xforeach $group (@groups) {
- X if ($vote{$group} eq "A") { $v = "Abstain"; }
- X if ($vote{$group} eq "Y") { $v = "Yes"; }
- X if ($vote{$group} eq "N") { $v = "No"; }
- X print MAIL "\tFor group $group: $v\n";
- X}
- Xclose(MAIL); close(ACK);
- X
- X######
- X###### SUBROUTINES GO HERE
- X######
- Xsub mass_ack {
- X return if (defined($acked));
- X open(MASS,">>$mass_ack") || &mailwarn("Couldn't open '$mass_ack':
- XYES vote from '$from' : ($<,$>) $!");
- X print MASS "$from\n"; close(MASS);
- X $acked = 1;
- X}
- X
- Xsub mailwarn {
- X local($reason) = shift(@_);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XWarning about Mail from: '$from' with subject: '$subject':
- XReason: $reason.
- XEOT
- X
- X}
- Xsub maillog {
- X local($reason) = shift(@_);
- X
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XMail from: '$from' with subject: '$subject' logged:
- XReason: $reason.
- XEOT
- X close(ERRLOG);
- X}
- Xsub maildebug {
- X local($reason) = shift(@_);
- X
- X return 0 if (!$debug);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XDebug Mail from: '$from' with subject: '$subject':
- XReason: $reason.
- XEOT
- X}
- X
- Xsub maildie {
- X local($reason) = shift(@_);
- X local($exitcode) = shift(@_);
- X
- X exit 0 if ($exitcode == 0);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XMail from: '$from' with subject: '$subject' failed:
- XReason: $reason.
- XEOT
- X close(ERRLOG);
- X exit $exitcode;
- X}
- X
- Xsub numdate {
- X local($y,$m,$d,$mn,$h) = @_;
- X local($n);
- X
- X $n = $h + (100*$mn) + (10000*$d) + (1000000*$m) + ($y * 100000000);
- X &maildebug("Converted ($y,$m,$d,$mn,$h) to $n");
- X return $n;
- X}
- X
- Xsub setup_mail {
- X $mail_is_on = 1;
- X if (!open(ERRLOG,"| /usr/lib/sendmail -t")) {
- X open(ERRLOG,">>$backup_err") || warn "Augh! Can't redirect
- XERRLOG to someplace useful!\n";
- X }
- X select(ERRLOG); $| = 1;
- X}
- END_OF_FILE
- if test 5308 -ne `wc -c <'multi/cfv_handler.pl'`; then
- echo shar: \"'multi/cfv_handler.pl'\" unpacked with wrong size!
- fi
- # end of 'multi/cfv_handler.pl'
- fi
- if test -f 'multi/makeme' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/makeme'\"
- else
- echo shar: Extracting \"'multi/makeme'\" \(214 characters\)
- sed "s/^X//" >'multi/makeme' <<'END_OF_FILE'
- X#!/bin/csh
- Xif ("$1" == "static") then
- X ./perl -u cfv_handler
- X undump cfv_handler perl core
- X chmod 4755 cfv_handler
- Xelse
- X setenv PWD `pwd`
- X cc -o cfv_handler perlsu.c -DPWD=\"$PWD/\"
- X chmod 4755 cfv_handler
- Xendif
- X
- END_OF_FILE
- if test 214 -ne `wc -c <'multi/makeme'`; then
- echo shar: \"'multi/makeme'\" unpacked with wrong size!
- fi
- # end of 'multi/makeme'
- fi
- if test -f 'multi/official' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/official'\"
- else
- echo shar: Extracting \"'multi/official'\" \(3279 characters\)
- sed "s/^X//" >'multi/official' <<'END_OF_FILE'
- X#!/usr/bin/perl
- X#
- X# OFFICIAL - official status of CFV
- X# and deal with duplicates properly
- X#
- Xdie "usage: official [-l|-f|-d]
- X\twhere -l does last vote priority
- X\t -f does first vote priority
- X\t -d discards duplicates\n" if (!defined($ARGV[0]));
- X#
- X# Get config
- X#
- Xrequire 'cfv.config';
- X#
- X# Raw, time-ordered, data
- X#
- X@votes = `cat votes`;
- X#
- X# This builds an associative array that has cleaned data
- X#
- X$y =0; $n = 0;
- Xfor ($i=0; $i<=$#votes; $i++) {
- X if ($votes[$i] =~ /^\[([YNA])\]\s+(\S+)\s+(.*)/) {
- X $p = "$3\n";
- X push(@people,$p) if (grep($_ eq $p,@people) == 0);
- X $g = $2;
- X $v = $1;
- X } else {
- X print "Bad syntax in vote: <$votes[$i]>\n";
- X next;
- X }
- X if (!defined($vote{$p,$g})) {
- X if ($v eq "Y") {
- X $vote{$p,$g} = "yes";
- X $y++;
- X } elsif ($v eq "N") {
- X $vote{$p,$g} = "no";
- X $n++;
- X } elsif ($v eq "A") {
- X $vote{$p,$g} = "abs";
- X $n++;
- X } else {
- X print "Bad vote: <$votes[$i]>\n";
- X }
- X next;
- X }
- X $first{$p,$g} = $vote{$p,$g} if (!defined($first{$p,$g}));
- X if ($v eq "Y") {
- X $last{$p,$g} = "yes";
- X $y++;
- X } elsif ($v eq "N") {
- X $last{$p,$g} = "no";
- X $n++;
- X } elsif ($v eq "A") {
- X $last{$p,$g} = "abs";
- X $n++;
- X } else {
- X print "Bad vote: <$votes[$i]>\n";
- X }
- X $vote{$p,$g} = "dup";
- X}
- X#
- X# Filter the array appropriately
- X#
- Xprint "[DAVE'S AUTOMATIC USENET CFV HANDLER - Rev 2]\n";
- X
- Xforeach $group (@groups) {
- X @tmass = @people;
- X @tyes = grep($vote{$_,$group} eq "yes",@tmass);
- X @tno = grep($vote{$_,$group} eq "no",@tmass);
- X @tdups = grep($vote{$_,$group} eq "dup",@tmass);
- X#
- X# Now deal with duplicates.
- X#
- X if ($ARGV[0] eq "-l") {
- X $method = "Last vote taken as valid";
- X foreach $person (@tdups) {
- X push(@tyes,$person) if ($last{$person,$group} eq "yes");
- X push(@tno,$person) if ($last{$person,$group} eq "no");
- X $vote{$person,$group} = $last{$person,$group};
- X }
- X } elsif ($ARGV[0] eq "-f") {
- X $method = "First vote taken as valid";
- X foreach $person (@tdups) {
- X push(@tyes,$person) if ($first{$person,$group} eq "yes");
- X push(@tno,$person) if ($first{$person,$group} eq "no");
- X $vote{$person,$group} = $first{$person,$group};
- X }
- X } elsif ($ARGV[0] eq "-d") {
- X $method = "Duplicates discarded";
- X } else {
- X die "Illegal argument: $ARGV[0]\n";
- X }
- X
- X# Tally ho!
- X#
- X $tyes = $#tyes + 1;
- X $tno = $#tno + 1;
- X $tmass = $#tmass + 1;
- X $tdups = $#tdups + 1;
- X $tmass -= $tdups if ($tdups > 0);
- X $pyes = $tyes/$tmass * 100; $pyes = sprintf("%02.2f",$pyes);
- X $pno = $tno/$tmass * 100; $pno = sprintf("%02.2f",$pno);
- X $pct = $tyes + $tno;
- X $pdiff = $tyes - $tno;
- X
- X print "
- X NewsGroup: $group
- XTotal Votes: $tmass\t
- XYes Votes: $tyes\t($pyes%)
- XNo Votes: $tno\t($pno%)
- XYes-No Votes: $pdiff
- XDuplicates: $tdups
- XDuplicate Resolution: $method\n";
- X}
- X
- Xprint "\nVote Key - Number refers to column:\n";
- Xfor $i (0..$#groups) {
- X print "\t$i: $groups[$i]\n";
- X $k = $i % 10; $m = int($i/10);
- X $row1 .= "$m";
- X $row2 .= "$k";
- X $row3 .= "=";
- X}
- Xprint "
- X-VOTE COLUMN-
- X$row1
- X$row2
- X$row3
- X";
- X
- Xforeach $p (sort @people) {
- X for $i (0..$#groups) {
- X print "Y" if ($vote{$p,$groups[$i]} eq "yes");
- X print "N" if ($vote{$p,$groups[$i]} eq "no");
- X print "A" if ($vote{$p,$groups[$i]} eq "abs");
- X }
- X print "\t\t$p";
- X}
- X
- X
- X
- X
- END_OF_FILE
- if test 3279 -ne `wc -c <'multi/official'`; then
- echo shar: \"'multi/official'\" unpacked with wrong size!
- fi
- # end of 'multi/official'
- fi
- if test -f 'multi/perlsu.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/perlsu.c'\"
- else
- echo shar: Extracting \"'multi/perlsu.c'\" \(392 characters\)
- sed "s/^X//" >'multi/perlsu.c' <<'END_OF_FILE'
- X/*
- X * PERLSU.C - SetUid wrapper for PERL
- X */
- X#include <malloc.h>
- X/*
- X * Here is the working directory. Should be defined on the command line
- X */
- X#ifndef PWD
- X#define PWD "./"
- X#endif
- X
- Xmain(argc,argv,envp) int argc; char *argv[]; char *envp[]; {
- X
- X char *buf;
- X
- X buf = malloc(sizeof(argv[0]) + 100);
- X strcpy(buf,PWD);
- X strcat(buf,argv[0]);
- X strcat(buf,".pl");
- X execve(buf,argv,envp);
- X}
- X
- X
- END_OF_FILE
- if test 392 -ne `wc -c <'multi/perlsu.c'`; then
- echo shar: \"'multi/perlsu.c'\" unpacked with wrong size!
- fi
- # end of 'multi/perlsu.c'
- fi
- if test -f 'multi/refused' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'multi/refused'\"
- else
- echo shar: Extracting \"'multi/refused'\" \(336 characters\)
- sed "s/^X//" >'multi/refused' <<'END_OF_FILE'
- X[This is a recording...]
- X
- XYour vote for soc.personals.ads.{group} has been refused by the automatic
- Xvoting software for the reasons listed below. If you are just
- Xsending mail about the CFV to me, rest assured I will get it and
- Xignore this message. Otherwise, you may want to resend your vote
- Xaccording to the guidelines in the CFV.
- END_OF_FILE
- if test 336 -ne `wc -c <'multi/refused'`; then
- echo shar: \"'multi/refused'\" unpacked with wrong size!
- fi
- # end of 'multi/refused'
- fi
- if test ! -d 'single' ; then
- echo shar: Creating directory \"'single'\"
- mkdir 'single'
- fi
- if test -f 'single/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/README'\"
- else
- echo shar: Extracting \"'single/README'\" \(2269 characters\)
- sed "s/^X//" >'single/README' <<'END_OF_FILE'
- XThis is the voting software I used on comp.security.misc
- XI make no guarantees or warranties...but it worked for
- Xme. It is written in PERL...if you don't have that then
- Xyou're on your own to get it.
- X
- X[*] OVERVIEW
- X
- XThis software is designed to sit at the end of an alias pipe
- Xfrom some mailer. It recieves mail messages and attempts to
- Xparse a reasonable vote out of them. Whether it finds a vote
- Xor not it sends a reply back to the voter informing him/her
- Xof what (if anything) it was able to do.
- X
- X[*] WHAT'S HERE
- X
- XI left it tailored for the last vote so you could see what I did
- Xmore clearly. Here are the files in this distribution:
- X
- Xacknowledge - The automatic acknowledgement that is sent
- X a voter via email.
- X
- Xcfv.config - Most all the configuration data is in here
- X
- Xcfv_handler.pl - This is the handler for incoming mail. Look
- X inside it to configure it for the path name of the
- X above file.
- X
- Xofficial - Used to do an official tally of votes.
- X
- Xrefused - Sent to voter when a vote is refused for some reason
- X
- X[*] CONFIGURATION
- X
- XEdit the cfv_handler.pl file to suit your needs. Everything is
- Xself explanatory. You'll probably find that the current patterns
- Xare ok, feel free to add more according to your needs.
- X
- X[*] INSTALLATION
- X
- XSince (for some reason - if you find out please let ME know)
- Xsendmail aliases can be almost any uid, a setuid program is needed
- Xto avoid making the vote data world writable. The "makeme" script
- X(I *really* didn't want to use 'make') will do this in two
- Xways:
- X
- X"makeme static" will only work if you have a statically linked
- XPERL binary in this directory AND an "undump" for your system
- Xsomewhere in your path. This is the "preferred" way to make a
- Xsetuid perl program.
- X
- X"makeme" will make a C wrapper around the program. Make sure that
- Xif you do it this way that you don't decide to move this directory
- Xto somewhere else without rerunning "makeme".
- X
- XOnce that is done, a binary called "cfv_handler" should be resident
- Xin this directory. Next decide upon an alias for your vote and do
- Xthis in your /etc/aliases file:
- X
- Xvote_address: "| <your directory>/cfv_handler"
- X
- X[*] TRIVIA
- X
- XAny problems, bugs, or enhancements should be sent to dave@elxr.jpl.nasa.gov...
- Xas this is pretty trivial code I have no problem supporting it.
- X
- X
- X
- END_OF_FILE
- if test 2269 -ne `wc -c <'single/README'`; then
- echo shar: \"'single/README'\" unpacked with wrong size!
- fi
- # end of 'single/README'
- fi
- if test -f 'single/acknowledge' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/acknowledge'\"
- else
- echo shar: Extracting \"'single/acknowledge'\" \(132 characters\)
- sed "s/^X//" >'single/acknowledge' <<'END_OF_FILE'
- X[This is a recording...]
- X
- XYour vote on comp.security.misc has been received by my
- Xautomatic voting software. Thank you for voting!
- END_OF_FILE
- if test 132 -ne `wc -c <'single/acknowledge'`; then
- echo shar: \"'single/acknowledge'\" unpacked with wrong size!
- fi
- # end of 'single/acknowledge'
- fi
- if test -f 'single/cfv_handler.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/cfv_handler.pl'\"
- else
- echo shar: Extracting \"'single/cfv_handler.pl'\" \(7107 characters\)
- sed "s/^X//" >'single/cfv_handler.pl' <<'END_OF_FILE'
- X#!/usr/bin/perl
- X#
- X# CFV_HANDLER - Handle a CFV from usenet. Expects candidate messages on STDIN.
- X#
- X# Copyright (c) 1991 by Dave Hayes - dave@elxr.jpl.nasa.gov
- X#
- X# All rights reserved.
- X#
- X# Permission is given to distribute these sources, as long as the
- X# copyright messages are not removed, and no monies are exchanged.
- X#
- X#######################CONFIGURE HERE
- X#
- X# Pathname of working directory (all files relative to here)
- X$cfv_dir="/home/dave/news/cfv/sec";
- X#
- X# Group you are running a vote for
- X$group = "comp.security.misc";
- X#
- X# Pathnames of some files (shouldn't need to change these)
- X$mass_ack = "$cfv_dir/mass_acknowledge"; # Where the currently voted people go
- X$votes = "$cfv_dir/votes"; # Where the votes go
- X$single_ack = "$cfv_dir/acknowledge"; # Canned vote acknowledgement
- X$refused = "$cfv_dir/refused"; # Canned vote refusal
- X#
- X# Other things
- X$start_date = "4/13/92 06:00"; # Voting starts
- X$end_date = "5/13/92 18:00"; # Voting ends
- X$moderator = "dave@elxr"; # Who to send errors to
- X$backup_err = "$cfv_dir/errors"; # Where to send errors to if above fails
- X#
- X# Regexp definitions.
- X# The software looks for a match such that one of the below regexps
- Xpreceeds one of the
- X# above newsgroups. Note the "\\" used to denote a "\", thus a PERL token of "\n"
- X# should be written as "\\n" below.
- X#
- X# Valid YES vote substrings
- X@yesvotes = (
- X "yes.*$group",
- X "in.*favo[ur].*$group"
- X);
- X#
- X# Valid NO vote regexps
- X@novotes = (
- X "no.*$group",
- X "against.*$group"
- X);
- X#
- X#####################END OF CONFIGURATION STUFF!
- X#
- X$debug = 0; # Use this if you want verbosity on ERRLOG
- X#
- X# This may be a faster way to read messages. With MailMan I didn't
- X# care if the message was in an array. Here I do cause I'm searching the
- X# body.
- X# Thanks to goehring@mentor.cc.purdue.edu (Scott Goehring)
- X$* = 1;
- X$save = $/; undef $/; $message = <STDIN>; $/ = $save;
- Xstudy $message;
- X($from) = $message =~ /^From: (.+)$/;
- X($subject) = $message =~ /^Subject: (.+)$/;
- X$subject =~ tr/A-Z/a-z/;
- X&maildebug("Message from '$from' with subject '$subject'");
- X#
- X# Check that we have a valid subject
- Xforeach $sub (@subjects) {
- X $found = 1 if ($subject =~ /$sub/i);
- X}
- Xif (!defined($found)) {
- X &mailwarn("Invalid subject. (@subjects) Message follows:");
- X print ERRLOG $message;
- X &maildie("EOT.",0);
- X}
- X#
- X# Check the date now. Must be within bounds
- X($smon,$sday,$syr,$shr,$smin) = split(/[\s\:\/]/,$start_date);
- X($emon,$eday,$eyr,$ehr,$emin) = split(/[\s\:\/]/,$end_date);
- X($x1,$cmin,$chr,$cday,$cmon,$cyr,$x2,$x3,$x4) = (localtime);
- X$s = &numdate($syr,$smon,$sday,$shr,$smin);
- X$e = &numdate($eyr,$emon,$eday,$ehr,$emin);
- X$c = &numdate($cyr,$cmon+1,$cday,$chr,$cmin);
- Xif ($s > $c || $c > $e) {
- X &mailwarn("Invalid date to vote. Message follows:");
- X print ERRLOG $message;
- X open(ACK,"<$refused") || &mailwarn("Couldn't open '$refused': out
- Xof date vote from '$from': $!");
- X open(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe to
- Xmail: out of date vote from '$from'");
- X print MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Error in your vote
- XEOT
- X print MAIL <ACK>;
- X print MAIL "\nYour vote is not with in the date bounds
- X'$start_date' and '$end_date'.\n";
- X close(MAIL);
- X &maildie("EOT.",0);
- X}
- X
- X#
- X# Now check for a valid vote.
- Xforeach $yv (@yesvotes) {
- X if ($message =~ /$yv/i) {
- X #
- X # A YES vote
- X #
- X open(MASS,">>$mass_ack") || &mailwarn("Couldn't open
- X'$mass_ack': YES vote from '$from' : ($<,$>) $!");
- X print MASS "$from\n";
- X close(MASS);
- X open(VOTES,">>$votes") || &mailwarn("Couldn't open '$votes':
- XYES vote from '$from' : ($<,$>) $!");
- X print VOTES "[Y] $from\n";
- X close(VOTES);
- X open(ACK,"<$single_ack") || &mailwarn("Couldn't open
- X'$single_ack': YES vote from '$from': $!");
- X open(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe
- Xto mail: out of date vote from '$from'");
- X print MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Your vote
- XEOT
- X print MAIL <ACK>;
- X print MAIL "\nYour YES vote was recorded successfully.\n";
- X close(MAIL); close(ACK);
- X &maildie("",0);
- X }
- X}
- Xforeach $nv (@novotes) {
- X if ($message =~ /$nv/i) {
- X #
- X # A NO vote
- X #
- X open(MASS,">>$mass_ack") || &mailwarn("Couldn't open
- X'$mass_ack': NO vote from '$from' : $!");
- X print MASS "$from\n";
- X close(MASS);
- X open(VOTES,">>$votes") || &mailwarn("Couldn't open '$votes': NO
- Xvote from '$from' : $! ");
- X print VOTES "[N] $from\n";
- X close(VOTES);
- X open(ACK,"<$single_ack") || &mailwarn("Couldn't open
- X'$single_ack': NO vote from '$from' : $!");
- X open(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe
- Xto mail: out of date vote from '$from'");
- X print MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Your Vote
- XEOT
- X print MAIL <ACK>;
- X print MAIL "\nYour NO vote was recorded successfully.\n";
- X &maildie("",0);
- X }
- X}
- X#
- X# If we get here this is an invalid vote
- Xopen(ACK,"<$refused") || &mailwarn("Couldn't open '$refused': INVALID
- Xvote from '$from' : $!");
- Xopen(MAIL,"|/usr/lib/sendmail -t") || &mailwarn("Couldn't pipe to
- Xmail: out of date vote from '$from'");
- Xprint MAIL <<EOT;
- XFrom: $moderator
- XTo: $from
- XSubject: Error in your vote
- XEOT
- Xprint MAIL <ACK>;
- Xprint MAIL "\nNo valid vote could be found in your message.\n\nValid
- XYES votes are of the wildcard form:\n\n";
- Xprint MAIL join("\n",@yesvotes);
- Xprint MAIL "\n\nValid NO votes are of the wildcard form:\n\n";
- Xprint MAIL join("\n",@novotes);
- Xclose(ACK); close(MAIL);
- X$message =~ s/^/>>>/g;
- X&mailwarn("Invalid vote. Message follows:\n\n$message");
- X&maildie("EOT",0);
- X
- X######
- X###### SUBROUTINES GO HERE
- X######
- Xsub mailwarn {
- X local($reason) = shift(@_);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XWarning about Mail from: '$from' with subject: '$subject':
- XReason: $reason.
- XEOT
- X
- X}
- Xsub maillog {
- X local($reason) = shift(@_);
- X
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XMail from: '$from' with subject: '$subject' logged:
- XReason: $reason.
- XEOT
- X close(ERRLOG);
- X}
- Xsub maildebug {
- X local($reason) = shift(@_);
- X
- X return 0 if (!$debug);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XDebug Mail from: '$from' with subject: '$subject':
- XReason: $reason.
- XEOT
- X}
- X
- Xsub maildie {
- X local($reason) = shift(@_);
- X local($exitcode) = shift(@_);
- X
- X exit 0 if ($exitcode == 0);
- X &setup_mail if (!defined($mail_is_on));
- X print ERRLOG <<EOT;
- XFrom: cfv_daemon
- XTo: $moderator
- XSubject: CFV daemon report
- X
- XMail from: '$from' with subject: '$subject' failed:
- XReason: $reason.
- XEOT
- X close(ERRLOG);
- X exit $exitcode;
- X}
- X
- Xsub numdate {
- X local($y,$m,$d,$mn,$h) = @_;
- X local($n);
- X
- X $n = $h + (100*$mn) + (10000*$d) + (1000000*$m) + ($y * 100000000);
- X &maildebug("Converted ($y,$m,$d,$mn,$h) to $n");
- X return $n;
- X}
- X
- Xsub setup_mail {
- X $mail_is_on = 1;
- X if (!open(ERRLOG,"| /usr/lib/sendmail -t")) {
- X open(ERRLOG,">>$backup_err") || warn "Augh! Can't redirect
- XERRLOG to someplace useful!\n";
- X }
- X select(ERRLOG); $| = 1;
- X}
- END_OF_FILE
- if test 7107 -ne `wc -c <'single/cfv_handler.pl'`; then
- echo shar: \"'single/cfv_handler.pl'\" unpacked with wrong size!
- fi
- # end of 'single/cfv_handler.pl'
- fi
- if test -f 'single/makeme' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/makeme'\"
- else
- echo shar: Extracting \"'single/makeme'\" \(214 characters\)
- sed "s/^X//" >'single/makeme' <<'END_OF_FILE'
- X#!/bin/csh
- Xif ("$1" == "static") then
- X ./perl -u cfv_handler
- X undump cfv_handler perl core
- X chmod 4755 cfv_handler
- Xelse
- X setenv PWD `pwd`
- X cc -o cfv_handler perlsu.c -DPWD=\"$PWD/\"
- X chmod 4755 cfv_handler
- Xendif
- X
- END_OF_FILE
- if test 214 -ne `wc -c <'single/makeme'`; then
- echo shar: \"'single/makeme'\" unpacked with wrong size!
- fi
- # end of 'single/makeme'
- fi
- if test -f 'single/official' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/official'\"
- else
- echo shar: Extracting \"'single/official'\" \(2473 characters\)
- sed "s/^X//" >'single/official' <<'END_OF_FILE'
- X#!/usr/bin/perl
- X#
- X# OFFICIAL - official status of CFV
- X# and deal with duplicates properly
- X#
- Xdie "usage: official [-l|-f|-d]
- X\twhere -l does last vote priority
- X\t -f does first vote priority
- X\t -d discards duplicates\n" if (!defined($ARGV[0]));
- X#
- X# Raw, time-ordered, data
- X#
- X@votes = `cat votes`;
- X#
- X# This builds an associative array that has cleaned data
- X#
- X$y =0; $n = 0;
- Xfor ($i=0; $i<=$#votes; $i++) {
- X if ($votes[$i] =~ /^\[([YN])\]\s+(.*)/) {
- X $p = "$2\n";
- X $v = $1;
- X } else {
- X print "Bad syntax in vote: <$votes[$i]>\n";
- X next;
- X }
- X if (!defined($vote{$p})) {
- X if ($v eq "Y") {
- X $vote{$p} = "yes";
- X $y++;
- X } elsif ($v eq "N") {
- X $vote{$p} = "no";
- X $n++;
- X } else {
- X print "Bad vote: <$votes[$i]>\n";
- X }
- X next;
- X }
- X $first{$p} = $vote{$p} if (!defined($first{$p}));
- X if ($v eq "Y") {
- X $last{$p} = "yes";
- X $y++;
- X } elsif ($v eq "N") {
- X $last{$p} = "no";
- X $n++;
- X } else {
- X print "Bad vote: <$votes[$i]>\n";
- X }
- X $vote{$p} = "dup";
- X}
- X#
- X# Filter the array appropriately
- X#
- X@tmass = keys(%vote);
- X@tyes = grep($vote{$_} eq "yes",@tmass);
- X@tno = grep($vote{$_} eq "no",@tmass);
- X@tdups = grep($vote{$_} eq "dup",@tmass);
- X#
- X# Now deal with duplicates.
- X#
- Xif ($ARGV[0] eq "-l") {
- X $method = "Last vote taken as valid";
- X foreach $person (@tdups) {
- X push(@tyes,$person) if ($last{$person} eq "yes");
- X push(@tno,$person) if ($last{$person} eq "no");
- X }
- X} elsif ($ARGV[0] eq "-f") {
- X $method = "First vote taken as valid";
- X foreach $person (@tdups) {
- X push(@tyes,$person) if ($first{$person} eq "yes");
- X push(@tno,$person) if ($first{$person} eq "no");
- X }
- X} elsif ($ARGV[0] eq "-d") {
- X $method = "Duplicates discarded";
- X} else {
- X die "Illegal argument: $ARGV[0]\n";
- X}
- X#
- X# Tally ho!
- X#
- X$tyes = $#tyes + 1;
- X$tno = $#tno + 1;
- X$tmass = $#tmass + 1;
- X$tdups = $#tdups + 1;
- X$tmass -= $tdups if ($ARGV[0] eq "-d" && $tdups > 0);
- X$pyes = $tyes/$tmass * 100; $pyes = sprintf("%02.2f",$pyes);
- X$pno = $tno/$tmass * 100; $pno = sprintf("%02.2f",$pno);
- X$pct = $tyes + $tno;
- X$pdiff = $tyes - $tno;
- X
- Xprint "
- X[DAVE'S AUTOMATIC USENET CFV HANDLER]
- X
- XTotal Votes: $tmass\t
- XYes Votes: $tyes\t($pyes%)
- XNo Votes: $tno\t($pno%)
- XYes-No Votes: $pdiff
- X
- XDuplicates: $tdups
- XDuplicate Resolution: $method\n\n";
- X
- Xif ($ARGV[0] eq "-d" && $tdups > 0) {
- X print "DUPLICATES:\n"; print @tdups; print "\n\n";
- X}
- X
- Xprint "YES VOTES:\n"; print (sort @tyes);
- Xprint "\n\nNO VOTES:\n"; print (sort @tno);
- X
- X
- X
- END_OF_FILE
- if test 2473 -ne `wc -c <'single/official'`; then
- echo shar: \"'single/official'\" unpacked with wrong size!
- fi
- # end of 'single/official'
- fi
- if test -f 'single/perlsu.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/perlsu.c'\"
- else
- echo shar: Extracting \"'single/perlsu.c'\" \(392 characters\)
- sed "s/^X//" >'single/perlsu.c' <<'END_OF_FILE'
- X/*
- X * PERLSU.C - SetUid wrapper for PERL
- X */
- X#include <malloc.h>
- X/*
- X * Here is the working directory. Should be defined on the command line
- X */
- X#ifndef PWD
- X#define PWD "./"
- X#endif
- X
- Xmain(argc,argv,envp) int argc; char *argv[]; char *envp[]; {
- X
- X char *buf;
- X
- X buf = malloc(sizeof(argv[0]) + 100);
- X strcpy(buf,PWD);
- X strcat(buf,argv[0]);
- X strcat(buf,".pl");
- X execve(buf,argv,envp);
- X}
- X
- X
- END_OF_FILE
- if test 392 -ne `wc -c <'single/perlsu.c'`; then
- echo shar: \"'single/perlsu.c'\" unpacked with wrong size!
- fi
- # end of 'single/perlsu.c'
- fi
- if test -f 'single/refused' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'single/refused'\"
- else
- echo shar: Extracting \"'single/refused'\" \(234 characters\)
- sed "s/^X//" >'single/refused' <<'END_OF_FILE'
- X[This is a recording...]
- X
- XYour vote for comp.security.misc has been refused by the automatic
- Xvoting software for the reasons listed below.
- X
- XYou may want to resend your vote according to the guidelines in the CFV,
- Xor send me a text
- END_OF_FILE
- if test 234 -ne `wc -c <'single/refused'`; then
- echo shar: \"'single/refused'\" unpacked with wrong size!
- fi
- # end of 'single/refused'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-