#!/bin/sh # Id$: batch/submaps-decode 1.78 10.10.2001 # # (c) 1994-2001, Dirk Meyer, Im Grund 4, 34317 Habichtswald # # decode signed messages and extract the content into # a data directory, which can be used by routing. # # security note: # absolute pathnames in the message are not checked # risk: people you have in your key ring # may touch files as user news # # no world writable directory dir="/var/lib/news/maps" log="/var/lib/news/maps.log" tmp1="${dir}/.tmp.1.$$" tmp2="${dir}/.tmp.2.$$" sep="----------------------------------------------------" # save message cat > "${tmp1}" # check for valid signature /usr/local/bin/pmcheck < "${tmp1}" >> "${log}" 2>&1 case $? in 0) if test "$1" = "-v" then echo "Good Signature" >> "${log}" cat "${tmp1}" >> "${log}" echo "${sep}" >> "${log}" fi # cut valid header sed -e '1,/This is a shell archive./d' "${tmp1}" >"${tmp2}" # if pattern does not exists, result is empty if test -s "${tmp2}" then # extract content in dir ( cd ${dir} && sh "${tmp2}" ) >> "${log}" 2>&1 else echo "No valid content found" >> "${log}" cat "${tmp1}" >> "${log}" echo "${sep}" >> "${log}" fi # cleanup rm -f "${tmp1}" "${tmp2}" exit 0 ;; 1) echo "No Signature" >> "${log}" ;; 2) echo "Bad Signature" >> "${log}" ;; *) echo "Unknown Error" >> "${log}" ;; esac cat "${tmp1}" >> "${log}" echo "${sep}" >> "${log}" rm -f "${tmp1}" exit 0 # # eof