2 # [should have a bin/sh line and EZPATH/QMPATH added above by make]
4 # script to diagnose ezmlm lists
5 # call as is for environment only, or as ezmlm-check 'DIR' for more info
8 if [ "$1" = '-S' ] ; then
12 if [ "$1" = '-s' ] ; then
17 QINJECT
="${QMPATH}/bin/qmail-inject"
18 EZLIST
="${EZPATH}/ezmlm-list"
20 MYDTLINE
="Delivered-To: ${MYNAME}"
21 FATAL
="${MYNAME}: fatal:"
24 # This should be a ``grep'' that does regexps. Needs to recognize ^ and $.
29 # Needed to isolate some lines in the DIR/editor ... files
32 # needed to count characters in $USER
34 # should mark executables with '*' and list one file per line
36 # should list links as: "... symlink -> file"
38 if [ ! -x
"$QINJECT" ]; then
39 ${ECHO} "$FATAL edit script to for path to qmail-inject"
43 if [ -z
"$SENDER" ] ; then
47 if ${CAT} - |
${GREP} "${MYDTLINE}" >/dev
/null
2>&1
49 ${ECHO} "FATAL this message is looping: it already has my Delivered-To line (#5.4.6)"
54 if [ ! -z
"$1" -a
! -d
"$1" ]; then
55 ${ECHO} "$FATAL $1 is not a directory"; exit 100
59 GET
=''; DIGEST
=''; FLAGARCH
=''; FLAGIND
=''; INLOCAL
=''; INLOCALOK
=''; INHOST
=''
60 MANAGE
=''; OUTLOCAL
=''; OUTHOST
=''; SPEC
=''; SRESTRICT
=''; STORE
=''; REMOTE
=''
61 MODSUB
=''; MODPOST
=''; SPEC
=''
64 ${ECHO} "Delivered-To: ezmlm-check"
66 ${ECHO} "Subject: ${MYNAME} results"
68 ${ECHO} "Important environment variables:"
70 ${ECHO} "SENDER ='$SENDER'"
71 ${ECHO} "NEWSENDER ='$NEWSENDER'"
72 ${ECHO} "RECIPIENT ='$RECIPIENT'"
73 ${ECHO} "USER ='$USER'"
74 ${ECHO} "DEFAULT ='$DEFAULT'"
75 ${ECHO} "LOCAL ='$LOCAL'"
76 ${ECHO} "HOST ='$HOST'"
77 ${ECHO} "---------------------------------------------------"
78 if [ ! -z
"$1" ]; then
79 ${ECHO} "Checking basic list setup:"
81 if [ ! -r
"$1/mailinglist" ]; then
82 ${ECHO} "$EZERR $1/mailinglist does not exist"
84 if [ -e
"$1/num" ]; then
85 if [ ! -w
"$1/num" ]; then
86 ${ECHO} "$EZERR $1/num is not writable to $USER"
88 NUM
=`${CAT} "$1/num" | ${HEAD} -1`
89 ${ECHO} "... latest message was message # $NUM"
92 ${ECHO} "... no num. This must be a new list ..."
95 if [ -e
"$1/lock" -a
! -w
"$1/lock" ]; then
96 ${ECHO} "$EZERR User $USER does not have write premission to $1/lock"
98 if [ -e
"$1/lockbounce" -a
! -w
"$1/lockbounce" ]; then
99 ${ECHO} "$EZERR User $USER does not have write premission to $1/lockbounce"
101 if [ ! -r
"$1/inlocal" ]; then
102 ${ECHO} "$EZERR $1/inlocal does not exist"
103 elif [ ! -r
"$1/inhost" ]; then
104 ${ECHO} "$EZERR $1/inhost does not exist"
106 INLOCAL
=`${CAT} "$1/inlocal"| ${HEAD} -1`
107 INHOST
=`${CAT} "$1/inhost"| ${HEAD} -1`
108 if [ -z
"$HOST" ]; then
109 ${ECHO} "$EZERR HOST is empty. Likely running from the command"
110 ${ECHO} " line. Run from $1/editor to check if HOST matches"
111 ${ECHO} " $1/inhost and LOCAL matches $1/inlocal."
112 ${ECHO} " Mismatches here are the most common setup error."
115 if [ "$HOST" != "$INHOST" ]; then
116 ${ECHO} "$EZERR HOST does not match $1/inhost"
118 ${ECHO} "... $1/inhost OK"
120 if ${ECHO} "$LOCAL" |
${GREP} -G
"^$INLOCAL" >/dev
/null
2>&1
122 ${ECHO} "... $1/inlocal OK"
125 "$EZERR LOCAL does not begin with contents of $1/inlocal"
129 if [ ! -r
"$1/outlocal" ]; then
130 ${ECHO} "$EZERR $1/outlocal does not exist"
132 OUTLOCAL
=`${CAT} "$1/outlocal"| ${HEAD} -1`
134 if [ ! -r
"$1/outhost" ]; then
135 ${ECHO} "$EZERR $1/outhost does not exist"
137 OUTHOST
=`${CAT} "$1/outhost"| ${HEAD} -1`
139 ${ECHO} "... The list is named ${OUTLOCAL}@${OUTHOST}"
140 if [ "$OUTHOST" != "$INHOST" ]; then
143 ${ECHO} "??? $1/inhost and $1/outhost do not"
144 ${ECHO} " match. This is very unusual ..."
146 if ${ECHO} "$INLOCAL" |
${GREP} "^${USER}" >/dev
/null
; then
147 USERSTART
='1'; INLOCALOK
='1'
149 if [ -z
"$USERSTART" ]; then
151 ${ECHO} "??? $1/inlocal does not start with the user name."
152 ${ECHO} " This is an error, unless $INLOCAL starts with"
153 ${ECHO} " an alias of \"$USER\"."
155 if [ "$INLOCAL" = "$OUTLOCAL" ]; then
156 ${ECHO} "... $1/inlocal matches $1/outlocal"
157 ${ECHO} " suggesting that this is a regular user-owned list."
158 CHARS
=`${ECHO} " $USER" | ${WC} -c`
159 LIST
=`${ECHO} "$OUTLOCAL" | cut -c$CHARS-`
161 if ${ECHO} "$INLOCAL" |
${GREP} "$OUTLOCAL$" >/dev
/null
; then
162 if [ ! -z
"$USERSTART" ]; then
163 ${ECHO} "... It appears that $OUTHOST is a virtual domain"
164 ${ECHO} " controlled by $USER."
166 if [ ! -z
"$HOSTMATCH" ]; then
167 ${ECHO} " This part of the setup appears correct."
171 ${ECHO} "$EZWARN $1/inlocal ends with the contents"
172 ${ECHO} " of $1/outlocal, but does not start with"
173 ${ECHO} " $USER. If this message persists when you"
174 ${ECHO} " run this program from $1/editor,"
175 ${ECHO} " there is a setup error."
179 ${ECHO} "$EZWARN $1/inlocal does not end with the contents"
180 ${ECHO} " of $1/outlocal. This is almost always wrong."
183 if [ ! -r
"$1/editor" ]; then
184 ${ECHO} "$EZERR $1/editor does not exist"
188 ${ECHO} "============================"
190 ${ECHO} "============================"
193 if [ ! -r
"$1/manager" ]; then
194 ${ECHO} "$EZERR $1/manager does not exist"
196 ${ECHO} "$1/manager:"
197 ${ECHO} "============================"
199 ${ECHO} "============================"
202 if [ ! -r
"$1/bouncer" ]; then
203 ${ECHO} "$EZERR $1/bouncer does not exist"
205 ${ECHO} "$1/bouncer:"
206 ${ECHO} "============================"
208 ${ECHO} "============================"
211 if [ ! -r
"$1/owner" ]; then
212 ${ECHO} "$EZERR $1/owner does not exist"
215 ${ECHO} "============================"
217 ${ECHO} "============================"
219 OWNER
=`${GREP} "@" < $1/owner`
221 if [ ! -r
"$1/headeradd" ]; then
222 ${ECHO} "$EZERR $1/headeradd does not exist"
224 ${ECHO} "$1/headeradd:"
225 ${ECHO} "============================"
226 ${CAT} "$1/headeradd"
227 ${ECHO} "============================"
230 if [ ! -r
"$1/headerremove" ]; then
231 ${ECHO} "$EZERR $1/headerremove does not exist"
233 ${ECHO} "$1/headerremove:"
234 ${ECHO} "============================"
235 ${CAT} "$1/headerremove"
236 ${ECHO} "============================"
239 ${ECHO} "---------------------------------------------------"
240 ${ECHO} "Checking standard options:"
242 if [ -r
"$1/public" ]; then
245 ${ECHO} "... not public"
247 if [ -r
"$1/archived" ]; then
249 ${ECHO} "... archived"
251 ${ECHO} "... not archived"
253 if [ -r
"$1/indexed" ]; then
256 ${ECHO} "... indexed"
258 ${ECHO} "... not indexed"
260 if [ ! -z
"$FLAGARCH" ]; then
261 if [ ! -d
"$1/archive" ]; then
262 ${ECHO} "$EZERR $1/archive is not a directory"
264 if [ ! -z
"$NUM" -a
! -r
"$1/archive/0/index" \
265 -a
! -z
"$FLAGIND" ]; then
266 ${ECHO} "$EZWARN list is archived, but there is no index."
267 ${ECHO} " Please run ezmlm-idx!"
271 if [ ! -d
"$1/bounce" ]; then
272 ${ECHO} "$EZERR $1/bounce is not a directory"
274 if [ -r
"$1/prefix" ]; then
275 PREFIX
=`${HEAD} -1 "$1/prefix"`
276 ${ECHO} "... using $1/prefix as subject prefix: $PREFIX"
279 if [ -r
"$1/sublist" ]; then
280 ${ECHO} "... this is a sublist for:"
281 ${HEAD} -1 < "$1/sublist"
283 ${ECHO} "... not a sublist"
285 if [ ! -d
"$1/text" ]; then
286 ${ECHO} "$EZERR $1/text is not a directory"
288 ${ECHO} "... Contents of $1/text not checked"
290 if [ ! -z
"$OWNER" ]; then
291 ${ECHO} "... Mail to owner goes to: $OWNER"
293 ${ECHO} "$EZWARN Mail to owner seems not to be forwarded."
294 ${ECHO} " Remember to check the mailbox once in a while!"
297 ${ECHO} "--------------------------------------------------"
299 ${ECHO} "... Links should be:"
300 ${ECHO} " ~/.qmail-{list} -> $1/editor"
301 ${ECHO} " ~/.qmail-{list}-default -> $1/manager"
302 ${ECHO} " ~/.qmail-{list}-owner -> $1/owner"
303 ${ECHO} " ~/.qmail-{list}-return-default -> $1/bouncer"
304 if [ ! -z
"$LIST" -a
! -z
"$INLOCALOK" ]; then
306 ${ECHO} " As far as I can see, '{list}' should be '$LIST'."
307 ${ECHO} " If so and if .qmail files should be in $HOME ..."
308 BN
="$HOME/.qmail-$LIST"
310 if ${LLS} "$FN" 2>/dev
/null |
${GREP} "$1/editor$" >/dev
/null
; then
313 ${ECHO} "??? $FN is BAD"
316 if ${LLS} "$FN" |
${GREP} "$1/manager$" >/dev
/null
; then
319 ${ECHO} "??? $FN is BAD"
322 if ${LLS} "$FN" |
${GREP} "$1/owner$" >/dev
/null
; then
325 ${ECHO} "??? $FN is BAD"
327 FN
="$BN-return-default"
328 if ${LLS} "$FN" |
${GREP} "$1/bouncer$" >/dev
/null
; then
331 ${ECHO} "??? $FN is BAD"
334 ${ECHO} "--------------------------------------------------"
335 ${ECHO} "Checking subscribers:"
337 if [ ! -d
"$1/subscribers" ]; then
338 ${ECHO} "$EZERR $1/subscribers is not a directory"
340 if [ ! -x
"$EZLIST" ]; then
341 ${ECHO} "$EZLIST is not available for listing"
343 if [ "$listsubscribers" = "yes" ] ; then
344 ${ECHO} "... Subscribers are:"
345 if ${EZLIST} "$1" |
${GREP} '@' ; then
348 ${ECHO} "$EZWARN no subscribers!"
351 if ${EZLIST} "$1" |
${GREP} '@' >/dev
/null
2>&1 ; then
352 ${ECHO} "... There are subscribers."
354 ${ECHO} "$EZWARN no subscribers!"
360 ${ECHO} "--------------------------------------------------"
361 ${ECHO} "Checking for digest:"
363 if ${GREP} 'ezmlm-tstdig' < $1/editor
>/dev
/null
2>&1 ; then
364 if ${GREP} -1 'ezmlm-tstdig' < $1/editor \
365 |
${TAIL} -1 |
${GREP} 'ezmlm-get' >/dev
/null
; then
366 ${ECHO} "... integrated digest via $1/editor"
371 if [ -z
"$DIGEST" ]; then
372 ${ECHO} "... no digest via $1/editor"
374 ${ECHO} "... links should be:"
375 ${ECHO} " ~/.qmail-{list}-digest-return-default -> $1/bouncer"
376 ${ECHO} " ~/.qmail-{list}-digest-owner -> $1/owner"
377 if [ ! -z
"$LIST" -a
! -z
"$INLOCALOK" ]; then
379 ${ECHO} " As far as I can see, '{list}' should be '$LIST'."
380 ${ECHO} " If so and if .qmail files should be in $HOME ..."
381 BN
="$HOME/.qmail-$LIST"
382 FN
="$BN-digest-return-default"
383 if ${LLS} "$FN" 2>/dev
/null | \
384 ${GREP} "$1/bouncer$" >/dev
/null
; then
387 ${ECHO} "??? $FN is BAD"
389 FN
="$BN-digest-owner"
390 if ${LLS} "$FN" 2>/dev
/null | \
391 ${GREP} "$1/owner$" >/dev
/null
; then
394 ${ECHO} "??? $FN is BAD"
398 if [ -d
"$1/digest" ]; then
399 if [ ! -d
"$1/digest/subscribers" ]; then
400 ${ECHO} "$EZERR $1/digest exists, but $1/digest/subscribers"
401 ${ECHO} "$EZERR is not a directory"
404 if [ ! -x
"$EZLIST" ]; then
405 ${ECHO} "$EZLIST is not available for listing"
407 if [ "$listsubscribers" = "yes" ] ; then
409 ${ECHO} "... Digest subscribers are:"
410 if ${EZLIST} "$1" |
${GREP} '@' ; then
413 ${ECHO} "$EZWARN no subscribers!"
416 if ${EZLIST} "$1" |
${GREP} '@' >/dev
/null
2>&1 ; then
417 ${ECHO} "... There are digest subscribers."
419 ${ECHO} "$EZWARN no subscribers!"
426 ${ECHO} "---------------------------------------------------"
427 ${ECHO} "Checking for subscription moderation/remote admin:"
429 if [ -r
"$1/remote" ]; then
431 ${ECHO} "... set up for remote administration"
432 REMOTE
=`${CAT} "$1/remote"| ${HEAD} -1`
433 if ${ECHO} "$REMOTE" |
${GREP} -G
"^/" >/dev
/null
2>&1
441 ${ECHO} "... no remote admin"
443 if [ -r
"$1/modsub" ]; then
445 ${ECHO} "... subscription moderated"
446 MODSUB
=`${CAT} "$1/modsub"| ${HEAD} -1`
447 if ${ECHO} "$MODSUB" |
${GREP} -G
"^/" >/dev
/null
2>&1
450 elif [ -z
"$MODDIR" ]; then
454 ${ECHO} "... no subscription moderation"
456 if [ "$FLAGMOD" = '1' ]; then
458 ${ECHO} "Mods/remote admins stored based in $MODDIR:"
460 if [ ! -d
"$MODDIR" ]; then
461 ${ECHO} "$EZERR moderator dir $MODDIR doesn't exist!"
462 elif [ -e
"$MODDIR/lock" -a
! -w
"$MODDIR/lock" ]; then
463 ${ECHO} "$EZERR $MODDIR/lock is not writable to user $USER"
464 elif [ ! -x
"$EZLIST" ]; then
465 ${ECHO} "${EZLIST} not available for listing"
467 if ${EZLIST} "$MODDIR" |
${GREP} '@' ; then
470 ${ECHO} "$EZERR no subscription moderators/remote admins!"
475 ${ECHO} "---------------------------------------------------"
476 ${ECHO} "Checking for message moderation:"
478 if ${GREP} 'ezmlm-gate' < "$1/editor" > /dev
/null
2>&1; then
481 if ${GREP} 'ezmlm-store' < "$1/editor" > /dev
/null
2>&1; then
485 if [ -r
"$1/modpost" ]; then
487 MODPOST
=`${CAT} "$1/modpost" | ${HEAD} -1`
488 if ${ECHO} "$MODPOST" |
${GREP} -G
"^/" >/dev
/null
2>&1
495 if [ "$STORE" = '1' -a
-z
"$FLAGMOD" ]; then
496 ${ECHO} "??? it looks from $1/editor like the list is set up"
497 ${ECHO} " for message moderation. However, since $1/modpost"
498 ${ECHO} " doesn't exist, ezmlm-store posts them directly. If"
499 ${ECHO} " this is not intended, please create $1/modpost."
503 elif [ -z
"$STORE" -a
-z
"$GATE" -a
"$FLAGMOD" = '1' ]; then
504 ${ECHO} "??? $1/modpost exists, leading me to think you'd like"
505 ${ECHO} " message moderation, but I can't find any call to"
506 ${ECHO} " ezmlm-store in $1/editor."
508 elif [ -z
"$STORE" -a
"$GATE" = '1' ]; then
509 if [ -z
"$FLAGMOD" ]; then
510 ${ECHO} "??? The list is set up with ezmlm-gate in $1/editor."
511 ${ECHO} " However, since $1/modpost does not exist all"
512 ${ECHO} " messages will be accepted!"
516 ${ECHO} "... The list is set up with ezmlm-gate in $1/editor."
517 ${ECHO} " Since $1/modpost exists, subscriber messages"
518 ${ECHO} " will be accepted and others will be send for"
519 ${ECHO} " moderation."
522 if [ "$FLAGMOD" = '1' ]; then
523 ${ECHO} "... message moderated"
525 ${ECHO} "Message moderators based in $MODDIR:"
527 if [ ! -d
"$MODDIR" ]; then
528 ${ECHO} "$EZERR moderator dir $MODDIR doesn't exist!"
529 elif [ -e
"$MODDIR/lock" -a
! -w
"$MODDIR/lock" ]; then
530 ${ECHO} "$EZERR $MODDIR/lock is not writable to user $USER"
531 elif [ ! -x
"$EZLIST" ]; then
532 ${ECHO} "${EZLIST} not available for listing"
534 if ${EZLIST} "$MODDIR" |
${GREP} '@' ; then
537 ${ECHO} "$EZERR no message moderators!"
542 if [ -r
"$1/modtime" ]; then
543 MODTIME
=`${CAT} "$1/modtime" | ${HEAD} -1`
544 if [ "$MODTIME" -eq
0 ]; then
546 elif [ "$MODTIME" -lt
24 ]; then
548 elif [ "$MODTIME" -gt
240 ]; then
554 ${ECHO} "... Messages awaiting moderation time out after $MT hours"
555 if [ ! -d
"$1/mod/pending" ]; then
556 ${ECHO} "$EZERR $MODDIR/pending is not a directory"
558 MODNUM
=`${LS} "$1/mod/pending" | ${GREP} -c '*'`
559 ${ECHO} "... there are $MODNUM messages awaiting moderator action"
561 if [ ! -d
"$1/mod/accepted" ]; then
562 ${ECHO} "$EZERR $MODDIR/accepted is not a directory"
564 if [ ! -d
"$1/mod/rejected" ]; then
565 ${ECHO} "$EZERR $MODDIR/rejected is not a directory"
567 if [ ! -r
"$1/moderator" ]; then
568 ${ECHO} "$EZERR $1/moderator is not readable to user $USER"
570 if ${GREP} 'ezmlm-moderate' < "$1/moderator" >/dev
/null
2>&1
574 ${ECHO} "$EZERR $1/moderator lacks ezmlm-moderate entry"
577 ${ECHO} "$1/moderator:"
578 ${ECHO} "============================"
579 ${CAT} "$1/moderator"
580 ${ECHO} "============================"
584 ${ECHO} "... Links should be:"
585 ${ECHO} " ~/.qmail-{list}-accept-default -> $1/moderator"
586 ${ECHO} " ~/.qmail-{list}-reject-default -> $1/moderator"
588 if [ ! -z
"$LIST" -a
! -z
"$INLOCALOK" ]; then
590 ${ECHO} " As far as I can see, '{list}' should be '$LIST'."
591 ${ECHO} " If so and if .qmail files should be in $HOME ..."
592 BN
="$HOME/.qmail-$LIST"
593 FN
="$BN-accept-default"
594 if ${LLS} "$FN" 2>/dev
/null | \
595 ${GREP} "$1/moderator$" >/dev
/null
; then
598 ${ECHO} "??? $FN is BAD"
600 FN
="$BN-reject-default"
601 if ${LLS} "$FN" 2>/dev
/null | \
602 ${GREP} "$1/moderator$" >/dev
/null
; then
605 ${ECHO} "??? $FN is BAD"
609 ${ECHO} "... no message moderation"
612 ${ECHO} "---------------------------------------------------"
613 ${ECHO} "Checking for SENDER checks:"
615 if ${GREP} 'ezmlm-issubn -n' < "$1/editor" >/dev
/null
2>&1 ; then
616 ${ECHO} "... Some type of blacklisting in use"
619 if ${GREP} 'ezmlm-issubn' < "$1/editor" |\
620 ${GREP} -v
-- '-n' >/dev
/null
2>&1 ; then
621 ${ECHO} "... Some type of SENDER check in use for posts"
624 if [ -z
"$SRESTRICT" ]; then
625 ${ECHO} "... no SENDER restrictions found for posts"
628 GET
=` ${GREP} 'ezmlm-get' < "$1/manager" | \
629 ${CUT} -d' ' -f2- | ${CUT} -d\' -f1`
630 if ${ECHO} "$GET" |
${GREP} 's' >/dev
/null
; then
631 ${ECHO} "... Only subscribers may access the archive"
633 ${ECHO} "... no SENDER restrictions for archive access"
636 ${ECHO} "---------------------------------------------------"
637 ${ECHO} "Checking for special options:"
639 MANAGE
=` ${GREP} 'ezmlm-manage' < "$1/manager" | \
640 ${CUT} -d' ' -f2- | ${CUT} -d\' -f1`
641 if ${ECHO} "$MANAGE" |
${GREP} 'e' >/dev
/null
; then
642 ${ECHO} "... remote editing of $1/text/ files enabled"
645 if ${ECHO} "$MANAGE" |
${GREP} 'l' >/dev
/null
; then
646 ${ECHO} "... remote listing of subscribers enabled"
649 if [ "$SPEC" = '1' -a
-z
"$REMOTE" ] ; then
651 "$EZERR but remote admin is not enabled, so this will not work!"
653 ${ECHO} "---------------------------------------------------"
656 ${ECHO} "EXT ='$EXT'"
657 ${ECHO} "EXT1 ='$EXT1'"
658 ${ECHO} "EXT2 ='$EXT2'"
659 ${ECHO} "EXT3 ='$EXT3'"
660 ${ECHO} "EXT4 ='$EXT4'"
661 ${ECHO} "DTLINE = $DTLINE"
662 ${ECHO} "RPLINE = $RPLINE"
663 ${ECHO} "UFLINE = $UFLINE"
664 ${ECHO} "---------------------------------------------------"
666 ${ECHO} "Hope that helps!"
667 ) |
"$RCP" ||
exit 100