File: Install

package info (click to toggle)
mixmaster 3.0.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,272 kB
  • ctags: 1,031
  • sloc: ansic: 18,669; sh: 1,448; yacc: 698; perl: 314; makefile: 160
file content (1403 lines) | stat: -rwxr-xr-x 28,319 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
#!/bin/sh
# Mixmaster version 3.0  --  (C) 1999-2008 Anonymizer Inc. and others.

# Mixmaster may be redistributed and modified under certain conditions.
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
# ANY KIND, either express or implied. See the file COPYRIGHT for
# details.

# $Id: Install 979 2008-03-03 18:17:07Z rabbi $

#whereis program default-path
whereis()
{
  #echo "Looking for $1..."
  found=""
  for i in $* `which $1 2>&1`
  do
    if [ -f "$i" -a -x "$i" ]
    then
      found=$i
    fi
  done
  if [ "$found" = "" ]
  then
    found=$2
#    echo "$1 not found. Using $found."
#  else
#    echo "$1 is at $found."
  fi
}

if echo -n | grep n >/dev/null
then
 echo1=""
 echo2="\c"
else
 echo1="-n"
 echo2=""
fi

# readln text default
readln()
{
  echo $echo1 "$1 [$2] $echo2"
  read ans
  if [ -z "$ans" ]
  then
    ans="$2"
  fi
}

# findlib libxxx.a -- find and configure libraries
#    Input:
#       $1       library name
#       $CONFIG  library configure options
#       $INCDIR  possible include directories
#       $SRCDIR  possible library source directories
#       $LIBDIR  possible library binary directories
#
#    Output:
#       $found   library directory
#       $lib     library name
#       $INCDIR  include directory if required, empty otherwise
#       $LDFLAG  linker options
#       $LIB     path to library file
#       $MAKELIB Makefile entry to compile library
findlib()
{
 lib=$1
 libso=`echo $lib | sed 's/\.a$/.so/'`
 echo "Looking for $lib..."

 found=
 source=
 type=
 LIB=
 LDFLAG=
 MAKELIB=

 for i in /usr/local/lib /usr/lib /lib /usr/lib64
 do
  if [ -r $i/$lib -o -r $i/$libso ]
  then
   found=$i
   type=system
  fi
 done

 for i in $LIBDIR
 do
  if [ -r $i/$lib -o -r $i/$libso ]
  then
   found=$i
   type=installed
  fi
 done

 for i in $SRCDIR
 do
  if [ -r $i/$lib -o -r $i/lib/$lib ]
  then
   found=$i
   type=binary
  fi
 done

 if [ -r "$found/$libso" ]
 then
  echo "Found at $found/$libso."
 elif [ -r "$found/$lib" ]
 then
  echo "Found at $found/$lib."
 elif [ -r "$found/lib/$lib" ]
 then
  echo "Found at $found/lib/$lib."
 fi

 for i in $SRCDIR
 do
  if [ -d $i -a ! "$type" = binary ]
  then
   source=$i
  fi
 done

 if [ "$source" != "" ]
 then
  echo "Found source directory $source."
  if [ "$found" = "" ]
  then
   ans=y
  else
   echo "Use the source if the pre-installed library causes compilation problems."
   readln "Use source?" n
  fi
  if [ "$ans" = "y" ]
  then
   found=$source
   type=source
  fi
 fi

 if [ "$found" = "" ]
 then
  echo "Not found."
 fi

 if [ -r $found/lib/$lib ]
 then
  LIB=$found/lib/$lib
 else
  LIB=$found/$lib
 fi
 if [ "$type" = system ]
 then
  LIB=
  LDFLAG="-l`echo $lib | sed 's/^lib//;s/\.a$//'` -L$found"
  if [ "$found" = "/usr/local/lib" ]
  then
    INCDIR="/usr/local/include $INCDIR"
  fi
 fi

 incdir=$INCDIR
 INCDIR=
 for i in $incdir
 do
  if [ -d $i ]
  then
   INCDIR=$i
  fi
 done

 if [ "$type" = source -o "$type" = binary ]
 then
  if [ ! -r $found/lib/$lib ]
  then
   MAKELIB="$found/$lib:
	cd $found; make $lib"
  fi
  if [ -d $found/include ]
  then
   INCDIR=$found/include
  else
   INCDIR=$found
  fi
 fi

 if [ "$type" = source ]
 then
  dir=`pwd`
  if [ "$dir" = "" ]
  then
   dir=$PWD
  fi

  cd $found
  if [ -x configure ]
  then
   echo "Configuring..."
   ./configure $CONFIG
  fi
  if [ "$lib" = "libcrypto.a" ]
  then
   if [ -f config ]
   then
    sh config
   elif [ -x Configure ]
   then
    ./Configure 2>tmp.$$
    cat tmp.$$
    readln "Your system?" `cat tmp.$$ | tr ' ' '\n' | grep -i \`uname\` | tail -1`
    rm -f tmp.$$
    echo "Configuring..."
    ./Configure $ans
   fi
  fi
  cd $dir
 fi
}

