#!/usr/bin/env perl # NAME: delegate.cgi # AUTH: James A. Bowery (jab) # NOTE: Copyright (C) 2003 The Electoral Corruption Killer # Washougal, WA # All Rights Reserved # # Unless explicitly acquired and licensed under the TECK # Commercial License ("TCL") Version 1.0, the contents # of this file are subject to the Reciprocal Public License # ("RPL") Version 1.0 and You may not copy or use this file # in either source code or executable form, except in # compliance with the terms and conditions of the RPL. # # You may obtain a copy of RPL from # http://www.opensource.org/licenses/rpl.php # # All software distributed under the Licenses is provided strictly # on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED, AND THE ELECTORAL CORRUPTION KILLER HEREBY # DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, # ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. # See Licenses for specific language governing rights and # limitations under the Licenses. # # =head1 Workflow For The Electoral Corruption Killer =head2 Introduction The Electoral Corruption Killer is a delegate system designed to stop betrayals of the public by Congress such as occurred with the 1998 expansion of H-1b visas when Congress overwhelmingly disregarded the will of 82% of the public (see http://www.ieeeusa.org/releases/1998/pr091698.html ). It's based on a computer program consisting of less than 120 lines of Perl code (not counting preformatted text like this). TECK makes it easy for a small campaign to win against a major incumbent in an election for Representative or perhaps even Senator, at the State or perhaps even the National level. Unlike ordinary electronic voting systems with hundreds of thousands of lines of code and sophisticated database technology, TECK works by making all votes public via a website so anyone with sufficient interest can at any time verify the tally. The program script itself is designed to be simple and small so anyone with a modicum of computer system administration expertise can analyze and install it, but as already stated the key to security of this system is in the public availability of the tally, so don't be mislead by ease of analyzing a small script and the care with which the installation is done -- that's not what is important -- again -- the key is the public availability of the tally. TECK works by keeping track of citizen delegates so that ordinary citizens don't need to be intimately involved with politics to exercise their legitimate rights as the ultimate keepers of security. If there is someone they trust, say an elder in a family or church, they simply declare their delegate to be exercised by that trustee. These trustees may in turn delegate to other trustees. All delegates are revocable at any time. The sole plank in the campaign platform of TECK candidates is that they will make a good-faith attempt to abide by the votes of their constituents during the legislative session. Given the current corrupt state of electoral politics and the alienation of the voters from it, anyone who knows someone who can run a small computer system can make a credible bid against an incumbent as a TECK. =head2 To Kick-off Your Campaign Kick off your campaign as The Electoral Corruption Killer with a bang! Or at least a bash. Here is a suggested procedure to create synergy between candidates for TECK and their constituents: =over 4 =item 1 Set up a website for your office. This website must be able to run Perl CGI scripts that require as much as a CPU second on a modern processor and 100M of RAM. =item 2 Install the attached Perl CGI script on your website. To make the database writable you must, in the CGI directory where it is installed, execute the shell command: "touch delegate_writable" =item 3 Obtain a dedicated computer system with an amount of RAM at least equal to 32M plus 1K for each voter in your district. This system will be used only for tallying delegates and votes. =item 4 Place the computer in a physically secure area, disconnected from all networks except the electrical grid. =item 5 Invite a variety of computer experts from the local community over for a campaign kick-off party. Admittance to the party is predicated on them agreeing not to touch the computer system and to report anyone attempting to touch the computer system. During this party you will all be in the same room as the computer system but the computer system will be roped off from the rest of the attendees and you will: =over 4 =item 1 Do a clean install of the latest version of Linux or FreeBSD with: Perl, GUI interface, a web browser (probably Mozilla) and a web server (probably Apache) capable of running Perl CGI scripts. =item 2 Copy the attached Perl CGI script (delegate.cgi) to the web browser's CGI directory (probably /usr/local/apache/cgi-bin). =item 3 As root, cd to the CGI directory and to each directory above the CGI directory to execute the shell command: "chmod a+w ." including the period but not the quotes. =item 4 From the web browser hit the URL: http://localhost/cgi-bin/delegate.cgi =item 5 Satisfy yourselves that the script is working as expected. If not, obtain help from your guests. Just about any reasonably sophisticated computer system administrator will be able to solve the problem easily unless there is a problem with the system you were given. =item 6 Obtain the names of computer professionals that are looking for work and give them the following campaign statement to pass to their circle of acquaintances: =begin html
=end html "82% of the public opposed expansion of the H-1b visa program yet Congress voted nearly unanimously to expand the H-1b program. Representative democracy is neither representative nor democratic. People are staying away from the voting booths in droves. is running for representative to change that. He will vote only the way you, his voters, tell him to vote either directly on each bill or, if you prefer, you can revocably delegate your votes to others (but not to ). You will be able to see how you are telling him to vote by visiting his web site at . Your vote will be public so everyone can verify the honesty of the system." =begin html
=end html =item 7 Say goodnight to your guests and secure the facility. =back =back =head2 Running Your Campaign and Office During the campaign simply run your office as you would during the legislative session: =over 4 =item 1 Solicit and accept input from voters on how they want to vote on various bills and to whom they wish to delegate their votes. Input it to the secured tally system. =item 2 Optimize your office as necessary to secure it and speed it. (An obvious suggestion is to give preference to processing easily-verified authorizations. For example, put up a caller-ID telephone answering computer for people to call. If they leave their name, and their caller ID is a listed phone number matching their name, then process their authorizations first. Process the others as you can afford the time and resources to authenticate them. Let people know how they can help ease your timely processing of their authorizations.) For an extensive discussion of potential office optimizations, see http://www.outlander.com/delegate_office.html =item 3 Periodically (as often as you can afford given your resources) copy the delegate_data.pl file to removable media and that copy to your website's CGI directory, treating your secured system's web access log as your transaction log for disaster recovery purposes. =item 4 Set delegate_data.pl on your website to be read only for owner, group and world. The shell command for this is: "chmod 444 delegate_data.pl" =back Copyright 2003 The Electoral Corruption Killer The author grants the right to copy under the terms of the Reciprocal Public License. You may obtain a copy of RPL from: http://www.opensource.org/licenses/rpl.php =cut BEGIN{ if(!-e 'delegate_data.pl'){ open A,">delegate_data.pl" or die "Can't initialize delegate_data.pl"; print A "1"; close A; } } use CGI::Carp; use CGI qw/:standard :debug/; use Data::Dumper; use Fcntl qw/:flock/; use lib '.'; -e 'delegate_writable' # START CRITICAL SECTION and (open(MUTEX,">delegate_mutex") or die "Can't write delegate_mutex: $!") and (flock(MUTEX,LOCK_EX) or die "Can't lock critical section: $!"); require 'delegate_data.pl'; print header; print "\n"; $phoneRE='(\d{10})'; $billRE='([1-9]\d{0,5})'; $voteRE='(0|1|2)'; $deleteRE='(#)'; if (param()) { $op=param('op'); while($op=~s/ / /g){}; $op=~s/^\s*|\s*$|[^\d# ]//g; if(-e 'delegate_writable'){ if(($phone,$delegates)=($op=~/^$phoneRE (($phoneRE )*$phoneRE)$/)){ $citizen{$phone}->{"delegates"}=[split /\s+/,$delegates]; print "$phone delegates to $delegates.

