mixmaster

mixmaster 3.0 patched for libressl
git clone git://parazyd.org/mixmaster.git
Log | Files | Refs | README

Install (28319B)


      1 #!/bin/sh
      2 # Mixmaster version 3.0  --  (C) 1999-2008 Anonymizer Inc. and others.
      3 
      4 # Mixmaster may be redistributed and modified under certain conditions.
      5 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
      6 # ANY KIND, either express or implied. See the file COPYRIGHT for
      7 # details.
      8 
      9 # $Id: Install 979 2008-03-03 18:17:07Z rabbi $
     10 
     11 #whereis program default-path
     12 whereis()
     13 {
     14   #echo "Looking for $1..."
     15   found=""
     16   for i in $* `which $1 2>&1`
     17   do
     18     if [ -f "$i" -a -x "$i" ]
     19     then
     20       found=$i
     21     fi
     22   done
     23   if [ "$found" = "" ]
     24   then
     25     found=$2
     26 #    echo "$1 not found. Using $found."
     27 #  else
     28 #    echo "$1 is at $found."
     29   fi
     30 }
     31 
     32 if echo -n | grep n >/dev/null
     33 then
     34  echo1=""
     35  echo2="\c"
     36 else
     37  echo1="-n"
     38  echo2=""
     39 fi
     40 
     41 # readln text default
     42 readln()
     43 {
     44   echo $echo1 "$1 [$2] $echo2"
     45   read ans
     46   if [ -z "$ans" ]
     47   then
     48     ans="$2"
     49   fi
     50 }
     51 
     52 # findlib libxxx.a -- find and configure libraries
     53 #    Input:
     54 #       $1       library name
     55 #       $CONFIG  library configure options
     56 #       $INCDIR  possible include directories
     57 #       $SRCDIR  possible library source directories
     58 #       $LIBDIR  possible library binary directories
     59 #
     60 #    Output:
     61 #       $found   library directory
     62 #       $lib     library name
     63 #       $INCDIR  include directory if required, empty otherwise
     64 #       $LDFLAG  linker options
     65 #       $LIB     path to library file
     66 #       $MAKELIB Makefile entry to compile library
     67 findlib()
     68 {
     69  lib=$1
     70  libso=`echo $lib | sed 's/\.a$/.so/'`
     71  echo "Looking for $lib..."
     72 
     73  found=
     74  source=
     75  type=
     76  LIB=
     77  LDFLAG=
     78  MAKELIB=
     79 
     80  for i in /usr/local/lib /usr/lib /lib /usr/lib64
     81  do
     82   if [ -r $i/$lib -o -r $i/$libso ]
     83   then
     84    found=$i
     85    type=system
     86   fi
     87  done
     88 
     89  for i in $LIBDIR
     90  do
     91   if [ -r $i/$lib -o -r $i/$libso ]
     92   then
     93    found=$i
     94    type=installed
     95   fi
     96  done
     97 
     98  for i in $SRCDIR
     99  do
    100   if [ -r $i/$lib -o -r $i/lib/$lib ]
    101   then
    102    found=$i
    103    type=binary
    104   fi
    105  done
    106 
    107  if [ -r "$found/$libso" ]
    108  then
    109   echo "Found at $found/$libso."
    110  elif [ -r "$found/$lib" ]
    111  then
    112   echo "Found at $found/$lib."
    113  elif [ -r "$found/lib/$lib" ]
    114  then
    115   echo "Found at $found/lib/$lib."
    116  fi
    117 
    118  for i in $SRCDIR
    119  do
    120   if [ -d $i -a ! "$type" = binary ]
    121   then
    122    source=$i
    123   fi
    124  done
    125 
    126  if [ "$source" != "" ]
    127  then
    128   echo "Found source directory $source."
    129   if [ "$found" = "" ]
    130   then
    131    ans=y
    132   else
    133    echo "Use the source if the pre-installed library causes compilation problems."
    134    readln "Use source?" n
    135   fi
    136   if [ "$ans" = "y" ]
    137   then
    138    found=$source
    139    type=source
    140   fi
    141  fi
    142 
    143  if [ "$found" = "" ]
    144  then
    145   echo "Not found."
    146  fi
    147 
    148  if [ -r $found/lib/$lib ]
    149  then
    150   LIB=$found/lib/$lib
    151  else
    152   LIB=$found/$lib
    153  fi
    154  if [ "$type" = system ]
    155  then
    156   LIB=
    157   LDFLAG="-l`echo $lib | sed 's/^lib//;s/\.a$//'` -L$found"
    158   if [ "$found" = "/usr/local/lib" ]
    159   then
    160     INCDIR="/usr/local/include $INCDIR"
    161   fi
    162  fi
    163 
    164  incdir=$INCDIR
    165  INCDIR=
    166  for i in $incdir
    167  do
    168   if [ -d $i ]
    169   then
    170    INCDIR=$i
    171   fi
    172  done
    173 
    174  if [ "$type" = source -o "$type" = binary ]
    175  then
    176   if [ ! -r $found/lib/$lib ]
    177   then
    178    MAKELIB="$found/$lib:
    179 	cd $found; make $lib"
    180   fi
    181   if [ -d $found/include ]
    182   then
    183    INCDIR=$found/include
    184   else
    185    INCDIR=$found
    186   fi
    187  fi
    188 
    189  if [ "$type" = source ]
    190  then
    191   dir=`pwd`
    192   if [ "$dir" = "" ]
    193   then
    194    dir=$PWD
    195   fi
    196 
    197   cd $found
    198   if [ -x configure ]
    199   then
    200    echo "Configuring..."
    201    ./configure $CONFIG
    202   fi
    203   if [ "$lib" = "libcrypto.a" ]
    204   then
    205    if [ -f config ]
    206    then
    207     sh config
    208    elif [ -x Configure ]
    209    then
    210     ./Configure 2>tmp.$$
    211     cat tmp.$$
    212     readln "Your system?" `cat tmp.$$ | tr ' ' '\n' | grep -i \`uname\` | tail -1`
    213     rm -f tmp.$$
    214     echo "Configuring..."
    215     ./Configure $ans
    216    fi
    217   fi
    218   cd $dir
    219  fi
    220 }
    221 
    222 # Global installation.
    223 
    224 
    225 ##########################################################################
    226 umask 077
    227 
    228 #FIXME -- Mixmaster now should be installed as root, and Install should
    229 #create a remailer user. /var/spool/mixmaster is a good home.
    230 
    231 if [ `whoami` = root ]
    232 then
    233  echo "Please create a new user, e.g, \`mix', and install Mixmaster under that
    234 user id.  Installing Mixmaster as root is not recommended."
    235  readln "Continue anyway?" n
    236  if [ "$ans" = n ]
    237  then
    238   exit 1
    239  fi
    240 fi
    241 
    242 MIXDIR="$PWD"
    243 if [ "$MIXDIR" = "" ]
    244 then
    245  MIXDIR=`pwd`
    246 fi
    247 MIXCFG="$MIXDIR/conf"
    248 MIXSRC="$MIXDIR/Src"
    249 MIXDEST0=${MIXPATH:-$HOME/Mix}
    250 
    251 system=`uname`
    252 if [ "$system" = "MS-DOS" ]
    253 then
    254  system=msdos
    255 fi
    256 
    257 if [ "$HOSTNAME" = "" ]
    258 then
    259  HOSTNAME=`hostname`
    260 fi
    261 if [ "$HOSTNAME" = "" ]
    262 then
    263  HOSTNAME=msdos
    264  system=msdos
    265 fi
    266 
    267 if [ "$system" = msdos ]
    268 then
    269  MIXDEST0=${MIXPATH:-C:/Mix}
    270 fi
    271 
    272 if [ -f "$MIXSRC/Makefile" ]
    273 then
    274  if grep "#Makefile generated.*$HOSTNAME" $MIXSRC/Makefile
    275  then
    276   echo "Found a Makefile for this system."
    277   readln "Use this Makefile?" y
    278   if [ "$ans" = n ]
    279   then
    280    rm -f "$MIXSRC/Makefile"
    281   fi
    282  else
    283   readln "Remove old Makefile?" y
    284   if [ "$ans" = y ]
    285   then
    286    rm -f "$MIXSRC/Makefile"
    287   fi
    288  fi
    289 fi
    290 
    291 if [ -f "$MIXSRC/Makefile" ]
    292 then
    293  MIXDEST=`grep "DSPOOL=" $MIXSRC/Makefile | sed 's/.*DSPOOL=..//;s/\".*//'`
    294  if [ "$MIXDEST" = "" ]
    295  then
    296   MIXDEST="$MIXDEST0"
    297  fi
    298 fi
    299 
    300 if [ "$MIXDEST" = "" ]
    301 then
    302  readln "Mixmaster directory?" "$MIXDEST0"
    303  MIXDEST=$ans
    304 else
    305  echo "Mixmaster directory: $MIXDEST"
    306 fi
    307 
    308 if [ ! -d "$MIXDEST" ]
    309 then
    310   echo "Creating directory $MIXDEST"
    311   mkdir "$MIXDEST"
    312 fi
    313 
    314 if [ ! -d "$MIXDEST" ]
    315 then
    316   echo "Cannot not create $MIXDEST"
    317   exit 1
    318 fi
    319 
    320 if [ -f "$MIXDEST/mix.cfg" ]
    321 then
    322   if [ -f "$MIXDEST/secring.mix" ]
    323   then
    324     remailer=y
    325     if grep PASSPHRASE "$MIXDEST/mix.cfg" >/dev/null
    326     then
    327       PASSINCONFIG=1
    328     fi
    329   else
    330     readln "Do you want to set up a remailer?" n
    331     remailer=$ans
    332   fi
    333 elif [ -f "$MIXDEST/mixmaster.conf" ]
    334 then
    335   echo "Upgrading from Mixmaster 2.0.*"
    336   remailer=n
    337 else
    338   readln "Do you want to set up a remailer?" y
    339   remailer=$ans
    340 fi
    341 
    342 
    343 ans=""
    344 if [ "$remailer" = "y" ]
    345 then
    346   ans="n"
    347   if [ "$PASSINCONFIG" != 1 ]
    348   then
    349     echo ""
    350     echo "You can either compile your secret passphrase into the binary
    351 or you can set it in your config file. Note that the former does not
    352 really increase security as the passphrase can still be discovered by
    353 running something like \`strings mixmaster'."
    354     echo ""
    355     echo "Most users should answer \`n' to this question:"
    356     echo ""
    357     readln "Do you want to compile the passphrase into the binary?" n
    358   fi
    359 
    360   rm -f "$MIXSRC/mix.o" # make sure our new passphrase takes effect
    361   if [ "$ans" = "y" ]
    362   then
    363     ans=""
    364     echo "Please enter a passphrase for your remailer (must be the same
    365 whenever you re-compile Mixmaster)."
    366     read ans
    367 
    368     if [ "$ans" != "" ]
    369     then
    370       PASS="PASS=$ans"
    371     else
    372       echo "WARNING: not setting a passphrase"
    373     fi
    374   else
    375     if [ "$PASSINCONFIG" != 1 ]
    376     then
    377       ans=""
    378       echo "Please enter a passphrase for your remailer (it will be 
    379 stored in mix.cfg in clear)."
    380       read ans
    381 
    382       if [ "$ans" = "" ]
    383       then
    384 	echo "WARNING: setting empty passphrase"
    385       fi
    386       PASSPHRASE="PASSPHRASE	$ans"
    387       if [ -f $MIXDEST/mix.cfg ]
    388       then
    389 	echo "$PASSPHRASE" >> $MIXDEST/mix.cfg
    390       fi
    391     fi
    392   fi
    393 fi
    394 
    395 
    396 cd "$MIXSRC"
    397 if [ ! -f Makefile ]
    398 then
    399  LIBS=
    400  INC=
    401  DEF=
    402  LDFLAGS=
    403 
    404  if [ ! -z "$PASS" ]
    405  then
    406    DEF="$DEF -DCOMPILEDPASS='\"\$(PASS)\"'"
    407  fi
    408 
    409  if [ "$system" = msdos ]
    410  then
    411   readln "Use WIN32 GUI?" y
    412   if [ "$ans" = y ]
    413   then
    414    system=win32
    415    LDFLAGS=-lwsock32
    416   fi
    417  fi
    418  if [ "$system" = SunOS ]
    419  then
    420   LDFLAGS="-lsocket -lnsl"
    421  fi
    422 
    423  LIBDIR=
    424  INCDIR=
    425  SRCDIR=zlib*
    426  findlib libz.a
    427  if [ "$found" = "" ]
    428  then
    429   readln "Continue anyway?" n
    430   if [ "$ans" = "n" ]
    431   then
    432    echo "Please install zlib 1.1.4 or 1.2.3 or greater now."
    433    exit 1
    434   fi
    435  else
    436   ZLIB="$MAKELIB"
    437   DEF="$DEF -DUSE_ZLIB"
    438   LIBS="$LIBS $LIB"
    439   LDFLAGS="$LDFLAGS $LDFLAG"
    440   if [ "$INCDIR" != "" ]
    441   then
    442    INC="$INC -I$INCDIR"
    443   fi
    444  fi
    445 
    446  LIBDIR=
    447  INCDIR="/usr/include /usr/include/pcre /usr/local/pcre/include"
    448  SRCDIR=pcre*
    449  findlib libpcre.a
    450  if [ "$found" != "" ]
    451  then
    452   PCRE="$MAKELIB"
    453   DEF="$DEF -DUSE_PCRE"
    454   LIBS="$LIBS $LIB"
    455   LDFLAGS="$LDFLAGS $LDFLAG"
    456   if [ "$INCDIR" != "" ]
    457   then
    458    INC="$INC -I$INCDIR"
    459   fi
    460  fi
    461 
    462  opensslinfo="Please get OpenSSL 0.9.6l or greater from http://www.openssl.org/"
    463  opensslwarning6="WARNING: This version of OpenSSL contains known vulnerabilities. Please upgrade to OpenSSL 0.9.6l or greater!"
    464  opensslwarning7="WARNING: This version of OpenSSL contains known vulnerabilities. Please upgrade to OpenSSL 0.9.7c or greater!"
    465  opensslwarning0=$opensslwarning7
    466  LIBDIR=/usr/local/ssl/lib
    467  INCDIR="/usr/include /usr/include/ssl /usr/lib/ssl/include /usr/local/ssl/include"
    468  SRCDIR="openssl*"
    469 
    470  opensslwarn()
    471  {
    472  if [ "$1" = "6" ]
    473  then
    474   echo $opensslwarning6
    475  elif [ "$1" = "7" ]
    476  then
    477   echo $opensslwarning7
    478  else 
    479   echo $opensslwarning0
    480  fi
    481   readln "Continue anyway?" y
    482   if [ "$ans" = "n" ]
    483   then
    484    echo $opensslinfo
    485    exit 1
    486   fi
    487  }
    488 
    489  if [ "$system" = win32 ]
    490  then
    491   findlib libeay32.a
    492  else
    493   findlib libcrypto.a
    494  fi
    495  if [ "$found" = "" ]
    496  then
    497   echo $opensslinfo
    498   exit 1
    499  fi
    500 
    501  OPENSSLLIB="$LIB"
    502  LIBS="$LIBS $LIB"
    503  LDFLAGS="$LDFLAGS $LDFLAG"
    504  if [ "$MAKELIB" != "" ]
    505  then
    506   OPENSSL="$found/$lib:
    507 	cd $found/crypto; make"
    508  fi
    509  if [ -d "$INCDIR/openssl" ]
    510  then
    511   INC="$INC -I$INCDIR"
    512  else
    513   # detect old SSLeay versions
    514   if [ -f "$INCDIR/crypto.h" ]
    515   then
    516    version=800
    517    if grep OPENSSL "$INCDIR/crypto.h" > /dev/null
    518    then
    519     version=920
    520    fi
    521   fi
    522  fi
    523 
    524  # Find the OpenSSL version header
    525  if [ -f "$INCDIR/openssl/opensslv.h" ]
    526  then
    527   version=`grep 'SSL.*_VERSION_NUMBER.*0x' $INCDIR/openssl/opensslv.h | sed 's/.*0x0*//;s/[ 	].*//;s/L$//' | tr '[a-f]' '[A-F]'`
    528  elif [ -f "$INCDIR/opensslv.h" ]
    529  then
    530   version=`grep 'SSL.*_VERSION_NUMBER.*0x' $INCDIR/opensslv.h | sed 's/.*0x0*//;s/[ 	].*//;s/L$//' | tr '[a-f]' '[A-F]'`
    531  fi
    532  if [ "$version" = "" ]
    533  then
    534   echo "Warning: Can't find OpenSSL version number!"
    535   readln "Continue anyway?" y
    536   if [ "$ans" = "n" ]
    537   then
    538    echo $opensslinfo
    539    exit 1
    540   fi
    541 #
    542 # Here we match against known OpenSSL versions
    543 #
    544  elif [ "$version" = "90581F" ]
    545  then
    546   decimalversion=9459743
    547   echo "Compiling with OpenSSL 0.9.5a."
    548   opensslwarn 6
    549  elif [ "$version" = "90601F" ]
    550  then
    551   decimalversion=9461791
    552   echo "Compiling with OpenSSL 0.9.6a."
    553   opensslwarn 6
    554  elif [ "$version" = "90602F" ]
    555  then
    556   decimalversion=9461807
    557   echo "Compiling with OpenSSL 0.9.6b."
    558   opensslwarn 6
    559  elif [ "$version" = "90603F" ]
    560  then
    561   decimalversion=9461823
    562   echo "Compiling with OpenSSL 0.9.6c."
    563   opensslwarn 6
    564  elif [ "$version" = "90604F" ]
    565  then
    566   decimalversion=9461839
    567   echo "Compiling with OpenSSL 0.9.6d."
    568   opensslwarn 6
    569  elif [ "$version" = "90605F" ]
    570  then
    571   decimalversion=9461855
    572   echo "Compiling with OpenSSL 0.9.6e."
    573   opensslwarn 6
    574  elif [ "$version" = "90606F" ]
    575  then
    576   decimalversion=9461871
    577   echo "Compiling with OpenSSL 0.9.6f."
    578   opensslwarn 6
    579  elif [ "$version" = "90607F" ]
    580  then
    581   decimalversion=9461887
    582   echo "Compiling with OpenSSL 0.9.6g."
    583   opensslwarn 6
    584  elif [ "$version" = "90608F" ]
    585  then
    586   decimalversion=9461903
    587   echo "Compiling with OpenSSL 0.9.6h."
    588   opensslwarn 6
    589 elif [ "$version" = "90609F" ]
    590  then
    591   decimalversion=9461919
    592   echo "Compiling with OpenSSL 0.9.6i."
    593   opensslwarn 6
    594  elif [ "$version" = "9060A0" ]
    595  then
    596   decimalversion=9461920
    597   echo "Compiling with OpenSSL 0.9.6j."
    598   opensslwarn 6
    599  elif [ "$version" = "9060B0" ]
    600  then
    601   decimalversion=9461936
    602   echo "Compiling with OpenSSL 0.9.6k."
    603   opensslwarn 6
    604  elif [ "$version" = "9060C0" ]
    605  then
    606   decimalversion=9461952
    607   echo "Compiling with OpenSSL 0.9.6l."
    608  elif [ "$version" = "9060D0" ]
    609  then
    610   decimalversion=9461968
    611   echo "Compiling with OpenSSL 0.9.6m."
    612  elif [ "$version" = "90700F" ]
    613  then
    614   decimalversion=9465871
    615   echo "Compiling with OpenSSL 0.9.7."
    616   opensslwarn 7
    617   DEF="$DEF -DUSE_AES"
    618  elif [ "$version" = "90701F" ]
    619  then
    620   decimalversion=9465887
    621   echo "Compiling with OpenSSL 0.9.7a."
    622   opensslwarn 7
    623   DEF="$DEF -DUSE_AES"
    624  elif [ "$version" = "90702F" ]
    625  then
    626   decimalversion=9465903
    627   echo "Compiling with OpenSSL 0.9.7b."
    628   opensslwarn 7
    629   DEF="$DEF -DUSE_AES"
    630  elif [ "$version" = "90703F" ]
    631  then
    632   decimalversion=9465919
    633   echo "Compiling with OpenSSL 0.9.7c."
    634   DEF="$DEF -DUSE_AES"
    635  elif [ "$version" = "90704F" ]
    636  then
    637   decimalversion=9465935
    638   echo "Compiling with OpenSSL 0.9.7d."
    639   DEF="$DEF -DUSE_AES"
    640  elif [ "$version" = "90705F" ]
    641  then
    642   decimalversion=9465951
    643   echo "Compiling with OpenSSL 0.9.7e."
    644   DEF="$DEF -DUSE_AES"
    645  elif [ "$version" = "90706F" ]
    646  then
    647   decimalversion=9465967
    648   echo "Compiling with OpenSSL 0.9.7f."
    649   DEF="$DEF -DUSE_AES"
    650  elif [ "$version" = "90707F" ]
    651  then
    652   decimalversion=9465983
    653   echo "Compiling with OpenSSL 0.9.7g."
    654   DEF="$DEF -DUSE_AES"
    655  elif [ "$version" = "90708F" ]
    656  then
    657   decimalversion=9465999
    658   echo "Compiling with OpenSSL 0.9.7h."
    659   DEF="$DEF -DUSE_AES"
    660  elif [ "$version" = "90709F" ]
    661  then
    662   decimalversion=9466015
    663   echo "Compiling with OpenSSL 0.9.7i."
    664   DEF="$DEF -DUSE_AES"
    665 
    666  elif [ "$version" = "9070AF" ]
    667  then
    668   decimalversion=9466031
    669   echo "Compiling with OpenSSL 0.9.7j."
    670   DEF="$DEF -DUSE_AES"
    671  elif [ "$version" = "9070BF" ]
    672  then
    673   decimalversion=9466047
    674   echo "Compiling with OpenSSL 0.9.7k."
    675   DEF="$DEF -DUSE_AES"
    676  elif [ "$version" = "9070CF" ]
    677  then
    678   decimalversion=9466063
    679   echo "Compiling with OpenSSL 0.9.7l."
    680   DEF="$DEF -DUSE_AES"
    681  elif [ "$version" = "9070DF" ]
    682  then
    683   decimalversion=9466079
    684   echo "Compiling with OpenSSL 0.9.7m."
    685   DEF="$DEF -DUSE_AES"
    686  elif [ "$version" = "9070EF" ]
    687  then
    688   decimalversion=9466095
    689   echo "Compiling with OpenSSL 0.9.7n."
    690   echo "This version was unreleased at the time of packaging."
    691   echo "It is not guaranteed to work. Please report any problems."
    692   DEF="$DEF -DUSE_AES"
    693  elif [ "$version" = "90800F" ]
    694  then
    695   decimalversion=9469967
    696   echo "Compiling with OpenSSL 0.9.8."
    697   DEF="$DEF -DUSE_AES"
    698  elif [ "$version" = "90801F" ]
    699  then
    700   decimalversion=9469983
    701   echo "Compiling with OpenSSL 0.9.8a."
    702   DEF="$DEF -DUSE_AES"
    703  elif [ "$version" = "90802F" ]
    704  then
    705   decimalversion=9469999
    706   echo "Compiling with OpenSSL 0.9.8b."
    707   DEF="$DEF -DUSE_AES"
    708  elif [ "$version" = "90803F" ]
    709  then
    710   decimalversion=9470015
    711   echo "Compiling with OpenSSL 0.9.8c."
    712   DEF="$DEF -DUSE_AES"
    713  elif [ "$version" = "90804F" ]
    714  then
    715   decimalversion=9470031
    716   echo "Compiling with OpenSSL 0.9.8d."
    717   DEF="$DEF -DUSE_AES"
    718  elif [ "$version" = "90805F" ]
    719  then
    720   decimalversion=9470047
    721   echo "Compiling with OpenSSL 0.9.8e."
    722   DEF="$DEF -DUSE_AES"
    723  elif [ "$version" = "90806F" ]
    724  then
    725   decimalversion=9470063
    726   echo "Compiling with OpenSSL 0.9.8f."
    727   DEF="$DEF -DUSE_AES"
    728  elif [ "$version" = "90807F" ]
    729  then
    730   decimalversion=9470079
    731   echo "Compiling with OpenSSL 0.9.8g."
    732   DEF="$DEF -DUSE_AES"
    733  elif [ "$version" = "90808F" ]
    734  then
    735   decimalversion=9470095
    736   echo "Compiling with OpenSSL 0.9.8h."
    737   DEF="$DEF -DUSE_AES"
    738  elif [ "$version" = "90809F" ]
    739  then
    740   decimalversion=9470111
    741   echo "Compiling with OpenSSL 0.9.8h."
    742   echo "This version was unreleased at the time of packaging."
    743   echo "It is not guaranteed to work. Please report any problems."
    744   DEF="$DEF -DUSE_AES"
    745  fi
    746 #
    747 # Now we try to guess about unknown versions: 
    748 #
    749  if [ "$decimalversion" = "" ]
    750  then
    751   decimalversion=`echo 16i $version p | dc`
    752  fi
    753  if [ "$decimalversion" = "" ]
    754  then
    755   echo "Warning: This version: ${version} of OpenSSL is not recognized."
    756   readln "Continue anyway?" y
    757   if [ "$ans" = "n" ]
    758   then
    759    echo $opensslinfo
    760    exit 1
    761   else
    762    echo "Does this version of OpenSSL contain AES support?"
    763    readln "If unsure of the answer, say \`n'" n
    764     if [ "$ans" = "y" ]
    765     then
    766     DEF="$DEF -DUSE_AES"
    767     fi
    768   fi
    769  elif [ "$decimalversion" -lt "2336" ]  # 920
    770  then
    771   echo "This version: ${version} of SSLeay is not supported."
    772   echo $opensslinfo
    773   exit 1
    774  elif [ "$decimalversion" -lt "9449728" ]  # 903100
    775  then
    776   echo "This version: ${version} of OpenSSL is not supported."
    777   echo $opensslinfo
    778   exit 1
    779  elif [ "$decimalversion" -gt "9470111" ]  # 0.9.8h
    780  then
    781   echo "Warning: This version: ${version} of OpenSSL is untested."
    782   readln "Continue anyway?" y
    783   if [ "$ans" = "n" ]
    784   then
    785    echo $opensslinfo
    786    exit 1
    787   else 
    788    echo "Does this version of OpenSSL contain AES support?"
    789    readln "If unsure of the answer, say \`n'" n
    790     if [ "$ans" = "y" ]
    791     then
    792     DEF="$DEF -DUSE_AES"
    793     fi
    794   fi
    795  fi
    796 
    797  LIBDIR=
    798  INCDIR=/usr/include/ncurses
    799  SRCDIR=ncurses*
    800  CONFIG=--enable-termcap
    801  if [ "$TERMINFO" != "" ]
    802  then
    803   CONFIG="--datadir=$TERMINFO"
    804  fi
    805  if [ -d /usr/share/terminfo ]
    806  then
    807   CONFIG=
    808  fi
    809  if [ -d /usr/lib/terminfo ]
    810  then
    811   CONFIG=--datadir=/usr/lib/terminfo
    812  fi
    813 
    814   if [ `uname` = OpenBSD ]
    815   then
    816    findlib libcurses.a
    817   else
    818    findlib libncurses.a
    819   fi
    820  if [ "$found" = "" ]
    821  then
    822   if [ "$system" != win32 ]
    823   then
    824    readln "Do you want to use Mixmaster's menu-based user interface?" y
    825    if [ "$ans" = "y" ]
    826    then
    827     echo "Please install ncurses now. It is available from http://www.clark.net/pub/dickey/ncurses/ncurses.tar.gz"
    828     exit 1
    829    fi
    830   fi
    831  else
    832   DEF="$DEF -DUSE_NCURSES"
    833   if [ "$type" = system -o "$type" = installed ]
    834   then
    835    LIBS="$LIBS $LIB"
    836    LDFLAGS="$LDFLAGS $LDFLAG"
    837   else
    838    LIBS="$LIBS $found/lib/$lib"
    839    NCURSES="$found/lib/$lib:
    840 	cd $found/ncurses; make ../lib/$lib"
    841   fi
    842   if [ "$INCDIR" != "" ]
    843   then
    844    INC="$INC -I$INCDIR"
    845   elif [ -f "/usr/include/ncurses.h" ]
    846   then
    847    DEF="$DEF -DHAVE_NCURSES_H"
    848   fi
    849  fi
    850 
    851  ideawarn()
    852  {
    853     echo "
    854   WARNING: Your version of OpenSSL has been configured without IDEA support.
    855   If you continue, Mixmaster will be installed with reduced functionality.
    856   This means (among other things) that Mixmaster will not create an RSA
    857   OpenPGP key (to avoid mail loss in the Type I system). You may want to
    858   re-install OpenSSL before proceeding.
    859 
    860   This will not concern you if you only plan to run a type II remailer or
    861   simply want a type II client."
    862     readln "Continue anyway?" y
    863     if [ "$ans" = "n" ]
    864     then
    865      exit 1
    866     fi
    867  }
    868 
    869  if [ "$system" = OpenBSD ]
    870  then
    871   LIBDIR=
    872   INCDIR=
    873   SRCDIR=idea*
    874   findlib libidea.a
    875   if [ "$found" = "" ]
    876   then
    877    ideawarn
    878   else
    879    DEF="$DEF -DUSE_IDEA"
    880    IDEALIB="$MAKELIB"
    881    LIBS="$LIBS $LIB"
    882    LDFLAGS="$LDFLAGS $LDFLAG"
    883    if [ "$INCDIR" != "" ]
    884    then
    885     INC="$INC -I$INCDIR"
    886    fi
    887   fi
    888  elif [ "$system" = msdos -o "$system" = win32 ]
    889  then
    890   DEF="$DEF -DUSE_IDEA"
    891  else
    892    echo "Checking for IDEA support..."
    893    cat <<END >tmptst.c
    894 #include <openssl/idea.h>
    895 int main() {
    896   void *dummy;
    897   dummy = idea_cfb64_encrypt;
    898   exit(0);
    899 }
    900 END
    901    if gcc $LDFLAGS $INC tmptst.c -o tmptst $OPENSSLLIB
    902    then
    903      DEF="$DEF -DUSE_IDEA"
    904    else
    905      ideawarn
    906    fi
    907    rm -f tmptst.c tmptst
    908  fi
    909 
    910  echo "testing for setenv()..."
    911  cat <<END >tmptst.c
    912 int main() {
    913 #include <stdlib.h>
    914  setenv("TZ", "GMT", 0);
    915  exit(0);
    916 }
    917 END
    918  if gcc tmptst.c -o tmptst
    919  then
    920    DEF="$DEF -DHAVE_SETENV"
    921  fi
    922  echo "done"
    923  rm -f tmptst.c tmptst
    924 
    925 # if [ "$MIXDEST" = "$HOME/Mix" ]
    926 # then
    927 #  SPOOL=
    928 # else
    929   SPOOL=-DSPOOL=\'\"$MIXDEST\"\'
    930 # fi
    931 
    932  echo "Generating Makefile."
    933  echo "#Makefile generated on $HOSTNAME `date`" >Makefile
    934  sed -e "s#%MIXDIR#$SPOOL#" \
    935      -e "s#%LIBS#$LIBS#" \
    936      -e "s#%LDFLAGS#$LDFLAGS#" \
    937      -e "s#%INC#$INC#" \
    938      -e "s#%DEF#$DEF#" < Makefile.in >> Makefile
    939 # echo "$ZLIB" >>Makefile
    940 # echo "$PCRE" >>Makefile
    941  echo "$IDEALIB" >>Makefile
    942  echo "$NCURSES" >>Makefile
    943  echo "$OPENSSL" >>Makefile
    944 fi
    945 
    946 
    947 
    948 
    949 
    950 echo "Compiling. Please wait."
    951 whereis make
    952 make=$found
    953 
    954 if [ "$system" = win32 ]
    955 then
    956 # (cd zlib*; make libz.a)
    957 # (cd pcre*; make libpcre.a)
    958  if [ "$PASS" != "" ]
    959  then
    960   $make "$PASS" dllmix
    961  else
    962   $make dllmix
    963  fi
    964 else
    965  if [ "$PASS" != "" ]
    966  then
    967   $make "$PASS"
    968  else
    969   $make
    970  fi
    971 fi
    972 
    973 if [ -x mixmaster ]
    974 then
    975  echo
    976 else
    977  echo "Error: The compilation failed. Please consult the documentation (section
    978 \`Installation problems')."
    979  readln "Remove the old Makefile?" y
    980  if [ "$ans" = y ]
    981  then
    982   rm -f Makefile
    983  fi
    984  exit 1
    985 fi
    986 
    987 if [ -f "$MIXDEST/mixmaster.conf" -a ! -f "$MIXDEST/mix.cfg" ]
    988 then
    989  export MIXDEST
    990  export MIXDIR
    991  export MIXSRC
    992  "${MIXDIR}/upgrade"
    993  exit 0
    994 fi
    995 
    996 if [ -f mixmaster.exe ]
    997 then
    998  cp mixmaster.exe "$MIXDEST"
    999 else
   1000  cp mixmaster "$MIXDEST"
   1001 fi
   1002 
   1003 cd "$MIXCFG"
   1004 for i in mlist.txt pubring.mix rlist.txt pubring.asc
   1005 do
   1006  if [ ! -f "$MIXDEST/$i" ]
   1007  then
   1008   cp "$i" "$MIXDEST"
   1009  fi
   1010 done
   1011 
   1012 if [ "$remailer" = "y" ]
   1013 then
   1014  cd "$MIXCFG"
   1015  for i in adminkey.txt dest.alw
   1016  do
   1017   if [ ! -f "$MIXDEST/$i" ]
   1018   then
   1019    cp "$i" "$MIXDEST"
   1020   fi
   1021  done
   1022 fi
   1023 
   1024 if [ "$remailer" = "n" ]
   1025 then
   1026  if [ ! -f "$MIXDEST/mix.cfg" ]
   1027  then
   1028   whereis sendmail /usr/lib/sendmail /usr/sbin/sendmail
   1029   echo "SENDMAIL	$found -t" >"$MIXDEST/mix.cfg"
   1030   cat mix.cfg >>"$MIXDEST/mix.cfg"
   1031  fi
   1032  echo "Client installation complete."
   1033  exit
   1034 fi
   1035 
   1036 for i in *.blk
   1037 do
   1038  if [ ! -f "$MIXDEST/$i" ]
   1039  then
   1040   cp "$i" "$MIXDEST"
   1041  fi
   1042 done
   1043 
   1044 cd "$MIXDEST"
   1045 
   1046 installed=n
   1047 if [ -f mix.cfg ]
   1048 then
   1049  if grep REMAILERADDR mix.cfg >/dev/null
   1050  then
   1051   installed=y
   1052  fi
   1053 fi
   1054 
   1055 if [ "$installed" = "n" ]
   1056 then
   1057  Date=`date`
   1058  whereis sendmail /usr/lib/sendmail /usr/sbin/sendmail
   1059  sendmail=$found
   1060 
   1061  echo "Mixmaster can be installed in the low-maintenance \`middleman' mode.
   1062 In that mode, it will send mail to other remailers only, to avoid
   1063 complaints about anonymous messages."
   1064  readln "Install as middleman?" n
   1065  middle=$ans
   1066 
   1067  readln "The e-mail address of your remailer:" `whoami`@$HOSTNAME
   1068  RMA=$ans
   1069 
   1070  echo "Do you want Mixmaster to send auto-replies to messages it does not
   1071 understand (If the address <$RMA> is also used"
   1072  readln "for mail to be read by a human, type \`n')?" y
   1073  autoreply=$ans
   1074 
   1075  if [ "$middle" = n ]
   1076  then
   1077   readln "An address to appear in the \`From:' line of anonymous messages:" `echo $RMA | sed 's/.*@/nobody@/'`
   1078   RAA=$ans
   1079 
   1080   readln "Address for complaints to be sent to:" `echo $RMA | sed 's/.*@/abuse@/'`
   1081   CA=$ans
   1082  else
   1083   RAA=$RMA
   1084   CA=$RMA
   1085  fi
   1086 
   1087  echo "Choose a name for your remailer.  It will appear in remailer status messages."
   1088  readln "Long name:" "Anonymous Remailer"
   1089  RMN=$ans
   1090 
   1091  if [ "$middle" = n ]
   1092  then
   1093   echo "Choose a name to be used in the \`From:' line of remailed messages."
   1094   readln "Anon long name:" "Anonymous"
   1095   RAN=$ans
   1096  fi
   1097 
   1098  readln "A short name to appear in lists:" `echo $HOSTNAME|sed 's/\..*//'`
   1099  SN=$ans
   1100 
   1101  readln "Accept Mixmaster (Type II) messages?" y
   1102  mix=$ans
   1103 
   1104  readln "Accept PGP (Type I) remailer messages?" n
   1105  pgp=$ans
   1106 
   1107  unencrypted=n
   1108  if [ "$pgp" = "y" ]
   1109  then
   1110   readln "Accept unencrypted remailer messages?" n
   1111   unencrypted=$ans
   1112  fi
   1113 
   1114  echo "Mixmaster will log error messages and warnings. Do you want to log"
   1115  readln "informational messages about normal operation as well?" y
   1116  if [ "$ans" = y ]
   1117  then
   1118   verbose=2
   1119  else
   1120   verbose=1
   1121  fi
   1122 
   1123  readln "Filter binary attachments?" n
   1124  binfilter=$ans
   1125 
   1126  if [ "$middle" = n ]
   1127  then
   1128   if [ "$autoreply" = y ]
   1129   then
   1130    readln "Allow users to add themselves to the list of blocked addresses?" y
   1131    autoblock=$ans
   1132   fi
   1133 
   1134   echo "Do you want to allow posting? Newsgroups can be restricted in dest.blk.
   1135 y)es, post locally; use m)ail-to-news gateway; n)o."
   1136   readln "Allow posting to Usenet?" m
   1137   post="$ans"
   1138   if [ "$ans" = y ]
   1139   then
   1140    whereis inews /usr/lib/news/inews
   1141    readln "News posting software:" "$found -h"
   1142    news=$ans
   1143    readln "Organization line for anonymous Usenet posts:" "Anonymous Posting Service"
   1144    orga=$ans
   1145    readln "Use anti-spam message IDs?" y
   1146    mid=$ans
   1147   elif [ "$ans" = m ]
   1148   then
   1149    readln "Mail-to-news gateway:" mail2news@nym.alias.net
   1150    news=$ans
   1151   fi
   1152  fi
   1153 
   1154 # Commented the poolsize question out, since poolsize is the least
   1155 # important of the three pool parameters.
   1156 #
   1157 # echo "How many messages do you want to keep in the reordering pool?
   1158 #A larger pool is more secure, but also causes higher latency.
   1159 #0 means to remail immediately."
   1160 # readln "Pool size:" 45
   1161 # poolsize=$ans
   1162 
   1163  mbox=
   1164  if [ -f ~/.forward ]
   1165  then
   1166   mbox=`head -1 ~/.forward | sed 's/^"//;s/"$//'`
   1167   if echo "$mbox" | grep 'mix' >/dev/null 2>/dev/null
   1168   then
   1169    mbox=
   1170   elif echo "$mbox" | grep 'procmail' >/dev/null 2>/dev/null
   1171   then
   1172    if grep mix ~/.procmailrc >/dev/null 2>/dev/null
   1173    then
   1174     mbox=
   1175    fi
   1176   fi
   1177  fi
   1178 
   1179  if [ "$mbox" = "" ]
   1180  then
   1181   mbox=${MAIL:-/usr/spool/mail/$NAME}
   1182   touch "$mbox"
   1183   if [ ! -w "$mbox" ]
   1184   then
   1185    echo "$mbox is not writeable."
   1186    readln "Mailbox for non-remailer messages:" "${MIXDEST}/mbox"
   1187    mbox=$ans
   1188   fi
   1189  fi
   1190 
   1191  cat <<END >mix.cfg
   1192 # mix.cfg -- installed $Date
   1193 SENDMAIL	$sendmail -t
   1194 
   1195 # Where to store non-remailer messages:
   1196 MAILBOX		$mbox
   1197 #MAILABUSE	mbox.abuse
   1198 #MAILBLOCK	mbox.block
   1199 #MAILUSAGE	mbox.usage
   1200 #MAILANON	mbox.anon
   1201 #MAILERROR	mbox.error
   1202 #MAILBOUNCE	mbox.bounce
   1203 
   1204 REMAIL		y
   1205 MIDDLEMAN	$middle
   1206 
   1207 BINFILTER	$binfilter
   1208 AUTOBLOCK	$autoblock
   1209 
   1210 ERRLOG          error.log
   1211 VERBOSE		$verbose
   1212 
   1213 # Remailer name and addresses
   1214 REMAILERADDR	$RMA
   1215 ANONADDR	$RAA
   1216 COMPLAINTS	$CA
   1217 
   1218 SHORTNAME	$SN
   1219 REMAILERNAME	$RMN
   1220 ANONNAME	$RAN
   1221 
   1222 # Supported formats:
   1223 MIX             $mix
   1224 PGP             $pgp
   1225 UNENCRYPTED     $unencrypted
   1226 
   1227 # Maximum message size in kB (0 for no limit):
   1228 SIZELIMIT       0
   1229 
   1230 # Usenet news:
   1231 NEWS		$news
   1232 ORGANIZATION	$orga
   1233 MID		$mid
   1234 
   1235 # Remailing strategy:
   1236 SENDPOOLTIME    15m
   1237 POOLSIZE        45
   1238 RATE            65
   1239 INDUMMYP        10
   1240 OUTDUMMYP       90
   1241 CHAIN           *,*,*,*
   1242 IDEXP           7d
   1243 PACKETEXP       7d
   1244 
   1245 $PASSPHRASE
   1246 
   1247 END
   1248 
   1249 fi # not yet installed
   1250 
   1251 
   1252 REPLACE="s/%RMN/$RMN/g;s/%RMA/$RMA/g;s/%CA/$CA/g;s/%RAA/$RAA/g"
   1253 if [ "$installed" = "n" ]
   1254 then
   1255  cd "$MIXCFG"
   1256  if [ ! -f "$MIXDEST/help.txt" ]
   1257  then
   1258   sed "$REPLACE" < intro.hlp >"$MIXDEST/help.txt"
   1259   if [ "$mix" = y ]
   1260   then
   1261    sed "$REPLACE" < mix.hlp >>"$MIXDEST/help.txt"
   1262   fi
   1263   if [ "$unencrypted" = y ]
   1264   then
   1265    sed "$REPLACE" < type1.hlp >>"$MIXDEST/help.txt"
   1266    if [ "$pgp" = y ]
   1267    then
   1268     sed "$REPLACE" < pgp.hlp >>"$MIXDEST/help.txt"
   1269    fi
   1270   elif [ "$pgp" = y ]
   1271   then
   1272    sed "$REPLACE" < pgponly.hlp >>"$MIXDEST/help.txt"
   1273   fi
   1274   if [ "$post" = y ]
   1275   then
   1276    if [ "$pgp" = y -o "$unencrypted" = y ]
   1277    then
   1278     sed "$REPLACE" < news.hlp >>"$MIXDEST/help.txt"
   1279    fi
   1280   fi
   1281   sed "$REPLACE" < end.hlp >>"$MIXDEST/help.txt"
   1282  fi
   1283 
   1284  for i in *.txt.in
   1285  do
   1286   j=`echo $i | sed 's/\.in$//'`
   1287   if [ ! -f "$MIXDEST/$j" ]
   1288   then
   1289     sed "$REPLACE" < "$i" >"$MIXDEST/$j"
   1290   fi
   1291  done
   1292  cd "$MIXDEST"
   1293 fi
   1294 
   1295 echo
   1296 if [ ! -f secring.mix ]
   1297 then
   1298  echo "Generating secret keys. This may take a while..."
   1299 else
   1300  echo "Updating secret keys..."
   1301 fi
   1302 ./mixmaster -K
   1303 if [ -f key.txt ]
   1304 then
   1305  echo "Done."
   1306  echo
   1307 else
   1308  echo "Installation failed. Please consult the Mixmaster documentation."
   1309  exit 1
   1310 fi
   1311 
   1312 if [ "$system" = msdos -o "$system" = win32 ]
   1313 then
   1314  exit
   1315 fi
   1316 
   1317 umask 033
   1318 
   1319 # Set .forward?
   1320 # 
   1321 set=y
   1322 # FIXME -- Mixmastger should run in daemon mode, not from procmail
   1323 # Make the Install script do that.
   1324 
   1325 if grep procmail ~/.forward >/dev/null 2>/dev/null
   1326 then
   1327  if grep mix ~/.procmailrc >/dev/null 2>/dev/null
   1328  then
   1329   echo "Mixmaster is installed in your .procmailrc file."
   1330   set=n
   1331  fi
   1332 fi
   1333 
   1334 if [ "$set" = y -a -f ~/.forward ]
   1335 then
   1336  echo "Your current .forward is:"
   1337  cat ~/.forward
   1338  echo
   1339  if grep mix ~/.forward >/dev/null 2>/dev/null
   1340  then
   1341   echo "Mixmaster already is installed in your .forward file."
   1342   set=n
   1343  elif [ "$mbox" != "" ]
   1344  then
   1345   if echo "$mbox" | grep '|' >/dev/null 2>/dev/null
   1346   then
   1347    echo "Mixmaster will pipe messages to $mbox"
   1348   elif echo $mbox | grep '@' >/dev/null 2>/dev/null
   1349   then
   1350    echo "Mixmaster will forward messages to $mbox"
   1351   else
   1352    echo "Mixmaster will store messages to $mbox"
   1353   fi
   1354  fi
   1355 fi
   1356 
   1357 if [ "$set" = y ]
   1358 then
   1359  echo "Set .forward to the following line:"
   1360  echo "\"|${MIXDEST}/mixmaster -RM\""
   1361  if [ -f ~/.forward ]
   1362  then
   1363   readln "Overwrite now?" n
   1364  else
   1365   readln "Do that now?" n
   1366  fi
   1367  if [ "$ans" = "y" ]
   1368  then
   1369   echo "\"|${MIXDEST}/mixmaster -RM\"" >~/.forward
   1370  fi
   1371 fi
   1372 
   1373 #FIXME -- we need a second script that can re-generate help files
   1374 # when the conf changes.
   1375 
   1376 if [ "$RMA" != "" ]
   1377 then
   1378  echo "
   1379 Mixmaster will send the following files as auto-replies:
   1380 Mail to <$RMA> with Subject: remailer-help => help.txt"
   1381  echo "Mail to <$RMA> with Subject: remailer-adminkey => adminkey.txt
   1382 Remember to add your Remailer Admin public PGP key to the adminkey.txt file."
   1383  if [ "$autoblock" = y ]
   1384  then
   1385   echo "Mail to <$RMA> with line DESTINATION-BLOCK => blocked.txt"
   1386  fi
   1387  if [ "$autoreply" = y ]
   1388  then
   1389   echo "Other mail to <$RMA> => usage.txt"
   1390   echo
   1391   if [ "$CA" != "$RMA" ]
   1392   then
   1393    echo "If you arrange for mail to <$CA> and <$RAA>
   1394 to be forwarded to <$RMA>:
   1395 Mail to <$CA> => abuse.txt
   1396 Mail to <$RAA> => reply.txt"
   1397   fi
   1398  fi
   1399 fi
   1400 
   1401 echo
   1402 echo "Mixmaster installation complete."
   1403