Article View: news.software.nntp
Article #7671A patch for INN to stop sending unwanted newsgroups
From: John T. Stapleton
Date: Thu, 16 May 1996 00:00
Date: Thu, 16 May 1996 00:00
672 lines
19417 bytes
19417 bytes
Here are patches to prevent unwanted newsgroups being sent to your news
neighbors even when the article is cross-posted to a subscribed newsgroup.
It is indicated by prefixing the newsgroup pattern with two exclamation
marks as was suggested in this newsgroup at some earlier time.
For example:
alt.*,!!alt.binaries.*
will not send the article if it is posted to an alt.binaries newsgroup
and cross-posted to another alt group which is not an alt.binaries
newsgroup. As with other patterns in the subscription list, the order
is important if the patterns overlap. It is not important if the
patterns don't overlap. The order doesn't matter in the following
example because the patterns don't overlap:
biz.*,!!clari.*
I have been running this for only a few days on one of my two servers.
One of my servers is for distributing news only (i.e. no readers) and
the other is fed exclusively by the first server.
Stapes
*** doc/newsfeeds.5.orig Thu May 16 15:39:42 EDT 1996
--- doc/newsfeeds.5 Thu May 16 16:00:42 EDT 1996
***************
*** 94,99 ****
--- 94,123 ----
but this would not have the same effect if there were a
``comp.sources-only'' group.
.PP
+ If a pattern begins with two exclamation marks, it means that any article
+ posted to a group matching the pattern will not be sent even though the
+ article may be cross-posted to a group which is subscribed. For example, to
+ send all "biz" groups, but do not send articles posted in a "biz" group if
+ it is cross-posted to a "clari" group, the following set of patterns can be
+ used:
+ .RS
+ .nf
+ biz.*,!!clari.*
+ .fi
+ .RE
+ The order of the above does not matter because the two patterns can never
+ overlap. The following would matter:
+ .RS
+ .nf
+ alt.*,!!alt.binaries.warez.*,misc.*
+ .fi
+ .RE
+ If you reverse the alt.* and alt.binaries.warez.* patterns, it would
+ nullify the double exclamation marks because the result of the last
+ match is the one that counts. Using the above example, if an article
+ is posted to one or more of the alt.binaries.warez.* groups and is
+ cross-posted to misc.test, then the article is not sent.
+ .PP
See
.IR innd (8)
for details on the propagation of control messages.
*** innd/art.c.orig Thu Mar 18 16:04:21 EST 1993
--- innd/art.c Sun Apr 14 15:54:45 EDT 1996
***************
*** 1392,1397 ****
--- 1392,1414 ----
/*
+ ** Check is site doesn't want this group even if it's crossposted
+ ** to a wanted group.
+ */
+ STATIC void
+ ARTunwantthegroup(name)
+ register char *name;
+ {
+ register SITE *sp;
+ register int i;
+
+ for (sp = Sites, i = nSites; --i >= 0; sp++)
+ if (sp->Name != NULL && SITEunwantsgroup(sp, name))
+ sp->Unwant = TRUE;
+ }
+
+
+ /*
** Assign article numbers to the article and create the Xref line.
** If we end up not being able to write the article, we'll get "holes"
** in the directory and active file.
***************
*** 1766,1771 ****
--- 1783,1789 ----
for (i = nGroups, ngp = Groups; --i >= 0; ngp++)
ngp->PostCount = 0;
for (i = nSites, sp = Sites; --i >= 0; sp++) {
+ sp->Unwant = FALSE;
sp->Sendit = FALSE;
sp->Seenit = FALSE;
sp->FNLnames.Used = 0;
***************
*** 1830,1835 ****
--- 1848,1854 ----
ARTsendthegroup(*groups);
Accepted = TRUE;
}
+ ARTunwantthegroup(*groups);
#if defined(DO_MERGE_TO_GROUPS)
/* Try to collapse all "to" newsgroups. */
***************
*** 1860,1871 ****
return buff;
}
/* Valid group, feed it to that group's sites. */
Accepted = TRUE;
for (isp = ngp->Sites, i = ngp->nSites; --i >= 0; isp++)
if (*isp >= 0) {
sp = &Sites[*isp];
! SITEmark(sp, ngp);
}
/* If it's excluded, don't file it. */
--- 1879,1896 ----
return buff;
}
+ /* See if any of this group's sites unwants this group. */
+ for (isp = ngp->Unwant, i = ngp->nUnwant; --i >= 0; isp++)
+ if (*isp >= 0)
+ Sites[*isp].Unwant = TRUE;
+
/* Valid group, feed it to that group's sites. */
Accepted = TRUE;
for (isp = ngp->Sites, i = ngp->nSites; --i >= 0; isp++)
if (*isp >= 0) {
sp = &Sites[*isp];
! if (!sp->Unwant)
! SITEmark(sp, ngp);
}
/* If it's excluded, don't file it. */
***************
*** 1880,1885 ****
--- 1905,1915 ----
j += ngp->NameLength + 1 + MAXARTFNAME + 1;
}
+ /* Loop over sites to find Unwants and undo Sendit flags. */
+ for (i = nSites, sp = Sites; --i >= 0; sp++)
+ if (sp->Unwant)
+ sp->Sendit = FALSE;
+
/* Control messages not filed in "to" get filed only in controlname
* or control. */
if (ControlHeader >= 0 && Accepted && !ToGroup) {
***************
*** 1941,1947 ****
for (isp = ngp->Sites, i = ngp->nSites; --i >= 0; isp++)
if (*isp >= 0) {
sp = &Sites[*isp];
! SITEmark(sp, ngp);
}
}
*ngptr = NULL;
--- 1971,1978 ----
for (isp = ngp->Sites, i = ngp->nSites; --i >= 0; isp++)
if (*isp >= 0) {
sp = &Sites[*isp];
! if (!sp->Unwant)
! SITEmark(sp, ngp);
}
}
*ngptr = NULL;
*** innd/cc.c.orig Thu Mar 18 16:04:22 EST 1993
--- innd/cc.c Sun Apr 14 13:46:03 EDT 1996
***************
*** 246,251 ****
--- 246,252 ----
register NEWSGROUP *ngp;
STRING error;
char *subbed;
+ char *unwanted;
/* If site already exists, drop it. */
if (SITEfind(av[0]) != NULL && (p = CCdrop(av)) != NULL)
***************
*** 274,281 ****
nSites++;
RENEW(Sites, SITE, nSites);
sp = &Sites[nSites - 1];
! for (i = nGroups, ngp = Groups; --i >= 0; ngp++)
RENEW(ngp->Sites, int, nSites);
}
SITElinkall();
}
--- 275,284 ----
nSites++;
RENEW(Sites, SITE, nSites);
sp = &Sites[nSites - 1];
! for (i = nGroups, ngp = Groups; --i >= 0; ngp++) {
RENEW(ngp->Sites, int, nSites);
+ RENEW(ngp->Unwant, int, nSites);
+ }
}
SITElinkall();
}
***************
*** 282,289 ****
/* Parse. */
subbed = NEW(char, nGroups);
! error = SITEparseone(p, sp, subbed);
DISPOSE(subbed);
if (error != NULL) {
DISPOSE(p);
syslog(L_ERROR, "%s bad_newsfeeds %s", av[0], error);
--- 285,294 ----
/* Parse. */
subbed = NEW(char, nGroups);
! unwanted = NEW(char, nGroups);
! error = SITEparseone(p, sp, subbed, unwanted);
DISPOSE(subbed);
+ DISPOSE(unwanted);
if (error != NULL) {
DISPOSE(p);
syslog(L_ERROR, "%s bad_newsfeeds %s", av[0], error);
***************
*** 400,406 ****
fake.Buffer.Size = 0;
fake.Buffer.Data = NULL;
for (errors = 0, i = 0; (p = strings[i]) != NULL; i++) {
! if ((error = SITEparseone(p, &fake, (char *)NULL)) != NULL) {
syslog(L_ERROR, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
}
--- 405,411 ----
fake.Buffer.Size = 0;
fake.Buffer.Data = NULL;
for (errors = 0, i = 0; (p = strings[i]) != NULL; i++) {
! if ((error = SITEparseone(p, &fake, (char *)NULL, (char *)NULL)) != NULL) {
syslog(L_ERROR, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
}
***************
*** 436,446 ****
SITEdrop(sp);
/* Loop over all groups, and if the site is in a group, clobber it. */
! for (idx = sp - Sites, i = nGroups, ngp = Groups; --i >= 0; ngp++)
for (j = ngp->nSites, ip = ngp->Sites; --j >= 0; ip++)
if (*ip == idx)
*ip = NOSITE;
!
return NULL;
}
--- 441,454 ----
SITEdrop(sp);
/* Loop over all groups, and if the site is in a group, clobber it. */
! for (idx = sp - Sites, i = nGroups, ngp = Groups; --i >= 0; ngp++) {
for (j = ngp->nSites, ip = ngp->Sites; --j >= 0; ip++)
if (*ip == idx)
*ip = NOSITE;
! for (j = ngp->nUnwant, ip = ngp->Unwant; --j >= 0; ip++)
! if (*ip == idx)
! *ip = NOSITE;
! }
return NULL;
}
*** innd/innd.h.orig Wed Jun 14 11:48:27 EDT 1995
--- innd/innd.h Sun Apr 14 15:49:30 EDT 1996
***************
*** 170,175 ****
--- 170,177 ----
char *Rest;
int nSites;
int *Sites;
+ int nUnwant;
+ int *Unwant;
struct _NEWSGROUP *Alias;
} NEWSGROUP;
***************
*** 199,204 ****
--- 201,207 ----
char **Exclusions;
char **Distributions;
char **Patterns;
+ BOOL Unwant;
BOOL Sendit;
BOOL Seenit;
BOOL DistRequired;
***************
*** 510,515 ****
--- 513,519 ----
extern BOOL SITEfunnelpatch();
extern BOOL SITEsetup();
extern BOOL SITEwantsgroup();
+ extern BOOL SITEunwantsgroup();
extern char **SITEreadfile();
extern SITE *SITEfind();
extern SITE *SITEfindnext();
*** innd/newsfeeds.c.orig Thu Mar 18 16:04:29 EST 1993
--- innd/newsfeeds.c Sun Apr 14 17:39:30 EDT 1996
***************
*** 104,123 ****
** Modify "subbed" according to the patterns in "patlist."
*/
STATIC void
! SITEsetlist(patlist, subbed)
char **patlist;
char *subbed;
{
register char *pat;
register char *p;
register char subvalue;
register NEWSGROUP *ngp;
register int i;
while ((pat = *patlist++) != NULL) {
subvalue = *pat != SUB_NEGATE;
! if (!subvalue)
pat++;
/* See if pattern is a simple newsgroup name. If so, set the
* right subbed element for that one group (if found); if not,
--- 104,131 ----
** Modify "subbed" according to the patterns in "patlist."
*/
STATIC void
! SITEsetlist(patlist, subbed, unwanted)
char **patlist;
char *subbed;
+ char *unwanted;
{
register char *pat;
register char *p;
+ register char *u;
register char subvalue;
+ register char unwantvalue;
register NEWSGROUP *ngp;
register int i;
while ((pat = *patlist++) != NULL) {
subvalue = *pat != SUB_NEGATE;
! unwantvalue = FALSE;
! if (!subvalue) {
pat++;
+ unwantvalue = *pat == SUB_NEGATE;
+ if (unwantvalue)
+ pat++;
+ }
/* See if pattern is a simple newsgroup name. If so, set the
* right subbed element for that one group (if found); if not,
***************
*** 127,139 ****
break;
if (*p == '\0') {
/* Simple string; look it up, set it. */
! if ((ngp = NGfind(pat)) != NULL)
subbed[ngp - Groups] = subvalue;
}
else
! for (p = subbed, ngp = Groups, i = nGroups; --i >= 0; ngp++, p++)
! if (wildmat(ngp->Name, pat))
*p = subvalue;
}
}
--- 135,152 ----
break;
if (*p == '\0') {
/* Simple string; look it up, set it. */
! if ((ngp = NGfind(pat)) != NULL) {
subbed[ngp - Groups] = subvalue;
+ unwanted[ngp - Groups] = unwantvalue;
+ }
}
else
! for (p = subbed, u = unwanted, ngp = Groups, i = nGroups;
! --i >= 0; ngp++, p++, u++)
! if (wildmat(ngp->Name, pat)) {
*p = subvalue;
+ *u = unwantvalue;
+ }
}
}
***************
*** 146,155 ****
** doing syntax checking.
*/
STRING
! SITEparseone(Entry, sp, subbed)
char *Entry;
SITE *sp;
char *subbed;
{
static char BATCH[] = _PATH_BATCHDIR;
register int i;
--- 159,169 ----
** doing syntax checking.
*/
STRING
! SITEparseone(Entry, sp, subbed, unwanted)
char *Entry;
SITE *sp;
char *subbed;
+ char *unwanted;
{
static char BATCH[] = _PATH_BATCHDIR;
register int i;
***************
*** 156,161 ****
--- 170,176 ----
register int j;
register NEWSGROUP *ngp;
register char *p;
+ register char *u;
char *f2;
char *f3;
char *f4;
***************
*** 203,211 ****
if (subbed) {
/* Read the subscription patterns and set the bits. */
(void)memset((POINTER)subbed, SUB_DEFAULT, (SIZE_T)nGroups);
if (ME.Patterns)
! SITEsetlist(ME.Patterns, subbed);
! SITEsetlist(sp->Patterns, subbed);
}
/* Get the third field, the flags. */
--- 218,227 ----
if (subbed) {
/* Read the subscription patterns and set the bits. */
(void)memset((POINTER)subbed, SUB_DEFAULT, (SIZE_T)nGroups);
+ (void)memset((POINTER)unwanted, SUB_DEFAULT, (SIZE_T)nGroups);
if (ME.Patterns)
! SITEsetlist(ME.Patterns, subbed, unwanted);
! SITEsetlist(sp->Patterns, subbed, unwanted);
}
/* Get the third field, the flags. */
***************
*** 377,383 ****
/* Now tell the groups this site gets that they should feed this site. */
if (sp != &ME && subbed) {
isp = sp - Sites;
! for (p = subbed, ngp = Groups, i = nGroups; --i >= 0; ngp++)
if (*p++) {
for (j = 0; j < ngp->nSites; j++)
if (ngp->Sites[j] == NOSITE) {
--- 393,400 ----
/* Now tell the groups this site gets that they should feed this site. */
if (sp != &ME && subbed) {
isp = sp - Sites;
! for (p = subbed, u = unwanted, ngp = Groups, i = nGroups;
! --i >= 0; ngp++)
if (*p++) {
for (j = 0; j < ngp->nSites; j++)
if (ngp->Sites[j] == NOSITE) {
***************
*** 387,392 ****
--- 404,418 ----
if (j == ngp->nSites)
ngp->Sites[ngp->nSites++] = isp;
}
+ if (*u++) {
+ for (j = 0; j < ngp->nUnwant; j++)
+ if (ngp->Unwant[j] == NOSITE) {
+ ngp->Unwant[j] = isp;
+ break;
+ }
+ if (j == ngp->nUnwant)
+ ngp->Unwant[ngp->nUnwant++] = isp;
+ }
}
/* If this is a duplicate name, find the master. */
***************
*** 474,479 ****
--- 500,506 ----
char **strings;
SITE *sp;
char *subbed;
+ char *unwanted;
STRING error;
int errors;
***************
*** 498,514 ****
/* Set up scratch subscription list. */
subbed = NEW(char, nGroups);
for (sp = Sites, errors = 0, i = 0; i < nSites; i++) {
p = strings[i];
if (p[0] == 'M' && p[1] == 'E' && p[2] == NF_FIELD_SEP) {
! if ((error = SITEparseone(p, &ME, subbed)) != NULL) {
syslog(L_FATAL, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
}
continue;
}
! if ((error = SITEparseone(p, sp, subbed)) != NULL) {
syslog(L_FATAL, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
continue;
--- 525,542 ----
/* Set up scratch subscription list. */
subbed = NEW(char, nGroups);
+ unwanted = NEW(char, nGroups);
for (sp = Sites, errors = 0, i = 0; i < nSites; i++) {
p = strings[i];
if (p[0] == 'M' && p[1] == 'E' && p[2] == NF_FIELD_SEP) {
! if ((error = SITEparseone(p, &ME, subbed, unwanted)) != NULL) {
syslog(L_FATAL, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
}
continue;
}
! if ((error = SITEparseone(p, sp, subbed, unwanted)) != NULL) {
syslog(L_FATAL, "%s bad_newsfeeds %s", MaxLength(p, p), error);
errors++;
continue;
***************
*** 531,536 ****
--- 559,565 ----
/* Free our scratch array, set up the funnel links. */
nSites = sp - Sites;
DISPOSE(subbed);
+ DISPOSE(unwanted);
DISPOSE(strings);
if (!SITEfunnelpatch()) {
JustCleanup();
*** innd/ng.c.orig Thu Mar 18 16:04:30 EST 1993
--- innd/ng.c Sun Apr 14 12:40:29 EDT 1996
***************
*** 119,124 ****
--- 119,126 ----
ngp->Last = atol(ngp->LastString);
ngp->nSites = 0;
ngp->Sites = NEW(int, NGHcount);
+ ngp->nUnwant = 0;
+ ngp->Unwant = NEW(int, NGHcount);
ngp->Alias = NULL;
/* Find the right bucket for the group, make sure there is room. */
***************
*** 158,165 ****
/* If re-reading, remove anything we might have had. */
if (Groups) {
! for (i = nGroups, ngp = Groups; --i >= 0; ngp++)
DISPOSE(ngp->Sites);
DISPOSE(Groups);
DISPOSE(GroupPointers);
DISPOSE(NGdirs.Data);
--- 160,169 ----
/* If re-reading, remove anything we might have had. */
if (Groups) {
! for (i = nGroups, ngp = Groups; --i >= 0; ngp++) {
DISPOSE(ngp->Sites);
+ DISPOSE(ngp->Unwant);
+ }
DISPOSE(Groups);
DISPOSE(GroupPointers);
DISPOSE(NGdirs.Data);
*** innd/site.c.orig Thu Mar 18 16:04:32 EST 1993
--- innd/site.c Sun Apr 14 12:28:41 EDT 1996
***************
*** 771,778 ****
if (ME.Patterns) {
for (argv = ME.Patterns; (pat = *argv++) != NULL; ) {
subvalue = *pat != SUB_NEGATE;
! if (!subvalue)
pat++;
if (wildmat(name, pat))
match = subvalue;
}
--- 771,781 ----
if (ME.Patterns) {
for (argv = ME.Patterns; (pat = *argv++) != NULL; ) {
subvalue = *pat != SUB_NEGATE;
! if (!subvalue) {
pat++;
+ if (*pat == SUB_NEGATE)
+ pat++;
+ }
if (wildmat(name, pat))
match = subvalue;
}
***************
*** 779,788 ****
}
for (argv = sp->Patterns; (pat = *argv++) != NULL; ) {
subvalue = *pat != SUB_NEGATE;
! if (!subvalue)
pat++;
if (wildmat(name, pat))
match = subvalue;
}
return match;
}
--- 782,837 ----
}
for (argv = sp->Patterns; (pat = *argv++) != NULL; ) {
subvalue = *pat != SUB_NEGATE;
! if (!subvalue) {
pat++;
+ if (*pat == SUB_NEGATE)
+ pat++;
+ }
if (wildmat(name, pat))
match = subvalue;
+ }
+ return match;
+ }
+
+
+ /*
+ ** Run down the site's pattern list and see if it unwants the specified
+ ** newsgroup.
+ */
+ BOOL
+ SITEunwantsgroup(sp, name)
+ register SITE *sp;
+ register char *name;
+ {
+ register BOOL match;
+ register BOOL unwantvalue;
+ register char *pat;
+ register char **argv;
+
+ match = SUB_DEFAULT;
+ if (ME.Patterns) {
+ for (argv = ME.Patterns; (pat = *argv++) != NULL; ) {
+ unwantvalue = *pat == SUB_NEGATE;
+ if (unwantvalue) {
+ pat++;
+ unwantvalue = *pat == SUB_NEGATE;
+ if (unwantvalue)
+ pat++;
+ }
+ if (wildmat(name, pat))
+ match = unwantvalue;
+ }
+ }
+ for (argv = sp->Patterns; (pat = *argv++) != NULL; ) {
+ unwantvalue = *pat == SUB_NEGATE;
+ if (unwantvalue) {
+ pat++;
+ unwantvalue = *pat == SUB_NEGATE;
+ if (unwantvalue)
+ pat++;
+ }
+ if (wildmat(name, pat))
+ match = unwantvalue;
}
return match;
}
Technical Details
Message-ID:
<4ngqoq$q1o@blazing.mro.dec.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <4ngqoq$q1o@blazing.mro.dec.com> Subject: A patch for INN to stop sending unwanted newsgroups Date: Thu, 16 May 1996 00:00:00 +0000 From: stapes@blazing.mro.dec.com (John T. Stapleton) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 155256425 Distribution: inet Organization: Digital Equipment Corporation - Marlboro, MA Newsgroups: news.software.nntp