Tallying votes with unix utilities
This is a demonstration of how to count votes on a Web page, using nothing but our form data handler, the Procmail email processor, and some Server Side Includes.How the votes are collected
- A form collects votes, and
- mails them to a special address.
- The special address feeds them into Procmail, which
- checks for a valid voting password, and
- records the voting in
- A private file in the vote-meister's home directory and
- A public file everyone can inspect
- Each voter has a secret voting password, known only to her and the pollster. It's recorded in the private record, so the pollster can authenticate the votes.
Files involved
There are several. They are all plain text.
name function origin booth.shtml This form is the ``ballot.'' It collects votes. Written with any HTML editor /v/pk-c/c/cls/frm2ml.pl Form data handler. Written by Cameron in Perl. donevoting.shtml This is the ``exit poll.'' It's where the form handler sends you. Written with any HTML editor that lets you write SSI tags. ~cls/.qmail-votedemo This dot-qmail file receives messages from the form handler and feeds them into Procmail Use the echo command or a text editor. proc This file tells Procmail what to do. (Syntax reference) Use a text editor. ~cls/votefile Private record. In a ``real'' election, this file would be secret. I made a link so you could se it in this demo. Created automatically by the first egrep command in the Procmail file. votefile Public record. Created automatically by the second egrep command in the Procmail file. ~cls/lockfile12 Procmail creates this temporary file while it is working. If a second Procmail comes along, due to two votes arriving at about the same time, it waits for lockfile12 to go away.. Created and removed automatically by Procmail Bugs and subtle stuff
- If you give a wrong password, you still get the Exit Poll.
- Nothing stops people from voting twice except inspecting the record visually.
- Only the pollster knows if someone voted with a wrong voter password. Their vote is recorded anyway.
- There is only one password for the whole question. There should be a password per voter.
- Users can't (Jul 17 2001) run SSI #exec under ~/.www so only people with Web projects can run Exit Polls. But anybody can run an election.
- Procmail runs with the user ID it inherits from Qmail. Therefoer the private and public votefiles belong to whoever receives the mail, as specified in the ballot form.