canlock-hp

Parsers for RFC 5536 message headers and RFC 8315 Cancel-Lock and Cancel-Key header fields.







News




General

The canlock-hp package contains standalone header parsers that can be used to implement RFC 8315 Netnews Cancel-Locks on the receiving (server) side.
They are intended as preprocessors for canlock, the command line frontend of libcanlock, but are independent programs.

canlock-mhp (Message Header Parser) is intended to process RFC 5536 Netnews articles and can be used to extract and unfold a single header field.

canlock-hfp (Header Field Parser) is intended to process RFC 8315 header fields (Cancel-Lock and Cancel-Key).

See README for details.




Example

Check incoming Cancel or Supersede

This script "check.sh" for POSIX operating systems expects the pathname of the article with the Keys ("Cancel-Key" header field) as the first option.
The second option must be the pathname of the article with the Locks ("Cancel-Lock" header field).
Both articles must be in canonical format (with CRLF line breaks).

#! /bin/sh

# Check options
if test $# -ne 2
then
   printf "%s\n%s\n" "Usage example: check.sh supersede.txt target.txt" \
          "(Both articles must be in canonical format)"
   exit 1
fi

# Extract Keys and Locks using canlock-hp
set -e
C_KEYS=$(<$1 canlock-mhp -f "Cancel-Key" | canlock-hfp 2>/dev/null)
printf "Keys : %s\n" "$C_KEYS" 1>&2
C_LOCKS=$(<$2 canlock-mhp -f "Cancel-Lock" | canlock-hfp 2>/dev/null)
printf "Locks: %s\n" "$C_LOCKS" 1>&2

# Check Keys against Locks using (lib)canlock
set +e
for k in $C_KEYS
do
   for l in $C_LOCKS
   do
      canlock -c "$k","$l" >/dev/null 2>&1
      RES=$?
      printf "\n%s\n" "Check Key \"$k\" against Lock \"$l\"" 1>&2
      if test $RES -eq 0
      then
         printf "%s\n" "=> Good" 1>&2
         break
      else
         printf "%s\n" "=> Mismatch" 1>&2
      fi
   done
   # On success abort outer loop too
   if test $RES -eq 0
   then
      break
   fi
done

# Check for error
if test $RES -ne 0
then
   exit 1
fi

# EOF



Dependencies




Documentation




Browser        Last update: 2018-06-02        michael.baeuerle@gmx.net