\n"; }elsif(($phone)=($op=~/^$phoneRE $deleteRE$/)){ delete $citizen{$phone}->{"delegate"}; print "$phone retains delegate.

\n"; }elsif(($phone,$bill,$voteOrDelegate,$vote,$delegate)=($op=~/^$phoneRE $billRE ($voteRE|$phoneRE)$/)){ $citizen{$phone}->{$bill}=$voteOrDelegate; if(defined($vote)){ print "$phone votes on bill $bill "; print (('"Nay."','"Yea."','"Abstain."')[$vote]); print "

\n"; }elsif($delegate){ print "$phone delegates on bill $bill to $delegate.

\n"; } }elsif(($phone,$bill,$delete)=($op=~/^$phoneRE $billRE $deleteRE$/)){ print "$phone exercises no authority specific to bill $bill.

\n"; delete $citizen{$phone}->{$bill}; } } if($phone){ open A,">delegate_data.pl.new"; print A Data::Dumper->Dump([\%citizen],[qw(*citizen)]); close A; `mv delegate_data.pl.new delegate_data.pl`; }elsif(($phone,$bill)=($op=~/^$phoneRE $billRE$/)){ showVote(); }elsif(($phone)=($op=~/^$phoneRE$/)){ print "

";
        print Dumper($citizen{$phone});
        print "
