INN commit: branches/2.5 (innd/Makefile innd/nc.c lib/Makefile)
INN Commit
rra at isc.org
Sun Nov 15 09:20:46 UTC 2009
Date: Sunday, November 15, 2009 @ 01:20:46
Author: iulius
Revision: 8762
Add support for the third wildmat argument to LIST commands.
Also check that the output does not contain a dot
on a single line.
Modified:
branches/2.5/innd/Makefile
branches/2.5/innd/nc.c
branches/2.5/lib/Makefile
---------------+
innd/Makefile | 14 +++++-----
innd/nc.c | 78 ++++++++++++++++++++++++++++++++++++++++++--------------
lib/Makefile | 6 +++-
3 files changed, 71 insertions(+), 27 deletions(-)
Modified: innd/Makefile
===================================================================
--- innd/Makefile 2009-11-15 09:20:34 UTC (rev 8761)
+++ innd/Makefile 2009-11-15 09:20:46 UTC (rev 8762)
@@ -154,13 +154,13 @@
nc.o: nc.c ../include/config.h ../include/inn/defines.h \
../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
../include/config.h ../include/inn/innconf.h ../include/inn/defines.h \
- ../include/inn/version.h innd.h ../include/portable/time.h \
- ../include/config.h ../include/portable/socket.h \
- ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
- ../include/inn/buffer.h ../include/inn/history.h \
- ../include/inn/messages.h ../include/inn/timer.h \
- ../include/inn/libinn.h ../include/nntp.h ../include/inn/nntp.h \
- ../include/inn/paths.h ../include/inn/storage.h \
+ ../include/inn/qio.h ../include/inn/version.h innd.h \
+ ../include/portable/time.h ../include/config.h \
+ ../include/portable/socket.h ../include/portable/getaddrinfo.h \
+ ../include/portable/getnameinfo.h ../include/inn/buffer.h \
+ ../include/inn/history.h ../include/inn/messages.h \
+ ../include/inn/timer.h ../include/inn/libinn.h ../include/nntp.h \
+ ../include/inn/nntp.h ../include/inn/paths.h ../include/inn/storage.h \
../include/inn/options.h
newsfeeds.o: newsfeeds.c ../include/config.h ../include/inn/defines.h \
../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
Modified: innd/nc.c
===================================================================
--- innd/nc.c 2009-11-15 09:20:34 UTC (rev 8761)
+++ innd/nc.c 2009-11-15 09:20:46 UTC (rev 8762)
@@ -8,6 +8,7 @@
#include "clibrary.h"
#include "inn/innconf.h"
+#include "inn/qio.h"
#include "inn/version.h"
#include "innd.h"
@@ -67,7 +68,7 @@
COMMAND("IHAVE", NCihave, true, 2, 2,
"message-ID"),
COMMAND("LIST", NClist, true, 1, 3,
- "[ACTIVE|ACTIVE.TIMES|NEWSGROUPS]"),
+ "[ACTIVE|ACTIVE.TIMES|NEWSGROUPS [wildmat]]"),
COMMAND("MODE", NCmode, false, 2, 2,
"READER"),
COMMAND("QUIT", NCquit, false, 1, 1,
@@ -671,8 +672,10 @@
static void
NClist(CHANNEL *cp, int ac, char *av[])
{
- char *p, *q, *end, *path;
- char *buff = NULL;
+ QIOSTATE *qp;
+ char *p, *path, *save;
+ char savec;
+ char *buff = NULL;
cp->Start = cp->Next;
@@ -689,18 +692,26 @@
/* ACTIVE when no argument given. */
if (ac == 1 || (strcasecmp(av[1], "ACTIVE") == 0)) {
- p = ICDreadactive(&end);
- /* We always have a valid return from ICDreadactive.
- * Otherwise, innd is shut down. */
- xasprintf(&buff, "%d Newsgroups in form \"group high low flags\"",
- NNTP_OK_LIST);
- NCwritereply(cp, buff);
- free(buff);
+ path = concatpath(innconf->pathdb, INN_PATH_ACTIVE);
+ qp = QIOopen(path);
+ free(path);
+ if (qp == NULL) {
+ xasprintf(&buff, "%d No list of active newsgroups available",
+ NNTP_ERR_UNAVAILABLE);
+ NCwritereply(cp, buff);
+ free(buff);
+ return;
+ } else {
+ xasprintf(&buff, "%d Newsgroups in form \"group high low flags\"",
+ NNTP_OK_LIST);
+ NCwritereply(cp, buff);
+ free(buff);
+ }
} else if (strcasecmp(av[1], "NEWSGROUPS") == 0) {
path = concatpath(innconf->pathdb, INN_PATH_NEWSGROUPS);
- p = ReadInFile(path, NULL);
+ qp = QIOopen(path);
free(path);
- if (p == NULL) {
+ if (qp == NULL) {
xasprintf(&buff, "%d No list of newsgroup descriptions available",
NNTP_ERR_UNAVAILABLE);
NCwritereply(cp, buff);
@@ -712,12 +723,11 @@
NCwritereply(cp, buff);
free(buff);
}
- end = p + strlen(p);
} else if (strcasecmp(av[1], "ACTIVE.TIMES") == 0) {
path = concatpath(innconf->pathdb, INN_PATH_ACTIVETIMES);
- p = ReadInFile(path, NULL);
+ qp = QIOopen(path);
free(path);
- if (p == NULL) {
+ if (qp == NULL) {
xasprintf(&buff, "%d No list of creation times available",
NNTP_ERR_UNAVAILABLE);
NCwritereply(cp, buff);
@@ -729,7 +739,6 @@
NCwritereply(cp, buff);
free(buff);
}
- end = p + strlen(p);
} else {
xasprintf(&buff, "%d Unknown LIST keyword", NNTP_ERR_SYNTAX);
NCwritereply(cp, buff);
@@ -738,10 +747,41 @@
}
/* Loop over all lines, sending the text and "\r\n". */
- for (; p < end && (q = strchr(p, '\n')) != NULL; p = q + 1) {
- WCHANappend(cp, p, q - p);
- WCHANappend(cp, NCterm, strlen(NCterm));
+ while ((p = QIOread(qp)) != NULL) {
+ /* Check that the output does not break the NNTP protocol. */
+ if (p[0] == '.' && p[1] == '\0') {
+ syslog(L_ERROR, "%s NClist single dot in file %s",
+ CHANname(cp), av[1]);
+ continue;
+ }
+
+ /* Check whether the newsgroup matches the wildmat pattern,
+ * if given. */
+ if (ac == 3) {
+ savec = '\0';
+ for (save = p; *save != '\0'; save++) {
+ if (*save == ' ' || *save == '\t') {
+ savec = *save;
+ *save = '\0';
+ break;
+ }
+ }
+
+ if (!uwildmat(p, av[2]))
+ continue;
+
+ if (savec != '\0')
+ *save = savec;
+ }
+
+ /* Write the line. */
+ WCHANappend(cp, p, strlen(p));
+ WCHANappend(cp, NCterm, strlen(NCterm));
}
+
+ QIOclose(qp);
+
+ /* Write the terminator. */
NCwritereply(cp, NCdot);
}
Modified: lib/Makefile
===================================================================
--- lib/Makefile 2009-11-15 09:20:34 UTC (rev 8761)
+++ lib/Makefile 2009-11-15 09:20:46 UTC (rev 8762)
@@ -88,6 +88,10 @@
../include/inn/defines.h: ../include/inn/system.h
# DO NOT DELETE THIS LINE -- make depend depends on it.
+argparse.o: argparse.c ../include/config.h ../include/inn/defines.h \
+ ../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
+ ../include/config.h ../include/inn/innconf.h ../include/inn/defines.h \
+ ../include/inn/libinn.h
buffer.o: buffer.c ../include/config.h ../include/inn/defines.h \
../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
../include/config.h ../include/inn/buffer.h ../include/inn/defines.h \
@@ -202,7 +206,7 @@
messageid.o: messageid.c ../include/config.h ../include/inn/defines.h \
../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
../include/config.h ../include/inn/innconf.h ../include/inn/defines.h \
- ../include/inn/libinn.h
+ ../include/inn/libinn.h ../include/inn/nntp.h
messages.o: messages.c ../include/config.h ../include/inn/defines.h \
../include/inn/system.h ../include/inn/options.h ../include/clibrary.h \
../include/config.h ../include/inn/messages.h ../include/inn/defines.h \
More information about the inn-committers
mailing list