/usr/lib/news/control/newgroup is in inn 1:1.7.2q-45build2.
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 | #! /bin/bash
## $Revision: 1.23 $
## Newgroup control-message handler
PROG=newgroup
## Some shells don't pass in $* unless we explicitly pass it in here.
## =()<. @<_PATH_PARSECTL>@ "$@">()=
. /usr/lib/news/bin/parsecontrol "$@"
## Valid parameters and group name?
case "$#" in
1|2)
;;
*)
${WRITELOG} ${LOGFILE} "Unparseable newgroup by ${FROM}" <${ARTICLE}
exit
;;
esac
case "$1" in
*[\ \ /:]*)
${WRITELOG} ${LOGFILE} "Unsafe newgroup by ${FROM}" <${ARTICLE}
exit
;;
esac
#### Simple check for a bork-style group. Uncomment to stop newgroups
#### with names deeper than 7 levels being created.
#ELEMS=`echo "$1" | awk -F. '{print NF}'`
#if [ $ELEMS -gt 7 ]; then
# ${WRITELOG} ${LOGFILE} "Too many elements in newsgroup name by ${FROM}" <${ARTICLE}
# exit
#fi
## Make sure article is approved.
${SED} -e '/^$/q' <${ARTICLE} >${TEMP}
grep '^Approved:' <${TEMP} >/dev/null 2>&1 || {
rm -f ${TEMP}
${WRITELOG} ${LOGFILE} "Unapproved newgroup by ${FROM}" <${ARTICLE}
exit
}
rm -f ${TEMP}
case "$2" in
[Mm]*)
set $1 m
;;
*)
set $1 y
;;
esac
## Kill the chefs; from <wesommer@athena.mit.edu>.
## That is, turn "alt.foo.bar.bar.bar" into an "x" group.
#case `echo $1 | ${AWK} -F. '{
# if (NF > 1 && $NF != "misc") {
# if (NF > 5 || $NF == $(NF - 1) || $(NF - 1) == $(NF - 2)) {
# print "bozo";
# }
# }
# }'` in
#bozo*)
# set $1 x
# ;;
#esac
## Compare group against active file.
SUFFIX=""
LINE=`grep "^$1 " <${ACTIVE} 2>/dev/null`
case "${LINE}" in
"")
## New group.
WORD=created
;;
"$1 "*" $2")
## Exact match; ignore it.
exit
;;
"$1 "*" ="*|"$1 "*" x"|"$1 "*" j")
${WRITELOG} ${LOGFILE} "Rejected special newsgroup ($1) by ${FROM}" \
<${ARTICLE}
exit
;;
*)
case "$2" in
m)
WORD="made moderated"
SUFFIX=" (Moderated)"
;;
y)
WORD="made unmoderated"
;;
esac
;;
esac
case ${ACTION} in
mail)
P1=$1
P2=$2
export FROM WORD NEWSBIN P1 P2 ARTICLE
(
echo "${FROM} requested that $1 be ${WORD}."
echo 'To do this, type the following:'
echo " ${NEWSBIN}/ctlinnd newgroup ${P1} ${P2} ${FROM}"
echo ''
echo 'The original article was:'
cat ${ARTICLE}
) | ${WRITELOG} ${LOGFILE} "newgroup $1 $2 ${FROM}"
exit
;;
logit)
${WRITELOG} ${LOGFILE} "skipping newgroup $1 $2 ${FROM} (would be ${WORD})" \
<${ARTICLE}
exit
;;
esac
## Do the work.
ctlinnd -s newgroup $1 $2 "${FROM}"
${WRITELOG} ${LOGFILE} "newgroup $1 $2 ${WORD} ${FROM}" <${ARTICLE}
## Get a description of the newsgroup; first from the article, and
## then from the newsgroups file.
DESC=`${SED} <${ARTICLE} -n -e "
:top
/^For your newsgroups file:\$/b scan
n
b top
:scan
n
/$1[ ]/ {
p
q
}
b scan"`
test -z "${DESC}" && {
DESC=`${EGREP} "^$1 " ${NEWSGROUPS} | ${SED} "s/[ ]*(Moderated)//"`
test -z "${DESC}" && DESC="$1 ?"
}
DESC="${DESC}${SUFFIX}"
## Lock so we can update newsgroups
LOCK=${LOCKS}/LOCK.newsgroups
PID=$$
TRY=0
MAXTRY=60
export LOCK MAXTRY PID LOGFILE TRY
while [ ${TRY} -lt ${MAXTRY} ]; do
shlock -p ${PID} -f ${LOCK} && break
sleep 2
TRY=`expr ${TRY} + 1`
done
## If we got the lock, update the file; otherwise, give up.
test ${TRY} -lt ${MAXTRY} || {
echo "Newgroup cannot update newsgroups. Locked by" `cat ${LOCK}` 1>&2
exit
}
${EGREP} -v "^$1[ ]" <${NEWSGROUPS} >${TEMP}
cat ${TEMP} >${NEWSGROUPS}
echo "${DESC}" >>${NEWSGROUPS}
rm ${TEMP} ${LOCK}
exit
|