INN commit: branches/2.5/nnrpd (article.c commands.c)
INN Commit
rra at isc.org
Fri Jan 22 23:35:12 UTC 2010
Date: Friday, January 22, 2010 @ 15:35:12
Author: iulius
Revision: 8923
Check whether a newsgroup has been selected, before asking
for authentication.
Answer to retry later when POST is not allowed due to backoff
limits.
Modified:
branches/2.5/nnrpd/article.c
branches/2.5/nnrpd/commands.c
------------+
article.c | 59 ++++++++++++++++++++++++++++---------------------------
commands.c | 63 +++++++++++++++++++++++++++--------------------------------
2 files changed, 59 insertions(+), 63 deletions(-)
Modified: article.c
===================================================================
--- article.c 2010-01-22 23:33:44 UTC (rev 8922)
+++ article.c 2010-01-22 23:35:12 UTC (rev 8923)
@@ -651,6 +651,12 @@
break;
}
+ /* Trying to read. */
+ if (GRPcount == 0 && !mid) {
+ Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
+ return;
+ }
+
/* Check authorizations. If an article number is requested
* (not a message-ID), we check whether the group is still readable. */
if (!ok || (!mid && PERMgroupmadeinvalid)) {
@@ -680,12 +686,6 @@
return;
}
- /* Trying to read. */
- if (GRPcount == 0) {
- Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
- return;
- }
-
/* Default is to get current article, or specified article. */
if (ac == 1) {
if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
@@ -733,6 +733,12 @@
bool next;
const char *message;
+ /* Trying to read. */
+ if (GRPcount == 0) {
+ Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
+ return;
+ }
+
/* No syntax to check. Only check authorizations. */
if (!PERMcanread || PERMgroupmadeinvalid) {
Reply("%d Read access denied\r\n",
@@ -740,11 +746,6 @@
return;
}
- /* Trying to read. */
- if (GRPcount == 0) {
- Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
- return;
- }
if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
Reply("%d Current article number %lu is invalid\r\n",
NNTP_FAIL_ARTNUM_INVALID, ARTnumber);
@@ -933,6 +934,12 @@
}
}
+ /* Trying to read. */
+ if (GRPcount == 0) {
+ Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
+ return;
+ }
+
/* Check authorizations. If a range is requested (not a message-ID),
* we check whether the group is still readable. */
if (!PERMcanread || (!mid && PERMgroupmadeinvalid)) {
@@ -941,12 +948,6 @@
return;
}
- /* Trying to read. */
- if (GRPcount == 0) {
- Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
- return;
- }
-
/* Parse range. CMDgetrange() correctly sets the range when
* there is no arguments. */
if (!CMDgetrange(ac, av, &range, &DidReply))
@@ -1174,6 +1175,12 @@
}
}
+ /* Trying to read. */
+ if (GRPcount == 0 && !mid) {
+ Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
+ return;
+ }
+
/* Check authorizations. If a range is requested (not a message-ID),
* we check whether the group is still readable. */
if (!PERMcanread || (!mid && PERMgroupmadeinvalid)) {
@@ -1191,12 +1198,6 @@
do {
/* Message-ID specified? */
if (mid) {
- p = av[2];
- if (!ARTopenbyid(p, &artnum, false)) {
- Reply("%d No such article\r\n", NNTP_FAIL_MSGID_NOTFOUND);
- break;
- }
-
/* FIXME: We do not handle metadata requests by message-ID. */
if (hdr && (IsMetaBytes || IsMetaLines)) {
Reply("%d Metadata requests by message-ID unsupported\r\n",
@@ -1204,6 +1205,12 @@
break;
}
+ p = av[2];
+ if (!ARTopenbyid(p, &artnum, false)) {
+ Reply("%d No such article\r\n", NNTP_FAIL_MSGID_NOTFOUND);
+ break;
+ }
+
if (!PERMartok()) {
ARTclose();
Reply("%d Read access denied for this article\r\n",
@@ -1227,12 +1234,6 @@
break;
}
- /* Trying to read. */
- if (GRPcount == 0) {
- Reply("%d Not in a newsgroup\r\n", NNTP_FAIL_NO_GROUP);
- break;
- }
-
/* Parse range. CMDgetrange() correctly sets the range when
* there is no arguments. */
if (!CMDgetrange(ac - 1, av + 1, &range, &DidReply))
Modified: commands.c
===================================================================
--- commands.c 2010-01-22 23:33:44 UTC (rev 8922)
+++ commands.c 2010-01-22 23:35:12 UTC (rev 8923)
@@ -628,45 +628,40 @@
backoff_inited = true;
}
- /* Dave's posting limiter. Limit postings to a certain rate
+ /* Dave's posting limiter. Limit postings to a certain rate.
* And now we support multiprocess rate limits. Questions?
- * E-mail <dave at jetcafe.org>.
- */
+ * E-mail <dave at jetcafe.org>. */
if (BACKOFFenabled) {
-
- /* Acquire lock (this could be in RateLimit but that would
- * invoke the spaghetti factor).
- */
- if ((path = (char *) PostRecFilename(Client.ip, PERMuser)) == NULL) {
- Reply("%d %s\r\n", ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH,
- ihave ? "Retry later" : "Posting not allowed");
- return;
- }
+ /* Acquire lock (this could be in RateLimit but that would
+ * invoke the spaghetti factor). */
+ if ((path = (char *) PostRecFilename(Client.ip, PERMuser)) == NULL) {
+ Reply("%d Retry later\r\n",
+ ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH);
+ return;
+ }
- if (LockPostRec(path) == 0) {
- syslog(L_ERROR, "%s error write locking '%s'",
- Client.host, path);
- Reply("%d %s\r\n", ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH,
- ihave ? "Retry later" : "Posting not allowed");
- return;
- }
+ if (LockPostRec(path) == 0) {
+ syslog(L_ERROR, "%s error write locking '%s'",
+ Client.host, path);
+ Reply("%d Retry later\r\n",
+ ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH);
+ return;
+ }
- if (!RateLimit(&sleeptime,path)) {
- syslog(L_ERROR, "%s can't check rate limit info", Client.host);
- Reply("%d %s\r\n", ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH,
- ihave ? "Retry later" : "Posting not allowed");
- UnlockPostRec(path);
- return;
- } else if (sleeptime != 0L) {
- syslog(L_NOTICE,"%s post sleep time is now %ld", Client.host, sleeptime);
- sleep(sleeptime);
- }
+ if (!RateLimit(&sleeptime,path)) {
+ syslog(L_ERROR, "%s can't check rate limit info", Client.host);
+ Reply("%d Retry later\r\n",
+ ihave ? NNTP_FAIL_IHAVE_DEFER : NNTP_FAIL_POST_AUTH);
+ UnlockPostRec(path);
+ return;
+ } else if (sleeptime != 0L) {
+ syslog(L_NOTICE,"%s post sleep time is now %ld", Client.host, sleeptime);
+ sleep(sleeptime);
+ }
- /* Remove the lock here so that only one nnrpd process does the
- * backoff sleep at once. Other procs are sleeping for the lock.
- */
- UnlockPostRec(path);
-
+ /* Remove the lock here so that only one nnrpd process does the
+ * backoff sleep at once. Other procs are sleeping for the lock. */
+ UnlockPostRec(path);
} /* End backoff code. */
/* Start at beginning of buffer. */
More information about the inn-committers
mailing list