# Global installation.


##########################################################################
umask 077

#FIXME -- Mixmaster now should be installed as root, and Install should
#create a remailer user. /var/spool/mixmaster is a good home.

if [ `whoami` = root ]
then
 echo "Please create a new user, e.g, \`mix', and install Mixmaster under that
user id.  Installing Mixmaster as root is not recommended."
 readln "Continue anyway?" n
 if [ "$ans" = n ]
 then
  exit 1
 fi
fi

MIXDIR="$PWD"
if [ "$MIXDIR" = "" ]
then
 MIXDIR=`pwd`
fi
MIXCFG="$MIXDIR/conf"
MIXSRC="$MIXDIR/Src"
MIXDEST0=${MIXPATH:-$HOME/Mix}

system=`uname`
if [ "$system" = "MS-DOS" ]
then
 system=msdos
fi

if [ "$HOSTNAME" = "" ]
then
 HOSTNAME=`hostname`
fi
if [ "$HOSTNAME" = "" ]
then
 HOSTNAME=msdos
 system=msdos
fi

if [ "$system" = msdos ]
then
 MIXDEST0=${MIXPATH:-C:/Mix}
fi

if [ -f "$MIXSRC/Makefile" ]
then
 if grep "#Makefile generated.*$HOSTNAME" $MIXSRC/Makefile
 then
  echo "Found a Makefile for this system."
  readln "Use this Makefile?" y
  if [ "$ans" = n ]
  then
   rm -f "$MIXSRC/Makefile"
  fi
 else
  readln "Remove old Makefile?" y
  if [ "$ans" = y ]
  then
   rm -f "$MIXSRC/Makefile"
  fi
 fi
fi

if [ -f "$MIXSRC/Makefile" ]
then
 MIXDEST=`grep "DSPOOL=" $MIXSRC/Makefile | sed 's/.*DSPOOL=..//;s/\".*//'`
 if [ "$MIXDEST" = "" ]
 then
  MIXDEST="$MIXDEST0"
 fi
fi

if [ "$MIXDEST" = "" ]
then
 readln "Mixmaster directory?" "$MIXDEST0"
 MIXDEST=$ans
else
 echo "Mixmaster directory: $MIXDEST"
fi

if [ ! -d "$MIXDEST" ]
then
  echo "Creating directory $MIXDEST"
  mkdir "$MIXDEST"
fi

if [ ! -d "$MIXDEST" ]
then
  echo "Cannot not create $MIXDEST"
  exit 1
fi

if [ -f "$MIXDEST/mix.cfg" ]
then
  if [ -f "$MIXDEST/secring.mix" ]
  then
    remailer=y
    if grep PASSPHRASE "$MIXDEST/mix.cfg" >/dev/null
    then
      PASSINCONFIG=1
    fi
  else
    readln "Do you want to set up a remailer?" n
    remailer=$ans
  fi
elif [ -f "$MIXDEST/mixmaster.conf" ]
then
  echo "Upgrading from Mixmaster 2.0.*"
  remailer=n
else
  readln "Do you want to set up a remailer?" y
  remailer=$ans
fi


ans=""
if [ "$remailer" = "y" ]
then
  ans="n"
  if [ "$PASSINCONFIG" != 1 ]
  then
    echo ""
    echo "You can either compile your secret passphrase into the binary