\n"; }elsif(($bill)=($op=~/^$billRE$/)){ $yeas=$nays=$abstains=$absents=0; for $phone (keys %citizen){ showVote(); if($vote==1){$yeas++} elsif(!defined($vote)){$absents++} elsif($vote==0){$nays++} elsif($vote==2){$abstains++} } print "Yeas $yeas, Nays $nays, Abstains $abstains, Absents $absents\n"; }else{ print "No query processed:
\"$op\"\n" } } -e delegate_writable # END CRITICAL SECTION and (flock(MUTEX,LOCK_UN) or die "Can't unlock delegate_mutex: $!"); print "
".h1('Enter delegate query:'), start_form(-method=>'GET',-name=>'op', -id=>'op'), '
Examples:
1822
    Tally the vote for bill 1822.
5554274444 42
    Show how 5554274444\'s vote is cast on bill 42.
5552242759
    Dump data for 5552242759.';
print '
5554274444 5554271111
    Set 5554274444\'s default delegate to 5554271111.
5554882222 #
    5554882222 wants no default delegate.
5554274444 5554271111 5554273239
    Set 5554274444\'s first default delegate to 5554271111 and second to 5554273239. Add as many more as desired.
5555228222 122 1
    Set 5555228222\'s vote on bill 122 to "Yea."
5558221121 42 0
    Set 5558221121\'s vote on bill 42 to "Nay."
5554293323 9402 2
    Set 5554293323\'s vote on bill 9402 to "Abstain."
5552242759 1822 5554274444
    Set 5552242759 to delegate bill 1822 to 5554274444.
5554291178 322 #
    Set 5554291178 to delegate bill 322 to default delegate if any.' if -e "delegate_writable";

print '
',textfield(-id=>'op',-name=>'op',-cols=>80,-maxlength=>1000); print submit, end_form,"
"; print "
";
print "The current delegate_data.pl database:\n\n";
print Data::Dumper->Dump([\%citizen],[qw(*citizen)]);
print "
\n"; print ""; exit(0); sub showVote{ undef($vote) unless @priorPhones; push @priorPhones,$phone; if($citizen{$phone}->{$bill}=~/($voteRE|$phoneRE)/){ if($3){ print "$phone delegates $bill to $3"; if(@priorPhones == $3){ print " This is a vicious cycle, hence @priorPhones is absent.

\n"; }else{ print ". "; do{local $phone=$3; showVote()}; } }else{ $vote=$2; print "$phone votes "; print (('"Nay."','"Yea."','"Abstain."')[$vote]); print ".

\n"; } }elsif($delegates=$citizen{$phone}->{"delegates"}){ my $n=0; for my $delegate (@$delegates){ $n++; print "$phone\'s #$n default delegate is $delegate. "; if(grep /$delegate/,@priorPhones){ print " This is a vicious cycle, hence $delegate is absent. "; next; }else{ do{local $phone=$delegate; showVote();} } last if defined($vote); } print "

\n"; }else{ print "$phone is absent.

\n"; } pop @priorPhones; return $vote; }