Article View: news.software.nntp
Article #17325Re: Limit crossposting to X amount (expire or channel)? & Expire Questions
From: Todd C Miller
Date: Sat, 26 Apr 1997 00:00
Date: Sat, 26 Apr 1997 00:00
185 lines
5013 bytes
5013 bytes
From the keyboard of lyle@azlink.com:
>
> Is there is a way to limit an article that is crossposted to X number
> of groups using either expire or a INN channel? I would like to figure
> out a way to either reject an article that has been posted to a
> specified number of groups or only let it post to the first X number
> of groups.
Below is a hack I made to crosspost to do this. It's a bit
heavy handed but it gets the job done. The diffs include
changes to the man page that tell how to use it. You have
to be runing crosspost of course...
- todd
--- crosspost.c.DIST Tue Dec 17 07:40:40 1996
+++ crosspost.c Tue Feb 11 22:56:43 1997
@@ -28,9 +28,9 @@
STATIC char *Dir;
STATIC int debug = FALSE;
+STATIC int maxxpost = 256;
STATIC int syncfiles = TRUE;
-
-#define MAXXPOST 256
+STATIC int xunlink = FALSE;
/*
@@ -92,9 +92,14 @@
register int i;
int nxp;
int fd;
- int lnval ;
- char *names[MAXXPOST];
+ int lnval;
+ STATIC char **names;
+
+ if (names == NULL && (names = malloc(sizeof(char *) * maxxpost)) == NULL) {
+ perror("can't allocate buffer");
+ exit(1);
+ }
for ( ; ; ) {
/* Read the first line of data. */
@@ -106,7 +111,18 @@
break;
}
- for (i = 0; *p && (i < MAXXPOST); i++) { /* parse input into array */
+ for (i = 0; *p; i++) { /* parse input into array */
+ if (i >= maxxpost) {
+ if (debug)
+ (void)fprintf(stderr, "crosspost: too many crossposts %s\n",
+ names[0]);
+ if (xunlink) {
+ (void)unlink(names[0]);
+ i = 0;
+ }
+ break;
+ }
+
names[i] = p;
for ( ; *p; p++) {
if (*p == '.') *p++ = '/'; /* dot to slash translation */
@@ -119,6 +135,8 @@
}
}
}
+ if (i < 1)
+ continue; /* exceptional condition */
nxp = i;
if (debug) {
for (i = 0; i < nxp; i++)
@@ -126,7 +144,7 @@
i, names[i]);
}
- if(syncfiles) fd = open(names[0], O_RDWR);
+ if (syncfiles) fd = open(names[0], O_RDWR);
for (i = 1; i < nxp; i++) {
lnval = link(names[0], names[i]) ;
@@ -217,7 +235,8 @@
STATIC NORETURN
Usage()
{
- (void)fprintf(stderr, "usage: crosspost [-D dir] [files...]\n");
+ (void)fprintf(stderr,
+ "usage: crosspost [-d] [-D dir] [-m max] [-s] [-u] [files...]\n");
exit(1);
}
@@ -235,7 +254,7 @@
(void)umask(NEWSUMASK);
/* Parse JCL. */
- while ((i = getopt(ac, av, "D:ds")) != EOF)
+ while ((i = getopt(ac, av, "D:dm:su")) != EOF)
switch (i) {
default:
Usage();
@@ -246,8 +265,18 @@
case 'd':
debug = TRUE;
break;
+ case 'm':
+ if (atoi(optarg) > 0)
+ maxxpost = atoi(optarg); /* max number of crossposts */
+ else
+ (void)fprintf(stderr, "invalid max number of crossposts: %d\n",
+ atoi(optarg));
+ break;
case 's':
syncfiles = FALSE; /* do not fsync articles */
+ break;
+ case 'u':
+ xunlink = TRUE; /* unlink article if > maxxpost */
break;
}
ac -= optind;
--- crosspost.8.DIST Fri Jan 3 12:08:44 1997
+++ crosspost.8 Tue Feb 11 23:03:45 1997
@@ -5,12 +5,21 @@
.SH SYNOPSIS
.B crosspost
[
+.B \-d
+]
+[
.BI \-D " dir"
]
[
+.BI \-m " max"
+]
+[
.B \-s
]
[
+.B \-u
+]
+[
.I file...
]
.SH DESCRIPTION
@@ -67,17 +76,31 @@
.RE
.sp
(where the -F is followed by a tab character.)
-.PP
+.SH OPTIONS
+.TP
+.B \-d
+Print debugging information to ``stderr''.
+.TP
+.B \-D
The ``\-D'' flag can be used to specify where the article spool is stored.
The default directory is
.\" =()<.IR @<_PATH_SPOOL>@ .>()=
.IR /var/spool/news .
-.PP
+.TP
+.B \-m
+Sets the maximum number of crossposts allowed to the specified
+number. The default is 256.
+.TP
+.B \-s
By default
.I crosspost
will fsync(2) each article after updating the links. The ``\-s'' flag
can be used
to prevent this.
+.TP
+.B \-u
+The ``\-u'' flag will cause any article with more than the maximum
+allowed number of crossposts to be unlinked.
.SH HISTORY
Written by Jerry Aguirre <jerry@ATC.Olivetti.Com>.
.SH "SEE ALSO"
--
Todd C. Miller Sysadmin/Consultant Todd.Miller@courtesan.com
Technical Details
Message-ID:
<5jtkre$rs3$1@xyzzy.home.courtesan.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-mailReferences:
<3360015a.28819979@news.azlink.com>Show Full Headers
Complete Article Headers
Message-ID: <5jtkre$rs3$1@xyzzy.home.courtesan.com> Subject: Re: Limit crossposting to X amount (expire or channel)? & Expire Questions Date: Sat, 26 Apr 1997 00:00:00 +0000 From: Todd C Miller <millert@courtesan.com> References: <3360015a.28819979@news.azlink.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-mail X-Deja-AN: 237567604 Distribution: inet Sender: millert@home.courtesan.com Organization: Courtesan Consulting Reply-To: millert@courtesan.com (Todd C Miller) Newsgroups: news.software.nntp X-Newsposter: Pnews 4.0-test45 (19 Oct 96)