or you can set it in your config file. Note that the former does not
really increase security as the passphrase can still be discovered by
running something like \`strings mixmaster'."
    echo ""
    echo "Most users should answer \`n' to this question:"
    echo ""
    readln "Do you want to compile the passphrase into the binary?" n
  fi

  rm -f "$MIXSRC/mix.o" # make sure our new passphrase takes effect
  if [ "$ans" = "y" ]
  then
    ans=""
    echo "Please enter a passphrase for your remailer (must be the same
whenever you re-compile Mixmaster)."
    read ans

    if [ "$ans" != "" ]
    then
      PASS="PASS=$ans"
    else
      echo "WARNING: not setting a passphrase"
    fi
  else
    if [ "$PASSINCONFIG" != 1 ]
    then
      ans=""
      echo "Please enter a passphrase for your remailer (it will be 
stored in mix.cfg in clear)."
      read ans

      if [ "$ans" = "" ]
      then
	echo "WARNING: setting empty passphrase"
      fi
      PASSPHRASE="PASSPHRASE	$ans"
      if [ -f $MIXDEST/mix.cfg ]
      then
	echo "$PASSPHRASE" >> $MIXDEST/mix.cfg
      fi
    fi
  fi
fi


cd "$MIXSRC"
if [ ! -f Makefile ]
then
 LIBS=
 INC=
 DEF=
 LDFLAGS=

 if [ ! -z "$PASS" ]
 then
   DEF="$DEF -DCOMPILEDPASS='\"\$(PASS)\"'"
 fi

 if [ "$system" = msdos ]
 then
  readln "Use WIN32 GUI?" y
  if [ "$ans" = y ]
  then
   system=win32
   LDFLAGS=-lwsock32
  fi
 fi
 if [ "$system" = SunOS ]
 then
  LDFLAGS="-lsocket -lnsl"
 fi

 LIBDIR=
 INCDIR=
 SRCDIR=zlib*
 findlib libz.a
 if [ "$found" = "" ]
 then
  readln "Continue anyway?" n
  if [ "$ans" = "n" ]
  then
   echo "Please install zlib 1.1.4 or 1.2.3 or greater now."
   exit 1
  fi
 else
  ZLIB="$MAKELIB"
  DEF="$DEF -DUSE_ZLIB"
  LIBS="$LIBS $LIB"
  LDFLAGS="$LDFLAGS $LDFLAG"
  if [ "$INCDIR" != "" ]
  then
   INC="$INC -I$INCDIR"
  fi
 fi

 LIBDIR=
 INCDIR="/usr/include /usr/include/pcre /usr/local/pcre/include"
 SRCDIR=pcre*
 findlib libpcre.a
 if [ "$found" != "" ]
 then
  PCRE="$MAKELIB"
  DEF="$DEF -DUSE_PCRE"
  LIBS="$LIBS $LIB"
  LDFLAGS="$LDFLAGS $LDFLAG"
  if [ "$INCDIR" != "" ]
  then
   INC="$INC -I$INCDIR"
  fi
 fi

 opensslinfo="Please get OpenSSL 0.9.6l or greater from http://www.openssl.org/"
 opensslwarning6="WARNING: This version of OpenSSL contains known vulnerabilities. Please upgrade to OpenSSL 0.9.6l or greater!"
 opensslwarning7="WARNING: This version of OpenSSL contains known vulnerabilities. Please upgrade to OpenSSL 0.9.7c or greater!"
 opensslwarning0=$opensslwarning7
 LIBDIR=/usr/local/ssl/lib
 INCDIR="/usr/include /usr/include/ssl /usr/lib/ssl/include /usr/local/ssl/include"
 SRCDIR="openssl*"

 opensslwarn()
 {
 if [ "$1" = "6" ]
 then
  echo $opensslwarning6
 elif [ "$1" = "7" ]
 then
  echo $opensslwarning7
 else 
  echo $opensslwarning0
 fi
  readln "Continue anyway?" y
  if [ "$ans" = "n" ]
  then
   echo $opensslinfo
   exit 1
  fi
 }

 if [ "$system" = win32 ]
 then
  findlib libeay32.a
 else
  findlib libcrypto.a
 fi
 if [ "$found" = "" ]
 then
  echo $opensslinfo
  exit 1
 fi

 OPENSSLLIB="$LIB"
 LIBS="$LIBS $LIB"
 LDFLAGS="$LDFLAGS $LDFLAG"
 if [ "$MAKELIB" != "" ]
 then
  OPENSSL="$found/$lib:
	cd $found/crypto; make"
 fi
 if [ -d "$INCDIR/openssl" ]
 then
  INC="$INC -I$INCDIR"
 else
  # detect old SSLeay versions
  if [ -f "$INCDIR/crypto.h" ]
  then
   version=800
   if grep OPENSSL "$INCDIR/crypto.h" > /dev/null
   then
    version=920
   fi
  fi
 fi

 # Find the OpenSSL version header
 if [ -f "$INCDIR/openssl/opensslv.h" ]
 then
  version=`grep 'SSL.*_VERSION_NUMBER.*0x' $INCDIR/openssl/opensslv.h | sed 's/.*0x0*//;s/[ 	].*//;s/L$//' | tr '[a-f]' '[A-F]'`
 elif [ -f "$INCDIR/opensslv.h" ]
 then
  version=`grep 'SSL.*_VERSION_NUMBER.*0x' $INCDIR/opensslv.h | sed 's/.*0x0*//;s/[ 	].*//;s/L$//' | tr '[a-f]' '[A-F]'`
 fi
 if [ "$version" = "" ]
 then
  echo "Warning: Can't find OpenSSL version number!"
  readln "Continue anyway?" y
  if [ "$ans" = "n" ]
  then
   echo $opensslinfo
   exit 1
  fi
#
# Here we match against known OpenSSL versions
#
 elif [ "$version" = "90581F" ]
 then
  decimalversion=9459743
  echo "Compiling with OpenSSL 0.9.5a."
  opensslwarn 6
 elif [ "$version" = "90601F" ]
 then
  decimalversion=9461791
  echo "Compiling with OpenSSL 0.9.6a."
  opensslwarn 6
 elif [ "$version" = "90602F" ]
 then
  decimalversion=9461807
  echo "Compiling with OpenSSL 0.9.6b."
  opensslwarn 6
 elif [ "$version" = "90603F" ]
 then
  decimalversion=9461823
  echo "Compiling with OpenSSL 0.9.6c."
  opensslwarn 6
 elif [ "$version" = "90604F" ]
 then
  decimalversion=9461839
  echo "Compiling with OpenSSL 0.9.6d."
  opensslwarn 6
 elif [ "$version" = "90605F" ]
 then
  decimalversion=9461855
  echo "Compiling with OpenSSL 0.9.6e."
  opensslwarn 6
 elif [ "$version" = "90606F" ]
 then
  decimalversion=9461871
  echo "Compiling with OpenSSL 0.9.6f."
  opensslwarn 6
 elif [ "$version" = "90607F" ]
 then
  decimalversion=9461887
  echo "Compiling with OpenSSL 0.9.6g."
  opensslwarn 6
 elif [ "$version" = "90608F" ]
 then
  decimalversion=9461903
  echo "Compiling with OpenSSL 0.9.6h."
  opensslwarn 6
elif [ "$version" = "90609F" ]
 then
  decimalversion=9461919
  echo "Compiling with OpenSSL 0.9.6i."
  opensslwarn 6
 elif [ "$version" = "9060A0" ]
 then
  decimalversion=9461920
  echo "Compiling with OpenSSL 0.9.6j."
  opensslwarn 6
 elif [ "$version" = "9060B0" ]
 then
  decimalversion=9461936
  echo "Compiling with OpenSSL 0.9.6k."
  opensslwarn 6
 elif [ "$version" = "9060C0" ]
 then
  decimalversion=9461952
  echo "Compiling with OpenSSL 0.9.6l."
 elif [ "$version" = "9060D0" ]
 then
  decimalversion=9461968
  echo "Compiling with OpenSSL 0.9.6m."
 elif [ "$version" = "90700F" ]
 then
  decimalversion=9465871
  echo "Compiling with OpenSSL 0.9.7."
  opensslwarn 7
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90701F" ]
 then
  decimalversion=9465887
  echo "Compiling with OpenSSL 0.9.7a."
  opensslwarn 7
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90702F" ]
 then
  decimalversion=9465903
  echo "Compiling with OpenSSL 0.9.7b."
  opensslwarn 7
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90703F" ]
 then
  decimalversion=9465919
  echo "Compiling with OpenSSL 0.9.7c."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90704F" ]
 then
  decimalversion=9465935
  echo "Compiling with OpenSSL 0.9.7d."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90705F" ]
 then
  decimalversion=9465951
  echo "Compiling with OpenSSL 0.9.7e."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90706F" ]
 then
  decimalversion=9465967
  echo "Compiling with OpenSSL 0.9.7f."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90707F" ]
 then
  decimalversion=9465983
  echo "Compiling with OpenSSL 0.9.7g."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90708F" ]
 then
  decimalversion=9465999
  echo "Compiling with OpenSSL 0.9.7h."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90709F" ]
 then
  decimalversion=9466015
  echo "Compiling with OpenSSL 0.9.7i."
  DEF="$DEF -DUSE_AES"

 elif [ "$version" = "9070AF" ]
 then
  decimalversion=9466031
  echo "Compiling with OpenSSL 0.9.7j."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "9070BF" ]
 then
  decimalversion=9466047
  echo "Compiling with OpenSSL 0.9.7k."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "9070CF" ]
 then
  decimalversion=9466063
  echo "Compiling with OpenSSL 0.9.7l."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "9070DF" ]
 then
  decimalversion=9466079
  echo "Compiling with OpenSSL 0.9.7m."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "9070EF" ]
 then
  decimalversion=9466095
  echo "Compiling with OpenSSL 0.9.7n."
  echo "This version was unreleased at the time of packaging."
  echo "It is not guaranteed to work. Please report any problems."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90800F" ]
 then
  decimalversion=9469967
  echo "Compiling with OpenSSL 0.9.8."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90801F" ]
 then
  decimalversion=9469983
  echo "Compiling with OpenSSL 0.9.8a."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90802F" ]
 then
  decimalversion=9469999
  echo "Compiling with OpenSSL 0.9.8b."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90803F" ]
 then
  decimalversion=9470015
  echo "Compiling with OpenSSL 0.9.8c."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90804F" ]
 then
  decimalversion=9470031
  echo "Compiling with OpenSSL 0.9.8d."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90805F" ]
 then
  decimalversion=9470047
  echo "Compiling with OpenSSL 0.9.8e."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90806F" ]
 then
  decimalversion=9470063
  echo "Compiling with OpenSSL 0.9.8f."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90807F" ]
 then
  decimalversion=9470079
  echo "Compiling with OpenSSL 0.9.8g."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90808F" ]
 then
  decimalversion=9470095
  echo "Compiling with OpenSSL 0.9.8h."
  DEF="$DEF -DUSE_AES"
 elif [ "$version" = "90809F" ]
 then
  decimalversion=9470111
  echo "Compiling with OpenSSL 0.9.8h."
  echo "This version was unreleased at the time of packaging."
  echo "It is not guaranteed to work. Please report any problems."
  DEF="$DEF -DUSE_AES"
 fi
#
# Now we try to guess about unknown versions: 
#
 if [ "$decimalversion" = "" ]
 then
  decimalversion=`echo 16i $version p | dc`
 fi
 if [ "$decimalversion" = "" ]
 then
  echo "Warning: This version: ${version} of OpenSSL is not recognized."
  readln "Continue anyway?" y
  if [ "$ans" = "n" ]
  then
   echo $opensslinfo
   exit 1
  else
   echo "Does this version of OpenSSL contain AES support?"
   readln "If unsure of the answer, say \`n'" n
    if [ "$ans" = "y" ]
    then
    DEF="$DEF -DUSE_AES"
    fi
  fi
 elif [ "$decimalversion" -lt "2336" ]  # 920
 then
  echo "This version: ${version} of SSLeay is not supported."
  echo $opensslinfo
  exit 1
 elif [ "$decimalversion" -lt "9449728" ]  # 903100
 then
  echo "This version: ${version} of OpenSSL is not supported."
  echo $opensslinfo
  exit 1
 elif [ "$decimalversion" -gt "9470111" ]  # 0.9.8h
 then
  echo "Warning: This version: ${version} of OpenSSL is untested."
  readln "Continue anyway?" y
  if [ "$ans" = "n" ]
  then
   echo $opensslinfo
   exit 1
  else 
   echo "Does this version of OpenSSL contain AES support?"
   readln "If unsure of the answer, say \`n'" n
    if [ "$ans" = "y" ]
    then
    DEF="$DEF -DUSE_AES"
    fi
  fi
 fi

 LIBDIR=
 INCDIR=/usr/include/ncurses
 SRCDIR=ncurses*
 CONFIG=--enable-termcap
 if [ "$TERMINFO" != "" ]
 then
  CONFIG="--datadir=$TERMINFO"
 fi
 if [ -d /usr/share/terminfo ]
 then
  CONFIG=
 fi
 if [ -d /usr/lib/terminfo ]
 then
  CONFIG=--datadir=/usr/lib/terminfo
 fi

  if [ `uname` = OpenBSD ]
  then
   findlib libcurses.a
  else
   findlib libncurses.a
  fi
 if [ "$found" = "" ]
 then
  if [ "$system" != win32 ]
  then
   readln "Do you want to use Mixmaster's menu-based user interface?" y
   if [ "$ans" = "y" ]
   then
    echo "Please install ncurses now. It is available from http://www.clark.net/pub/dickey/ncurses/ncurses.tar.gz"
    exit 1
   fi
  fi
 else
  DEF="$DEF -DUSE_NCURSES"
  if [ "$type" = system -o "$type" = installed ]
  then
   LIBS="$LIBS $LIB"
   LDFLAGS="$LDFLAGS $LDFLAG"
  else
   LIBS="$LIBS $found/lib/$lib"
   NCURSES="$found/lib/$lib:
	cd $found/ncurses; make ../lib/$lib"
  fi
  if [ "$INCDIR" != "" ]
  then
   INC="$INC -I$INCDIR"
  elif [ -f "/usr/include/ncurses.h" ]
  then
   DEF="$DEF -DHAVE_NCURSES_H"
  fi
 fi

 ideawarn()
 {
    echo "
  WARNING: Your version of OpenSSL has been configured without IDEA support.
  If you continue, Mixmaster will be installed with reduced functionality.
  This means (among other things) that Mixmaster will not create an RSA
  OpenPGP key (to avoid mail loss in the Type I system). You may want to
  re-install OpenSSL before proceeding.

  This will not concern you if you only plan to run a type II remailer or
  simply want a type II client."
    readln "Continue anyway?" y
    if [ "$ans" = "n" ]
    then
     exit 1
    fi
 }

 if [ "$system" = OpenBSD ]
 then
  LIBDIR=
  INCDIR=
  SRCDIR=idea*
  findlib libidea.a
  if [ "$found" = "" ]
  then
   ideawarn
  else
   DEF="$DEF -DUSE_IDEA"
   IDEALIB="$MAKELIB"
   LIBS="$LIBS $LIB"
   LDFLAGS="$LDFLAGS $LDFLAG"
   if [ "$INCDIR" != "" ]
   then
    INC="$INC -I$INCDIR"
   fi
  fi
 elif [ "$system" = msdos -o "$system" = win32 ]
 then
  DEF="$DEF -DUSE_IDEA"
 else
   echo "Checking for IDEA support..."
   cat <<END >tmptst.c
#include <openssl/idea.h>
int main() {
  void *dummy;
  dummy = idea_cfb64_encrypt;
  exit(0);
}
END
   if gcc $LDFLAGS $INC tmptst.c -o tmptst $OPENSSLLIB
   then
     DEF="$DEF -DUSE_IDEA"
   else
     ideawarn
   fi
   rm -f tmptst.c tmptst
 fi

 echo "testing for setenv()..."
 cat <<END >tmptst.c
int main() {
#include <stdlib.h>
 setenv("TZ", "GMT", 0);
 exit(0);
}
END
 if gcc tmptst.c -o tmptst
 then
   DEF="$DEF -DHAVE_SETENV"
 fi
 echo "done"
 rm -f tmptst.c tmptst

# if [ "$MIXDEST" = "$HOME/Mix" ]
# then
#  SPOOL=
# else
  SPOOL=-DSPOOL=\'\"$MIXDEST\"\'
# fi

 echo "Generating Makefile."
 echo "#Makefile generated on $HOSTNAME `date`" >Makefile
 sed -e "s#%MIXDIR#$SPOOL#" \
     -e "s#%LIBS#$LIBS#" \
     -e "s#%LDFLAGS#$LDFLAGS#" \
     -e "s#%INC#$INC#" \
     -e "s#%DEF#$DEF#" < Makefile.in >> Makefile
# echo "$ZLIB" >>Makefile
# echo "$PCRE" >>Makefile
 echo "$IDEALIB" >>Makefile
 echo "$NCURSES" >>Makefile
 echo "$OPENSSL" >>Makefile
fi





echo "Compiling. Please wait."
whereis make
make=$found

if [ "$system" = win32 ]
then
# (cd zlib*; make libz.a)
# (cd pcre*; make libpcre.a)
 if [ "$PASS" != "" ]
 then
  $make "$PASS" dllmix
 else
  $make dllmix
 fi
else
 if [ "$PASS" != "" ]
 then
  $make "$PASS"
 else
  $make
 fi
fi

if [ -x mixmaster ]
then
 echo
else
 echo "Error: The compilation failed. Please consult the documentation (section
\`Installation problems')."
 readln "Remove the old Makefile?" y
 if [ "$ans" = y ]
 then
  rm -f Makefile
 fi
 exit 1
fi

if [ -f "$MIXDEST/mixmaster.conf" -a ! -f "$MIXDEST/mix.cfg" ]
then
 export MIXDEST
 export MIXDIR
 export MIXSRC
 "${MIXDIR}/upgrade"
 exit 0
fi

if [ -f mixmaster.exe ]
then
 cp mixmaster.exe "$MIXDEST"
else
 cp mixmaster "$MIXDEST"
fi

cd "$MIXCFG"
for i in mlist.txt pubring.mix rlist.txt pubring.asc
do
 if [ ! -f "$MIXDEST/$i" ]
 then
  cp "$i" "$MIXDEST"
 fi
done

if [ "$remailer" = "y" ]
then
 cd "$MIXCFG"
 for i in adminkey.txt dest.alw
 do
  if [ ! -f "$MIXDEST/$i" ]
  then
   cp "$i" "$MIXDEST"
  fi
 done
fi

if [ "$remailer" = "n" ]
then
 if [ ! -f "$MIXDEST/mix.cfg" ]
 then
  whereis sendmail /usr/lib/sendmail /usr/sbin/sendmail
  echo "SENDMAIL	$found -t" >"$MIXDEST/mix.cfg"
  cat mix.cfg >>"$MIXDEST/mix.cfg"
 fi
 echo "Client installation complete."
 exit
fi

for i in *.blk
do
 if [ ! -f "$MIXDEST/$i" ]
 then
  cp "$i" "$MIXDEST"
 fi
done

cd "$MIXDEST"

installed=n
if [ -f mix.cfg ]
then
 if grep REMAILERADDR mix.cfg >/dev/null
 then
  installed=y
 fi
fi

if [ "$installed" = "n" ]
then
 Date=`date`
 whereis sendmail /usr/lib/sendmail /usr/sbin/sendmail
 sendmail=$found

 echo "Mixmaster can be installed in the low-maintenance \`middleman' mode.
In that mode, it will send mail to other remailers only, to avoid
complaints about anonymous messages."
 readln "Install as middleman?" n
 middle=$ans

 readln "The e-mail address of your remailer:" `whoami`@$HOSTNAME
 RMA=$ans

 echo "Do you want Mixmaster to send auto-replies to messages it does not
understand (If the address <$RMA> is also used"
 readln "for mail to be read by a human, type \`n')?" y
 autoreply=$ans

 if [ "$middle" = n ]
 then
  readln "An address to appear in the \`From:' line of anonymous messages:" `echo $RMA | sed 's/.*@/nobody@/'`
  RAA=$ans

  readln "Address for complaints to be sent to:" `echo $RMA | sed 's/.*@/abuse@/'`
  CA=$ans
 else
  RAA=$RMA
  CA=$RMA
 fi

 echo "Choose a name for your remailer.  It will appear in remailer status messages."
 readln "Long name:" "Anonymous Remailer"
 RMN=$ans

 if [ "$middle" = n ]
 then
  echo "Choose a name to be used in the \`From:' line of remailed messages."
  readln "Anon long name:" "Anonymous"
  RAN=$ans
 fi

 readln "A short name to appear in lists:" `echo $HOSTNAME|sed 's/\..*//'`
 SN=$ans

 readln "Accept Mixmaster (Type II) messages?" y
 mix=$ans

 readln "Accept PGP (Type I) remailer messages?" n
 pgp=$ans

 unencrypted=n
 if [ "$pgp" = "y" ]
 then
  readln "Accept unencrypted remailer messages?" n
  unencrypted=$ans
 fi

 echo "Mixmaster will log error messages and warnings. Do you want to log"
 readln "informational messages about normal operation as well?" y
 if [ "$ans" = y ]
 then
  verbose=2
 else
  verbose=1
 fi

 readln "Filter binary attachments?" n
 binfilter=$ans

 if [ "$middle" = n ]
 then
  if [ "$autoreply" = y ]
  then
   readln "Allow users to add themselves to the list of blocked addresses?" y
   autoblock=$ans
  fi

  echo "Do you want to allow posting? Newsgroups can be restricted in dest.blk.
y)es, post locally; use m)ail-to-news gateway; n)o."
  readln "Allow posting to Usenet?" m
  post="$ans"
  if [ "$ans" = y ]
  then
   whereis inews /usr/lib/news/inews
   readln "News posting software:" "$found -h"
   news=$ans
   readln "Organization line for anonymous Usenet posts:" "Anonymous Posting Service"
   orga=$ans
   readln "Use anti-spam message IDs?" y
   mid=$ans
  elif [ "$ans" = m ]
  then
   readln "Mail-to-news gateway:" mail2news@nym.alias.net
   news=$ans
  fi
 fi

# Commented the poolsize question out, since poolsize is the least
# important of the three pool parameters.
#
# echo "How many messages do you want to keep in the reordering pool?
#A larger pool is more secure, but also causes higher latency.
#0 means to remail immediately."
# readln "Pool size:" 45
# poolsize=$ans

 mbox=
 if [ -f ~/.forward ]
 then
  mbox=`head -1 ~/.forward | sed 's/^"//;s/"$//'`
  if echo "$mbox" | grep 'mix' >/dev/null 2>/dev/null
  then
   mbox=
  elif echo "$mbox" | grep 'procmail' >/dev/null 2>/dev/null
  then
   if grep mix ~/.procmailrc >/dev/null 2>/dev/null
   then
    mbox=
   fi
  fi
 fi

 if [ "$mbox" = "" ]
 then
  mbox=${MAIL:-/usr/spool/mail/$NAME}
  touch "$mbox"
  if [ ! -w "$mbox" ]
  then
   echo "$mbox is not writeable."
   readln "Mailbox for non-remailer messages:" "${MIXDEST}/mbox"
   mbox=$ans
  fi
 fi

 cat <<END >mix.cfg
# mix.cfg -- installed $Date
SENDMAIL	$sendmail -t

# Where to store non-remailer messages:
MAILBOX		$mbox
#MAILABUSE	mbox.abuse
#MAILBLOCK	mbox.block
#MAILUSAGE	mbox.usage
#MAILANON	mbox.anon
#MAILERROR	mbox.error
#MAILBOUNCE	mbox.bounce

REMAIL		y
MIDDLEMAN	$middle

BINFILTER	$binfilter
AUTOBLOCK	$autoblock

ERRLOG          error.log
VERBOSE		$verbose

# Remailer name and addresses
REMAILERADDR	$RMA
ANONADDR	$RAA
COMPLAINTS	$CA

SHORTNAME	$SN
REMAILERNAME	$RMN
ANONNAME	$RAN

# Supported formats:
MIX             $mix
PGP             $pgp
UNENCRYPTED     $unencrypted

# Maximum message size in kB (0 for no limit):
SIZELIMIT       0

# Usenet news:
NEWS		$news
ORGANIZATION	$orga
MID		$mid

# Remailing strategy:
SENDPOOLTIME    15m
POOLSIZE        45
RATE            65
INDUMMYP        10
OUTDUMMYP       90
CHAIN           *,*,*,*
IDEXP           7d
PACKETEXP       7d

$PASSPHRASE

END

fi # not yet installed


REPLACE="s/%RMN/$RMN/g;s/%RMA/$RMA/g;s/%CA/$CA/g;s/%RAA/$RAA/g"
if [ "$installed" = "n" ]
then
 cd "$MIXCFG"
 if [ ! -f "$MIXDEST/help.txt" ]
 then
  sed "$REPLACE" < intro.hlp >"$MIXDEST/help.txt"
  if [ "$mix" = y ]
  then
   sed "$REPLACE" < mix.hlp >>"$MIXDEST/help.txt"
  fi
  if [ "$unencrypted" = y ]
  then
   sed "$REPLACE" < type1.hlp >>"$MIXDEST/help.txt"
   if [ "$pgp" = y ]
   then
    sed "$REPLACE" < pgp.hlp >>"$MIXDEST/help.txt"
   fi
  elif [ "$pgp" = y ]
  then
   sed "$REPLACE" < pgponly.hlp >>"$MIXDEST/help.txt"
  fi
  if [ "$post" = y ]
  then
   if [ "$pgp" = y -o "$unencrypted" = y ]
   then
    sed "$REPLACE" < news.hlp >>"$MIXDEST/help.txt"
   fi
  fi
  sed "$REPLACE" < end.hlp >>"$MIXDEST/help.txt"
 fi

 for i in *.txt.in
 do
  j=`echo $i | sed 's/\.in$//'`
  if [ ! -f "$MIXDEST/$j" ]
  then
    sed "$REPLACE" < "$i" >"$MIXDEST/$j"
  fi
 done
 cd "$MIXDEST"
fi

echo
if [ ! -f secring.mix ]
then
 echo "Generating secret keys. This may take a while..."
else
 echo "Updating secret keys..."
fi
./mixmaster -K
if [ -f key.txt ]
then
 echo "Done."
 echo
else
 echo "Installation failed. Please consult the Mixmaster documentation."
 exit 1
fi

if [ "$system" = msdos -o "$system" = win32 ]
then
 exit
fi

umask 033

# Set .forward?
# 
set=y
# FIXME -- Mixmastger should run in daemon mode, not from procmail
# Make the Install script do that.

if grep procmail ~/.forward >/dev/null 2>/dev/null
then
 if grep mix ~/.procmailrc >/dev/null 2>/dev/null
 then
  echo "Mixmaster is installed in your .procmailrc file."
  set=n
 fi
fi

if [ "$set" = y -a -f ~/.forward ]
then
 echo "Your current .forward is:"
 cat ~/.forward
 echo
 if grep mix ~/.forward >/dev/null 2>/dev/null
 then
  echo "Mixmaster already is installed in your .forward file."
  set=n
 elif [ "$mbox" != "" ]
 then
  if echo "$mbox" | grep '|' >/dev/null 2>/dev/null
  then
   echo "Mixmaster will pipe messages to $mbox"
  elif echo $mbox | grep '@' >/dev/null 2>/dev/null
  then
   echo "Mixmaster will forward messages to $mbox"
  else
   echo "Mixmaster will store messages to $mbox"
  fi
 fi
fi

if [ "$set" = y ]
then
 echo "Set .forward to the following line:"
 echo "\"|${MIXDEST}/mixmaster -RM\""
 if [ -f ~/.forward ]
 then
  readln "Overwrite now?" n
 else
  readln "Do that now?" n
 fi
 if [ "$ans" = "y" ]
 then
  echo "\"|${MIXDEST}/mixmaster -RM\"" >~/.forward
 fi
fi

#FIXME -- we need a second script that can re-generate help files
# when the conf changes.

if [ "$RMA" != "" ]
then
 echo "
Mixmaster will send the following files as auto-replies:
Mail to <$RMA> with Subject: remailer-help => help.txt"
 echo "Mail to <$RMA> with Subject: remailer-adminkey => adminkey.txt
Remember to add your Remailer Admin public PGP key to the adminkey.txt file."
 if [ "$autoblock" = y ]
 then
  echo "Mail to <$RMA> with line DESTINATION-BLOCK => blocked.txt"
 fi
 if [ "$autoreply" = y ]
 then
  echo "Other mail to <$RMA> => usage.txt"
  echo
  if [ "$CA" != "$RMA" ]
  then
   echo "If you arrange for mail to <$CA> and <$RAA>
to be forwarded to <$RMA>:
Mail to <$CA> => abuse.txt
Mail to <$RAA> => reply.txt"
  fi
 fi
fi

echo
echo "Mixmaster installation complete."