/[pkg-mixmaster]/trunk/Mix2.0/Install
ViewVC logotype

Contents of /trunk/Mix2.0/Install

Parent Directory Parent Directory | Revision Log Revision Log


Revision 238 - (show annotations) (download)
Tue Sep 10 20:06:52 2002 UTC (10 years, 8 months ago) by rabbi
File size: 16653 byte(s)
Added new nymservers for destination.allow.
1 #!/bin/sh
2
3 # $Id: Install,v 1.4 2002/09/10 20:06:52 rabbi Exp $
4 #
5 # Mixmaster installation script, using many ideas from
6 # Adam Shostack's Install-Mix.
7
8 MIXDIR=$PWD
9 if [ "$MIXDIR" = "" ]
10 then
11 MIXDIR=`pwd`
12 fi
13 MIXSRC=$MIXDIR/Src
14
15 MIXDEST0=${MIXPATH:-$HOME/Mix}
16 if [ ! -z "$1" ]
17 then
18 if [ "$1" = "-v" ]
19 then
20 if [ ! -z "$2" ]
21 then
22 MIXDEST0=$2
23 fi
24 else
25 MIXDEST0=$1
26 fi
27 fi
28
29 #whereis program default-path
30 whereis()
31 {
32 #echo "Looking for $1..."
33 found=""
34 for i in $* `which $1 2>&1`
35 do
36 if [ -f "$i" -a -x "$i" ]
37 then
38 found=$i
39 fi
40 done
41 if [ "$found" = "" ]
42 then
43 found=$2
44 # echo "$1 not found. Using $found."
45 # else
46 # echo "$1 is at $found."
47 fi
48 }
49
50 whereis gmake make
51 MAKE=$found
52
53 if echo -n | grep n >/dev/null
54 then
55 echo1=""
56 echo2="\c"
57 else
58 echo1="-n"
59 echo2=""
60 fi
61
62 readln()
63 {
64 echo $echo1 "$1 [$2] $echo2"
65 read ans
66 if [ -z "$ans" ]
67 then
68 ans="$2"
69 fi
70 }
71
72 inst_files()
73 {
74 cd $MIXDIR
75 touch install.$$
76 if [ ! -f $MIXDEST/install.$$ ]
77 then
78 for i in $1
79 do
80 cp $i $MIXDEST
81 done
82 else
83 cp $mixmaster $MIXDEST
84 fi
85 rm -f install.$$
86 }
87
88 conf_file()
89 {
90 sed -e "s/%RMN/$_RMN/g" \
91 -e "s/%SRMN/$_SRMN/g" \
92 -e "s/%RMA/$_RMA/g" \
93 -e "s/%RAA/$_RAA/g" \
94 -e "s/%RAN/$_RAN/g" \
95 -e "s/%CA/$_CA/g" \
96 -e "s/%PS/$_PS/g" \
97 -e "s/%PP/$_PP/g" \
98 -e "s#%NEWS#$_NEWS#g" \
99 -e "s#%MAIL#$_MAIL#g" \
100 -e "s/%ORG/$_ORG/g" \
101 -e "s/%M2N/$_M2N/g" \
102 -e "s/%MM/$_MM/g" ${MIXDIR}/$1.in > $1
103 }
104
105
106 mix_testloop()
107 {
108 echo step $1
109 MIXPATH=. ./mixmaster -R <infile
110 if [ ! -f mail* ]
111 then
112 echo "Failed."
113 exit 1
114 fi
115 mv -f mail* infile
116 }
117
118 mix_test() {
119 if [ "`echo mail*`" = 'mail*' ]
120 then
121 cd $MIXDEST
122 to=`grep COMPLAINTS mixmaster.conf | sed 's/.*[ ]//'`
123 n=`grep SHORTNAME mixmaster.conf | sed 's/.*[ ]//'`
124 if [ "$to" = "" ]
125 then
126 to=nobody
127 echo "Problem: COMPLAINTS is not set in mixmaster.conf!"
128 fi
129 if [ "$n" = "" ]
130 then
131 echo "Problem: SHORTNAME is not set in mixmaster.conf! Installation aborted."
132 exit 1
133 fi
134 echo "Testing Mixmaster:"
135 if [ "$MODE" = 2 ]
136 then
137 echo "[You can ignore the warning below.]"
138 fi
139
140 echo "This is a test." >infile
141 MIXPATH=. ./mixmaster infile -f -to $to -s "test message" -o outfile -l $n $n $n
142 if [ ! -f outfile ]
143 then
144 echo "Failed."
145 exit 1
146 fi
147 mv outfile infile
148 mix_testloop 1
149 mix_testloop 2
150 mix_testloop 3
151 cat infile
152 rm -f infile
153 echo "Test passed."
154 fi
155 }
156
157 if [ -d "$MIXSRC" ]
158 then
159 mixmaster=$MIXSRC/mixmaster
160 else
161 if [ -f mixmaster ]
162 then
163 mixmaster=$MIXDIR/mixmaster
164 else
165 echo "Cannot find mixmaster source directory $MIXDIR."
166 exit 1
167 fi
168 fi
169
170 if [ -d $MIXSRC/rsaref ]
171 then
172 echo "Using RSAREF."
173 cp $MIXSRC/Makefile-rsaref $MIXSRC/Makefile
174 else
175 if [ ! -d $MIXSRC/ssleay ]
176 then
177 if [ -r /usr/local/ssl/lib/libcrypto.a ]
178 then
179 mkdir $MIXSRC/ssleay
180 ln -s /usr/local/ssl/lib $MIXSRC/ssleay/lib
181 ln -s /usr/local/ssl/include $MIXSRC/ssleay/include
182 elif [ -d $MIXDIR/SSLeay-* ]
183 then
184 ln -s $MIXDIR/SSLeay-* $MIXSRC/ssleay
185 elif [ -d $MIXSRC/SSLeay-* ]
186 then
187 ln -s $MIXSRC/SSLeay-* $MIXSRC/ssleay
188 else
189 echo "Error: No cryptographic library found."
190 echo
191 echo "Please install the RSAREF or OpenSSL source code in $MIXSRC,"
192 echo "install OpenSSL in /usr/local/ssl, or link your OpenSSL directory to"
193 echo "$MIXSRC/ssleay."
194 exit 1
195 fi
196 fi
197 if [ ! -f $MIXSRC/ssleay/lib/libcrypto.a ]
198 then
199 (cd $MIXSRC/ssleay
200 if [ ! -x ./Configure ]
201 then
202 echo "Problem: $MIXSRC/ssleay exists, but does not contain the required files."
203 exit 1
204 fi
205 ./Configure
206 readln "Your system?" `uname| tr 'A-Z' 'a-z'`-gcc
207 ./Configure $ans
208 cd crypto
209 make)
210 fi
211 echo "Using OpenSSL."
212 cp $MIXSRC/Makefile-bsafe $MIXSRC/Makefile
213 fi
214
215 NAME=`whoami`
216 if [ "$NAME" = root ]
217 then
218 echo "Installing Mixmaster as root is not recommended.
219 Please create a new user, e.g. \`mixmaster'."
220 readln "Continue anyway?" n
221 if [ "$ans" = y ]
222 then
223 root=1
224 else
225 exit 1
226 fi
227 fi
228
229 ########################################################################
230
231 readln "Mixmaster directory?" $MIXDEST0
232 MIXDEST=$ans
233
234 umask 077
235
236 if [ ! -d $MIXDEST ]
237 then
238 echo "Creating directory $MIXDEST"
239 mkdir $MIXDEST
240 fi
241
242 if [ ! -d $MIXDEST ]
243 then
244 echo "Cannot not create $MIXDEST"
245 exit 1
246 fi
247
248 if [ -f $MIXDEST/secring.mix ]
249 then
250 echo "Upgrading from previous remailer installation..."
251 if grep '^X.*Comm.*:' $MIXDEST/mail* /dev/null >/dev/null 2>/dev/null
252 then
253 echo
254 echo "WARNING: Due to a change in the internal format, the messages that
255 are currently in your pool may carry a double disclaimer.
256 Press ^C to abort and send the messages before you proceed.
257 Press RETURN to continue."
258 read
259 fi
260 MODE=3
261 else
262 echo "How do you want to use Mixmaster?
263
264 1: client only
265 2: middleman remailer
266 3: public remailer"
267
268 read MODE
269 if [ "$MODE" != 1 -a "$MODE" != 2 -a "$MODE" != 3 ]
270 then
271 echo "Installation aborted."
272 exit 1
273 fi
274 fi
275
276 _MM=0
277 if [ "$MODE" = 2 ]
278 then
279 echo "Anonymous messages will not be sent to the recipient directly. In addition,
280 you can hide your identity from users by using an anonymous address for your
281 remailer. In that case, the remailer will send status messages anonymously."
282 readln "Are you going to do that?" n
283 if [ "$ans" = "y" ]
284 then
285 _MM=1
286 echo "NOTE: Encrypted mixmaster packets will be sent to the next hop directly.
287 You will have to configure the remailer to send all outgoing messages through a
288 remailer chain if you need to protect your identity from more determined
289 adversaries."
290 fi
291 fi
292
293 if [ "$MODE" != 1 ]
294 then
295 if [ -d $MIXSRC ]
296 then
297 echo "Please enter a pass phrase for your remailer (must be the same
298 whenever you re-compile Mixmaster)."
299 read PASS
300 if [ ! -z "$PASS" ]
301 then
302 cd $MIXSRC; $MAKE newpass
303 fi
304 fi
305 fi
306
307 if [ -d $MIXSRC ]
308 then
309 SYSTEM=`uname | tr A-Z a-z`
310 if [ $SYSTEM = "sunos" ]; then
311 if [ `uname -r | awk -F. '{print $1}'` = 5 ]; then
312 SYSTEM='solaris'
313 fi
314 fi
315
316 cd $MIXSRC
317
318 if grep "^$SYSTEM:" Makefile >/dev/null
319 then
320 TARGET=$SYSTEM
321 else
322 echo "This does not seem to be a tested system."
323 TARGET=all
324 fi
325
326 echo "Now building mixmaster. Please wait."
327
328 $MAKE $TARGET PASS=$PASS MIXPATH=$MIXDEST
329
330 if [ ! -x mixmaster ]
331 then
332 echo "As you can probably see, the build failed. Read the docs."
333 if [ "$TARGET" = all ]
334 then
335 echo "It may be necessary to modify the Makefile for your system."
336 fi
337 exit 1
338 fi
339 fi
340
341 whereis sendmail /usr/lib/sendmail /usr/sbin/sendmail
342 SENDMAIL=$found
343
344 if [ "$MODE" = 1 ]
345 then
346 inst_files "$mixmaster type2.list pubring.mix mixmaster.1 mix.list urls"
347 if [ ! -f "$SENDMAIL" ]
348 then
349 readln "Name and path of sendmail program:" "$SENDMAIL"
350 SENDMAIL="$ans"
351 fi
352 sed "s#/usr/lib/sendmail#$SENDMAIL#" <mixmaster.conf >$MIXDEST/mixmaster.conf
353 else
354 if [ -f $MIXDEST/secring.mix ]
355 then
356 # upgrade
357 inst_files "$mixmaster mixmaster.1 urls"
358 else
359 # new installation
360 inst_files "$mixmaster type2.list pubring.mix destination.block \
361 mix.help pubring.mix source.block mixmaster.1 headers.del mix.list urls"
362 fi
363 fi
364
365 cd $MIXDEST
366
367 readln "Get the current mixmaster list now?" y
368 if [ "$ans" = y ]
369 then
370 $MIXDIR/getlist
371 fi
372
373 if [ "$MODE" = 1 ]
374 then
375 cd $MIXDEST
376 elif [ ! -f $MIXDEST/secring.mix ]
377 then
378
379 if [ "$root" != 1 ]
380 then
381 readln "Do you have cooperation from root in installing Mixmaster?" n
382 if [ "$ans" = y ]
383 then
384 root=1
385 fi
386 fi
387
388 if [ "$root" != 1 ]
389 then
390 # Assume that procmail is installed if .procmailrc exists and if it is
391 # called from .forward.
392 if [ -f ~/.procmailrc ]
393 then
394 procmail=1
395 elif grep procmail ~/.forward >/dev/null 2>/dev/null
396 then
397 procmail=1
398 else
399 whereis procmail
400 if [ -x $found ]
401 then
402 ans=n
403 readln "Do you want to run Mixmaster from procmail?" y
404 if [ "$ans" = y ]
405 then
406 procmail=2
407 fi
408 fi
409 fi
410 fi
411
412 readln "Do you want to log error messages?" y
413 if [ "$ans" = y ]
414 then
415 MIXLOG="2>>${MIXDEST}/log"
416 fi
417
418 readln "Do you want to run Mixmaster from cron?" y
419 if [ "$ans" = y ]
420 then
421 cron=1
422 else
423 MIXOPT="-S -L"
424 fi
425
426 if [ "$1" = "-v" ]
427 then
428 readln "Packet-ID logging?" y
429 else
430 ans="y"
431 fi
432 if [ "$ans" = y ]
433 then
434 touch id.log
435 fi
436
437 if [ "$root" = 1 ]
438 then
439 readln "The e-mail address of your remailer:" mixmaster@`hostname`
440 else
441 readln "The e-mail address of your remailer:" $NAME@`hostname`
442 fi
443 _RMA=$ans
444 NAME2=`echo $_RMA | sed 's/@.*//'`
445
446 if [ "$root" = 1 -a "$NAME2" != "$NAME" ]
447 then
448 MBOX="${MIXDEST}/mbox" # will use an alias address
449 else
450 MBOX=${MAIL:-/usr/spool/mail/$NAME}
451 if touch $MBOX >/dev/null 2>/dev/null
452 then
453 root=0 # We can write to the default mbox and don't set an alias
454 else
455 MBOX="${MIXDEST}/mbox"
456 fi
457 fi
458
459 if [ "$MODE" = 2 ]
460 then
461 echo "You can set up a list of addresses that your remailer will mail to directly.
462 All other messages will be forwarded to another remailer.
463 It is usually a good idea to allow sending mail to nym servers and to yourself.
464 This list will be sent to users in reponse to a \"remailer-conf\" request.
465 Specify the addresses or \`none'."
466 echo "@`echo $_RMA | sed 's/.*@//'`" >destination.allow
467 echo "@redneck.gacracker.org @nym.xganon.com @hod.aarg.net @nym.gmsociety.org @nym.alias.net @alias.cyberpass.net @anon.nymserver.com @mailanon.com @anon.efga.org" >>destination.allow
468 readln "Allow mailing to:" "`tr '
469 ' ' ' <destination.allow`"
470 if echo "$ans" | grep none >/dev/null
471 then
472 echo >destination.allow
473 _RMN="Mixmaster"
474 else
475 echo "$ans" | tr ' ' '
476 ' >destination.allow
477 fi
478 fi # MODE = 2
479
480 if [ "$_RMN" = "Mixmaster" -a "$1" != "-v" ]
481 then
482 # mail to users not allowed. We can use default values for mixmaster.conf
483 _CA=$_RMA
484 _RAN="Anonymous"
485 else
486 readln "An address to appear in the \`From:' line of anonymous messages:" `echo $_RMA | sed 's/.*@/nobody@/'`
487 _RAA=$ans
488
489 readln "Address for complaints to be sent to:" `whoami`@`echo $_RMA | sed 's/.*@//'`
490 _CA=$ans
491 echo "Choose a name for your remailer. It will appear in remailer status messages."
492 readln "Long name:" "Anonymous Remailer"
493 _RMN=$ans
494
495 echo "Choose a name to be used in the \`From:' line of remailed messages."
496 readln "Anon long name:" "Anonymous"
497 _RAN=$ans
498 fi
499
500 readln "A short name to appear in lists:" `hostname|sed 's/\..*//'`
501 _SRMN=`echo $ans | tr -d ' '`
502
503 echo "How many messages do you want to keep in the reordering pool?
504 The security of the mixmaster is better with larger pools, but the
505 large pool also causes higher latency. As your mixmaster grows in
506 popularity, you can increase the poolsize to get more security.
507 0 means to remail immediately."
508 readln "Message pool size:" 5
509 _PS=$ans
510
511 _PP=100
512 if [ "$1" = "-v" -a "$cron" = 1 ]
513 then
514 echo "You can define the rate at which messages leave the system. A
515 reduced rate can be useful to avoid \`flooding attacks' and reduce system
516 load when lots of messages arrive at the same time. Specify the fraction of
517 messages to send each time the pool is processed."
518 readln "Percent of messages (1-100):" 100
519 _PP="$ans"
520 fi
521
522 _MAIL="$SENDMAIL -t"
523 if [ "$1" = "-v" -o ! -f "$SENDMAIL" ]
524 then
525 readln "Name and path of sendmail program (-t flag required):" "$_MAIL"
526 _MAIL="$ans"
527 fi
528
529 _M2N="mail2news@nym.alias.net"
530
531 if [ "$MODE" != 2 ]
532 then
533 echo "Do you want to allow posting to Usenet? Newsgroups can be restricted
534 using the destination.block file.
535 y = Yes, post locally; m = Use mail-to-news gateway; n = No."
536 readln "Allow posting to Usenet?" m
537 if [ "$ans" = y ]
538 then
539 whereis inews /usr/lib/news/inews
540 readln "News posting software:" "$found -h"
541 _NEWS="$ans"
542 readln "Organization line for anonymous Usenet posts:" "Anonymous Posting Service"
543 _ORG="$ans"
544 fi
545 if [ "$ans" = m ]
546 then
547 readln "Mail-to-news gateway:" mail2news@nym.alias.net
548 _NEWS="mail-to-news"
549 _M2N="$ans"
550 fi
551 fi
552
553 cd $MIXDEST
554 conf_file mixmaster.conf
555 conf_file mix.help
556 conf_file keyinfo.txt
557
558 if [ "$MODE" = 2 ]
559 then
560 echo "
561 This remailer can only be used in the middle of a chain." >>mix.help
562 fi
563
564 #if [ -f testkey ] # for debugging
565 #then # for debugging
566 # echo "WARNING: Using test key!!!" # for debugging
567 # cp testkey secring.mix # for debugging
568 # MIXPATH=. ./mixmaster -K # for debugging
569 #else # for debugging
570 MIXPATH=. ./mixmaster -G
571 #fi # for debugging
572
573 grep @ mix.key | head -1 >> type2.list
574 echo >> pubring.mix
575 sed '1,/-=-=-=/d' mix.key >> pubring.mix
576
577 mix_test
578
579 echo "----------------------------------------------------------------------------"
580
581 if [ "$cron" = 1 ]
582 then
583 echo
584 echo "Add the following line to your crontab:"
585 echo "5,15,25,35,45,55 * * * * ${MIXDEST}/mixmaster -S -L $MIXLOG"
586 if crontab -l 2>/dev/null | grep mixmaster >/dev/null
587 then
588 echo '(Mixmaster already is registered in your crontab.)'
589 else
590 readln "Do that now?" y
591 if [ "$ans" = y ]
592 then
593 (crontab -l 2>/dev/null
594 echo "5,15,25,35,45,55 * * * * ${MIXDEST}/mixmaster -S -L $MIXLOG" ) >$MIXDIR/inst
595 if crontab $MIXDIR/inst 2>&1 | grep usage >/dev/null 2>/dev/null
596 then
597 crontab -r $MIXDIR/inst
598 fi
599 fi
600 fi
601 fi
602
603 umask 033
604
605 if [ "$procmail" = 2 ]
606 then
607 procmail=1
608 if [ -f ~/.forward ]
609 then
610 echo "Your current .forward is:"
611 cat ~/.forward
612 fi
613 echo "Set .forward to the following line:"
614 echo "\"|$found\"" | tee $MIXDIR/inst
615 if [ -f ~/.forward ]
616 then
617 readln "Overwrite?" n
618 else
619 readln "Do that now?" y
620 fi
621 if [ "$ans" = y ]
622 then
623 cat $MIXDIR/inst >~/.forward
624 fi
625 fi
626
627 if [ "$procmail" = 1 ]
628 then
629 echo "Add the following lines to .procmailrc:"
630 ( echo
631 echo ":0 f :remailer.lock"
632 echo "|${MIXDEST}/mixmaster -R $MIXOPT $MIXLOG" ) | tee $MIXDIR/inst
633 echo
634 if grep mixmaster ~/.procmailrc >/dev/null 2>/dev/null
635 then
636 echo '(Mixmaster already is registered in your .procmailrc file.)'
637 else
638 readln "Do that now?" y
639 if [ "$ans" = y ]
640 then
641 cat $MIXDIR/inst >>~/.procmailrc
642 fi
643 fi
644 else
645 if [ "$1" = "-v" ]
646 then
647 readln "Mailbox for non-remailer messages:" $MBOX
648 MBOX=$ans
649 fi
650 touch $MBOX >/dev/null 2>/dev/null
651 if [ "$root" != 1 -a ! -w $MBOX ]
652 then
653 echo "Warning: $MBOX is not writable! This may result in lost messages."
654 fi
655
656 if [ "$root" = 1 ]
657 then
658 echo
659 echo "Add the following line to /etc/aliases:"
660 echo "`echo $_RMA | sed 's/@.*//'`: \"|${MIXDEST}/mixmaster -R $MIXOPT >>$MBOX $MIXLOG\""
661 else
662 echo
663 if [ -f ~/.forward ]
664 then
665 echo "Your current .forward is:"
666 cat ~/.forward
667 fi
668 echo "Set .forward to the following line:"
669 echo "\"|${MIXDEST}/mixmaster -R $MIXOPT >>$MBOX $MIXLOG\"" | tee $MIXDIR/inst
670 if [ -f ~/.forward ]
671 then
672 readln "Overwrite?" n
673 else
674 readln "Do that now?" y
675 fi
676 if [ "$ans" = y ]
677 then
678 echo "Please make sure that your mail is delivered properly."
679 cat $MIXDIR/inst >~/.forward
680 fi
681 fi
682 fi
683 else # update
684 if [ -f mix.key -a ! -f mix.key.ori ]
685 then
686 echo "Renaming \`mix.key' to \`mix.key.ori' (can be deleted later)."
687 mv mix.key mix.key.ori
688 fi
689 if [ -f mix.key.ori -a ! -f keyinfo.txt ]
690 then
691 sed '1,/=-=-=-=-=-=-=-=-=-=-=-=/p;d' <mix.key.ori >keyinfo.txt
692 KEYINFO=1
693 fi
694 if grep Subject keyinfo.txt >/dev/null
695 then
696 if [ "$KEYINFO" = 1 ]
697 then
698 echo "Creating file \`keyinfo.txt' from \`mix.key.ori'."
699 fi
700 else
701 _RMN=`grep '^REMAILERNAME' <mixmaster.conf | sed 's/^REMAILERNAME[ ]*//'`
702 conf_file keyinfo.txt
703 echo "Creating file \`keyinfo.txt'."
704 fi
705 chmod 600 secring.mix
706 MIXPATH=. ./mixmaster -K
707 mix_test
708 fi
709
710 umask 000
711 chmod 711 $MIXDEST
712 chmod 4711 $MIXDEST/mixmaster
713 if [ ! -d $MIXSRC -a ! -f $MIXDEST/mix-bin ]
714 then
715 mv $MIXDEST/mixmaster $MIXDEST/mix-bin
716 echo "#!/bin/sh
717 MIXPATH=$MIXDEST $MIXDEST/mix-bin $*" >$MIXDEST/mixmaster
718 chmod 711 $MIXDEST/mixmaster
719 fi
720
721 echo "Mixmaster installation complete."

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5