python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / networking / bsd-finger / ubuntu-0.17-9.patch
blob24decb60281fc7e4130abd2eb694a5b035028bae
1 --- bsd-finger-0.17.orig/finger/finger.1
2 +++ bsd-finger-0.17/finger/finger.1
3 @@ -169,16 +169,14 @@
4 must be able to see the
5 .Pa .nofinger
6 file. This generally means that the home directory containing the file
7 -must have the other-users-execute bit set (o+w). See
8 +must have the other-users-execute bit set (o+x). See
9 .Xr chmod 1 .
10 If you use this feature for privacy, please test it with ``finger
11 @localhost'' before relying on it, just in case.
12 .It ~/.plan
13 .It ~/.project
14 -.It ~/.pgp
15 +.It ~/.pgpkey
16 These files are printed as part of a long-format request. The
17 -.Pa .project
18 -file is limited to one line; the
19 .Pa .plan
20 file may be arbitrarily long.
21 .El
22 --- bsd-finger-0.17.orig/finger/finger.c
23 +++ bsd-finger-0.17/finger/finger.c
24 @@ -77,7 +77,7 @@
25 #include "../version.h"
27 static void loginlist(void);
28 -static void userlist(int argc, char *argv[]);
29 +static int userlist(int argc, char *argv[]);
31 int lflag, pplan;
32 static int sflag, mflag;
33 @@ -92,6 +92,7 @@
35 int main(int argc, char *argv[]) {
36 int ch;
37 + int err = 0;
38 struct sockaddr_in sin;
39 socklen_t slen = sizeof(sin);
41 @@ -159,7 +160,7 @@
44 else {
45 - userlist(argc, argv);
46 + err = userlist(argc, argv);
48 * Assign explicit "large" format if names given and -s not
49 * explicitly stated. Force the -l AFTER we get names so any
50 @@ -172,7 +173,7 @@
51 if (lflag) lflag_print();
52 else sflag_print();
54 - return 0;
55 + return err;
58 /* Returns 1 if .nofinger is found and enable_nofinger is set. */
59 @@ -181,10 +182,16 @@
60 check_nofinger(struct passwd *pw)
62 if (enable_nofinger) {
63 - char path[PATH_MAX];
64 struct stat tripe;
65 - snprintf(path, sizeof(path), "%s/.nofinger", pw->pw_dir);
66 - if (stat(path, &tripe)==0) {
67 + int ret;
68 + char *path;
69 + if (asprintf(&path, "%s/.nofinger", pw->pw_dir) < 0) {
70 + eprintf("finger: Out of space.\n");
71 + exit(1);
72 + }
73 + ret = stat(path, &tripe);
74 + free(path);
75 + if (!ret) {
76 return 1;
79 @@ -264,10 +271,11 @@
83 -static void
84 +static int
85 userlist(int argc, char *argv[])
87 int i;
88 + int err = 0;
89 PERSON *pn;
90 PERSON *nethead, **nettail;
91 struct utmp *uptr;
92 @@ -297,13 +305,13 @@
94 /* handle network requests */
95 for (pn = nethead; pn; pn = pn->next) {
96 - netfinger(pn->name);
97 + err |= netfinger(pn->name);
98 if (pn->next || entries)
99 xputc('\n');
102 if (entries == 0)
103 - return;
104 + return err;
107 * Scan thru the list of users currently logged in, saving
108 @@ -331,4 +339,6 @@
109 enter_lastlog(pn);
111 endutent();
113 + return err;
115 --- bsd-finger-0.17.orig/finger/finger.h
116 +++ bsd-finger-0.17/finger/finger.h
117 @@ -92,7 +92,7 @@
118 void enter_where(struct utmp *ut, PERSON *pn);
119 void enter_lastlog(PERSON *pn);
120 int match(struct passwd *pw, const char *user);
121 -void netfinger(const char *name);
122 +int netfinger(const char *name);
123 const char *prphone(const char *num);
125 #ifndef DAYSPERNYEAR
126 --- bsd-finger-0.17.orig/finger/lprint.c
127 +++ bsd-finger-0.17/finger/lprint.c
128 @@ -48,7 +48,7 @@
129 #include <sys/types.h>
130 #include <sys/file.h>
131 #include <sys/stat.h>
132 -#include <sys/time.h>
133 +#include <time.h>
134 #include "finger.h"
136 static void lprint(PERSON *pn);
137 @@ -100,7 +100,7 @@
138 * office, office phone, home phone if available
140 xprintf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s",
141 - pn->name, pn->realname, pn->dir);
142 + pn->name, pn->realname ? pn->realname : "", pn->dir);
143 xprintf("\tShell: %-s\n", *pn->shell ? pn->shell : _PATH_BSHELL);
146 --- bsd-finger-0.17.orig/finger/net.c
147 +++ bsd-finger-0.17/finger/net.c
148 @@ -51,7 +51,7 @@
149 #include <ctype.h>
150 #include "finger.h"
152 -void netfinger(const char *name) {
153 +int netfinger(const char *name) {
154 register FILE *fp;
155 struct in_addr defaddr;
156 register int c, sawret, ateol;
157 @@ -62,7 +62,7 @@
158 char *alist[1], *host;
160 host = strrchr(name, '@');
161 - if (!host) return;
162 + if (!host) return 1;
163 *host++ = '\0';
165 memset(&sn, 0, sizeof(sn));
166 @@ -70,7 +70,7 @@
167 sp = getservbyname("finger", "tcp");
168 if (!sp) {
169 eprintf("finger: tcp/finger: unknown service\n");
170 - return;
171 + return 1;
173 sn.sin_port = sp->s_port;
175 @@ -78,7 +78,7 @@
176 if (!hp) {
177 if (!inet_aton(host, &defaddr)) {
178 eprintf("finger: unknown host: %s\n", host);
179 - return;
180 + return 1;
182 def.h_name = host;
183 def.h_addr_list = alist;
184 @@ -96,7 +96,7 @@
186 if ((s = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) {
187 eprintf("finger: socket: %s\n", strerror(errno));
188 - return;
189 + return 1;
192 /* print hostname before connecting, in case it takes a while */
193 @@ -104,7 +104,7 @@
194 if (connect(s, (struct sockaddr *)&sn, sizeof(sn)) < 0) {
195 eprintf("finger: connect: %s\n", strerror(errno));
196 close(s);
197 - return;
198 + return 1;
201 /* -l flag for remote fingerd */
202 @@ -128,7 +128,7 @@
203 if (!fp) {
204 eprintf("finger: fdopen: %s\n", strerror(errno));
205 close(s);
206 - return;
207 + return 1;
210 sawret = 0;
211 @@ -152,4 +152,6 @@
213 if (!ateol) xputc('\n');
214 fclose(fp);
216 + return 0;
218 --- bsd-finger-0.17.orig/finger/sprint.c
219 +++ bsd-finger-0.17/finger/sprint.c
220 @@ -40,7 +40,7 @@
221 #endif /* not lint */
223 #include <sys/types.h>
224 -#include <sys/time.h>
225 +#include <time.h>
226 #include <stdio.h>
227 #include <stdlib.h>
228 #include <string.h>
229 --- bsd-finger-0.17.orig/finger/util.c
230 +++ bsd-finger-0.17/finger/util.c
231 @@ -64,7 +64,7 @@
232 struct stat sb;
234 /* No device for X console. Utmp entry by XDM login (":0"). */
235 - if (w->tty[0] == ':') {
236 + if (strchr(w->tty, ':')) {
237 w->idletime = 0; /* would be nice to have it emit ??? */
238 w->writable = 0;
239 return;
240 @@ -109,9 +109,8 @@
241 * fields[3] -> homephone
243 nfields = 0;
244 - for (p = strtok(bp, ","); p; p = strtok(NULL, ",")) {
245 - if (*p==0) p = NULL; // skip empties
246 - if (nfields < 4) fields[nfields++] = p;
247 + while ((p = strsep(&bp, ","))) {
248 + if (nfields < 4) fields[nfields++] = *p ? p : NULL;
250 while (nfields<4) fields[nfields++] = NULL;
252 @@ -150,6 +149,9 @@
254 pn->realname = rname;
256 + else {
257 + pn->realname = NULL;
260 pn->office = fields[1] ? strdup(fields[1]) : NULL;
261 pn->officephone = fields[2] ? strdup(fields[2]) : NULL;