/usr/lib/news/bin/parsecontrol is in inn 1:1.7.2q-44+b2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | #! /bin/sh
## $Revision: 1.15 $
## Initial parsing of control messages.
## =()<. @<_PATH_SHELLVARS>@>()=
. /usr/lib/news/innshellvars
WRITELOG=${NEWSBIN}/writelog
PGPVERIFY=false
if [ "X$WANT_PGPVERIFY" = XDO ]; then
PGPVERIFY=true
fi
MAILFAILURES=false
if [ "X$MAIL_BADCONTROLS" = XDO ]; then
MAILFAILURES=true
fi
AZ=ABCDEFGHIJKLMNOPQRSTUVWXYZ
az=abcdefghijklmnopqrstuvwxyz
ZN=0123456789
# Attempt to sanitize the address
FROM="`echo \"$1\" | tr ${AZ} ${az} | tr -dc \\\055${az}${ZN}+_.@%`"
REPLYTO="`echo \"$2\" | tr ${AZ} ${az} | tr -dc \\\055${az}${ZN}+_.@%`"
case "$3" in
"")
ARTICLE=/dev/null
;;
/*)
ARTICLE="$3"
;;
*)
ARTICLE="${SPOOL}/$3"
;;
esac
PATHHOST="$4"
# Catch an address left with a leading '-'
case "X$FROM" in
X-*)
if $MAILFAILURES; then
${SED} -e 's/^~/~~/' < ${ARTICLE} \
| ${MAILCMD} -s "Bad FROM address" ${NEWSMASTER}
fi
cat ${ARTICLE} |
writelog $MOST_LOGS/badcontrol.log "`date` Bad FROM address"
exit
;;
esac
case "X$REPLYTO" in
X-*)
if $MAILFAILURES; then
${SED} -e 's/^~/~~/' < ${ARTICLE} \
| ${MAILCMD} -s "Bad REPLY-TO address" ${NEWSMASTER}
fi
cat ${ARTICLE} |
writelog $MOST_LOGS/badcontrol.log "`date` Bad REPLY-TO address"
exit
;;
esac
umask 002
TEMP=${TMPDIR}/ctl$$
## Avoid egrep bugs with empty or-patterns.
test -z "${PROG}" && PROG=all
${EGREP} "^(${PROG}|all):" <${CTLFILE} >${TEMP}
## Get any arguments.
if grep "^Control:[ ]*${PROG}" <${ARTICLE} >/dev/null 2>&1 ; then
set X `${SED} -n -e "s/^Control:[ ]*${PROG}//p" -e '/^$/q' <${ARTICLE}`
shift
else
if grep "^Subject:[ ]*cmsg[ ]*${PROG}" \
<${ARTICLE} >/dev/null 2>&1 ; then
set X `${SED} -n -e "s/^Subject:[ ]*cmsg[ ]*${PROG}//p" \
-e '/^$/q' <${ARTICLE}`
shift
else
rm -f ${TEMP}
if $MAILFAILURES; then
${SED} -e 's/^~/~~/' < ${ARTICLE} \
| ${MAILCMD} -s "Bad header by ${FROM}" ${NEWSMASTER}
fi
cat ${ARTICLE} |
writelog $MOST_LOGS/badcontrol.log "`date` Bad header by ${FROM}"
exit
fi
fi
# Check characters in values of variables that will be inside an eval
TRANS1="`echo \"$1\" | tr ${AZ} ${az} | tr -dc \\\055${az}${ZN}+_.`"
if [ ${1}X != ${TRANS1}X ]; then
rm -f ${TEMP}
if $MAILFAILURES; then
${SED} -e 's/^~/~~/' < ${ARTICLE} \
| ${MAILCMD} -s "Malformed newsgroup name by ${FROM}" ${NEWSMASTER}
fi
cat ${ARTICLE} |
writelog $MOST_LOGS/badcontrol.log \
"`date` Malformed newsgroup name by ${FROM}"
exit
fi
TRANSP="`echo \"$PROG\" | tr ${AZ} ${az} | tr -dc \\\055${az}${ZN}+_.`"
if [ ${PROG}X != ${TRANSP}X ]; then
rm -f ${TEMP}
if $MAILFAILURES; then
${SED} -e 's/^~/~~/' < ${ARTICLE} \
| ${MAILCMD} -s "Unexpected program name by ${FROM}" ${NEWSMASTER}
fi
cat ${ARTICLE} |
writelog $MOST_LOGS/badcontrol.log \
"`date` Unexpected program name by ${FROM}"
exit
fi
ACTION=mail
IFS=:
exec <${TEMP}
while read MESSAGE FROM_PAT NG_PAT ACT_PAT ; do
eval "case \"${FROM}\" in
${FROM_PAT})
## Got a match -- if newgroup/rmgroup, must also
## match the newsgroup pattern.
case \"${PROG}\" in
newgroup|rmgroup)
case \"$1\" in
${NG_PAT})
ACTION=${ACT_PAT}
;;
esac
;;
*)
ACTION=${ACT_PAT}
;;
esac
;;
esac"
done
rm -f ${TEMP}
IFS="`echo stn | tr stn ' \011\012'`"
LOGFILE=mail
case ${ACTION} in
drop)
exit
;;
log)
echo "`date` Ignored ${PROG} ${ARTICLE} by ${FROM} (${PATHHOST})" 1>&2
exit
;;
log=*)
LOGFILE=`expr "${ACTION}" : 'log=[ ]*\(.*\)'`
ACTION=logit
;;
doit=*)
LOGFILE=`expr "${ACTION}" : 'doit=[ ]*\(.*\)'`
ACTION=doit
;;
verify-*=*)
LOGFILE=`expr "${ACTION}" : 'verify-.*=[ ]*\(.*\)'`
PGPAUTH=`expr "${ACTION}" : 'verify-\([^=]*\)'`
ACTION=verify
;;
verify-*)
PGPAUTH=`expr "${ACTION}" : 'verify-\([^=]*\)'`
ACTION=verify
;;
esac
if $PGPVERIFY; then
PGPSENDER=`pgpverify < ${ARTICLE}`;
PGP_STATUS=$?
case "${ACTION}:${PGP_STATUS}" in
verify:0)
case "${PGPAUTH}" in
"")
ACTION=mail
LOGFILE=mail
;;
${PGPSENDER})
ACTION=doit
;;
*)
ACTION=mail
LOGFILE=mail
;;
esac
;;
# code 255 is failure to run pgp.
verify:255)
ACTION=logit
LOGFILE=failedpgp
;;
# pgp ran, but failed to verify message.
verify:*)
ACTION=logit
LOGFILE=badpgp
;;
esac
fi
case "${LOGFILE}" in
"")
LOGFILE=/dev/null
;;
mail|/*)
;;
*)
LOGFILE=${MOST_LOGS}/${LOGFILE}.log
;;
esac
export LOGFILE
|