3 # usage: .../new-ballot '[YNA]' 'Remove Bad Bozo from the moderation panel'
4 # ^ regexp, put into /^(?:$regexp)$/io
6 use strict qw(refs vars);
9 my $sballotdir= $0; $sballotdir =~ s,/[^/]*$,,;
10 chdir $sballotdir or die "$sballotdir $!";
18 $ARGV[0] !~ m/^-/ or die;
19 my $regexp= shift @ARGV;
20 my $title= shift @ARGV;
24 system "rm -rf issues/new";
25 mkdir "issues" or $!==&EEXIST or die $!;
26 mkdir "issues/new",0770 or die $!;
28 stat "issues/new" or die $!;
29 my $issueid= time.'-'.((stat _)[1]);
30 my $issuedir= "issues/$issueid";
32 rename "issues/new", $issuedir or die $!;
34 open T, "> $issuedir/title" or die $!;
35 print T $title, "\n" or die $!;
36 print T $regexp, "\n" or die $!;
40 open S, "/dev/urandom" or die $!;
44 sysread(S, $nonce, $hashlen) == $hashlen or die $!;
45 return unpack "H*", $nonce;
50 open M, "../moderators" or die $!;
54 m/^([A-Z]+)\s+(\S+)\s*$/ or die;
55 my $m= { Name => $1, Email => $2 };
56 $m->{Nonce}= randhex(); $m->{Ident}= hash($m->{Nonce});
57 $m->{Password}= randhex(); $m->{HashedPw}= hash($m->{Password});
64 print P <<END or warn $!;
65 To: $setting{ABBREV} moderators <$setting{MODEMAIL}>
66 Subject: Secret ballot initiated for $setting{ABBREV}
68 The administrator of $setting{GROUP}
69 has initiated a new secret ballot on the question:
73 Each moderator will be sent a private email telling them their
74 pseudonym and voting details.
76 There will also be an announcement from the administrator confirming
77 that this is the live ballot (as if there are problems with the
78 software, it may be necessary to initiate several) and explaining what
79 to enter into the "vote" box on the voting page. Please do not vote
80 until you've received that confirmation.
82 The moderators who will be able to vote are the following people:
84 foreach my $m (@mods) {
85 my $opqe= $m->{Email};
86 $opqe =~ s/\@/ (at) /;
87 printf P " %-10s %s\n", $m->{Name}, $opqe or die $!;
90 print P <<END or die $!;
91 If you are not listed, or your email address is wrong, or you do not
92 receive the private login details email (which should arrive almost
93 immediately), please say so as soon as possible.
95 The pseudonyms which have been assigned are as follows:
98 @mods= sort { $a->{Ident} cmp $b->{Ident} } @mods;
99 foreach my $m (@mods) {
100 my $vfile= "$issuedir/v.$m->{Ident}";
101 open V, "> $vfile" or die "$vfile $!";
102 print V "$m->{HashedPw} not voted\n" or die $!;
104 print P " ", $m->{Ident}, "\n" or die $!;
107 print P <<END or die $!;
108 (the pseudonyms have been sorted into numerical order)
110 Thanks for your attention.
111 moderation system robot
116 foreach my $m (@mods) {
118 print P <<END or warn $!;
119 To: $setting{ABBREV} moderator $m->{Name} <$m->{Email}>
120 Subject: [$setting{ABBREV}] Secret ballot private info
122 The administrator of $setting{GROUP}
123 has initiated a new secret ballot on the question:
127 Your login details for voting are:
128 Pseudonym: $m->{Ident}
129 Password: $m->{Password}
131 These are confidential to you, valid only for this particular vote,
132 and cannot be regenerated if they are lost. So please keep this email
133 but do not reveal it to anyone. Reveal the password only to the
136 There will also be an announcement from the administrator confirming
137 that this is the live ballot (as if there are problems with the
138 software, it may be necessary to initiate several) and explaining what
139 to enter into the "vote" box on the voting page. Please do not vote
140 until you've received that confirmation.
142 You may then cast (and change) your vote here:
143 $setting{CGIBASEURL}/g.$setting{ABBREV}/sballot?issue=$issueid
145 Thanks for your attention,
146 moderation system robot
148 Addendum for the paranoid:
149 Your pseudonym was generated from a nonce, as follows:
150 echo $m->{Nonce} | sha256sum
151 Only you know this nonce - it is not stored on the moderation system
152 server. You should check that your vote is properly recorded and
153 complain if not: vote tallies will list which way each pseudonym