X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=clickslide%2Fcgilite%2Fsession.sh;h=8ed8d8808e0655cc8b89c6ce7bb0df318b0b571f;hb=36762a2fc213c874392965346db3ea34571d9b07;hp=25a65987c3671df4f4c8499279a71487edad5775;hpb=a659176f8a57114eac7a68ef0d8586b92bde442c;p=vhs_kurs diff --git a/clickslide/cgilite/session.sh b/clickslide/cgilite/session.sh index 25a6598..8ed8d88 100755 --- a/clickslide/cgilite/session.sh +++ b/clickslide/cgilite/session.sh @@ -41,6 +41,15 @@ timeid(){ checkid(){ grep -m 1 -xE '[0-9a-zA-Z:=]{16}'; } +transid(){ + # transaction ID to modify a given file + local file="$1" + { stat -c %F%i%n%N%s%Y "$file" 2>&- + printf %s "$SESSION_ID" + server_key + } | sha256sum | cut -d\ -f1 +} + update_session(){ local session sid time sig serverkey checksig @@ -53,9 +62,9 @@ update_session(){ checksig="${checksig%% *}" d=$(date +%s) - if [ "$checksig" != "$sig" \ - -o "$time" -lt "$d" \ - -o ! "$(printf %s "$sid" |checkid)" ] 2>&- + if ! [ "$checksig" = "$sig" \ + -a "$time" -ge "$d" \ + -a "$(printf %s "$sid" |checkid)" ] 2>&- then debug Setting up new session sid="$(randomid)"