summaryrefslogtreecommitdiff
path: root/debian/patches/01-legacy.patch
blob: 91bf0a9f82808b663627552a00508664defee142 (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
--- a/finger/finger.1	2000-07-31 09:56:57.000000000 +1000
+++ b/finger/finger.1	2009-06-10 20:08:45.000000000 +1000
@@ -169,16 +169,14 @@ started by
 must be able to see the
 .Pa .nofinger
 file. This generally means that the home directory containing the file
-must have the other-users-execute bit set (o+w). See
+must have the other-users-execute bit set (o+x). See
 .Xr chmod 1 .
 If you use this feature for privacy, please test it with ``finger
 @localhost'' before relying on it, just in case.
 .It ~/.plan
 .It ~/.project
-.It ~/.pgp
+.It ~/.pgpkey
 These files are printed as part of a long-format request. The
-.Pa .project
-file is limited to one line; the
 .Pa .plan
 file may be arbitrarily long.
 .El
--- a/finger/finger.c	1999-12-19 03:41:51.000000000 +1100
+++ b/finger/finger.c	2009-06-10 20:08:45.000000000 +1000
@@ -77,7 +77,7 @@ char finger_rcsid[] = \
 #include "../version.h"
 
 static void loginlist(void);
-static void userlist(int argc, char *argv[]);
+static int userlist(int argc, char *argv[]);
 
 int lflag, pplan;
 static int sflag, mflag;
@@ -92,6 +92,7 @@ int entries;			/* number of people */
 
 int main(int argc, char *argv[]) {
 	int ch;
+	int err = 0;
 	struct sockaddr_in sin;
 	socklen_t slen = sizeof(sin);
 
@@ -159,7 +160,7 @@ int main(int argc, char *argv[]) {
 		}
 	} 
 	else {
-		userlist(argc, argv);
+		err = userlist(argc, argv);
 		/*
 		 * Assign explicit "large" format if names given and -s not
 		 * explicitly stated.  Force the -l AFTER we get names so any
@@ -172,7 +173,7 @@ int main(int argc, char *argv[]) {
 		if (lflag) lflag_print();
 		else sflag_print();
 	}
-	return 0;
+	return err;
 }
 
 /* Returns 1 if .nofinger is found and enable_nofinger is set. */
@@ -181,10 +182,16 @@ int
 check_nofinger(struct passwd *pw)
 {
 	if (enable_nofinger) {
-		char path[PATH_MAX];
 		struct stat tripe;
-		snprintf(path, sizeof(path), "%s/.nofinger", pw->pw_dir);
-		if (stat(path, &tripe)==0) {
+		int ret;
+		char *path;
+		if (asprintf(&path, "%s/.nofinger", pw->pw_dir) < 0) {
+			eprintf("finger: Out of space.\n");
+			exit(1);
+		}
+		ret = stat(path, &tripe);
+		free(path);
+		if (!ret) {
 			return 1;
 		}
 	}
@@ -264,10 +271,11 @@ static void do_local(int argc, char *arg
 
 }
 
-static void
+static int
 userlist(int argc, char *argv[])
 {
 	int i;
+	int err = 0;
 	PERSON *pn;
 	PERSON *nethead, **nettail;
 	struct utmp *uptr;
@@ -297,13 +305,13 @@ userlist(int argc, char *argv[])
 
 	/* handle network requests */
 	for (pn = nethead; pn; pn = pn->next) {
-		netfinger(pn->name);
+		err |= netfinger(pn->name);
 		if (pn->next || entries)
 			xputc('\n');
 	}
 
 	if (entries == 0)
-		return;
+		return err;
 
 	/*
 	 * Scan thru the list of users currently logged in, saving
@@ -331,4 +339,6 @@ userlist(int argc, char *argv[])
 		enter_lastlog(pn);
 	}
 	endutent();
+
+	return err;
 }
--- a/finger/finger.h	1999-09-14 20:51:11.000000000 +1000
+++ b/finger/finger.h	2009-06-10 20:08:45.000000000 +1000
@@ -92,7 +92,7 @@ void sflag_print(void);
 void enter_where(struct utmp *ut, PERSON *pn);
 void enter_lastlog(PERSON *pn);
 int match(struct passwd *pw, const char *user);
-void netfinger(const char *name);
+int netfinger(const char *name);
 const char *prphone(const char *num);
 
 #ifndef DAYSPERNYEAR
--- a/finger/lprint.c	1999-09-14 20:51:11.000000000 +1000
+++ b/finger/lprint.c	2009-06-10 20:08:45.000000000 +1000
@@ -48,7 +48,7 @@ char lprint_rcsid[] = 
 #include <sys/types.h>
 #include <sys/file.h>
 #include <sys/stat.h>
-#include <sys/time.h>
+#include <time.h>
 #include "finger.h"
 
 static void lprint(PERSON *pn);
@@ -100,7 +100,7 @@ lprint(PERSON *pn)
 	 *	office, office phone, home phone if available
 	 */
 	xprintf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s",
-		pn->name, pn->realname, pn->dir);
+		pn->name, pn->realname ? pn->realname : "", pn->dir);
 	xprintf("\tShell: %-s\n", *pn->shell ? pn->shell : _PATH_BSHELL);
 
 	/*
--- a/finger/net.c	1999-09-14 20:51:11.000000000 +1000
+++ b/finger/net.c	2009-06-10 20:08:45.000000000 +1000
@@ -51,7 +51,7 @@ char net_rcsid[] = "$Id: net.c,v 1.9 199
 #include <ctype.h>
 #include "finger.h"
 
-void netfinger(const char *name) {
+int netfinger(const char *name) {
 	register FILE *fp;
 	struct in_addr defaddr;
 	register int c, sawret, ateol;
@@ -62,7 +62,7 @@ void netfinger(const char *name) {
 	char *alist[1], *host;
 
 	host = strrchr(name, '@');
-	if (!host) return;
+	if (!host) return 1;
 	*host++ = '\0';
 
 	memset(&sn, 0, sizeof(sn));
@@ -70,7 +70,7 @@ void netfinger(const char *name) {
 	sp = getservbyname("finger", "tcp");
 	if (!sp) {
 		eprintf("finger: tcp/finger: unknown service\n");
-		return;
+		return 1;
 	}
 	sn.sin_port = sp->s_port;
 
@@ -78,7 +78,7 @@ void netfinger(const char *name) {
 	if (!hp) {
 		if (!inet_aton(host, &defaddr)) {
 			eprintf("finger: unknown host: %s\n", host);
-			return;
+			return 1;
 		}
 		def.h_name = host;
 		def.h_addr_list = alist;
@@ -96,7 +96,7 @@ void netfinger(const char *name) {
 
 	if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
 		eprintf("finger: socket: %s\n", strerror(errno));
-		return;
+		return 1;
 	}
 
 	/* print hostname before connecting, in case it takes a while */
@@ -104,7 +104,7 @@ void netfinger(const char *name) {
 	if (connect(s, (struct sockaddr *)&sn, sizeof(sn)) < 0) {
 		eprintf("finger: connect: %s\n", strerror(errno));
 		close(s);
-		return;
+		return 1;
 	}
 
 	/* -l flag for remote fingerd  */
@@ -128,7 +128,7 @@ void netfinger(const char *name) {
 	if (!fp) {
 		eprintf("finger: fdopen: %s\n", strerror(errno));
 		close(s);
-		return;
+		return 1;
 	}
 
 	sawret = 0;
@@ -152,4 +152,6 @@ void netfinger(const char *name) {
 	}
 	if (!ateol) xputc('\n');
 	fclose(fp);
+
+	return 0;
 }
--- a/finger/sprint.c	1999-12-13 05:59:33.000000000 +1100
+++ b/finger/sprint.c	2009-06-10 20:08:45.000000000 +1000
@@ -40,7 +40,7 @@ char sprint_rcsid[] = "$Id: sprint.c,v 1
 #endif /* not lint */
 
 #include <sys/types.h>
-#include <sys/time.h>
+#include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
--- a/finger/util.c	1999-09-29 08:53:58.000000000 +1000
+++ b/finger/util.c	2009-06-10 20:08:45.000000000 +1000
@@ -64,7 +64,7 @@ static void find_idle_and_ttywrite(regis
 	struct stat sb;
 
 	/* No device for X console. Utmp entry by XDM login (":0"). */
-	if (w->tty[0] == ':') {
+	if (strchr(w->tty, ':')) {
 		w->idletime = 0;  /* would be nice to have it emit ??? */
 		w->writable = 0;
 		return;
@@ -109,9 +109,8 @@ static void userinfo(PERSON *pn, struct 
 	 * fields[3] -> homephone
 	 */
 	nfields = 0;
-	for (p = strtok(bp, ","); p; p = strtok(NULL, ",")) {
-		if (*p==0) p = NULL;  // skip empties
-		if (nfields < 4) fields[nfields++] = p;
+	while ((p = strsep(&bp, ","))) {
+		if (nfields < 4) fields[nfields++] = *p ? p : NULL;
 	}
 	while (nfields<4) fields[nfields++] = NULL;
 
@@ -150,6 +149,9 @@ static void userinfo(PERSON *pn, struct 
 
 		pn->realname = rname;
 	}
+	else {
+		pn->realname = NULL;
+	}
 
 	pn->office =      fields[1] ? strdup(fields[1]) : NULL;
 	pn->officephone = fields[2] ? strdup(fields[2]) : NULL;
--- a/fingerd/fingerd.8	2000-07-31 09:56:57.000000000 +1000
+++ b/fingerd/fingerd.8	2009-06-10 20:08:45.000000000 +1000
@@ -36,10 +36,10 @@
 .Dt FINGERD 8
 .Os "Linux NetKit (0.17)"
 .Sh NAME
-.Nm fingerd
+.Nm in.fingerd
 .Nd remote user information server
 .Sh SYNOPSIS
-.Nm fingerd
+.Nm in.fingerd
 .Op Fl wulf
 .Op Fl pL Ar path
 .Op Fl t Ar timeout
@@ -61,7 +61,7 @@ option is given, remote users will get a
 banner
 which also shows some informations (e.g. uptime, operating system name and
 release) about the system the
-.Nm fingerd
+.Nm in.fingerd
 is running on. Some sites may consider this a security risk as it
 gives out information that may be useful to crackers. 
 .Pp
@@ -85,7 +85,7 @@ resource reasons.
 .Pp
 The 
 .Fl p
-option allows specification of an alternate location for fingerd to find
+option allows specification of an alternate location for in.fingerd to find
 the 
 .Dq finger
 program. The
@@ -97,7 +97,7 @@ The
 option specifies the time to wait for a request before closing the
 connection.  A value of 0 waits forever.  The default is 60 seconds.
 .Pp
-Options to fingerd should be specified in 
+Options to in.fingerd should be specified in 
 .Pa /etc/inetd.conf .
 .Pp
 The finger protocol consists mostly of specifying command arguments.
@@ -105,12 +105,12 @@ The 
 .Xr inetd 8
 .Dq super-server
 runs
-.Nm fingerd
+.Nm in.fingerd
 for 
 .Tn TCP
 requests received on port 79.
 Once connected 
-.Nm fingerd
+.Nm in.fingerd
 reads a single command line
 terminated by a
 .Aq Tn CRLF
--- a/fingerd/fingerd.c	1999-12-13 05:46:28.000000000 +1100
+++ b/fingerd/fingerd.c	2009-06-10 20:08:45.000000000 +1000
@@ -55,6 +55,7 @@ char rcsid[] = 
 #include <netinet/in.h>
 #include <sys/utsname.h>
 #include <sys/wait.h>
+#include <sys/socket.h>
 
 #include "pathnames.h"
 #include "../version.h"