summaryrefslogtreecommitdiff
path: root/news/nn/files/patch-an
blob: 409d93cf78169aa81fc4122a652bb86146b4cefe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
--- nntp.c.orig	Tue Oct  9 11:39:11 2001
+++ nntp.c	Fri Dec  7 07:10:29 2001
@@ -37,6 +37,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <ctype.h>
+#include <sys/param.h>
 
 #ifdef NOV
 #include "hash.h"
@@ -88,6 +89,7 @@
 static void debug_msg __APROTO((char *prefix, char *str));
 static void io_error __APROTO((void));
 static void find_server __APROTO((void));
+char * find_domain(char *domainFile);
 static int get_server_line __APROTO((char *string, int size));
 static int get_server __APROTO((char *string, int size));
 static int get_socket __APROTO((void));
@@ -319,6 +321,49 @@
 }
 
 /*
+ * find_domain		Get the domain name for posting from a named file.
+ *			Handle blank lines and comments.
+ *
+ *	Parameters:	"file" is the name of the file to read.
+ *
+ *	Returns:	Pointer to static data area containing the
+ *			first non-blank/comment line in the file.
+ *			NULL on error (or lack of entry in file).
+ *
+ *	Side effects:	None.
+ */
+
+char *
+find_domain(domainFile)
+char	*domainFile;
+{
+	register FILE	*fp;
+	register char	*cp;
+	static char	buf[MAXHOSTNAMELEN];
+	char		*index();
+
+	if (domainFile == NULL)
+		return (NULL);
+
+	fp = fopen(domainFile, "r");
+	if (fp == NULL)
+		return (NULL);
+
+	while (fgets(buf, sizeof (buf), fp) != NULL) {
+		if (*buf == '\n' || *buf == '#')
+			continue;
+		cp = index(buf, '\n');
+		if (cp)
+			*cp = '\0';
+		(void) fclose(fp);
+		return (buf);
+	}
+
+	(void) fclose(fp);
+	return (NULL);
+}
+
+/*
  * get_server_line: get a line from the server.
  *
  *	Expects to be connected to the server.
@@ -1726,7 +1771,7 @@
  * Phil Lapsley <phil@ucbvax.berkeley.edu>
  */
 
-static char    host_name[256];
+static char    host_name[MAXHOSTNAMELEN];
 
 /*
  * gen_frompath -- generate From: and Path: lines, in the form
@@ -1745,6 +1790,7 @@
 #ifndef HIDDENNET
 	char	*cp;
 #endif
+	char	*domain;
 
 	fprintf(nntp_out, "From: ");
 	passwd = getpwuid(getuid());
@@ -1772,9 +1818,15 @@
 			DOMAIN);
 #endif /* HIDDENNET */
 #else
-	fprintf(nntp_out, "<%s@%s>\r\n",
-		passwd->pw_name,
-		host_name);
+	domain = find_domain(DOMAIN_FILE);
+	if (domain == NULL)
+		fprintf(nntp_out, "From: <%s@%s>\r\n",
+			passwd->pw_name,
+			host_name);
+	else
+		fprintf(nntp_out, "From: <%s@%s>\r\n",
+			passwd->pw_name,
+			domain);
 #endif
 
 #ifdef HIDDENNET