Thread View: news.software.nntp
1 messages
1 total messages
Started by George Baltz
Wed, 16 Apr 1997 00:00
Verifying moderator's posts
Author: George Baltz
Date: Wed, 16 Apr 1997 00:00
Date: Wed, 16 Apr 1997 00:00
421 lines
15227 bytes
15227 bytes
We've had some minor problems with bogus posts to local moderated
groups (along with some incredulous comments from local moderators
"You mean it doesn't matter what I put there?") so I hacked up this
mod to nnrpd to verify and then hide/change the text on the Approved:
header, on a group by group basis. It does mean you have to know/find
each moderator that uses your server.
This was originally written for 1.4unoff4, then upgraded to 1.5.1. I
looked into using the perl_hooks in 1.5.1, but it looks like they
discard changes to %hdr. It should have some changes for
Install.ms.?, innlog.pl, and inncheck, but I haven't gotten a round
tuit yet (the only one here is nailed on somebody's wall :-)).
Note well the comments in the sample config file...
Cut below and feed to sh from $INN -
--------------------------
touch doc/moderators.pwd.5 samples/moderators.pwd
patch -p <<EOF
*** config/config.dist.orig Tue Dec 17 09:40:40 EST 1996
--- config/config.dist Tue Mar 18 13:30:27 EST 1997
***************
*** 1,4 ****
! ## $Revision: 1.64 $
##
## InterNetNews configuration file.
## Note that if you leave a field blank, you must have the trailing tab!
--- 1,4 ----
! ## $Revision: 1.2 $
##
## InterNetNews configuration file.
## Note that if you leave a field blank, you must have the trailing tab!
***************
*** 753,758 ****
--- 753,761 ----
## Where to mail to the moderators.
#### =()<_PATH_MODERATORS @<_PATH_MODERATORS>@>()=
_PATH_MODERATORS /var/news/etc/moderators
+ ## Where moderators' keys are kept
+ #### =()<_PATH_MODERATORS_PWD @<_PATH_MODERATORS_PWD>@>()=
+ _PATH_MODERATORS_PWD /var/news/etc/moderators.pwd
## A temporary file, for client inews to use.
#### =()<_PATH_TEMPMODERATORS @<_PATH_TEMPMODERATORS>@>()=
_PATH_TEMPMODERATORS /var/tmp/moderatorsXXXXXX
*** site/Makefile.orig Thu Dec 19 14:18:28 EST 1996
--- site/Makefile Tue Mar 18 13:57:23 EST 1997
***************
*** 27,32 ****
--- 27,34 ----
PATH_NOLIMIT = $(PATH_INNDHOSTS).nolimit
## =()<PATH_MODERATORS = @<_PATH_MODERATORS>@>()=
PATH_MODERATORS = /var/news/etc/moderators
+ ## =()<PATH_MODERATORS_PWD = @<_PATH_MODERATORS_PWD>@>()=
+ PATH_MODERATORS_PWD = /var/news/etc/moderators.pwd
## =()<PATH_DISTPATS = @<_PATH_DISTPATS>@>()=
PATH_DISTPATS = /var/news/etc/distrib.pats
## =()<PATH_NEWSBOOT = @<_PATH_NEWSBOOT>@>()=
***************
*** 119,125 ****
REST = \
newsfeeds \
hosts.nntp hosts.nntp.nolimit nnrp.access passwd.nntp \
! inn.conf moderators \
control.ctl expire.ctl nntpsend.ctl \
innwatch.ctl distrib.pats actsync.cfg actsync.ign \
sample.control
--- 121,127 ----
REST = \
newsfeeds \
hosts.nntp hosts.nntp.nolimit nnrp.access passwd.nntp \
! inn.conf moderators moderators.pwd \
control.ctl expire.ctl nntpsend.ctl \
innwatch.ctl distrib.pats actsync.cfg actsync.ign \
sample.control
***************
*** 130,136 ****
$D$(PATH_NEWSFEEDS) \
$D$(PATH_INNDHOSTS) $D$(PATH_NOLIMIT) \
$D$(PATH_NNRPACCESS) $D$(PATH_NNTPPASS) \
! $D$(PATH_CONFIG) $D$(PATH_MODERATORS) \
$D$(PATH_CONTROLCTL) $D$(PATH_EXPIRECTL) $D$(NEWSLIB)/nntpsend.ctl \
$D$(PATH_CTLWATCH) $D$(PATH_DISTPATS) \
$D$(PATH_ACTSYNC_CFG) $D$(PATH_ACTSYNC_IGN) \
--- 132,138 ----
$D$(PATH_NEWSFEEDS) \
$D$(PATH_INNDHOSTS) $D$(PATH_NOLIMIT) \
$D$(PATH_NNRPACCESS) $D$(PATH_NNTPPASS) \
! $D$(PATH_CONFIG) $D$(PATH_MODERATORS) $D$(PATH_MODERATORS_PWD) \
$D$(PATH_CONTROLCTL) $D$(PATH_EXPIRECTL) $D$(NEWSLIB)/nntpsend.ctl \
$D$(PATH_CTLWATCH) $D$(PATH_DISTPATS) \
$D$(PATH_ACTSYNC_CFG) $D$(PATH_ACTSYNC_IGN) \
***************
*** 223,228 ****
--- 225,231 ----
$D$(PATH_EXPIRECTL): expire.ctl ; $(COPY_RPRI) $? $@
$D$(PATH_CONFIG): inn.conf ; $(COPY_RPUB) $? $@
$D$(PATH_MODERATORS): moderators ; $(COPY_RPUB) $? $@
+ $D$(PATH_MODERATORS_PWD): moderators.pwd ; $(COPY_RPRI) $? $@
$D$(PATH_DISTPATS): distrib.pats ; $(COPY_RPUB) $? $@
$D$(PATH_NNTPPASS): passwd.nntp ; $(COPY_RPRI) $? $@
$D$(NEWSBIN)/nntpsend: nntpsend ; $(COPY_XPRI) $? $@
***************
*** 289,294 ****
--- 292,298 ----
innshellvars.tcl: ../samples/innshellvars.tcl ; $(COPY) $? $@
innshellvars.csh: ../samples/innshellvars.csh ; $(COPY) $? $@
moderators: ../samples/moderators ; $(COPY) $? $@
+ moderators.pwd: ../samples/moderators.pwd ; $(COPY) $? $@
distrib.pats: ../samples/distrib.pats ; $(COPY) $? $@
newgroup: ../samples/newgroup ; $(COPY) $? $@
news.daily: ../samples/news.daily ; $(COPY) $? $@
*** nnrpd/post.c.orig Tue Dec 17 09:40:40 EST 1996
--- nnrpd/post.c Wed Apr 16 09:56:52 EDT 1997
***************
*** 1,4 ****
! /* $Revision: 1.32 $
**
** Check article, send it to the local server.
*/
--- 1,4 ----
! /* $Revision: 1.5 $
**
** Check article, send it to the local server.
*/
***************
*** 549,554 ****
--- 549,617 ----
}
+ /* Check for valid approval key, if required
+ ** Returns string which should appear in the Approved: header.
+ */
+
+
+ STATIC STRING
+ CheckApproval(gpname, approval)
+ char *gpname;
+ char *approval;
+ {
+ FILE *Fp;
+ char buff[BUFSIZ], *p, *q, *r;
+ static char ourheader[SMBUF];
+
+ if (approval == NULL) return NULL;
+ if ((Fp = fopen(_PATH_MODERATORS_PWD, "r")) == NULL) {
+ syslog(LOG_WARNING, "No moderator password file, article accepted");
+ return approval;
+ }
+ while (fgets(buff, sizeof buff, Fp) != NULL) {
+ if ((p = strchr(buff, '\n')) != NULL)
+ *p = '\0';
+ if (buff[0] == '\0' || buff[0] == COMMENT_CHAR)
+ continue;
+ if ((p = strchr(buff, ':')) == NULL)
+ continue; /* Malformed line */
+ *p++ = '\0';
+ if (wildmat(gpname, buff)) {
+ /* Found the controlling entry... */
+ for ( ; *p ; p = r) {
+ if ( *p == ':' ) {
+ /* void key, anything works */
+ sprintf(buff,"%s Null moderator key, post accepted in %s",
+ ClientHost, gpname);
+ syslog(LOG_INFO, buff);
+ fclose(Fp);
+ return approval;
+ }
+ q = strchr(p, ':');
+ if ( !q ) break; /* Malformed line */
+ *q++ = '\0';
+ if ((r = strchr(q, ':')) == NULL) {
+ r = q + strlen(q);
+ } else {
+ *r++ = '\0';
+ }
+ if (EQ(p, approval)) {
+ fclose(Fp);
+ strncpy(ourheader, q, sizeof ourheader);
+ return ourheader;
+ }
+ }
+ break; /* Only one entry tried */
+ }
+ }
+ /* No matches, assume the worst */
+ fclose(Fp);
+ sprintf(buff, "%s Bogus attempt to post to moderated group %s",
+ ClientHost, gpname);
+ syslog(LOG_WARNING, buff);
+ return NULL;
+ }
+
/*
** Check the newsgroups and make sure they're all valid, that none are
** moderated, etc.
***************
*** 562,568 ****
register char *groups;
register char *p;
register GROUPENTRY *gp;
! register BOOL approved;
struct _DDHANDLE *h;
char *grplist[2];
BOOL IsNewgroup;
--- 625,631 ----
register char *groups;
register char *p;
register GROUPENTRY *gp;
! register char *approved;
struct _DDHANDLE *h;
char *grplist[2];
BOOL IsNewgroup;
***************
*** 574,585 ****
if ((p = strtok(groups, NGSEPS)) == NULL)
return "Can't parse newsgroups line";
- /* Don't mail article if just checking Followup-To line. */
- approved = HDR(_approved) != NULL || article == NULL;
-
Error[0] = '\0';
FoundOne = FALSE;
h = DDstart((FILE *)NULL, (FILE *)NULL);
do {
#if defined(DO_MERGE_TO_GROUPS)
if (p[0] == 't' && p[1] == 'o' && p[2] == '.')
--- 637,646 ----
if ((p = strtok(groups, NGSEPS)) == NULL)
return "Can't parse newsgroups line";
Error[0] = '\0';
FoundOne = FALSE;
h = DDstart((FILE *)NULL, (FILE *)NULL);
+ approved = HDR(_approved);
do {
#if defined(DO_MERGE_TO_GROUPS)
if (p[0] == 't' && p[1] == 'o' && p[2] == '.')
***************
*** 593,599 ****
case NF_FLAG_OK:
break;
case NF_FLAG_MODERATED:
! if (!approved) {
DISPOSE(groups);
DISPOSE(DDend(h));
return MailArticle(gp->Name, article);
--- 654,665 ----
case NF_FLAG_OK:
break;
case NF_FLAG_MODERATED:
! /* Don't mail article if just checking Followup-To line. */
! if (article == NULL) break;
!
! approved = CheckApproval(gp->Name, HDR(_approved));
!
! if (approved == NULL) {
DISPOSE(groups);
DISPOSE(DDend(h));
return MailArticle(gp->Name, article);
***************
*** 621,626 ****
--- 687,693 ----
}
}
} while ((p = strtok((char *)NULL, NGSEPS)) != NULL);
+ HDR(_approved) = approved; /* Restore public Approved: text */
DISPOSE(groups);
if (!FoundOne && !IsNewgroup)
*** samples/moderators.pwd.orig Tue Mar 18 14:23:46 EST 1997
--- samples/moderators.pwd Thu Apr 3 09:53:46 EST 1997
***************
*** 0 ****
--- 1,35 ----
+ ## $Revision: 1.7 $
+ ##
+ ## Control posting to moderated groups
+ ##
+ ## Format:
+ ## <NGname>:Secret Key:Public String:[key:public:...]
+ ## where:
+ ## <NGname> is a wildmat(q.v.) pattern
+ ## <Secret Key> is what must be on the Approved: header when it's posted
+ ## If it is NULL, any string will do (like previously).
+ ## If it is a space(' '), all articles will be mailed.
+ ## <Public String> is what appears in the Approved: line in the spool
+ ## If it is NULL, the original will be propagated.
+ ##
+ ## Only the first line that matches will be processed.
+ ##
+ ## Be careful! These defaults do not allow
+ ## posting to any non-local.* moderated group except a couple
+ ## of 'self-moderated' alt groups.
+ ##
+ #
+ # Simple group name with anything allowed on the Approved: header.
+ alt.hackers::
+ alt.sysadmin.recovery::
+ # Make sure the moderator is nobody (/dev/null)
+ alt.dev.null::
+ #
+ # Local group with >Sekret Key!!<
+ local.announce:Terces:Admin@my.site:
+ # Other local groups with multiple moderators/keys
+ local.*:KeyForBigBoss:Honcho@my.site:KeyForWorkerBee:Doer@my.site:
+ #
+ # Default (the '*'), with key you can't enter (the ' ').
+ *: ::
+
*** include/paths.h.orig Thu Dec 19 14:18:12 EST 1996
--- include/paths.h Fri Apr 4 11:15:05 EST 1997
***************
*** 128,133 ****
--- 128,135 ----
#define _PATH_TEMPMODERATORS "/var/tmp/moderatorsXXXXXX"
/* =()<#define _PATH_MODERATORS "@<_PATH_MODERATORS>@">()= */
#define _PATH_MODERATORS "/usr/local/news/moderators"
+ /* =()<#define _PATH_MODERATORS_PWD "@<_PATH_MODERATORS_PWD>@">()= */
+ #define _PATH_MODERATORS_PWD "/usr/local/news/moderators.pwd"
/* =()<#define _PATH_SERVER "@<_PATH_SERVER>@">()= */
#define _PATH_SERVER "/usr/local/news/server"
/* =()<#define _PATH_NNTPPASS "@<_PATH_NNTPPASS>@">()= */
*** doc/moderators.pwd.5.orig Mon Mar 31 14:18:17 EST 1997
--- doc/moderators.pwd.5 Mon Mar 31 15:16:59 EST 1997
***************
*** 0 ****
--- 1,82 ----
+ .\" $Revision: 1.2 $
+ .TH MODERATORS.PWD 5
+ .SH NAME
+ moderators.pwd \- private/public tokens for moderator approval
+ .SH DESCRIPTION
+ While processing a post to a moderated newsgroup,
+ .IR nnrpd (1)
+ reads the file
+ .\" =()<.I @<_PATH_MODERATORS_PWD>@>()=
+ .I /usr/local/news/moderators.pwd
+ to determine if the article should be posted directly, or mailed to a
+ moderator.
+ .PP
+ The file is read until a match is found.
+ Only the first match is
+ used, so more specific entries should appear first. The last
+ entry in the file should match any group (``*'') as a default.
+ Blank lines and lines starting with a number sign (``#'') are ignored.
+ All other lines should consist of multiple fields separated by colons.
+ .PP
+ The first field is a
+ .IR wildmat(3) -style
+ pattern.
+ If it matches the name of the newsgroup, then following pairs of fields
+ are examined to validate the contents of the Approved: header.
+ The first field of each pair is compared to the contents of the
+ Approved: header; if it does not match, the following field is
+ skipped, and the search continues. If it does match, the next
+ field will replace the contents of the Approved: header.
+ .PP
+ If no match is found, the Approved: line is ignored, and the article
+ is mailed to the address as determined by the
+ .IR moderators(5)
+ file.
+ .PP
+ Note that header processing removes leading and trailing
+ whitespace, so private keys with leading or trailing space will never
+ match.
+
+ .I Void fields
+ If the private key is void, any text will suffice; if the public
+ string is void, the private key will be reused.
+ .PP
+ Here is a sample file:
+ .RS
+ .nf
+ ## Format:
+ ## <NGname>:Secret Key:Public String:[key:public:...]
+ #
+ # Simple group name with anything allowed on the Approved: header.
+ alt.hackers::
+ #
+ # Local group with >Sekret Key!!<
+ local.announce:Terces:Admin@my.site:
+ # Other local groups with multiple moderators/keys
+ local.*:KeyForBigBoss:Honcho@my.site:KeyForWorkerBee:Doer@my.site:
+ #
+ # Default (the '*'), with key you can't enter (the ' ').
+ *: ::
+ .fi
+ .RE
+
+ Using the above file, articles posted to alt.hackers will be accepted
+ with any text on the Approved: header; only those matching one of the
+ appropriate keys would be accepted for any moderated local.* group,
+ and all articles for any other moderated group would mailed and not
+ posted.
+ .SH BUGS
+ The current implementation ignores this file during a local (
+ .I inews(1)
+ ) posting.
+
+ If an article is to be crossposted to multiple moderated groups, the same
+ private key must be allowed for all of the groups.
+ .SH HISTORY
+ Written by George Baltz <gwb+news@csc.umd.edu> for InterNetNews.
+ .de R$
+ This is revision \\$3, dated \\$4.
+ ..
+ .R$ $Id: moderators.pwd.5,v 1.2 1997/03/31 19:13:28 gwb Exp gwb $
+ .SH "SEE ALSO"
+ moderators(5), wildmat(3).
EOF
--------------------
--
George Baltz N3GB 301-405-3059 gwb@csc.umd.edu
Captain (Emeritus), UMD Hors d'Oeuvres Team "Working in this place is like
Computer Science Center, University of Maryland trying to dance 'Swan Lake'
College Park, MD 20742-2411 on the Beltway" - Jeff Jewett
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads