diff --git a/doc/guide.html b/doc/guide.html index 8f1a32473..903ac33f0 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -348,7 +348,7 @@ GNU Make
  • Erlang mysql library. Optional. For MySQL authentication or storage. See section 3.2.1.
  • Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section 3.2.3.
  • PAM library. Optional. For Pluggable Authentication Modules (PAM). See section 3.1.4. -
  • ImageMagick’s Convert program, and Bash. Optional. For CAPTCHA challenges. See section 3.1.8. +
  • ImageMagick’s Convert program. Optional. For CAPTCHA challenges. See section 3.1.8.
  • 2.4.2  Download Source Code

    Released versions of ejabberd are available in the ProcessOne ejabberd downloads page: @@ -1233,7 +1233,7 @@ In order to take effect there must be a translation file

    3.1.8  CAPTCHA

    Some ejabberd modules can be configured to require a CAPTCHA challenge on certain actions. If the client does not support CAPTCHA Forms (XEP-0158), -a web link is provided so the user can fill the challenge in a web browser.

    An example Bash script is provided that generates the image +a web link is provided so the user can fill the challenge in a web browser.

    An example script is provided that generates the image using ImageMagick’s Convert program.

    The configurable options are:

    {captcha_cmd, Path}
    diff --git a/doc/guide.tex b/doc/guide.tex index 95fc54fe1..45aa7414c 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -312,7 +312,7 @@ To compile \ejabberd{} on a `Unix-like' operating system, you need: \item Erlang mysql library. Optional. For MySQL authentication or storage. See section \ref{compilemysql}. \item Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section \ref{compilepgsql}. \item PAM library. Optional. For Pluggable Authentication Modules (PAM). See section \ref{pam}. -\item ImageMagick's Convert program, and Bash. Optional. For CAPTCHA challenges. See section \ref{captcha}. +\item ImageMagick's Convert program. Optional. For CAPTCHA challenges. See section \ref{captcha}. \end{itemize} \makesubsection{download}{Download Source Code} @@ -1531,7 +1531,7 @@ Some \ejabberd{} modules can be configured to require a CAPTCHA challenge on cer If the client does not support CAPTCHA Forms (\xepref{0158}), a web link is provided so the user can fill the challenge in a web browser. -An example Bash script is provided that generates the image +An example script is provided that generates the image using ImageMagick's Convert program. The configurable options are: diff --git a/tools/captcha.sh b/tools/captcha.sh index d68edfa03..560a048ad 100644 --- a/tools/captcha.sh +++ b/tools/captcha.sh @@ -1,35 +1,70 @@ -#!/bin/bash +#!/bin/sh INPUT=$1 -WAVE1_AMPLITUDE=$((2 + $RANDOM % 5)) -WAVE1_LENGTH=$((50 + $RANDOM % 25)) -WAVE2_AMPLITUDE=$((2 + $RANDOM % 5)) -WAVE2_LENGTH=$((50 + $RANDOM % 25)) -WAVE3_AMPLITUDE=$((2 + $RANDOM % 5)) -WAVE3_LENGTH=$((50 + $RANDOM % 25)) -W1_LINE_START_Y=$((10 + $RANDOM % 40)) -W1_LINE_STOP_Y=$((10 + $RANDOM % 40)) -W2_LINE_START_Y=$((10 + $RANDOM % 40)) -W2_LINE_STOP_Y=$((10 + $RANDOM % 40)) -W3_LINE_START_Y=$((10 + $RANDOM % 40)) -W3_LINE_STOP_Y=$((10 + $RANDOM % 40)) +if test -n ${BASH_VERSION:-''} ; then + get_random () + { + R=$RANDOM + } +else + for n in `od -A n -t u2 -N 48 /dev/urandom`; do RL="$RL$n "; done + get_random () + { + R=${RL%% *} + RL=${RL#* } + } +fi -B1_LINE_START_Y=$(($RANDOM % 40)) -B1_LINE_STOP_Y=$(($RANDOM % 40)) -B2_LINE_START_Y=$(($RANDOM % 40)) -B2_LINE_STOP_Y=$(($RANDOM % 40)) -#B3_LINE_START_Y=$(($RANDOM % 40)) -#B3_LINE_STOP_Y=$(($RANDOM % 40)) +get_random +WAVE1_AMPLITUDE=$((2 + $R % 5)) +get_random +WAVE1_LENGTH=$((50 + $R % 25)) +get_random +WAVE2_AMPLITUDE=$((2 + $R % 5)) +get_random +WAVE2_LENGTH=$((50 + $R % 25)) +get_random +WAVE3_AMPLITUDE=$((2 + $R % 5)) +get_random +WAVE3_LENGTH=$((50 + $R % 25)) +get_random +W1_LINE_START_Y=$((10 + $R % 40)) +get_random +W1_LINE_STOP_Y=$((10 + $R % 40)) +get_random +W2_LINE_START_Y=$((10 + $R % 40)) +get_random +W2_LINE_STOP_Y=$((10 + $R % 40)) +get_random +W3_LINE_START_Y=$((10 + $R % 40)) +get_random +W3_LINE_STOP_Y=$((10 + $R % 40)) -B1_LINE_START_X=$(($RANDOM % 20)) -B1_LINE_STOP_X=$((100 + $RANDOM % 40)) -B2_LINE_START_X=$(($RANDOM % 20)) -B2_LINE_STOP_X=$((100 + $RANDOM % 40)) -#B3_LINE_START_X=$(($RANDOM % 20)) -#B3_LINE_STOP_X=$((100 + $RANDOM % 40)) +get_random +B1_LINE_START_Y=$(($R % 40)) +get_random +B1_LINE_STOP_Y=$(($R % 40)) +get_random +B2_LINE_START_Y=$(($R % 40)) +get_random +B2_LINE_STOP_Y=$(($R % 40)) +#B3_LINE_START_Y=$(($R % 40)) +#B3_LINE_STOP_Y=$(($R % 40)) -ROLL_X=$(($RANDOM % 40)) +get_random +B1_LINE_START_X=$(($R % 20)) +get_random +B1_LINE_STOP_X=$((100 + $R % 40)) +get_random +B2_LINE_START_X=$(($R % 20)) +get_random +B2_LINE_STOP_X=$((100 + $R % 40)) +#B3_LINE_START_X=$(($R % 20)) +#B3_LINE_STOP_X=$((100 + $R % 40)) + +get_random +ROLL_X=$(($R % 40)) convert -size 180x60 xc:none -pointsize 40 \ \( -clone 0 -fill white \