aboutsummaryrefslogtreecommitdiffstats
path: root/ftp/wu-ftpd+ipv6/files/patch-ad
blob: 8a6749a4e6de48debc3b62c55eb2a7c94c3a0fef (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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
*** src/ftpd.c.orig Tue Jan  7 00:27:09 1997
--- src/ftpd.c  Fri Jan 17 17:45:14 1997
***************
*** 139,146 ****
   *freopen(const char *, const char *, FILE *);
  extern int ftpd_pclose(FILE *iop),
    fclose(FILE *);
! extern char *getline(),
!  *realpath(char *pathname, char *result);
  extern char cbuf[];
  extern off_t restart_point;
  
--- 139,146 ----
   *freopen(const char *, const char *, FILE *);
  extern int ftpd_pclose(FILE *iop),
    fclose(FILE *);
! extern char *getline();
! extern char *realpath(const char *pathname, char *result);
  extern char cbuf[];
  extern off_t restart_point;
  
***************
*** 237,242 ****
--- 237,247 ----
  
  #endif /* SETPROCTITLE */
  
+ #ifdef SKEY
+ #include <skey.h>
+ int   pwok = 0;
+ #endif
+ 
  #ifdef KERBEROS
  void init_krb();
  void end_krb();
***************
*** 252,257 ****
--- 257,269 ----
  char  ls_short[50];
  struct aclmember *entry = NULL;
  
+ void end_login(void);
+ void send_data(FILE *, FILE *, off_t);
+ void dolog(struct sockaddr_in *);
+ void dologout(int);
+ void perror_reply(int, char *);
+ 
+ void
  main(int argc, char **argv, char **envp)
  {
      int addrlen,
***************
*** 686,691 ****
--- 698,705 ----
   * does not have a standard shell as returned by getusershell().  Disallow
   * anyone mentioned in the file _PATH_FTPUSERS to allow people such as root
   * and uucp to be avoided. */
+ 
+ void
  user(char *name)
  {
      register char *cp;
***************
*** 878,884 ****
--- 892,903 ----
      } else
          acl_setfunctions();
  
+ #ifdef SKEY
+     pwok = skeyaccess(name, NULL, remotehost, remoteaddr);
+     reply(331, "%s", skey_challenge(name, pw, pwok));
+ #else
      reply(331, "Password required for %s.", name);
+ #endif
      askpasswd = 1;
      /* Delay before reading passwd after first failed attempt to slow down
       * passwd-guessing programs. */
***************
*** 887,892 ****
--- 906,912 ----
  }
  
  /* Check if a user is in the file _PATH_FTPUSERS */
+ int
  checkuser(char *name)
  {
      register FILE *fd;
***************
*** 911,916 ****
--- 931,937 ----
  
  /* Terminate login as previous user, if any, resetting state; used when USER
   * command is given or login fails. */
+ void
  end_login(void)
  {
  
***************
*** 965,970 ****
--- 986,992 ----
          return 0;
  }
  
+ void
  pass(char *passwd)
  {
      char *xpasswd,
***************
*** 1007,1014 ****
--- 1029,1041 ----
  #ifdef KERBEROS
          xpasswd = crypt16(passwd, salt);
  #else
+ #ifdef SKEY
+   xpasswd = skey_crypt(passwd, salt, pw, pwok);
+   pwok = 0;
+ #else
          xpasswd = crypt(passwd, salt);
  #endif
+ #endif
  
  #ifdef ULTRIX_AUTH
          if ((numfails = ultrix_check_pass(passwd, xpasswd)) < 0) {
***************
*** 1095,1101 ****
      (void) initgroups(pw->pw_name, pw->pw_gid);
  
      /* open wtmp before chroot */
!     (void) sprintf(ttyline, "ftp%d", getpid());
      logwtmp(ttyline, pw->pw_name, remotehost);
      logged_in = 1;
  
--- 1122,1132 ----
      (void) initgroups(pw->pw_name, pw->pw_gid);
  
      /* open wtmp before chroot */
! #if (defined(BSD) && (BSD >= 199103))
!     (void) sprintf(ttyline, "ftp%ld", getpid());
! #else
!     (void) sprintf(ttyline, "ftpd%d", getpid());
! #endif
      logwtmp(ttyline, pw->pw_name, remotehost);
      logged_in = 1;
  
***************
*** 1190,1197 ****
          reply(230, "Guest login ok, access restrictions apply.");
  #ifdef SETPROCTITLE
          sprintf(proctitle, "%s: anonymous/%.*s", remotehost,
!                     sizeof(proctitle) - sizeof(remotehost) -
!                     sizeof(": anonymous/"), passwd);
          setproctitle("%s", proctitle);
  #endif /* SETPROCTITLE */
          if (logging)
--- 1221,1228 ----
          reply(230, "Guest login ok, access restrictions apply.");
  #ifdef SETPROCTITLE
          sprintf(proctitle, "%s: anonymous/%.*s", remotehost,
!                     (int) (sizeof(proctitle) - sizeof(remotehost) -
!                     sizeof(": anonymous/")), passwd);
          setproctitle("%s", proctitle);
  #endif /* SETPROCTITLE */
          if (logging)
***************
*** 1235,1240 ****
--- 1266,1272 ----
      return (buf);
  }
  
+ void
  retrieve(char *cmd, char *name)
  {
      FILE *fin,
***************
*** 1403,1409 ****
      if (dout == NULL)
          goto done;
  #ifdef HAVE_ST_BLKSIZE
!     send_data(fin, dout, st.st_blksize);
  #else
      send_data(fin, dout, BUFSIZ);
  #endif
--- 1435,1441 ----
      if (dout == NULL)
          goto done;
  #ifdef HAVE_ST_BLKSIZE
!     send_data(fin, dout, st.st_blksize*2);
  #else
      send_data(fin, dout, BUFSIZ);
  #endif
***************
*** 1422,1428 ****
--- 1454,1464 ----
          for (loop = 0; namebuf[loop]; loop++)
              if (isspace(namebuf[loop]) || iscntrl(namebuf[loop]))
                  namebuf[loop] = '_';
+ #if (defined(BSD) && (BSD >= 199103))
+         sprintf(msg, "%.24s %d %s %qd %s %c %s %c %c %s ftp %d %s\n",
+ #else
          sprintf(msg, "%.24s %d %s %d %s %c %s %c %c %s ftp %d %s\n",
+ #endif
                  ctime(&curtime),
                  xfertime,
                  remotehost,
***************
*** 1445,1450 ****
--- 1481,1487 ----
          (*closefunc) (fin);
  }
  
+ void
  store(char *name, char *mode, int unique)
  {
      FILE *fout, *din;
***************
*** 1610,1616 ****
          for (loop = 0; namebuf[loop]; loop++)
              if (isspace(namebuf[loop]) || iscntrl(namebuf[loop]))
                  namebuf[loop] = '_';
!         sprintf(msg, "%.24s %d %s %d %s %c %s %c %c %s ftp %d %s\n",
                  ctime(&curtime),
                  xfertime,
                  remotehost,
--- 1647,1657 ----
          for (loop = 0; namebuf[loop]; loop++)
              if (isspace(namebuf[loop]) || iscntrl(namebuf[loop]))
                  namebuf[loop] = '_';
! #if (defined(BSD) && (BSD >= 199103))
!         sprintf(msg, "%.24s %d %s %qd %s %c %s %c %c %s ftp %d %s\n",
! #else
!         sprintf(msg, "%.24s %d %s %d %s %c %s %c %c %s ftp %d %s\n", 
! #endif
                  ctime(&curtime),
                  xfertime,
                  remotehost,
***************
*** 1678,1683 ****
--- 1719,1735 ----
      if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *) &on, sizeof(int)) < 0)
            syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
  #endif
+ #ifdef TCP_NOPUSH
+   /*
+    * Turn off push flag to keep sender TCP from sending short packets
+    * at the boundaries of each write().  Should probably do a SO_SNDBUF
+    * to set the send buffer size as well, but that may not be desirable
+    * in heavy-load situations.
+    */
+   on = 1;
+   if (setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, (char *)&on, sizeof on) < 0)
+       syslog(LOG_WARNING, "setsockopt (TCP_NOPUSH): %m");
+ #endif
  
      return (fdopen(s, mode));
    bad:
***************
*** 1699,1705 ****
      file_size = size;
      byte_count = 0;
      if (size != (off_t) - 1)
!         (void) sprintf(sizebuf, " (%ld bytes)", size);
      else
          (void) strcpy(sizebuf, "");
      if (pdata >= 0) {
--- 1751,1761 ----
      file_size = size;
      byte_count = 0;
      if (size != (off_t) - 1)
! #if (defined(BSD) && (BSD >= 199103))
!         (void) sprintf(sizebuf, " (%qd bytes)", size);
! #else
!   (void) sprintf(sizebuf, " (%d bytes)", size);
! #endif
      else
          (void) strcpy(sizebuf, "");
      if (pdata >= 0) {
***************
*** 1707,1715 ****
          int s,
            fromlen = sizeof(from);
  
!         s = accept(pdata, (struct sockaddr *) &from, &fromlen);
!         if (s < 0) {
!             reply(425, "Can't open data connection.");
              (void) close(pdata);
              pdata = -1;
              return (NULL);
--- 1763,1785 ----
          int s,
            fromlen = sizeof(from);
  
! #ifdef FD_ZERO
!        struct timeval timeout;
!        fd_set set;
! 
!        FD_ZERO(&set);
!        FD_SET(pdata, &set);
! 
!        timeout.tv_usec = 0;
!        timeout.tv_sec = 120;
! 
!        if (select(pdata+1, &set, (fd_set *) 0, (fd_set *) 0, &timeout) == 0 ||
!            (s = accept(pdata, (struct sockaddr *) &from, &fromlen)) < 0) {
! #else
!           s = accept(pdata, (struct sockaddr *) &from, &fromlen);
!           if (s < 0) {
! #endif
!       reply(425, "Can't open data connection.");
              (void) close(pdata);
              pdata = -1;
              return (NULL);
***************
*** 1764,1769 ****
--- 1834,1840 ----
   * encapsulation of the data subject to Mode, Structure, and Type.
   *
   * NB: Form isn't handled. */
+ void
  send_data(FILE *instr, FILE *outstr, off_t blksize)
  {
      register int c,
***************
*** 1839,1844 ****
--- 1910,1916 ----
   * the data subject to Mode, Structure, and Type.
   *
   * N.B.: Form isn't handled. */
+ int
  receive_data(FILE *instr, FILE *outstr)
  {
      register int c;
***************
*** 1915,1920 ****
--- 1987,1993 ----
      return (-1);
  }
  
+ void
  statfilecmd(char *filename)
  {
      char line[BUFSIZ];
***************
*** 1948,1953 ****
--- 2021,2027 ----
      reply(211, "End of Status");
  }
  
+ void
  statcmd(void)
  {
      struct sockaddr_in *sin;
***************
*** 2001,2006 ****
--- 2075,2081 ----
      reply(211, "End of status");
  }
  
+ void
  fatal(char *s)
  {
      reply(451, "Error in server: %s\n", s);
***************
*** 2095,2100 ****
--- 2170,2176 ----
  
  #else
  /* VARARGS2 */
+ void
  reply(int n, char *fmt, int p0, int p1, int p2, int p3, int p4, int p5)
  {
      if (autospout != NULL) {
***************
*** 2129,2134 ****
--- 2205,2211 ----
  }
  
  /* VARARGS2 */
+ void
  lreply(int n, char *fmt, int p0, int p1, int p2, int p3, int p4, int p5)
  {
      if (!dolreplies)
***************
*** 2144,2160 ****
--- 2221,2240 ----
  }
  #endif
  
+ void
  ack(char *s)
  {
      reply(250, "%s command successful.", s);
  }
  
+ void
  nack(char *s)
  {
      reply(502, "%s command not implemented.", s);
  }
  
  /* ARGSUSED */
+ void
  yyerror(char *s)
  {
      char *cp;
***************
*** 2164,2169 ****
--- 2244,2250 ----
      reply(500, "'%s': command not understood.", cbuf);
  }
  
+ void
  delete(char *name)
  {
      struct stat st;
***************
*** 2208,2213 ****
--- 2289,2295 ----
      ack("DELE");
  }
  
+ void
  cwd(char *path)
  {
      struct aclmember *entry = NULL;
***************
*** 2248,2253 ****
--- 2330,2336 ----
      }
  }
  
+ void
  makedir(char *name)
  {
    uid_t uid;
***************
*** 2274,2282 ****
      reply(257, "MKD command successful.");
  }
  
  removedir(char *name)
  {
!   int c, d;  /* dummy variables */
          int valid = 0;
  
      /*
--- 2357,2366 ----
      reply(257, "MKD command successful.");
  }
  
+ void
  removedir(char *name)
  {
!   unsigned long c, d;  /* dummy variables */
          int valid = 0;
  
      /*
***************
*** 2298,2303 ****
--- 2382,2388 ----
          ack("RMD");
  }
  
+ void
  pwd(void)
  {
      char path[MAXPATHLEN + 1];
***************
*** 2312,2318 ****
  #else
      if (getwd(path) == (char *) NULL)
  #endif
!         reply(550, "%s.", path);
      else
          reply(257, "\"%s\" is current directory.", path);
  }
--- 2397,2404 ----
  #else
      if (getwd(path) == (char *) NULL)
  #endif
! /*        reply(550, "%s.", path); */
!   reply(550, "Permission denied.");
      else
          reply(257, "\"%s\" is current directory.", path);
  }
***************
*** 2342,2347 ****
--- 2428,2434 ----
      return (name);
  }
  
+ void
  renamecmd(char *from, char *to)
  {
  
***************
*** 2357,2362 ****
--- 2444,2450 ----
          ack("RNTO");
  }
  
+ void
  dolog(struct sockaddr_in *sin)
  {
      struct hostent *hp;
***************
*** 2412,2417 ****
--- 2500,2506 ----
  }
  
  /* Record logout in wtmp file and exit with supplied status. */
+ void
  dologout(int status)
  {
     /*
***************
*** 2466,2471 ****
--- 2555,2561 ----
   * PASV command in RFC959. However, it has been blessed as a legitimate
   * response by Jon Postel in a telephone conversation with Rick Adams on 25
   * Jan 89. */
+ void
  passive(void)
  {
      int len;
***************
*** 2537,2542 ****
--- 2627,2633 ----
  }
  
  /* Format and send reply containing system error number. */
+ void
  perror_reply(int code, char *string)
  {
      reply(code, "%s: %s.", string, strerror(errno));
***************
*** 2545,2550 ****
--- 2636,2642 ----
  static char *onefile[] =
  {"", 0};
  
+ void
  send_file_list(char *whichfiles)
  {
      struct stat st;