INN commit: trunk/nnrpd (7 files)
INN Commit
Russ_Allbery at isc.org
Wed Sep 17 20:03:40 UTC 2008
Date: Wednesday, September 17, 2008 @ 13:03:40
Author: iulius
Revision: 8032
Use Reply() and Printf() at the right moment!
Reply() can be traced (response codes) whereas Printf() can not.
Modified:
trunk/nnrpd/article.c
trunk/nnrpd/commands.c
trunk/nnrpd/group.c
trunk/nnrpd/list.c
trunk/nnrpd/nnrpd.c
trunk/nnrpd/nnrpd.h
trunk/nnrpd/perm.c
------------+
article.c | 12 ++++++------
commands.c | 2 +-
group.c | 10 +++++-----
list.c | 8 ++++----
nnrpd.c | 14 ++++++++------
nnrpd.h | 56 ++++++++++++++++++++++++++++----------------------------
perm.c | 4 ++--
7 files changed, 54 insertions(+), 52 deletions(-)
Modified: article.c
===================================================================
--- article.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ article.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -939,7 +939,7 @@
Reply("%d Current article number %d is invalid\r\n",
xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
if (xover)
- Reply(".\r\n");
+ Printf(".\r\n");
return;
}
if (PERMaccessconf->nnrpdoverstats) {
@@ -1037,7 +1037,7 @@
Reply("%d Current article number %d is invalid\r\n",
xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
if (xover)
- Reply(".\r\n");
+ Printf(".\r\n");
} else {
if(useIOb) {
SendIOb(".\r\n", 3);
@@ -1148,7 +1148,7 @@
if (mid) {
p = av[2];
if (!ARTopenbyid(p, &artnum, false)) {
- Printf("%d No such article\r\n", NNTP_FAIL_NOTFOUND);
+ Reply("%d No such article\r\n", NNTP_FAIL_NOTFOUND);
break;
}
@@ -1165,7 +1165,7 @@
break;
}
- Printf("%d Header information for %s follows (from the article)\r\n",
+ Reply("%d Header information for %s follows (from the article)\r\n",
hdr ? NNTP_OK_HDR : NNTP_OK_HEAD, av[1]);
if ((text = GetHeader(av[1])) != NULL
@@ -1232,7 +1232,7 @@
} else {
Reply("%d No header information for %s follows (from articles)\r\n",
NNTP_OK_HEAD, av[1]);
- Reply(".\r\n");
+ Printf(".\r\n");
}
break;
} else {
@@ -1308,7 +1308,7 @@
} else {
Reply("%d No header or metadata information for %s follows (from overview)\r\n",
NNTP_OK_HEAD, av[1]);
- Reply(".\r\n");
+ Printf(".\r\n");
}
break;
} else {
Modified: commands.c
===================================================================
--- commands.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ commands.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -643,7 +643,7 @@
if (longline) {
warn("%s too long in post", Client.host);
- Printf("%d Line %d too long\r\n",
+ Reply("%d Line %d too long\r\n",
ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_POST_REJECT, longline);
POSTrejected++;
return;
Modified: group.c
===================================================================
--- group.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ group.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -37,7 +37,7 @@
/* Parse arguments. */
if (ac == 1) {
if (GRPcur == NULL) {
- Printf("%d No group specified\r\n", NNTP_FAIL_NO_GROUP);
+ Reply("%d No group specified\r\n", NNTP_FAIL_NO_GROUP);
return;
} else {
group = xstrdup(GRPcur);
@@ -263,7 +263,7 @@
/* Parse the arguments. */
if (ac == 1) {
if (GRPcount == 0) {
- Printf("%d No group specified\r\n", NNTP_FAIL_XGTITLE);
+ Reply("%d No group specified\r\n", NNTP_FAIL_XGTITLE);
return;
}
p = GRPcur;
@@ -272,7 +272,7 @@
p = av[1];
if (!PERMspecified) {
- Printf("%d No descriptions follow\r\n", NNTP_OK_XGTITLE);
+ Reply("%d No descriptions follow\r\n", NNTP_OK_XGTITLE);
Printf(".\r\n");
return;
}
@@ -280,10 +280,10 @@
/* Open the file, get ready to scan. */
if ((qp = QIOopen(NEWSGROUPS)) == NULL) {
syslog(L_ERROR, "%s can't open %s %m", Client.host, NEWSGROUPS);
- Printf("%d Can't open %s\r\n", NNTP_FAIL_XGTITLE, NEWSGROUPS);
+ Reply("%d Can't open %s\r\n", NNTP_FAIL_XGTITLE, NEWSGROUPS);
return;
}
- Printf("%d Descriptions in form \"group description\"\r\n", NNTP_OK_XGTITLE);
+ Reply("%d Descriptions in form \"group description\"\r\n", NNTP_OK_XGTITLE);
/* Print all lines with matching newsgroup name. */
while ((line = QIOread(qp)) != NULL) {
Modified: list.c
===================================================================
--- list.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ list.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -155,14 +155,14 @@
return;
}
Reply("%d %s\r\n", NNTP_OK_LIST, lp->Format);
- Reply(":\r\n");
+ Printf(":\r\n");
if (range) {
/* These information are only known by the overview system,
* and are only accessible with a range. */
- Reply(":bytes\r\n");
- Reply(":lines\r\n");
+ Printf(":bytes\r\n");
+ Printf(":lines\r\n");
}
- Reply(".\r\n");
+ Printf(".\r\n");
}
Modified: nnrpd.c
===================================================================
--- nnrpd.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ nnrpd.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -322,7 +322,7 @@
Printf("Report problems to <%s>.\r\n",
newsmaster);
}
- Reply(".\r\n");
+ Printf(".\r\n");
}
@@ -420,7 +420,7 @@
if (getpeername(STDIN_FILENO, sac, &length) < 0) {
if (!isatty(STDIN_FILENO)) {
sysnotice("? can't getpeername");
- Printf("%d Can't get your name. Goodbye!\r\n", NNTP_ERR_ACCESS);
+ Reply("%d Can't get your name. Goodbye!\r\n", NNTP_ERR_ACCESS);
ExitWithStats(1, true);
}
strlcpy(Client.host, "stdin", sizeof(Client.host));
@@ -429,7 +429,7 @@
HostErrorStr = default_host_error;
if (!network_sockaddr_sprint(Client.ip, sizeof(Client.ip), sac)) {
notice("? can't get client numeric address: %s", HostErrorStr);
- Printf("%d Can't get your numeric address. Goodbye!\r\n",
+ Reply("%d Can't get your numeric address. Goodbye!\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, true);
}
@@ -448,7 +448,7 @@
length = sizeof(sss);
if (getsockname(STDIN_FILENO, sas, &length) < 0) {
sysnotice("%s can't getsockname", Client.host);
- Printf("%d Can't figure out where you connected to. Goodbye!\r\n",
+ Reply("%d Can't figure out where you connected to. Goodbye!\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, true);
}
@@ -456,7 +456,7 @@
size = sizeof(Client.serverip);
if (!network_sockaddr_sprint(Client.serverip, size, sas)) {
notice("? can't get server numeric address: %s", HostErrorStr);
- Printf("%d Can't get my own numeric address. Goodbye!\r\n",
+ Reply("%d Can't get my own numeric address. Goodbye!\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, true);
}
@@ -586,6 +586,8 @@
/*
** Send a reply, possibly with debugging output.
+** Reply() is used for answers which can possibly be traced (response codes).
+** Printf() is used in other cases.
*/
void
Reply(const char *fmt, ...)
@@ -1003,7 +1005,7 @@
StartConnection();
if (!PERMcanread && !PERMcanpost && !PERMneedauth) {
syslog(L_NOTICE, "%s no_permission", Client.host);
- Printf("%d You have no permission to talk. Goodbye!\r\n",
+ Reply("%d You have no permission to talk. Goodbye!\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, false);
}
Modified: nnrpd.h
===================================================================
--- nnrpd.h 2008-09-17 19:55:23 UTC (rev 8031)
+++ nnrpd.h 2008-09-17 20:03:40 UTC (rev 8032)
@@ -1,6 +1,6 @@
/* $Id$
**
-** Net News Reading Protocol server.
+** NetNews Reading Protocol server.
*/
#include "config.h"
@@ -35,8 +35,8 @@
} ARTRANGE;
/*
-** access configuration for each readers
- */
+** Access configuration for each reader.
+*/
typedef struct _ACCESSGROUP {
char *name;
char *key;
@@ -95,7 +95,7 @@
/*
-** Structure used by line_read to keep track of what's been read
+** Structure used by line_read to keep track of what has been read.
*/
struct line {
char *start;
@@ -135,11 +135,11 @@
*/
enum timer {
TMR_IDLE = TMR_APPLICATION, /* Server is completely idle. */
- TMR_NEWNEWS, /* Executing NEWNEWS command */
- TMR_READART, /* Reading an article (SMretrieve) */
- TMR_CHECKART, /* Checking an article (ARTinstorebytoken) */
- TMR_NNTPREAD, /* Reading from the peer */
- TMR_NNTPWRITE, /* Writing to the peer */
+ TMR_NEWNEWS, /* Executing NEWNEWS command. */
+ TMR_READART, /* Reading an article (SMretrieve). */
+ TMR_CHECKART, /* Checking an article (ARTinstorebytoken). */
+ TMR_NNTPREAD, /* Reading from the peer. */
+ TMR_NNTPWRITE, /* Writing to the peer. */
TMR_MAX
};
@@ -174,23 +174,23 @@
extern char *NNRPACCESS;
EXTERN char PERMuser[SMBUF];
EXTERN FILE *locallog;
-EXTERN ARTNUM ARTnumber; /* Current article number */
-EXTERN ARTNUM ARThigh; /* Current high number for group */
-EXTERN ARTNUM ARTlow; /* Current low number for group */
-EXTERN unsigned long ARTcount; /* Number of articles in group */
-EXTERN long MaxBytesPerSecond; /* maximum bytes per sec a client can use, defaults to 0 */
+EXTERN ARTNUM ARTnumber; /* Current article number. */
+EXTERN ARTNUM ARThigh; /* Current high number for group. */
+EXTERN ARTNUM ARTlow; /* Current low number for group. */
+EXTERN unsigned long ARTcount; /* Number of articles in group. */
+EXTERN long MaxBytesPerSecond; /* Maximum bytes per sec a client can use, defaults to 0. */
EXTERN long ARTget;
EXTERN long ARTgettime;
EXTERN long ARTgetsize;
-EXTERN long OVERcount; /* number of (X)OVER commands */
-EXTERN long OVERhit; /* number of (X)OVER records found in .overview */
-EXTERN long OVERmiss; /* number of (X)OVER records found in articles */
-EXTERN long OVERtime; /* number of ms spent sending (X)OVER data */
-EXTERN long OVERsize; /* number of bytes of (X)OVER data sent */
-EXTERN long OVERdbz; /* number of ms spent reading dbz data */
-EXTERN long OVERseek; /* number of ms spent seeking history */
-EXTERN long OVERget; /* number of ms spent reading history */
-EXTERN long OVERartcheck; /* number of ms spent article check */
+EXTERN long OVERcount; /* Number of (X)OVER commands. */
+EXTERN long OVERhit; /* Number of (X)OVER records found in overview. */
+EXTERN long OVERmiss; /* Number of (X)OVER records found in articles. */
+EXTERN long OVERtime; /* Number of ms spent sending (X)OVER data. */
+EXTERN long OVERsize; /* Number of bytes of (X)OVER data sent. */
+EXTERN long OVERdbz; /* Number of ms spent reading dbz data. */
+EXTERN long OVERseek; /* Number of ms spent seeking history. */
+EXTERN long OVERget; /* Number of ms spent reading history. */
+EXTERN long OVERartcheck; /* Number of ms spent article check. */
EXTERN double IDLEtime;
EXTERN unsigned long GRParticles;
EXTERN long GRPcount;
@@ -254,9 +254,11 @@
#endif
-/* Run a resolver or authenticator. The directory is where to look for the
- command if not fully qualified. username and password may be NULL to run
- resolvers. */
+/*
+** Run a resolver or authenticator. The directory is where to look for the
+** command if not fully qualified. username and password may be NULL to run
+** resolvers.
+*/
char *auth_external(struct client *, const char *command,
const char *directory, const char *username,
const char *password);
@@ -290,8 +292,6 @@
READTYPE line_read(struct line *, int, const char **, size_t *, size_t *);
#ifdef HAVE_SASL
-#include <sasl/sasl.h>
-
extern sasl_conn_t *sasl_conn;
extern int sasl_ssf, sasl_maxout;
extern sasl_callback_t sasl_callbacks[];
Modified: perm.c
===================================================================
--- perm.c 2008-09-17 19:55:23 UTC (rev 8031)
+++ perm.c 2008-09-17 20:03:40 UTC (rev 8032)
@@ -1401,7 +1401,7 @@
if (auth_realms == NULL) {
/* no one can talk, empty file */
syslog(L_NOTICE, "%s no_permission", Client.host);
- Printf("%d You have no permission to talk. Goodbye.\r\n",
+ Reply("%d You have no permission to talk. Goodbye.\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, true);
}
@@ -1440,7 +1440,7 @@
} else if (!PERMcanauthenticate) {
/* Couldn't resolve the user. */
syslog(L_NOTICE, "%s no_user", Client.host);
- Printf("%d Could not get your access name. Goodbye!\r\n",
+ Reply("%d Could not get your access name. Goodbye!\r\n",
NNTP_ERR_ACCESS);
ExitWithStats(1, true);
} else {
More information about the inn-committers
mailing list