From f800860a9e27901caee624dd9c4c1e2c4cb3f23a Mon Sep 17 00:00:00 2001 From: Moleflap hackers Date: Wed, 28 Apr 2010 02:10:01 +0200 Subject: [PATCH] fixes fix opendoor syntax made magic_run portable, but is now linux specific :-( mix add_token --- door/magic_run | 5 +++-- door/token.lua | 3 +++ www/opendoor | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/door/magic_run b/door/magic_run index 4342e9f..96c4fbe 100755 --- a/door/magic_run +++ b/door/magic_run @@ -1,6 +1,7 @@ -#!/bin/sh +#!/bin/bash f=`basename $0` -cd /home/cricket/door/ +MAGIC=`readlink /proc/$$/fd/255` +cd `dirname $MAGIC` lua $f.lua diff --git a/door/token.lua b/door/token.lua index 0a22dff..bfb9106 100644 --- a/door/token.lua +++ b/door/token.lua @@ -28,6 +28,9 @@ function add_token(con, token, gpg_id) -- add token to the database local prefix = token:sub(1, config.prefix_len) if not gpg_id then gpg_id = con:execute("select trim(gpg_id) from tokens where prefix='"..prefix.."';"):fetch() + if not gpg_id then + gpg_id = "" + end end local ttl = now + config.ttl + math.floor(math.random() * config.ruttl) diff --git a/www/opendoor b/www/opendoor index 70d2380..9b89ef6 100644 --- a/www/opendoor +++ b/www/opendoor @@ -7,7 +7,7 @@ WLAN_NAME="<<>" PREFIX_LEN=4 # END CONFIG -PORT=8888 +PORT=80 STORE_ENC="$STORE.enc" STORE_TMP="$STORE.tmp" @@ -69,8 +69,13 @@ do_pgp() { if [ $? != 0 ]; then return 2 fi - CSUM=`head -n 1 $STORE_ENC` - OSUM=`cat $STORE | cut -c1-${#CSUM}` + if [ -e $STORE ]; then + CSUM=`head -n 1 $STORE_ENC` + OSUM=`cat $STORE | cut -c1-${#CSUM}` + else + CSUM="1" + OSUM="2" + fi if [ "x$CSUM" != "x$OSUM" ] || [ $FORCE_PGP != 0 ]; then rm -f $STORE_TMP tail -n +3 $STORE_ENC | gpg --decrypt --output $STORE_TMP @@ -126,7 +131,7 @@ fi do_pgp -if [[ $? -gt 2 ]]; then +if [ $? -gt 2 ]; then echo "fatal error" exit fi