3 [ -n "$include_session" ] && return 0
7 IDFILE="${IDFILE:-${_DATA:-.}/serverkey}"
8 if ! grep -m1 -xE '.{512}' "$IDFILE"; then
9 dd count=1 bs=512 if=/dev/urandom \
15 # 6-Bit Code that retains sort order of input data, while beeing safe to use
16 # in ascii transmissions, unix file names, HTTP URLs, and HTML attributes
20 y;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;0123456789:=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;
25 dd bs=12 count=1 if=/dev/urandom \
30 d=$(($(date +%s) % 4294967296))
33 $((d / 16777216 % 256)) \
34 $((d / 65536 % 256)) \
38 dd bs=8 count=1 if=/dev/urandom
42 checkid(){ grep -m 1 -xE '[0-9a-zA-Z:_]{16}'; }
45 local session sid time sig serverkey checksig
47 IFS=- read -r sid time sig <<-END
50 serverkey="$(server_key)"
52 checksig="$(printf %s "$sid" "$time" "$serverkey" | sha256sum)"
53 checksig="${checksig%% *}"
56 if [ "$checksig" != "$sig" -o "$time" -lt "$d" ] 2>&-; then
60 time=$(( $(date +%s) + 7200 ))
61 sig="$(printf %s "$sid" "$time" "$serverkey" |sha256sum)"
63 printf %s\\n "${sid}-${time}-${sig}"
66 SESSION_ID="$(update_session)"
67 SET_COOKIE 0 "session=$SESSION_ID" HttpOnly
68 SESSION_ID="${SESSION_ID%%-*}"