Debian Codegraph @

debian/patches/recommend_ID

raw
1 Purpose: Make the server tell the client a recommended Message-ID before POST.
2
3 Reasoning: Many clients need to know the Message-IDs of their own
4 postings for bookkeeping or other purposes, so they generate them
5 themselves. But the better place for devising Message-IDs is the
6 server to guarantee unambiguity. This is a simple NNTP protocol
7 extension: in the 340 response to POST, the server gives a recommended
8 Message-ID. It can be recognized by the <...@...> syntax.
9 To utilize this feature, we need better clients, of course.
10
11 Patch against: snapshot 19981013
12
13 --- inn-1.7.2.orig/nnrpd/post.c
14 +++ inn-1.7.2/nnrpd/post.c
15 @@ -306,8 +309,9 @@
16 ** Return NULL if okay, or an error message.
17 */
18 STATIC STRING
19 -ProcessHeaders(linecount)
20 +ProcessHeaders(linecount, idbuff)
21 int linecount;
22 + char *idbuff;
23 {
24 static char MONTHS[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
25 static char datebuff[40];
26 @@ -394,12 +399,7 @@
27
28 /* Set Message-ID */
29 if (HDR(_messageid) == NULL) {
30 - if ((p = GenerateMessageID()) == NULL) {
31 - (void)sprintf(Error, "Can't generate Message-ID, %s",
32 - strerror(errno));
33 - return Error;
34 - }
35 - HDR(_messageid) = p;
36 + HDR(_messageid) = COPY(idbuff); /* XXX leak? valgrind says no */
37 }
38
39 /* Set Path */
40 @@ -846,7 +853,7 @@
41 if ((error = CheckIncludedText(article, i)) != NULL)
42 return error;
43 #endif /* defined(DO_CHECK_INCLUDED_TEXT) */
44 - if ((error = ProcessHeaders(i)) != NULL)
45 + if ((error = ProcessHeaders(i, idbuff)) != NULL)
46 return error;
47 if (i == 0 && HDR(_control) == NULL)
48 return "Article is empty";
49 --- inn-1.7.2.orig/nnrpd/commands.c
50 +++ inn-1.7.2/nnrpd/commands.c
51 @@ -567,12 +567,15 @@
52 size = 4096;
53 article = NEW(char, size);
54 }
55 + idbuff[0] = 0;
56 + if ((p = GenerateMessageID()) != NULL)
57 + strcpy(idbuff, p);
58 + Reply("%d Ok, recommended ID %s\r\n", NNTP_START_POST_VAL, idbuff);
59 + (void)fflush(stdout);
60 +
61 p = article;
62 end = &article[size];
63
64 - Reply("%d Ok\r\n", NNTP_START_POST_VAL);
65 - (void)fflush(stdout);
66 -
67 for (l = 0, longline = 0; ; l++) {
68 /* Need more room? */
69 if (end - p < ART_LINE_MALLOC) {
70 @@ -638,7 +641,7 @@
71 response = ARTpost(article, idbuff);
72 if (response == NULL) {
73 syslog(L_NOTICE, "%s post ok %s", ClientHost, idbuff);
74 - Reply("%s\r\n", NNTP_POSTEDOK);
75 + Reply("%s %s\r\n", NNTP_POSTEDOK, idbuff);
76 POSTreceived++;
77 }
78 else {