diff --git a/build-deb/Makefile b/build-deb/Makefile index 576a320..0a5614c 100644 --- a/build-deb/Makefile +++ b/build-deb/Makefile @@ -8,6 +8,8 @@ deb: man ../requirments.txt ../run.py ../luser ../LICENSE cp -r ../luser/* luser/var/luser/luser/ cp ../run.py luser/var/luser/ cp ../LICENSE luser/var/luser/ + chmod -w luser/DEBIAN/* + chmod +w luser/DEBIAN/control dpkg-deb --build luser clean: rm -f luser.deb diff --git a/build-deb/luser/DEBIAN/control b/build-deb/luser/DEBIAN/control index 403e66d..4772ada 100644 --- a/build-deb/luser/DEBIAN/control +++ b/build-deb/luser/DEBIAN/control @@ -4,8 +4,8 @@ Priority: optional Architecture: all Essential: no Installed-Size: 2000 -Depends: python3-flask, python3-ldap3, gunicorn +Depends: python3-flask, python3-ldap3, gunicorn, imagemagick, python3-passlib Homepage: https://gitea.dmz.rs/fram3d/luser Maintainer: fram3d Description: Web app that allows users to add,remove and change passwords in LDAP system -Version: 1.0.2 +Version: 1.0.4 diff --git a/build-deb/luser/DEBIAN/postinst b/build-deb/luser/DEBIAN/postinst index 573bb70..7cfb3f5 100755 --- a/build-deb/luser/DEBIAN/postinst +++ b/build-deb/luser/DEBIAN/postinst @@ -1,5 +1,7 @@ -#!/bin/sh +#!/bin/bash /usr/bin/systemctl enable luser.service /sbin/service luser start -cp /tmp/oldluserconfig.ini /var/luser/luser/config.ini -rm /tmp/oldluserconfig.ini +if [ -f /tmp/oldluserconfig.ini ] ; then + cp /tmp/oldluserconfig.ini /var/luser/luser/config.ini + rm /tmp/oldluserconfig.ini +fi diff --git a/build-deb/luser/DEBIAN/preinst b/build-deb/luser/DEBIAN/preinst index 8f060aa..b7976a0 100755 --- a/build-deb/luser/DEBIAN/preinst +++ b/build-deb/luser/DEBIAN/preinst @@ -1,2 +1,4 @@ -#!/bin/sh -cp /var/luser/luser/config.ini /tmp/oldluserconfig.ini +#!/bin/bash +if [ -f /var/luser/luser/config.ini ] ; then + cp /var/luser/luser/config.ini /tmp/oldluserconfig.ini +fi diff --git a/build-deb/luser/DEBIAN/prerm b/build-deb/luser/DEBIAN/prerm index 1044fe7..ffac95f 100755 --- a/build-deb/luser/DEBIAN/prerm +++ b/build-deb/luser/DEBIAN/prerm @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash /sbin/service luser stop /usr/bin/systemdctl disable luser.service -cp /var/luser/luser/config.ini /tmp/oldluserconfig.ini +if [ -f /var/luser/luser/config.ini ] ; then + cp /var/luser/luser/config.ini /tmp/oldluserconfig.ini +fi diff --git a/build-deb/luser/lib/systemd/system/luser.service b/build-deb/luser/lib/systemd/system/luser.service index 3505f83..561a682 100644 --- a/build-deb/luser/lib/systemd/system/luser.service +++ b/build-deb/luser/lib/systemd/system/luser.service @@ -5,7 +5,7 @@ After=network.target nss-lookup.target [Service] WorkingDirectory=/var/luser/ -ExecStart=/usr/bin/gunicorn --workers 3 --bind 127.0.0.1:5000 run:app +ExecStart=/usr/bin/gunicorn --workers 3 --bind 0.0.0.0:80 run:app [Install] WantedBy=multi-user.target diff --git a/build-deb/luser/usr/local/bin/captcha.sh b/build-deb/luser/usr/local/bin/captcha.sh new file mode 100755 index 0000000..9fa4a52 --- /dev/null +++ b/build-deb/luser/usr/local/bin/captcha.sh @@ -0,0 +1,100 @@ +#!/bin/sh + +# This script is an example captcha script. +# It takes the text to recognize in the captcha image as a parameter. +# It return the image binary as a result. ejabberd support PNG, JPEG and GIF. + +# The whole idea of the captcha script is to let server admins adapt it to +# their own needs. The goal is to be able to make the captcha generation as +# unique as possible, to make the captcha challenge difficult to bypass by +# a bot. +# Server admins are thus supposed to write and use their own captcha generators. + +# This script relies on ImageMagick. +# It is NOT compliant with ImageMagick forks like GraphicsMagick. + +INPUT=$1 + +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 + +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)) + +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)) + +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 \ + -stroke black -strokewidth 4 -annotate +0+40 "$INPUT" \ + -stroke white -strokewidth 2 -annotate +0+40 "$INPUT" \ + -roll +$ROLL_X+0 \ + -wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \ + -roll -$ROLL_X+0 \) \ + \( -clone 0 -stroke black \ + -strokewidth 1 -draw \ + "line $B1_LINE_START_X,$B1_LINE_START_Y $B1_LINE_STOP_X,$B1_LINE_STOP_Y" \ + -strokewidth 1 -draw \ + "line $B2_LINE_START_X,$B2_LINE_START_Y $B2_LINE_STOP_X,$B2_LINE_STOP_Y" \ + -wave "$WAVE2_AMPLITUDE"x"$WAVE2_LENGTH" \) \ + \( -clone 0 -stroke white \ + -strokewidth 2 -draw "line 0,$W1_LINE_START_Y 140,$W1_LINE_STOP_Y" \ + -strokewidth 2 -draw "line 0,$W2_LINE_START_Y 140,$W2_LINE_STOP_Y" \ + -strokewidth 2 -draw "line 0,$W3_LINE_START_Y 140,$W3_LINE_STOP_Y" \ + -wave "$WAVE3_AMPLITUDE"x"$WAVE3_LENGTH" \) \ + -flatten -crop 140x60 +repage -quality 90 -depth 8 png:- diff --git a/luser/config.ini b/luser/config.ini index 1084b0d..0afa144 100644 --- a/luser/config.ini +++ b/luser/config.ini @@ -3,6 +3,6 @@ LDAPHOST = ldap.example.org LDAPADMINNAME = cn=admin,dc=example,dc=org LDAPPASS = verysecr3t USERBASE = ou=Users,dc=example,dc=org -CAPTCHA_PATH = /var/luser/luser/static/account/register/captcha_img/ +CAPTCHA_PATH = /var/luser/luser/static/register/captcha_img/ ALTUSERBASE = # ALTUSERBASE = ou=UsersAlt,dc=example,dc=org