ftp: don't use restartable signals Refactor to not rely upon restartable signals (SA_RESTART), possibly fixing intermittent failures with -q QUITTIME. ftp transfers: handle EINTR/EAGAIN in copy_bytes(), instead of relying upon restartable signals. http/https transfers: Explicitly print an error similar to progressmeter() when timing-out for -Q QUITTIME in fetch_wait(), and set errno to ETIMEDOUT so that the warn() in fetch_url() prints a more accurate error message. PR/55857diff -r1.170 -r1.171 src/usr.bin/ftp/ftp.c
(lukem)
--- src/usr.bin/ftp/ftp.c 2020/07/11 02:19:31 1.170
+++ src/usr.bin/ftp/ftp.c 2021/01/06 04:43:14 1.171
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: ftp.c,v 1.170 2020/07/11 02:19:31 lukem Exp $ */ | 1 | /* $NetBSD: ftp.c,v 1.171 2021/01/06 04:43:14 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996-2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Luke Mewburn. | 8 | * by Luke Mewburn. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -82,27 +82,27 @@ | @@ -82,27 +82,27 @@ | |||
82 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 82 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
83 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 83 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
84 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 84 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 85 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 86 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
87 | * SUCH DAMAGE. | 87 | * SUCH DAMAGE. | |
88 | */ | 88 | */ | |
89 | 89 | |||
90 | #include <sys/cdefs.h> | 90 | #include <sys/cdefs.h> | |
91 | #ifndef lint | 91 | #ifndef lint | |
92 | #if 0 | 92 | #if 0 | |
93 | static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; | 93 | static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; | |
94 | #else | 94 | #else | |
95 | __RCSID("$NetBSD: ftp.c,v 1.170 2020/07/11 02:19:31 lukem Exp $"); | 95 | __RCSID("$NetBSD: ftp.c,v 1.171 2021/01/06 04:43:14 lukem Exp $"); | |
96 | #endif | 96 | #endif | |
97 | #endif /* not lint */ | 97 | #endif /* not lint */ | |
98 | 98 | |||
99 | #include <sys/types.h> | 99 | #include <sys/types.h> | |
100 | #include <sys/stat.h> | 100 | #include <sys/stat.h> | |
101 | #include <sys/socket.h> | 101 | #include <sys/socket.h> | |
102 | #include <sys/time.h> | 102 | #include <sys/time.h> | |
103 | 103 | |||
104 | #include <netinet/in.h> | 104 | #include <netinet/in.h> | |
105 | #include <netinet/in_systm.h> | 105 | #include <netinet/in_systm.h> | |
106 | #include <netinet/ip.h> | 106 | #include <netinet/ip.h> | |
107 | #include <arpa/inet.h> | 107 | #include <arpa/inet.h> | |
108 | #include <arpa/ftp.h> | 108 | #include <arpa/ftp.h> | |
@@ -583,27 +583,27 @@ abortxfer(int notused) | @@ -583,27 +583,27 @@ abortxfer(int notused) | |||
583 | strlcpy(msgbuf, "\nsend", sizeof(msgbuf)); | 583 | strlcpy(msgbuf, "\nsend", sizeof(msgbuf)); | |
584 | break; | 584 | break; | |
585 | default: | 585 | default: | |
586 | errx(1, "abortxfer: unknown direction `%s'", direction); | 586 | errx(1, "abortxfer: unknown direction `%s'", direction); | |
587 | } | 587 | } | |
588 | len = strlcat(msgbuf, " aborted. Waiting for remote to finish abort.\n", | 588 | len = strlcat(msgbuf, " aborted. Waiting for remote to finish abort.\n", | |
589 | sizeof(msgbuf)); | 589 | sizeof(msgbuf)); | |
590 | write(fileno(ttyout), msgbuf, len); | 590 | write(fileno(ttyout), msgbuf, len); | |
591 | siglongjmp(xferabort, 1); | 591 | siglongjmp(xferabort, 1); | |
592 | } | 592 | } | |
593 | 593 | |||
594 | /* | 594 | /* | |
595 | * Read data from infd & write to outfd, using buf/bufsize as the temporary | 595 | * Read data from infd & write to outfd, using buf/bufsize as the temporary | |
596 | * buffer, dealing with short writes. | 596 | * buffer, dealing with short reads or writes. | |
597 | * If rate_limit != 0, rate-limit the transfer. | 597 | * If rate_limit != 0, rate-limit the transfer. | |
598 | * If hash_interval != 0, fputc('c', ttyout) every hash_interval bytes. | 598 | * If hash_interval != 0, fputc('c', ttyout) every hash_interval bytes. | |
599 | * Updates global variables: bytes. | 599 | * Updates global variables: bytes. | |
600 | * Returns 0 if ok, 1 if there was a read error, 2 if there was a write error. | 600 | * Returns 0 if ok, 1 if there was a read error, 2 if there was a write error. | |
601 | * In the case of error, errno contains the appropriate error code. | 601 | * In the case of error, errno contains the appropriate error code. | |
602 | */ | 602 | */ | |
603 | static int | 603 | static int | |
604 | copy_bytes(int infd, int outfd, char *buf, size_t bufsize, | 604 | copy_bytes(int infd, int outfd, char *buf, size_t bufsize, | |
605 | int rate_limit, int hash_interval) | 605 | int rate_limit, int hash_interval) | |
606 | { | 606 | { | |
607 | volatile off_t hashc; | 607 | volatile off_t hashc; | |
608 | ssize_t inc, outc; | 608 | ssize_t inc, outc; | |
609 | char *bufp; | 609 | char *bufp; | |
@@ -617,35 +617,45 @@ copy_bytes(int infd, int outfd, char *bu | @@ -617,35 +617,45 @@ copy_bytes(int infd, int outfd, char *bu | |||
617 | else | 617 | else | |
618 | bufchunk = bufsize; | 618 | bufchunk = bufsize; | |
619 | 619 | |||
620 | while (1) { | 620 | while (1) { | |
621 | if (rate_limit) { | 621 | if (rate_limit) { | |
622 | (void)gettimeofday(&tvthen, NULL); | 622 | (void)gettimeofday(&tvthen, NULL); | |
623 | } | 623 | } | |
624 | errno = 0; | 624 | errno = 0; | |
625 | inc = outc = 0; | 625 | inc = outc = 0; | |
626 | /* copy bufchunk at a time */ | 626 | /* copy bufchunk at a time */ | |
627 | bufrem = bufchunk; | 627 | bufrem = bufchunk; | |
628 | while (bufrem > 0) { | 628 | while (bufrem > 0) { | |
629 | inc = read(infd, buf, MIN((off_t)bufsize, bufrem)); | 629 | inc = read(infd, buf, MIN((off_t)bufsize, bufrem)); | |
630 | if (inc <= 0) | 630 | if (inc < 0) { | |
631 | if (errno == EINTR || errno == EAGAIN) { | |||
632 | continue; | |||
633 | } | |||
634 | goto copy_done; | |||
635 | } else if (inc == 0) { | |||
631 | goto copy_done; | 636 | goto copy_done; | |
637 | } | |||
632 | bytes += inc; | 638 | bytes += inc; | |
633 | bufrem -= inc; | 639 | bufrem -= inc; | |
634 | bufp = buf; | 640 | bufp = buf; | |
635 | while (inc > 0) { | 641 | while (inc > 0) { | |
636 | outc = write(outfd, bufp, inc); | 642 | outc = write(outfd, bufp, inc); | |
637 | if (outc < 0) | 643 | if (outc < 0) { | |
644 | if (errno == EINTR || errno == EAGAIN) { | |||
645 | continue; | |||
646 | } | |||
638 | goto copy_done; | 647 | goto copy_done; | |
648 | } | |||
639 | inc -= outc; | 649 | inc -= outc; | |
640 | bufp += outc; | 650 | bufp += outc; | |
641 | } | 651 | } | |
642 | if (hash_interval) { | 652 | if (hash_interval) { | |
643 | while (bytes >= hashc) { | 653 | while (bytes >= hashc) { | |
644 | (void)putc('#', ttyout); | 654 | (void)putc('#', ttyout); | |
645 | hashc += hash_interval; | 655 | hashc += hash_interval; | |
646 | } | 656 | } | |
647 | (void)fflush(ttyout); | 657 | (void)fflush(ttyout); | |
648 | } | 658 | } | |
649 | } | 659 | } | |
650 | if (rate_limit) { /* rate limited; wait if necessary */ | 660 | if (rate_limit) { /* rate limited; wait if necessary */ | |
651 | while (1) { | 661 | while (1) { |
--- src/usr.bin/ftp/progressbar.c 2019/06/22 23:40:33 1.23
+++ src/usr.bin/ftp/progressbar.c 2021/01/06 04:43:14 1.24
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $ */ | 1 | /* $NetBSD: progressbar.c,v 1.24 2021/01/06 04:43:14 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997-2021 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Luke Mewburn. | 8 | * by Luke Mewburn. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | __RCSID("$NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $"); | 34 | __RCSID("$NetBSD: progressbar.c,v 1.24 2021/01/06 04:43:14 lukem Exp $"); | |
35 | #endif /* not lint */ | 35 | #endif /* not lint */ | |
36 | 36 | |||
37 | /* | 37 | /* | |
38 | * FTP User Program -- Misc support routines | 38 | * FTP User Program -- Misc support routines | |
39 | */ | 39 | */ | |
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/types.h> | 41 | #include <sys/types.h> | |
42 | #include <sys/time.h> | 42 | #include <sys/time.h> | |
43 | 43 | |||
44 | #include <err.h> | 44 | #include <err.h> | |
45 | #include <errno.h> | 45 | #include <errno.h> | |
46 | #include <signal.h> | 46 | #include <signal.h> | |
47 | #include <stdio.h> | 47 | #include <stdio.h> | |
@@ -183,27 +183,27 @@ progressmeter(int flag) | @@ -183,27 +183,27 @@ progressmeter(int flag) | |||
183 | siglongjmp(toplevel, 1); | 183 | siglongjmp(toplevel, 1); | |
184 | } | 184 | } | |
185 | #endif /* !STANDALONE_PROGRESS */ | 185 | #endif /* !STANDALONE_PROGRESS */ | |
186 | } | 186 | } | |
187 | /* | 187 | /* | |
188 | * Always set the handler even if we are not the foreground process. | 188 | * Always set the handler even if we are not the foreground process. | |
189 | */ | 189 | */ | |
190 | #ifdef STANDALONE_PROGRESS | 190 | #ifdef STANDALONE_PROGRESS | |
191 | if (progress) { | 191 | if (progress) { | |
192 | #else | 192 | #else | |
193 | if (quit_time > 0 || progress) { | 193 | if (quit_time > 0 || progress) { | |
194 | #endif /* !STANDALONE_PROGRESS */ | 194 | #endif /* !STANDALONE_PROGRESS */ | |
195 | if (flag == -1) { | 195 | if (flag == -1) { | |
196 | (void)xsignal_restart(SIGALRM, updateprogressmeter, 1); | 196 | (void)xsignal(SIGALRM, updateprogressmeter); | |
197 | alarmtimer(1); /* set alarm timer for 1 Hz */ | 197 | alarmtimer(1); /* set alarm timer for 1 Hz */ | |
198 | } else if (flag == 1) { | 198 | } else if (flag == 1) { | |
199 | alarmtimer(0); | 199 | alarmtimer(0); | |
200 | (void)xsignal(SIGALRM, SIG_DFL); | 200 | (void)xsignal(SIGALRM, SIG_DFL); | |
201 | } | 201 | } | |
202 | } | 202 | } | |
203 | #ifndef NO_PROGRESS | 203 | #ifndef NO_PROGRESS | |
204 | if (!progress) | 204 | if (!progress) | |
205 | return; | 205 | return; | |
206 | len = 0; | 206 | len = 0; | |
207 | 207 | |||
208 | /* | 208 | /* | |
209 | * print progress bar only if we are foreground process. | 209 | * print progress bar only if we are foreground process. | |
@@ -394,83 +394,31 @@ psummary(int notused) | @@ -394,83 +394,31 @@ psummary(int notused) | |||
394 | * Set the SIGALRM interval timer for wait seconds, 0 to disable. | 394 | * Set the SIGALRM interval timer for wait seconds, 0 to disable. | |
395 | */ | 395 | */ | |
396 | void | 396 | void | |
397 | alarmtimer(int wait) | 397 | alarmtimer(int wait) | |
398 | { | 398 | { | |
399 | struct itimerval itv; | 399 | struct itimerval itv; | |
400 | 400 | |||
401 | itv.it_value.tv_sec = wait; | 401 | itv.it_value.tv_sec = wait; | |
402 | itv.it_value.tv_usec = 0; | 402 | itv.it_value.tv_usec = 0; | |
403 | itv.it_interval = itv.it_value; | 403 | itv.it_interval = itv.it_value; | |
404 | setitimer(ITIMER_REAL, &itv, NULL); | 404 | setitimer(ITIMER_REAL, &itv, NULL); | |
405 | } | 405 | } | |
406 | 406 | |||
407 | ||||
408 | /* | 407 | /* | |
409 | * Install a POSIX signal handler, allowing the invoker to set whether | 408 | * Install a non-restartable POSIX signal handler. | |
410 | * the signal should be restartable or not | |||
411 | */ | 409 | */ | |
412 | sigfunc | 410 | sigfunc | |
413 | xsignal_restart(int sig, sigfunc func, int restartable) | 411 | xsignal(int sig, sigfunc func) | |
414 | { | 412 | { | |
415 | struct sigaction act, oact; | 413 | struct sigaction act, oact; | |
416 | act.sa_handler = func; | 414 | act.sa_handler = func; | |
417 | 415 | |||
418 | sigemptyset(&act.sa_mask); | 416 | sigemptyset(&act.sa_mask); | |
419 | #if defined(SA_RESTART) /* 4.4BSD, Posix(?), SVR4 */ | 417 | act.sa_flags = 0; | |
420 | act.sa_flags = restartable ? SA_RESTART : 0; | 418 | #if defined(SA_INTERRUPT) /* SunOS 4.x */ | |
421 | #elif defined(SA_INTERRUPT) /* SunOS 4.x */ | 419 | act.sa_flags = SA_INTERRUPT; | |
422 | act.sa_flags = restartable ? 0 : SA_INTERRUPT; | |||
423 | #else | |||
424 | #error "system must have SA_RESTART or SA_INTERRUPT" | |||
425 | #endif | 420 | #endif | |
426 | if (sigaction(sig, &act, &oact) < 0) | 421 | if (sigaction(sig, &act, &oact) < 0) | |
427 | return (SIG_ERR); | 422 | return (SIG_ERR); | |
428 | return (oact.sa_handler); | 423 | return (oact.sa_handler); | |
429 | } | 424 | } | |
430 | ||||
431 | /* | |||
432 | * Install a signal handler with the `restartable' flag set dependent upon | |||
433 | * which signal is being set. (This is a wrapper to xsignal_restart()) | |||
434 | */ | |||
435 | sigfunc | |||
436 | xsignal(int sig, sigfunc func) | |||
437 | { | |||
438 | int restartable; | |||
439 | ||||
440 | /* | |||
441 | * Some signals print output or change the state of the process. | |||
442 | * There should be restartable, so that reads and writes are | |||
443 | * not affected. Some signals should cause program flow to change; | |||
444 | * these signals should not be restartable, so that the system call | |||
445 | * will return with EINTR, and the program will go do something | |||
446 | * different. If the signal handler calls longjmp() or siglongjmp(), | |||
447 | * it doesn't matter if it's restartable. | |||
448 | */ | |||
449 | ||||
450 | switch(sig) { | |||
451 | #ifdef SIGINFO | |||
452 | case SIGINFO: | |||
453 | #endif | |||
454 | case SIGQUIT: | |||
455 | case SIGUSR1: | |||
456 | case SIGUSR2: | |||
457 | case SIGWINCH: | |||
458 | restartable = 1; | |||
459 | break; | |||
460 | ||||
461 | case SIGALRM: | |||
462 | case SIGINT: | |||
463 | case SIGPIPE: | |||
464 | restartable = 0; | |||
465 | break; | |||
466 | ||||
467 | default: | |||
468 | /* | |||
469 | * This is unpleasant, but I don't know what would be better. | |||
470 | * Right now, this "can't happen" | |||
471 | */ | |||
472 | errx(1, "xsignal_restart: called with signal %d", sig); | |||
473 | } | |||
474 | ||||
475 | return(xsignal_restart(sig, func, restartable)); | |||
476 | } |
--- src/usr.bin/ftp/progressbar.h 2009/04/12 10:18:52 1.8
+++ src/usr.bin/ftp/progressbar.h 2021/01/06 04:43:14 1.9
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: progressbar.h,v 1.8 2009/04/12 10:18:52 lukem Exp $ */ | 1 | /* $NetBSD: progressbar.h,v 1.9 2021/01/06 04:43:14 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Luke Mewburn. | 8 | * by Luke Mewburn. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -58,27 +58,26 @@ GLOBAL char *prefix; /* Text written | @@ -58,27 +58,26 @@ GLOBAL char *prefix; /* Text written | |||
58 | GLOBAL int fromatty; /* input is from a terminal */ | 58 | GLOBAL int fromatty; /* input is from a terminal */ | |
59 | GLOBAL int verbose; /* print messages coming back from server */ | 59 | GLOBAL int verbose; /* print messages coming back from server */ | |
60 | GLOBAL int quit_time; /* maximum time to wait if stalled */ | 60 | GLOBAL int quit_time; /* maximum time to wait if stalled */ | |
61 | 61 | |||
62 | GLOBAL const char *direction; /* direction transfer is occurring */ | 62 | GLOBAL const char *direction; /* direction transfer is occurring */ | |
63 | 63 | |||
64 | GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */ | 64 | GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */ | |
65 | #endif /* !STANDALONE_PROGRESS */ | 65 | #endif /* !STANDALONE_PROGRESS */ | |
66 | 66 | |||
67 | int foregroundproc(void); | 67 | int foregroundproc(void); | |
68 | void alarmtimer(int); | 68 | void alarmtimer(int); | |
69 | void progressmeter(int); | 69 | void progressmeter(int); | |
70 | sigfunc xsignal(int, sigfunc); | 70 | sigfunc xsignal(int, sigfunc); | |
71 | sigfunc xsignal_restart(int, sigfunc, int); | |||
72 | 71 | |||
73 | #ifndef STANDALONE_PROGRESS | 72 | #ifndef STANDALONE_PROGRESS | |
74 | void psummary(int); | 73 | void psummary(int); | |
75 | void ptransfer(int); | 74 | void ptransfer(int); | |
76 | #endif /* !STANDALONE_PROGRESS */ | 75 | #endif /* !STANDALONE_PROGRESS */ | |
77 | 76 | |||
78 | #ifdef NO_LONG_LONG | 77 | #ifdef NO_LONG_LONG | |
79 | # define LLF "%ld" | 78 | # define LLF "%ld" | |
80 | # define LLFP(x) "%" x "ld" | 79 | # define LLFP(x) "%" x "ld" | |
81 | # define LLT long | 80 | # define LLT long | |
82 | # define ULLF "%lu" | 81 | # define ULLF "%lu" | |
83 | # define ULLFP(x) "%" x "lu" | 82 | # define ULLFP(x) "%" x "lu" | |
84 | # define ULLT unsigned long | 83 | # define ULLT unsigned long |
--- src/usr.bin/ftp/ssl.c 2019/04/07 00:44:54 1.8
+++ src/usr.bin/ftp/ssl.c 2021/01/06 04:43:14 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ssl.c,v 1.8 2019/04/07 00:44:54 christos Exp $ */ | 1 | /* $NetBSD: ssl.c,v 1.9 2021/01/06 04:43:14 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav | 4 | * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav | |
5 | * Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg@NetBSD.org> | 5 | * Copyright (c) 2008, 2010 Joerg Sonnenberger <joerg@NetBSD.org> | |
6 | * Copyright (c) 2015 Thomas Klausner <wiz@NetBSD.org> | 6 | * Copyright (c) 2015 Thomas Klausner <wiz@NetBSD.org> | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer | 13 | * notice, this list of conditions and the following disclaimer | |
14 | * in this position and unchanged. | 14 | * in this position and unchanged. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | * | 31 | * | |
32 | * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $ | 32 | * $FreeBSD: common.c,v 1.53 2007/12/19 00:26:36 des Exp $ | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | #ifndef lint | 36 | #ifndef lint | |
37 | __RCSID("$NetBSD: ssl.c,v 1.8 2019/04/07 00:44:54 christos Exp $"); | 37 | __RCSID("$NetBSD: ssl.c,v 1.9 2021/01/06 04:43:14 lukem Exp $"); | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include <time.h> | 40 | #include <time.h> | |
41 | #include <unistd.h> | 41 | #include <unistd.h> | |
42 | #include <string.h> | 42 | #include <string.h> | |
43 | #include <fcntl.h> | 43 | #include <fcntl.h> | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/select.h> | 46 | #include <sys/select.h> | |
47 | #include <sys/uio.h> | 47 | #include <sys/uio.h> | |
48 | 48 | |||
49 | #include <netinet/tcp.h> | 49 | #include <netinet/tcp.h> | |
50 | #include <netinet/in.h> | 50 | #include <netinet/in.h> | |
@@ -346,26 +346,30 @@ fetch_cache_data(struct fetch_connect *c | @@ -346,26 +346,30 @@ fetch_cache_data(struct fetch_connect *c | |||
346 | static int | 346 | static int | |
347 | fetch_wait(struct fetch_connect *conn, ssize_t rlen, struct timeval *timeout) | 347 | fetch_wait(struct fetch_connect *conn, ssize_t rlen, struct timeval *timeout) | |
348 | { | 348 | { | |
349 | struct timeval now, delta; | 349 | struct timeval now, delta; | |
350 | int fd = conn->sd; | 350 | int fd = conn->sd; | |
351 | fd_set fds; | 351 | fd_set fds; | |
352 | 352 | |||
353 | FD_ZERO(&fds); | 353 | FD_ZERO(&fds); | |
354 | while (!FD_ISSET(fd, &fds)) { | 354 | while (!FD_ISSET(fd, &fds)) { | |
355 | FD_SET(fd, &fds); | 355 | FD_SET(fd, &fds); | |
356 | if (quit_time > 0) { | 356 | if (quit_time > 0) { | |
357 | gettimeofday(&now, NULL); | 357 | gettimeofday(&now, NULL); | |
358 | if (!timercmp(timeout, &now, >)) { | 358 | if (!timercmp(timeout, &now, >)) { | |
359 | fprintf(ttyout, "\r\n%s: transfer aborted" | |||
360 | " because stalled for %lu sec.\r\n", | |||
361 | getprogname(), (unsigned long)quit_time); | |||
362 | errno = ETIMEDOUT; | |||
359 | conn->iserr = ETIMEDOUT; | 363 | conn->iserr = ETIMEDOUT; | |
360 | return -1; | 364 | return -1; | |
361 | } | 365 | } | |
362 | timersub(timeout, &now, &delta); | 366 | timersub(timeout, &now, &delta); | |
363 | } | 367 | } | |
364 | errno = 0; | 368 | errno = 0; | |
365 | if (select(fd + 1, | 369 | if (select(fd + 1, | |
366 | rlen == FETCH_READ_WAIT ? &fds : NULL, | 370 | rlen == FETCH_READ_WAIT ? &fds : NULL, | |
367 | rlen == FETCH_WRITE_WAIT ? &fds : NULL, | 371 | rlen == FETCH_WRITE_WAIT ? &fds : NULL, | |
368 | NULL, quit_time > 0 ? &delta : NULL) < 0) { | 372 | NULL, quit_time > 0 ? &delta : NULL) < 0) { | |
369 | if (errno == EINTR) | 373 | if (errno == EINTR) | |
370 | continue; | 374 | continue; | |
371 | conn->iserr = errno; | 375 | conn->iserr = errno; |
--- src/usr.bin/ftp/version.h 2020/07/18 03:00:37 1.91
+++ src/usr.bin/ftp/version.h 2021/01/06 04:43:14 1.92
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: version.h,v 1.91 2020/07/18 03:00:37 lukem Exp $ */ | 1 | /* $NetBSD: version.h,v 1.92 2021/01/06 04:43:14 lukem Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999-2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999-2021 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Luke Mewburn. | 8 | * by Luke Mewburn. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -24,15 +24,15 @@ | @@ -24,15 +24,15 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #ifndef FTP_PRODUCT | 32 | #ifndef FTP_PRODUCT | |
33 | #define FTP_PRODUCT "NetBSD-ftp" | 33 | #define FTP_PRODUCT "NetBSD-ftp" | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #ifndef FTP_VERSION | 36 | #ifndef FTP_VERSION | |
37 | #define FTP_VERSION "20200718" | 37 | #define FTP_VERSION "20210106" | |
38 | #endif | 38 | #endif |